From 29ff3efebf8081c518b4bce191c625660f402bd2 Mon Sep 17 00:00:00 2001 From: Florent Castelli Date: Thu, 17 Feb 2022 16:23:56 +0100 Subject: [PATCH 001/847] Reland: Make dcSCTP the default SCTP implementation To disable dcSCTP and fallback to usrsctp, you can use the field trial WebRTC-DataChannel-Dcsctp/Disabled/ Also remove a hidden no-break space in dcSCTP logging causing issues in some log parsing. Bug: chromium:1243702 Change-Id: I46136a8913a6d803a3c63c710f3ed29523e4d773 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251867 Auto-Submit: Florent Castelli Reviewed-by: Victor Boivie Reviewed-by: Harald Alvestrand Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#36027} --- media/sctp/sctp_transport_factory.cc | 8 ++++---- media/sctp/sctp_transport_factory.h | 2 +- net/dcsctp/socket/dcsctp_socket.cc | 2 +- pc/data_channel_integrationtest.cc | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/media/sctp/sctp_transport_factory.cc b/media/sctp/sctp_transport_factory.cc index 5097d423d9..071d7fdb23 100644 --- a/media/sctp/sctp_transport_factory.cc +++ b/media/sctp/sctp_transport_factory.cc @@ -25,11 +25,11 @@ namespace cricket { SctpTransportFactory::SctpTransportFactory(rtc::Thread* network_thread) - : network_thread_(network_thread), use_dcsctp_("Enabled", false) { + : network_thread_(network_thread), use_usrsctp_("Disabled", false) { RTC_UNUSED(network_thread_); #ifdef WEBRTC_HAVE_DCSCTP - webrtc::ParseFieldTrial({&use_dcsctp_}, webrtc::field_trial::FindFullName( - "WebRTC-DataChannel-Dcsctp")); + webrtc::ParseFieldTrial({&use_usrsctp_}, webrtc::field_trial::FindFullName( + "WebRTC-DataChannel-Dcsctp")); #endif } @@ -38,7 +38,7 @@ SctpTransportFactory::CreateSctpTransport( rtc::PacketTransportInternal* transport) { std::unique_ptr result; #ifdef WEBRTC_HAVE_DCSCTP - if (use_dcsctp_.Get()) { + if (!use_usrsctp_.Get()) { result = std::unique_ptr(new webrtc::DcSctpTransport( network_thread_, transport, webrtc::Clock::GetRealTimeClock())); } diff --git a/media/sctp/sctp_transport_factory.h b/media/sctp/sctp_transport_factory.h index ed7c2163d7..9ae246a6a6 100644 --- a/media/sctp/sctp_transport_factory.h +++ b/media/sctp/sctp_transport_factory.h @@ -29,7 +29,7 @@ class SctpTransportFactory : public webrtc::SctpTransportFactoryInterface { private: rtc::Thread* network_thread_; - webrtc::FieldTrialFlag use_dcsctp_; + webrtc::FieldTrialFlag use_usrsctp_; }; } // namespace cricket diff --git a/net/dcsctp/socket/dcsctp_socket.cc b/net/dcsctp/socket/dcsctp_socket.cc index 9f38ad8aec..b93584ed47 100644 --- a/net/dcsctp/socket/dcsctp_socket.cc +++ b/net/dcsctp/socket/dcsctp_socket.cc @@ -196,7 +196,7 @@ DcSctpSocket::DcSctpSocket(absl::string_view log_prefix, [this]() { callbacks_.OnTotalBufferedAmountLow(); }) {} std::string DcSctpSocket::log_prefix() const { - return log_prefix_ + "[" + std::string(ToString(state_)) + "] "; + return log_prefix_ + "[" + std::string(ToString(state_)) + "] "; } bool DcSctpSocket::IsConsistent() const { diff --git a/pc/data_channel_integrationtest.cc b/pc/data_channel_integrationtest.cc index e6c06912f6..c0dbfdd4bf 100644 --- a/pc/data_channel_integrationtest.cc +++ b/pc/data_channel_integrationtest.cc @@ -832,7 +832,7 @@ TEST_P(DataChannelIntegrationTest, EXPECT_GT(202u, callee()->data_observer()->received_message_count()); EXPECT_LE(2u, callee()->data_observer()->received_message_count()); // Then, check that observed behavior (lose some messages) has not changed - if (webrtc::field_trial::IsEnabled("WebRTC-DataChannel-Dcsctp")) { + if (!webrtc::field_trial::IsDisabled("WebRTC-DataChannel-Dcsctp")) { // DcSctp loses all messages. This is correct. EXPECT_EQ(2u, callee()->data_observer()->received_message_count()); } else { From 18454b772026745e0294ba64c202a19acec60cd1 Mon Sep 17 00:00:00 2001 From: Sergey Silkin Date: Fri, 18 Feb 2022 11:54:28 +0100 Subject: [PATCH 002/847] Replace printf with RTC_LOG in YUV readers/writers Bug: none Change-Id: I70027a850b750067e0f7622fccfa724406974a1a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251866 Commit-Queue: Sergey Silkin Reviewed-by: Andrey Logvin Cr-Commit-Position: refs/heads/main@{#36028} --- test/testsupport/y4m_frame_reader.cc | 30 +++++++++++++++++----------- test/testsupport/y4m_frame_writer.cc | 13 ++++++------ test/testsupport/yuv_frame_reader.cc | 25 ++++++++++++++--------- test/testsupport/yuv_frame_writer.cc | 16 +++++++-------- 4 files changed, 47 insertions(+), 37 deletions(-) diff --git a/test/testsupport/y4m_frame_reader.cc b/test/testsupport/y4m_frame_reader.cc index 3f037a3b4b..6c34a2dd3e 100644 --- a/test/testsupport/y4m_frame_reader.cc +++ b/test/testsupport/y4m_frame_reader.cc @@ -14,6 +14,7 @@ #include "api/scoped_refptr.h" #include "api/video/i420_buffer.h" +#include "rtc_base/logging.h" #include "test/testsupport/file_utils.h" #include "test/testsupport/frame_reader.h" @@ -41,42 +42,47 @@ Y4mFrameReaderImpl::~Y4mFrameReaderImpl() { bool Y4mFrameReaderImpl::Init() { if (input_width_ <= 0 || input_height_ <= 0) { - fprintf(stderr, "Frame width and height must be >0, was %d x %d\n", - input_width_, input_height_); + RTC_LOG(LS_ERROR) << "Frame width and height must be positive. Was: " + << input_width_ << "x" << input_height_; return false; } input_file_ = fopen(input_filename_.c_str(), "rb"); if (input_file_ == nullptr) { - fprintf(stderr, "Couldn't open input file for reading: %s\n", - input_filename_.c_str()); + RTC_LOG(LS_ERROR) << "Couldn't open input file: " + << input_filename_.c_str(); return false; } size_t source_file_size = GetFileSize(input_filename_); if (source_file_size <= 0u) { - fprintf(stderr, "Found empty file: %s\n", input_filename_.c_str()); + RTC_LOG(LS_ERROR) << "Input file " << input_filename_.c_str() + << " is empty."; return false; } if (fread(buffer_, 1, kFileHeaderSize, input_file_) < kFileHeaderSize) { - fprintf(stderr, "Failed to read file header from input file: %s\n", - input_filename_.c_str()); + RTC_LOG(LS_ERROR) << "Couldn't read Y4M header from input file: " + << input_filename_.c_str(); return false; } - // Calculate total number of frames. + number_of_frames_ = static_cast((source_file_size - kFileHeaderSize) / frame_length_in_bytes_); + + if (number_of_frames_ == 0) { + RTC_LOG(LS_ERROR) << "Input file " << input_filename_.c_str() + << " is too small."; + } return true; } rtc::scoped_refptr Y4mFrameReaderImpl::ReadFrame() { if (input_file_ == nullptr) { - fprintf(stderr, - "Y4mFrameReaderImpl is not initialized (input file is NULL)\n"); + RTC_LOG(LS_ERROR) << "Y4mFrameReaderImpl is not initialized."; return nullptr; } if (fread(buffer_, 1, kFrameHeaderSize, input_file_) < kFrameHeaderSize && ferror(input_file_)) { - fprintf(stderr, "Failed to read frame header from input file: %s\n", - input_filename_.c_str()); + RTC_LOG(LS_ERROR) << "Couldn't read frame header from input file: " + << input_filename_.c_str(); return nullptr; } return YuvFrameReaderImpl::ReadFrame(); diff --git a/test/testsupport/y4m_frame_writer.cc b/test/testsupport/y4m_frame_writer.cc index 896524fa0c..1bb4543963 100644 --- a/test/testsupport/y4m_frame_writer.cc +++ b/test/testsupport/y4m_frame_writer.cc @@ -8,11 +8,11 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include #include #include +#include "rtc_base/logging.h" #include "test/testsupport/frame_writer.h" namespace webrtc { @@ -34,8 +34,8 @@ bool Y4mFrameWriterImpl::Init() { int bytes_written = fprintf(output_file_, "YUV4MPEG2 W%d H%d F%d:1 C420\n", width_, height_, frame_rate_); if (bytes_written < 0) { - fprintf(stderr, "Failed to write Y4M file header to file %s\n", - output_filename_.c_str()); + RTC_LOG(LS_ERROR) << "Failed to write Y4M file header to file: " + << output_filename_.c_str(); return false; } return true; @@ -43,14 +43,13 @@ bool Y4mFrameWriterImpl::Init() { bool Y4mFrameWriterImpl::WriteFrame(const uint8_t* frame_buffer) { if (output_file_ == nullptr) { - fprintf(stderr, - "Y4mFrameWriterImpl is not initialized (output file is NULL)\n"); + RTC_LOG(LS_ERROR) << "Y4mFrameWriterImpl is not initialized."; return false; } int bytes_written = fprintf(output_file_, "FRAME\n"); if (bytes_written < 0) { - fprintf(stderr, "Failed to write Y4M frame header to file %s\n", - output_filename_.c_str()); + RTC_LOG(LS_ERROR) << "Couldn't write Y4M frame header to file: " + << output_filename_.c_str(); return false; } return YuvFrameWriterImpl::WriteFrame(frame_buffer); diff --git a/test/testsupport/yuv_frame_reader.cc b/test/testsupport/yuv_frame_reader.cc index fca982bf34..330541496b 100644 --- a/test/testsupport/yuv_frame_reader.cc +++ b/test/testsupport/yuv_frame_reader.cc @@ -14,6 +14,7 @@ #include "api/scoped_refptr.h" #include "api/video/i420_buffer.h" +#include "rtc_base/logging.h" #include "test/frame_utils.h" #include "test/testsupport/file_utils.h" #include "test/testsupport/frame_reader.h" @@ -86,32 +87,38 @@ YuvFrameReaderImpl::~YuvFrameReaderImpl() { bool YuvFrameReaderImpl::Init() { if (input_width_ <= 0 || input_height_ <= 0) { - fprintf(stderr, "Frame width and height must be >0, was %d x %d\n", - input_width_, input_height_); + RTC_LOG(LS_ERROR) << "Frame width and height must be positive. Was: " + << input_width_ << "x" << input_height_; return false; } input_file_ = fopen(input_filename_.c_str(), "rb"); if (input_file_ == nullptr) { - fprintf(stderr, "Couldn't open input file for reading: %s\n", - input_filename_.c_str()); + RTC_LOG(LS_ERROR) << "Couldn't open input file: " + << input_filename_.c_str(); return false; } // Calculate total number of frames. size_t source_file_size = GetFileSize(input_filename_); if (source_file_size <= 0u) { - fprintf(stderr, "Found empty file: %s\n", input_filename_.c_str()); + RTC_LOG(LS_ERROR) << "Input file " << input_filename_.c_str() + << " is empty."; return false; } number_of_frames_ = static_cast(source_file_size / frame_length_in_bytes_); + + if (number_of_frames_ == 0) { + RTC_LOG(LS_ERROR) << "Input file " << input_filename_.c_str() + << " is too small."; + } + current_frame_index_ = 0; return true; } rtc::scoped_refptr YuvFrameReaderImpl::ReadFrame() { if (input_file_ == nullptr) { - fprintf(stderr, - "YuvFrameReaderImpl is not initialized (input file is NULL)\n"); + RTC_LOG(LS_ERROR) << "YuvFrameReaderImpl is not initialized."; return nullptr; } @@ -142,8 +149,8 @@ rtc::scoped_refptr YuvFrameReaderImpl::ReadFrame() { buffer = ReadI420Buffer(input_width_, input_height_, input_file_); if (!buffer && ferror(input_file_)) { - fprintf(stderr, "Error reading from input file: %s\n", - input_filename_.c_str()); + RTC_LOG(LS_ERROR) << "Couldn't read frame from file: " + << input_filename_.c_str(); } } while (dropper_ && dropper_->UpdateLevel() == DropperUtil::DropDecision::kDropframe); diff --git a/test/testsupport/yuv_frame_writer.cc b/test/testsupport/yuv_frame_writer.cc index 59cb74ebeb..e5e0a6ba7f 100644 --- a/test/testsupport/yuv_frame_writer.cc +++ b/test/testsupport/yuv_frame_writer.cc @@ -8,12 +8,12 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include #include #include #include "rtc_base/checks.h" +#include "rtc_base/logging.h" #include "test/testsupport/frame_writer.h" namespace webrtc { @@ -34,8 +34,7 @@ YuvFrameWriterImpl::~YuvFrameWriterImpl() { bool YuvFrameWriterImpl::Init() { if (width_ <= 0 || height_ <= 0) { - fprintf(stderr, "Frame width and height must be >0, was %d x %d\n", width_, - height_); + RTC_LOG(LS_ERROR) << "Frame width and height must be positive."; return false; } frame_length_in_bytes_ = @@ -43,8 +42,8 @@ bool YuvFrameWriterImpl::Init() { output_file_ = fopen(output_filename_.c_str(), "wb"); if (output_file_ == nullptr) { - fprintf(stderr, "Couldn't open output file for writing: %s\n", - output_filename_.c_str()); + RTC_LOG(LS_ERROR) << "Couldn't open output file: " + << output_filename_.c_str(); return false; } return true; @@ -53,15 +52,14 @@ bool YuvFrameWriterImpl::Init() { bool YuvFrameWriterImpl::WriteFrame(const uint8_t* frame_buffer) { RTC_DCHECK(frame_buffer); if (output_file_ == nullptr) { - fprintf(stderr, - "YuvFrameWriterImpl is not initialized (output file is NULL)\n"); + RTC_LOG(LS_ERROR) << "YuvFrameWriterImpl is not initialized."; return false; } size_t bytes_written = fwrite(frame_buffer, 1, frame_length_in_bytes_, output_file_); if (bytes_written != frame_length_in_bytes_) { - fprintf(stderr, "Failed to write %zu bytes to file %s\n", - frame_length_in_bytes_, output_filename_.c_str()); + RTC_LOG(LS_ERROR) << "Cound't write frame to file: " + << output_filename_.c_str(); return false; } return true; From d15f3e1220549d30cd2ab6063208ff022b67d3fd Mon Sep 17 00:00:00 2001 From: Jeremy Leconte Date: Fri, 18 Feb 2022 10:16:32 +0100 Subject: [PATCH 003/847] Prepare the code to run ios tests with the standalone recipe. The flags isolated-script-test-output and isolated-script-test-perf-output need to be consumed by the tests. The generated .app folder in added in the data list of the gni file. This will make it available in the runtime_deps file and thus will be populated to the swarming tasks. Bug: webrtc:13556 Change-Id: I2c75774b847d9f686c3abc00ba0400bbc3fcefae Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/240520 Reviewed-by: Artem Titov Reviewed-by: Christoffer Jansson Reviewed-by: Mirko Bonadei Commit-Queue: Jeremy Leconte Cr-Commit-Position: refs/heads/main@{#36029} --- test/test_main_lib.cc | 4 +--- tools_webrtc/mb/mb.py | 7 +++++++ webrtc.gni | 9 +++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/test/test_main_lib.cc b/test/test_main_lib.cc index 6e5cff175a..ea3b714ffd 100644 --- a/test/test_main_lib.cc +++ b/test/test_main_lib.cc @@ -57,7 +57,7 @@ ABSL_FLAG( "described by histogram.proto in " "https://chromium.googlesource.com/catapult/."); -#else +#endif ABSL_FLAG(std::string, isolated_script_test_output, @@ -72,8 +72,6 @@ ABSL_FLAG( "described by histogram.proto in " "https://chromium.googlesource.com/catapult/."); -#endif - constexpr char kPlotAllMetrics[] = "all"; ABSL_FLAG(std::vector, plot, diff --git a/tools_webrtc/mb/mb.py b/tools_webrtc/mb/mb.py index d1869135b1..bbb5b6f472 100755 --- a/tools_webrtc/mb/mb.py +++ b/tools_webrtc/mb/mb.py @@ -900,6 +900,7 @@ def GetSwarmingCommand(self, target, vals): is_android = 'target_os="android"' in vals['gn_args'] is_linux = self.platform.startswith('linux') and not is_android + is_ios = 'target_os="ios"' in vals['gn_args'] if test_type == 'nontest': self.WriteFailureAndRaise('We should not be isolating %s.' % target, @@ -932,6 +933,12 @@ def GetSwarmingCommand(self, target, vals): '--logcat-output-file', '${ISOLATED_OUTDIR}/logcats', '--store-tombstones' ] + elif is_ios: + cmdline += [ + vpython_exe, '../../tools_webrtc/flags_compatibility.py', + 'bin/run_%s' % target, '--out-dir', '${ISOLATED_OUTDIR}' + ] + extra_files.append('../../tools_webrtc/flags_compatibility.py') else: if test_type == 'raw': cmdline += [vpython_exe, '../../tools_webrtc/flags_compatibility.py'] diff --git a/webrtc.gni b/webrtc.gni index 6e81fc4285..8040f628d9 100644 --- a/webrtc.gni +++ b/webrtc.gni @@ -530,6 +530,15 @@ template("rtc_test") { [ "//third_party/llvm-build/Release+Asserts/lib/libstdc++.so.6" ] } } + # TODO(crbug.com/webrtc/13556): Adding the .app folder in the runtime_deps + # shoulnd't be necessary. this code should be removed and the same solution + # as Chromium should be used. + if (is_ios) { + if (!defined(invoker.data)) { + data = [] + } + data += [ "${root_out_dir}/${target_name}.app" ] + } } } From 8968bcae8df3d9b1391d843f3892d369e5e128bc Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Fri, 18 Feb 2022 17:01:26 +0100 Subject: [PATCH 004/847] In RtcpTransceiver avoid generating rtcp sender reports for inactive senders Bug: webrtc:8239 Change-Id: I97d50c628db04c56669179ab7039a3fe3bd61d34 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251901 Reviewed-by: Emil Lundmark Commit-Queue: Danil Chapovalov Cr-Commit-Position: refs/heads/main@{#36030} --- .../rtp_rtcp/source/rtcp_transceiver_impl.cc | 12 ++++ .../source/rtcp_transceiver_impl_unittest.cc | 65 +++++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/modules/rtp_rtcp/source/rtcp_transceiver_impl.cc b/modules/rtp_rtcp/source/rtcp_transceiver_impl.cc index 94451efcd7..c075b2f99e 100644 --- a/modules/rtp_rtcp/source/rtcp_transceiver_impl.cc +++ b/modules/rtp_rtcp/source/rtcp_transceiver_impl.cc @@ -56,6 +56,7 @@ struct RtcpTransceiverImpl::RemoteSenderState { struct RtcpTransceiverImpl::LocalSenderState { uint32_t ssrc; + size_t last_num_sent_bytes = 0; RtpStreamRtcpHandler* handler = nullptr; }; @@ -527,6 +528,17 @@ RtcpTransceiverImpl::CompoundPacketInfo RtcpTransceiverImpl::FillReports( LocalSenderState& rtp_sender = *it; RtpStreamRtcpHandler::RtpStats stats = rtp_sender.handler->SentStats(); + if (stats.num_sent_bytes() < rtp_sender.last_num_sent_bytes) { + RTC_LOG(LS_ERROR) << "Inconsistent SR for SSRC " << rtp_sender.ssrc + << ". Number of total sent bytes decreased."; + rtp_sender.last_num_sent_bytes = 0; + } + if (stats.num_sent_bytes() == rtp_sender.last_num_sent_bytes) { + // Skip because no RTP packet was send for this SSRC since last report. + continue; + } + rtp_sender.last_num_sent_bytes = stats.num_sent_bytes(); + last_handled_sender_it = it; rtcp::SenderReport sender_report; sender_report.SetSenderSsrc(rtp_sender.ssrc); diff --git a/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc b/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc index 0a69d29df4..417dcdd3de 100644 --- a/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc @@ -69,7 +69,21 @@ class MockMediaReceiverRtcpObserver : public MediaReceiverRtcpObserver { class MockRtpStreamRtcpHandler : public RtpStreamRtcpHandler { public: + MockRtpStreamRtcpHandler() { + // With each next call increase number of sent packets and bytes to simulate + // active RTP sender. + ON_CALL(*this, SentStats).WillByDefault([this] { + RtpStats stats; + stats.set_num_sent_packets(++num_calls_); + stats.set_num_sent_bytes(1'000 * num_calls_); + return stats; + }); + } + MOCK_METHOD(RtpStats, SentStats, (), (override)); + + private: + int num_calls_ = 0; }; class MockNetworkLinkRtcpObserver : public NetworkLinkRtcpObserver { @@ -1472,5 +1486,56 @@ TEST(RtcpTransceiverImplTest, RotatesSendersWhenAllSenderReportDoNotFit) { } } +TEST(RtcpTransceiverImplTest, SkipsSenderReportForInactiveSender) { + static constexpr uint32_t kSenderSsrc[] = {12345, 23456}; + RtcpTransceiverConfig config = DefaultTestConfig(); + RtcpPacketParser rtcp_parser; + RtcpParserTransport transport(&rtcp_parser); + config.outgoing_transport = &transport; + RtcpTransceiverImpl rtcp_transceiver(config); + + RtpStreamRtcpHandler::RtpStats sender_stats[2]; + NiceMock sender[2]; + ON_CALL(sender[0], SentStats).WillByDefault([&] { return sender_stats[0]; }); + ON_CALL(sender[1], SentStats).WillByDefault([&] { return sender_stats[1]; }); + rtcp_transceiver.AddMediaSender(kSenderSsrc[0], &sender[0]); + rtcp_transceiver.AddMediaSender(kSenderSsrc[1], &sender[1]); + + // Start with both senders beeing active. + sender_stats[0].set_num_sent_packets(10); + sender_stats[0].set_num_sent_bytes(1'000); + sender_stats[1].set_num_sent_packets(5); + sender_stats[1].set_num_sent_bytes(2'000); + rtcp_transceiver.SendCompoundPacket(); + EXPECT_EQ(transport.num_packets(), 1); + EXPECT_EQ(rtcp_parser.sender_report()->num_packets(), 2); + + // Keep 1st sender active, but make 2nd second look inactive by returning the + // same RtpStats. + sender_stats[0].set_num_sent_packets(15); + sender_stats[0].set_num_sent_bytes(2'000); + rtcp_transceiver.SendCompoundPacket(); + EXPECT_EQ(transport.num_packets(), 2); + EXPECT_EQ(rtcp_parser.sender_report()->num_packets(), 3); + EXPECT_EQ(rtcp_parser.sender_report()->sender_ssrc(), kSenderSsrc[0]); + + // Swap active sender. + sender_stats[1].set_num_sent_packets(20); + sender_stats[1].set_num_sent_bytes(3'000); + rtcp_transceiver.SendCompoundPacket(); + EXPECT_EQ(transport.num_packets(), 3); + EXPECT_EQ(rtcp_parser.sender_report()->num_packets(), 4); + EXPECT_EQ(rtcp_parser.sender_report()->sender_ssrc(), kSenderSsrc[1]); + + // Activate both senders again. + sender_stats[0].set_num_sent_packets(20); + sender_stats[0].set_num_sent_bytes(3'000); + sender_stats[1].set_num_sent_packets(25); + sender_stats[1].set_num_sent_bytes(3'500); + rtcp_transceiver.SendCompoundPacket(); + EXPECT_EQ(transport.num_packets(), 4); + EXPECT_EQ(rtcp_parser.sender_report()->num_packets(), 6); +} + } // namespace } // namespace webrtc From feac97bb251488bb426406afa0873627d1254db1 Mon Sep 17 00:00:00 2001 From: Alessio Bazzica Date: Fri, 11 Feb 2022 10:46:15 +0100 Subject: [PATCH 005/847] AgcManagerDirect: improve AgcMinMicLevelExperimentEnabled50 test Also test the field trial with valid parameter and non-empty suffix. Bug: webrtc:7494 Change-Id: I3d871b41dd71c951ac56e180b3c09cda4c3627d4 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251441 Reviewed-by: Hanna Silen Commit-Queue: Alessio Bazzica Cr-Commit-Position: refs/heads/main@{#36031} --- .../agc/agc_manager_direct_unittest.cc | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/modules/audio_processing/agc/agc_manager_direct_unittest.cc b/modules/audio_processing/agc/agc_manager_direct_unittest.cc index d727449229..5c9b383f78 100644 --- a/modules/audio_processing/agc/agc_manager_direct_unittest.cc +++ b/modules/audio_processing/agc/agc_manager_direct_unittest.cc @@ -128,13 +128,15 @@ void CallPreProcessAudioBuffer(int num_calls, } } -std::string GetAgcMinMicLevelExperimentFieldTrial(int enabled_value) { +std::string GetAgcMinMicLevelExperimentFieldTrial( + int enabled_value, + const std::string& suffix = "") { RTC_DCHECK_GE(enabled_value, 0); RTC_DCHECK_LE(enabled_value, 255); char field_trial_buffer[64]; rtc::SimpleStringBuilder builder(field_trial_buffer); builder << "WebRTC-Audio-AgcMinMicLevelExperiment/Enabled-" << enabled_value - << "/"; + << suffix << "/"; return builder.str(); } @@ -883,13 +885,16 @@ TEST(AgcManagerDirectStandaloneTest, AgcMinMicLevelExperiment) { } TEST(AgcManagerDirectStandaloneTest, AgcMinMicLevelExperimentDisabled) { - test::ScopedFieldTrials field_trial( - "WebRTC-Audio-AgcMinMicLevelExperiment/Disabled/"); - std::unique_ptr manager = - CreateAgcManagerDirect(kInitialVolume, kClippedLevelStep, - kClippedRatioThreshold, kClippedWaitFrames); - EXPECT_EQ(manager->channel_agcs_[0]->min_mic_level(), kMinMicLevel); - EXPECT_EQ(manager->channel_agcs_[0]->startup_min_level(), kInitialVolume); + for (const std::string& field_trial_suffix : {"", "_20220210"}) { + test::ScopedFieldTrials field_trial( + "WebRTC-Audio-AgcMinMicLevelExperiment/Disabled" + field_trial_suffix + + "/"); + std::unique_ptr manager = + CreateAgcManagerDirect(kInitialVolume, kClippedLevelStep, + kClippedRatioThreshold, kClippedWaitFrames); + EXPECT_EQ(manager->channel_agcs_[0]->min_mic_level(), kMinMicLevel); + EXPECT_EQ(manager->channel_agcs_[0]->startup_min_level(), kInitialVolume); + } } // Checks that a field-trial parameter outside of the valid range [0,255] is @@ -921,13 +926,16 @@ TEST(AgcManagerDirectStandaloneTest, AgcMinMicLevelExperimentOutOfRangeBelow) { // changed. TEST(AgcManagerDirectStandaloneTest, AgcMinMicLevelExperimentEnabled50) { constexpr int kMinMicLevelOverride = 50; - test::ScopedFieldTrials field_trial( - GetAgcMinMicLevelExperimentFieldTrial(kMinMicLevelOverride)); - std::unique_ptr manager = - CreateAgcManagerDirect(kInitialVolume, kClippedLevelStep, - kClippedRatioThreshold, kClippedWaitFrames); - EXPECT_EQ(manager->channel_agcs_[0]->min_mic_level(), kMinMicLevelOverride); - EXPECT_EQ(manager->channel_agcs_[0]->startup_min_level(), kInitialVolume); + for (const std::string& field_trial_suffix : {"", "_20220210"}) { + SCOPED_TRACE(field_trial_suffix); + test::ScopedFieldTrials field_trial(GetAgcMinMicLevelExperimentFieldTrial( + kMinMicLevelOverride, field_trial_suffix)); + std::unique_ptr manager = + CreateAgcManagerDirect(kInitialVolume, kClippedLevelStep, + kClippedRatioThreshold, kClippedWaitFrames); + EXPECT_EQ(manager->channel_agcs_[0]->min_mic_level(), kMinMicLevelOverride); + EXPECT_EQ(manager->channel_agcs_[0]->startup_min_level(), kInitialVolume); + } } // Checks that, when the "WebRTC-Audio-AgcMinMicLevelExperiment" field trial is From 39f027e0b05c763630d4e950a8648933828fe9bc Mon Sep 17 00:00:00 2001 From: Tommi Date: Sat, 19 Feb 2022 14:13:35 +0100 Subject: [PATCH 006/847] Add .mailmap for git. This is purely to aid with `git log` type statements that allows for grouping different display names for the same address. No-try: true Bug: none Change-Id: I6b0af50eac356aa864e1387f3f35c3270c211faf Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251941 Auto-Submit: Tomas Gunnarsson Reviewed-by: Mirko Bonadei Commit-Queue: Mirko Bonadei Cr-Commit-Position: refs/heads/main@{#36032} --- .mailmap | 1 + 1 file changed, 1 insertion(+) create mode 100644 .mailmap diff --git a/.mailmap b/.mailmap new file mode 100644 index 0000000000..634f3a6ac5 --- /dev/null +++ b/.mailmap @@ -0,0 +1 @@ +Tommi Tomas Gunnarsson From 0b06552ab332ca5e1473b6193abd90d6527ebd21 Mon Sep 17 00:00:00 2001 From: Byoungchan Lee Date: Fri, 18 Feb 2022 09:52:11 +0900 Subject: [PATCH 007/847] Android: Respect input buffer layout of MediaFormat On Android, MediaCodec can request a specific layout of the input buffer. One can use the stride and slice height to calculate the layout from the Encoder's MediaFormat. The current code assumes a specific layout, which is a problematic in Android 12. Fix this by honoring the stride and slice-height. Bug: webrtc:13427 Change-Id: I2d3e429309e3add3ae668e0390460b51e6a49eb9 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/240680 Reviewed-by: Niels Moller Reviewed-by: Harald Alvestrand Commit-Queue: Daniel.L (Byoungchan) Lee Cr-Commit-Position: refs/heads/main@{#36033} --- sdk/android/api/org/webrtc/YuvHelper.java | 115 +++++++++++++----- .../src/org/webrtc/YuvHelperTest.java | 35 ++++++ .../java/org/webrtc/HardwareVideoEncoder.java | 52 +++++++- .../java/org/webrtc/MediaCodecWrapper.java | 2 + .../webrtc/MediaCodecWrapperFactoryImpl.java | 5 + .../org/webrtc/AndroidVideoDecoderTest.java | 3 +- .../src/org/webrtc/FakeMediaCodecWrapper.java | 9 +- .../org/webrtc/HardwareVideoEncoderTest.java | 3 +- 8 files changed, 183 insertions(+), 41 deletions(-) diff --git a/sdk/android/api/org/webrtc/YuvHelper.java b/sdk/android/api/org/webrtc/YuvHelper.java index 83bd7dcbb4..afb8e837d1 100644 --- a/sdk/android/api/org/webrtc/YuvHelper.java +++ b/sdk/android/api/org/webrtc/YuvHelper.java @@ -14,55 +14,93 @@ /** Wraps libyuv methods to Java. All passed byte buffers must be direct byte buffers. */ public class YuvHelper { - /** Helper method for copying I420 to tightly packed destination buffer. */ + /** + * Copy I420 Buffer to a contiguously allocated buffer. + *

In Android, MediaCodec can request a buffer of a specific layout with the stride and + * slice-height (or plane height), and this function is used in this case. + *

For more information, see + * https://cs.android.com/android/platform/superproject/+/64fea7e5726daebc40f46890100837c01091100d:frameworks/base/media/java/android/media/MediaFormat.java;l=568 + * @param dstStrideY the stride of output buffers' Y plane. + * @param dstSliceHeightY the slice-height of output buffer's Y plane. + * @param dstStrideU the stride of output buffers' U (and V) plane. + * @param dstSliceHeightU the slice-height of output buffer's U (and V) plane + */ public static void I420Copy(ByteBuffer srcY, int srcStrideY, ByteBuffer srcU, int srcStrideU, - ByteBuffer srcV, int srcStrideV, ByteBuffer dst, int width, int height) { - final int chromaHeight = (height + 1) / 2; - final int chromaWidth = (width + 1) / 2; - - final int minSize = width * height + chromaWidth * chromaHeight * 2; - if (dst.capacity() < minSize) { + ByteBuffer srcV, int srcStrideV, ByteBuffer dst, int dstWidth, int dstHeight, int dstStrideY, + int dstSliceHeightY, int dstStrideU, int dstSliceHeightU) { + final int chromaWidth = (dstWidth + 1) / 2; + final int chromaHeight = (dstHeight + 1) / 2; + + final int dstStartY = 0; + final int dstEndY = dstStartY + dstStrideY * dstHeight; + final int dstStartU = dstStartY + dstStrideY * dstSliceHeightY; + final int dstEndU = dstStartU + dstStrideU * chromaHeight; + final int dstStartV = dstStartU + dstStrideU * dstSliceHeightU; + // The last line doesn't need any padding, so use chromaWidth + // to calculate the exact end position. + final int dstEndV = dstStartV + dstStrideU * (chromaHeight - 1) + chromaWidth; + if (dst.capacity() < dstEndV) { throw new IllegalArgumentException("Expected destination buffer capacity to be at least " - + minSize + " was " + dst.capacity()); + + dstEndV + " was " + dst.capacity()); } - final int startY = 0; - final int startU = height * width; - final int startV = startU + chromaHeight * chromaWidth; - - dst.position(startY); + dst.limit(dstEndY); + dst.position(dstStartY); final ByteBuffer dstY = dst.slice(); - dst.position(startU); + dst.limit(dstEndU); + dst.position(dstStartU); final ByteBuffer dstU = dst.slice(); - dst.position(startV); + dst.limit(dstEndV); + dst.position(dstStartV); final ByteBuffer dstV = dst.slice(); - nativeI420Copy(srcY, srcStrideY, srcU, srcStrideU, srcV, srcStrideV, dstY, width, dstU, - chromaWidth, dstV, chromaWidth, width, height); + I420Copy(srcY, srcStrideY, srcU, srcStrideU, srcV, srcStrideV, dstY, dstStrideY, dstU, + dstStrideU, dstV, dstStrideU, dstWidth, dstHeight); } - /** Helper method for copying I420 to tightly packed NV12 destination buffer. */ - public static void I420ToNV12(ByteBuffer srcY, int srcStrideY, ByteBuffer srcU, int srcStrideU, - ByteBuffer srcV, int srcStrideV, ByteBuffer dst, int width, int height) { - final int chromaWidth = (width + 1) / 2; - final int chromaHeight = (height + 1) / 2; + /** Helper method for copying I420 to tightly packed destination buffer. */ + public static void I420Copy(ByteBuffer srcY, int srcStrideY, ByteBuffer srcU, int srcStrideU, + ByteBuffer srcV, int srcStrideV, ByteBuffer dst, int dstWidth, int dstHeight) { + I420Copy(srcY, srcStrideY, srcU, srcStrideU, srcV, srcStrideV, dst, dstWidth, dstHeight, + dstWidth, dstHeight, (dstWidth + 1) / 2, (dstHeight + 1) / 2); + } - final int minSize = width * height + chromaWidth * chromaHeight * 2; - if (dst.capacity() < minSize) { + /** + * Copy I420 Buffer to a contiguously allocated buffer. + * @param dstStrideY the stride of output buffers' Y plane. + * @param dstSliceHeightY the slice-height of output buffer's Y plane. + */ + public static void I420ToNV12(ByteBuffer srcY, int srcStrideY, ByteBuffer srcU, int srcStrideU, + ByteBuffer srcV, int srcStrideV, ByteBuffer dst, int dstWidth, int dstHeight, int dstStrideY, + int dstSliceHeightY) { + final int chromaHeight = (dstHeight + 1) / 2; + final int chromaWidth = (dstWidth + 1) / 2; + + final int dstStartY = 0; + final int dstEndY = dstStartY + dstStrideY * dstHeight; + final int dstStartUV = dstStartY + dstStrideY * dstSliceHeightY; + final int dstEndUV = dstStartUV + chromaWidth * chromaHeight * 2; + if (dst.capacity() < dstEndUV) { throw new IllegalArgumentException("Expected destination buffer capacity to be at least " - + minSize + " was " + dst.capacity()); + + dstEndUV + " was " + dst.capacity()); } - final int startY = 0; - final int startUV = height * width; - - dst.position(startY); + dst.limit(dstEndY); + dst.position(dstStartY); final ByteBuffer dstY = dst.slice(); - dst.position(startUV); + dst.limit(dstEndUV); + dst.position(dstStartUV); final ByteBuffer dstUV = dst.slice(); - nativeI420ToNV12(srcY, srcStrideY, srcU, srcStrideU, srcV, srcStrideV, dstY, width, dstUV, - chromaWidth * 2, width, height); + I420ToNV12(srcY, srcStrideY, srcU, srcStrideU, srcV, srcStrideV, dstY, dstStrideY, dstUV, + chromaWidth * 2, dstWidth, dstHeight); + } + + /** Helper method for copying I420 to tightly packed NV12 destination buffer. */ + public static void I420ToNV12(ByteBuffer srcY, int srcStrideY, ByteBuffer srcU, int srcStrideU, + ByteBuffer srcV, int srcStrideV, ByteBuffer dst, int dstWidth, int dstHeight) { + I420ToNV12(srcY, srcStrideY, srcU, srcStrideU, srcV, srcStrideV, dst, dstWidth, dstHeight, + dstWidth, dstHeight); } /** Helper method for rotating I420 to tightly packed destination buffer. */ @@ -109,9 +147,18 @@ public static void ABGRToI420(ByteBuffer src, int srcStride, ByteBuffer dstY, in src, srcStride, dstY, dstStrideY, dstU, dstStrideU, dstV, dstStrideV, width, height); } + /** + * Copies I420 to the I420 dst buffer. + *

Unlike `libyuv::I420Copy`, this function checks if the height <= 0, so flipping is not + * supported. + */ public static void I420Copy(ByteBuffer srcY, int srcStrideY, ByteBuffer srcU, int srcStrideU, ByteBuffer srcV, int srcStrideV, ByteBuffer dstY, int dstStrideY, ByteBuffer dstU, int dstStrideU, ByteBuffer dstV, int dstStrideV, int width, int height) { + if (srcY == null || srcU == null || srcV == null || dstY == null || dstU == null || dstV == null + || width <= 0 || height <= 0) { + throw new IllegalArgumentException("Invalid I420Copy input arguments"); + } nativeI420Copy(srcY, srcStrideY, srcU, srcStrideU, srcV, srcStrideV, dstY, dstStrideY, dstU, dstStrideU, dstV, dstStrideV, width, height); } @@ -119,6 +166,10 @@ public static void I420Copy(ByteBuffer srcY, int srcStrideY, ByteBuffer srcU, in public static void I420ToNV12(ByteBuffer srcY, int srcStrideY, ByteBuffer srcU, int srcStrideU, ByteBuffer srcV, int srcStrideV, ByteBuffer dstY, int dstStrideY, ByteBuffer dstUV, int dstStrideUV, int width, int height) { + if (srcY == null || srcU == null || srcV == null || dstY == null || dstUV == null || width <= 0 + || height <= 0) { + throw new IllegalArgumentException("Invalid I420ToNV12 input arguments"); + } nativeI420ToNV12(srcY, srcStrideY, srcU, srcStrideU, srcV, srcStrideV, dstY, dstStrideY, dstUV, dstStrideUV, width, height); } diff --git a/sdk/android/instrumentationtests/src/org/webrtc/YuvHelperTest.java b/sdk/android/instrumentationtests/src/org/webrtc/YuvHelperTest.java index 693bdd4a79..0a63bd7634 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/YuvHelperTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/YuvHelperTest.java @@ -101,6 +101,25 @@ public void testI420CopyTight() { new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 51, 52, 53, 54, 101, 102, 105, 106}, dst); } + @SmallTest + @Test + public void testI420CopyStride() { + final int dstStrideY = 4; + final int dstSliceHeightY = 4; + final int dstStrideU = dstStrideY / 2; + final int dstSliceHeightU = dstSliceHeightY / 2; + final int dstSize = dstStrideY * dstStrideY * 3 / 2; + + final ByteBuffer dst = ByteBuffer.allocateDirect(dstSize); + YuvHelper.I420Copy(TEST_I420_Y, TEST_I420_STRIDE_Y, TEST_I420_U, TEST_I420_STRIDE_V, + TEST_I420_V, TEST_I420_STRIDE_U, dst, TEST_WIDTH, TEST_HEIGHT, dstStrideY, dstSliceHeightY, + dstStrideU, dstSliceHeightU); + + assertByteBufferContentEquals(new byte[] {1, 2, 3, 0, 4, 5, 6, 0, 7, 8, 9, 0, 0, 0, 0, 0, 51, + 52, 53, 54, 101, 102, 105, 106}, + dst); + } + @SmallTest @Test public void testI420ToNV12() { @@ -132,6 +151,22 @@ public void testI420ToNV12Tight() { new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 51, 101, 52, 102, 53, 105, 54, 106}, dst); } + @SmallTest + @Test + public void testI420ToNV12Stride() { + final int dstStrideY = 4; + final int dstSliceHeightY = 4; + final int dstSize = dstStrideY * dstStrideY * 3 / 2; + + final ByteBuffer dst = ByteBuffer.allocateDirect(dstSize); + YuvHelper.I420ToNV12(TEST_I420_Y, TEST_I420_STRIDE_Y, TEST_I420_U, TEST_I420_STRIDE_V, + TEST_I420_V, TEST_I420_STRIDE_U, dst, TEST_WIDTH, TEST_HEIGHT, dstStrideY, dstSliceHeightY); + + assertByteBufferContentEquals(new byte[] {1, 2, 3, 0, 4, 5, 6, 0, 7, 8, 9, 0, 0, 0, 0, 0, 51, + 101, 52, 102, 53, 105, 54, 106}, + dst); + } + private static void assertByteBufferContentEquals(byte[] expected, ByteBuffer test) { assertTrue( "ByteBuffer is too small. Expected " + expected.length + " but was " + test.capacity(), diff --git a/sdk/android/src/java/org/webrtc/HardwareVideoEncoder.java b/sdk/android/src/java/org/webrtc/HardwareVideoEncoder.java index e5062629c7..0825c1e742 100644 --- a/sdk/android/src/java/org/webrtc/HardwareVideoEncoder.java +++ b/sdk/android/src/java/org/webrtc/HardwareVideoEncoder.java @@ -15,6 +15,7 @@ import android.media.MediaCodecInfo; import android.media.MediaFormat; import android.opengl.GLES20; +import android.os.Build; import android.os.Bundle; import android.view.Surface; import androidx.annotation.Nullable; @@ -149,6 +150,10 @@ public void waitForZero() { private int width; private int height; + // Y-plane strides in the encoder's input + private int stride; + // Y-plane slice-height in the encoder's input + private int sliceHeight; private boolean useSurfaceMode; // --- Only accessed from the encoding thread. @@ -280,6 +285,10 @@ private VideoCodecStatus initEncodeInternal() { textureEglBase.makeCurrent(); } + MediaFormat inputFormat = codec.getInputFormat(); + stride = getStride(inputFormat, width); + sliceHeight = getSliceHeight(inputFormat, height); + codec.start(); outputBuffers = codec.getOutputBuffers(); } catch (IllegalStateException e) { @@ -686,9 +695,25 @@ private boolean canUseSurface() { return sharedContext != null && surfaceColorFormat != null; } + private static int getStride(MediaFormat inputFormat, int width) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && inputFormat != null + && inputFormat.containsKey(MediaFormat.KEY_STRIDE)) { + return inputFormat.getInteger(MediaFormat.KEY_STRIDE); + } + return width; + } + + private static int getSliceHeight(MediaFormat inputFormat, int height) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && inputFormat != null + && inputFormat.containsKey(MediaFormat.KEY_SLICE_HEIGHT)) { + return inputFormat.getInteger(MediaFormat.KEY_SLICE_HEIGHT); + } + return height; + } + // Visible for testing. protected void fillInputBuffer(ByteBuffer buffer, VideoFrame.Buffer videoFrameBuffer) { - yuvFormat.fillBuffer(buffer, videoFrameBuffer); + yuvFormat.fillBuffer(buffer, videoFrameBuffer, stride, sliceHeight); } /** @@ -697,24 +722,39 @@ protected void fillInputBuffer(ByteBuffer buffer, VideoFrame.Buffer videoFrameBu private enum YuvFormat { I420 { @Override - void fillBuffer(ByteBuffer dstBuffer, VideoFrame.Buffer srcBuffer) { + void fillBuffer( + ByteBuffer dstBuffer, VideoFrame.Buffer srcBuffer, int dstStrideY, int dstSliceHeightY) { + /* + * According to the docs in Android MediaCodec, the stride of the U and V planes can be + * calculated based on the color format, though it is generally undefined and depends on the + * device and release. + *

Assuming the width and height, dstStrideY and dstSliceHeightY are + * even, it works fine when we define the stride and slice-height of the dst U/V plane to be + * half of the dst Y plane. + */ + int dstStrideU = dstStrideY / 2; + int dstSliceHeight = dstSliceHeightY / 2; VideoFrame.I420Buffer i420 = srcBuffer.toI420(); YuvHelper.I420Copy(i420.getDataY(), i420.getStrideY(), i420.getDataU(), i420.getStrideU(), - i420.getDataV(), i420.getStrideV(), dstBuffer, i420.getWidth(), i420.getHeight()); + i420.getDataV(), i420.getStrideV(), dstBuffer, i420.getWidth(), i420.getHeight(), + dstStrideY, dstSliceHeightY, dstStrideU, dstSliceHeight); i420.release(); } }, NV12 { @Override - void fillBuffer(ByteBuffer dstBuffer, VideoFrame.Buffer srcBuffer) { + void fillBuffer( + ByteBuffer dstBuffer, VideoFrame.Buffer srcBuffer, int dstStrideY, int dstSliceHeightY) { VideoFrame.I420Buffer i420 = srcBuffer.toI420(); YuvHelper.I420ToNV12(i420.getDataY(), i420.getStrideY(), i420.getDataU(), i420.getStrideU(), - i420.getDataV(), i420.getStrideV(), dstBuffer, i420.getWidth(), i420.getHeight()); + i420.getDataV(), i420.getStrideV(), dstBuffer, i420.getWidth(), i420.getHeight(), + dstStrideY, dstSliceHeightY); i420.release(); } }; - abstract void fillBuffer(ByteBuffer dstBuffer, VideoFrame.Buffer srcBuffer); + abstract void fillBuffer( + ByteBuffer dstBuffer, VideoFrame.Buffer srcBuffer, int dstStrideY, int dstSliceHeightY); static YuvFormat valueOf(int colorFormat) { switch (colorFormat) { diff --git a/sdk/android/src/java/org/webrtc/MediaCodecWrapper.java b/sdk/android/src/java/org/webrtc/MediaCodecWrapper.java index bb67d1f4b9..89f392d3bd 100644 --- a/sdk/android/src/java/org/webrtc/MediaCodecWrapper.java +++ b/sdk/android/src/java/org/webrtc/MediaCodecWrapper.java @@ -41,6 +41,8 @@ interface MediaCodecWrapper { void releaseOutputBuffer(int index, boolean render); + MediaFormat getInputFormat(); + MediaFormat getOutputFormat(); ByteBuffer[] getInputBuffers(); diff --git a/sdk/android/src/java/org/webrtc/MediaCodecWrapperFactoryImpl.java b/sdk/android/src/java/org/webrtc/MediaCodecWrapperFactoryImpl.java index 544d6ebe4f..29edf6ef0c 100644 --- a/sdk/android/src/java/org/webrtc/MediaCodecWrapperFactoryImpl.java +++ b/sdk/android/src/java/org/webrtc/MediaCodecWrapperFactoryImpl.java @@ -78,6 +78,11 @@ public void releaseOutputBuffer(int index, boolean render) { mediaCodec.releaseOutputBuffer(index, render); } + @Override + public MediaFormat getInputFormat() { + return mediaCodec.getInputFormat(); + } + @Override public MediaFormat getOutputFormat() { return mediaCodec.getOutputFormat(); diff --git a/sdk/android/tests/src/org/webrtc/AndroidVideoDecoderTest.java b/sdk/android/tests/src/org/webrtc/AndroidVideoDecoderTest.java index 644b24b1b3..04891e2563 100644 --- a/sdk/android/tests/src/org/webrtc/AndroidVideoDecoderTest.java +++ b/sdk/android/tests/src/org/webrtc/AndroidVideoDecoderTest.java @@ -201,9 +201,10 @@ public void setUp() { MockitoAnnotations.initMocks(this); when(mockSurfaceTextureHelper.getSurfaceTexture()) .thenReturn(new SurfaceTexture(/*texName=*/0)); + MediaFormat inputFormat = new MediaFormat(); MediaFormat outputFormat = new MediaFormat(); // TODO(sakal): Add more details to output format as needed. - fakeMediaCodecWrapper = spy(new FakeMediaCodecWrapper(outputFormat)); + fakeMediaCodecWrapper = spy(new FakeMediaCodecWrapper(inputFormat, outputFormat)); fakeDecoderCallback = new FakeDecoderCallback(); } diff --git a/sdk/android/tests/src/org/webrtc/FakeMediaCodecWrapper.java b/sdk/android/tests/src/org/webrtc/FakeMediaCodecWrapper.java index 990f7b3aca..c5e69498e0 100644 --- a/sdk/android/tests/src/org/webrtc/FakeMediaCodecWrapper.java +++ b/sdk/android/tests/src/org/webrtc/FakeMediaCodecWrapper.java @@ -104,6 +104,7 @@ public int getFlags() { private State state = State.STOPPED_UNINITIALIZED; private @Nullable MediaFormat configuredFormat; private int configuredFlags; + private final MediaFormat inputFormat; private final MediaFormat outputFormat; private final ByteBuffer[] inputBuffers = new ByteBuffer[NUM_INPUT_BUFFERS]; private final ByteBuffer[] outputBuffers = new ByteBuffer[NUM_OUTPUT_BUFFERS]; @@ -111,7 +112,8 @@ public int getFlags() { private final boolean[] outputBufferReserved = new boolean[NUM_OUTPUT_BUFFERS]; private final List queuedOutputBuffers = new ArrayList<>(); - public FakeMediaCodecWrapper(MediaFormat outputFormat) { + public FakeMediaCodecWrapper(MediaFormat inputFormat, MediaFormat outputFormat) { + this.inputFormat = inputFormat; this.outputFormat = outputFormat; } @@ -299,6 +301,11 @@ public ByteBuffer[] getOutputBuffers() { return outputBuffers; } + @Override + public MediaFormat getInputFormat() { + return inputFormat; + } + @Override public MediaFormat getOutputFormat() { return outputFormat; diff --git a/sdk/android/tests/src/org/webrtc/HardwareVideoEncoderTest.java b/sdk/android/tests/src/org/webrtc/HardwareVideoEncoderTest.java index 145c0cc29a..08f7fb055f 100644 --- a/sdk/android/tests/src/org/webrtc/HardwareVideoEncoderTest.java +++ b/sdk/android/tests/src/org/webrtc/HardwareVideoEncoderTest.java @@ -161,9 +161,10 @@ private VideoFrame createTestVideoFrame(long timestampNs) { @Before public void setUp() { MockitoAnnotations.initMocks(this); + MediaFormat inputFormat = new MediaFormat(); MediaFormat outputFormat = new MediaFormat(); // TODO(sakal): Add more details to output format as needed. - fakeMediaCodecWrapper = spy(new FakeMediaCodecWrapper(outputFormat)); + fakeMediaCodecWrapper = spy(new FakeMediaCodecWrapper(inputFormat, outputFormat)); } @Test From ba2677061aa0872f742a8f4b7327e2878f461df6 Mon Sep 17 00:00:00 2001 From: Henrik Lundin Date: Wed, 16 Feb 2022 15:15:12 +0000 Subject: [PATCH 008/847] Add fuzzer test for G722 and fix a fuzzer problem The problem was fixed by implementing the methid PacketDuration() in AudioDecoderG722StereoImpl, which catches the issue in AudioDecoder::Decode(). Bug: chromium:1280851 Change-Id: I31f974b9999f3c1c62b0e5dc39bb3e56a9a9388d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251842 Reviewed-by: Minyue Li Commit-Queue: Henrik Lundin Cr-Commit-Position: refs/heads/main@{#36034} --- .../codecs/g722/audio_decoder_g722.cc | 6 +++ .../codecs/g722/audio_decoder_g722.h | 1 + test/fuzzers/BUILD.gn | 8 ++++ test/fuzzers/audio_decoder_g722_fuzzer.cc | 39 +++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 test/fuzzers/audio_decoder_g722_fuzzer.cc diff --git a/modules/audio_coding/codecs/g722/audio_decoder_g722.cc b/modules/audio_coding/codecs/g722/audio_decoder_g722.cc index f02ca7f896..c21ab9341f 100644 --- a/modules/audio_coding/codecs/g722/audio_decoder_g722.cc +++ b/modules/audio_coding/codecs/g722/audio_decoder_g722.cc @@ -114,6 +114,12 @@ int AudioDecoderG722StereoImpl::DecodeInternal(const uint8_t* encoded, return static_cast(ret); } +int AudioDecoderG722StereoImpl::PacketDuration(const uint8_t* encoded, + size_t encoded_len) const { + // 1/2 encoded byte per sample per channel. + return static_cast(2 * encoded_len / Channels()); +} + int AudioDecoderG722StereoImpl::SampleRateHz() const { return 16000; } diff --git a/modules/audio_coding/codecs/g722/audio_decoder_g722.h b/modules/audio_coding/codecs/g722/audio_decoder_g722.h index 39e9e630be..5872fad5de 100644 --- a/modules/audio_coding/codecs/g722/audio_decoder_g722.h +++ b/modules/audio_coding/codecs/g722/audio_decoder_g722.h @@ -57,6 +57,7 @@ class AudioDecoderG722StereoImpl final : public AudioDecoder { std::vector ParsePayload(rtc::Buffer&& payload, uint32_t timestamp) override; int SampleRateHz() const override; + int PacketDuration(const uint8_t* encoded, size_t encoded_len) const override; size_t Channels() const override; protected: diff --git a/test/fuzzers/BUILD.gn b/test/fuzzers/BUILD.gn index a5e2e44ff1..cc8b312ab3 100644 --- a/test/fuzzers/BUILD.gn +++ b/test/fuzzers/BUILD.gn @@ -259,6 +259,14 @@ rtc_library("audio_decoder_fuzzer") { absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } +webrtc_fuzzer_test("audio_decoder_g722_fuzzer") { + sources = [ "audio_decoder_g722_fuzzer.cc" ] + deps = [ + ":audio_decoder_fuzzer", + "../../modules/audio_coding:g722", + ] +} + webrtc_fuzzer_test("audio_decoder_ilbc_fuzzer") { sources = [ "audio_decoder_ilbc_fuzzer.cc" ] deps = [ diff --git a/test/fuzzers/audio_decoder_g722_fuzzer.cc b/test/fuzzers/audio_decoder_g722_fuzzer.cc new file mode 100644 index 0000000000..08599aa333 --- /dev/null +++ b/test/fuzzers/audio_decoder_g722_fuzzer.cc @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2022 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/codecs/g722/audio_decoder_g722.h" +#include "test/fuzzers/audio_decoder_fuzzer.h" + +namespace webrtc { +void FuzzOneInput(const uint8_t* data, size_t size) { + if (size > 10000 || size < 1) { + return; + } + + std::unique_ptr dec; + size_t num_channels; + if (data[0] % 2) { + dec = std::make_unique(); + num_channels = 1; + } else { + dec = std::make_unique(); + num_channels = 2; + } + // Allocate a maximum output size of 100 ms. + const int sample_rate_hz = dec->SampleRateHz(); + const size_t allocated_ouput_size_samples = + sample_rate_hz / 10 * num_channels; + std::unique_ptr output = + std::make_unique(allocated_ouput_size_samples); + FuzzAudioDecoder( + DecoderFunctionType::kNormalDecode, data, size, dec.get(), sample_rate_hz, + allocated_ouput_size_samples * sizeof(int16_t), output.get()); +} +} // namespace webrtc From 153c9e51074b3004ffeaa6fdb9749e4269b71ba8 Mon Sep 17 00:00:00 2001 From: Sergey Silkin Date: Mon, 21 Feb 2022 11:05:25 +0000 Subject: [PATCH 009/847] Revert "Use internal() in VideoTrack when invoking the source." This reverts commit 962bf1896185c0d84232f2bfae492eeb04e1236d. Reason for revert: Regressions in PC tests https://crbug.com/webrtc/13697 Original change's description: > Use internal() in VideoTrack when invoking the source. > > This skips going through the proxy and potentially hide a thread hop > should a regression occur. > > This CL contains a part of a previously reviewed, landed, reverted, > relanded and re-reverted CL: > https://webrtc-review.googlesource.com/c/src/+/250180 > > Bug: webrtc:13540 > Change-Id: If098f5c04a263547fb53f44e9f9738b8e941a294 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251861 > Reviewed-by: Harald Alvestrand > Commit-Queue: Tomas Gunnarsson > Cr-Commit-Position: refs/heads/main@{#36026} Bug: webrtc:13540 Change-Id: Iea76094aedda91271154f89c356b140c95717976 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251981 Bot-Commit: rubber-stamper@appspot.gserviceaccount.com Reviewed-by: Harald Alvestrand Commit-Queue: Sergey Silkin Cr-Commit-Position: refs/heads/main@{#36035} --- pc/video_track.cc | 10 +++------- pc/video_track.h | 3 --- pc/video_track_unittest.cc | 11 +---------- 3 files changed, 4 insertions(+), 20 deletions(-) diff --git a/pc/video_track.cc b/pc/video_track.cc index 4559181ce7..27274dc095 100644 --- a/pc/video_track.cc +++ b/pc/video_track.cc @@ -57,18 +57,18 @@ void VideoTrack::AddOrUpdateSink(rtc::VideoSinkInterface* sink, VideoSourceBaseGuarded::AddOrUpdateSink(sink, wants); rtc::VideoSinkWants modified_wants = wants; modified_wants.black_frames = !enabled_w_; - video_source_->internal()->AddOrUpdateSink(sink, modified_wants); + video_source_->AddOrUpdateSink(sink, modified_wants); } void VideoTrack::RemoveSink(rtc::VideoSinkInterface* sink) { RTC_DCHECK_RUN_ON(worker_thread_); VideoSourceBaseGuarded::RemoveSink(sink); - video_source_->internal()->RemoveSink(sink); + video_source_->RemoveSink(sink); } void VideoTrack::RequestRefreshFrame() { RTC_DCHECK_RUN_ON(worker_thread_); - video_source_->internal()->RequestRefreshFrame(); + video_source_->RequestRefreshFrame(); } VideoTrackSourceInterface* VideoTrack::GetSource() const { @@ -76,10 +76,6 @@ VideoTrackSourceInterface* VideoTrack::GetSource() const { return video_source_.get(); } -VideoTrackSourceInterface* VideoTrack::GetSourceInternal() const { - return video_source_->internal(); -} - VideoTrackInterface::ContentHint VideoTrack::content_hint() const { RTC_DCHECK_RUN_ON(&signaling_thread_); return content_hint_; diff --git a/pc/video_track.h b/pc/video_track.h index 66262d22d1..2bf7f31741 100644 --- a/pc/video_track.h +++ b/pc/video_track.h @@ -54,9 +54,6 @@ class VideoTrack : public MediaStreamTrack, MediaStreamTrackInterface::TrackState state() const override; std::string kind() const override; - // Direct access to the non-proxied source object for internal implementation. - VideoTrackSourceInterface* GetSourceInternal() const; - protected: VideoTrack( const std::string& id, diff --git a/pc/video_track_unittest.cc b/pc/video_track_unittest.cc index e6dcce7939..6342b608f1 100644 --- a/pc/video_track_unittest.cc +++ b/pc/video_track_unittest.cc @@ -40,19 +40,10 @@ class VideoTrackTest : public ::testing::Test { protected: rtc::scoped_refptr video_track_source_; - rtc::scoped_refptr video_track_; + rtc::scoped_refptr video_track_; cricket::FakeFrameSource frame_source_; }; -// VideoTrack::Create will create an API proxy around the source object. -// The `GetSource` method provides access to the proxy object intented for API -// use while the GetSourceInternal() provides direct access to the source object -// as provided to the `VideoTrack::Create` factory function. -TEST_F(VideoTrackTest, CheckApiProxyAndInternalSource) { - EXPECT_NE(video_track_->GetSource(), video_track_source_.get()); - EXPECT_EQ(video_track_->GetSourceInternal(), video_track_source_.get()); -} - // Test changing the source state also changes the track state. TEST_F(VideoTrackTest, SourceStateChangeTrackState) { EXPECT_EQ(MediaStreamTrackInterface::kLive, video_track_->state()); From c4ed5f0b1a848b18cef751b967dd3c61a8e14ff9 Mon Sep 17 00:00:00 2001 From: Henrik Lundin Date: Wed, 16 Feb 2022 16:03:47 +0000 Subject: [PATCH 010/847] Adding fuzzer for G711/PCM u/A decoders and fixing a fuzzer problem Bug: chromium:1279775 Change-Id: I8cc3f5fe25b9e707e9d171251026bd5a8bad5da5 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251844 Reviewed-by: Minyue Li Commit-Queue: Henrik Lundin Cr-Commit-Position: refs/heads/main@{#36036} --- .../codecs/g711/audio_decoder_pcm.cc | 16 ++++++- test/fuzzers/BUILD.gn | 8 ++++ test/fuzzers/audio_decoder_pcm_fuzzer.cc | 45 +++++++++++++++++++ 3 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 test/fuzzers/audio_decoder_pcm_fuzzer.cc diff --git a/modules/audio_coding/codecs/g711/audio_decoder_pcm.cc b/modules/audio_coding/codecs/g711/audio_decoder_pcm.cc index d580a0509b..46ac671b30 100644 --- a/modules/audio_coding/codecs/g711/audio_decoder_pcm.cc +++ b/modules/audio_coding/codecs/g711/audio_decoder_pcm.cc @@ -40,8 +40,14 @@ int AudioDecoderPcmU::DecodeInternal(const uint8_t* encoded, int16_t* decoded, SpeechType* speech_type) { RTC_DCHECK_EQ(SampleRateHz(), sample_rate_hz); + // Adjust the encoded length down to ensure the same number of samples in each + // channel. + const size_t encoded_len_adjusted = + PacketDuration(encoded, encoded_len) * + Channels(); // 1 byte per sample per channel int16_t temp_type = 1; // Default is speech. - size_t ret = WebRtcG711_DecodeU(encoded, encoded_len, decoded, &temp_type); + size_t ret = + WebRtcG711_DecodeU(encoded, encoded_len_adjusted, decoded, &temp_type); *speech_type = ConvertSpeechType(temp_type); return static_cast(ret); } @@ -75,8 +81,14 @@ int AudioDecoderPcmA::DecodeInternal(const uint8_t* encoded, int16_t* decoded, SpeechType* speech_type) { RTC_DCHECK_EQ(SampleRateHz(), sample_rate_hz); + // Adjust the encoded length down to ensure the same number of samples in each + // channel. + const size_t encoded_len_adjusted = + PacketDuration(encoded, encoded_len) * + Channels(); // 1 byte per sample per channel int16_t temp_type = 1; // Default is speech. - size_t ret = WebRtcG711_DecodeA(encoded, encoded_len, decoded, &temp_type); + size_t ret = + WebRtcG711_DecodeA(encoded, encoded_len_adjusted, decoded, &temp_type); *speech_type = ConvertSpeechType(temp_type); return static_cast(ret); } diff --git a/test/fuzzers/BUILD.gn b/test/fuzzers/BUILD.gn index cc8b312ab3..c71231453c 100644 --- a/test/fuzzers/BUILD.gn +++ b/test/fuzzers/BUILD.gn @@ -316,6 +316,14 @@ webrtc_fuzzer_test("audio_decoder_multiopus_fuzzer") { ] } +webrtc_fuzzer_test("audio_decoder_pcm_fuzzer") { + sources = [ "audio_decoder_pcm_fuzzer.cc" ] + deps = [ + ":audio_decoder_fuzzer", + "../../modules/audio_coding:g711", + ] +} + webrtc_fuzzer_test("audio_decoder_pcm16b_fuzzer") { sources = [ "audio_decoder_pcm16b_fuzzer.cc" ] deps = [ diff --git a/test/fuzzers/audio_decoder_pcm_fuzzer.cc b/test/fuzzers/audio_decoder_pcm_fuzzer.cc new file mode 100644 index 0000000000..dbfcaf9976 --- /dev/null +++ b/test/fuzzers/audio_decoder_pcm_fuzzer.cc @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022 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 "modules/audio_coding/codecs/g711/audio_decoder_pcm.h" +#include "test/fuzzers/audio_decoder_fuzzer.h" + +namespace webrtc { +void FuzzOneInput(const uint8_t* data, size_t size) { + if (size > 10000 || size < 2) { + return; + } + + const size_t num_channels = data[0] % 16 + 1; + + std::unique_ptr dec; + if (data[1] % 2) { + dec = std::make_unique(num_channels); + } else { + dec = std::make_unique(num_channels); + } + + // Two first bytes of the data are used. Move forward. + data += 2; + size -= 2; + + // Allocate a maximum output size of 100 ms. + const size_t allocated_ouput_size_samples = + dec->SampleRateHz() * num_channels / 10; + std::unique_ptr output = + std::make_unique(allocated_ouput_size_samples); + FuzzAudioDecoder(DecoderFunctionType::kNormalDecode, data, size, dec.get(), + dec->SampleRateHz(), + allocated_ouput_size_samples * sizeof(int16_t), + output.get()); +} +} // namespace webrtc From 808531653e72bb6b4095a0b33d911edcbbc54f46 Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Mon, 21 Feb 2022 13:23:06 +0100 Subject: [PATCH 011/847] In RtcpTransceiver implement handling incoming RRTR Bug: webrtc:8239 Change-Id: I4a469b6a0c2e387e35262798f4686fbf310d00cd Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251902 Reviewed-by: Emil Lundmark Commit-Queue: Danil Chapovalov Cr-Commit-Position: refs/heads/main@{#36037} --- modules/rtp_rtcp/source/rtcp_packet/dlrr.h | 10 +++++ .../rtcp_packet/extended_reports_unittest.cc | 13 ------ modules/rtp_rtcp/source/rtcp_packet/rrtr.h | 8 ++++ .../rtp_rtcp/source/rtcp_transceiver_config.h | 7 +++ .../rtp_rtcp/source/rtcp_transceiver_impl.cc | 44 ++++++++++++++++--- .../rtp_rtcp/source/rtcp_transceiver_impl.h | 8 ++++ .../source/rtcp_transceiver_impl_unittest.cc | 38 ++++++++++++++++ 7 files changed, 109 insertions(+), 19 deletions(-) diff --git a/modules/rtp_rtcp/source/rtcp_packet/dlrr.h b/modules/rtp_rtcp/source/rtcp_packet/dlrr.h index 6fe2099fd9..ad91dfdcc6 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/dlrr.h +++ b/modules/rtp_rtcp/source/rtcp_packet/dlrr.h @@ -24,11 +24,21 @@ struct ReceiveTimeInfo { ReceiveTimeInfo() : ssrc(0), last_rr(0), delay_since_last_rr(0) {} ReceiveTimeInfo(uint32_t ssrc, uint32_t last_rr, uint32_t delay) : ssrc(ssrc), last_rr(last_rr), delay_since_last_rr(delay) {} + uint32_t ssrc; uint32_t last_rr; uint32_t delay_since_last_rr; }; +inline bool operator==(const ReceiveTimeInfo& lhs, const ReceiveTimeInfo& rhs) { + return lhs.ssrc == rhs.ssrc && lhs.last_rr == rhs.last_rr && + lhs.delay_since_last_rr == rhs.delay_since_last_rr; +} + +inline bool operator!=(const ReceiveTimeInfo& lhs, const ReceiveTimeInfo& rhs) { + return !(lhs == rhs); +} + // DLRR Report Block: Delay since the Last Receiver Report (RFC 3611). class Dlrr { public: diff --git a/modules/rtp_rtcp/source/rtcp_packet/extended_reports_unittest.cc b/modules/rtp_rtcp/source/rtcp_packet/extended_reports_unittest.cc index 7c50c01c43..3d9a2a3408 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/extended_reports_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_packet/extended_reports_unittest.cc @@ -24,19 +24,6 @@ using webrtc::rtcp::ReceiveTimeInfo; using webrtc::rtcp::Rrtr; namespace webrtc { -// Define comparision operators that shouldn't be needed in production, -// but make testing matches more clear. -namespace rtcp { -bool operator==(const Rrtr& rrtr1, const Rrtr& rrtr2) { - return rrtr1.ntp() == rrtr2.ntp(); -} - -bool operator==(const ReceiveTimeInfo& time1, const ReceiveTimeInfo& time2) { - return time1.ssrc == time2.ssrc && time1.last_rr == time2.last_rr && - time1.delay_since_last_rr == time2.delay_since_last_rr; -} -} // namespace rtcp - namespace { constexpr uint32_t kSenderSsrc = 0x12345678; constexpr uint8_t kEmptyPacket[] = {0x80, 207, 0x00, 0x01, diff --git a/modules/rtp_rtcp/source/rtcp_packet/rrtr.h b/modules/rtp_rtcp/source/rtcp_packet/rrtr.h index 8eb4ce62ad..827bd74399 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/rrtr.h +++ b/modules/rtp_rtcp/source/rtcp_packet/rrtr.h @@ -46,6 +46,14 @@ class Rrtr { NtpTime ntp_; }; +inline bool operator==(const Rrtr& rrtr1, const Rrtr& rrtr2) { + return rrtr1.ntp() == rrtr2.ntp(); +} + +inline bool operator!=(const Rrtr& rrtr1, const Rrtr& rrtr2) { + return !(rrtr1 == rrtr2); +} + } // namespace rtcp } // namespace webrtc #endif // MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_RRTR_H_ diff --git a/modules/rtp_rtcp/source/rtcp_transceiver_config.h b/modules/rtp_rtcp/source/rtcp_transceiver_config.h index 0be633fc61..2400f9b908 100644 --- a/modules/rtp_rtcp/source/rtcp_transceiver_config.h +++ b/modules/rtp_rtcp/source/rtcp_transceiver_config.h @@ -162,6 +162,13 @@ struct RtcpTransceiverConfig { // https://tools.ietf.org/html/rfc3611#section-4.4 and #section-4.5 bool non_sender_rtt_measurement = false; + // Reply to incoming RRTR messages so that remote endpoint may estimate RTT as + // non-sender as described in https://tools.ietf.org/html/rfc3611#section-4.4 + // and #section-4.5 + // TODO(danilchap): Make it true by default after users got enough time to + // turn it off if not needed. + bool reply_to_non_sender_rtt_measurement = false; + // Allows a REMB message to be sent immediately when SetRemb is called without // having to wait for the next compount message to be sent. bool send_remb_on_change = false; diff --git a/modules/rtp_rtcp/source/rtcp_transceiver_impl.cc b/modules/rtp_rtcp/source/rtcp_transceiver_impl.cc index c075b2f99e..5909af93ce 100644 --- a/modules/rtp_rtcp/source/rtcp_transceiver_impl.cc +++ b/modules/rtp_rtcp/source/rtcp_transceiver_impl.cc @@ -370,6 +370,14 @@ void RtcpTransceiverImpl::HandleExtendedReports( if (!extended_reports.Parse(rtcp_packet_header)) return; + if (config_.reply_to_non_sender_rtt_measurement && extended_reports.rrtr()) { + RrtrTimes& rrtr = received_rrtrs_[extended_reports.sender_ssrc()]; + rrtr.received_remote_mid_ntp_time = + CompactNtp(extended_reports.rrtr()->ntp()); + rrtr.local_receive_mid_ntp_time = + CompactNtp(config_.clock->ConvertTimestampToNtpTime(now)); + } + if (extended_reports.dlrr()) HandleDlrr(extended_reports.dlrr(), now); @@ -620,7 +628,29 @@ void RtcpTransceiverImpl::CreateCompoundPacket(Timestamp now, if (remb_.has_value()) { reserved_bytes += remb_->BlockLength(); } + absl::optional xr; + if (!received_rrtrs_.empty()) { + RTC_DCHECK(config_.reply_to_non_sender_rtt_measurement); + xr.emplace(); + uint32_t now_ntp = + CompactNtp(config_.clock->ConvertTimestampToNtpTime(now)); + for (const auto& [ssrc, rrtr_info] : received_rrtrs_) { + rtcp::ReceiveTimeInfo reply; + reply.ssrc = ssrc; + reply.last_rr = rrtr_info.received_remote_mid_ntp_time; + reply.delay_since_last_rr = + now_ntp - rrtr_info.local_receive_mid_ntp_time; + xr->AddDlrrItem(reply); + } + reserved_bytes += xr->BlockLength(); + } if (config_.non_sender_rtt_measurement) { + // It looks like bytes for ExtendedReport header are reserved twice, but in + // practice the same RtcpTransceiver won't both produce RRTR (i.e. it is a + // receiver-only) and reply to RRTR (i.e. remote participant is a receiver + // only). If that happen, then `reserved_bytes` would be slightly larger + // than it should, which is not an issue. + // 4 bytes for common RTCP header + 4 bytes for the ExtenedReports header. reserved_bytes += (4 + 4 + rtcp::Rrtr::kLength); } @@ -635,14 +665,16 @@ void RtcpTransceiverImpl::CreateCompoundPacket(Timestamp now, sender.AppendPacket(*remb_); } if (!result.has_sender_report && config_.non_sender_rtt_measurement) { - rtcp::ExtendedReports xr; - xr.SetSenderSsrc(result.sender_ssrc); - + if (!xr.has_value()) { + xr.emplace(); + } rtcp::Rrtr rrtr; rrtr.SetNtp(config_.clock->ConvertTimestampToNtpTime(now)); - xr.SetRrtr(rrtr); - - sender.AppendPacket(xr); + xr->SetRrtr(rrtr); + } + if (xr.has_value()) { + xr->SetSenderSsrc(result.sender_ssrc); + sender.AppendPacket(*xr); } } diff --git a/modules/rtp_rtcp/source/rtcp_transceiver_impl.h b/modules/rtp_rtcp/source/rtcp_transceiver_impl.h index ce25899bcf..8dc50b89e6 100644 --- a/modules/rtp_rtcp/source/rtcp_transceiver_impl.h +++ b/modules/rtp_rtcp/source/rtcp_transceiver_impl.h @@ -82,6 +82,13 @@ class RtcpTransceiverImpl { class PacketSender; struct RemoteSenderState; struct LocalSenderState; + struct RrtrTimes { + // Received remote NTP timestamp in compact representation. + uint32_t received_remote_mid_ntp_time; + + // Local NTP time when the report was received in compact representation. + uint32_t local_receive_mid_ntp_time; + }; void HandleReceivedPacket(const rtcp::CommonHeader& rtcp_packet_header, Timestamp now, @@ -144,6 +151,7 @@ class RtcpTransceiverImpl { std::list local_senders_; flat_map::iterator> local_senders_by_ssrc_; + flat_map received_rrtrs_; RepeatingTaskHandle periodic_task_handle_; }; diff --git a/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc b/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc index 417dcdd3de..82bfadecef 100644 --- a/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc @@ -45,6 +45,7 @@ using ::testing::NiceMock; using ::testing::Return; using ::testing::SizeIs; using ::testing::StrictMock; +using ::testing::UnorderedElementsAre; using ::testing::WithArg; using ::webrtc::rtcp::Bye; using ::webrtc::rtcp::CompoundPacket; @@ -1208,6 +1209,43 @@ TEST(RtcpTransceiverImplTest, SendsXrRrtrWhenEnabled) { EXPECT_EQ(rtcp_parser.xr()->rrtr()->ntp(), ntp_time_now); } +TEST(RtcpTransceiverImplTest, RepliesToRrtrWhenEnabled) { + static constexpr uint32_t kSenderSsrc[] = {4321, 9876}; + SimulatedClock clock(0); + RtcpTransceiverConfig config = DefaultTestConfig(); + config.clock = &clock; + config.reply_to_non_sender_rtt_measurement = true; + RtcpPacketParser rtcp_parser; + RtcpParserTransport transport(&rtcp_parser); + config.outgoing_transport = &transport; + RtcpTransceiverImpl rtcp_transceiver(config); + + rtcp::ExtendedReports xr; + rtcp::Rrtr rrtr; + rrtr.SetNtp(NtpTime(uint64_t{0x1111'2222'3333'4444})); + xr.SetRrtr(rrtr); + xr.SetSenderSsrc(kSenderSsrc[0]); + rtcp_transceiver.ReceivePacket(xr.Build(), clock.CurrentTime()); + clock.AdvanceTime(TimeDelta::Millis(1'500)); + + rrtr.SetNtp(NtpTime(uint64_t{0x4444'5555'6666'7777})); + xr.SetRrtr(rrtr); + xr.SetSenderSsrc(kSenderSsrc[1]); + rtcp_transceiver.ReceivePacket(xr.Build(), clock.CurrentTime()); + clock.AdvanceTime(TimeDelta::Millis(500)); + + rtcp_transceiver.SendCompoundPacket(); + + EXPECT_EQ(rtcp_parser.xr()->num_packets(), 1); + static constexpr uint32_t kComactNtpOneSecond = 0x0001'0000; + EXPECT_THAT(rtcp_parser.xr()->dlrr().sub_blocks(), + UnorderedElementsAre( + rtcp::ReceiveTimeInfo(kSenderSsrc[0], 0x2222'3333, + /*delay=*/2 * kComactNtpOneSecond), + rtcp::ReceiveTimeInfo(kSenderSsrc[1], 0x5555'6666, + /*delay=*/kComactNtpOneSecond / 2))); +} + TEST(RtcpTransceiverImplTest, SendsNoXrRrtrWhenDisabled) { SimulatedClock clock(0); RtcpTransceiverConfig config; From c13caac2d56095f4486cf462e6d4dc5eb6846739 Mon Sep 17 00:00:00 2001 From: Christoffer Jansson Date: Mon, 21 Feb 2022 16:32:18 +0100 Subject: [PATCH 012/847] Fix urllib import + add test Unblocks the chromium to webrtc roller. Bug: webrtc:13607 Change-Id: I877d8d25624bdc924425ef338f392ce7686207f2 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251984 Reviewed-by: Mirko Bonadei Commit-Queue: Christoffer Jansson Cr-Commit-Position: refs/heads/main@{#36038} --- tools_webrtc/autoroller/roll_deps.py | 2 +- .../autoroller/unittests/roll_deps_test.py | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/tools_webrtc/autoroller/roll_deps.py b/tools_webrtc/autoroller/roll_deps.py index 0aa2320a63..269200bff5 100755 --- a/tools_webrtc/autoroller/roll_deps.py +++ b/tools_webrtc/autoroller/roll_deps.py @@ -18,7 +18,7 @@ import re import subprocess import sys -import urllib +import urllib.request def FindSrcDirPath(): diff --git a/tools_webrtc/autoroller/unittests/roll_deps_test.py b/tools_webrtc/autoroller/unittests/roll_deps_test.py index 688b6651b8..42db81c258 100755 --- a/tools_webrtc/autoroller/unittests/roll_deps_test.py +++ b/tools_webrtc/autoroller/unittests/roll_deps_test.py @@ -323,6 +323,40 @@ def testSubmit(self): self.assertEqual(ChooseCQMode(False, 100, 500000, 500100), 2) +class TestReadUrlContent(unittest.TestCase): + def setUp(self): + self.url = 'http://localhost+?format=TEXT' + + def testReadUrlContent(self): + url_mock = mock.Mock() + roll_deps.urllib.request.urlopen = url_mock + + roll_deps.ReadUrlContent(self.url) + + calls = [ + mock.call('http://localhost+?format=TEXT'), + mock.call().readlines(), + mock.call().close() + ] + self.assertEqual(url_mock.mock_calls, calls) + + def testReadUrlContentError(self): + roll_deps.logging = mock.Mock() + + readlines_mock = mock.Mock() + readlines_mock.readlines = mock.Mock( + side_effect=IOError('Connection error')) + readlines_mock.close = mock.Mock() + + url_mock = mock.Mock(return_value=readlines_mock) + roll_deps.urllib.request.urlopen = url_mock + + try: + roll_deps.ReadUrlContent(self.url) + except OSError: + self.assertTrue(roll_deps.logging.exception.called) + + def _SetupGitLsRemoteCall(cmd_fake, url, revision): cmd = ['git', 'ls-remote', url, revision] cmd_fake.AddExpectation(cmd, _returns=(revision, None)) From 1f6e4308ab071d1386a25ca5d833f89a1de58a3f Mon Sep 17 00:00:00 2001 From: Sergey Silkin Date: Mon, 21 Feb 2022 09:42:45 +0000 Subject: [PATCH 013/847] Revert "Move VideoTrackSourceProxy creation into VideoTrack." This reverts commit 4bc7223cf0775737a615c677b82c78e49a6a8a2c. Reason for revert: Regressions in PC tests https://crbug.com/webrtc/13697 Original change's description: > Move VideoTrackSourceProxy creation into VideoTrack. > > This CL contains a part of a previously reviewed, landed, reverted, > relanded and re-reverted CL: > https://webrtc-review.googlesource.com/c/src/+/250180 > > Bug: webrtc:13540 > Change-Id: Id6df8da5ff61e3ec90d0b3f3d828e8f670d4931b > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251860 > Reviewed-by: Harald Alvestrand > Auto-Submit: Tomas Gunnarsson > Commit-Queue: Tomas Gunnarsson > Cr-Commit-Position: refs/heads/main@{#36025} Bug: webrtc:13540 Change-Id: Ibae8c1d39fa4d71aafd9666b66e6abc8eb8fddb2 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251980 Bot-Commit: rubber-stamper@appspot.gserviceaccount.com Reviewed-by: Harald Alvestrand Reviewed-by: Tomas Gunnarsson Commit-Queue: Tomas Gunnarsson Cr-Commit-Position: refs/heads/main@{#36039} --- pc/BUILD.gn | 1 - pc/audio_track.h | 4 ---- pc/video_rtp_receiver.cc | 6 +++++- pc/video_track.cc | 18 +++++------------- pc/video_track.h | 17 ++++------------- 5 files changed, 14 insertions(+), 32 deletions(-) diff --git a/pc/BUILD.gn b/pc/BUILD.gn index e7b7cc0102..277657e6a0 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -1272,7 +1272,6 @@ rtc_library("video_track") { "video_track.h", ] deps = [ - ":rtc_pc_base", "../api:media_stream_interface", "../api:scoped_refptr", "../api:sequence_checker", diff --git a/pc/audio_track.h b/pc/audio_track.h index 920bb948ba..f357391987 100644 --- a/pc/audio_track.h +++ b/pc/audio_track.h @@ -21,10 +21,6 @@ namespace webrtc { -// TODO(tommi): Instead of inheriting from `MediaStreamTrack<>`, implement the -// properties directly in this class. `MediaStreamTrack` doesn't guard against -// conflicting access, so we'd need to override those methods anyway in this -// class in order to make sure things are correctly checked. class AudioTrack : public MediaStreamTrack, public ObserverInterface { protected: diff --git a/pc/video_rtp_receiver.cc b/pc/video_rtp_receiver.cc index d1f8fb0d96..c5ead9e773 100644 --- a/pc/video_rtp_receiver.cc +++ b/pc/video_rtp_receiver.cc @@ -41,7 +41,11 @@ VideoRtpReceiver::VideoRtpReceiver( track_(VideoTrackProxyWithInternal::Create( rtc::Thread::Current(), worker_thread, - VideoTrack::Create(receiver_id, source_, worker_thread))), + VideoTrack::Create(receiver_id, + CreateVideoTrackSourceProxy(rtc::Thread::Current(), + worker_thread, + source_), + worker_thread))), attachment_id_(GenerateUniqueId()) { RTC_DCHECK(worker_thread_); SetStreams(streams); diff --git a/pc/video_track.cc b/pc/video_track.cc index 27274dc095..6e749b0526 100644 --- a/pc/video_track.cc +++ b/pc/video_track.cc @@ -23,14 +23,12 @@ namespace webrtc { -VideoTrack::VideoTrack( - const std::string& label, - rtc::scoped_refptr< - VideoTrackSourceProxyWithInternal> source, - rtc::Thread* worker_thread) +VideoTrack::VideoTrack(const std::string& label, + VideoTrackSourceInterface* video_source, + rtc::Thread* worker_thread) : MediaStreamTrack(label), worker_thread_(worker_thread), - video_source_(std::move(source)), + video_source_(video_source), content_hint_(ContentHint::kNone) { RTC_DCHECK_RUN_ON(&signaling_thread_); // Detach the thread checker for VideoSourceBaseGuarded since we'll make calls @@ -132,13 +130,7 @@ rtc::scoped_refptr VideoTrack::Create( const std::string& id, VideoTrackSourceInterface* source, rtc::Thread* worker_thread) { - rtc::scoped_refptr< - VideoTrackSourceProxyWithInternal> - source_proxy = VideoTrackSourceProxy::Create(rtc::Thread::Current(), - worker_thread, source); - - return rtc::make_ref_counted(id, std::move(source_proxy), - worker_thread); + return rtc::make_ref_counted(id, source, worker_thread); } } // namespace webrtc diff --git a/pc/video_track.h b/pc/video_track.h index 2bf7f31741..bf433b5f5a 100644 --- a/pc/video_track.h +++ b/pc/video_track.h @@ -22,16 +22,11 @@ #include "api/video/video_source_interface.h" #include "media/base/video_source_base.h" #include "rtc_base/system/no_unique_address.h" -#include "pc/video_track_source_proxy.h" #include "rtc_base/thread.h" #include "rtc_base/thread_annotations.h" namespace webrtc { -// TODO(tommi): Instead of inheriting from `MediaStreamTrack<>`, implement the -// properties directly in this class. `MediaStreamTrack` doesn't guard against -// conflicting access, so we'd need to override those methods anyway in this -// class in order to make sure things are correctly checked. class VideoTrack : public MediaStreamTrack, public rtc::VideoSourceBaseGuarded, public ObserverInterface { @@ -55,11 +50,9 @@ class VideoTrack : public MediaStreamTrack, std::string kind() const override; protected: - VideoTrack( - const std::string& id, - rtc::scoped_refptr< - VideoTrackSourceProxyWithInternal> source, - rtc::Thread* worker_thread); + VideoTrack(const std::string& id, + VideoTrackSourceInterface* video_source, + rtc::Thread* worker_thread); ~VideoTrack(); private: @@ -68,9 +61,7 @@ class VideoTrack : public MediaStreamTrack, RTC_NO_UNIQUE_ADDRESS webrtc::SequenceChecker signaling_thread_; rtc::Thread* const worker_thread_; - const rtc::scoped_refptr< - VideoTrackSourceProxyWithInternal> - video_source_; + const rtc::scoped_refptr video_source_; ContentHint content_hint_ RTC_GUARDED_BY(&signaling_thread_); // Cached `enabled` state for the worker thread. This is kept in sync with // the state maintained on the signaling thread via set_enabled() but can From 3147e29c4e15df274a2d4a271341f77df640f550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CMichael?= Date: Sat, 19 Feb 2022 16:48:50 -0600 Subject: [PATCH 014/847] Refactor encoder-complexity param in VideoCodec w/backward compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move complexity parameter to the main VideoCodec class to enable additional video codecs to use the parameter without creating a new codec-specific structure. Bug: webrtc:13694 Change-Id: Icb7cf640b178875d799f39ade8b5084e3222bb1c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251921 Reviewed-by: Erik Språng Commit-Queue: Michael Horowitz Cr-Commit-Position: refs/heads/main@{#36040} --- api/video_codecs/video_codec.cc | 19 +++++++++++++++++++ api/video_codecs/video_codec.h | 6 ++++++ media/engine/simulcast_encoder_adapter.cc | 4 ++-- .../simulcast_encoder_adapter_unittest.cc | 13 ++++++++----- .../test/videocodec_test_fixture_impl.cc | 4 ++-- .../codecs/vp8/libvpx_vp8_encoder.cc | 2 +- .../codecs/vp8/test/vp8_impl_unittest.cc | 3 ++- 7 files changed, 40 insertions(+), 11 deletions(-) diff --git a/api/video_codecs/video_codec.cc b/api/video_codecs/video_codec.cc index d850917ac2..75c89e6985 100644 --- a/api/video_codecs/video_codec.cc +++ b/api/video_codecs/video_codec.cc @@ -139,4 +139,23 @@ VideoCodecType PayloadStringToCodecType(const std::string& name) { return kVideoCodecGeneric; } +VideoCodecComplexity VideoCodec::GetVideoEncoderComplexity() const { + if (complexity_.has_value()) { + return complexity_.value(); + } + switch (codecType) { + case kVideoCodecVP8: + return VP8().complexity; + case kVideoCodecVP9: + return VP9().complexity; + default: + return VideoCodecComplexity::kComplexityNormal; + } +} + +void VideoCodec::SetVideoEncoderComplexity( + VideoCodecComplexity complexity_setting) { + complexity_ = complexity_setting; +} + } // namespace webrtc diff --git a/api/video_codecs/video_codec.h b/api/video_codecs/video_codec.h index 1e6e21c0ec..f00176d3f9 100644 --- a/api/video_codecs/video_codec.h +++ b/api/video_codecs/video_codec.h @@ -109,6 +109,9 @@ class RTC_EXPORT VideoCodec { scalability_mode_ = std::string(scalability_mode); } + VideoCodecComplexity GetVideoEncoderComplexity() const; + void SetVideoEncoderComplexity(VideoCodecComplexity complexity_setting); + // Public variables. TODO(hta): Make them private with accessors. VideoCodecType codecType; @@ -169,6 +172,9 @@ class RTC_EXPORT VideoCodec { // This will allow removing the VideoCodec* types from this file. VideoCodecUnion codec_specific_; std::string scalability_mode_; + // 'complexity_' indicates the CPU capability of the client. It's used to + // determine encoder CPU complexity (e.g., cpu_used for VP8, VP9. and AV1). + absl::optional complexity_; }; } // namespace webrtc diff --git a/media/engine/simulcast_encoder_adapter.cc b/media/engine/simulcast_encoder_adapter.cc index 9143361e82..704c2d6a0b 100644 --- a/media/engine/simulcast_encoder_adapter.cc +++ b/media/engine/simulcast_encoder_adapter.cc @@ -791,8 +791,8 @@ webrtc::VideoCodec SimulcastEncoderAdapter::MakeStreamCodec( // kComplexityHigher, which maps to cpu_used = -4. int pixels_per_frame = codec_params.width * codec_params.height; if (pixels_per_frame < 352 * 288) { - codec_params.VP8()->complexity = - webrtc::VideoCodecComplexity::kComplexityHigher; + codec_params.SetVideoEncoderComplexity( + webrtc::VideoCodecComplexity::kComplexityHigher); } // Turn off denoising for all streams but the highest resolution. codec_params.VP8()->denoisingOn = false; diff --git a/media/engine/simulcast_encoder_adapter_unittest.cc b/media/engine/simulcast_encoder_adapter_unittest.cc index bb2335cb5b..5025656ae0 100644 --- a/media/engine/simulcast_encoder_adapter_unittest.cc +++ b/media/engine/simulcast_encoder_adapter_unittest.cc @@ -502,7 +502,8 @@ class TestSimulcastEncoderAdapterFake : public ::testing::Test, EXPECT_EQ(ref.maxBitrate, target.maxBitrate); EXPECT_EQ(ref.minBitrate, target.minBitrate); EXPECT_EQ(ref.maxFramerate, target.maxFramerate); - EXPECT_EQ(ref.VP8().complexity, target.VP8().complexity); + EXPECT_EQ(ref.GetVideoEncoderComplexity(), + target.GetVideoEncoderComplexity()); EXPECT_EQ(ref.VP8().numberOfTemporalLayers, target.VP8().numberOfTemporalLayers); EXPECT_EQ(ref.VP8().denoisingOn, target.VP8().denoisingOn); @@ -538,8 +539,8 @@ class TestSimulcastEncoderAdapterFake : public ::testing::Test, // stream 0, the lowest resolution stream. InitRefCodec(0, &ref_codec); ref_codec.qpMax = 45; - ref_codec.VP8()->complexity = - webrtc::VideoCodecComplexity::kComplexityHigher; + ref_codec.SetVideoEncoderComplexity( + webrtc::VideoCodecComplexity::kComplexityHigher); ref_codec.VP8()->denoisingOn = false; ref_codec.startBitrate = 100; // Should equal to the target bitrate. VerifyCodec(ref_codec, 0); @@ -1134,7 +1135,8 @@ TEST_F(TestSimulcastEncoderAdapterFake, DoesNotAlterMaxQpForScreenshare) { VideoCodec ref_codec; InitRefCodec(0, &ref_codec); ref_codec.qpMax = kHighMaxQp; - ref_codec.VP8()->complexity = webrtc::VideoCodecComplexity::kComplexityHigher; + ref_codec.SetVideoEncoderComplexity( + webrtc::VideoCodecComplexity::kComplexityHigher); ref_codec.VP8()->denoisingOn = false; ref_codec.startBitrate = 100; // Should equal to the target bitrate. VerifyCodec(ref_codec, 0); @@ -1167,7 +1169,8 @@ TEST_F(TestSimulcastEncoderAdapterFake, VideoCodec ref_codec; InitRefCodec(2, &ref_codec, true /* reverse_layer_order */); ref_codec.qpMax = kHighMaxQp; - ref_codec.VP8()->complexity = webrtc::VideoCodecComplexity::kComplexityHigher; + ref_codec.SetVideoEncoderComplexity( + webrtc::VideoCodecComplexity::kComplexityHigher); ref_codec.VP8()->denoisingOn = false; ref_codec.startBitrate = 100; // Should equal to the target bitrate. VerifyCodec(ref_codec, 2); 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 871300a6e0..1029d901a0 100644 --- a/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc +++ b/modules/video_coding/codecs/test/videocodec_test_fixture_impl.cc @@ -104,7 +104,6 @@ std::string CodecSpecificToString(const VideoCodec& codec) { rtc::SimpleStringBuilder ss(buf); switch (codec.codecType) { case kVideoCodecVP8: - ss << "complexity: " << static_cast(codec.VP8().complexity); ss << "\nnum_temporal_layers: " << static_cast(codec.VP8().numberOfTemporalLayers); ss << "\ndenoising: " << codec.VP8().denoisingOn; @@ -113,7 +112,6 @@ std::string CodecSpecificToString(const VideoCodec& codec) { ss << "\nkey_frame_interval: " << codec.VP8().keyFrameInterval; break; case kVideoCodecVP9: - ss << "complexity: " << static_cast(codec.VP9().complexity); ss << "\nnum_temporal_layers: " << static_cast(codec.VP9().numberOfTemporalLayers); ss << "\nnum_spatial_layers: " @@ -302,6 +300,8 @@ std::string VideoCodecTestFixtureImpl::Config::ToString() const { ss << "\nnum_simulcast_streams: " << static_cast(codec_settings.numberOfSimulcastStreams); ss << "\n\n--> codec_settings." << codec_type; + ss << "complexity: " + << static_cast(codec_settings.GetVideoEncoderComplexity()); ss << "\n" << CodecSpecificToString(codec_settings); if (codec_settings.numberOfSimulcastStreams > 1) { for (int i = 0; i < codec_settings.numberOfSimulcastStreams; ++i) { diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc index a613be4154..ced6f478d1 100644 --- a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc +++ b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc @@ -591,7 +591,7 @@ int LibvpxVp8Encoder::InitEncode(const VideoCodec* inst, } // Allow the user to set the complexity for the base stream. - switch (inst->VP8().complexity) { + switch (inst->GetVideoEncoderComplexity()) { case VideoCodecComplexity::kComplexityHigh: cpu_speed_[0] = -5; break; 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 c257edd7c1..0ec7a453c1 100644 --- a/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc +++ b/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc @@ -76,7 +76,8 @@ class TestVp8Impl : public VideoCodecUnitTest { webrtc::test::CodecSettings(kVideoCodecVP8, codec_settings); codec_settings->width = kWidth; codec_settings->height = kHeight; - codec_settings->VP8()->complexity = VideoCodecComplexity::kComplexityNormal; + codec_settings->SetVideoEncoderComplexity( + VideoCodecComplexity::kComplexityNormal); } void EncodeAndWaitForFrame(const VideoFrame& input_frame, From 694eae7064b6b53162e6a8084366dfb5618677bd Mon Sep 17 00:00:00 2001 From: Christoffer Jansson Date: Mon, 21 Feb 2022 20:05:33 +0100 Subject: [PATCH 015/847] Decode/encode data to utf-8 Currently blocking the chromium to webrtc roller Bug: webrtc:13607 Change-Id: I02237b266d4f2a2fdec2975b9e67d1c4b2099a48 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252001 Reviewed-by: Mirko Bonadei Commit-Queue: Christoffer Jansson Cr-Commit-Position: refs/heads/main@{#36041} --- tools_webrtc/autoroller/roll_deps.py | 12 +++++----- .../autoroller/unittests/roll_deps_test.py | 24 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tools_webrtc/autoroller/roll_deps.py b/tools_webrtc/autoroller/roll_deps.py index 269200bff5..13e7582410 100755 --- a/tools_webrtc/autoroller/roll_deps.py +++ b/tools_webrtc/autoroller/roll_deps.py @@ -120,7 +120,7 @@ def ParseDepsDict(deps_content): def ParseLocalDepsFile(filename): with open(filename, 'rb') as f: - deps_content = f.read() + deps_content = f.read().decode('utf-8') return ParseDepsDict(deps_content) @@ -196,7 +196,7 @@ def _ReadGitilesContent(url): # Download and decode BASE64 content until # https://code.google.com/p/gitiles/issues/detail?id=7 is fixed. base64_content = ReadUrlContent(url + '?format=TEXT') - return base64.b64decode(base64_content[0]) + return base64.b64decode(base64_content[0].decode('utf-8')) def ReadRemoteCrFile(path_below_src, revision): @@ -524,8 +524,8 @@ def Section(adjective, deps): def UpdateDepsFile(deps_filename, rev_update, changed_deps, new_cr_content): """Update the DEPS file with the new revision.""" - with open(deps_filename, 'r') as deps_file: - deps_content = deps_file.read() + with open(deps_filename, 'rb') as deps_file: + deps_content = deps_file.read().decode('utf-8') # Update the chromium_revision variable. deps_content = deps_content.replace(rev_update.current_chromium_rev, @@ -544,8 +544,8 @@ def UpdateDepsFile(deps_filename, rev_update, changed_deps, new_cr_content): (ANDROID_DEPS_START, ANDROID_DEPS_END, faulty)) deps_content = deps_re.sub(new_deps.group(0), deps_content) - with open(deps_filename, 'w') as deps_file: - deps_file.write(deps_content) + with open(deps_filename, 'wb') as deps_file: + deps_file.write(deps_content.encode('utf-8')) # Update each individual DEPS entry. for dep in changed_deps: diff --git a/tools_webrtc/autoroller/unittests/roll_deps_test.py b/tools_webrtc/autoroller/unittests/roll_deps_test.py index 42db81c258..b58f319eec 100755 --- a/tools_webrtc/autoroller/unittests/roll_deps_test.py +++ b/tools_webrtc/autoroller/unittests/roll_deps_test.py @@ -108,22 +108,22 @@ def testUpdateDepsFile(self): new_rev = 'aaaaabbbbbcccccdddddeeeeefffff0000011111' current_rev = TEST_DATA_VARS['chromium_revision'] - with open(self._new_cr_depsfile_android) as deps_file: - new_cr_contents = deps_file.read() + with open(self._new_cr_depsfile_android, 'rb') as deps_file: + new_cr_contents = deps_file.read().decode('utf-8') UpdateDepsFile(self._webrtc_depsfile, ChromiumRevisionUpdate(current_rev, new_rev), [], new_cr_contents) - with open(self._webrtc_depsfile) as deps_file: - deps_contents = deps_file.read() + with open(self._webrtc_depsfile, 'rb') as deps_file: + deps_contents = deps_file.read().decode('utf-8') self.assertTrue(new_rev in deps_contents, 'Failed to find %s in\n%s' % (new_rev, deps_contents)) def _UpdateDepsSetup(self): - with open(self._webrtc_depsfile_android) as deps_file: - webrtc_contents = deps_file.read() - with open(self._new_cr_depsfile_android) as deps_file: - new_cr_contents = deps_file.read() + with open(self._webrtc_depsfile_android, 'rb') as deps_file: + webrtc_contents = deps_file.read().decode('utf-8') + with open(self._new_cr_depsfile_android, 'rb') as deps_file: + new_cr_contents = deps_file.read().decode('utf-8') webrtc_deps = ParseDepsDict(webrtc_contents) new_cr_deps = ParseDepsDict(new_cr_contents) @@ -132,8 +132,8 @@ def _UpdateDepsSetup(self): UpdateDepsFile(self._webrtc_depsfile_android, NO_CHROMIUM_REVISION_UPDATE, changed_deps, new_cr_contents) - with open(self._webrtc_depsfile_android) as deps_file: - updated_contents = deps_file.read() + with open(self._webrtc_depsfile_android, 'rb') as deps_file: + updated_contents = deps_file.read().decode('utf-8') return webrtc_contents, updated_contents @@ -160,8 +160,8 @@ def testRemoveAndroidGeneratedDeps(self): self.assertFalse(removed in updated_contents) def testParseDepsDict(self): - with open(self._webrtc_depsfile) as deps_file: - deps_contents = deps_file.read() + with open(self._webrtc_depsfile, 'rb') as deps_file: + deps_contents = deps_file.read().decode('utf-8') local_scope = ParseDepsDict(deps_contents) vars_dict = local_scope['vars'] From 7a5978e4cd914c7298133eac08e2fbc57d18c562 Mon Sep 17 00:00:00 2001 From: Jeremy Leconte Date: Tue, 22 Feb 2022 07:26:33 +0000 Subject: [PATCH 016/847] Revert "Add the possibility to output a json gtest output to the perf tests." This reverts commit cbfa235b3548ae1a0b8f5b80a879214ca5f1bd56. Reason for revert: iOS bots will use flags_compatibility with isolated_script_test_output but not gtest_output. Original change's description: > Add the possibility to output a json gtest output to the perf tests. > > We use the Chromium existing flag isolated_script_test_output that we translate into gtest_output. > This is because the Chromium flag has the same purpose as gtest_output and is already provided in the recipe modules. > > No-Presubmit: True > Bug: b/197492097 > Change-Id: Ia432a85b0e0ab32008b39ffe751d11aefb9b24ea > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251041 > Reviewed-by: Mirko Bonadei > Commit-Queue: Jeremy Leconte > Cr-Commit-Position: refs/heads/main@{#35937} No-Presubmit: True Bug: b/197492097 Change-Id: I94e75328570f89011fbb0daf035f0072b8ea2f7d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252040 Reviewed-by: Mirko Bonadei Commit-Queue: Jeremy Leconte Cr-Commit-Position: refs/heads/main@{#36042} --- audio/test/low_bandwidth_audio_test.py | 7 ++++--- tools_webrtc/flags_compatibility.py | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/audio/test/low_bandwidth_audio_test.py b/audio/test/low_bandwidth_audio_test.py index 386572f6e5..051d67fea4 100755 --- a/audio/test/low_bandwidth_audio_test.py +++ b/audio/test/low_bandwidth_audio_test.py @@ -296,9 +296,6 @@ def main(): else: test_command = [os.path.join(args.build_dir, 'low_bandwidth_audio_test')] - if args.isolated_script_test_output: - test_command += ['--gtest_output=json:' + args.isolated_script_test_output] - analyzers = [Analyzer('pesq', _RunPesq, pesq_path, 16000)] # Check if POLQA can run at all, or skip the 48 kHz tests entirely. example_path = os.path.join(SRC_DIR, 'resources', 'voice_engine', @@ -366,6 +363,10 @@ def main(): with open(args.isolated_script_test_perf_output, 'wb') as f: f.write(histograms.AsProto().SerializeToString()) + if args.isolated_script_test_output: + with open(args.isolated_script_test_output, 'w') as f: + json.dump({"version": 3}, f) + return test_process.wait() diff --git a/tools_webrtc/flags_compatibility.py b/tools_webrtc/flags_compatibility.py index e7aeb93faf..72c66a594f 100755 --- a/tools_webrtc/flags_compatibility.py +++ b/tools_webrtc/flags_compatibility.py @@ -22,7 +22,9 @@ def main(): test_command = _ForcePythonInterpreter(unrecognized_args) if args.isolated_script_test_output: - test_command += ['--gtest_output=json:' + args.isolated_script_test_output] + test_command += [ + '--isolated_script_test_output', args.isolated_script_test_output + ] if args.isolated_script_test_perf_output: test_command += [ '--isolated_script_test_perf_output=' + From c8f0502f0fd3c737b1dc18808b371d6e25ab1b5f Mon Sep 17 00:00:00 2001 From: Christoffer Jansson Date: Mon, 21 Feb 2022 21:30:41 +0100 Subject: [PATCH 017/847] Fix typo - Parenthesis was in the wrong place. No-Try: True Bug: webrtc:13607 Change-Id: Iba13bcf94f7a89cdc0e124d42e879b9c900a56cc Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252003 Reviewed-by: Mirko Bonadei Commit-Queue: Christoffer Jansson Cr-Commit-Position: refs/heads/main@{#36043} --- tools_webrtc/autoroller/roll_deps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools_webrtc/autoroller/roll_deps.py b/tools_webrtc/autoroller/roll_deps.py index 13e7582410..b66cd84435 100755 --- a/tools_webrtc/autoroller/roll_deps.py +++ b/tools_webrtc/autoroller/roll_deps.py @@ -196,7 +196,7 @@ def _ReadGitilesContent(url): # Download and decode BASE64 content until # https://code.google.com/p/gitiles/issues/detail?id=7 is fixed. base64_content = ReadUrlContent(url + '?format=TEXT') - return base64.b64decode(base64_content[0].decode('utf-8')) + return base64.b64decode(base64_content[0]).decode('utf-8') def ReadRemoteCrFile(path_below_src, revision): From 7b0a30ec9ac7a07bb4b49ce2f5672b0a7c41d788 Mon Sep 17 00:00:00 2001 From: Jeremy Leconte Date: Tue, 22 Feb 2022 09:53:41 +0100 Subject: [PATCH 018/847] Allow low_bandwith_audio_test.py to pass unknown arg to the test. * The idea is copied from flags_compatibility since this file does a bit the same thing. * Remove extra_test_args which is not used and becomes unecessary. * Fix lint issues. Bug: b/197492097 Change-Id: I378e163a5116ded13619f91ce50859519c9550df Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252004 Reviewed-by: Mirko Bonadei Commit-Queue: Jeremy Leconte Cr-Commit-Position: refs/heads/main@{#36044} --- audio/test/low_bandwidth_audio_test.py | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/audio/test/low_bandwidth_audio_test.py b/audio/test/low_bandwidth_audio_test.py index 051d67fea4..07065e2c8d 100755 --- a/audio/test/low_bandwidth_audio_test.py +++ b/audio/test/low_bandwidth_audio_test.py @@ -67,24 +67,16 @@ def _ParseArgs(): '--isolated-script-test-output', default=None, help='Path to output an empty JSON file which Chromium infra requires.') - parser.add_argument('--extra-test-args', - default=[], - action='append', - help='Extra args to path to the test binary.') - # Ignore Chromium-specific flags - parser.add_argument('--test-launcher-summary-output', type=str, default=None) - args = parser.parse_args() - - return args + return parser.parse_known_args() def _GetPlatform(): if sys.platform == 'win32': return 'win' - elif sys.platform == 'darwin': + if sys.platform == 'darwin': return 'mac' - elif sys.platform.startswith('linux'): + if sys.platform.startswith('linux'): return 'linux' raise AssertionError('Unknown platform %s' % sys.platform) @@ -258,14 +250,13 @@ def _ConfigurePythonPath(args): # Fail early in case the proto hasn't been built. try: - #pylint: disable=unused-variable + #pylint: disable=unused-import import histogram_pb2 except ImportError as e: - logging.exception(e) raise ImportError('Could not import histogram_pb2. You need to build the ' 'low_bandwidth_audio_perf_test target before invoking ' 'this script. Expected to find ' - 'histogram_pb2.py in %s.' % histogram_proto_path) + 'histogram_pb2.py in %s.' % histogram_proto_path) from e def main(): @@ -274,7 +265,7 @@ def main(): datefmt='%Y-%m-%d %H:%M:%S') logging.info('Invoked with %s', str(sys.argv)) - args = _ParseArgs() + args, extra_test_args = _ParseArgs() _ConfigurePythonPath(args) @@ -309,7 +300,7 @@ def main(): test_process = subprocess.Popen(_LogCommand(test_command + [ '--sample_rate_hz=%d' % analyzer.sample_rate_hz, '--test_case_prefix=%s' % analyzer.name, - ] + args.extra_test_args), + ] + extra_test_args), universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) From 9bbfe9e5e09e12ea78048c610de85aeb5970176e Mon Sep 17 00:00:00 2001 From: Florent Castelli Date: Mon, 21 Feb 2022 14:39:47 +0100 Subject: [PATCH 019/847] dcsctp: Fix data race in debug logging The variable instance_count might be accessed from multiple threads when different PeerConnectionFactory objects are used, which may create multiple network threads. This is a pattern mostly noticed in tests. This fixes issues with logging when run under TSAN, it should not have any production impact. Bug: chromium:1243702 Change-Id: Iab1412a7907545811a309cab27a3ae23b4718606 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251983 Auto-Submit: Florent Castelli Reviewed-by: Victor Boivie Commit-Queue: Florent Castelli Cr-Commit-Position: refs/heads/main@{#36045} --- media/sctp/dcsctp_transport.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/media/sctp/dcsctp_transport.cc b/media/sctp/dcsctp_transport.cc index 38d2799f36..0a671ced87 100644 --- a/media/sctp/dcsctp_transport.cc +++ b/media/sctp/dcsctp_transport.cc @@ -10,6 +10,7 @@ #include "media/sctp/dcsctp_transport.h" +#include #include #include #include @@ -126,7 +127,7 @@ DcSctpTransport::DcSctpTransport(rtc::Thread* network_thread, socket_->HandleTimeout(timeout_id); }) { RTC_DCHECK_RUN_ON(network_thread_); - static int instance_count = 0; + static std::atomic instance_count = 0; rtc::StringBuilder sb; sb << debug_name_ << instance_count++; debug_name_ = sb.Release(); From f1e4a66e9433b747fd545b864261c0eb265d284b Mon Sep 17 00:00:00 2001 From: Christoffer Jansson Date: Tue, 22 Feb 2022 10:51:52 +0100 Subject: [PATCH 020/847] Fix py3 compatibility for webrtc_version_updater Bug: webrtc:13607 Change-Id: I5890dc86286b0a6ece793655bcda15315d415b39 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252060 Reviewed-by: Mirko Bonadei Commit-Queue: Christoffer Jansson Cr-Commit-Position: refs/heads/main@{#36046} --- .../version_updater/update_version.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tools_webrtc/version_updater/update_version.py b/tools_webrtc/version_updater/update_version.py index af1ea0f09f..83e7ce8061 100644 --- a/tools_webrtc/version_updater/update_version.py +++ b/tools_webrtc/version_updater/update_version.py @@ -30,7 +30,7 @@ def FindSrcDirPath(): UPDATE_BRANCH_NAME = 'webrtc_version_update' CHECKOUT_SRC_DIR = FindSrcDirPath() -NOTIFY_EMAIL = 'mbonadei@webrtc.org' +NOTIFY_EMAIL = 'webrtc-trooper@webrtc.org' def _RemovePreviousUpdateBranch(): @@ -47,7 +47,8 @@ def _RemovePreviousUpdateBranch(): def _GetLastAuthor(): """Returns a string with the author of the last commit.""" author = subprocess.check_output( - ['git', 'log', '-1', '--pretty=format:"%an"']).splitlines() + ['git', 'log', '-1', '--pretty=format:"%an"'], + universal_newlines=True).splitlines() return author @@ -57,7 +58,8 @@ def _GetBranches(): 'active' is a string with name of the currently active branch, while 'branches' is the list of all branches. """ - lines = subprocess.check_output(['git', 'branch']).splitlines() + lines = subprocess.check_output(['git', 'branch'], + universal_newlines=True).splitlines() branches = [] active = '' for line in lines: @@ -78,8 +80,8 @@ def _CreateUpdateBranch(): def _UpdateWebRTCVersion(filename): - with open(filename) as f: - content = f.read() + with open(filename, 'rb') as f: + content = f.read().decode('utf-8') d = datetime.datetime.utcnow() # pylint: disable=line-too-long new_content = re.sub( @@ -89,12 +91,13 @@ def _UpdateWebRTCVersion(filename): content, flags=re.MULTILINE) # pylint: enable=line-too-long - with open(filename, 'w') as f: - f.write(new_content) + with open(filename, 'wb') as f: + f.write(new_content.encode('utf-8')) def _IsTreeClean(): - stdout = subprocess.check_output(['git', 'status', '--porcelain']) + stdout = subprocess.check_output(['git', 'status', '--porcelain'], + universal_newlines=True) if len(stdout) == 0: return True return False From 09f5713a6b0416ccc5b5dbcec793c07162bd7fa9 Mon Sep 17 00:00:00 2001 From: Tommi Date: Thu, 17 Feb 2022 13:19:55 +0100 Subject: [PATCH 021/847] Reland "Move VideoTrackSourceProxy creation into VideoTrack." This is a reland of 4bc7223cf0775737a615c677b82c78e49a6a8a2c Original change's description: > Move VideoTrackSourceProxy creation into VideoTrack. > > This CL contains a part of a previously reviewed, landed, reverted, > relanded and re-reverted CL: > https://webrtc-review.googlesource.com/c/src/+/250180 > > Bug: webrtc:13540 > Change-Id: Id6df8da5ff61e3ec90d0b3f3d828e8f670d4931b > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251860 > Reviewed-by: Harald Alvestrand > Auto-Submit: Tomas Gunnarsson > Commit-Queue: Tomas Gunnarsson > Cr-Commit-Position: refs/heads/main@{#36025} Bug: webrtc:13540 Change-Id: I81df66daa40c59ab0b8677d7065f1703f071a10a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252041 Reviewed-by: Sergey Silkin Commit-Queue: Tomas Gunnarsson Cr-Commit-Position: refs/heads/main@{#36047} --- pc/BUILD.gn | 1 + pc/audio_track.h | 4 ++++ pc/video_rtp_receiver.cc | 6 +----- pc/video_track.cc | 18 +++++++++++++----- pc/video_track.h | 17 +++++++++++++---- 5 files changed, 32 insertions(+), 14 deletions(-) diff --git a/pc/BUILD.gn b/pc/BUILD.gn index 277657e6a0..e7b7cc0102 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -1272,6 +1272,7 @@ rtc_library("video_track") { "video_track.h", ] deps = [ + ":rtc_pc_base", "../api:media_stream_interface", "../api:scoped_refptr", "../api:sequence_checker", diff --git a/pc/audio_track.h b/pc/audio_track.h index f357391987..920bb948ba 100644 --- a/pc/audio_track.h +++ b/pc/audio_track.h @@ -21,6 +21,10 @@ namespace webrtc { +// TODO(tommi): Instead of inheriting from `MediaStreamTrack<>`, implement the +// properties directly in this class. `MediaStreamTrack` doesn't guard against +// conflicting access, so we'd need to override those methods anyway in this +// class in order to make sure things are correctly checked. class AudioTrack : public MediaStreamTrack, public ObserverInterface { protected: diff --git a/pc/video_rtp_receiver.cc b/pc/video_rtp_receiver.cc index c5ead9e773..d1f8fb0d96 100644 --- a/pc/video_rtp_receiver.cc +++ b/pc/video_rtp_receiver.cc @@ -41,11 +41,7 @@ VideoRtpReceiver::VideoRtpReceiver( track_(VideoTrackProxyWithInternal::Create( rtc::Thread::Current(), worker_thread, - VideoTrack::Create(receiver_id, - CreateVideoTrackSourceProxy(rtc::Thread::Current(), - worker_thread, - source_), - worker_thread))), + VideoTrack::Create(receiver_id, source_, worker_thread))), attachment_id_(GenerateUniqueId()) { RTC_DCHECK(worker_thread_); SetStreams(streams); diff --git a/pc/video_track.cc b/pc/video_track.cc index 6e749b0526..27274dc095 100644 --- a/pc/video_track.cc +++ b/pc/video_track.cc @@ -23,12 +23,14 @@ namespace webrtc { -VideoTrack::VideoTrack(const std::string& label, - VideoTrackSourceInterface* video_source, - rtc::Thread* worker_thread) +VideoTrack::VideoTrack( + const std::string& label, + rtc::scoped_refptr< + VideoTrackSourceProxyWithInternal> source, + rtc::Thread* worker_thread) : MediaStreamTrack(label), worker_thread_(worker_thread), - video_source_(video_source), + video_source_(std::move(source)), content_hint_(ContentHint::kNone) { RTC_DCHECK_RUN_ON(&signaling_thread_); // Detach the thread checker for VideoSourceBaseGuarded since we'll make calls @@ -130,7 +132,13 @@ rtc::scoped_refptr VideoTrack::Create( const std::string& id, VideoTrackSourceInterface* source, rtc::Thread* worker_thread) { - return rtc::make_ref_counted(id, source, worker_thread); + rtc::scoped_refptr< + VideoTrackSourceProxyWithInternal> + source_proxy = VideoTrackSourceProxy::Create(rtc::Thread::Current(), + worker_thread, source); + + return rtc::make_ref_counted(id, std::move(source_proxy), + worker_thread); } } // namespace webrtc diff --git a/pc/video_track.h b/pc/video_track.h index bf433b5f5a..2bf7f31741 100644 --- a/pc/video_track.h +++ b/pc/video_track.h @@ -22,11 +22,16 @@ #include "api/video/video_source_interface.h" #include "media/base/video_source_base.h" #include "rtc_base/system/no_unique_address.h" +#include "pc/video_track_source_proxy.h" #include "rtc_base/thread.h" #include "rtc_base/thread_annotations.h" namespace webrtc { +// TODO(tommi): Instead of inheriting from `MediaStreamTrack<>`, implement the +// properties directly in this class. `MediaStreamTrack` doesn't guard against +// conflicting access, so we'd need to override those methods anyway in this +// class in order to make sure things are correctly checked. class VideoTrack : public MediaStreamTrack, public rtc::VideoSourceBaseGuarded, public ObserverInterface { @@ -50,9 +55,11 @@ class VideoTrack : public MediaStreamTrack, std::string kind() const override; protected: - VideoTrack(const std::string& id, - VideoTrackSourceInterface* video_source, - rtc::Thread* worker_thread); + VideoTrack( + const std::string& id, + rtc::scoped_refptr< + VideoTrackSourceProxyWithInternal> source, + rtc::Thread* worker_thread); ~VideoTrack(); private: @@ -61,7 +68,9 @@ class VideoTrack : public MediaStreamTrack, RTC_NO_UNIQUE_ADDRESS webrtc::SequenceChecker signaling_thread_; rtc::Thread* const worker_thread_; - const rtc::scoped_refptr video_source_; + const rtc::scoped_refptr< + VideoTrackSourceProxyWithInternal> + video_source_; ContentHint content_hint_ RTC_GUARDED_BY(&signaling_thread_); // Cached `enabled` state for the worker thread. This is kept in sync with // the state maintained on the signaling thread via set_enabled() but can From bad789d92f964464cc6fbc40c6f9ab12f27a3ce6 Mon Sep 17 00:00:00 2001 From: Evan Shrubsole Date: Tue, 22 Feb 2022 11:19:22 +0100 Subject: [PATCH 022/847] Fix FrameBuffer3 trial video_receive_stream2 tests Change-Id: I9673915d4b5b53adea08abb54311af794cf40de8 Bug: webrtc:13658 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252061 Reviewed-by: Ilya Nikolaevskiy Commit-Queue: Evan Shrubsole Cr-Commit-Position: refs/heads/main@{#36048} --- video/video_receive_stream2_unittest.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/video/video_receive_stream2_unittest.cc b/video/video_receive_stream2_unittest.cc index 41e0ecba71..3c6640a711 100644 --- a/video/video_receive_stream2_unittest.cc +++ b/video/video_receive_stream2_unittest.cc @@ -80,7 +80,7 @@ class VideoReceiveStream2Test : public ::testing::Test { h264_decoder_factory_(&mock_h264_video_decoder_), config_(&mock_transport_, &h264_decoder_factory_), call_stats_(Clock::GetRealTimeClock(), loop_.task_queue()), - field_trials_("WebRTC-FrameBuffer3/Enabled/") {} + field_trials_("WebRTC-FrameBuffer3/arm:FrameBuffer3/") {} ~VideoReceiveStream2Test() override { if (video_receive_stream_) video_receive_stream_->UnregisterFromTransport(); @@ -539,8 +539,8 @@ class VideoReceiveStream2TestWithSimulatedClock VideoReceiveStream2TestWithSimulatedClock() : time_controller_(Timestamp::Millis(4711)), field_trials_(std::get<1>(GetParam()) - ? "WebRTC-FrameBuffer3/Enabled/" - : "WebRTC-FrameBuffer3/Disabled/"), + ? "WebRTC-FrameBuffer3/arm:FrameBuffer3/" + : "WebRTC-FrameBuffer3/arm:FrameBuffer2/"), fake_decoder_factory_([this] { return std::make_unique([this] { OnFrameDecoded(); }); }), From 70098a80ac55d73804870364f7263f69231e10a5 Mon Sep 17 00:00:00 2001 From: Christoffer Jansson Date: Mon, 21 Feb 2022 19:43:36 +0100 Subject: [PATCH 023/847] Add file exclusion for tests we do not want to run in PRESUBMIT Bug: webrtc:13691 Change-Id: I2d71599816cad31471746737235265d2f4b62894 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252000 Reviewed-by: Mirko Bonadei Reviewed-by: Tomas Gunnarsson Commit-Queue: Christoffer Jansson Cr-Commit-Position: refs/heads/main@{#36049} --- PRESUBMIT.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/PRESUBMIT.py b/PRESUBMIT.py index b83f262e3d..5c7db2e9d6 100755 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -819,21 +819,22 @@ def RunPythonTests(input_api, output_api): def Join(*args): return input_api.os_path.join(input_api.PresubmitLocalPath(), *args) + excluded_files = [ + # This test should be run manually after webrtc_dashboard_upload target + # has been built. + 'catapult_uploader_test.py' + ] + test_directories = [ input_api.PresubmitLocalPath(), Join('rtc_tools', 'py_event_log_analyzer'), Join('audio', 'test', 'unittests'), ] + [ root for root, _, files in os.walk(Join('tools_webrtc')) if any( - f.endswith('_test.py') for f in files) + f.endswith('_test.py') and f not in excluded_files for f in files) ] tests = [] - skipped_tests = [ - # This test should be run manually after webrtc_dashboard_upload target - # has been built. - r'catapult_uploader_test\.py$' - ] for directory in test_directories: tests.extend( @@ -842,7 +843,6 @@ def Join(*args): output_api, directory, files_to_check=[r'.+_test\.py$'], - files_to_skip=skipped_tests, run_on_python2=False)) return input_api.RunTests(tests, parallel=True) From e20a5247f0a8408986dc4671646e56c21db90f62 Mon Sep 17 00:00:00 2001 From: Christoffer Jansson Date: Tue, 22 Feb 2022 11:57:59 +0100 Subject: [PATCH 024/847] another decode... I went through more thoroghly this time I think I gotem all Bug: webrtc:13607 Change-Id: I0e8773903bff16e807cc32a1a6f0177d43543e44 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252062 Reviewed-by: Mirko Bonadei Commit-Queue: Christoffer Jansson Cr-Commit-Position: refs/heads/main@{#36050} --- tools_webrtc/autoroller/roll_deps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools_webrtc/autoroller/roll_deps.py b/tools_webrtc/autoroller/roll_deps.py index b66cd84435..85ba943e7d 100755 --- a/tools_webrtc/autoroller/roll_deps.py +++ b/tools_webrtc/autoroller/roll_deps.py @@ -450,7 +450,7 @@ def GetClangRev(lines): raise RollError('Could not parse Clang revision!') with open(CLANG_UPDATE_SCRIPT_LOCAL_PATH, 'rb') as f: - current_lines = f.readlines() + current_lines = f.readlines().decode('utf-8') current_rev = GetClangRev(current_lines) new_clang_update_py = ReadRemoteCrFile(CLANG_UPDATE_SCRIPT_URL_PATH, From 36cf4787d064635578cde107c9b993379b17fec6 Mon Sep 17 00:00:00 2001 From: Christoffer Jansson Date: Tue, 22 Feb 2022 14:17:00 +0100 Subject: [PATCH 025/847] Remove binary mode Realized I could actually test this fully locally using: vpython3 roll_deps.py --dry-run -i No-Try: True Bug: webrtc:13607 Change-Id: Ibd4d8c002f76b3524da22056a34645178c66687a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252064 Reviewed-by: Mirko Bonadei Commit-Queue: Christoffer Jansson Cr-Commit-Position: refs/heads/main@{#36051} --- tools_webrtc/autoroller/roll_deps.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools_webrtc/autoroller/roll_deps.py b/tools_webrtc/autoroller/roll_deps.py index 85ba943e7d..2f374eb70c 100755 --- a/tools_webrtc/autoroller/roll_deps.py +++ b/tools_webrtc/autoroller/roll_deps.py @@ -449,8 +449,8 @@ def GetClangRev(lines): return match.group(1) raise RollError('Could not parse Clang revision!') - with open(CLANG_UPDATE_SCRIPT_LOCAL_PATH, 'rb') as f: - current_lines = f.readlines().decode('utf-8') + with open(CLANG_UPDATE_SCRIPT_LOCAL_PATH, 'r') as f: + current_lines = f.readlines() current_rev = GetClangRev(current_lines) new_clang_update_py = ReadRemoteCrFile(CLANG_UPDATE_SCRIPT_URL_PATH, From 974750e928ef7335105daeadcae15372bf051913 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Tue, 22 Feb 2022 14:02:05 -0800 Subject: [PATCH 026/847] Roll chromium_revision 1d65e161b8..fcc50d8cd1 (968255:973924) Change log: https://chromium.googlesource.com/chromium/src/+log/1d65e161b8..fcc50d8cd1 Full diff: https://chromium.googlesource.com/chromium/src/+/1d65e161b8..fcc50d8cd1 Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/5de2454055..b3563c3762 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/bcaab68639..cd91260149 * src/buildtools: https://chromium.googlesource.com/chromium/src/buildtools/+log/2a745cc87d..93c15529c3 * src/buildtools/third_party/libc++abi/trunk: https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git/+log/77c52e2f68..738dc100c6 * src/buildtools/third_party/libunwind/trunk: https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git/+log/b86911d6e7..8cd7191937 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/9adcdab416..d95306e336 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/67a0c97ff4..da335163eb * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/f30eafbf52..c033af7edf * src/third_party/android_build_tools/aapt2: 0yR8wK_fSMgdVKwnx4nRPi-amaLV7Kcr4Os6mg_DGI4C..yQIf5Ev_-q9u6Pr_a0APd1dHcImJSmotVADw4Pj151QC * src/third_party/android_deps/libs/com_android_tools_desugar_jdk_libs: version:2@1.1.1.cr0..version:2@1.1.5.cr1 * src/third_party/android_deps/libs/com_android_tools_desugar_jdk_libs_configuration: version:2@1.1.1.cr0..version:2@1.1.5.cr1 * src/third_party/android_sdk/public: Ez2NWws2SJYCF6qw2O-mSCqK6424l3ZdSTpppLyVR_cC..PGPmqJtSIQ84If155ba7iTU846h5WJ-bL5d_OoUWEWYC * src/third_party/androidx: EqXyh_ypMvWmNBJPk_Xk9bp-pc8lerSz48cySEsnbMwC..F8k604AvABforYzuHHVPAKR63JI50fyxFmcXAgoRluEC * src/third_party/boringssl/src: https://boringssl.googlesource.com/boringssl.git/+log/123eaaef26..68addd2f71 * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/25f38be662..5242864bdf * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/1b93e14c92..42cf2acbae * src/third_party/freetype/src: https://chromium.googlesource.com/chromium/src/third_party/freetype2.git/+log/24db55ecb8..bcdfa38692 * src/third_party/googletest/src: https://chromium.googlesource.com/external/github.com/google/googletest.git/+log/43efa0a4ef..c9461a9b55 * src/third_party/icu: https://chromium.googlesource.com/chromium/deps/icu.git/+log/2e0f298944..b867f209e4 * src/third_party/libaom/source/libaom: https://aomedia.googlesource.com/aom.git/+log/c9feb209a4..a08d3f6c32 * src/third_party/libvpx/source/libvpx: https://chromium.googlesource.com/webm/libvpx.git/+log/51415c4076..df0d06de6d * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/605bd3a3ad..dfc6cffca9 * src/third_party/turbine: ZweGxnankyMPNqORbYcApzrOXpyg-9XcK7_-qdjELlcC..VhmfIPuSDHHeilnA7WC0MhR9ShZNF25tA0Te4RYIZG8C * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/55c693b555..b86885e473 * src/tools/luci-go: git_revision:462d0a9cdbe947cd652fcd0c54f64ebc712858a5..git_revision:582e828c5a8aaf5cdd0ad1d5465fb9092b71eab8 * src/tools/luci-go: git_revision:462d0a9cdbe947cd652fcd0c54f64ebc712858a5..git_revision:582e828c5a8aaf5cdd0ad1d5465fb9092b71eab8 DEPS diff: https://chromium.googlesource.com/chromium/src/+/1d65e161b8..fcc50d8cd1/DEPS Clang version changed llvmorg-14-init-17086-g38e16e1c:llvmorg-15-init-1995-g5bec1ea7 Details: https://chromium.googlesource.com/chromium/src/+/1d65e161b8..fcc50d8cd1/tools/clang/scripts/update.py BUG=None Change-Id: Ib40bb546873ad3fd40beeafbf15dfa9fe1876a24 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252141 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36052} --- DEPS | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/DEPS b/DEPS index 9bc9237a85..048cc037c5 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': '1d65e161b823702fbaed6c1e74bf01008cad2edf', + 'chromium_revision': 'fcc50d8cd150681f0ee7020f38c14963f463c1ee', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,24 +23,24 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@5de2454055b98b7cedb8b3ca31a5e73fd7f2329d', + 'https://chromium.googlesource.com/chromium/src/base@b3563c37627a3ffff99980d7f2732d134b0ad105', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@bcaab68639cce04f2c52c6d65f5199af6d763d75', + 'https://chromium.googlesource.com/chromium/src/build@cd91260149d06af08481668f49dd7ca6753f6a5e', 'src/buildtools': - 'https://chromium.googlesource.com/chromium/src/buildtools@2a745cc87d28e53996469189bc7661811d6f9c34', + 'https://chromium.googlesource.com/chromium/src/buildtools@93c15529c323c6cc12516ef9caac7fd815ee7c82', # 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@9adcdab41620a7c899745609e4083d023e449d1e', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@d95306e336e2033b65128188f59f68eb75df71d7', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@67a0c97ff4b57f30d97825107bee9e112a020f79', + 'https://chromium.googlesource.com/chromium/src/testing@da335163ebeceac8d4b792c9fecb5b82fc30aa15', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@f30eafbf5286fc58f85215253b7807c2b7125361', + 'https://chromium.googlesource.com/chromium/src/third_party@c033af7edf96727b5b9a790b7ce46d2aa598f2e0', 'src/buildtools/linux64': { 'packages': [ @@ -78,9 +78,9 @@ deps = { 'src/buildtools/third_party/libc++/trunk': 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxx.git@79a2e924d96e2fc1e4b937c42efd08898fa472d7', 'src/buildtools/third_party/libc++abi/trunk': - 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git@77c52e2f68f76dbe661420d85f51521805990ae2', + 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git@738dc100c61890744f9e78cac27c71d0a2190781', 'src/buildtools/third_party/libunwind/trunk': - 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git@b86911d6e7455c4be2ddbc390803aecad19cfc3a', + 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git@8cd7191937c9341646c88e39eae63ccd692ace91', 'src/tools/clang/dsymutil': { 'packages': [ @@ -117,7 +117,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_build_tools/aapt2', - 'version': '0yR8wK_fSMgdVKwnx4nRPi-amaLV7Kcr4Os6mg_DGI4C', + 'version': 'yQIf5Ev_-q9u6Pr_a0APd1dHcImJSmotVADw4Pj151QC', }, ], 'condition': 'checkout_android', @@ -136,11 +136,11 @@ deps = { }, 'src/third_party/boringssl/src': - 'https://boringssl.googlesource.com/boringssl.git@123eaaef26abc278f53ae338e9c758eb01c70b08', + 'https://boringssl.googlesource.com/boringssl.git@68addd2f719422cd00f44f06c330457269d3facf', 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@25f38be662aec0c8b1509024001e5cc5254a363c', + 'https://chromium.googlesource.com/catapult.git@5242864bdf5c33c046ad795adfa9e60096e0cf11', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@1b93e14c92416185694f8764be425f82fa0d4242', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@42cf2acbaee8f149fdc08661eece63aaf271b4bc', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -162,7 +162,7 @@ deps = { 'condition': 'checkout_linux', }, 'src/third_party/freetype/src': - 'https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@24db55ecb81ca726b9c7e12e37d54a986c84f014', + 'https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@bcdfa38692d590dda5bc9e4334842abe92ec0ba5', 'src/third_party/harfbuzz-ng/src': 'https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git@0acf466c44143de2e9b9cc0375cb25ec67cb132f', 'src/third_party/google_benchmark/src': { @@ -182,9 +182,9 @@ deps = { 'dep_type': 'cipd', }, 'src/third_party/googletest/src': - 'https://chromium.googlesource.com/external/github.com/google/googletest.git@43efa0a4efd40c78b9210d15373112081899a97c', + 'https://chromium.googlesource.com/external/github.com/google/googletest.git@c9461a9b55ba954df0489bab6420eb297bed846b', 'src/third_party/icu': { - 'url': 'https://chromium.googlesource.com/chromium/deps/icu.git@2e0f2989441ec2f55abec30f48e89981dbac2c34', + 'url': 'https://chromium.googlesource.com/chromium/deps/icu.git@b867f209e4b56b0a8c01aaaba3882ad41e438c4f', }, 'src/third_party/jdk': { 'packages': [ @@ -222,15 +222,15 @@ deps = { 'src/third_party/dav1d/libdav1d': 'https://chromium.googlesource.com/external/github.com/videolan/dav1d.git@cce2b0564d3b0aa1a5e4ec0c561b6a1b8497cebb', 'src/third_party/libaom/source/libaom': - 'https://aomedia.googlesource.com/aom.git@c9feb209a41343981c215072583d385bdda2bab1', + 'https://aomedia.googlesource.com/aom.git@a08d3f6c329a25744712578a70715e5cfd749759', 'src/third_party/libunwindstack': { 'url': 'https://chromium.googlesource.com/chromium/src/third_party/libunwindstack.git@6868358481bb1e5e20d155c1084dc436c88b5e6b', 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@605bd3a3ad96c56f98780e7b4b6b247e1d9e0ae9', + 'https://android.googlesource.com/platform/external/perfetto.git@dfc6cffca9b6a34068386915d50040c6bc142717', 'src/third_party/libvpx/source/libvpx': - 'https://chromium.googlesource.com/webm/libvpx.git@51415c4076578d3cbc32fcd0d683161c3e887814', + 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': 'https://chromium.googlesource.com/libyuv/libyuv.git@b4ddbaf549a1bf5572bf703fd2862d1eb7380c6a', 'src/third_party/lss': { @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@55c693b555dff2de2756ae4cd2e1322737879a6f', + 'https://chromium.googlesource.com/chromium/src/tools@b86885e4731e26eccc70cf53bd595a1730f46a32', 'src/third_party/accessibility_test_framework': { 'packages': [ @@ -384,7 +384,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/androidx', - 'version': 'EqXyh_ypMvWmNBJPk_Xk9bp-pc8lerSz48cySEsnbMwC', + 'version': 'F8k604AvABforYzuHHVPAKR63JI50fyxFmcXAgoRluEC', }, ], 'condition': 'checkout_android', @@ -423,7 +423,7 @@ deps = { }, { 'package': 'chromium/third_party/android_sdk/public/cmdline-tools', - 'version': 'Ez2NWws2SJYCF6qw2O-mSCqK6424l3ZdSTpppLyVR_cC', + 'version': 'PGPmqJtSIQ84If155ba7iTU846h5WJ-bL5d_OoUWEWYC', }, ], 'condition': 'checkout_android', @@ -478,7 +478,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/turbine', - 'version': 'ZweGxnankyMPNqORbYcApzrOXpyg-9XcK7_-qdjELlcC', + 'version': 'VhmfIPuSDHHeilnA7WC0MhR9ShZNF25tA0Te4RYIZG8C', }, ], 'condition': 'checkout_android', @@ -489,11 +489,11 @@ deps = { 'packages': [ { 'package': 'infra/tools/luci/isolate/${{platform}}', - 'version': 'git_revision:462d0a9cdbe947cd652fcd0c54f64ebc712858a5', + 'version': 'git_revision:582e828c5a8aaf5cdd0ad1d5465fb9092b71eab8', }, { 'package': 'infra/tools/luci/swarming/${{platform}}', - 'version': 'git_revision:462d0a9cdbe947cd652fcd0c54f64ebc712858a5', + 'version': 'git_revision:582e828c5a8aaf5cdd0ad1d5465fb9092b71eab8', }, ], 'dep_type': 'cipd', @@ -971,7 +971,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_tools_desugar_jdk_libs', - 'version': 'version:2@1.1.1.cr0', + 'version': 'version:2@1.1.5.cr1', }, ], 'condition': 'checkout_android', @@ -982,7 +982,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_tools_desugar_jdk_libs_configuration', - 'version': 'version:2@1.1.1.cr0', + 'version': 'version:2@1.1.5.cr1', }, ], 'condition': 'checkout_android', From 34cd1d36fa00ccf24b7bf85686c3b60ae01420f7 Mon Sep 17 00:00:00 2001 From: Tommi Date: Thu, 17 Feb 2022 13:28:57 +0100 Subject: [PATCH 027/847] Reland "Use internal() in VideoTrack when invoking the source." This is a reland of 962bf1896185c0d84232f2bfae492eeb04e1236d Original change's description: > Use internal() in VideoTrack when invoking the source. > > This skips going through the proxy and potentially hide a thread hop > should a regression occur. > > This CL contains a part of a previously reviewed, landed, reverted, > relanded and re-reverted CL: > https://webrtc-review.googlesource.com/c/src/+/250180 > > Bug: webrtc:13540 > Change-Id: If098f5c04a263547fb53f44e9f9738b8e941a294 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251861 > Reviewed-by: Harald Alvestrand > Commit-Queue: Tomas Gunnarsson > Cr-Commit-Position: refs/heads/main@{#36026} Bug: webrtc:13540 Change-Id: I00e998be6614b1a478ddf02110b3a2d67bd42274 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252043 Reviewed-by: Sergey Silkin Reviewed-by: Harald Alvestrand Commit-Queue: Tomas Gunnarsson Cr-Commit-Position: refs/heads/main@{#36053} --- pc/video_track.cc | 10 +++++++--- pc/video_track.h | 3 +++ pc/video_track_unittest.cc | 11 ++++++++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/pc/video_track.cc b/pc/video_track.cc index 27274dc095..4559181ce7 100644 --- a/pc/video_track.cc +++ b/pc/video_track.cc @@ -57,18 +57,18 @@ void VideoTrack::AddOrUpdateSink(rtc::VideoSinkInterface* sink, VideoSourceBaseGuarded::AddOrUpdateSink(sink, wants); rtc::VideoSinkWants modified_wants = wants; modified_wants.black_frames = !enabled_w_; - video_source_->AddOrUpdateSink(sink, modified_wants); + video_source_->internal()->AddOrUpdateSink(sink, modified_wants); } void VideoTrack::RemoveSink(rtc::VideoSinkInterface* sink) { RTC_DCHECK_RUN_ON(worker_thread_); VideoSourceBaseGuarded::RemoveSink(sink); - video_source_->RemoveSink(sink); + video_source_->internal()->RemoveSink(sink); } void VideoTrack::RequestRefreshFrame() { RTC_DCHECK_RUN_ON(worker_thread_); - video_source_->RequestRefreshFrame(); + video_source_->internal()->RequestRefreshFrame(); } VideoTrackSourceInterface* VideoTrack::GetSource() const { @@ -76,6 +76,10 @@ VideoTrackSourceInterface* VideoTrack::GetSource() const { return video_source_.get(); } +VideoTrackSourceInterface* VideoTrack::GetSourceInternal() const { + return video_source_->internal(); +} + VideoTrackInterface::ContentHint VideoTrack::content_hint() const { RTC_DCHECK_RUN_ON(&signaling_thread_); return content_hint_; diff --git a/pc/video_track.h b/pc/video_track.h index 2bf7f31741..66262d22d1 100644 --- a/pc/video_track.h +++ b/pc/video_track.h @@ -54,6 +54,9 @@ class VideoTrack : public MediaStreamTrack, MediaStreamTrackInterface::TrackState state() const override; std::string kind() const override; + // Direct access to the non-proxied source object for internal implementation. + VideoTrackSourceInterface* GetSourceInternal() const; + protected: VideoTrack( const std::string& id, diff --git a/pc/video_track_unittest.cc b/pc/video_track_unittest.cc index 6342b608f1..e6dcce7939 100644 --- a/pc/video_track_unittest.cc +++ b/pc/video_track_unittest.cc @@ -40,10 +40,19 @@ class VideoTrackTest : public ::testing::Test { protected: rtc::scoped_refptr video_track_source_; - rtc::scoped_refptr video_track_; + rtc::scoped_refptr video_track_; cricket::FakeFrameSource frame_source_; }; +// VideoTrack::Create will create an API proxy around the source object. +// The `GetSource` method provides access to the proxy object intented for API +// use while the GetSourceInternal() provides direct access to the source object +// as provided to the `VideoTrack::Create` factory function. +TEST_F(VideoTrackTest, CheckApiProxyAndInternalSource) { + EXPECT_NE(video_track_->GetSource(), video_track_source_.get()); + EXPECT_EQ(video_track_->GetSourceInternal(), video_track_source_.get()); +} + // Test changing the source state also changes the track state. TEST_F(VideoTrackTest, SourceStateChangeTrackState) { EXPECT_EQ(MediaStreamTrackInterface::kLive, video_track_->state()); From 3572650fb7493d91617c9b71eac705b3e8e71bc9 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Tue, 22 Feb 2022 20:02:24 -0800 Subject: [PATCH 028/847] Roll chromium_revision fcc50d8cd1..4ad0798dfd (973924:974045) Change log: https://chromium.googlesource.com/chromium/src/+log/fcc50d8cd1..4ad0798dfd Full diff: https://chromium.googlesource.com/chromium/src/+/fcc50d8cd1..4ad0798dfd Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/b3563c3762..d9e6daa144 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/cd91260149..51ff1c607b * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/d95306e336..329b18ceb3 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/da335163eb..064ccfc12b * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/c033af7edf..3c02c2fa5e * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/5242864bdf..4ac0eac51b * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/42cf2acbae..64f5f26f1a * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/b86885e473..5561a9ea21 DEPS diff: https://chromium.googlesource.com/chromium/src/+/fcc50d8cd1..4ad0798dfd/DEPS No update to Clang. BUG=None Change-Id: Iadfac3bcd49faf58940275280ecfbacfadbbd347 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252200 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36054} --- DEPS | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/DEPS b/DEPS index 048cc037c5..1b25ae0567 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': 'fcc50d8cd150681f0ee7020f38c14963f463c1ee', + 'chromium_revision': '4ad0798dfd0f4955f3d92569e1d25dbe13d268b0', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@b3563c37627a3ffff99980d7f2732d134b0ad105', + 'https://chromium.googlesource.com/chromium/src/base@d9e6daa144c992480b6155143cbc9cbb3d814068', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@cd91260149d06af08481668f49dd7ca6753f6a5e', + 'https://chromium.googlesource.com/chromium/src/build@51ff1c607b9e3e9a4a6d0fc74dbd1ed46dfdd340', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@93c15529c323c6cc12516ef9caac7fd815ee7c82', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@d95306e336e2033b65128188f59f68eb75df71d7', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@329b18ceb3f49dbfee2640e7f5c0adb219015913', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@da335163ebeceac8d4b792c9fecb5b82fc30aa15', + 'https://chromium.googlesource.com/chromium/src/testing@064ccfc12b479a061562809a3760c9b38be5fbf2', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@c033af7edf96727b5b9a790b7ce46d2aa598f2e0', + 'https://chromium.googlesource.com/chromium/src/third_party@3c02c2fa5ed10b0e876ca3f1b5316e41f94d04c0', 'src/buildtools/linux64': { 'packages': [ @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@5242864bdf5c33c046ad795adfa9e60096e0cf11', + 'https://chromium.googlesource.com/catapult.git@4ac0eac51b57114d5a50793dee6ffbda9859850f', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@42cf2acbaee8f149fdc08661eece63aaf271b4bc', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@64f5f26f1a0c8b8333514cdb861847f02d405f36', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@b86885e4731e26eccc70cf53bd595a1730f46a32', + 'https://chromium.googlesource.com/chromium/src/tools@5561a9ea2105d3aad491ed2736b78bf8eaa26214', 'src/third_party/accessibility_test_framework': { 'packages': [ From a05c7502bf272044ab66c36d6eaca6d8a9fa381d Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Tue, 22 Feb 2022 20:06:02 -0800 Subject: [PATCH 029/847] Update WebRTC code version (2022-02-23T04:06:01). Bug: None Change-Id: Ie185725650b1ad700810ef33bef68abd49b6353a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252201 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36055} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index b0c5059680..eada4660a1 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 2022-02-08T04:04:22"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-02-23T04:06:01"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From 3b393ec991ed26a36195c9f41e74b0d7d72e6953 Mon Sep 17 00:00:00 2001 From: Christoffer Jansson Date: Wed, 23 Feb 2022 09:39:10 +0100 Subject: [PATCH 030/847] Fixes escaped line breaks Bug: webrtc:13607 Change-Id: I24c252ecb6d443abb8206e752bdff73ee5084807 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252260 Reviewed-by: Mirko Bonadei Commit-Queue: Christoffer Jansson Cr-Commit-Position: refs/heads/main@{#36056} --- tools_webrtc/gn_check_autofix.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools_webrtc/gn_check_autofix.py b/tools_webrtc/gn_check_autofix.py index f55d125e32..88ba0cc749 100644 --- a/tools_webrtc/gn_check_autofix.py +++ b/tools_webrtc/gn_check_autofix.py @@ -55,7 +55,10 @@ def __exit__(self, exc, value, _tb): def Run(cmd): print('Running:', ' '.join(cmd)) - sub = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + sub = subprocess.Popen(cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + universal_newlines=True) return sub.communicate() @@ -155,14 +158,14 @@ def main(): ] + sys.argv[1:]) mb_output = Run(mb_gen_command) - errors = mb_output[0].decode('utf-8').split('ERROR')[1:] + errors = mb_output[0].split('ERROR')[1:] if mb_output[1]: print(mb_output[1]) return 1 for error in errors: - error = error.splitlines() + error = error.split('\\n') target_msg = 'The target:' if target_msg not in error: target_msg = 'It is not in any dependency of' From 6589def397b2685e617260ee0004fbc969a266aa Mon Sep 17 00:00:00 2001 From: Tommi Date: Thu, 17 Feb 2022 23:36:47 +0100 Subject: [PATCH 031/847] Align sender/receiver teardown in RtpTransceiver. This makes SetChannel() consistently make 2 invokes instead of a multiple of senders+receivers (previous minimum was 4 but could be larger). * Stop() doesn't hop to the worker thread. * SetMediaChannel(), an already-required step on the worker thread for senders and *sometimes* for receivers[1], is now consistently required for both. This simplifies transceiver teardown and enables the next bullet. * Transceiver stops all senders and receivers in one go rather than ping ponging between threads. [1] When not required, it was done implicitly inside of Stop(). See changes in `RtpTransceiver::SetChannel` Bug: webrtc:13540 Change-Id: Ied61636c8ef09d782bf519524fff2a31e15219a8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/249797 Reviewed-by: Harald Alvestrand Reviewed-by: Tomas Gunnarsson Commit-Queue: Tomas Gunnarsson Cr-Commit-Position: refs/heads/main@{#36057} --- pc/BUILD.gn | 1 + pc/audio_rtp_receiver.cc | 146 +++++++++++++-------------- pc/audio_rtp_receiver.h | 26 +++-- pc/audio_rtp_receiver_unittest.cc | 3 +- pc/rtc_stats_collector_unittest.cc | 24 ++++- pc/rtp_receiver.h | 21 +++- pc/rtp_sender.h | 5 + pc/rtp_sender_receiver_unittest.cc | 7 +- pc/rtp_transceiver.cc | 59 +++++++---- pc/rtp_transceiver_unittest.cc | 35 ++++--- pc/rtp_transmission_manager.cc | 18 ++-- pc/stats_collector_unittest.cc | 5 +- pc/test/mock_rtp_receiver_internal.h | 2 +- pc/video_rtp_receiver.cc | 115 +++++++++++---------- pc/video_rtp_receiver.h | 13 ++- pc/video_rtp_receiver_unittest.cc | 34 ++++--- 16 files changed, 304 insertions(+), 210 deletions(-) diff --git a/pc/BUILD.gn b/pc/BUILD.gn index e7b7cc0102..1a296c1658 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -1278,6 +1278,7 @@ rtc_library("video_track") { "../api:sequence_checker", "../api/video:video_frame", "../media:rtc_media_base", + "../pc:rtc_pc_base", "../rtc_base", "../rtc_base:checks", "../rtc_base:refcount", diff --git a/pc/audio_rtp_receiver.cc b/pc/audio_rtp_receiver.cc index a49b7ce48e..43294c7e93 100644 --- a/pc/audio_rtp_receiver.cc +++ b/pc/audio_rtp_receiver.cc @@ -25,20 +25,24 @@ namespace webrtc { -AudioRtpReceiver::AudioRtpReceiver(rtc::Thread* worker_thread, - std::string receiver_id, - std::vector stream_ids, - bool is_unified_plan) +AudioRtpReceiver::AudioRtpReceiver( + rtc::Thread* worker_thread, + std::string receiver_id, + std::vector stream_ids, + bool is_unified_plan, + cricket::VoiceMediaChannel* voice_channel /*= nullptr*/) : AudioRtpReceiver(worker_thread, receiver_id, CreateStreamsFromIds(std::move(stream_ids)), - is_unified_plan) {} + is_unified_plan, + voice_channel) {} AudioRtpReceiver::AudioRtpReceiver( rtc::Thread* worker_thread, const std::string& receiver_id, const std::vector>& streams, - bool is_unified_plan) + bool is_unified_plan, + cricket::VoiceMediaChannel* voice_channel /*= nullptr*/) : worker_thread_(worker_thread), id_(receiver_id), source_(rtc::make_ref_counted( @@ -49,7 +53,8 @@ AudioRtpReceiver::AudioRtpReceiver( track_(AudioTrackProxyWithInternal::Create( rtc::Thread::Current(), AudioTrack::Create(receiver_id, source_))), - cached_track_enabled_(track_->enabled()), + media_channel_(voice_channel), + cached_track_enabled_(track_->internal()->enabled()), attachment_id_(GenerateUniqueId()), worker_thread_safety_(PendingTaskSafetyFlag::CreateDetachedInactive()) { RTC_DCHECK(worker_thread_); @@ -69,15 +74,15 @@ AudioRtpReceiver::~AudioRtpReceiver() { void AudioRtpReceiver::OnChanged() { RTC_DCHECK_RUN_ON(&signaling_thread_checker_); - if (cached_track_enabled_ != track_->enabled()) { - cached_track_enabled_ = track_->enabled(); - worker_thread_->PostTask(ToQueuedTask( - worker_thread_safety_, - [this, enabled = cached_track_enabled_, volume = cached_volume_]() { - RTC_DCHECK_RUN_ON(worker_thread_); - Reconfigure(enabled, volume); - })); - } + const bool enabled = track_->internal()->enabled(); + if (cached_track_enabled_ == enabled) + return; + cached_track_enabled_ = enabled; + worker_thread_->PostTask( + ToQueuedTask(worker_thread_safety_, [this, enabled]() { + RTC_DCHECK_RUN_ON(worker_thread_); + Reconfigure(enabled); + })); } // RTC_RUN_ON(worker_thread_) @@ -97,20 +102,18 @@ void AudioRtpReceiver::OnSetVolume(double volume) { RTC_DCHECK_GE(volume, 0); RTC_DCHECK_LE(volume, 10); - // Update the cached_volume_ even when stopped, to allow clients to set the - // volume before starting/restarting, eg see crbug.com/1272566. - cached_volume_ = volume; - - // When the track is disabled, the volume of the source, which is the - // corresponding WebRtc Voice Engine channel will be 0. So we do not allow - // setting the volume to the source when the track is disabled. - if (track_->enabled()) { - worker_thread_->PostTask( - ToQueuedTask(worker_thread_safety_, [this, volume = cached_volume_]() { - RTC_DCHECK_RUN_ON(worker_thread_); - SetOutputVolume_w(volume); - })); - } + bool track_enabled = track_->internal()->enabled(); + worker_thread_->Invoke(RTC_FROM_HERE, [&]() { + RTC_DCHECK_RUN_ON(worker_thread_); + // Update the cached_volume_ even when stopped, to allow clients to set + // the volume before starting/restarting, eg see crbug.com/1272566. + cached_volume_ = volume; + // When the track is disabled, the volume of the source, which is the + // corresponding WebRtc Voice Engine channel will be 0. So we do not + // allow setting the volume to the source when the track is disabled. + if (track_enabled) + SetOutputVolume_w(volume); + }); } rtc::scoped_refptr AudioRtpReceiver::dtls_transport() @@ -159,52 +162,49 @@ AudioRtpReceiver::GetFrameDecryptor() const { void AudioRtpReceiver::Stop() { RTC_DCHECK_RUN_ON(&signaling_thread_checker_); - // TODO(deadbeef): Need to do more here to fully stop receiving packets. source_->SetState(MediaSourceInterface::kEnded); - - worker_thread_->Invoke(RTC_FROM_HERE, [&]() { - RTC_DCHECK_RUN_ON(worker_thread_); - - if (media_channel_) - SetOutputVolume_w(0.0); - - SetMediaChannel_w(nullptr); - }); + track_->internal()->set_ended(); } -void AudioRtpReceiver::StopAndEndTrack() { +void AudioRtpReceiver::SetSourceEnded() { RTC_DCHECK_RUN_ON(&signaling_thread_checker_); - Stop(); - track_->internal()->set_ended(); + source_->SetState(MediaSourceInterface::kEnded); } +// RTC_RUN_ON(&signaling_thread_checker_) void AudioRtpReceiver::RestartMediaChannel(absl::optional ssrc) { - RTC_DCHECK_RUN_ON(&signaling_thread_checker_); + bool enabled = track_->internal()->enabled(); MediaSourceInterface::SourceState state = source_->state(); - worker_thread_->Invoke( - RTC_FROM_HERE, - [&, enabled = cached_track_enabled_, volume = cached_volume_]() { - RTC_DCHECK_RUN_ON(worker_thread_); - if (!media_channel_) - return; // Can't restart. - - if (state != MediaSourceInterface::kInitializing) { - if (ssrc_ == ssrc) - return; - source_->Stop(media_channel_, ssrc_); - } - - ssrc_ = std::move(ssrc); - source_->Start(media_channel_, ssrc_); - if (ssrc_) { - media_channel_->SetBaseMinimumPlayoutDelayMs(*ssrc_, delay_.GetMs()); - } - - Reconfigure(enabled, volume); - }); + worker_thread_->Invoke(RTC_FROM_HERE, [&]() { + RTC_DCHECK_RUN_ON(worker_thread_); + RestartMediaChannel_w(std::move(ssrc), enabled, state); + }); source_->SetState(MediaSourceInterface::kLive); } +// RTC_RUN_ON(worker_thread_) +void AudioRtpReceiver::RestartMediaChannel_w( + absl::optional ssrc, + bool track_enabled, + MediaSourceInterface::SourceState state) { + if (!media_channel_) + return; // Can't restart. + + if (state != MediaSourceInterface::kInitializing) { + if (ssrc_ == ssrc) + return; + source_->Stop(media_channel_, ssrc_); + } + + ssrc_ = std::move(ssrc); + source_->Start(media_channel_, ssrc_); + if (ssrc_) { + media_channel_->SetBaseMinimumPlayoutDelayMs(*ssrc_, delay_.GetMs()); + } + + Reconfigure(track_enabled); +} + void AudioRtpReceiver::SetupMediaChannel(uint32_t ssrc) { RTC_DCHECK_RUN_ON(&signaling_thread_checker_); RestartMediaChannel(ssrc); @@ -284,10 +284,10 @@ void AudioRtpReceiver::SetDepacketizerToDecoderFrameTransformer( } // RTC_RUN_ON(worker_thread_) -void AudioRtpReceiver::Reconfigure(bool track_enabled, double volume) { +void AudioRtpReceiver::Reconfigure(bool track_enabled) { RTC_DCHECK(media_channel_); - SetOutputVolume_w(track_enabled ? volume : 0); + SetOutputVolume_w(track_enabled ? cached_volume_ : 0); if (ssrc_ && frame_decryptor_) { // Reattach the frame decryptor if we were reconfigured. @@ -318,18 +318,12 @@ void AudioRtpReceiver::SetJitterBufferMinimumDelay( } void AudioRtpReceiver::SetMediaChannel(cricket::MediaChannel* media_channel) { - RTC_DCHECK_RUN_ON(&signaling_thread_checker_); + RTC_DCHECK_RUN_ON(worker_thread_); RTC_DCHECK(media_channel == nullptr || media_channel->media_type() == media_type()); + if (!media_channel && media_channel_) + SetOutputVolume_w(0.0); - worker_thread_->Invoke(RTC_FROM_HERE, [&] { - RTC_DCHECK_RUN_ON(worker_thread_); - SetMediaChannel_w(media_channel); - }); -} - -// RTC_RUN_ON(worker_thread_) -void AudioRtpReceiver::SetMediaChannel_w(cricket::MediaChannel* media_channel) { media_channel ? worker_thread_safety_->SetAlive() : worker_thread_safety_->SetNotAlive(); media_channel_ = static_cast(media_channel); diff --git a/pc/audio_rtp_receiver.h b/pc/audio_rtp_receiver.h index 978c550dfe..6f70243c0f 100644 --- a/pc/audio_rtp_receiver.h +++ b/pc/audio_rtp_receiver.h @@ -45,16 +45,24 @@ class AudioRtpReceiver : public ObserverInterface, public AudioSourceInterface::AudioObserver, public RtpReceiverInternal { public: + // The constructor supports optionally passing the voice channel to the + // instance at construction time without having to call `SetMediaChannel()` + // on the worker thread straight after construction. + // However, when using that, the assumption is that right after construction, + // a call to either `SetupUnsignaledMediaChannel` or `SetupMediaChannel` + // will be made, which will internally start the source on the worker thread. AudioRtpReceiver(rtc::Thread* worker_thread, std::string receiver_id, std::vector stream_ids, - bool is_unified_plan); + bool is_unified_plan, + cricket::VoiceMediaChannel* voice_channel = nullptr); // TODO(https://crbug.com/webrtc/9480): Remove this when streams() is removed. AudioRtpReceiver( rtc::Thread* worker_thread, const std::string& receiver_id, const std::vector>& streams, - bool is_unified_plan); + bool is_unified_plan, + cricket::VoiceMediaChannel* media_channel = nullptr); virtual ~AudioRtpReceiver(); // ObserverInterface implementation @@ -90,7 +98,7 @@ class AudioRtpReceiver : public ObserverInterface, // RtpReceiverInternal implementation. void Stop() override; - void StopAndEndTrack() override; + void SetSourceEnded() override; void SetupMediaChannel(uint32_t ssrc) override; void SetupUnsignaledMediaChannel() override; uint32_t ssrc() const override; @@ -114,12 +122,14 @@ class AudioRtpReceiver : public ObserverInterface, override; private: - void RestartMediaChannel(absl::optional ssrc); - void Reconfigure(bool track_enabled, double volume) + void RestartMediaChannel(absl::optional ssrc) + RTC_RUN_ON(&signaling_thread_checker_); + void RestartMediaChannel_w(absl::optional ssrc, + bool track_enabled, + MediaSourceInterface::SourceState state) RTC_RUN_ON(worker_thread_); + void Reconfigure(bool track_enabled) RTC_RUN_ON(worker_thread_); void SetOutputVolume_w(double volume) RTC_RUN_ON(worker_thread_); - void SetMediaChannel_w(cricket::MediaChannel* media_channel) - RTC_RUN_ON(worker_thread_); RTC_NO_UNIQUE_ADDRESS SequenceChecker signaling_thread_checker_; rtc::Thread* const worker_thread_; @@ -132,7 +142,7 @@ class AudioRtpReceiver : public ObserverInterface, std::vector> streams_ RTC_GUARDED_BY(&signaling_thread_checker_); bool cached_track_enabled_ RTC_GUARDED_BY(&signaling_thread_checker_); - double cached_volume_ RTC_GUARDED_BY(&signaling_thread_checker_) = 1.0; + double cached_volume_ RTC_GUARDED_BY(worker_thread_) = 1.0; RtpReceiverObserverInterface* observer_ RTC_GUARDED_BY(&signaling_thread_checker_) = nullptr; bool received_first_packet_ RTC_GUARDED_BY(&signaling_thread_checker_) = diff --git a/pc/audio_rtp_receiver_unittest.cc b/pc/audio_rtp_receiver_unittest.cc index 763677b046..294e580525 100644 --- a/pc/audio_rtp_receiver_unittest.cc +++ b/pc/audio_rtp_receiver_unittest.cc @@ -24,6 +24,7 @@ using ::testing::Mock; static const int kTimeOut = 100; static const double kDefaultVolume = 1; static const double kVolume = 3.7; +static const double kVolumeMuted = 0.0; static const uint32_t kSsrc = 3; namespace webrtc { @@ -42,8 +43,8 @@ class AudioRtpReceiverTest : public ::testing::Test { } ~AudioRtpReceiverTest() { + EXPECT_CALL(media_channel_, SetOutputVolume(kSsrc, kVolumeMuted)); receiver_->SetMediaChannel(nullptr); - receiver_->Stop(); } rtc::Thread* worker_; diff --git a/pc/rtc_stats_collector_unittest.cc b/pc/rtc_stats_collector_unittest.cc index 8f0936c26c..b39621d862 100644 --- a/pc/rtc_stats_collector_unittest.cc +++ b/pc/rtc_stats_collector_unittest.cc @@ -363,7 +363,6 @@ rtc::scoped_refptr CreateMockSender( EXPECT_CALL(*sender, AttachmentId()).WillRepeatedly(Return(attachment_id)); EXPECT_CALL(*sender, stream_ids()).WillRepeatedly(Return(local_stream_ids)); EXPECT_CALL(*sender, SetTransceiverAsStopped()); - EXPECT_CALL(*sender, Stop()); return sender; } @@ -389,7 +388,7 @@ rtc::scoped_refptr CreateMockReceiver( return params; })); EXPECT_CALL(*receiver, AttachmentId()).WillRepeatedly(Return(attachment_id)); - EXPECT_CALL(*receiver, StopAndEndTrack()); + EXPECT_CALL(*receiver, Stop()).WillRepeatedly(Return()); return receiver; } @@ -460,6 +459,8 @@ class RTCStatsCollectorWrapper { rtc::scoped_refptr sender = CreateMockSender(media_type, track, ssrc, attachment_id, {}); + EXPECT_CALL(*sender, Stop()); + EXPECT_CALL(*sender, SetMediaChannel(_)); pc_->AddSender(sender); return sender; } @@ -490,6 +491,7 @@ class RTCStatsCollectorWrapper { .WillRepeatedly( Return(std::vector>( {remote_stream}))); + EXPECT_CALL(*receiver, SetMediaChannel(_)).WillRepeatedly(Return()); pc_->AddReceiver(receiver); return receiver; } @@ -532,6 +534,7 @@ class RTCStatsCollectorWrapper { voice_sender_info.local_stats[0].ssrc, voice_sender_info.local_stats[0].ssrc + 10, local_stream_ids); EXPECT_CALL(*rtp_sender, SetMediaChannel(_)).WillRepeatedly(Return()); + EXPECT_CALL(*rtp_sender, Stop()); pc_->AddSender(rtp_sender); } @@ -550,7 +553,7 @@ class RTCStatsCollectorWrapper { voice_receiver_info.local_stats[0].ssrc + 10); EXPECT_CALL(*rtp_receiver, streams()) .WillRepeatedly(Return(remote_streams)); - EXPECT_CALL(*rtp_receiver, SetMediaChannel(_)); + EXPECT_CALL(*rtp_receiver, SetMediaChannel(_)).WillRepeatedly(Return()); pc_->AddReceiver(rtp_receiver); } @@ -569,6 +572,7 @@ class RTCStatsCollectorWrapper { video_sender_info.local_stats[0].ssrc, video_sender_info.local_stats[0].ssrc + 10, local_stream_ids); EXPECT_CALL(*rtp_sender, SetMediaChannel(_)).WillRepeatedly(Return()); + EXPECT_CALL(*rtp_sender, Stop()); pc_->AddSender(rtp_sender); } @@ -587,7 +591,7 @@ class RTCStatsCollectorWrapper { video_receiver_info.local_stats[0].ssrc + 10); EXPECT_CALL(*rtp_receiver, streams()) .WillRepeatedly(Return(remote_streams)); - EXPECT_CALL(*rtp_receiver, SetMediaChannel(_)); + EXPECT_CALL(*rtp_receiver, SetMediaChannel(_)).WillRepeatedly(Return()); pc_->AddReceiver(rtp_receiver); } @@ -2691,6 +2695,8 @@ TEST_F(RTCStatsCollectorTest, RTCVideoSourceStatsCollectedForSenderWithTrack) { "LocalVideoTrackID", MediaStreamTrackInterface::kLive, video_source); rtc::scoped_refptr sender = CreateMockSender( cricket::MEDIA_TYPE_VIDEO, video_track, kSsrc, kAttachmentId, {}); + EXPECT_CALL(*sender, Stop()); + EXPECT_CALL(*sender, SetMediaChannel(_)); pc_->AddSender(sender); rtc::scoped_refptr report = stats_->GetStatsReport(); @@ -2734,6 +2740,8 @@ TEST_F(RTCStatsCollectorTest, "LocalVideoTrackID", MediaStreamTrackInterface::kLive, video_source); rtc::scoped_refptr sender = CreateMockSender( cricket::MEDIA_TYPE_VIDEO, video_track, kNoSsrc, kAttachmentId, {}); + EXPECT_CALL(*sender, Stop()); + EXPECT_CALL(*sender, SetMediaChannel(_)); pc_->AddSender(sender); rtc::scoped_refptr report = stats_->GetStatsReport(); @@ -2763,6 +2771,8 @@ TEST_F(RTCStatsCollectorTest, /*source=*/nullptr); rtc::scoped_refptr sender = CreateMockSender( cricket::MEDIA_TYPE_VIDEO, video_track, kSsrc, kAttachmentId, {}); + EXPECT_CALL(*sender, Stop()); + EXPECT_CALL(*sender, SetMediaChannel(_)); pc_->AddSender(sender); rtc::scoped_refptr report = stats_->GetStatsReport(); @@ -2785,6 +2795,8 @@ TEST_F(RTCStatsCollectorTest, pc_->AddVoiceChannel("AudioMid", "TransportName", voice_media_info); rtc::scoped_refptr sender = CreateMockSender( cricket::MEDIA_TYPE_AUDIO, /*track=*/nullptr, kSsrc, kAttachmentId, {}); + EXPECT_CALL(*sender, Stop()); + EXPECT_CALL(*sender, SetMediaChannel(_)); pc_->AddSender(sender); rtc::scoped_refptr report = stats_->GetStatsReport(); @@ -3108,6 +3120,8 @@ TEST_F(RTCStatsCollectorTest, rtc::scoped_refptr sender = CreateMockSender( cricket::MEDIA_TYPE_VIDEO, /*track=*/nullptr, kSsrc, kAttachmentId, {}); + EXPECT_CALL(*sender, Stop()); + EXPECT_CALL(*sender, SetMediaChannel(_)); pc_->AddSender(sender); rtc::scoped_refptr report = stats_->GetStatsReport(); @@ -3257,6 +3271,7 @@ TEST_F(RTCStatsCollectorTest, StatsReportedOnZeroSsrc) { MediaStreamTrackInterface::kLive); rtc::scoped_refptr sender = CreateMockSender(cricket::MEDIA_TYPE_AUDIO, track, 0, 49, {}); + EXPECT_CALL(*sender, Stop()); pc_->AddSender(sender); rtc::scoped_refptr report = stats_->GetStatsReport(); @@ -3276,6 +3291,7 @@ TEST_F(RTCStatsCollectorTest, DoNotCrashOnSsrcChange) { MediaStreamTrackInterface::kLive); rtc::scoped_refptr sender = CreateMockSender(cricket::MEDIA_TYPE_AUDIO, track, 4711, 49, {}); + EXPECT_CALL(*sender, Stop()); pc_->AddSender(sender); // We do not generate any matching voice_sender_info stats. diff --git a/pc/rtp_receiver.h b/pc/rtp_receiver.h index 73fc5b9858..7d124dfd69 100644 --- a/pc/rtp_receiver.h +++ b/pc/rtp_receiver.h @@ -42,16 +42,27 @@ namespace webrtc { // Internal class used by PeerConnection. class RtpReceiverInternal : public RtpReceiverInterface { public: - // Stops receiving. The track may be reactivated. + // Call on the signaling thread, to let the receiver know that the the + // embedded source object should enter a stopped/ended state and the track's + // state set to `kEnded`, a final state that cannot be reversed. virtual void Stop() = 0; - // Stops the receiver permanently. - // Causes the associated track to enter kEnded state. Cannot be reversed. - virtual void StopAndEndTrack() = 0; + + // Call on the signaling thread to set the source's state to `ended` before + // clearing the media channel (`SetMediaChannel(nullptr)`) on the worker + // thread. + // The difference between `Stop()` and `SetSourceEnded()` is that the latter + // does not change the state of the associated track. + // NOTE: Calling this function should be followed with a call to + // `SetMediaChannel(nullptr)` on the worker thread, to complete the operation. + virtual void SetSourceEnded() = 0; // Sets the underlying MediaEngine channel associated with this RtpSender. // A VoiceMediaChannel should be used for audio RtpSenders and // a VideoMediaChannel should be used for video RtpSenders. - // Must call SetMediaChannel(nullptr) before the media channel is destroyed. + // NOTE: + // * SetMediaChannel(nullptr) must be called before the media channel is + // destroyed. + // * This method must be invoked on the worker thread. virtual void SetMediaChannel(cricket::MediaChannel* media_channel) = 0; // Configures the RtpReceiver with the underlying media channel, with the diff --git a/pc/rtp_sender.h b/pc/rtp_sender.h index b87f8d4813..ca2d1385ce 100644 --- a/pc/rtp_sender.h +++ b/pc/rtp_sender.h @@ -222,6 +222,11 @@ class RtpSenderBase : public RtpSenderInternal, public ObserverInterface { std::vector stream_ids_; RtpParameters init_parameters_; + // TODO(tommi): `media_channel_` and several other member variables in this + // class (ssrc_, stopped_, etc) are accessed from more than one thread without + // a guard or lock. Internally there are also several Invoke()s that we could + // remove since the upstream code may already be performing several operations + // on the worker thread. cricket::MediaChannel* media_channel_ = nullptr; rtc::scoped_refptr track_; diff --git a/pc/rtp_sender_receiver_unittest.cc b/pc/rtp_sender_receiver_unittest.cc index 2c6bc7b71a..d947b8b3e9 100644 --- a/pc/rtp_sender_receiver_unittest.cc +++ b/pc/rtp_sender_receiver_unittest.cc @@ -347,7 +347,7 @@ class RtpSenderReceiverTest void DestroyAudioRtpReceiver() { if (!audio_rtp_receiver_) return; - audio_rtp_receiver_->Stop(); + audio_rtp_receiver_->SetMediaChannel(nullptr); audio_rtp_receiver_ = nullptr; VerifyVoiceChannelNoOutput(); } @@ -356,6 +356,7 @@ class RtpSenderReceiverTest if (!video_rtp_receiver_) return; video_rtp_receiver_->Stop(); + video_rtp_receiver_->SetMediaChannel(nullptr); video_rtp_receiver_ = nullptr; VerifyVideoChannelNoOutput(); } @@ -1640,7 +1641,7 @@ TEST_F(RtpSenderReceiverTest, AudioReceiverCannotSetFrameDecryptorAfterStop) { rtc::scoped_refptr fake_frame_decryptor( new FakeFrameDecryptor()); EXPECT_EQ(nullptr, audio_rtp_receiver_->GetFrameDecryptor()); - audio_rtp_receiver_->Stop(); + audio_rtp_receiver_->SetMediaChannel(nullptr); audio_rtp_receiver_->SetFrameDecryptor(fake_frame_decryptor); // TODO(webrtc:9926) - Validate media channel not set once fakes updated. DestroyAudioRtpReceiver(); @@ -1687,7 +1688,7 @@ TEST_F(RtpSenderReceiverTest, VideoReceiverCannotSetFrameDecryptorAfterStop) { rtc::scoped_refptr fake_frame_decryptor( new FakeFrameDecryptor()); EXPECT_EQ(nullptr, video_rtp_receiver_->GetFrameDecryptor()); - video_rtp_receiver_->Stop(); + video_rtp_receiver_->SetMediaChannel(nullptr); video_rtp_receiver_->SetFrameDecryptor(fake_frame_decryptor); // TODO(webrtc:9926) - Validate media channel not set once fakes updated. DestroyVideoRtpReceiver(); diff --git a/pc/rtp_transceiver.cc b/pc/rtp_transceiver.cc index c8afec899a..013277fa53 100644 --- a/pc/rtp_transceiver.cc +++ b/pc/rtp_transceiver.cc @@ -212,26 +212,34 @@ void RtpTransceiver::SetChannel( } }); - for (const auto& sender : senders_) { - sender->internal()->SetMediaChannel(channel_ ? channel_->media_channel() - : nullptr); - } - RTC_DCHECK_BLOCK_COUNT_NO_MORE_THAN(1); - for (const auto& receiver : receivers_) { - if (!channel_) { - receiver->internal()->Stop(); - } else { - receiver->internal()->SetMediaChannel(channel_->media_channel()); - } + if (!channel_) { + for (const auto& receiver : receivers_) + receiver->internal()->SetSourceEnded(); + RTC_DCHECK_BLOCK_COUNT_NO_MORE_THAN(1); // There should not be an invoke. } - // Destroy the channel, if we had one, now _after_ updating the receivers who - // might have had references to the previous channel. - if (channel_to_delete) { - channel_manager_->DestroyChannel(channel_to_delete); + if (channel_to_delete || !senders_.empty() || !receivers_.empty()) { + channel_manager_->worker_thread()->Invoke(RTC_FROM_HERE, [&]() { + auto* media_channel = channel_ ? channel_->media_channel() : nullptr; + for (const auto& sender : senders_) { + sender->internal()->SetMediaChannel(media_channel); + } + + for (const auto& receiver : receivers_) { + receiver->internal()->SetMediaChannel(media_channel); + } + + // Destroy the channel, if we had one, now _after_ updating the receivers + // who might have had references to the previous channel. + if (channel_to_delete) { + channel_manager_->DestroyChannel(channel_to_delete); + } + }); } + + RTC_DCHECK_BLOCK_COUNT_NO_MORE_THAN(2); } void RtpTransceiver::AddSender( @@ -272,6 +280,7 @@ void RtpTransceiver::AddReceiver( } bool RtpTransceiver::RemoveReceiver(RtpReceiverInterface* receiver) { + RTC_DCHECK_RUN_ON(thread_); RTC_DCHECK(!unified_plan_); if (receiver) { RTC_DCHECK_EQ(media_type(), receiver->media_type()); @@ -280,8 +289,13 @@ bool RtpTransceiver::RemoveReceiver(RtpReceiverInterface* receiver) { if (it == receivers_.end()) { return false; } - // `Stop()` will clear the internally cached pointer to the media channel. + (*it)->internal()->Stop(); + channel_manager_->worker_thread()->Invoke(RTC_FROM_HERE, [&]() { + // `Stop()` will clear the receiver's pointer to the media channel. + (*it)->internal()->SetMediaChannel(nullptr); + }); + receivers_.erase(it); return true; } @@ -399,15 +413,22 @@ void RtpTransceiver::StopSendingAndReceiving() { // // 3. Stop sending media with sender. // + RTC_DCHECK_RUN_ON(thread_); + // 4. Send an RTCP BYE for each RTP stream that was being sent by sender, as // specified in [RFC3550]. - RTC_DCHECK_RUN_ON(thread_); for (const auto& sender : senders_) sender->internal()->Stop(); - // 5. Stop receiving media with receiver. + // Signal to receiver sources that we're stopping. for (const auto& receiver : receivers_) - receiver->internal()->StopAndEndTrack(); + receiver->internal()->Stop(); + + channel_manager_->worker_thread()->Invoke(RTC_FROM_HERE, [&]() { + // 5 Stop receiving media with receiver. + for (const auto& receiver : receivers_) + receiver->internal()->SetMediaChannel(nullptr); + }); stopping_ = true; direction_ = webrtc::RtpTransceiverDirection::kInactive; diff --git a/pc/rtp_transceiver_unittest.cc b/pc/rtp_transceiver_unittest.cc index d63af92169..df6dd29f31 100644 --- a/pc/rtp_transceiver_unittest.cc +++ b/pc/rtp_transceiver_unittest.cc @@ -146,7 +146,8 @@ class RtpTransceiverUnifiedPlanTest : public ::testing::Test { // Basic tests for Stop() TEST_F(RtpTransceiverUnifiedPlanTest, StopSetsDirection) { - EXPECT_CALL(*receiver_.get(), StopAndEndTrack()); + EXPECT_CALL(*receiver_.get(), Stop()); + EXPECT_CALL(*receiver_.get(), SetMediaChannel(_)); EXPECT_CALL(*sender_.get(), SetTransceiverAsStopped()); EXPECT_CALL(*sender_.get(), Stop()); @@ -204,8 +205,7 @@ class RtpTransceiverTestForHeaderExtensions : public ::testing::Test { } void ClearChannel(cricket::MockChannelInterface& mock_channel) { - EXPECT_CALL(*sender_.get(), SetMediaChannel(nullptr)); - EXPECT_CALL(*receiver_.get(), Stop()); + EXPECT_CALL(*sender_.get(), SetMediaChannel(_)); EXPECT_CALL(mock_channel, SetFirstPacketReceivedCallback(_)); EXPECT_CALL(channel_manager_, DestroyChannel(&mock_channel)) .WillRepeatedly(testing::Return()); @@ -221,7 +221,8 @@ class RtpTransceiverTestForHeaderExtensions : public ::testing::Test { }; TEST_F(RtpTransceiverTestForHeaderExtensions, OffersChannelManagerList) { - EXPECT_CALL(*receiver_.get(), StopAndEndTrack()); + EXPECT_CALL(*receiver_.get(), Stop()); + EXPECT_CALL(*receiver_.get(), SetMediaChannel(_)); EXPECT_CALL(*sender_.get(), SetTransceiverAsStopped()); EXPECT_CALL(*sender_.get(), Stop()); @@ -229,7 +230,8 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, OffersChannelManagerList) { } TEST_F(RtpTransceiverTestForHeaderExtensions, ModifiesDirection) { - EXPECT_CALL(*receiver_.get(), StopAndEndTrack()); + EXPECT_CALL(*receiver_.get(), Stop()); + EXPECT_CALL(*receiver_.get(), SetMediaChannel(_)); EXPECT_CALL(*sender_.get(), SetTransceiverAsStopped()); EXPECT_CALL(*sender_.get(), Stop()); @@ -253,7 +255,8 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, ModifiesDirection) { } TEST_F(RtpTransceiverTestForHeaderExtensions, AcceptsStoppedExtension) { - EXPECT_CALL(*receiver_.get(), StopAndEndTrack()); + EXPECT_CALL(*receiver_.get(), Stop()); + EXPECT_CALL(*receiver_.get(), SetMediaChannel(_)); EXPECT_CALL(*sender_.get(), SetTransceiverAsStopped()); EXPECT_CALL(*sender_.get(), Stop()); @@ -265,7 +268,8 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, AcceptsStoppedExtension) { } TEST_F(RtpTransceiverTestForHeaderExtensions, RejectsUnsupportedExtension) { - EXPECT_CALL(*receiver_.get(), StopAndEndTrack()); + EXPECT_CALL(*receiver_.get(), Stop()); + EXPECT_CALL(*receiver_.get(), SetMediaChannel(_)); EXPECT_CALL(*sender_.get(), SetTransceiverAsStopped()); EXPECT_CALL(*sender_.get(), Stop()); @@ -279,7 +283,8 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, RejectsUnsupportedExtension) { TEST_F(RtpTransceiverTestForHeaderExtensions, RejectsStoppedMandatoryExtensions) { - EXPECT_CALL(*receiver_.get(), StopAndEndTrack()); + EXPECT_CALL(*receiver_.get(), Stop()); + EXPECT_CALL(*receiver_.get(), SetMediaChannel(_)); EXPECT_CALL(*sender_.get(), SetTransceiverAsStopped()); EXPECT_CALL(*sender_.get(), Stop()); @@ -299,7 +304,8 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, TEST_F(RtpTransceiverTestForHeaderExtensions, NoNegotiatedHdrExtsWithoutChannel) { - EXPECT_CALL(*receiver_.get(), StopAndEndTrack()); + EXPECT_CALL(*receiver_.get(), Stop()); + EXPECT_CALL(*receiver_.get(), SetMediaChannel(_)); EXPECT_CALL(*sender_.get(), SetTransceiverAsStopped()); EXPECT_CALL(*sender_.get(), Stop()); EXPECT_THAT(transceiver_.HeaderExtensionsNegotiated(), ElementsAre()); @@ -308,8 +314,8 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, TEST_F(RtpTransceiverTestForHeaderExtensions, NoNegotiatedHdrExtsWithChannelWithoutNegotiation) { const std::string content_name("my_mid"); - EXPECT_CALL(*receiver_.get(), SetMediaChannel(_)); - EXPECT_CALL(*receiver_.get(), StopAndEndTrack()); + EXPECT_CALL(*receiver_.get(), SetMediaChannel(_)).WillRepeatedly(Return()); + EXPECT_CALL(*receiver_.get(), Stop()).WillRepeatedly(Return()); EXPECT_CALL(*sender_.get(), SetMediaChannel(_)); EXPECT_CALL(*sender_.get(), SetTransceiverAsStopped()); EXPECT_CALL(*sender_.get(), Stop()); @@ -329,8 +335,8 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, TEST_F(RtpTransceiverTestForHeaderExtensions, ReturnsNegotiatedHdrExts) { const std::string content_name("my_mid"); - EXPECT_CALL(*receiver_.get(), SetMediaChannel(_)); - EXPECT_CALL(*receiver_.get(), StopAndEndTrack()); + EXPECT_CALL(*receiver_.get(), SetMediaChannel(_)).WillRepeatedly(Return()); + EXPECT_CALL(*receiver_.get(), Stop()).WillRepeatedly(Return()); EXPECT_CALL(*sender_.get(), SetMediaChannel(_)); EXPECT_CALL(*sender_.get(), SetTransceiverAsStopped()); EXPECT_CALL(*sender_.get(), Stop()); @@ -362,7 +368,8 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, ReturnsNegotiatedHdrExts) { TEST_F(RtpTransceiverTestForHeaderExtensions, ReturnsNegotiatedHdrExtsSecondTime) { - EXPECT_CALL(*receiver_.get(), StopAndEndTrack()); + EXPECT_CALL(*receiver_.get(), Stop()); + EXPECT_CALL(*receiver_.get(), SetMediaChannel(_)); EXPECT_CALL(*sender_.get(), SetTransceiverAsStopped()); EXPECT_CALL(*sender_.get(), Stop()); diff --git a/pc/rtp_transmission_manager.cc b/pc/rtp_transmission_manager.cc index 951d1c38e5..130dc311a4 100644 --- a/pc/rtp_transmission_manager.cc +++ b/pc/rtp_transmission_manager.cc @@ -459,13 +459,14 @@ void RtpTransmissionManager::CreateAudioReceiver( // TODO(https://crbug.com/webrtc/9480): When we remove remote_streams(), use // the constructor taking stream IDs instead. auto audio_receiver = rtc::make_ref_counted( - worker_thread(), remote_sender_info.sender_id, streams, IsUnifiedPlan()); - audio_receiver->SetMediaChannel(voice_media_channel()); + worker_thread(), remote_sender_info.sender_id, streams, IsUnifiedPlan(), + voice_media_channel()); if (remote_sender_info.sender_id == kDefaultAudioSenderId) { audio_receiver->SetupUnsignaledMediaChannel(); } else { audio_receiver->SetupMediaChannel(remote_sender_info.first_ssrc); } + auto receiver = RtpReceiverProxyWithInternal::Create( signaling_thread(), worker_thread(), std::move(audio_receiver)); GetAudioTransceiver()->internal()->AddReceiver(receiver); @@ -483,12 +484,13 @@ void RtpTransmissionManager::CreateVideoReceiver( // the constructor taking stream IDs instead. auto video_receiver = rtc::make_ref_counted( worker_thread(), remote_sender_info.sender_id, streams); - video_receiver->SetMediaChannel(video_media_channel()); - if (remote_sender_info.sender_id == kDefaultVideoSenderId) { - video_receiver->SetupUnsignaledMediaChannel(); - } else { - video_receiver->SetupMediaChannel(remote_sender_info.first_ssrc); - } + + video_receiver->SetupMediaChannel( + remote_sender_info.sender_id == kDefaultVideoSenderId + ? absl::nullopt + : absl::optional(remote_sender_info.first_ssrc), + video_media_channel()); + auto receiver = RtpReceiverProxyWithInternal::Create( signaling_thread(), worker_thread(), std::move(video_receiver)); GetVideoTransceiver()->internal()->AddReceiver(receiver); diff --git a/pc/stats_collector_unittest.cc b/pc/stats_collector_unittest.cc index c9740460db..7688ffe727 100644 --- a/pc/stats_collector_unittest.cc +++ b/pc/stats_collector_unittest.cc @@ -764,9 +764,8 @@ static rtc::scoped_refptr CreateMockReceiver( Return(track->kind() == MediaStreamTrackInterface::kAudioKind ? cricket::MEDIA_TYPE_AUDIO : cricket::MEDIA_TYPE_VIDEO)); - EXPECT_CALL(*receiver, SetMediaChannel(_)).Times(AtMost(1)); - EXPECT_CALL(*receiver, Stop()); - EXPECT_CALL(*receiver, StopAndEndTrack()); + EXPECT_CALL(*receiver, SetMediaChannel(_)).WillRepeatedly(Return()); + EXPECT_CALL(*receiver, Stop()).WillRepeatedly(Return()); return receiver; } diff --git a/pc/test/mock_rtp_receiver_internal.h b/pc/test/mock_rtp_receiver_internal.h index ba244039af..c222a04e2f 100644 --- a/pc/test/mock_rtp_receiver_internal.h +++ b/pc/test/mock_rtp_receiver_internal.h @@ -57,7 +57,7 @@ class MockRtpReceiverInternal : public RtpReceiverInternal { // RtpReceiverInternal methods. MOCK_METHOD(void, Stop, (), (override)); - MOCK_METHOD(void, StopAndEndTrack, (), (override)); + MOCK_METHOD(void, SetSourceEnded, (), (override)); MOCK_METHOD(void, SetMediaChannel, (cricket::MediaChannel*), (override)); MOCK_METHOD(void, SetupMediaChannel, (uint32_t), (override)); MOCK_METHOD(void, SetupUnsignaledMediaChannel, (), (override)); diff --git a/pc/video_rtp_receiver.cc b/pc/video_rtp_receiver.cc index d1f8fb0d96..a428603745 100644 --- a/pc/video_rtp_receiver.cc +++ b/pc/video_rtp_receiver.cc @@ -109,74 +109,66 @@ void VideoRtpReceiver::SetDepacketizerToDecoderFrameTransformer( void VideoRtpReceiver::Stop() { RTC_DCHECK_RUN_ON(&signaling_thread_checker_); - // TODO(deadbeef): Need to do more here to fully stop receiving packets. - source_->SetState(MediaSourceInterface::kEnded); - - worker_thread_->Invoke(RTC_FROM_HERE, [&] { - RTC_DCHECK_RUN_ON(worker_thread_); - if (media_channel_) { - SetSink(nullptr); - SetMediaChannel_w(nullptr); - } - source_->ClearCallback(); - }); + track_->internal()->set_ended(); } -void VideoRtpReceiver::StopAndEndTrack() { +void VideoRtpReceiver::SetSourceEnded() { RTC_DCHECK_RUN_ON(&signaling_thread_checker_); - Stop(); - track_->internal()->set_ended(); + source_->SetState(MediaSourceInterface::kEnded); } +// RTC_RUN_ON(&signaling_thread_checker_) void VideoRtpReceiver::RestartMediaChannel(absl::optional ssrc) { - RTC_DCHECK_RUN_ON(&signaling_thread_checker_); - MediaSourceInterface::SourceState state = source_->state(); - // TODO(tommi): Can we restart the media channel without blocking? worker_thread_->Invoke(RTC_FROM_HERE, [&] { RTC_DCHECK_RUN_ON(worker_thread_); - if (!media_channel_) { - // Ignore further negotiations if we've already been stopped and don't - // have an associated media channel. - return; // Can't restart. - } + RestartMediaChannel_w(std::move(ssrc), state); + }); + source_->SetState(MediaSourceInterface::kLive); +} - const bool encoded_sink_enabled = saved_encoded_sink_enabled_; +// RTC_RUN_ON(worker_thread_) +void VideoRtpReceiver::RestartMediaChannel_w( + absl::optional ssrc, + MediaSourceInterface::SourceState state) { + if (!media_channel_) { + return; // Can't restart. + } - if (state != MediaSourceInterface::kInitializing) { - if (ssrc == ssrc_) - return; + const bool encoded_sink_enabled = saved_encoded_sink_enabled_; - // Disconnect from a previous ssrc. - SetSink(nullptr); + if (state != MediaSourceInterface::kInitializing) { + if (ssrc == ssrc_) + return; - if (encoded_sink_enabled) - SetEncodedSinkEnabled(false); - } + // Disconnect from a previous ssrc. + SetSink(nullptr); - // Set up the new ssrc. - ssrc_ = std::move(ssrc); - SetSink(source_->sink()); - if (encoded_sink_enabled) { - SetEncodedSinkEnabled(true); - } + if (encoded_sink_enabled) + SetEncodedSinkEnabled(false); + } - if (frame_transformer_ && media_channel_) { - media_channel_->SetDepacketizerToDecoderFrameTransformer( - ssrc_.value_or(0), frame_transformer_); - } + // Set up the new ssrc. + ssrc_ = std::move(ssrc); + SetSink(source_->sink()); + if (encoded_sink_enabled) { + SetEncodedSinkEnabled(true); + } - if (media_channel_ && ssrc_) { - if (frame_decryptor_) { - media_channel_->SetFrameDecryptor(*ssrc_, frame_decryptor_); - } + if (frame_transformer_ && media_channel_) { + media_channel_->SetDepacketizerToDecoderFrameTransformer( + ssrc_.value_or(0), frame_transformer_); + } - media_channel_->SetBaseMinimumPlayoutDelayMs(*ssrc_, delay_.GetMs()); + if (media_channel_ && ssrc_) { + if (frame_decryptor_) { + media_channel_->SetFrameDecryptor(*ssrc_, frame_decryptor_); } - }); - source_->SetState(MediaSourceInterface::kLive); + + media_channel_->SetBaseMinimumPlayoutDelayMs(*ssrc_, delay_.GetMs()); + } } // RTC_RUN_ON(worker_thread_) @@ -266,14 +258,11 @@ void VideoRtpReceiver::SetJitterBufferMinimumDelay( } void VideoRtpReceiver::SetMediaChannel(cricket::MediaChannel* media_channel) { - RTC_DCHECK_RUN_ON(&signaling_thread_checker_); + RTC_DCHECK_RUN_ON(worker_thread_); RTC_DCHECK(media_channel == nullptr || media_channel->media_type() == media_type()); - worker_thread_->Invoke(RTC_FROM_HERE, [&] { - RTC_DCHECK_RUN_ON(worker_thread_); - SetMediaChannel_w(media_channel); - }); + SetMediaChannel_w(media_channel); } // RTC_RUN_ON(worker_thread_) @@ -281,6 +270,10 @@ void VideoRtpReceiver::SetMediaChannel_w(cricket::MediaChannel* media_channel) { if (media_channel == media_channel_) return; + if (!media_channel) { + SetSink(nullptr); + } + bool encoded_sink_enabled = saved_encoded_sink_enabled_; if (encoded_sink_enabled && media_channel_) { // Turn off the old sink, if any. @@ -303,6 +296,9 @@ void VideoRtpReceiver::SetMediaChannel_w(cricket::MediaChannel* media_channel) { ssrc_.value_or(0), frame_transformer_); } } + + if (!media_channel) + source_->ClearCallback(); } void VideoRtpReceiver::NotifyFirstPacketReceived() { @@ -320,6 +316,19 @@ std::vector VideoRtpReceiver::GetSources() const { return media_channel_->GetSources(*ssrc_); } +void VideoRtpReceiver::SetupMediaChannel(absl::optional ssrc, + cricket::MediaChannel* media_channel) { + RTC_DCHECK_RUN_ON(&signaling_thread_checker_); + RTC_DCHECK(media_channel); + MediaSourceInterface::SourceState state = source_->state(); + worker_thread_->Invoke(RTC_FROM_HERE, [&] { + RTC_DCHECK_RUN_ON(worker_thread_); + SetMediaChannel_w(media_channel); + RestartMediaChannel_w(std::move(ssrc), state); + }); + source_->SetState(MediaSourceInterface::kLive); +} + void VideoRtpReceiver::OnGenerateKeyFrame() { RTC_DCHECK_RUN_ON(worker_thread_); if (!media_channel_) { diff --git a/pc/video_rtp_receiver.h b/pc/video_rtp_receiver.h index 681f423e29..4261e417d2 100644 --- a/pc/video_rtp_receiver.h +++ b/pc/video_rtp_receiver.h @@ -88,7 +88,7 @@ class VideoRtpReceiver : public RtpReceiverInternal { // RtpReceiverInternal implementation. void Stop() override; - void StopAndEndTrack() override; + void SetSourceEnded() override; void SetupMediaChannel(uint32_t ssrc) override; void SetupUnsignaledMediaChannel() override; uint32_t ssrc() const override; @@ -110,8 +110,17 @@ class VideoRtpReceiver : public RtpReceiverInternal { std::vector GetSources() const override; + // Combines SetMediaChannel, SetupMediaChannel and + // SetupUnsignaledMediaChannel. + void SetupMediaChannel(absl::optional ssrc, + cricket::MediaChannel* media_channel); + private: - void RestartMediaChannel(absl::optional ssrc); + void RestartMediaChannel(absl::optional ssrc) + RTC_RUN_ON(&signaling_thread_checker_); + void RestartMediaChannel_w(absl::optional ssrc, + MediaSourceInterface::SourceState state) + RTC_RUN_ON(worker_thread_); void SetSink(rtc::VideoSinkInterface* sink) RTC_RUN_ON(worker_thread_); void SetMediaChannel_w(cricket::MediaChannel* media_channel) diff --git a/pc/video_rtp_receiver_unittest.cc b/pc/video_rtp_receiver_unittest.cc index 42ff2611ef..56aa3688a8 100644 --- a/pc/video_rtp_receiver_unittest.cc +++ b/pc/video_rtp_receiver_unittest.cc @@ -60,13 +60,20 @@ class VideoRtpReceiverTest : public testing::Test { std::string("receiver"), std::vector({"stream"}))) { worker_thread_->Start(); - receiver_->SetMediaChannel(&channel_); + SetMediaChannel(&channel_); } ~VideoRtpReceiverTest() override { - // Clear expectations that tests may have set up before calling Stop(). + // Clear expectations that tests may have set up before calling + // SetMediaChannel(nullptr). Mock::VerifyAndClearExpectations(&channel_); receiver_->Stop(); + SetMediaChannel(nullptr); + } + + void SetMediaChannel(cricket::MediaChannel* media_channel) { + worker_thread_->Invoke( + RTC_FROM_HERE, [&]() { receiver_->SetMediaChannel(media_channel); }); } webrtc::VideoTrackSourceInterface* Source() { @@ -94,23 +101,24 @@ TEST_F(VideoRtpReceiverTest, MockVideoMediaChannel channel2(nullptr, cricket::VideoOptions()); EXPECT_CALL(channel_, GenerateKeyFrame).Times(0); EXPECT_CALL(channel2, GenerateKeyFrame).Times(0); - receiver_->SetMediaChannel(&channel2); + SetMediaChannel(&channel2); Mock::VerifyAndClearExpectations(&channel2); // Generate a key frame. When we switch channel next time, we will have to // re-generate it as we don't know if it was eventually received + EXPECT_CALL(channel2, GenerateKeyFrame).Times(1); Source()->GenerateKeyFrame(); MockVideoMediaChannel channel3(nullptr, cricket::VideoOptions()); EXPECT_CALL(channel3, GenerateKeyFrame); - receiver_->SetMediaChannel(&channel3); + SetMediaChannel(&channel3); // Switching to a new channel should now not cause calls to GenerateKeyFrame. StrictMock channel4(nullptr, cricket::VideoOptions()); - receiver_->SetMediaChannel(&channel4); + SetMediaChannel(&channel4); - // We must call Stop() here since the mock media channels live on the stack - // and `receiver_` still has a pointer to those objects. - receiver_->Stop(); + // We must call SetMediaChannel(nullptr) here since the mock media channels + // live on the stack and `receiver_` still has a pointer to those objects. + SetMediaChannel(nullptr); } TEST_F(VideoRtpReceiverTest, EnablesEncodedOutput) { @@ -135,7 +143,7 @@ TEST_F(VideoRtpReceiverTest, DisablesEnablesEncodedOutputOnChannelSwitch) { Source()->AddEncodedSink(&sink); MockVideoMediaChannel channel2(nullptr, cricket::VideoOptions()); EXPECT_CALL(channel2, SetRecordableEncodedFrameCallback); - receiver_->SetMediaChannel(&channel2); + SetMediaChannel(&channel2); Mock::VerifyAndClearExpectations(&channel2); // When clearing encoded frame buffer function, we need channel switches @@ -143,11 +151,11 @@ TEST_F(VideoRtpReceiverTest, DisablesEnablesEncodedOutputOnChannelSwitch) { EXPECT_CALL(channel2, ClearRecordableEncodedFrameCallback); Source()->RemoveEncodedSink(&sink); StrictMock channel3(nullptr, cricket::VideoOptions()); - receiver_->SetMediaChannel(&channel3); + SetMediaChannel(&channel3); - // We must call Stop() here since the mock media channels live on the stack - // and `receiver_` still has a pointer to those objects. - receiver_->Stop(); + // We must call SetMediaChannel(nullptr) here since the mock media channels + // live on the stack and `receiver_` still has a pointer to those objects. + SetMediaChannel(nullptr); } TEST_F(VideoRtpReceiverTest, BroadcastsEncodedFramesWhenEnabled) { From 42abc13d17d92bbf1bb1c3d54b12f6351ac76244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Spr=C3=A5ng?= Date: Wed, 23 Feb 2022 11:34:46 +0100 Subject: [PATCH 032/847] Run degraded fake network on Call's network thread. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids creating a dedicated task queue that potentially contends with the network thread. Bug: webrtc:251043 Change-Id: I2d54486c4235dac44b79f89d4f3d81b4d3de4026 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252282 Reviewed-by: Stefan Holmer Commit-Queue: Erik Språng Cr-Commit-Position: refs/heads/main@{#36058} --- call/call_factory.cc | 3 +-- call/degraded_call.cc | 35 +++++++++++++++++------------------ call/degraded_call.h | 10 +++++----- 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/call/call_factory.cc b/call/call_factory.cc index a3079eb7b2..40357850a1 100644 --- a/call/call_factory.cc +++ b/call/call_factory.cc @@ -165,8 +165,7 @@ Call* CallFactory::CreateCall(const Call::Config& config) { config.rtp_transport_controller_send_factory->Create( transportConfig, Clock::GetRealTimeClock(), ProcessThread::Create("PacerThread")))), - send_degradation_configs, receive_degradation_configs, - config.task_queue_factory); + send_degradation_configs, receive_degradation_configs); } if (!module_thread_) { diff --git a/call/degraded_call.cc b/call/degraded_call.cc index 1eb2275d20..0d01e8696d 100644 --- a/call/degraded_call.cc +++ b/call/degraded_call.cc @@ -18,13 +18,13 @@ namespace webrtc { DegradedCall::FakeNetworkPipeOnTaskQueue::FakeNetworkPipeOnTaskQueue( - TaskQueueFactory* task_queue_factory, + TaskQueueBase* task_queue, + const ScopedTaskSafety& task_safety, Clock* clock, std::unique_ptr network_behavior) : clock_(clock), - task_queue_(task_queue_factory->CreateTaskQueue( - "DegradedSendQueue", - TaskQueueFactory::Priority::NORMAL)), + task_queue_(task_queue), + task_safety_(task_safety), pipe_(clock, std::move(network_behavior)) {} void DegradedCall::FakeNetworkPipeOnTaskQueue::SendRtp( @@ -61,21 +61,22 @@ bool DegradedCall::FakeNetworkPipeOnTaskQueue::Process() { return false; } - task_queue_.PostTask([this, time_to_next]() { - RTC_DCHECK_RUN_ON(&task_queue_); + task_queue_->PostTask(ToQueuedTask(task_safety_, [this, time_to_next] { + RTC_DCHECK_RUN_ON(task_queue_); int64_t next_process_time = *time_to_next + clock_->TimeInMilliseconds(); if (!next_process_ms_ || next_process_time < *next_process_ms_) { next_process_ms_ = next_process_time; - task_queue_.PostDelayedHighPrecisionTask( - [this]() { - RTC_DCHECK_RUN_ON(&task_queue_); - if (!Process()) { - next_process_ms_.reset(); - } - }, + task_queue_->PostDelayedHighPrecisionTask( + ToQueuedTask(task_safety_, + [this] { + RTC_DCHECK_RUN_ON(task_queue_); + if (!Process()) { + next_process_ms_.reset(); + } + }), *time_to_next); } - }); + })); return true; } @@ -128,11 +129,9 @@ bool DegradedCall::FakeNetworkPipeTransportAdapter::SendRtcp( DegradedCall::DegradedCall( std::unique_ptr call, const std::vector& send_configs, - const std::vector& receive_configs, - TaskQueueFactory* task_queue_factory) + const std::vector& receive_configs) : clock_(Clock::GetRealTimeClock()), call_(std::move(call)), - task_queue_factory_(task_queue_factory), send_config_index_(0), send_configs_(send_configs), send_simulated_network_(nullptr), @@ -154,7 +153,7 @@ DegradedCall::DegradedCall( auto network = std::make_unique(send_configs_[0]); send_simulated_network_ = network.get(); send_pipe_ = std::make_unique( - task_queue_factory_, clock_, std::move(network)); + call_->network_thread(), task_safety_, clock_, std::move(network)); if (send_configs_.size() > 1) { call_->network_thread()->PostDelayedTask( ToQueuedTask(task_safety_, [this] { UpdateSendNetworkConfig(); }), diff --git a/call/degraded_call.h b/call/degraded_call.h index 87a83f9730..dd80a0c5dd 100644 --- a/call/degraded_call.h +++ b/call/degraded_call.h @@ -52,8 +52,7 @@ class DegradedCall : public Call, private PacketReceiver { explicit DegradedCall( std::unique_ptr call, const std::vector& send_configs, - const std::vector& receive_configs, - TaskQueueFactory* task_queue_factory); + const std::vector& receive_configs); ~DegradedCall() override; // Implements Call. @@ -115,7 +114,8 @@ class DegradedCall : public Call, private PacketReceiver { class FakeNetworkPipeOnTaskQueue { public: FakeNetworkPipeOnTaskQueue( - TaskQueueFactory* task_queue_factory, + TaskQueueBase* task_queue, + const ScopedTaskSafety& task_safety, Clock* clock, std::unique_ptr network_behavior); @@ -134,7 +134,8 @@ class DegradedCall : public Call, private PacketReceiver { bool Process(); Clock* const clock_; - rtc::TaskQueue task_queue_; + TaskQueueBase* const task_queue_; + const ScopedTaskSafety& task_safety_; FakeNetworkPipe pipe_; absl::optional next_process_ms_ RTC_GUARDED_BY(&task_queue_); }; @@ -171,7 +172,6 @@ class DegradedCall : public Call, private PacketReceiver { Clock* const clock_; const std::unique_ptr call_; ScopedTaskSafety task_safety_; - TaskQueueFactory* const task_queue_factory_; size_t send_config_index_; const std::vector send_configs_; SimulatedNetwork* send_simulated_network_; From 286664c38184779616ea4f49ceb6010d297ba3ac Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Wed, 23 Feb 2022 06:01:37 -0800 Subject: [PATCH 033/847] Roll chromium_revision 4ad0798dfd..a52f3ba050 (974045:974149) Change log: https://chromium.googlesource.com/chromium/src/+log/4ad0798dfd..a52f3ba050 Full diff: https://chromium.googlesource.com/chromium/src/+/4ad0798dfd..a52f3ba050 Changed dependencies * src/build: https://chromium.googlesource.com/chromium/src/build/+log/51ff1c607b..df888d519a * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/329b18ceb3..90f3bddf86 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/064ccfc12b..f6ece9fd76 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/3c02c2fa5e..57414e84d2 * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/4ac0eac51b..58ce6f9e68 * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/64f5f26f1a..306b03b191 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/5561a9ea21..68fd7a7434 DEPS diff: https://chromium.googlesource.com/chromium/src/+/4ad0798dfd..a52f3ba050/DEPS No update to Clang. BUG=None Change-Id: I280c7eed787923dceac506fa18b75d7fa72446cb Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252302 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36059} --- DEPS | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/DEPS b/DEPS index 1b25ae0567..bf33304e86 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': '4ad0798dfd0f4955f3d92569e1d25dbe13d268b0', + 'chromium_revision': 'a52f3ba050d68f3815222129226d96b3a62da48c', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -25,7 +25,7 @@ deps = { 'src/base': 'https://chromium.googlesource.com/chromium/src/base@d9e6daa144c992480b6155143cbc9cbb3d814068', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@51ff1c607b9e3e9a4a6d0fc74dbd1ed46dfdd340', + 'https://chromium.googlesource.com/chromium/src/build@df888d519aa790ec9719c400c5d7ea7f4dc4d1f9', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@93c15529c323c6cc12516ef9caac7fd815ee7c82', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@329b18ceb3f49dbfee2640e7f5c0adb219015913', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@90f3bddf86c0b39176d30b031c3e04df75722103', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@064ccfc12b479a061562809a3760c9b38be5fbf2', + 'https://chromium.googlesource.com/chromium/src/testing@f6ece9fd7658350dad6f7c23671f57d8f748e8cf', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@3c02c2fa5ed10b0e876ca3f1b5316e41f94d04c0', + 'https://chromium.googlesource.com/chromium/src/third_party@57414e84d2728d13d16d4b914b26cbca9b6b3070', 'src/buildtools/linux64': { 'packages': [ @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@4ac0eac51b57114d5a50793dee6ffbda9859850f', + 'https://chromium.googlesource.com/catapult.git@58ce6f9e689bd01661c62e7464497f03e8ec003f', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@64f5f26f1a0c8b8333514cdb861847f02d405f36', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@306b03b1912affcae0dbecbe5aa36b414fb4ae2a', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@5561a9ea2105d3aad491ed2736b78bf8eaa26214', + 'https://chromium.googlesource.com/chromium/src/tools@68fd7a7434f253370f44eb306fa8fbb8facd376a', 'src/third_party/accessibility_test_framework': { 'packages': [ From 003e6e99b3e7e40e49d41f3541bafd0925748ae3 Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Wed, 23 Feb 2022 15:23:52 +0100 Subject: [PATCH 034/847] [PCLF] Add ability to specify custom PortAllocator flags Bug: b/196034093 Change-Id: Ia1838c5c9ace096d7e77e31f7f2ad6b6352fd1ea Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252100 Reviewed-by: Mirko Bonadei Reviewed-by: Jonas Oreland Reviewed-by: Jonas Oreland Commit-Queue: Artem Titov Cr-Commit-Position: refs/heads/main@{#36060} --- api/test/peerconnection_quality_test_fixture.h | 5 +++++ test/DEPS | 3 +++ test/pc/e2e/BUILD.gn | 1 + test/pc/e2e/peer_configurer.h | 5 +++++ test/pc/e2e/peer_connection_quality_test_params.h | 4 ++++ test/pc/e2e/test_peer_factory.cc | 8 +++++--- 6 files changed, 23 insertions(+), 3 deletions(-) diff --git a/api/test/peerconnection_quality_test_fixture.h b/api/test/peerconnection_quality_test_fixture.h index 198868d7a7..1bd2eb2635 100644 --- a/api/test/peerconnection_quality_test_fixture.h +++ b/api/test/peerconnection_quality_test_fixture.h @@ -371,6 +371,11 @@ class PeerConnectionE2EQualityTestFixture { std::unique_ptr tls_cert_verifier) = 0; virtual PeerConfigurer* SetIceTransportFactory( std::unique_ptr factory) = 0; + // Flags to set on `cricket::PortAllocator`. These flags will be added + // to the default ones that are presented on the port allocator. + // For possible values check p2p/base/port_allocator.h. + virtual PeerConfigurer* SetPortAllocatorExtraFlags( + uint32_t extra_flags) = 0; // Add new video stream to the call that will be sent from this peer. // Default implementation of video frames generator will be used. diff --git a/test/DEPS b/test/DEPS index 2d45003a76..ed994b7e79 100644 --- a/test/DEPS +++ b/test/DEPS @@ -60,6 +60,9 @@ specific_include_rules = { "+pc", "+p2p", ], + ".*peer_connection_quality_test_params\.h": [ + "+p2p/base/port_allocator.h", + ], ".*network_emulation_pc_unittest\.cc": [ "+pc/peer_connection_wrapper.h", "+pc/test/mock_peer_connection_observers.h", diff --git a/test/pc/e2e/BUILD.gn b/test/pc/e2e/BUILD.gn index 1befff95bf..4e4b6bfda3 100644 --- a/test/pc/e2e/BUILD.gn +++ b/test/pc/e2e/BUILD.gn @@ -60,6 +60,7 @@ if (!build_with_chromium) { "../../../api/transport:network_control", "../../../api/transport:webrtc_key_value_config", "../../../api/video_codecs:video_codecs_api", + "../../../p2p:rtc_p2p", "../../../rtc_base", "../../../rtc_base:threading", ] diff --git a/test/pc/e2e/peer_configurer.h b/test/pc/e2e/peer_configurer.h index faf887834d..33ad5ebd12 100644 --- a/test/pc/e2e/peer_configurer.h +++ b/test/pc/e2e/peer_configurer.h @@ -195,6 +195,11 @@ class PeerConfigurerImpl final components_->pc_dependencies->ice_transport_factory = std::move(factory); return this; } + + PeerConfigurer* SetPortAllocatorExtraFlags(uint32_t extra_flags) override { + params_->port_allocator_extra_flags = extra_flags; + return this; + } // Implementation of PeerConnectionE2EQualityTestFixture::PeerConfigurer end. InjectableComponents* components() { return components_.get(); } diff --git a/test/pc/e2e/peer_connection_quality_test_params.h b/test/pc/e2e/peer_connection_quality_test_params.h index 37ccf57033..93fa8c11b9 100644 --- a/test/pc/e2e/peer_connection_quality_test_params.h +++ b/test/pc/e2e/peer_connection_quality_test_params.h @@ -24,6 +24,7 @@ #include "api/transport/webrtc_key_value_config.h" #include "api/video_codecs/video_decoder_factory.h" #include "api/video_codecs/video_encoder_factory.h" +#include "p2p/base/port_allocator.h" #include "rtc_base/network.h" #include "rtc_base/rtc_certificate_generator.h" #include "rtc_base/ssl_certificate.h" @@ -112,6 +113,9 @@ struct Params { std::vector video_configs; // If `audio_config` is set audio stream will be configured absl::optional audio_config; + // Flags to set on `cricket::PortAllocator`. These flags will be added + // to the default ones that are presented on the port allocator. + uint32_t port_allocator_extra_flags = cricket::kDefaultPortAllocatorFlags; // If `rtc_event_log_path` is set, an RTCEventLog will be saved in that // location and it will be available for further analysis. absl::optional rtc_event_log_path; diff --git a/test/pc/e2e/test_peer_factory.cc b/test/pc/e2e/test_peer_factory.cc index 709148c5b3..119c8e114f 100644 --- a/test/pc/e2e/test_peer_factory.cc +++ b/test/pc/e2e/test_peer_factory.cc @@ -257,6 +257,7 @@ PeerConnectionFactoryDependencies CreatePCFDependencies( // from InjectableComponents::PeerConnectionComponents. PeerConnectionDependencies CreatePCDependencies( MockPeerConnectionObserver* observer, + uint32_t port_allocator_extra_flags, std::unique_ptr pc_dependencies) { PeerConnectionDependencies pc_deps(observer); @@ -264,7 +265,7 @@ PeerConnectionDependencies CreatePCDependencies( pc_dependencies->network_manager, pc_dependencies->packet_socket_factory); // This test does not support TCP - int flags = cricket::PORTALLOCATOR_DISABLE_TCP; + int flags = port_allocator_extra_flags | cricket::PORTALLOCATOR_DISABLE_TCP; port_allocator->set_flags(port_allocator->flags() | flags); pc_deps.allocator = std::move(port_allocator); @@ -344,8 +345,9 @@ std::unique_ptr TestPeerFactory::CreateTestPeer( CreateModularPeerConnectionFactory(std::move(pcf_deps)); // Create peer connection. - PeerConnectionDependencies pc_deps = CreatePCDependencies( - observer.get(), std::move(components->pc_dependencies)); + PeerConnectionDependencies pc_deps = + CreatePCDependencies(observer.get(), params->port_allocator_extra_flags, + std::move(components->pc_dependencies)); rtc::scoped_refptr peer_connection = peer_connection_factory ->CreatePeerConnectionOrError(params->rtc_configuration, From 54f3be5c3789b1823c1ec91f765084b76d795391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Spr=C3=A5ng?= Date: Wed, 23 Feb 2022 13:48:53 +0100 Subject: [PATCH 035/847] Deflake VideoSendStreamTest::TestNackRetransmission. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This test method previously didn't account for retransmissions that can fail for valid reasons e.g. retransmitting too soon or overusing the retransmission bandwidth budget. Now, we keep periodically requesting retransmissions until the packets we seek have been received. Bug: webrtc:13480 Change-Id: Ica620049b2c6c123117f5fa270dae0a08b320948 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252283 Reviewed-by: Björn Terelius Commit-Queue: Erik Språng Cr-Commit-Position: refs/heads/main@{#36061} --- video/video_send_stream_tests.cc | 46 +++++++++++++++++++------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/video/video_send_stream_tests.cc b/video/video_send_stream_tests.cc index a7ba243ed2..01669a50dc 100644 --- a/video/video_send_stream_tests.cc +++ b/video/video_send_stream_tests.cc @@ -947,12 +947,7 @@ void VideoSendStreamTest::TestNackRetransmission( ++send_count_; // NACK packets at arbitrary points. - if (send_count_ == 5 || send_count_ == 25) { - nacked_sequence_numbers_.insert( - nacked_sequence_numbers_.end(), - non_padding_sequence_numbers_.end() - kNackedPacketsAtOnceCount, - non_padding_sequence_numbers_.end()); - + if (send_count_ % 25 == 0) { RTCPSender::Configuration config; config.clock = Clock::GetRealTimeClock(); config.outgoing_transport = transport_adapter_.get(); @@ -964,11 +959,19 @@ void VideoSendStreamTest::TestNackRetransmission( rtcp_sender.SetRemoteSSRC(kVideoSendSsrcs[0]); RTCPSender::FeedbackState feedback_state; + uint16_t nack_sequence_numbers[kNackedPacketsAtOnceCount]; + int nack_count = 0; + for (uint16_t sequence_number : + sequence_numbers_pending_retransmission_) { + if (nack_count < kNackedPacketsAtOnceCount) { + nack_sequence_numbers[nack_count++] = sequence_number; + } else { + break; + } + } - EXPECT_EQ(0, rtcp_sender.SendRTCP( - feedback_state, kRtcpNack, - static_cast(nacked_sequence_numbers_.size()), - &nacked_sequence_numbers_.front())); + EXPECT_EQ(0, rtcp_sender.SendRTCP(feedback_state, kRtcpNack, nack_count, + nack_sequence_numbers)); } uint16_t sequence_number = rtp_packet.SequenceNumber(); @@ -980,17 +983,25 @@ void VideoSendStreamTest::TestNackRetransmission( sequence_number = (rtx_header[0] << 8) + rtx_header[1]; } - auto found = absl::c_find(nacked_sequence_numbers_, sequence_number); - if (found != nacked_sequence_numbers_.end()) { - nacked_sequence_numbers_.erase(found); - + auto it = sequence_numbers_pending_retransmission_.find(sequence_number); + if (it == sequence_numbers_pending_retransmission_.end()) { + // Not currently pending retransmission. Add it to retransmission queue + // if media and limit not reached. + if (rtp_packet.Ssrc() == kVideoSendSsrcs[0] && + rtp_packet.payload_size() > 0 && + retransmit_count_ + + sequence_numbers_pending_retransmission_.size() < + kRetransmitTarget) { + sequence_numbers_pending_retransmission_.insert(sequence_number); + } + } else { + // Packet is a retransmission, remove it from queue and check if done. + sequence_numbers_pending_retransmission_.erase(it); if (++retransmit_count_ == kRetransmitTarget) { EXPECT_EQ(retransmit_ssrc_, rtp_packet.Ssrc()); EXPECT_EQ(retransmit_payload_type_, rtp_packet.PayloadType()); observation_complete_.Set(); } - } else { - non_padding_sequence_numbers_.push_back(sequence_number); } return SEND_PACKET; @@ -1018,8 +1029,7 @@ void VideoSendStreamTest::TestNackRetransmission( int retransmit_count_; const uint32_t retransmit_ssrc_; const uint8_t retransmit_payload_type_; - std::vector nacked_sequence_numbers_; - std::vector non_padding_sequence_numbers_; + std::set sequence_numbers_pending_retransmission_; } test(retransmit_ssrc, retransmit_payload_type); RunBaseTest(&test); From b50cfc9fbb1feeeda345a666d6841d4f5aaaf49e Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Wed, 23 Feb 2022 12:02:05 -0800 Subject: [PATCH 036/847] Roll chromium_revision a52f3ba050..0b2f63dc4b (974149:974286) Change log: https://chromium.googlesource.com/chromium/src/+log/a52f3ba050..0b2f63dc4b Full diff: https://chromium.googlesource.com/chromium/src/+/a52f3ba050..0b2f63dc4b Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/d9e6daa144..1ccd6b651d * src/build: https://chromium.googlesource.com/chromium/src/build/+log/df888d519a..e3b729952d * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/90f3bddf86..469142ebf2 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/f6ece9fd76..bede1d9398 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/57414e84d2..0c497a1ac6 * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/58ce6f9e68..8f3c4ef866 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/68fd7a7434..01862032d8 DEPS diff: https://chromium.googlesource.com/chromium/src/+/a52f3ba050..0b2f63dc4b/DEPS No update to Clang. BUG=None Change-Id: I34486eaf48139e5d1959ecf9a9fad3f1af012403 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252288 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36062} --- DEPS | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/DEPS b/DEPS index bf33304e86..bd0073f459 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': 'a52f3ba050d68f3815222129226d96b3a62da48c', + 'chromium_revision': '0b2f63dc4b44dd325cbd0ef09553b411f2ecf71d', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@d9e6daa144c992480b6155143cbc9cbb3d814068', + 'https://chromium.googlesource.com/chromium/src/base@1ccd6b651d26656f0640bfd1f92ac6a7bc0ed050', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@df888d519aa790ec9719c400c5d7ea7f4dc4d1f9', + 'https://chromium.googlesource.com/chromium/src/build@e3b729952de607b9f3d522053dc657a2f0d2b7fb', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@93c15529c323c6cc12516ef9caac7fd815ee7c82', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@90f3bddf86c0b39176d30b031c3e04df75722103', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@469142ebf2d30e46538330cba8734971e11ea520', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@f6ece9fd7658350dad6f7c23671f57d8f748e8cf', + 'https://chromium.googlesource.com/chromium/src/testing@bede1d93986afb8ca46431bb50b6b2ec2a461d2a', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@57414e84d2728d13d16d4b914b26cbca9b6b3070', + 'https://chromium.googlesource.com/chromium/src/third_party@0c497a1ac6f7a99ffca2095023fee71bf12183c8', 'src/buildtools/linux64': { 'packages': [ @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@58ce6f9e689bd01661c62e7464497f03e8ec003f', + 'https://chromium.googlesource.com/catapult.git@8f3c4ef86630d09ba69e3e6dd35553791cfa6b1e', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@68fd7a7434f253370f44eb306fa8fbb8facd376a', + 'https://chromium.googlesource.com/chromium/src/tools@01862032d809eff27a0b83832d8b79b943005c2c', 'src/third_party/accessibility_test_framework': { 'packages': [ From 3be0c39f910602b3a5d23ee353b5605dca39a170 Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Wed, 23 Feb 2022 20:05:40 -0800 Subject: [PATCH 037/847] Update WebRTC code version (2022-02-24T04:05:39). Bug: None Change-Id: I52834e964bda1509e5cc33bca3c44e4ddc8a2700 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252360 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36063} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index eada4660a1..b87c852b44 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 2022-02-23T04:06:01"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-02-24T04:05:39"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From c24a2189d72b2bf37e91ffe99605912de4d633a7 Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Wed, 23 Feb 2022 13:44:59 +0000 Subject: [PATCH 038/847] Update IWYU tool with a mapping file Also apply IWYU to all .cc files in pc/, and correct BUILD file to match. Note: Some files came out wrong when iwyu was applied. These are not included. Bug: none Change-Id: Ib5ea46b8fcc505414d0447cca7218ad3afc2e321 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252280 Reviewed-by: Mirko Bonadei Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#36064} --- pc/BUILD.gn | 51 ++++++++++++++++++- pc/audio_rtp_receiver.cc | 3 +- pc/audio_rtp_receiver_unittest.cc | 4 +- pc/channel.cc | 10 ++-- pc/channel.h | 4 ++ pc/channel_manager.cc | 3 +- pc/channel_manager.h | 2 + pc/channel_manager_unittest.cc | 9 ++-- pc/channel_unittest.cc | 11 +++- pc/connection_context.cc | 3 +- pc/connection_context.h | 1 + pc/data_channel_controller.cc | 3 -- pc/data_channel_controller.h | 1 + pc/data_channel_integrationtest.cc | 21 ++++++-- pc/data_channel_unittest.cc | 12 ++++- pc/dtls_srtp_transport.h | 1 + pc/dtls_srtp_transport_unittest.cc | 3 +- pc/dtls_transport.cc | 2 +- pc/dtls_transport_unittest.cc | 8 ++- pc/dtmf_sender.cc | 2 - pc/dtmf_sender.h | 3 ++ pc/external_hmac.h | 1 + pc/ice_server_parsing.cc | 2 - pc/ice_transport_unittest.cc | 5 +- pc/jitter_buffer_delay.h | 1 + pc/jitter_buffer_delay_unittest.cc | 3 -- pc/jsep_ice_candidate.cc | 2 - pc/jsep_session_description.cc | 13 ++++- pc/jsep_session_description_unittest.cc | 3 +- pc/jsep_transport.cc | 1 + pc/jsep_transport_collection.h | 1 + pc/jsep_transport_controller.cc | 2 +- pc/jsep_transport_controller.h | 1 + pc/jsep_transport_controller_unittest.cc | 14 ++++- pc/jsep_transport_unittest.cc | 24 +++++++-- pc/media_session.cc | 4 +- pc/media_session_unittest.cc | 22 +++++--- pc/media_stream.cc | 1 - pc/media_stream_unittest.cc | 2 - pc/peer_connection.h | 1 - ...r_connection_adaptation_integrationtest.cc | 11 ++++ pc/peer_connection_bundle_unittest.cc | 46 +++++++++++++++-- pc/peer_connection_crypto_unittest.cc | 32 +++++++++++- pc/peer_connection_data_channel_unittest.cc | 10 ++-- pc/peer_connection_end_to_end_unittest.cc | 28 +++++++++- pc/peer_connection_factory.cc | 2 +- pc/peer_connection_factory.h | 1 + pc/peer_connection_factory_unittest.cc | 11 ++-- ...er_connection_header_extension_unittest.cc | 27 ++++++++-- pc/peer_connection_histogram_unittest.cc | 6 ++- pc/peer_connection_ice_unittest.cc | 41 ++++++++++++++- pc/peer_connection_integrationtest.cc | 3 ++ pc/peer_connection_interface_unittest.cc | 15 +----- pc/peer_connection_jsep_unittest.cc | 41 +++++++++++++-- pc/peer_connection_media_unittest.cc | 35 ++++++++++++- pc/peer_connection_message_handler.cc | 1 + pc/peer_connection_rampup_tests.cc | 6 +-- pc/peer_connection_rtp_unittest.cc | 8 ++- pc/peer_connection_signaling_unittest.cc | 37 ++++++++++++-- pc/peer_connection_simulcast_unittest.cc | 29 ++++++++++- pc/peer_connection_wrapper.cc | 2 - pc/proxy.h | 3 ++ pc/remote_audio_source.cc | 1 + pc/rtc_stats_collector.cc | 11 ++-- pc/rtc_stats_collector.h | 2 + pc/rtc_stats_collector_unittest.cc | 30 ++++++++++- pc/rtc_stats_integrationtest.cc | 3 -- pc/rtc_stats_traversal_unittest.cc | 1 - pc/rtp_media_utils.h | 2 + pc/rtp_parameters_conversion.cc | 2 +- pc/rtp_parameters_conversion.h | 1 - pc/rtp_parameters_conversion_unittest.cc | 7 ++- pc/rtp_receiver.cc | 2 +- pc/rtp_sender.cc | 1 + pc/rtp_sender.h | 4 ++ pc/rtp_sender_receiver_unittest.cc | 10 +++- pc/rtp_transceiver.cc | 2 + pc/rtp_transceiver.h | 5 ++ pc/rtp_transceiver_unittest.cc | 3 ++ pc/rtp_transmission_manager.cc | 3 +- pc/rtp_transmission_manager.h | 2 + pc/rtp_transport.cc | 4 +- pc/rtp_transport.h | 1 + pc/rtp_transport_unittest.cc | 8 +-- pc/sctp_data_channel_transport.cc | 3 -- pc/sctp_transport.h | 2 + pc/sctp_transport_unittest.cc | 7 +++ pc/sctp_utils.cc | 4 +- pc/sctp_utils_unittest.cc | 2 + pc/sdp_offer_answer.h | 1 - pc/sdp_offer_answer_unittest.cc | 24 --------- pc/sdp_serializer.cc | 2 +- pc/sdp_serializer_unittest.cc | 4 +- pc/sdp_utils.cc | 2 +- pc/session_description.cc | 3 +- pc/session_description.h | 2 +- pc/session_description_unittest.cc | 2 - pc/srtp_filter.cc | 4 +- pc/srtp_session.cc | 6 +++ pc/srtp_session.h | 3 ++ pc/srtp_transport_unittest.cc | 3 +- pc/stats_collector.cc | 7 ++- pc/stats_collector.h | 6 +++ pc/stats_collector_unittest.cc | 8 ++- pc/track_media_info_map.cc | 2 +- pc/track_media_info_map_unittest.cc | 14 +++-- pc/transceiver_list.cc | 2 + pc/used_ids_unittest.cc | 1 + pc/video_rtp_receiver.cc | 3 +- pc/video_rtp_receiver_unittest.cc | 6 +++ pc/video_rtp_track_source_unittest.cc | 6 +++ pc/video_track.cc | 2 - pc/video_track.h | 3 +- pc/video_track_source.h | 2 + pc/video_track_source_proxy.cc | 2 + pc/video_track_source_proxy.h | 7 +++ pc/video_track_unittest.cc | 2 +- pc/webrtc_sdp.cc | 3 +- pc/webrtc_sdp_unittest.cc | 9 +++- pc/webrtc_session_description_factory.cc | 6 ++- tools_webrtc/iwyu/apply-iwyu | 4 +- tools_webrtc/iwyu/iwyu-filter-list | 1 + tools_webrtc/iwyu/mappings.imp | 32 ++++++++++++ 123 files changed, 751 insertions(+), 211 deletions(-) create mode 100644 tools_webrtc/iwyu/mappings.imp diff --git a/pc/BUILD.gn b/pc/BUILD.gn index 1a296c1658..c088e2cdaf 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -142,13 +142,16 @@ rtc_library("rtc_pc_base") { "../api:rtp_transceiver_direction", "../api:scoped_refptr", "../api:sequence_checker", + "../api:video_track_source_constraints", "../api/crypto:options", "../api/rtc_event_log", "../api/task_queue", "../api/transport:datagram_transport_interface", "../api/transport:enums", "../api/transport:sctp_transport_factory_interface", + "../api/units:timestamp", "../api/video:builtin_video_bitrate_allocator_factory", + "../api/video:recordable_encoded_frame", "../api/video:video_bitrate_allocator_factory", "../api/video:video_frame", "../api/video:video_rtp_headers", @@ -156,6 +159,7 @@ rtc_library("rtc_pc_base") { "../call:call_interfaces", "../call:rtp_interfaces", "../call:rtp_receiver", + "../call:video_stream_api", "../common_video", "../common_video:common_video", "../logging:ice_log", @@ -174,6 +178,8 @@ rtc_library("rtc_pc_base") { "../rtc_base:socket_address", "../rtc_base:stringutils", "../rtc_base:threading", + "../rtc_base/containers:flat_map", + "../rtc_base/containers:flat_set", "../rtc_base/network:sent_packet", "../rtc_base/synchronization:mutex", "../rtc_base/system:file_wrapper", @@ -219,6 +225,7 @@ rtc_source_set("session_description") { "../p2p:rtc_p2p", "../rtc_base:checks", "../rtc_base:socket_address", + "../rtc_base:stringutils", "../rtc_base/system:rtc_export", ] absl_deps = [ @@ -471,6 +478,8 @@ rtc_library("connection_context") { "../p2p:rtc_p2p", "../rtc_base", "../rtc_base:checks", + "../rtc_base:socket_factory", + "../rtc_base:socket_server", "../rtc_base:threading", "../rtc_base/task_utils:to_queued_task", ] @@ -547,6 +556,7 @@ rtc_source_set("rtc_stats_collector") { "../api:scoped_refptr", "../api:sequence_checker", "../api/task_queue:task_queue", + "../api/units:time_delta", "../api/video:video_rtp_headers", "../call:call_interfaces", "../common_video:common_video", @@ -568,7 +578,10 @@ rtc_source_set("rtc_stats_collector") { "../rtc_base:timeutils", "../rtc_base/third_party/sigslot:sigslot", ] - absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] + absl_deps = [ + "//third_party/abseil-cpp/absl/strings", + "//third_party/abseil-cpp/absl/types:optional", + ] } rtc_source_set("rtc_stats_traversal") { @@ -818,7 +831,10 @@ rtc_source_set("stats_collector") { "../rtc_base:timeutils", "../system_wrappers:field_trial", ] - absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] + absl_deps = [ + "//third_party/abseil-cpp/absl/strings", + "//third_party/abseil-cpp/absl/types:optional", + ] } rtc_source_set("stream_collection") { visibility = [ ":*" ] @@ -879,6 +895,7 @@ rtc_source_set("webrtc_sdp") { ] absl_deps = [ "//third_party/abseil-cpp/absl/algorithm:container", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } @@ -965,6 +982,7 @@ rtc_source_set("peer_connection_factory") { "../api:rtp_parameters", "../api:scoped_refptr", "../api:sequence_checker", + "../api/metronome", "../api/neteq:neteq_api", "../api/rtc_event_log:rtc_event_log", "../api/task_queue:task_queue", @@ -1057,6 +1075,7 @@ rtc_library("rtp_transceiver") { "../rtc_base:logging", "../rtc_base:macromagic", "../rtc_base:refcount", + "../rtc_base:rtc_base_approved", "../rtc_base:threading", "../rtc_base/task_utils:pending_task_safety_flag", "../rtc_base/task_utils:to_queued_task", @@ -1286,6 +1305,7 @@ rtc_library("video_track") { "../rtc_base:threading", "../rtc_base/system:no_unique_address", ] + absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } rtc_source_set("sdp_state_provider") { @@ -1306,6 +1326,7 @@ rtc_library("jitter_buffer_delay") { deps = [ "../api:sequence_checker", "../rtc_base:checks", + "../rtc_base:macromagic", "../rtc_base:safe_conversions", "../rtc_base:safe_minmax", "../rtc_base/system:no_unique_address", @@ -1517,6 +1538,7 @@ if (rtc_include_tests && !build_with_chromium) { deps = [ ":audio_rtp_receiver", ":libjingle_peerconnection", + ":media_protocol_names", ":pc_test_utils", ":peerconnection", ":rtc_pc", @@ -1530,7 +1552,12 @@ if (rtc_include_tests && !build_with_chromium) { "../api:rtc_error", "../api:rtp_headers", "../api:rtp_parameters", + "../api:scoped_refptr", + "../api/task_queue:task_queue", + "../api/transport:datagram_transport_interface", + "../api/transport:enums", "../api/video:builtin_video_bitrate_allocator_factory", + "../api/video:recordable_encoded_frame", "../api/video/test:mock_recordable_encoded_frame", "../call:rtp_interfaces", "../call:rtp_receiver", @@ -1547,7 +1574,9 @@ if (rtc_include_tests && !build_with_chromium) { "../rtc_base:gunit_helpers", "../rtc_base:rtc_base_approved", "../rtc_base:rtc_base_tests_utils", + "../rtc_base:socket_address", "../rtc_base:threading", + "../rtc_base/containers:flat_set", "../rtc_base/task_utils:pending_task_safety_flag", "../rtc_base/task_utils:to_queued_task", "../rtc_base/third_party/sigslot", @@ -1559,6 +1588,7 @@ if (rtc_include_tests && !build_with_chromium) { "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings", + "//third_party/abseil-cpp/absl/types:optional", ] if (rtc_build_libsrtp) { @@ -1582,6 +1612,7 @@ if (rtc_include_tests && !build_with_chromium) { "../api:create_peerconnection_factory", "../api:libjingle_peerconnection_api", "../api:media_stream_interface", + "../api:rtc_error", "../api:rtc_stats_api", "../api:scoped_refptr", "../api/audio:audio_mixer_api", @@ -1601,6 +1632,7 @@ if (rtc_include_tests && !build_with_chromium) { "../rtc_base:gunit_helpers", "../rtc_base:rtc_base_tests_utils", "../rtc_base:socket_address", + "../rtc_base:socket_factory", "../rtc_base:threading", "../system_wrappers", "../test:perf_test", @@ -1690,6 +1722,7 @@ if (rtc_include_tests && !build_with_chromium) { ":integration_test_helpers", ":jitter_buffer_delay", ":local_audio_source", + ":media_protocol_names", ":media_stream", ":peer_connection", ":peer_connection_factory", @@ -1708,6 +1741,7 @@ if (rtc_include_tests && !build_with_chromium) { ":sdp_serializer", ":sdp_utils", ":session_description", + ":simulcast_description", ":stats_collector", ":stream_collection", ":track_media_info_map", @@ -1729,9 +1763,11 @@ if (rtc_include_tests && !build_with_chromium) { "../api:mock_rtp", "../api:mock_video_track", "../api:packet_socket_factory", + "../api:priority", "../api:rtc_error", "../api:rtp_transceiver_direction", "../api:scoped_refptr", + "../api/adaptation:resource_adaptation_api", "../api/audio:audio_mixer_api", "../api/crypto:frame_decryptor_interface", "../api/crypto:frame_encryptor_interface", @@ -1740,13 +1776,22 @@ if (rtc_include_tests && !build_with_chromium) { "../api/rtc_event_log:rtc_event_log_factory", "../api/task_queue", "../api/task_queue:default_task_queue_factory", + "../api/transport:datagram_transport_interface", "../api/transport:field_trial_based_config", + "../api/transport:sctp_transport_factory_interface", "../api/transport:webrtc_key_value_config", "../api/transport/rtp:rtp_source", "../api/units:time_delta", + "../api/units:timestamp", "../api/video:builtin_video_bitrate_allocator_factory", + "../api/video:encoded_image", + "../api/video:recordable_encoded_frame", + "../api/video:video_bitrate_allocator_factory", + "../api/video:video_codec_constants", + "../api/video:video_frame", "../api/video:video_rtp_headers", "../call/adaptation:resource_adaptation_test_utilities", + "../common_video", "../logging:fake_rtc_event_log", "../media:rtc_data_sctp_transport_internal", "../media:rtc_media_config", @@ -1761,9 +1806,11 @@ if (rtc_include_tests && !build_with_chromium) { "../rtc_base:checks", "../rtc_base:gunit_helpers", "../rtc_base:ip_address", + "../rtc_base:network_constants", "../rtc_base:rtc_base_tests_utils", "../rtc_base:rtc_json", "../rtc_base:socket_address", + "../rtc_base:socket_factory", "../rtc_base:threading", "../rtc_base/synchronization:mutex", "../rtc_base/third_party/base64", diff --git a/pc/audio_rtp_receiver.cc b/pc/audio_rtp_receiver.cc index 43294c7e93..3a306720c7 100644 --- a/pc/audio_rtp_receiver.cc +++ b/pc/audio_rtp_receiver.cc @@ -12,6 +12,7 @@ #include +#include #include #include @@ -20,7 +21,7 @@ #include "pc/media_stream_track_proxy.h" #include "rtc_base/checks.h" #include "rtc_base/location.h" -#include "rtc_base/logging.h" +#include "rtc_base/ref_counted_object.h" #include "rtc_base/task_utils/to_queued_task.h" namespace webrtc { diff --git a/pc/audio_rtp_receiver_unittest.cc b/pc/audio_rtp_receiver_unittest.cc index 294e580525..ac843fe9c2 100644 --- a/pc/audio_rtp_receiver_unittest.cc +++ b/pc/audio_rtp_receiver_unittest.cc @@ -10,9 +10,11 @@ #include "pc/audio_rtp_receiver.h" -#include "media/base/media_channel.h" +#include + #include "pc/test/mock_voice_media_channel.h" #include "rtc_base/gunit.h" +#include "rtc_base/ref_counted_object.h" #include "rtc_base/thread.h" #include "test/gmock.h" #include "test/gtest.h" diff --git a/pc/channel.cc b/pc/channel.cc index b322ae2e73..629f4ff36d 100644 --- a/pc/channel.cc +++ b/pc/channel.cc @@ -12,26 +12,26 @@ #include #include -#include -#include +#include +#include #include -#include "absl/algorithm/container.h" #include "absl/strings/string_view.h" #include "api/rtp_parameters.h" #include "api/sequence_checker.h" -#include "api/task_queue/queued_task.h" +#include "api/units/timestamp.h" #include "media/base/codec.h" #include "media/base/rid_description.h" #include "media/base/rtp_utils.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" +#include "p2p/base/dtls_transport_internal.h" #include "pc/rtp_media_utils.h" #include "rtc_base/checks.h" #include "rtc_base/copy_on_write_buffer.h" +#include "rtc_base/location.h" #include "rtc_base/logging.h" #include "rtc_base/network_route.h" #include "rtc_base/strings/string_format.h" -#include "rtc_base/synchronization/mutex.h" #include "rtc_base/task_utils/pending_task_safety_flag.h" #include "rtc_base/task_utils/to_queued_task.h" #include "rtc_base/trace_event.h" diff --git a/pc/channel.h b/pc/channel.h index 930ca9bdfd..018cb43ba3 100644 --- a/pc/channel.h +++ b/pc/channel.h @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -21,12 +22,14 @@ #include #include +#include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "api/call/audio_sink.h" #include "api/crypto/crypto_options.h" #include "api/function_view.h" #include "api/jsep.h" #include "api/media_types.h" +#include "api/rtp_parameters.h" #include "api/rtp_receiver_interface.h" #include "api/rtp_transceiver_direction.h" #include "api/scoped_refptr.h" @@ -52,6 +55,7 @@ #include "rtc_base/async_packet_socket.h" #include "rtc_base/async_udp_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/location.h" #include "rtc_base/network.h" diff --git a/pc/channel_manager.cc b/pc/channel_manager.cc index 2146ed5087..1482d7f862 100644 --- a/pc/channel_manager.cc +++ b/pc/channel_manager.cc @@ -10,17 +10,16 @@ #include "pc/channel_manager.h" -#include #include #include "absl/algorithm/container.h" #include "absl/memory/memory.h" #include "absl/strings/match.h" +#include "api/media_types.h" #include "api/sequence_checker.h" #include "media/base/media_constants.h" #include "rtc_base/checks.h" #include "rtc_base/location.h" -#include "rtc_base/logging.h" #include "rtc_base/trace_event.h" namespace cricket { diff --git a/pc/channel_manager.h b/pc/channel_manager.h index a1c4efd55b..72bd1328b3 100644 --- a/pc/channel_manager.h +++ b/pc/channel_manager.h @@ -27,10 +27,12 @@ #include "media/base/media_config.h" #include "media/base/media_engine.h" #include "pc/channel.h" +#include "pc/channel_interface.h" #include "pc/rtp_transport_internal.h" #include "pc/session_description.h" #include "rtc_base/system/file_wrapper.h" #include "rtc_base/thread.h" +#include "rtc_base/thread_annotations.h" #include "rtc_base/unique_id_generator.h" namespace cricket { diff --git a/pc/channel_manager_unittest.cc b/pc/channel_manager_unittest.cc index 765e8e144d..9503243a09 100644 --- a/pc/channel_manager_unittest.cc +++ b/pc/channel_manager_unittest.cc @@ -10,19 +10,18 @@ #include "pc/channel_manager.h" -#include - -#include "api/rtc_error.h" +#include "api/sequence_checker.h" #include "api/video/builtin_video_bitrate_allocator_factory.h" #include "media/base/fake_media_engine.h" #include "media/base/test_utils.h" #include "media/engine/fake_webrtc_call.h" -#include "p2p/base/dtls_transport_internal.h" #include "p2p/base/fake_dtls_transport.h" #include "p2p/base/p2p_constants.h" -#include "p2p/base/packet_transport_internal.h" #include "pc/dtls_srtp_transport.h" +#include "pc/rtp_transport_internal.h" +#include "rtc_base/arraysize.h" #include "rtc_base/checks.h" +#include "rtc_base/location.h" #include "rtc_base/thread.h" #include "test/gtest.h" diff --git a/pc/channel_unittest.cc b/pc/channel_unittest.cc index 304c3b28b4..3bf9556403 100644 --- a/pc/channel_unittest.cc +++ b/pc/channel_unittest.cc @@ -10,9 +10,11 @@ #include "pc/channel.h" +#include + #include -#include -#include +#include +#include #include "api/array_view.h" #include "api/audio_options.h" @@ -21,11 +23,15 @@ #include "media/base/fake_media_engine.h" #include "media/base/fake_rtp.h" #include "media/base/media_channel.h" +#include "media/base/media_constants.h" +#include "media/base/rid_description.h" #include "p2p/base/candidate_pair_interface.h" +#include "p2p/base/dtls_transport_internal.h" #include "p2p/base/fake_dtls_transport.h" #include "p2p/base/fake_packet_transport.h" #include "p2p/base/ice_transport_internal.h" #include "p2p/base/p2p_constants.h" +#include "p2p/base/packet_transport_internal.h" #include "pc/dtls_srtp_transport.h" #include "pc/jsep_transport.h" #include "pc/rtp_transport.h" @@ -33,6 +39,7 @@ #include "rtc_base/buffer.h" #include "rtc_base/byte_order.h" #include "rtc_base/checks.h" +#include "rtc_base/location.h" #include "rtc_base/rtc_certificate.h" #include "rtc_base/ssl_identity.h" #include "rtc_base/task_utils/pending_task_safety_flag.h" diff --git a/pc/connection_context.cc b/pc/connection_context.cc index 6e531339f4..d093ee3cf5 100644 --- a/pc/connection_context.cc +++ b/pc/connection_context.cc @@ -10,14 +10,15 @@ #include "pc/connection_context.h" -#include #include #include #include "api/transport/field_trial_based_config.h" +#include "media/base/media_engine.h" #include "media/sctp/sctp_transport_factory.h" #include "rtc_base/helpers.h" #include "rtc_base/internal/default_socket_server.h" +#include "rtc_base/socket_server.h" #include "rtc_base/task_utils/to_queued_task.h" #include "rtc_base/time_utils.h" diff --git a/pc/connection_context.h b/pc/connection_context.h index 5e814079f9..2aaa840df1 100644 --- a/pc/connection_context.h +++ b/pc/connection_context.h @@ -29,6 +29,7 @@ #include "rtc_base/network.h" #include "rtc_base/network_monitor_factory.h" #include "rtc_base/rtc_certificate_generator.h" +#include "rtc_base/socket_factory.h" #include "rtc_base/thread.h" #include "rtc_base/thread_annotations.h" diff --git a/pc/data_channel_controller.cc b/pc/data_channel_controller.cc index adbf303105..832eb03f79 100644 --- a/pc/data_channel_controller.cc +++ b/pc/data_channel_controller.cc @@ -10,11 +10,8 @@ #include "pc/data_channel_controller.h" -#include #include -#include "absl/algorithm/container.h" -#include "absl/types/optional.h" #include "api/peer_connection_interface.h" #include "api/rtc_error.h" #include "pc/peer_connection_internal.h" diff --git a/pc/data_channel_controller.h b/pc/data_channel_controller.h index 00d38f0c84..fa10b745c6 100644 --- a/pc/data_channel_controller.h +++ b/pc/data_channel_controller.h @@ -19,6 +19,7 @@ #include #include "api/data_channel_interface.h" +#include "api/rtc_error.h" #include "api/scoped_refptr.h" #include "api/sequence_checker.h" #include "api/transport/data_channel_transport_interface.h" diff --git a/pc/data_channel_integrationtest.cc b/pc/data_channel_integrationtest.cc index c0dbfdd4bf..c76a4d97b0 100644 --- a/pc/data_channel_integrationtest.cc +++ b/pc/data_channel_integrationtest.cc @@ -10,24 +10,37 @@ #include -#include -#include +#include +#include #include +#include #include +#include "absl/algorithm/container.h" #include "absl/types/optional.h" #include "api/data_channel_interface.h" -#include "api/dtmf_sender_interface.h" +#include "api/dtls_transport_interface.h" #include "api/peer_connection_interface.h" #include "api/scoped_refptr.h" +#include "api/sctp_transport_interface.h" +#include "api/stats/rtc_stats_report.h" +#include "api/stats/rtcstats_objects.h" #include "api/units/time_delta.h" +#include "p2p/base/transport_description.h" +#include "p2p/base/transport_info.h" +#include "pc/media_session.h" +#include "pc/session_description.h" #include "pc/test/integration_test_helpers.h" #include "pc/test/mock_peer_connection_observers.h" +#include "rtc_base/copy_on_write_buffer.h" #include "rtc_base/fake_clock.h" #include "rtc_base/gunit.h" -#include "rtc_base/ref_counted_object.h" +#include "rtc_base/helpers.h" +#include "rtc_base/logging.h" +#include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/virtual_socket_server.h" #include "system_wrappers/include/field_trial.h" +#include "test/gmock.h" #include "test/gtest.h" namespace webrtc { diff --git a/pc/data_channel_unittest.cc b/pc/data_channel_unittest.cc index 44c080bbda..5797d1da44 100644 --- a/pc/data_channel_unittest.cc +++ b/pc/data_channel_unittest.cc @@ -8,17 +8,27 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include #include #include +#include #include +#include "api/data_channel_interface.h" +#include "api/rtc_error.h" +#include "api/scoped_refptr.h" +#include "api/transport/data_channel_transport_interface.h" +#include "media/base/media_channel.h" #include "media/sctp/sctp_transport_internal.h" #include "pc/sctp_data_channel.h" #include "pc/sctp_utils.h" #include "pc/test/fake_data_channel_provider.h" +#include "rtc_base/copy_on_write_buffer.h" #include "rtc_base/gunit.h" -#include "rtc_base/numerics/safe_conversions.h" +#include "rtc_base/ssl_stream_adapter.h" +#include "rtc_base/third_party/sigslot/sigslot.h" +#include "rtc_base/thread.h" #include "test/gtest.h" using webrtc::DataChannelInterface; diff --git a/pc/dtls_srtp_transport.h b/pc/dtls_srtp_transport.h index da068c9b8a..c2c51c22f2 100644 --- a/pc/dtls_srtp_transport.h +++ b/pc/dtls_srtp_transport.h @@ -11,6 +11,7 @@ #ifndef PC_DTLS_SRTP_TRANSPORT_H_ #define PC_DTLS_SRTP_TRANSPORT_H_ +#include #include #include diff --git a/pc/dtls_srtp_transport_unittest.cc b/pc/dtls_srtp_transport_unittest.cc index 72df81a923..76d9c30c5e 100644 --- a/pc/dtls_srtp_transport_unittest.cc +++ b/pc/dtls_srtp_transport_unittest.cc @@ -14,7 +14,6 @@ #include #include -#include #include "call/rtp_demuxer.h" #include "media/base/fake_rtp.h" @@ -26,9 +25,11 @@ #include "pc/test/rtp_transport_test_util.h" #include "rtc_base/async_packet_socket.h" #include "rtc_base/byte_order.h" +#include "rtc_base/containers/flat_set.h" #include "rtc_base/copy_on_write_buffer.h" #include "rtc_base/rtc_certificate.h" #include "rtc_base/ssl_identity.h" +#include "rtc_base/third_party/sigslot/sigslot.h" #include "test/gtest.h" using cricket::FakeDtlsTransport; diff --git a/pc/dtls_transport.cc b/pc/dtls_transport.cc index e8d6ae9b6a..c9f3279fbc 100644 --- a/pc/dtls_transport.cc +++ b/pc/dtls_transport.cc @@ -19,7 +19,7 @@ #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/ref_counted_object.h" -#include "rtc_base/ssl_certificate.h" +#include "rtc_base/ssl_stream_adapter.h" namespace webrtc { diff --git a/pc/dtls_transport_unittest.cc b/pc/dtls_transport_unittest.cc index 1400ff94c2..a9ac73c9b8 100644 --- a/pc/dtls_transport_unittest.cc +++ b/pc/dtls_transport_unittest.cc @@ -13,9 +13,15 @@ #include #include -#include "absl/memory/memory.h" +#include "absl/types/optional.h" +#include "api/rtc_error.h" #include "p2p/base/fake_dtls_transport.h" +#include "p2p/base/p2p_constants.h" +#include "rtc_base/fake_ssl_identity.h" #include "rtc_base/gunit.h" +#include "rtc_base/ref_counted_object.h" +#include "rtc_base/rtc_certificate.h" +#include "rtc_base/ssl_identity.h" #include "test/gmock.h" #include "test/gtest.h" diff --git a/pc/dtmf_sender.cc b/pc/dtmf_sender.cc index 1148350aa2..8b82c31aa9 100644 --- a/pc/dtmf_sender.cc +++ b/pc/dtmf_sender.cc @@ -13,8 +13,6 @@ #include #include -#include - #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/ref_counted_object.h" diff --git a/pc/dtmf_sender.h b/pc/dtmf_sender.h index 915d9874b3..ae213b3bf4 100644 --- a/pc/dtmf_sender.h +++ b/pc/dtmf_sender.h @@ -17,12 +17,14 @@ #include "api/dtmf_sender_interface.h" #include "api/scoped_refptr.h" +#include "api/sequence_checker.h" #include "pc/proxy.h" #include "rtc_base/location.h" #include "rtc_base/ref_count.h" #include "rtc_base/task_utils/pending_task_safety_flag.h" #include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread.h" +#include "rtc_base/thread_annotations.h" // DtmfSender is the native implementation of the RTCDTMFSender defined by // the WebRTC W3C Editor's Draft. @@ -102,6 +104,7 @@ class DtmfSender : public DtmfSenderInterface, public sigslot::has_slots<> { // Define proxy for DtmfSenderInterface. BEGIN_PRIMARY_PROXY_MAP(DtmfSender) + PROXY_PRIMARY_THREAD_DESTRUCTOR() PROXY_METHOD1(void, RegisterObserver, DtmfSenderObserverInterface*) PROXY_METHOD0(void, UnregisterObserver) diff --git a/pc/external_hmac.h b/pc/external_hmac.h index 3319beaed4..3c2936c685 100644 --- a/pc/external_hmac.h +++ b/pc/external_hmac.h @@ -33,6 +33,7 @@ #include "third_party/libsrtp/crypto/include/auth.h" #include "third_party/libsrtp/crypto/include/crypto_types.h" #include "third_party/libsrtp/include/srtp.h" +#include "third_party/libsrtp/include/srtp_priv.h" #define EXTERNAL_HMAC_SHA1 SRTP_HMAC_SHA1 + 1 #define HMAC_KEY_LENGTH 20 diff --git a/pc/ice_server_parsing.cc b/pc/ice_server_parsing.cc index 88f77bf0a9..cb4145be1a 100644 --- a/pc/ice_server_parsing.cc +++ b/pc/ice_server_parsing.cc @@ -12,9 +12,7 @@ #include -#include #include // For std::isdigit. -#include #include #include "p2p/base/port_interface.h" diff --git a/pc/ice_transport_unittest.cc b/pc/ice_transport_unittest.cc index ebb46cb5d5..95af2cd552 100644 --- a/pc/ice_transport_unittest.cc +++ b/pc/ice_transport_unittest.cc @@ -12,13 +12,12 @@ #include #include -#include #include "api/ice_transport_factory.h" +#include "api/scoped_refptr.h" #include "p2p/base/fake_ice_transport.h" #include "p2p/base/fake_port_allocator.h" -#include "rtc_base/gunit.h" -#include "test/gmock.h" +#include "rtc_base/ref_counted_object.h" #include "test/gtest.h" namespace webrtc { diff --git a/pc/jitter_buffer_delay.h b/pc/jitter_buffer_delay.h index dc10e3d2ba..a6bec01ce7 100644 --- a/pc/jitter_buffer_delay.h +++ b/pc/jitter_buffer_delay.h @@ -16,6 +16,7 @@ #include "absl/types/optional.h" #include "api/sequence_checker.h" #include "rtc_base/system/no_unique_address.h" +#include "rtc_base/thread_annotations.h" namespace webrtc { diff --git a/pc/jitter_buffer_delay_unittest.cc b/pc/jitter_buffer_delay_unittest.cc index b00075ceb5..79c39fffb8 100644 --- a/pc/jitter_buffer_delay_unittest.cc +++ b/pc/jitter_buffer_delay_unittest.cc @@ -10,9 +10,6 @@ #include "pc/jitter_buffer_delay.h" -#include - -#include "absl/types/optional.h" #include "test/gtest.h" namespace webrtc { diff --git a/pc/jsep_ice_candidate.cc b/pc/jsep_ice_candidate.cc index 6dacde629c..1e97ad42d8 100644 --- a/pc/jsep_ice_candidate.cc +++ b/pc/jsep_ice_candidate.cc @@ -10,8 +10,6 @@ #include "api/jsep_ice_candidate.h" -#include - #include "pc/webrtc_sdp.h" // This file contains JsepIceCandidate-related functions that are not diff --git a/pc/jsep_session_description.cc b/pc/jsep_session_description.cc index 57ccf7ca6e..4c57396f08 100644 --- a/pc/jsep_session_description.cc +++ b/pc/jsep_session_description.cc @@ -11,11 +11,20 @@ #include "api/jsep_session_description.h" #include +#include +#include "absl/types/optional.h" +#include "p2p/base/p2p_constants.h" #include "p2p/base/port.h" -#include "pc/media_session.h" +#include "p2p/base/transport_description.h" +#include "p2p/base/transport_info.h" +#include "pc/media_session.h" // IWYU pragma: keep #include "pc/webrtc_sdp.h" -#include "rtc_base/arraysize.h" +#include "rtc_base/checks.h" +#include "rtc_base/ip_address.h" +#include "rtc_base/logging.h" +#include "rtc_base/net_helper.h" +#include "rtc_base/socket_address.h" using cricket::SessionDescription; diff --git a/pc/jsep_session_description_unittest.cc b/pc/jsep_session_description_unittest.cc index 2202aa81d0..ee446cbbda 100644 --- a/pc/jsep_session_description_unittest.cc +++ b/pc/jsep_session_description_unittest.cc @@ -13,8 +13,6 @@ #include #include -#include -#include #include #include @@ -29,6 +27,7 @@ #include "pc/session_description.h" #include "pc/webrtc_sdp.h" #include "rtc_base/helpers.h" +#include "rtc_base/net_helper.h" #include "rtc_base/socket_address.h" #include "rtc_base/string_encode.h" #include "test/gtest.h" diff --git a/pc/jsep_transport.cc b/pc/jsep_transport.cc index 706c342a8d..00447b088d 100644 --- a/pc/jsep_transport.cc +++ b/pc/jsep_transport.cc @@ -15,6 +15,7 @@ #include #include +#include #include #include "api/array_view.h" diff --git a/pc/jsep_transport_collection.h b/pc/jsep_transport_collection.h index aa5293475e..099e24a457 100644 --- a/pc/jsep_transport_collection.h +++ b/pc/jsep_transport_collection.h @@ -18,6 +18,7 @@ #include #include +#include "api/jsep.h" #include "api/peer_connection_interface.h" #include "api/sequence_checker.h" #include "pc/jsep_transport.h" diff --git a/pc/jsep_transport_controller.cc b/pc/jsep_transport_controller.cc index b7e9f361bc..e63742aaee 100644 --- a/pc/jsep_transport_controller.cc +++ b/pc/jsep_transport_controller.cc @@ -12,9 +12,9 @@ #include -#include #include #include +#include #include #include diff --git a/pc/jsep_transport_controller.h b/pc/jsep_transport_controller.h index d207269d09..ed4d20ba84 100644 --- a/pc/jsep_transport_controller.h +++ b/pc/jsep_transport_controller.h @@ -17,6 +17,7 @@ #include #include #include +#include #include #include diff --git a/pc/jsep_transport_controller_unittest.cc b/pc/jsep_transport_controller_unittest.cc index 52d8182179..622a9b90e3 100644 --- a/pc/jsep_transport_controller_unittest.cc +++ b/pc/jsep_transport_controller_unittest.cc @@ -11,14 +11,26 @@ #include "pc/jsep_transport_controller.h" #include -#include +#include +#include #include "api/dtls_transport_interface.h" +#include "api/transport/enums.h" +#include "p2p/base/candidate_pair_interface.h" #include "p2p/base/dtls_transport_factory.h" #include "p2p/base/fake_dtls_transport.h" #include "p2p/base/fake_ice_transport.h" +#include "p2p/base/p2p_constants.h" #include "p2p/base/transport_info.h" +#include "rtc_base/fake_ssl_identity.h" #include "rtc_base/gunit.h" +#include "rtc_base/location.h" +#include "rtc_base/logging.h" +#include "rtc_base/net_helper.h" +#include "rtc_base/ref_counted_object.h" +#include "rtc_base/socket_address.h" +#include "rtc_base/ssl_fingerprint.h" +#include "rtc_base/ssl_identity.h" #include "rtc_base/thread.h" #include "test/gtest.h" diff --git a/pc/jsep_transport_unittest.cc b/pc/jsep_transport_unittest.cc index d06fa9596a..2ec96d2af7 100644 --- a/pc/jsep_transport_unittest.cc +++ b/pc/jsep_transport_unittest.cc @@ -10,15 +10,33 @@ #include "pc/jsep_transport.h" -#include +#include +#include + +#include +#include #include #include -#include "api/ice_transport_factory.h" +#include "api/candidate.h" #include "media/base/fake_rtp.h" #include "p2p/base/fake_dtls_transport.h" #include "p2p/base/fake_ice_transport.h" -#include "rtc_base/gunit.h" +#include "p2p/base/p2p_constants.h" +#include "p2p/base/packet_transport_internal.h" +#include "rtc_base/async_packet_socket.h" +#include "rtc_base/buffer.h" +#include "rtc_base/byte_order.h" +#include "rtc_base/copy_on_write_buffer.h" +#include "rtc_base/helpers.h" +#include "rtc_base/logging.h" +#include "rtc_base/net_helper.h" +#include "rtc_base/ref_counted_object.h" +#include "rtc_base/socket_address.h" +#include "rtc_base/ssl_certificate.h" +#include "rtc_base/ssl_identity.h" +#include "rtc_base/third_party/sigslot/sigslot.h" +#include "test/gtest.h" namespace cricket { namespace { diff --git a/pc/media_session.cc b/pc/media_session.cc index 96c285e67e..2a3a698874 100644 --- a/pc/media_session.cc +++ b/pc/media_session.cc @@ -14,8 +14,7 @@ #include #include -#include -#include +#include #include #include @@ -24,7 +23,6 @@ #include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "api/crypto_params.h" -#include "api/video_codecs/h264_profile_level_id.h" #include "media/base/codec.h" #include "media/base/media_constants.h" #include "media/base/sdp_video_format_utils.h" diff --git a/pc/media_session_unittest.cc b/pc/media_session_unittest.cc index cfe9ac8a31..6bc842d222 100644 --- a/pc/media_session_unittest.cc +++ b/pc/media_session_unittest.cc @@ -10,32 +10,42 @@ #include "pc/media_session.h" +#include + #include +#include +#include #include #include -#include +#include #include #include "absl/algorithm/container.h" -#include "absl/memory/memory.h" #include "absl/strings/match.h" +#include "absl/strings/string_view.h" +#include "api/candidate.h" +#include "api/crypto_params.h" #include "media/base/codec.h" +#include "media/base/media_constants.h" #include "media/base/test_utils.h" #include "media/sctp/sctp_transport_internal.h" #include "p2p/base/p2p_constants.h" #include "p2p/base/transport_description.h" #include "p2p/base/transport_info.h" +#include "pc/media_protocol_names.h" #include "pc/rtp_media_utils.h" -#include "pc/srtp_filter.h" +#include "rtc_base/arraysize.h" #include "rtc_base/checks.h" #include "rtc_base/fake_ssl_identity.h" -#include "rtc_base/gunit.h" -#include "rtc_base/message_digest.h" -#include "rtc_base/ssl_adapter.h" +#include "rtc_base/rtc_certificate.h" +#include "rtc_base/ssl_identity.h" +#include "rtc_base/ssl_stream_adapter.h" +#include "rtc_base/string_encode.h" #include "rtc_base/strings/string_builder.h" #include "rtc_base/unique_id_generator.h" #include "test/field_trial.h" #include "test/gmock.h" +#include "test/gtest.h" #define ASSERT_CRYPTO(cd, s, cs) \ ASSERT_EQ(s, cd->cryptos().size()); \ diff --git a/pc/media_stream.cc b/pc/media_stream.cc index 6fe308827c..011d8abf55 100644 --- a/pc/media_stream.cc +++ b/pc/media_stream.cc @@ -13,7 +13,6 @@ #include #include -#include #include "rtc_base/checks.h" #include "rtc_base/ref_counted_object.h" diff --git a/pc/media_stream_unittest.cc b/pc/media_stream_unittest.cc index 6ce8de9a1a..1d6935690e 100644 --- a/pc/media_stream_unittest.cc +++ b/pc/media_stream_unittest.cc @@ -12,8 +12,6 @@ #include -#include - #include "pc/audio_track.h" #include "pc/test/fake_video_track_source.h" #include "pc/video_track.h" diff --git a/pc/peer_connection.h b/pc/peer_connection.h index 4855d32be1..cd4af9e420 100644 --- a/pc/peer_connection.h +++ b/pc/peer_connection.h @@ -14,7 +14,6 @@ #include #include -#include #include #include #include diff --git a/pc/peer_connection_adaptation_integrationtest.cc b/pc/peer_connection_adaptation_integrationtest.cc index dfb12971b4..b5a5f5231d 100644 --- a/pc/peer_connection_adaptation_integrationtest.cc +++ b/pc/peer_connection_adaptation_integrationtest.cc @@ -8,12 +8,22 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include + #include +#include +#include "absl/types/optional.h" +#include "api/adaptation/resource.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" +#include "api/media_stream_interface.h" +#include "api/peer_connection_interface.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/video_source_interface.h" #include "call/adaptation/test/fake_resource.h" #include "pc/test/fake_periodic_video_source.h" #include "pc/test/fake_periodic_video_track_source.h" @@ -22,6 +32,7 @@ #include "rtc_base/gunit.h" #include "rtc_base/ref_counted_object.h" #include "rtc_base/thread.h" +#include "rtc_base/time_utils.h" #include "rtc_base/virtual_socket_server.h" #include "test/gtest.h" diff --git a/pc/peer_connection_bundle_unittest.cc b/pc/peer_connection_bundle_unittest.cc index e5eb6c4e18..4a5d373310 100644 --- a/pc/peer_connection_bundle_unittest.cc +++ b/pc/peer_connection_bundle_unittest.cc @@ -8,21 +8,59 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "api/audio/audio_mixer.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" +#include "api/candidate.h" #include "api/create_peerconnection_factory.h" +#include "api/jsep.h" +#include "api/media_types.h" +#include "api/peer_connection_interface.h" +#include "api/rtp_receiver_interface.h" +#include "api/rtp_sender_interface.h" +#include "api/rtp_transceiver_interface.h" +#include "api/scoped_refptr.h" +#include "api/stats/rtc_stats.h" +#include "api/stats/rtc_stats_report.h" +#include "api/stats/rtcstats_objects.h" #include "api/video_codecs/builtin_video_decoder_factory.h" #include "api/video_codecs/builtin_video_encoder_factory.h" -#include "p2p/base/fake_port_allocator.h" -#include "p2p/base/test_stun_server.h" +#include "media/base/stream_params.h" +#include "modules/audio_device/include/audio_device.h" +#include "modules/audio_processing/include/audio_processing.h" +#include "p2p/base/p2p_constants.h" +#include "p2p/base/port.h" +#include "p2p/base/port_allocator.h" +#include "p2p/base/transport_info.h" #include "p2p/client/basic_port_allocator.h" -#include "pc/media_session.h" +#include "pc/channel.h" #include "pc/peer_connection.h" #include "pc/peer_connection_proxy.h" #include "pc/peer_connection_wrapper.h" +#include "pc/rtp_transceiver.h" +#include "pc/rtp_transport_internal.h" #include "pc/sdp_utils.h" +#include "pc/session_description.h" +#include "pc/test/mock_peer_connection_observers.h" +#include "rtc_base/checks.h" +#include "rtc_base/logging.h" +#include "rtc_base/net_helper.h" +#include "rtc_base/network.h" +#include "rtc_base/rtc_certificate_generator.h" +#include "rtc_base/socket_address.h" +#include "rtc_base/thread.h" +#include "test/gtest.h" #ifdef WEBRTC_ANDROID #include "pc/test/android_test_initializer.h" #endif diff --git a/pc/peer_connection_crypto_unittest.cc b/pc/peer_connection_crypto_unittest.cc index 394203cb02..1741b99289 100644 --- a/pc/peer_connection_crypto_unittest.cc +++ b/pc/peer_connection_crypto_unittest.cc @@ -8,17 +8,47 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "absl/types/optional.h" +#include "api/audio/audio_mixer.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/create_peerconnection_factory.h" +#include "api/crypto/crypto_options.h" +#include "api/crypto_params.h" +#include "api/jsep.h" +#include "api/peer_connection_interface.h" +#include "api/scoped_refptr.h" #include "api/video_codecs/builtin_video_decoder_factory.h" #include "api/video_codecs/builtin_video_encoder_factory.h" +#include "modules/audio_device/include/audio_device.h" +#include "modules/audio_processing/include/audio_processing.h" #include "p2p/base/fake_port_allocator.h" +#include "p2p/base/port_allocator.h" +#include "p2p/base/transport_description.h" +#include "p2p/base/transport_info.h" +#include "pc/media_protocol_names.h" #include "pc/media_session.h" #include "pc/peer_connection_wrapper.h" #include "pc/sdp_utils.h" +#include "pc/session_description.h" +#include "pc/test/mock_peer_connection_observers.h" +#include "rtc_base/checks.h" +#include "rtc_base/ref_counted_object.h" +#include "rtc_base/rtc_certificate.h" +#include "rtc_base/rtc_certificate_generator.h" +#include "rtc_base/ssl_fingerprint.h" +#include "rtc_base/thread.h" +#include "test/gtest.h" #ifdef WEBRTC_ANDROID #include "pc/test/android_test_initializer.h" #endif diff --git a/pc/peer_connection_data_channel_unittest.cc b/pc/peer_connection_data_channel_unittest.cc index 5a6377b00d..0fb1c638eb 100644 --- a/pc/peer_connection_data_channel_unittest.cc +++ b/pc/peer_connection_data_channel_unittest.cc @@ -20,24 +20,24 @@ #include "api/media_types.h" #include "api/peer_connection_interface.h" #include "api/scoped_refptr.h" +#include "api/sctp_transport_interface.h" #include "api/task_queue/default_task_queue_factory.h" -#include "media/base/codec.h" +#include "api/task_queue/task_queue_factory.h" +#include "api/transport/sctp_transport_factory_interface.h" #include "media/base/fake_media_engine.h" -#include "media/base/media_constants.h" #include "media/base/media_engine.h" -#include "media/sctp/sctp_transport_internal.h" #include "p2p/base/p2p_constants.h" #include "p2p/base/port_allocator.h" #include "pc/media_session.h" #include "pc/peer_connection.h" -#include "pc/peer_connection_factory.h" #include "pc/peer_connection_proxy.h" #include "pc/peer_connection_wrapper.h" +#include "pc/sctp_transport.h" #include "pc/sdp_utils.h" #include "pc/session_description.h" #include "pc/test/mock_peer_connection_observers.h" #include "rtc_base/checks.h" -#include "rtc_base/ref_counted_object.h" +#include "rtc_base/logging.h" #include "rtc_base/rtc_certificate_generator.h" #include "rtc_base/thread.h" #include "test/gmock.h" diff --git a/pc/peer_connection_end_to_end_unittest.cc b/pc/peer_connection_end_to_end_unittest.cc index 3a6402703f..78dcda3202 100644 --- a/pc/peer_connection_end_to_end_unittest.cc +++ b/pc/peer_connection_end_to_end_unittest.cc @@ -8,20 +8,46 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include + +#include +#include #include +#include +#include +#include +#include #include "absl/strings/match.h" +#include "absl/types/optional.h" #include "api/audio_codecs/L16/audio_decoder_L16.h" #include "api/audio_codecs/L16/audio_encoder_L16.h" #include "api/audio_codecs/audio_codec_pair_id.h" +#include "api/audio_codecs/audio_decoder.h" +#include "api/audio_codecs/audio_decoder_factory.h" #include "api/audio_codecs/audio_decoder_factory_template.h" +#include "api/audio_codecs/audio_encoder.h" +#include "api/audio_codecs/audio_encoder_factory.h" #include "api/audio_codecs/audio_encoder_factory_template.h" +#include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/opus_audio_decoder_factory.h" #include "api/audio_codecs/opus_audio_encoder_factory.h" +#include "api/audio_options.h" +#include "api/data_channel_interface.h" +#include "api/media_stream_interface.h" +#include "api/peer_connection_interface.h" +#include "api/rtc_error.h" +#include "api/scoped_refptr.h" #include "media/sctp/sctp_transport_internal.h" +#include "rtc_base/checks.h" +#include "rtc_base/copy_on_write_buffer.h" #include "rtc_base/gunit.h" -#include "rtc_base/logging.h" #include "rtc_base/physical_socket_server.h" +#include "rtc_base/ref_counted_object.h" +#include "rtc_base/third_party/sigslot/sigslot.h" +#include "rtc_base/thread.h" +#include "test/gmock.h" +#include "test/gtest.h" #ifdef WEBRTC_ANDROID #include "pc/test/android_test_initializer.h" diff --git a/pc/peer_connection_factory.cc b/pc/peer_connection_factory.cc index db2f468a01..262ca90cd9 100644 --- a/pc/peer_connection_factory.cc +++ b/pc/peer_connection_factory.cc @@ -10,7 +10,7 @@ #include "pc/peer_connection_factory.h" -#include +#include #include #include "absl/strings/match.h" diff --git a/pc/peer_connection_factory.h b/pc/peer_connection_factory.h index c1599f4885..f09ca66e6e 100644 --- a/pc/peer_connection_factory.h +++ b/pc/peer_connection_factory.h @@ -23,6 +23,7 @@ #include "api/fec_controller.h" #include "api/media_stream_interface.h" #include "api/media_types.h" +#include "api/metronome/metronome.h" #include "api/neteq/neteq_factory.h" #include "api/network_state_predictor.h" #include "api/peer_connection_interface.h" diff --git a/pc/peer_connection_factory_unittest.cc b/pc/peer_connection_factory_unittest.cc index c12b563e27..4e97053fea 100644 --- a/pc/peer_connection_factory_unittest.cc +++ b/pc/peer_connection_factory_unittest.cc @@ -10,16 +10,10 @@ #include "pc/peer_connection_factory.h" -#include - -#include -#include #include #include #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/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/create_peerconnection_factory.h" @@ -28,17 +22,18 @@ #include "api/media_stream_interface.h" #include "api/video_codecs/builtin_video_decoder_factory.h" #include "api/video_codecs/builtin_video_encoder_factory.h" -#include "api/video_codecs/video_decoder_factory.h" -#include "api/video_codecs/video_encoder_factory.h" #include "media/base/fake_frame_source.h" #include "modules/audio_device/include/audio_device.h" #include "modules/audio_processing/include/audio_processing.h" #include "p2p/base/fake_port_allocator.h" #include "p2p/base/port.h" +#include "p2p/base/port_allocator.h" #include "p2p/base/port_interface.h" #include "pc/test/fake_audio_capture_module.h" #include "pc/test/fake_video_track_source.h" +#include "rtc_base/rtc_certificate_generator.h" #include "rtc_base/socket_address.h" +#include "rtc_base/time_utils.h" #include "test/gtest.h" #ifdef WEBRTC_ANDROID diff --git a/pc/peer_connection_header_extension_unittest.cc b/pc/peer_connection_header_extension_unittest.cc index 8bf6c7ab44..d7d160b631 100644 --- a/pc/peer_connection_header_extension_unittest.cc +++ b/pc/peer_connection_header_extension_unittest.cc @@ -9,17 +9,38 @@ */ #include +#include #include - +#include +#include + +#include "absl/strings/string_view.h" +#include "absl/types/optional.h" +#include "api/call/call_factory_interface.h" +#include "api/jsep.h" +#include "api/media_types.h" +#include "api/peer_connection_interface.h" +#include "api/rtc_error.h" #include "api/rtc_event_log/rtc_event_log_factory.h" +#include "api/rtc_event_log/rtc_event_log_factory_interface.h" +#include "api/rtp_parameters.h" +#include "api/rtp_transceiver_direction.h" +#include "api/rtp_transceiver_interface.h" +#include "api/scoped_refptr.h" #include "api/task_queue/default_task_queue_factory.h" +#include "api/task_queue/task_queue_factory.h" #include "media/base/fake_media_engine.h" +#include "media/base/media_engine.h" #include "p2p/base/fake_port_allocator.h" -#include "pc/media_session.h" +#include "p2p/base/port_allocator.h" #include "pc/peer_connection_wrapper.h" -#include "rtc_base/gunit.h" +#include "pc/session_description.h" +#include "pc/test/mock_peer_connection_observers.h" +#include "rtc_base/rtc_certificate_generator.h" #include "rtc_base/strings/string_builder.h" +#include "rtc_base/thread.h" #include "test/gmock.h" +#include "test/gtest.h" namespace webrtc { diff --git a/pc/peer_connection_histogram_unittest.cc b/pc/peer_connection_histogram_unittest.cc index 27bae854d6..ae88b65213 100644 --- a/pc/peer_connection_histogram_unittest.cc +++ b/pc/peer_connection_histogram_unittest.cc @@ -15,6 +15,7 @@ #include #include "absl/types/optional.h" +#include "api/async_resolver_factory.h" #include "api/call/call_factory_interface.h" #include "api/jsep.h" #include "api/jsep_session_description.h" @@ -22,7 +23,9 @@ #include "api/rtc_error.h" #include "api/scoped_refptr.h" #include "api/task_queue/default_task_queue_factory.h" +#include "api/task_queue/task_queue_factory.h" #include "media/base/fake_media_engine.h" +#include "media/base/media_engine.h" #include "p2p/base/mock_async_resolver.h" #include "p2p/base/port_allocator.h" #include "p2p/client/basic_port_allocator.h" @@ -39,13 +42,14 @@ #include "rtc_base/fake_mdns_responder.h" #include "rtc_base/fake_network.h" #include "rtc_base/gunit.h" +#include "rtc_base/mdns_responder_interface.h" #include "rtc_base/ref_counted_object.h" -#include "rtc_base/rtc_certificate_generator.h" #include "rtc_base/socket_address.h" #include "rtc_base/thread.h" #include "rtc_base/virtual_socket_server.h" #include "system_wrappers/include/metrics.h" #include "test/gmock.h" +#include "test/gtest.h" namespace webrtc { diff --git a/pc/peer_connection_ice_unittest.cc b/pc/peer_connection_ice_unittest.cc index c04ff8e204..ed64aa24ea 100644 --- a/pc/peer_connection_ice_unittest.cc +++ b/pc/peer_connection_ice_unittest.cc @@ -8,15 +8,52 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "absl/types/optional.h" +#include "api/audio/audio_mixer.h" +#include "api/candidate.h" +#include "api/ice_transport_interface.h" +#include "api/jsep.h" +#include "api/media_types.h" +#include "api/peer_connection_interface.h" +#include "api/rtc_error.h" +#include "api/scoped_refptr.h" +#include "modules/audio_device/include/audio_device.h" +#include "modules/audio_processing/include/audio_processing.h" #include "p2p/base/fake_port_allocator.h" -#include "p2p/base/test_stun_server.h" +#include "p2p/base/ice_transport_internal.h" +#include "p2p/base/p2p_constants.h" +#include "p2p/base/port.h" +#include "p2p/base/port_allocator.h" +#include "p2p/base/transport_description.h" +#include "p2p/base/transport_info.h" #include "p2p/client/basic_port_allocator.h" +#include "pc/channel_interface.h" +#include "pc/dtls_transport.h" #include "pc/media_session.h" #include "pc/peer_connection.h" #include "pc/peer_connection_wrapper.h" +#include "pc/rtp_transceiver.h" #include "pc/sdp_utils.h" +#include "pc/session_description.h" +#include "rtc_base/checks.h" +#include "rtc_base/ip_address.h" +#include "rtc_base/logging.h" +#include "rtc_base/net_helper.h" +#include "rtc_base/ref_counted_object.h" +#include "rtc_base/rtc_certificate_generator.h" +#include "rtc_base/socket_address.h" +#include "rtc_base/thread.h" +#include "test/gtest.h" #ifdef WEBRTC_ANDROID #include "pc/test/android_test_initializer.h" #endif diff --git a/pc/peer_connection_integrationtest.cc b/pc/peer_connection_integrationtest.cc index 0c97d0da95..1ee85c3be6 100644 --- a/pc/peer_connection_integrationtest.cc +++ b/pc/peer_connection_integrationtest.cc @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -86,6 +87,8 @@ #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" namespace webrtc { diff --git a/pc/peer_connection_interface_unittest.cc b/pc/peer_connection_interface_unittest.cc index 0d9f419149..7dd3b31a0c 100644 --- a/pc/peer_connection_interface_unittest.cc +++ b/pc/peer_connection_interface_unittest.cc @@ -12,9 +12,7 @@ #include #include -#include -#include #include #include #include @@ -22,32 +20,26 @@ #include "absl/strings/str_replace.h" #include "absl/types/optional.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/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/call/call_factory_interface.h" #include "api/create_peerconnection_factory.h" #include "api/data_channel_interface.h" #include "api/jsep.h" -#include "api/jsep_session_description.h" #include "api/media_stream_interface.h" #include "api/media_types.h" #include "api/rtc_error.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/rtc_event_log/rtc_event_log_factory.h" #include "api/rtc_event_log_output.h" -#include "api/rtc_event_log_output_file.h" #include "api/rtp_receiver_interface.h" #include "api/rtp_sender_interface.h" -#include "api/rtp_transceiver_interface.h" +#include "api/rtp_transceiver_direction.h" #include "api/scoped_refptr.h" #include "api/task_queue/default_task_queue_factory.h" #include "api/transport/field_trial_based_config.h" #include "api/video_codecs/builtin_video_decoder_factory.h" #include "api/video_codecs/builtin_video_encoder_factory.h" -#include "api/video_codecs/video_decoder_factory.h" -#include "api/video_codecs/video_encoder_factory.h" #include "media/base/codec.h" #include "media/base/media_config.h" #include "media/base/media_engine.h" @@ -68,8 +60,8 @@ #include "pc/media_stream.h" #include "pc/peer_connection.h" #include "pc/peer_connection_factory.h" -#include "pc/rtc_stats_collector.h" #include "pc/rtp_sender.h" +#include "pc/rtp_sender_proxy.h" #include "pc/session_description.h" #include "pc/stream_collection.h" #include "pc/test/fake_audio_capture_module.h" @@ -79,17 +71,14 @@ #include "pc/test/test_sdp_strings.h" #include "pc/video_track.h" #include "rtc_base/checks.h" -#include "rtc_base/copy_on_write_buffer.h" #include "rtc_base/gunit.h" #include "rtc_base/ref_counted_object.h" #include "rtc_base/rtc_certificate_generator.h" #include "rtc_base/socket_address.h" #include "rtc_base/thread.h" -#include "rtc_base/time_utils.h" #include "rtc_base/virtual_socket_server.h" #include "test/gmock.h" #include "test/gtest.h" -#include "test/testsupport/file_utils.h" #ifdef WEBRTC_ANDROID #include "pc/test/android_test_initializer.h" diff --git a/pc/peer_connection_jsep_unittest.cc b/pc/peer_connection_jsep_unittest.cc index 66581ca852..590fa90102 100644 --- a/pc/peer_connection_jsep_unittest.cc +++ b/pc/peer_connection_jsep_unittest.cc @@ -8,21 +8,56 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "absl/strings/string_view.h" +#include "absl/types/optional.h" +#include "api/call/call_factory_interface.h" +#include "api/jsep.h" +#include "api/media_stream_interface.h" +#include "api/media_types.h" +#include "api/peer_connection_interface.h" +#include "api/rtc_error.h" +#include "api/rtp_parameters.h" +#include "api/rtp_receiver_interface.h" +#include "api/rtp_sender_interface.h" +#include "api/rtp_transceiver_direction.h" +#include "api/rtp_transceiver_interface.h" +#include "api/scoped_refptr.h" #include "api/task_queue/default_task_queue_factory.h" +#include "api/task_queue/task_queue_factory.h" #include "api/transport/field_trial_based_config.h" +#include "api/transport/sctp_transport_factory_interface.h" +#include "api/transport/webrtc_key_value_config.h" +#include "media/base/media_engine.h" +#include "media/base/stream_params.h" #include "media/engine/webrtc_media_engine.h" #include "media/engine/webrtc_media_engine_defaults.h" +#include "modules/audio_device/include/audio_device.h" +#include "p2p/base/p2p_constants.h" +#include "p2p/base/port_allocator.h" +#include "p2p/base/transport_info.h" +#include "pc/channel_interface.h" #include "pc/media_session.h" -#include "pc/peer_connection_factory.h" #include "pc/peer_connection_wrapper.h" #include "pc/sdp_utils.h" +#include "pc/session_description.h" +#include "pc/test/mock_peer_connection_observers.h" +#include "rtc_base/rtc_certificate_generator.h" +#include "rtc_base/thread.h" +#include "test/gtest.h" #ifdef WEBRTC_ANDROID #include "pc/test/android_test_initializer.h" #endif #include "pc/test/fake_audio_capture_module.h" -#include "rtc_base/gunit.h" #include "rtc_base/virtual_socket_server.h" #include "test/gmock.h" #include "test/pc/sctp/fake_sctp_transport.h" diff --git a/pc/peer_connection_media_unittest.cc b/pc/peer_connection_media_unittest.cc index 30034b4cd5..2a3a0aff99 100644 --- a/pc/peer_connection_media_unittest.cc +++ b/pc/peer_connection_media_unittest.cc @@ -12,25 +12,56 @@ // PeerConnection and the underlying media engine, as well as tests that check // the media-related aspects of SDP. +#include +#include +#include +#include #include #include +#include #include +#include +#include +#include #include "absl/algorithm/container.h" #include "absl/types/optional.h" +#include "api/audio_options.h" #include "api/call/call_factory_interface.h" +#include "api/jsep.h" +#include "api/media_types.h" +#include "api/peer_connection_interface.h" +#include "api/rtc_error.h" #include "api/rtc_event_log/rtc_event_log_factory.h" +#include "api/rtc_event_log/rtc_event_log_factory_interface.h" +#include "api/rtp_parameters.h" +#include "api/rtp_sender_interface.h" +#include "api/rtp_transceiver_direction.h" +#include "api/rtp_transceiver_interface.h" +#include "api/scoped_refptr.h" #include "api/task_queue/default_task_queue_factory.h" +#include "api/task_queue/task_queue_factory.h" +#include "media/base/codec.h" #include "media/base/fake_media_engine.h" +#include "media/base/media_constants.h" +#include "media/base/media_engine.h" +#include "media/base/stream_params.h" #include "p2p/base/fake_port_allocator.h" +#include "p2p/base/p2p_constants.h" +#include "p2p/base/port_allocator.h" +#include "p2p/base/transport_info.h" #include "pc/media_session.h" #include "pc/peer_connection_wrapper.h" #include "pc/rtp_media_utils.h" -#include "pc/sdp_utils.h" +#include "pc/session_description.h" +#include "pc/test/mock_peer_connection_observers.h" +#include "rtc_base/checks.h" +#include "rtc_base/rtc_certificate_generator.h" +#include "rtc_base/thread.h" +#include "test/gtest.h" #ifdef WEBRTC_ANDROID #include "pc/test/android_test_initializer.h" #endif -#include "pc/test/fake_rtc_certificate_generator.h" #include "rtc_base/gunit.h" #include "rtc_base/virtual_socket_server.h" #include "test/gmock.h" diff --git a/pc/peer_connection_message_handler.cc b/pc/peer_connection_message_handler.cc index 54f75f00a9..77db3e45e2 100644 --- a/pc/peer_connection_message_handler.cc +++ b/pc/peer_connection_message_handler.cc @@ -10,6 +10,7 @@ #include "pc/peer_connection_message_handler.h" +#include #include #include "api/jsep.h" diff --git a/pc/peer_connection_rampup_tests.cc b/pc/peer_connection_rampup_tests.cc index 692ca9d689..dc5a11f58a 100644 --- a/pc/peer_connection_rampup_tests.cc +++ b/pc/peer_connection_rampup_tests.cc @@ -15,8 +15,6 @@ #include "absl/types/optional.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/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/audio_options.h" @@ -24,14 +22,13 @@ #include "api/jsep.h" #include "api/media_stream_interface.h" #include "api/peer_connection_interface.h" +#include "api/rtc_error.h" #include "api/scoped_refptr.h" #include "api/stats/rtc_stats.h" #include "api/stats/rtc_stats_report.h" #include "api/stats/rtcstats_objects.h" #include "api/video_codecs/builtin_video_decoder_factory.h" #include "api/video_codecs/builtin_video_encoder_factory.h" -#include "api/video_codecs/video_decoder_factory.h" -#include "api/video_codecs/video_encoder_factory.h" #include "modules/audio_device/include/audio_device.h" #include "modules/audio_processing/include/audio_processing.h" #include "p2p/base/port_allocator.h" @@ -51,6 +48,7 @@ #include "rtc_base/location.h" #include "rtc_base/ref_counted_object.h" #include "rtc_base/socket_address.h" +#include "rtc_base/socket_factory.h" #include "rtc_base/ssl_certificate.h" #include "rtc_base/test_certificate_verifier.h" #include "rtc_base/thread.h" diff --git a/pc/peer_connection_rtp_unittest.cc b/pc/peer_connection_rtp_unittest.cc index fac738b7ba..6c08ba47bc 100644 --- a/pc/peer_connection_rtp_unittest.cc +++ b/pc/peer_connection_rtp_unittest.cc @@ -8,8 +8,9 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include +#include +#include #include #include #include @@ -17,8 +18,6 @@ #include "absl/types/optional.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/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/create_peerconnection_factory.h" @@ -30,14 +29,13 @@ #include "api/rtp_parameters.h" #include "api/rtp_receiver_interface.h" #include "api/rtp_sender_interface.h" +#include "api/rtp_transceiver_direction.h" #include "api/rtp_transceiver_interface.h" #include "api/scoped_refptr.h" #include "api/set_remote_description_observer_interface.h" #include "api/uma_metrics.h" #include "api/video_codecs/builtin_video_decoder_factory.h" #include "api/video_codecs/builtin_video_encoder_factory.h" -#include "api/video_codecs/video_decoder_factory.h" -#include "api/video_codecs/video_encoder_factory.h" #include "media/base/stream_params.h" #include "modules/audio_device/include/audio_device.h" #include "modules/audio_processing/include/audio_processing.h" diff --git a/pc/peer_connection_signaling_unittest.cc b/pc/peer_connection_signaling_unittest.cc index 90dd868de6..5923d2c47f 100644 --- a/pc/peer_connection_signaling_unittest.cc +++ b/pc/peer_connection_signaling_unittest.cc @@ -12,20 +12,52 @@ // machine, as well as tests that check basic, media-agnostic aspects of SDP. #include +#include +#include +#include #include +#include +#include #include +#include +#include +#include +#include "absl/types/optional.h" +#include "api/audio/audio_mixer.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/create_peerconnection_factory.h" -#include "api/jsep_session_description.h" +#include "api/dtls_transport_interface.h" +#include "api/jsep.h" +#include "api/media_types.h" +#include "api/peer_connection_interface.h" +#include "api/rtc_error.h" +#include "api/rtp_receiver_interface.h" +#include "api/rtp_sender_interface.h" +#include "api/rtp_transceiver_interface.h" +#include "api/scoped_refptr.h" +#include "api/set_local_description_observer_interface.h" +#include "api/set_remote_description_observer_interface.h" #include "api/video_codecs/builtin_video_decoder_factory.h" #include "api/video_codecs/builtin_video_encoder_factory.h" +#include "media/base/codec.h" +#include "modules/audio_device/include/audio_device.h" +#include "modules/audio_processing/include/audio_processing.h" +#include "p2p/base/port_allocator.h" #include "pc/peer_connection.h" #include "pc/peer_connection_proxy.h" #include "pc/peer_connection_wrapper.h" #include "pc/sdp_utils.h" -#include "pc/webrtc_sdp.h" +#include "pc/session_description.h" +#include "pc/test/mock_peer_connection_observers.h" +#include "rtc_base/checks.h" +#include "rtc_base/ref_counted_object.h" +#include "rtc_base/rtc_certificate.h" +#include "rtc_base/rtc_certificate_generator.h" +#include "rtc_base/string_encode.h" +#include "rtc_base/thread.h" +#include "test/gtest.h" #ifdef WEBRTC_ANDROID #include "pc/test/android_test_initializer.h" #endif @@ -33,7 +65,6 @@ #include "pc/test/fake_rtc_certificate_generator.h" #include "rtc_base/gunit.h" #include "rtc_base/virtual_socket_server.h" -#include "test/gmock.h" namespace webrtc { diff --git a/pc/peer_connection_simulcast_unittest.cc b/pc/peer_connection_simulcast_unittest.cc index 31385754b7..10c4f39703 100644 --- a/pc/peer_connection_simulcast_unittest.cc +++ b/pc/peer_connection_simulcast_unittest.cc @@ -8,26 +8,51 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include +#include +#include #include #include // no-presubmit-check TODO(webrtc:8982) +#include +#include +#include #include "absl/algorithm/container.h" +#include "absl/strings/string_view.h" +#include "api/audio/audio_mixer.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/create_peerconnection_factory.h" +#include "api/jsep.h" #include "api/media_types.h" +#include "api/peer_connection_interface.h" #include "api/rtc_error.h" +#include "api/rtp_parameters.h" +#include "api/rtp_sender_interface.h" +#include "api/rtp_transceiver_direction.h" #include "api/rtp_transceiver_interface.h" +#include "api/scoped_refptr.h" #include "api/uma_metrics.h" +#include "api/video/video_codec_constants.h" #include "api/video_codecs/builtin_video_decoder_factory.h" #include "api/video_codecs/builtin_video_encoder_factory.h" -#include "pc/peer_connection.h" +#include "media/base/rid_description.h" +#include "media/base/stream_params.h" +#include "modules/audio_device/include/audio_device.h" +#include "modules/audio_processing/include/audio_processing.h" +#include "pc/channel_interface.h" #include "pc/peer_connection_wrapper.h" +#include "pc/session_description.h" +#include "pc/simulcast_description.h" #include "pc/test/fake_audio_capture_module.h" #include "pc/test/mock_peer_connection_observers.h" -#include "rtc_base/gunit.h" +#include "rtc_base/checks.h" +#include "rtc_base/strings/string_builder.h" +#include "rtc_base/thread.h" +#include "rtc_base/unique_id_generator.h" #include "system_wrappers/include/metrics.h" #include "test/gmock.h" +#include "test/gtest.h" using ::testing::Contains; using ::testing::Each; diff --git a/pc/peer_connection_wrapper.cc b/pc/peer_connection_wrapper.cc index 641d8bf053..6a7a30edc0 100644 --- a/pc/peer_connection_wrapper.cc +++ b/pc/peer_connection_wrapper.cc @@ -12,8 +12,6 @@ #include -#include -#include #include #include diff --git a/pc/proxy.h b/pc/proxy.h index 85cb70d34c..e48f479183 100644 --- a/pc/proxy.h +++ b/pc/proxy.h @@ -59,6 +59,8 @@ #ifndef PC_PROXY_H_ #define PC_PROXY_H_ +#include + #include #include #include @@ -69,6 +71,7 @@ #include "api/task_queue/queued_task.h" #include "api/task_queue/task_queue_base.h" #include "rtc_base/event.h" +#include "rtc_base/location.h" #include "rtc_base/message_handler.h" #include "rtc_base/ref_counted_object.h" #include "rtc_base/string_utils.h" diff --git a/pc/remote_audio_source.cc b/pc/remote_audio_source.cc index 78a35f32a8..781e4512be 100644 --- a/pc/remote_audio_source.cc +++ b/pc/remote_audio_source.cc @@ -13,6 +13,7 @@ #include #include +#include #include "absl/algorithm/container.h" #include "api/scoped_refptr.h" diff --git a/pc/rtc_stats_collector.cc b/pc/rtc_stats_collector.cc index 7e9807e449..13c62ec975 100644 --- a/pc/rtc_stats_collector.cc +++ b/pc/rtc_stats_collector.cc @@ -10,26 +10,28 @@ #include "pc/rtc_stats_collector.h" +#include #include -#include #include #include #include #include +#include #include #include +#include "absl/strings/string_view.h" #include "api/array_view.h" #include "api/candidate.h" +#include "api/dtls_transport_interface.h" #include "api/media_stream_interface.h" #include "api/rtp_parameters.h" -#include "api/rtp_receiver_interface.h" -#include "api/rtp_sender_interface.h" #include "api/sequence_checker.h" #include "api/stats/rtc_stats.h" #include "api/stats/rtcstats_objects.h" #include "api/task_queue/queued_task.h" +#include "api/units/time_delta.h" #include "api/video/video_content_type.h" #include "common_video/include/quality_limitation_reason.h" #include "media/base/media_channel.h" @@ -37,7 +39,6 @@ #include "modules/rtp_rtcp/include/report_block_data.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "p2p/base/connection_info.h" -#include "p2p/base/dtls_transport_internal.h" #include "p2p/base/ice_transport_internal.h" #include "p2p/base/p2p_constants.h" #include "p2p/base/port.h" @@ -45,6 +46,8 @@ #include "pc/channel_interface.h" #include "pc/data_channel_utils.h" #include "pc/rtc_stats_traversal.h" +#include "pc/rtp_receiver_proxy.h" +#include "pc/rtp_sender_proxy.h" #include "pc/webrtc_sdp.h" #include "rtc_base/checks.h" #include "rtc_base/ip_address.h" diff --git a/pc/rtc_stats_collector.h b/pc/rtc_stats_collector.h index c84e6d3fef..e6d9d184fe 100644 --- a/pc/rtc_stats_collector.h +++ b/pc/rtc_stats_collector.h @@ -12,6 +12,8 @@ #define PC_RTC_STATS_COLLECTOR_H_ #include + +#include #include #include #include diff --git a/pc/rtc_stats_collector_unittest.cc b/pc/rtc_stats_collector_unittest.cc index b39621d862..d33760abcb 100644 --- a/pc/rtc_stats_collector_unittest.cc +++ b/pc/rtc_stats_collector_unittest.cc @@ -11,28 +11,45 @@ #include "pc/rtc_stats_collector.h" #include +#include +#include #include #include #include #include #include +#include #include #include -#include "absl/memory/memory.h" #include "absl/strings/str_replace.h" +#include "api/candidate.h" #include "api/dtls_transport_interface.h" +#include "api/media_stream_interface.h" #include "api/media_stream_track.h" #include "api/rtp_parameters.h" +#include "api/stats/rtc_stats.h" #include "api/stats/rtc_stats_report.h" #include "api/stats/rtcstats_objects.h" #include "api/units/time_delta.h" +#include "api/units/timestamp.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 "api/video/video_source_interface.h" +#include "common_video/include/quality_limitation_reason.h" +#include "media/base/media_channel.h" +#include "modules/audio_processing/include/audio_processing_statistics.h" #include "modules/rtp_rtcp/include/report_block_data.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" +#include "p2p/base/connection_info.h" +#include "p2p/base/ice_transport_internal.h" #include "p2p/base/p2p_constants.h" #include "p2p/base/port.h" #include "pc/media_stream.h" +#include "pc/stream_collection.h" #include "pc/test/fake_data_channel_provider.h" #include "pc/test/fake_peer_connection_for_stats.h" #include "pc/test/mock_data_channel.h" @@ -43,10 +60,19 @@ #include "rtc_base/fake_clock.h" #include "rtc_base/fake_ssl_identity.h" #include "rtc_base/gunit.h" -#include "rtc_base/logging.h" +#include "rtc_base/network_constants.h" +#include "rtc_base/ref_counted_object.h" +#include "rtc_base/rtc_certificate.h" +#include "rtc_base/socket_address.h" +#include "rtc_base/ssl_fingerprint.h" +#include "rtc_base/ssl_identity.h" +#include "rtc_base/ssl_stream_adapter.h" +#include "rtc_base/string_encode.h" #include "rtc_base/strings/json.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/time_utils.h" +#include "test/gmock.h" +#include "test/gtest.h" using ::testing::_; using ::testing::AtLeast; diff --git a/pc/rtc_stats_integrationtest.cc b/pc/rtc_stats_integrationtest.cc index ad533499ab..be9cd6fbc0 100644 --- a/pc/rtc_stats_integrationtest.cc +++ b/pc/rtc_stats_integrationtest.cc @@ -11,7 +11,6 @@ #include #include -#include #include #include #include @@ -19,8 +18,6 @@ #include "absl/algorithm/container.h" #include "absl/strings/match.h" -#include "api/audio_codecs/audio_decoder_factory.h" -#include "api/audio_codecs/audio_encoder_factory.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/audio_options.h" diff --git a/pc/rtc_stats_traversal_unittest.cc b/pc/rtc_stats_traversal_unittest.cc index c7d097117e..6e9b784313 100644 --- a/pc/rtc_stats_traversal_unittest.cc +++ b/pc/rtc_stats_traversal_unittest.cc @@ -11,7 +11,6 @@ #include "pc/rtc_stats_traversal.h" #include -#include #include #include "api/stats/rtcstats_objects.h" diff --git a/pc/rtp_media_utils.h b/pc/rtp_media_utils.h index 6f7986f096..5c61f5b1d6 100644 --- a/pc/rtp_media_utils.h +++ b/pc/rtp_media_utils.h @@ -11,6 +11,8 @@ #ifndef PC_RTP_MEDIA_UTILS_H_ #define PC_RTP_MEDIA_UTILS_H_ +#include // no-presubmit-check TODO(webrtc:8982) + #include "api/rtp_transceiver_direction.h" #include "api/rtp_transceiver_interface.h" diff --git a/pc/rtp_parameters_conversion.cc b/pc/rtp_parameters_conversion.cc index 8d3064ed93..afba4bc94f 100644 --- a/pc/rtp_parameters_conversion.cc +++ b/pc/rtp_parameters_conversion.cc @@ -10,10 +10,10 @@ #include "pc/rtp_parameters_conversion.h" -#include #include #include #include +#include #include #include "api/array_view.h" diff --git a/pc/rtp_parameters_conversion.h b/pc/rtp_parameters_conversion.h index 62e4685722..959f3fde47 100644 --- a/pc/rtp_parameters_conversion.h +++ b/pc/rtp_parameters_conversion.h @@ -11,7 +11,6 @@ #ifndef PC_RTP_PARAMETERS_CONVERSION_H_ #define PC_RTP_PARAMETERS_CONVERSION_H_ -#include #include #include "absl/types/optional.h" diff --git a/pc/rtp_parameters_conversion_unittest.cc b/pc/rtp_parameters_conversion_unittest.cc index 99d976abcd..50d90e1c30 100644 --- a/pc/rtp_parameters_conversion_unittest.cc +++ b/pc/rtp_parameters_conversion_unittest.cc @@ -10,10 +10,13 @@ #include "pc/rtp_parameters_conversion.h" -#include +#include +#include +#include -#include "rtc_base/gunit.h" +#include "api/media_types.h" #include "test/gmock.h" +#include "test/gtest.h" using ::testing::UnorderedElementsAre; diff --git a/pc/rtp_receiver.cc b/pc/rtp_receiver.cc index 2444c9b60d..a2b3353c0e 100644 --- a/pc/rtp_receiver.cc +++ b/pc/rtp_receiver.cc @@ -17,7 +17,7 @@ #include "pc/media_stream.h" #include "pc/media_stream_proxy.h" -#include "rtc_base/location.h" +#include "rtc_base/thread.h" namespace webrtc { diff --git a/pc/rtp_sender.cc b/pc/rtp_sender.cc index 110b5aae0a..dc53105b6d 100644 --- a/pc/rtp_sender.cc +++ b/pc/rtp_sender.cc @@ -12,6 +12,7 @@ #include #include +#include #include #include diff --git a/pc/rtp_sender.h b/pc/rtp_sender.h index ca2d1385ce..569a6007d3 100644 --- a/pc/rtp_sender.h +++ b/pc/rtp_sender.h @@ -17,6 +17,7 @@ #include #include + #include #include #include @@ -32,13 +33,16 @@ #include "api/rtp_parameters.h" #include "api/rtp_sender_interface.h" #include "api/scoped_refptr.h" +#include "api/sequence_checker.h" #include "media/base/audio_source.h" #include "media/base/media_channel.h" #include "pc/dtmf_sender.h" #include "pc/stats_collector_interface.h" +#include "rtc_base/checks.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread.h" +#include "rtc_base/thread_annotations.h" namespace webrtc { diff --git a/pc/rtp_sender_receiver_unittest.cc b/pc/rtp_sender_receiver_unittest.cc index d947b8b3e9..c0b09e39c3 100644 --- a/pc/rtp_sender_receiver_unittest.cc +++ b/pc/rtp_sender_receiver_unittest.cc @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -28,15 +29,20 @@ #include "api/rtc_error.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/rtp_parameters.h" +#include "api/rtp_receiver_interface.h" #include "api/scoped_refptr.h" #include "api/test/fake_frame_decryptor.h" #include "api/test/fake_frame_encryptor.h" #include "api/video/builtin_video_bitrate_allocator_factory.h" +#include "api/video/video_bitrate_allocator_factory.h" +#include "api/video/video_codec_constants.h" #include "media/base/codec.h" +#include "media/base/delayable.h" #include "media/base/fake_media_engine.h" #include "media/base/media_channel.h" #include "media/base/media_config.h" #include "media/base/media_engine.h" +#include "media/base/rid_description.h" #include "media/base/stream_params.h" #include "media/base/test_utils.h" #include "media/engine/fake_webrtc_call.h" @@ -50,8 +56,6 @@ #include "pc/dtls_srtp_transport.h" #include "pc/local_audio_source.h" #include "pc/media_stream.h" -#include "pc/remote_audio_source.h" -#include "pc/rtp_receiver.h" #include "pc/rtp_sender.h" #include "pc/rtp_transport_internal.h" #include "pc/test/fake_video_track_source.h" @@ -59,6 +63,8 @@ #include "pc/video_track.h" #include "rtc_base/checks.h" #include "rtc_base/gunit.h" +#include "rtc_base/location.h" +#include "rtc_base/ref_counted_object.h" #include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread.h" #include "test/gmock.h" diff --git a/pc/rtp_transceiver.cc b/pc/rtp_transceiver.cc index 013277fa53..5e3a084d2d 100644 --- a/pc/rtp_transceiver.cc +++ b/pc/rtp_transceiver.cc @@ -10,6 +10,7 @@ #include "pc/rtp_transceiver.h" +#include #include #include #include @@ -24,6 +25,7 @@ #include "pc/rtp_media_utils.h" #include "pc/session_description.h" #include "rtc_base/checks.h" +#include "rtc_base/location.h" #include "rtc_base/logging.h" #include "rtc_base/task_utils/to_queued_task.h" #include "rtc_base/thread.h" diff --git a/pc/rtp_transceiver.h b/pc/rtp_transceiver.h index b8dbb677dd..e7e3fb9be1 100644 --- a/pc/rtp_transceiver.h +++ b/pc/rtp_transceiver.h @@ -20,9 +20,12 @@ #include "absl/types/optional.h" #include "api/array_view.h" +#include "api/jsep.h" #include "api/media_types.h" #include "api/rtc_error.h" #include "api/rtp_parameters.h" +#include "api/rtp_receiver_interface.h" +#include "api/rtp_sender_interface.h" #include "api/rtp_transceiver_direction.h" #include "api/rtp_transceiver_interface.h" #include "api/scoped_refptr.h" @@ -34,6 +37,8 @@ #include "pc/rtp_receiver_proxy.h" #include "pc/rtp_sender.h" #include "pc/rtp_sender_proxy.h" +#include "pc/rtp_transport_internal.h" +#include "pc/session_description.h" #include "rtc_base/ref_counted_object.h" #include "rtc_base/task_utils/pending_task_safety_flag.h" #include "rtc_base/third_party/sigslot/sigslot.h" diff --git a/pc/rtp_transceiver_unittest.cc b/pc/rtp_transceiver_unittest.cc index df6dd29f31..e5c7733178 100644 --- a/pc/rtp_transceiver_unittest.cc +++ b/pc/rtp_transceiver_unittest.cc @@ -14,12 +14,15 @@ #include +#include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "api/rtp_parameters.h" #include "media/base/fake_media_engine.h" +#include "media/base/media_engine.h" #include "pc/test/mock_channel_interface.h" #include "pc/test/mock_rtp_receiver_internal.h" #include "pc/test/mock_rtp_sender_internal.h" +#include "rtc_base/thread.h" #include "test/gmock.h" #include "test/gtest.h" diff --git a/pc/rtp_transmission_manager.cc b/pc/rtp_transmission_manager.cc index 130dc311a4..5dbb765098 100644 --- a/pc/rtp_transmission_manager.cc +++ b/pc/rtp_transmission_manager.cc @@ -10,7 +10,7 @@ #include "pc/rtp_transmission_manager.h" -#include +#include #include #include "absl/types/optional.h" @@ -23,6 +23,7 @@ #include "rtc_base/checks.h" #include "rtc_base/helpers.h" #include "rtc_base/logging.h" +#include "rtc_base/ref_counted_object.h" namespace webrtc { diff --git a/pc/rtp_transmission_manager.h b/pc/rtp_transmission_manager.h index 209c8408de..3496bfa54d 100644 --- a/pc/rtp_transmission_manager.h +++ b/pc/rtp_transmission_manager.h @@ -29,7 +29,9 @@ #include "media/base/media_channel.h" #include "pc/channel_manager.h" #include "pc/rtp_receiver.h" +#include "pc/rtp_receiver_proxy.h" #include "pc/rtp_sender.h" +#include "pc/rtp_sender_proxy.h" #include "pc/rtp_transceiver.h" #include "pc/stats_collector_interface.h" #include "pc/transceiver_list.h" diff --git a/pc/rtp_transport.cc b/pc/rtp_transport.cc index d4edb9501c..334dc4d0b2 100644 --- a/pc/rtp_transport.cc +++ b/pc/rtp_transport.cc @@ -11,11 +11,13 @@ #include "pc/rtp_transport.h" #include -#include + +#include #include #include "absl/strings/string_view.h" #include "api/array_view.h" +#include "api/units/timestamp.h" #include "media/base/rtp_utils.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" #include "rtc_base/checks.h" diff --git a/pc/rtp_transport.h b/pc/rtp_transport.h index 893d91e734..39d4ad5b54 100644 --- a/pc/rtp_transport.h +++ b/pc/rtp_transport.h @@ -18,6 +18,7 @@ #include "absl/types/optional.h" #include "call/rtp_demuxer.h" +#include "call/video_receive_stream.h" #include "modules/rtp_rtcp/include/rtp_header_extension_map.h" #include "p2p/base/packet_transport_internal.h" #include "pc/rtp_transport_internal.h" diff --git a/pc/rtp_transport_unittest.cc b/pc/rtp_transport_unittest.cc index aae6d2c462..0e6af734f3 100644 --- a/pc/rtp_transport_unittest.cc +++ b/pc/rtp_transport_unittest.cc @@ -10,16 +10,10 @@ #include "pc/rtp_transport.h" -#include -#include -#include -#include - -#include "api/rtp_headers.h" -#include "api/rtp_parameters.h" #include "p2p/base/fake_packet_transport.h" #include "pc/test/rtp_transport_test_util.h" #include "rtc_base/buffer.h" +#include "rtc_base/containers/flat_set.h" #include "rtc_base/third_party/sigslot/sigslot.h" #include "test/gtest.h" diff --git a/pc/sctp_data_channel_transport.cc b/pc/sctp_data_channel_transport.cc index f01f86ebd8..626d1757b7 100644 --- a/pc/sctp_data_channel_transport.cc +++ b/pc/sctp_data_channel_transport.cc @@ -10,9 +10,6 @@ #include "pc/sctp_data_channel_transport.h" -#include "absl/types/optional.h" -#include "pc/sctp_utils.h" - namespace webrtc { SctpDataChannelTransport::SctpDataChannelTransport( diff --git a/pc/sctp_transport.h b/pc/sctp_transport.h index 16b98407b6..4981db4ede 100644 --- a/pc/sctp_transport.h +++ b/pc/sctp_transport.h @@ -16,9 +16,11 @@ #include "api/dtls_transport_interface.h" #include "api/scoped_refptr.h" #include "api/sctp_transport_interface.h" +#include "api/sequence_checker.h" #include "media/sctp/sctp_transport_internal.h" #include "p2p/base/dtls_transport_internal.h" #include "pc/dtls_transport.h" +#include "rtc_base/checks.h" #include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread.h" #include "rtc_base/thread_annotations.h" diff --git a/pc/sctp_transport_unittest.cc b/pc/sctp_transport_unittest.cc index 679b481f4c..e3168d8b99 100644 --- a/pc/sctp_transport_unittest.cc +++ b/pc/sctp_transport_unittest.cc @@ -14,10 +14,17 @@ #include #include "absl/memory/memory.h" +#include "absl/types/optional.h" #include "api/dtls_transport_interface.h" +#include "api/transport/data_channel_transport_interface.h" +#include "media/base/media_channel.h" #include "p2p/base/fake_dtls_transport.h" +#include "p2p/base/p2p_constants.h" +#include "p2p/base/packet_transport_internal.h" #include "pc/dtls_transport.h" +#include "rtc_base/copy_on_write_buffer.h" #include "rtc_base/gunit.h" +#include "rtc_base/ref_counted_object.h" #include "test/gmock.h" #include "test/gtest.h" diff --git a/pc/sctp_utils.cc b/pc/sctp_utils.cc index f7458405ea..c60e339b08 100644 --- a/pc/sctp_utils.cc +++ b/pc/sctp_utils.cc @@ -11,12 +11,12 @@ #include "pc/sctp_utils.h" #include -#include + +#include #include "absl/types/optional.h" #include "api/priority.h" #include "rtc_base/byte_buffer.h" -#include "rtc_base/checks.h" #include "rtc_base/copy_on_write_buffer.h" #include "rtc_base/logging.h" diff --git a/pc/sctp_utils_unittest.cc b/pc/sctp_utils_unittest.cc index af14fe4f6b..146886b8cb 100644 --- a/pc/sctp_utils_unittest.cc +++ b/pc/sctp_utils_unittest.cc @@ -12,6 +12,8 @@ #include +#include "absl/types/optional.h" +#include "api/priority.h" #include "rtc_base/byte_buffer.h" #include "rtc_base/copy_on_write_buffer.h" #include "test/gtest.h" diff --git a/pc/sdp_offer_answer.h b/pc/sdp_offer_answer.h index 622d57af24..67ead47242 100644 --- a/pc/sdp_offer_answer.h +++ b/pc/sdp_offer_answer.h @@ -15,7 +15,6 @@ #include #include -#include #include #include #include diff --git a/pc/sdp_offer_answer_unittest.cc b/pc/sdp_offer_answer_unittest.cc index df343cce3a..b992c34906 100644 --- a/pc/sdp_offer_answer_unittest.cc +++ b/pc/sdp_offer_answer_unittest.cc @@ -8,53 +8,29 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include - #include -#include #include #include -#include "absl/types/optional.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/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/create_peerconnection_factory.h" -#include "api/jsep.h" -#include "api/media_stream_interface.h" #include "api/media_types.h" #include "api/peer_connection_interface.h" -#include "api/rtc_error.h" -#include "api/rtp_parameters.h" -#include "api/rtp_receiver_interface.h" -#include "api/rtp_sender_interface.h" #include "api/rtp_transceiver_interface.h" #include "api/scoped_refptr.h" -#include "api/set_remote_description_observer_interface.h" -#include "api/uma_metrics.h" #include "api/video_codecs/builtin_video_decoder_factory.h" #include "api/video_codecs/builtin_video_encoder_factory.h" -#include "api/video_codecs/video_decoder_factory.h" -#include "api/video_codecs/video_encoder_factory.h" -#include "media/base/stream_params.h" #include "modules/audio_device/include/audio_device.h" #include "modules/audio_processing/include/audio_processing.h" #include "p2p/base/port_allocator.h" -#include "pc/media_session.h" #include "pc/peer_connection_wrapper.h" -#include "pc/sdp_utils.h" -#include "pc/session_description.h" #include "pc/test/fake_audio_capture_module.h" #include "pc/test/mock_peer_connection_observers.h" -#include "rtc_base/checks.h" -#include "rtc_base/gunit.h" -#include "rtc_base/ref_counted_object.h" #include "rtc_base/rtc_certificate_generator.h" #include "rtc_base/thread.h" #include "system_wrappers/include/metrics.h" -#include "test/gmock.h" #include "test/gtest.h" // This file contains unit tests that relate to the behavior of the diff --git a/pc/sdp_serializer.cc b/pc/sdp_serializer.cc index cdd2f2e9ad..6d405d07a9 100644 --- a/pc/sdp_serializer.cc +++ b/pc/sdp_serializer.cc @@ -10,9 +10,9 @@ #include "pc/sdp_serializer.h" -#include #include #include +#include #include #include diff --git a/pc/sdp_serializer_unittest.cc b/pc/sdp_serializer_unittest.cc index 68d4c2acef..0c31750df4 100644 --- a/pc/sdp_serializer_unittest.cc +++ b/pc/sdp_serializer_unittest.cc @@ -10,12 +10,14 @@ #include "pc/sdp_serializer.h" +#include + #include #include #include #include -#include "rtc_base/gunit.h" +#include "test/gtest.h" using cricket::RidDescription; using cricket::RidDirection; diff --git a/pc/sdp_utils.cc b/pc/sdp_utils.cc index b750b04a46..ca61f0013f 100644 --- a/pc/sdp_utils.cc +++ b/pc/sdp_utils.cc @@ -10,8 +10,8 @@ #include "pc/sdp_utils.h" -#include #include +#include #include "api/jsep_session_description.h" #include "rtc_base/checks.h" diff --git a/pc/session_description.cc b/pc/session_description.cc index 7b878cbf7b..c1feedbf53 100644 --- a/pc/session_description.cc +++ b/pc/session_description.cc @@ -10,11 +10,10 @@ #include "pc/session_description.h" -#include - #include "absl/algorithm/container.h" #include "absl/memory/memory.h" #include "rtc_base/checks.h" +#include "rtc_base/strings/string_builder.h" namespace cricket { namespace { diff --git a/pc/session_description.h b/pc/session_description.h index ee7a91c84c..a68c312f42 100644 --- a/pc/session_description.h +++ b/pc/session_description.h @@ -15,9 +15,9 @@ #include #include -#include #include #include +#include #include #include diff --git a/pc/session_description_unittest.cc b/pc/session_description_unittest.cc index 00ce538398..4d0913bad2 100644 --- a/pc/session_description_unittest.cc +++ b/pc/session_description_unittest.cc @@ -9,8 +9,6 @@ */ #include "pc/session_description.h" -#include - #include "test/gtest.h" namespace cricket { diff --git a/pc/srtp_filter.cc b/pc/srtp_filter.cc index c48dfdb4cd..9d7f39a7a3 100644 --- a/pc/srtp_filter.cc +++ b/pc/srtp_filter.cc @@ -11,8 +11,8 @@ #include "pc/srtp_filter.h" #include -#include -#include + +#include #include "absl/strings/match.h" #include "rtc_base/logging.h" diff --git a/pc/srtp_session.cc b/pc/srtp_session.cc index 76ab3a8fe8..a81f2415a5 100644 --- a/pc/srtp_session.cc +++ b/pc/srtp_session.cc @@ -10,12 +10,18 @@ #include "pc/srtp_session.h" +#include + #include +#include #include "absl/base/attributes.h" +#include "absl/base/const_init.h" #include "api/array_view.h" #include "modules/rtp_rtcp/source/rtp_util.h" #include "pc/external_hmac.h" +#include "rtc_base/byte_order.h" +#include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/ssl_stream_adapter.h" #include "rtc_base/string_encode.h" diff --git a/pc/srtp_session.h b/pc/srtp_session.h index f1b6a52b47..d88eaae319 100644 --- a/pc/srtp_session.h +++ b/pc/srtp_session.h @@ -11,6 +11,9 @@ #ifndef PC_SRTP_SESSION_H_ #define PC_SRTP_SESSION_H_ +#include +#include + #include #include "api/scoped_refptr.h" diff --git a/pc/srtp_transport_unittest.cc b/pc/srtp_transport_unittest.cc index 59bc8e8090..980ebca08a 100644 --- a/pc/srtp_transport_unittest.cc +++ b/pc/srtp_transport_unittest.cc @@ -12,8 +12,6 @@ #include -#include -#include #include #include "call/rtp_demuxer.h" @@ -25,6 +23,7 @@ #include "rtc_base/async_packet_socket.h" #include "rtc_base/byte_order.h" #include "rtc_base/checks.h" +#include "rtc_base/containers/flat_set.h" #include "rtc_base/ssl_stream_adapter.h" #include "rtc_base/third_party/sigslot/sigslot.h" #include "test/gtest.h" diff --git a/pc/stats_collector.cc b/pc/stats_collector.cc index 493c26cfbd..6b1cda3ad5 100644 --- a/pc/stats_collector.cc +++ b/pc/stats_collector.cc @@ -13,18 +13,19 @@ #include #include +#include #include -#include +#include #include #include #include +#include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "api/audio_codecs/audio_encoder.h" #include "api/candidate.h" #include "api/data_channel_interface.h" #include "api/media_types.h" -#include "api/rtp_receiver_interface.h" #include "api/rtp_sender_interface.h" #include "api/scoped_refptr.h" #include "api/sequence_checker.h" @@ -39,6 +40,8 @@ #include "pc/channel_interface.h" #include "pc/data_channel_utils.h" #include "pc/rtp_receiver.h" +#include "pc/rtp_receiver_proxy.h" +#include "pc/rtp_sender_proxy.h" #include "pc/rtp_transceiver.h" #include "pc/transport_stats.h" #include "rtc_base/checks.h" diff --git a/pc/stats_collector.h b/pc/stats_collector.h index 71b802dd09..751a2de09c 100644 --- a/pc/stats_collector.h +++ b/pc/stats_collector.h @@ -21,18 +21,24 @@ #include #include #include +#include #include #include +#include "absl/types/optional.h" #include "api/media_stream_interface.h" #include "api/peer_connection_interface.h" +#include "api/scoped_refptr.h" #include "api/stats_types.h" #include "p2p/base/connection_info.h" #include "p2p/base/port.h" #include "pc/peer_connection_internal.h" +#include "pc/rtp_transceiver.h" #include "pc/stats_collector_interface.h" +#include "pc/transport_stats.h" #include "rtc_base/network_constants.h" #include "rtc_base/ssl_certificate.h" +#include "rtc_base/thread_annotations.h" namespace webrtc { diff --git a/pc/stats_collector_unittest.cc b/pc/stats_collector_unittest.cc index 7688ffe727..144ca34b55 100644 --- a/pc/stats_collector_unittest.cc +++ b/pc/stats_collector_unittest.cc @@ -12,7 +12,7 @@ #include -#include +#include #include "absl/algorithm/container.h" #include "absl/types/optional.h" @@ -20,11 +20,16 @@ #include "api/candidate.h" #include "api/data_channel_interface.h" #include "api/media_stream_track.h" +#include "api/media_types.h" +#include "api/rtp_sender_interface.h" #include "api/scoped_refptr.h" #include "call/call.h" #include "media/base/media_channel.h" #include "modules/audio_processing/include/audio_processing_statistics.h" +#include "p2p/base/ice_transport_internal.h" #include "pc/media_stream.h" +#include "pc/rtp_receiver.h" +#include "pc/rtp_sender.h" #include "pc/sctp_data_channel.h" #include "pc/test/fake_peer_connection_for_stats.h" #include "pc/test/fake_video_track_source.h" @@ -43,6 +48,7 @@ #include "rtc_base/string_encode.h" #include "rtc_base/third_party/base64/base64.h" #include "rtc_base/thread.h" +#include "test/gmock.h" #include "test/gtest.h" using cricket::ConnectionInfo; diff --git a/pc/track_media_info_map.cc b/pc/track_media_info_map.cc index e68f2f7a52..12670dda28 100644 --- a/pc/track_media_info_map.cc +++ b/pc/track_media_info_map.cc @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include "api/media_types.h" diff --git a/pc/track_media_info_map_unittest.cc b/pc/track_media_info_map_unittest.cc index a58331f0df..8cf3360c6f 100644 --- a/pc/track_media_info_map_unittest.cc +++ b/pc/track_media_info_map_unittest.cc @@ -10,22 +10,28 @@ #include "pc/track_media_info_map.h" +#include + +#include #include -#include #include +#include #include #include -#include "api/rtp_sender_interface.h" +#include "api/media_types.h" +#include "api/rtp_parameters.h" #include "api/test/mock_video_track.h" -#include "api/transport/rtp/rtp_source.h" #include "media/base/media_channel.h" #include "pc/audio_track.h" #include "pc/test/fake_video_track_source.h" #include "pc/test/mock_rtp_receiver_internal.h" #include "pc/test/mock_rtp_sender_internal.h" #include "pc/video_track.h" -#include "rtc_base/ref_count.h" +#include "rtc_base/checks.h" +#include "rtc_base/ref_counted_object.h" +#include "rtc_base/thread.h" +#include "test/gmock.h" #include "test/gtest.h" namespace webrtc { diff --git a/pc/transceiver_list.cc b/pc/transceiver_list.cc index 235c9af036..139c498634 100644 --- a/pc/transceiver_list.cc +++ b/pc/transceiver_list.cc @@ -10,6 +10,8 @@ #include "pc/transceiver_list.h" +#include + #include "rtc_base/checks.h" namespace webrtc { diff --git a/pc/used_ids_unittest.cc b/pc/used_ids_unittest.cc index af66898450..6362f2773a 100644 --- a/pc/used_ids_unittest.cc +++ b/pc/used_ids_unittest.cc @@ -10,6 +10,7 @@ #include "pc/used_ids.h" +#include "absl/strings/string_view.h" #include "test/gtest.h" using cricket::UsedIds; diff --git a/pc/video_rtp_receiver.cc b/pc/video_rtp_receiver.cc index a428603745..7659d7c2f9 100644 --- a/pc/video_rtp_receiver.cc +++ b/pc/video_rtp_receiver.cc @@ -12,15 +12,16 @@ #include +#include #include #include #include "api/video/recordable_encoded_frame.h" -#include "api/video_track_source_proxy_factory.h" #include "pc/video_track.h" #include "rtc_base/checks.h" #include "rtc_base/location.h" #include "rtc_base/logging.h" +#include "rtc_base/ref_counted_object.h" namespace webrtc { diff --git a/pc/video_rtp_receiver_unittest.cc b/pc/video_rtp_receiver_unittest.cc index 56aa3688a8..c13214fcbb 100644 --- a/pc/video_rtp_receiver_unittest.cc +++ b/pc/video_rtp_receiver_unittest.cc @@ -10,11 +10,17 @@ #include "pc/video_rtp_receiver.h" +#include #include +#include "api/task_queue/task_queue_base.h" +#include "api/video/recordable_encoded_frame.h" #include "api/video/test/mock_recordable_encoded_frame.h" #include "media/base/fake_media_engine.h" +#include "rtc_base/location.h" +#include "rtc_base/ref_counted_object.h" #include "test/gmock.h" +#include "test/gtest.h" using ::testing::_; using ::testing::AnyNumber; diff --git a/pc/video_rtp_track_source_unittest.cc b/pc/video_rtp_track_source_unittest.cc index 5666b77d5f..bb1dc193de 100644 --- a/pc/video_rtp_track_source_unittest.cc +++ b/pc/video_rtp_track_source_unittest.cc @@ -10,6 +10,12 @@ #include "pc/video_rtp_track_source.h" +#include "absl/types/optional.h" +#include "api/scoped_refptr.h" +#include "api/units/timestamp.h" +#include "api/video/color_space.h" +#include "api/video/encoded_image.h" +#include "api/video/video_codec_type.h" #include "rtc_base/ref_counted_object.h" #include "test/gmock.h" #include "test/gtest.h" diff --git a/pc/video_track.cc b/pc/video_track.cc index 4559181ce7..744800c9f3 100644 --- a/pc/video_track.cc +++ b/pc/video_track.cc @@ -10,7 +10,6 @@ #include "pc/video_track.h" -#include #include #include @@ -18,7 +17,6 @@ #include "api/sequence_checker.h" #include "rtc_base/checks.h" #include "rtc_base/location.h" -#include "rtc_base/logging.h" #include "rtc_base/ref_counted_object.h" namespace webrtc { diff --git a/pc/video_track.h b/pc/video_track.h index 66262d22d1..f938b3362c 100644 --- a/pc/video_track.h +++ b/pc/video_track.h @@ -13,6 +13,7 @@ #include +#include "absl/types/optional.h" #include "api/media_stream_interface.h" #include "api/media_stream_track.h" #include "api/scoped_refptr.h" @@ -21,8 +22,8 @@ #include "api/video/video_sink_interface.h" #include "api/video/video_source_interface.h" #include "media/base/video_source_base.h" -#include "rtc_base/system/no_unique_address.h" #include "pc/video_track_source_proxy.h" +#include "rtc_base/system/no_unique_address.h" #include "rtc_base/thread.h" #include "rtc_base/thread_annotations.h" diff --git a/pc/video_track_source.h b/pc/video_track_source.h index 3f568f642b..723b10d8f3 100644 --- a/pc/video_track_source.h +++ b/pc/video_track_source.h @@ -20,8 +20,10 @@ #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" namespace webrtc { diff --git a/pc/video_track_source_proxy.cc b/pc/video_track_source_proxy.cc index 309c1f20f8..26f0ecec98 100644 --- a/pc/video_track_source_proxy.cc +++ b/pc/video_track_source_proxy.cc @@ -11,7 +11,9 @@ #include "pc/video_track_source_proxy.h" #include "api/media_stream_interface.h" +#include "api/scoped_refptr.h" #include "api/video_track_source_proxy_factory.h" +#include "rtc_base/thread.h" namespace webrtc { diff --git a/pc/video_track_source_proxy.h b/pc/video_track_source_proxy.h index 1f6d976ba8..8500a98766 100644 --- a/pc/video_track_source_proxy.h +++ b/pc/video_track_source_proxy.h @@ -11,7 +11,13 @@ #ifndef PC_VIDEO_TRACK_SOURCE_PROXY_H_ #define PC_VIDEO_TRACK_SOURCE_PROXY_H_ +#include "absl/types/optional.h" #include "api/media_stream_interface.h" +#include "api/video/recordable_encoded_frame.h" +#include "api/video/video_frame.h" +#include "api/video/video_sink_interface.h" +#include "api/video/video_source_interface.h" +#include "api/video_track_source_constraints.h" #include "pc/proxy.h" namespace webrtc { @@ -21,6 +27,7 @@ namespace webrtc { // TODO(deadbeef): Move this to .cc file. What threads methods are called on is // an implementation detail. BEGIN_PROXY_MAP(VideoTrackSource) + PROXY_PRIMARY_THREAD_DESTRUCTOR() PROXY_CONSTMETHOD0(SourceState, state) BYPASS_PROXY_CONSTMETHOD0(bool, remote) diff --git a/pc/video_track_unittest.cc b/pc/video_track_unittest.cc index e6dcce7939..2a10c93f7b 100644 --- a/pc/video_track_unittest.cc +++ b/pc/video_track_unittest.cc @@ -13,11 +13,11 @@ #include #include "media/base/fake_frame_source.h" -#include "media/base/video_common.h" #include "pc/test/fake_video_track_renderer.h" #include "pc/test/fake_video_track_source.h" #include "pc/video_track_source.h" #include "rtc_base/ref_counted_object.h" +#include "rtc_base/time_utils.h" #include "test/gtest.h" using webrtc::FakeVideoTrackRenderer; diff --git a/pc/webrtc_sdp.cc b/pc/webrtc_sdp.cc index 3f06f307a4..ea7a148fe1 100644 --- a/pc/webrtc_sdp.cc +++ b/pc/webrtc_sdp.cc @@ -12,9 +12,9 @@ #include #include -#include #include +#include #include #include #include @@ -31,6 +31,7 @@ #include "api/jsep_session_description.h" #include "api/media_types.h" // for RtpExtension +#include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "api/rtc_error.h" #include "api/rtp_parameters.h" diff --git a/pc/webrtc_sdp_unittest.cc b/pc/webrtc_sdp_unittest.cc index 21d682315e..ea1b07d06a 100644 --- a/pc/webrtc_sdp_unittest.cc +++ b/pc/webrtc_sdp_unittest.cc @@ -11,10 +11,10 @@ #include #include -#include #include #include #include +#include #include #include #include @@ -22,21 +22,26 @@ #include "absl/algorithm/container.h" #include "absl/memory/memory.h" #include "absl/strings/str_replace.h" +#include "absl/strings/string_view.h" +#include "absl/types/optional.h" #include "api/array_view.h" #include "api/crypto_params.h" #include "api/jsep_session_description.h" #include "api/media_types.h" #include "api/rtp_parameters.h" -#include "api/rtp_transceiver_interface.h" +#include "api/rtp_transceiver_direction.h" #include "media/base/codec.h" #include "media/base/media_constants.h" +#include "media/base/rid_description.h" #include "media/base/stream_params.h" #include "p2p/base/p2p_constants.h" #include "p2p/base/port.h" #include "p2p/base/transport_description.h" #include "p2p/base/transport_info.h" +#include "pc/media_protocol_names.h" #include "pc/media_session.h" #include "pc/session_description.h" +#include "pc/simulcast_description.h" #include "rtc_base/checks.h" #include "rtc_base/message_digest.h" #include "rtc_base/socket_address.h" diff --git a/pc/webrtc_session_description_factory.cc b/pc/webrtc_session_description_factory.cc index 36130758a3..82ba849544 100644 --- a/pc/webrtc_session_description_factory.cc +++ b/pc/webrtc_session_description_factory.cc @@ -11,8 +11,8 @@ #include "pc/webrtc_session_description_factory.h" #include -#include -#include + +#include #include #include #include @@ -23,6 +23,7 @@ #include "api/jsep.h" #include "api/jsep_session_description.h" #include "api/rtc_error.h" +#include "api/sequence_checker.h" #include "pc/sdp_state_provider.h" #include "pc/session_description.h" #include "rtc_base/checks.h" @@ -32,6 +33,7 @@ #include "rtc_base/ssl_identity.h" #include "rtc_base/ssl_stream_adapter.h" #include "rtc_base/string_encode.h" +#include "rtc_base/unique_id_generator.h" using cricket::MediaSessionOptions; using rtc::UniqueRandomIdGenerator; diff --git a/tools_webrtc/iwyu/apply-iwyu b/tools_webrtc/iwyu/apply-iwyu index e7d5021950..7f2809b769 100755 --- a/tools_webrtc/iwyu/apply-iwyu +++ b/tools_webrtc/iwyu/apply-iwyu @@ -17,7 +17,7 @@ # Set this to 1 to get more debug information. # Set this to 2 to also get a dump of the iwyu tool output. -DEBUG=1 +DEBUG=2 set -e if [ $DEBUG -gt 0 ]; then @@ -26,6 +26,7 @@ fi IWYU_TOOL="${IWYU_TOOL:-/usr/bin/iwyu_tool}" FIX_INCLUDE="${FIX_INCLUDE:-/usr/bin/fix_include}" +IWYU_TOOL_DIR="${IWYU_TOOL_DIR:-tools_webrtc/iwyu}" COMPILE_COMMANDS='' error() { @@ -68,6 +69,7 @@ fi # IWYU has a confusing set of exit codes. Discard it. "$IWYU_TOOL" -p "$COMPILE_COMMANDS" "$FILE_CC" -- -Xiwyu --no_fwd_decls \ + -Xiwyu --mapping_file=../../$IWYU_TOOL_DIR/mappings.imp \ >& /tmp/includefixes$$ || echo "IWYU done, code $?" if grep 'fatal error' /tmp/includefixes$$; then diff --git a/tools_webrtc/iwyu/iwyu-filter-list b/tools_webrtc/iwyu/iwyu-filter-list index 2332cd3d61..b5b0fb0721 100644 --- a/tools_webrtc/iwyu/iwyu-filter-list +++ b/tools_webrtc/iwyu/iwyu-filter-list @@ -6,3 +6,4 @@ #include #include <__memory/unique_ptr.h> #include <__tree> +#include diff --git a/tools_webrtc/iwyu/mappings.imp b/tools_webrtc/iwyu/mappings.imp new file mode 100644 index 0000000000..aa19c2b4c2 --- /dev/null +++ b/tools_webrtc/iwyu/mappings.imp @@ -0,0 +1,32 @@ +# +# Mappings file for IWYU in webrtc +# +# Documentation of syntax: +# https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/IWYUMappings.md +# +# Remember that it needs include strings INCLUDING <> or "" inside the quotes. +# +[ +# Redirect to have gmock and gtest includes under our control +{ include: ['"gmock/gmock.h"', "private", '"test/gmock.h"', "public"] }, +{ include: ['"gtest/gtest.h"', "private", '"test/gtest.h"', "public"] }, + +# rtc_base/containers internal defs +{ include: ['"rtc_base/containers/flat_tree.h"', "private", '"rtc_base/containers/flat_set.h"', "public"] }, + +# Revectoring of JSON +{ include: ['"json/reader.h"', "private", '"rtc_base/strings/json.h"', "public"] }, +{ include: ['"json/value.h"', "private", '"rtc_base/strings/json.h"', "public"] }, + +# LIBSRTP overrides +{ include: ['"rdbx.h"', "private", '"third_party/libsrtp/include/srtp_priv.h"', "public"] }, +{ include: ['"auth.h"', "private", '"third_party/libsrtp/include/srtp_priv.h"', "public"] }, + +# Needed to agree with presubmit tests for includes (and not include ) +{ symbol: ["std::string", "public", "", "public"] }, +{ symbol: ["std::move", "public", "", "public"] }, +{ symbol: ["std::make_unique", "public", "", "public"] }, +{ symbol: ["std::unique_ptr", "public", "", "public"] }, +# Needed to avoid +{ symbol: ["std::ostringstream", "public", "", "public"] }, +] \ No newline at end of file From caf2063a9e8afbdec9af767395bbe74e69237ae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Terelius?= Date: Thu, 24 Feb 2022 12:15:25 +0100 Subject: [PATCH 039/847] Roll chromium_revision 47fab10a5d..b4562c8dc8 (974582:974583) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The third_party/android_deps/libs/org_robolectric_shadows_multidex dependency had to be moved manually. Change log: https://chromium.googlesource.com/chromium/src/+log/47fab10a5d..b4562c8dc8 Full diff: https://chromium.googlesource.com/chromium/src/+/47fab10a5d..b4562c8dc8 Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/1ccd6b651d..187616c5fc * src/build: https://chromium.googlesource.com/chromium/src/build/+log/e3b729952d..bcfb6fca6d * src/buildtools: https://chromium.googlesource.com/chromium/src/buildtools/+log/93c15529c3..893aa038dd * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/469142ebf2..4eaa194b8b * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/bede1d9398..629e78f5b3 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/0c497a1ac6..d2f57fb779 * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/8f3c4ef866..08a8050c47 * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/306b03b191..2c668c866d * src/third_party/freetype/src: https://chromium.googlesource.com/chromium/src/third_party/freetype2.git/+log/bcdfa38692..034e5dbf92 * src/third_party/icu: https://chromium.googlesource.com/chromium/deps/icu.git/+log/b867f209e4..901474b180 * src/third_party/robolectric: Kdd6dNFAKqj9g9Bsfo2z1zQr52Vk60EL_wb9Bf2c8rcC..FihBToFLI9o7fW09ZtQ_5YruQy6sDWMo1Pv0g97eAxEC * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/01862032d8..bc929d3e94 DEPS diff: https://chromium.googlesource.com/chromium/src/+/47fab10a5d..b4562c8dc8/DEPS No update to Clang. BUG=chromium:1184780 Change-Id: If302a3bec96f4b94d320d611e6cdb163305c591e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252420 Auto-Submit: Björn Terelius Reviewed-by: Mirko Bonadei Commit-Queue: Mirko Bonadei Cr-Commit-Position: refs/heads/main@{#36065} --- DEPS | 340 ++++++++--------------------------------------------------- 1 file changed, 42 insertions(+), 298 deletions(-) diff --git a/DEPS b/DEPS index bd0073f459..12fda9d1c0 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': '0b2f63dc4b44dd325cbd0ef09553b411f2ecf71d', + 'chromium_revision': 'b4562c8dc867d02eac53a1cacfa8c01dcce85ec4', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,24 +23,24 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@1ccd6b651d26656f0640bfd1f92ac6a7bc0ed050', + 'https://chromium.googlesource.com/chromium/src/base@187616c5fc42d8f190b3931eacffb7223e83f262', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@e3b729952de607b9f3d522053dc657a2f0d2b7fb', + 'https://chromium.googlesource.com/chromium/src/build@bcfb6fca6d9c1747faa96854e0e124deef6b458b', 'src/buildtools': - 'https://chromium.googlesource.com/chromium/src/buildtools@93c15529c323c6cc12516ef9caac7fd815ee7c82', + 'https://chromium.googlesource.com/chromium/src/buildtools@893aa038dd17d05f3c5ff5af98daebabc294a948', # 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@469142ebf2d30e46538330cba8734971e11ea520', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@4eaa194b8b3c40af0f810417816f02bac7269b81', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@bede1d93986afb8ca46431bb50b6b2ec2a461d2a', + 'https://chromium.googlesource.com/chromium/src/testing@629e78f5b3d5bf879409c9624095078d312be446', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@0c497a1ac6f7a99ffca2095023fee71bf12183c8', + 'https://chromium.googlesource.com/chromium/src/third_party@d2f57fb7795d3a9a59d98d3ce82898af35fbca75', 'src/buildtools/linux64': { 'packages': [ @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@8f3c4ef86630d09ba69e3e6dd35553791cfa6b1e', + 'https://chromium.googlesource.com/catapult.git@08a8050c47dc376c85ba2bda2ec4db2e1f7ea961', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@306b03b1912affcae0dbecbe5aa36b414fb4ae2a', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@2c668c866d8678edbff7d10f99c03e82140242ec', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -162,7 +162,7 @@ deps = { 'condition': 'checkout_linux', }, 'src/third_party/freetype/src': - 'https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@bcdfa38692d590dda5bc9e4334842abe92ec0ba5', + 'https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@034e5dbf92ea3a7ea7c9322e47a3a50ff23f7b55', 'src/third_party/harfbuzz-ng/src': 'https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git@0acf466c44143de2e9b9cc0375cb25ec67cb132f', 'src/third_party/google_benchmark/src': { @@ -184,7 +184,7 @@ deps = { 'src/third_party/googletest/src': 'https://chromium.googlesource.com/external/github.com/google/googletest.git@c9461a9b55ba954df0489bab6420eb297bed846b', 'src/third_party/icu': { - 'url': 'https://chromium.googlesource.com/chromium/deps/icu.git@b867f209e4b56b0a8c01aaaba3882ad41e438c4f', + 'url': 'https://chromium.googlesource.com/chromium/deps/icu.git@901474b1806d6b5a068606006dbb4c08e9974353', }, 'src/third_party/jdk': { 'packages': [ @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@01862032d809eff27a0b83832d8b79b943005c2c', + 'https://chromium.googlesource.com/chromium/src/tools@bc929d3e944c8dbe7d849a1de5aeb0141cd7fabc', 'src/third_party/accessibility_test_framework': { 'packages': [ @@ -456,7 +456,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/robolectric', - 'version': 'Kdd6dNFAKqj9g9Bsfo2z1zQr52Vk60EL_wb9Bf2c8rcC', + 'version': 'FihBToFLI9o7fW09ZtQ_5YruQy6sDWMo1Pv0g97eAxEC', }, ], 'condition': 'checkout_android', @@ -499,20 +499,6 @@ deps = { 'dep_type': 'cipd', }, - # TODO(crbug.com/1184780) Move this back to ANDROID_DEPS Generated Code - # section once org_robolectric_shadows_multidex is updated to a new version - # that does not need jetify. - 'src/third_party/android_deps/libs/org_robolectric_shadows_multidex': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_robolectric_shadows_multidex', - 'version': 'version:4.3.1-cr1', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - # Everything coming after this is automatically updated by the auto-roller. # === ANDROID_DEPS Generated Code Start === # Generated by //third_party/android_deps/fetch_all.py @@ -604,28 +590,6 @@ deps = { 'dep_type': 'cipd', }, - 'src/third_party/android_deps/libs/backport_util_concurrent_backport_util_concurrent': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/backport_util_concurrent_backport_util_concurrent', - 'version': 'version:2@3.1.cr0', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/libs/classworlds_classworlds': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/classworlds_classworlds', - 'version': 'version:2@1.1-alpha-2.cr0', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - 'src/third_party/android_deps/libs/com_android_support_animated_vector_drawable': { 'packages': [ { @@ -1334,7 +1298,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_auto_value_auto_value_annotations', - 'version': 'version:2@1.7.cr0', + 'version': 'version:2@1.7.4.cr0', }, ], 'condition': 'checkout_android', @@ -1792,28 +1756,6 @@ deps = { 'dep_type': 'cipd', }, - 'src/third_party/android_deps/libs/nekohtml_nekohtml': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/nekohtml_nekohtml', - 'version': 'version:2@1.9.6.2.cr0', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/libs/nekohtml_xercesminimal': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/nekohtml_xercesminimal', - 'version': 'version:2@1.9.6.2.cr0', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - 'src/third_party/android_deps/libs/net_ltgt_gradle_incap_incap': { 'packages': [ { @@ -1836,182 +1778,6 @@ deps = { 'dep_type': 'cipd', }, - 'src/third_party/android_deps/libs/org_apache_ant_ant': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_apache_ant_ant', - 'version': 'version:2@1.8.0.cr0', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/libs/org_apache_ant_ant_launcher': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_apache_ant_ant_launcher', - 'version': 'version:2@1.8.0.cr0', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/libs/org_apache_maven_maven_ant_tasks': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_apache_maven_maven_ant_tasks', - 'version': 'version:2@2.1.3.cr0', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/libs/org_apache_maven_maven_artifact': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_apache_maven_maven_artifact', - 'version': 'version:2@2.2.1.cr0', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/libs/org_apache_maven_maven_artifact_manager': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_apache_maven_maven_artifact_manager', - 'version': 'version:2@2.2.1.cr0', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/libs/org_apache_maven_maven_error_diagnostics': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_apache_maven_maven_error_diagnostics', - 'version': 'version:2@2.2.1.cr0', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/libs/org_apache_maven_maven_model': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_apache_maven_maven_model', - 'version': 'version:2@2.2.1.cr0', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/libs/org_apache_maven_maven_plugin_registry': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_apache_maven_maven_plugin_registry', - 'version': 'version:2@2.2.1.cr0', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/libs/org_apache_maven_maven_profile': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_apache_maven_maven_profile', - 'version': 'version:2@2.2.1.cr0', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/libs/org_apache_maven_maven_project': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_apache_maven_maven_project', - 'version': 'version:2@2.2.1.cr0', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/libs/org_apache_maven_maven_repository_metadata': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_apache_maven_maven_repository_metadata', - 'version': 'version:2@2.2.1.cr0', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/libs/org_apache_maven_maven_settings': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_apache_maven_maven_settings', - 'version': 'version:2@2.2.1.cr0', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/libs/org_apache_maven_wagon_wagon_file': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_apache_maven_wagon_wagon_file', - 'version': 'version:2@1.0-beta-6.cr0', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/libs/org_apache_maven_wagon_wagon_http_lightweight': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_apache_maven_wagon_wagon_http_lightweight', - 'version': 'version:2@1.0-beta-6.cr0', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/libs/org_apache_maven_wagon_wagon_http_shared': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_apache_maven_wagon_wagon_http_shared', - 'version': 'version:2@1.0-beta-6.cr0', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/libs/org_apache_maven_wagon_wagon_provider_api': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_apache_maven_wagon_wagon_provider_api', - 'version': 'version:2@1.0-beta-6.cr0', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - 'src/third_party/android_deps/libs/org_ccil_cowan_tagsoup_tagsoup': { 'packages': [ { @@ -2067,39 +1833,6 @@ deps = { 'dep_type': 'cipd', }, - 'src/third_party/android_deps/libs/org_codehaus_plexus_plexus_container_default': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_codehaus_plexus_plexus_container_default', - 'version': 'version:2@1.0-alpha-9-stable-1.cr0', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/libs/org_codehaus_plexus_plexus_interpolation': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_codehaus_plexus_plexus_interpolation', - 'version': 'version:2@1.11.cr0', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/libs/org_codehaus_plexus_plexus_utils': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/org_codehaus_plexus_plexus_utils', - 'version': 'version:2@1.5.15.cr0', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - 'src/third_party/android_deps/libs/org_eclipse_jgit_org_eclipse_jgit': { 'packages': [ { @@ -2203,7 +1936,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_ow2_asm_asm', - 'version': 'version:2@7.0.cr0', + 'version': 'version:2@9.0.cr0', }, ], 'condition': 'checkout_android', @@ -2214,7 +1947,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_ow2_asm_asm_analysis', - 'version': 'version:2@7.0.cr0', + 'version': 'version:2@9.0.cr0', }, ], 'condition': 'checkout_android', @@ -2225,7 +1958,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_ow2_asm_asm_commons', - 'version': 'version:2@7.0.cr0', + 'version': 'version:2@9.0.cr0', }, ], 'condition': 'checkout_android', @@ -2236,7 +1969,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_ow2_asm_asm_tree', - 'version': 'version:2@7.0.cr0', + 'version': 'version:2@9.0.cr0', }, ], 'condition': 'checkout_android', @@ -2247,7 +1980,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_ow2_asm_asm_util', - 'version': 'version:2@7.0.cr0', + 'version': 'version:2@9.0.cr0', }, ], 'condition': 'checkout_android', @@ -2269,7 +2002,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_annotations', - 'version': 'version:2@4.3.1.cr0', + 'version': 'version:2@4.6.1.cr0', }, ], 'condition': 'checkout_android', @@ -2280,7 +2013,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_junit', - 'version': 'version:2@4.3.1.cr0', + 'version': 'version:2@4.6.1.cr0', }, ], 'condition': 'checkout_android', @@ -2291,7 +2024,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_pluginapi', - 'version': 'version:2@4.3.1.cr0', + 'version': 'version:2@4.6.1.cr0', }, ], 'condition': 'checkout_android', @@ -2302,7 +2035,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_plugins_maven_dependency_resolver', - 'version': 'version:2@4.3.1.cr0', + 'version': 'version:2@4.6.1.cr0', }, ], 'condition': 'checkout_android', @@ -2313,7 +2046,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_resources', - 'version': 'version:2@4.3.1.cr0', + 'version': 'version:2@4.6.1.cr0', }, ], 'condition': 'checkout_android', @@ -2324,7 +2057,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_robolectric', - 'version': 'version:2@4.3.1.cr0', + 'version': 'version:2@4.6.1.cr0', }, ], 'condition': 'checkout_android', @@ -2335,7 +2068,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_sandbox', - 'version': 'version:2@4.3.1.cr0', + 'version': 'version:2@4.6.1.cr0', }, ], 'condition': 'checkout_android', @@ -2346,7 +2079,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_shadowapi', - 'version': 'version:2@4.3.1.cr0', + 'version': 'version:2@4.6.1.cr0', }, ], 'condition': 'checkout_android', @@ -2357,7 +2090,18 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_shadows_framework', - 'version': 'version:2@4.3.1.cr0', + 'version': 'version:2@4.6.1.cr0', + }, + ], + 'condition': 'checkout_android', + 'dep_type': 'cipd', + }, + + 'src/third_party/android_deps/libs/org_robolectric_shadows_multidex': { + 'packages': [ + { + 'package': 'chromium/third_party/android_deps/libs/org_robolectric_shadows_multidex', + 'version': 'version:2@4.6.1.cr1', }, ], 'condition': 'checkout_android', @@ -2368,7 +2112,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_shadows_playservices', - 'version': 'version:2@4.3.1.cr0', + 'version': 'version:2@4.6.1.cr0', }, ], 'condition': 'checkout_android', @@ -2379,7 +2123,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_utils', - 'version': 'version:2@4.3.1.cr0', + 'version': 'version:2@4.6.1.cr0', }, ], 'condition': 'checkout_android', @@ -2390,7 +2134,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_utils_reflector', - 'version': 'version:2@4.3.1.cr0', + 'version': 'version:2@4.6.1.cr0', }, ], 'condition': 'checkout_android', From 7a992e21b9c3ff03aa34488a9c91fa580ca4faa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Terelius?= Date: Thu, 24 Feb 2022 13:34:45 +0100 Subject: [PATCH 040/847] Reland "Refactor AnalyzerConfig to use Timestamps instead of microseconds." MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a reland of 43fb16921b29ecd3a2d87876dda75c575e05f66a Original change's description: > Refactor AnalyzerConfig to use Timestamps instead of microseconds. > > Add optional offset-to-UTC parameter to output. This allows aligning > the x-axis in the generated charts to other UTC-based logs. > > Bug: b/215140373 > Change-Id: I65bcd295718acbb8c94e363907c1abc458067bfd > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/250203 > Reviewed-by: Kristoffer Erlandsson > Commit-Queue: Björn Terelius > Cr-Commit-Position: refs/heads/main@{#35992} Bug: b/215140373 Change-Id: Id2b88cc4b8078a97275d49a617581cbbd02d2c6f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252380 Reviewed-by: Kristoffer Erlandsson Commit-Queue: Björn Terelius Cr-Commit-Position: refs/heads/main@{#36066} --- .../rtc_event_log/events/logged_rtp_rtcp.h | 16 ++ .../events/rtc_event_alr_state.h | 1 + .../rtc_event_audio_network_adaptation.h | 1 + .../events/rtc_event_audio_playout.h | 1 + .../rtc_event_audio_receive_stream_config.h | 1 + .../rtc_event_audio_send_stream_config.h | 1 + .../events/rtc_event_begin_log.h | 1 + .../events/rtc_event_bwe_update_delay_based.h | 1 + .../events/rtc_event_bwe_update_loss_based.h | 1 + .../events/rtc_event_dtls_transport_state.h | 1 + .../events/rtc_event_dtls_writable_state.h | 1 + .../rtc_event_log/events/rtc_event_end_log.h | 1 + .../events/rtc_event_frame_decoded.h | 1 + .../events/rtc_event_generic_ack_received.h | 1 + .../rtc_event_generic_packet_received.h | 1 + .../events/rtc_event_generic_packet_sent.h | 1 + .../events/rtc_event_ice_candidate_pair.h | 1 + .../rtc_event_ice_candidate_pair_config.h | 1 + .../events/rtc_event_probe_cluster_created.h | 1 + .../events/rtc_event_probe_result_failure.h | 1 + .../events/rtc_event_probe_result_success.h | 1 + .../events/rtc_event_remote_estimate.h | 1 + .../events/rtc_event_route_change.h | 1 + .../rtc_event_video_receive_stream_config.h | 1 + .../rtc_event_video_send_stream_config.h | 1 + logging/rtc_event_log/rtc_event_log_parser.cc | 24 +-- logging/rtc_event_log/rtc_event_log_parser.h | 8 +- .../rtc_event_log/rtc_event_log_unittest.cc | 4 +- rtc_tools/rtc_event_log_visualizer/alerts.cc | 18 ++- .../rtc_event_log_visualizer/analyze_audio.cc | 22 +-- .../rtc_event_log_visualizer/analyzer.cc | 149 +++++++++--------- .../analyzer_common.h | 42 +++-- rtc_tools/rtc_event_log_visualizer/main.cc | 9 +- .../rtc_event_log_visualizer/plot_base.cc | 6 +- .../rtc_event_log_visualizer/plot_base.h | 6 + .../proto/chart.proto | 4 + 36 files changed, 203 insertions(+), 129 deletions(-) diff --git a/logging/rtc_event_log/events/logged_rtp_rtcp.h b/logging/rtc_event_log/events/logged_rtp_rtcp.h index 179d70dd63..053a16371d 100644 --- a/logging/rtc_event_log/events/logged_rtp_rtcp.h +++ b/logging/rtc_event_log/events/logged_rtp_rtcp.h @@ -41,6 +41,7 @@ struct LoggedRtpPacket { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp; // TODO(terelius): This allocates space for 15 CSRCs even if none are used. @@ -57,6 +58,7 @@ struct LoggedRtpPacketIncoming { : rtp(timestamp, header, header_length, total_length) {} int64_t log_time_us() const { return rtp.timestamp.us(); } int64_t log_time_ms() const { return rtp.timestamp.ms(); } + Timestamp log_time() const { return rtp.timestamp; } LoggedRtpPacket rtp; }; @@ -69,6 +71,7 @@ struct LoggedRtpPacketOutgoing { : rtp(timestamp, header, header_length, total_length) {} int64_t log_time_us() const { return rtp.timestamp.us(); } int64_t log_time_ms() const { return rtp.timestamp.ms(); } + Timestamp log_time() const { return rtp.timestamp; } LoggedRtpPacket rtp; }; @@ -87,6 +90,7 @@ struct LoggedRtcpPacket { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp; std::vector raw_data; @@ -101,6 +105,7 @@ struct LoggedRtcpPacketIncoming { int64_t log_time_us() const { return rtcp.timestamp.us(); } int64_t log_time_ms() const { return rtcp.timestamp.ms(); } + Timestamp log_time() const { return rtcp.timestamp; } LoggedRtcpPacket rtcp; }; @@ -114,6 +119,7 @@ struct LoggedRtcpPacketOutgoing { int64_t log_time_us() const { return rtcp.timestamp.us(); } int64_t log_time_ms() const { return rtcp.timestamp.ms(); } + Timestamp log_time() const { return rtcp.timestamp; } LoggedRtcpPacket rtcp; }; @@ -126,6 +132,7 @@ struct LoggedRtcpPacketReceiverReport { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::ReceiverReport rr; @@ -139,6 +146,7 @@ struct LoggedRtcpPacketSenderReport { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::SenderReport sr; @@ -149,6 +157,7 @@ struct LoggedRtcpPacketExtendedReports { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::ExtendedReports xr; @@ -161,6 +170,7 @@ struct LoggedRtcpPacketRemb { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::Remb remb; @@ -173,6 +183,7 @@ struct LoggedRtcpPacketNack { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::Nack nack; @@ -183,6 +194,7 @@ struct LoggedRtcpPacketFir { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::Fir fir; @@ -193,6 +205,7 @@ struct LoggedRtcpPacketPli { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::Pli pli; @@ -209,6 +222,7 @@ struct LoggedRtcpPacketTransportFeedback { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::TransportFeedback transport_feedback; @@ -223,6 +237,7 @@ struct LoggedRtcpPacketLossNotification { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::LossNotification loss_notification; @@ -233,6 +248,7 @@ struct LoggedRtcpPacketBye { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::Bye bye; diff --git a/logging/rtc_event_log/events/rtc_event_alr_state.h b/logging/rtc_event_log/events/rtc_event_alr_state.h index 44e68a680e..9f595ecd90 100644 --- a/logging/rtc_event_log/events/rtc_event_alr_state.h +++ b/logging/rtc_event_log/events/rtc_event_alr_state.h @@ -32,6 +32,7 @@ struct LoggedAlrStateEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); bool in_alr; diff --git a/logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h b/logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h index b9e919c2e8..d4cae3abfa 100644 --- a/logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h +++ b/logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h @@ -31,6 +31,7 @@ struct LoggedAudioNetworkAdaptationEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); AudioEncoderRuntimeConfig config; diff --git a/logging/rtc_event_log/events/rtc_event_audio_playout.h b/logging/rtc_event_log/events/rtc_event_audio_playout.h index 3788324d15..196c3ca247 100644 --- a/logging/rtc_event_log/events/rtc_event_audio_playout.h +++ b/logging/rtc_event_log/events/rtc_event_audio_playout.h @@ -32,6 +32,7 @@ struct LoggedAudioPlayoutEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); uint32_t ssrc; diff --git a/logging/rtc_event_log/events/rtc_event_audio_receive_stream_config.h b/logging/rtc_event_log/events/rtc_event_audio_receive_stream_config.h index ac8813c937..9863e235af 100644 --- a/logging/rtc_event_log/events/rtc_event_audio_receive_stream_config.h +++ b/logging/rtc_event_log/events/rtc_event_audio_receive_stream_config.h @@ -30,6 +30,7 @@ struct LoggedAudioRecvConfig { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtclog::StreamConfig config; diff --git a/logging/rtc_event_log/events/rtc_event_audio_send_stream_config.h b/logging/rtc_event_log/events/rtc_event_audio_send_stream_config.h index 8b699e71cf..550723bcf0 100644 --- a/logging/rtc_event_log/events/rtc_event_audio_send_stream_config.h +++ b/logging/rtc_event_log/events/rtc_event_audio_send_stream_config.h @@ -29,6 +29,7 @@ struct LoggedAudioSendConfig { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtclog::StreamConfig config; diff --git a/logging/rtc_event_log/events/rtc_event_begin_log.h b/logging/rtc_event_log/events/rtc_event_begin_log.h index 8dc47b5a02..f3b74c117e 100644 --- a/logging/rtc_event_log/events/rtc_event_begin_log.h +++ b/logging/rtc_event_log/events/rtc_event_begin_log.h @@ -35,6 +35,7 @@ struct LoggedStartEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp utc_time() const { return utc_start_time; } diff --git a/logging/rtc_event_log/events/rtc_event_bwe_update_delay_based.h b/logging/rtc_event_log/events/rtc_event_bwe_update_delay_based.h index 4f145de412..796f119388 100644 --- a/logging/rtc_event_log/events/rtc_event_bwe_update_delay_based.h +++ b/logging/rtc_event_log/events/rtc_event_bwe_update_delay_based.h @@ -76,6 +76,7 @@ struct LoggedBweDelayBasedUpdate { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); int32_t bitrate_bps; diff --git a/logging/rtc_event_log/events/rtc_event_bwe_update_loss_based.h b/logging/rtc_event_log/events/rtc_event_bwe_update_loss_based.h index 1caf818a0c..fd41b316e0 100644 --- a/logging/rtc_event_log/events/rtc_event_bwe_update_loss_based.h +++ b/logging/rtc_event_log/events/rtc_event_bwe_update_loss_based.h @@ -37,6 +37,7 @@ struct LoggedBweLossBasedUpdate { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); int32_t bitrate_bps; diff --git a/logging/rtc_event_log/events/rtc_event_dtls_transport_state.h b/logging/rtc_event_log/events/rtc_event_dtls_transport_state.h index c2496dd532..b9af213256 100644 --- a/logging/rtc_event_log/events/rtc_event_dtls_transport_state.h +++ b/logging/rtc_event_log/events/rtc_event_dtls_transport_state.h @@ -26,6 +26,7 @@ namespace webrtc { struct LoggedDtlsTransportState { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); DtlsTransportState dtls_transport_state; diff --git a/logging/rtc_event_log/events/rtc_event_dtls_writable_state.h b/logging/rtc_event_log/events/rtc_event_dtls_writable_state.h index 20221df9da..c820f184d7 100644 --- a/logging/rtc_event_log/events/rtc_event_dtls_writable_state.h +++ b/logging/rtc_event_log/events/rtc_event_dtls_writable_state.h @@ -28,6 +28,7 @@ struct LoggedDtlsWritableState { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); bool writable; diff --git a/logging/rtc_event_log/events/rtc_event_end_log.h b/logging/rtc_event_log/events/rtc_event_end_log.h index ed7770f339..79648bdb8d 100644 --- a/logging/rtc_event_log/events/rtc_event_end_log.h +++ b/logging/rtc_event_log/events/rtc_event_end_log.h @@ -32,6 +32,7 @@ struct LoggedStopEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::PlusInfinity(); }; diff --git a/logging/rtc_event_log/events/rtc_event_frame_decoded.h b/logging/rtc_event_log/events/rtc_event_frame_decoded.h index db5162cd0d..91190faea9 100644 --- a/logging/rtc_event_log/events/rtc_event_frame_decoded.h +++ b/logging/rtc_event_log/events/rtc_event_frame_decoded.h @@ -29,6 +29,7 @@ namespace webrtc { struct LoggedFrameDecoded { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); int64_t render_time_ms; diff --git a/logging/rtc_event_log/events/rtc_event_generic_ack_received.h b/logging/rtc_event_log/events/rtc_event_generic_ack_received.h index d1ad0f1fef..57fd7cd9a6 100644 --- a/logging/rtc_event_log/events/rtc_event_generic_ack_received.h +++ b/logging/rtc_event_log/events/rtc_event_generic_ack_received.h @@ -36,6 +36,7 @@ struct LoggedGenericAckReceived { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); int64_t packet_number; diff --git a/logging/rtc_event_log/events/rtc_event_generic_packet_received.h b/logging/rtc_event_log/events/rtc_event_generic_packet_received.h index fddee67740..a6006ca4d4 100644 --- a/logging/rtc_event_log/events/rtc_event_generic_packet_received.h +++ b/logging/rtc_event_log/events/rtc_event_generic_packet_received.h @@ -33,6 +33,7 @@ struct LoggedGenericPacketReceived { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); int64_t packet_number; diff --git a/logging/rtc_event_log/events/rtc_event_generic_packet_sent.h b/logging/rtc_event_log/events/rtc_event_generic_packet_sent.h index 0f839ca949..903950a398 100644 --- a/logging/rtc_event_log/events/rtc_event_generic_packet_sent.h +++ b/logging/rtc_event_log/events/rtc_event_generic_packet_sent.h @@ -37,6 +37,7 @@ struct LoggedGenericPacketSent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } size_t packet_length() const { return payload_length + padding_length + overhead_length; diff --git a/logging/rtc_event_log/events/rtc_event_ice_candidate_pair.h b/logging/rtc_event_log/events/rtc_event_ice_candidate_pair.h index 85cf79735a..bdacf15a59 100644 --- a/logging/rtc_event_log/events/rtc_event_ice_candidate_pair.h +++ b/logging/rtc_event_log/events/rtc_event_ice_candidate_pair.h @@ -45,6 +45,7 @@ struct LoggedIceCandidatePairEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); IceCandidatePairEventType type; diff --git a/logging/rtc_event_log/events/rtc_event_ice_candidate_pair_config.h b/logging/rtc_event_log/events/rtc_event_ice_candidate_pair_config.h index 0dfbfc838a..e72d999cff 100644 --- a/logging/rtc_event_log/events/rtc_event_ice_candidate_pair_config.h +++ b/logging/rtc_event_log/events/rtc_event_ice_candidate_pair_config.h @@ -72,6 +72,7 @@ enum class IceCandidateNetworkType { struct LoggedIceCandidatePairConfig { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); IceCandidatePairConfigType type; diff --git a/logging/rtc_event_log/events/rtc_event_probe_cluster_created.h b/logging/rtc_event_log/events/rtc_event_probe_cluster_created.h index b91d89c239..ae6810c39d 100644 --- a/logging/rtc_event_log/events/rtc_event_probe_cluster_created.h +++ b/logging/rtc_event_log/events/rtc_event_probe_cluster_created.h @@ -39,6 +39,7 @@ struct LoggedBweProbeClusterCreatedEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); int32_t id; diff --git a/logging/rtc_event_log/events/rtc_event_probe_result_failure.h b/logging/rtc_event_log/events/rtc_event_probe_result_failure.h index ba4db75c66..1aa6e75cb7 100644 --- a/logging/rtc_event_log/events/rtc_event_probe_result_failure.h +++ b/logging/rtc_event_log/events/rtc_event_probe_result_failure.h @@ -40,6 +40,7 @@ struct LoggedBweProbeFailureEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); int32_t id; diff --git a/logging/rtc_event_log/events/rtc_event_probe_result_success.h b/logging/rtc_event_log/events/rtc_event_probe_result_success.h index 172e9aa2eb..49d1abec5a 100644 --- a/logging/rtc_event_log/events/rtc_event_probe_result_success.h +++ b/logging/rtc_event_log/events/rtc_event_probe_result_success.h @@ -33,6 +33,7 @@ struct LoggedBweProbeSuccessEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); int32_t id; diff --git a/logging/rtc_event_log/events/rtc_event_remote_estimate.h b/logging/rtc_event_log/events/rtc_event_remote_estimate.h index 17de63c475..4a39ecc597 100644 --- a/logging/rtc_event_log/events/rtc_event_remote_estimate.h +++ b/logging/rtc_event_log/events/rtc_event_remote_estimate.h @@ -28,6 +28,7 @@ struct LoggedRemoteEstimateEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); absl::optional link_capacity_lower; diff --git a/logging/rtc_event_log/events/rtc_event_route_change.h b/logging/rtc_event_log/events/rtc_event_route_change.h index 542d15e3b3..bc1461d7bb 100644 --- a/logging/rtc_event_log/events/rtc_event_route_change.h +++ b/logging/rtc_event_log/events/rtc_event_route_change.h @@ -29,6 +29,7 @@ struct LoggedRouteChangeEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); bool connected; diff --git a/logging/rtc_event_log/events/rtc_event_video_receive_stream_config.h b/logging/rtc_event_log/events/rtc_event_video_receive_stream_config.h index f3380d1bb6..0be56c2065 100644 --- a/logging/rtc_event_log/events/rtc_event_video_receive_stream_config.h +++ b/logging/rtc_event_log/events/rtc_event_video_receive_stream_config.h @@ -30,6 +30,7 @@ struct LoggedVideoRecvConfig { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtclog::StreamConfig config; diff --git a/logging/rtc_event_log/events/rtc_event_video_send_stream_config.h b/logging/rtc_event_log/events/rtc_event_video_send_stream_config.h index 15c28999dc..f1717b19ea 100644 --- a/logging/rtc_event_log/events/rtc_event_video_send_stream_config.h +++ b/logging/rtc_event_log/events/rtc_event_video_send_stream_config.h @@ -30,6 +30,7 @@ struct LoggedVideoSendConfig { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtclog::StreamConfig config; diff --git a/logging/rtc_event_log/rtc_event_log_parser.cc b/logging/rtc_event_log/rtc_event_log_parser.cc index f0d165bdb2..b4392e8088 100644 --- a/logging/rtc_event_log/rtc_event_log_parser.cc +++ b/logging/rtc_event_log/rtc_event_log_parser.cc @@ -1110,8 +1110,8 @@ void ParsedRtcEventLog::Clear() { last_incoming_rtcp_packet_.clear(); - first_timestamp_ = std::numeric_limits::max(); - last_timestamp_ = std::numeric_limits::min(); + first_timestamp_ = Timestamp::PlusInfinity(); + last_timestamp_ = Timestamp::MinusInfinity(); first_log_segment_ = LogSegment(0, std::numeric_limits::max()); incoming_rtp_extensions_maps_.clear(); @@ -1232,8 +1232,8 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::ParseStream( // stream configurations and starting/stopping the log. // TODO(terelius): Figure out if we actually need to find the first and last // timestamp in the parser. It seems like this could be done by the caller. - first_timestamp_ = std::numeric_limits::max(); - last_timestamp_ = std::numeric_limits::min(); + first_timestamp_ = Timestamp::PlusInfinity(); + last_timestamp_ = Timestamp::MinusInfinity(); StoreFirstAndLastTimestamp(alr_state_events()); StoreFirstAndLastTimestamp(route_change_events()); for (const auto& audio_stream : audio_playout_events()) { @@ -1272,7 +1272,8 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::ParseStream( // event, we could use the timestamp of the the last previous regular event. auto start_iter = start_log_events().begin(); auto stop_iter = stop_log_events().begin(); - int64_t start_us = first_timestamp(); + int64_t start_us = + first_timestamp().us_or(std::numeric_limits::max()); int64_t next_start_us = std::numeric_limits::max(); int64_t stop_us = std::numeric_limits::max(); if (start_iter != start_log_events().end()) { @@ -1286,15 +1287,14 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::ParseStream( } stop_us = std::min(stop_us, next_start_us); if (stop_us == std::numeric_limits::max() && - last_timestamp() != std::numeric_limits::min()) { - stop_us = last_timestamp(); + !last_timestamp().IsMinusInfinity()) { + stop_us = last_timestamp().us(); } RTC_PARSE_CHECK_OR_RETURN_LE(start_us, stop_us); first_log_segment_ = LogSegment(start_us, stop_us); - if (first_timestamp_ == std::numeric_limits::max() && - last_timestamp_ == std::numeric_limits::min()) { - first_timestamp_ = last_timestamp_ = 0; + if (first_timestamp_ > last_timestamp_) { + first_timestamp_ = last_timestamp_ = Timestamp::Zero(); } return status; @@ -1563,8 +1563,8 @@ template void ParsedRtcEventLog::StoreFirstAndLastTimestamp(const std::vector& v) { if (v.empty()) return; - first_timestamp_ = std::min(first_timestamp_, v.front().log_time_us()); - last_timestamp_ = std::max(last_timestamp_, v.back().log_time_us()); + first_timestamp_ = std::min(first_timestamp_, v.front().log_time()); + last_timestamp_ = std::max(last_timestamp_, v.back().log_time()); } ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreParsedLegacyEvent( diff --git a/logging/rtc_event_log/rtc_event_log_parser.h b/logging/rtc_event_log/rtc_event_log_parser.h index 4a9ff3495f..9ef4e347de 100644 --- a/logging/rtc_event_log/rtc_event_log_parser.h +++ b/logging/rtc_event_log/rtc_event_log_parser.h @@ -643,8 +643,8 @@ class ParsedRtcEventLog { return decoded_frames_; } - int64_t first_timestamp() const { return first_timestamp_; } - int64_t last_timestamp() const { return last_timestamp_; } + Timestamp first_timestamp() const { return first_timestamp_; } + Timestamp last_timestamp() const { return last_timestamp_; } const LogSegment& first_log_segment() const { return first_log_segment_; } @@ -889,8 +889,8 @@ class ParsedRtcEventLog { std::vector last_incoming_rtcp_packet_; - int64_t first_timestamp_; - int64_t last_timestamp_; + Timestamp first_timestamp_ = Timestamp::PlusInfinity(); + Timestamp last_timestamp_ = Timestamp::MinusInfinity(); LogSegment first_log_segment_ = LogSegment(0, std::numeric_limits::max()); diff --git a/logging/rtc_event_log/rtc_event_log_unittest.cc b/logging/rtc_event_log/rtc_event_log_unittest.cc index 8f32eecd8b..34904a5e02 100644 --- a/logging/rtc_event_log/rtc_event_log_unittest.cc +++ b/logging/rtc_event_log/rtc_event_log_unittest.cc @@ -785,8 +785,8 @@ void RtcEventLogSession::ReadAndVerifyLog() { parsed_generic_acks_received[i]); } - EXPECT_EQ(first_timestamp_ms_, parsed_log.first_timestamp() / 1000); - EXPECT_EQ(last_timestamp_ms_, parsed_log.last_timestamp() / 1000); + EXPECT_EQ(first_timestamp_ms_, parsed_log.first_timestamp().ms()); + EXPECT_EQ(last_timestamp_ms_, parsed_log.last_timestamp().ms()); EXPECT_EQ(parsed_log.first_log_segment().start_time_ms(), std::min(start_time_us_ / 1000, first_timestamp_ms_)); diff --git a/rtc_tools/rtc_event_log_visualizer/alerts.cc b/rtc_tools/rtc_event_log_visualizer/alerts.cc index 2d1868fa28..c0d8784fa8 100644 --- a/rtc_tools/rtc_event_log_visualizer/alerts.cc +++ b/rtc_tools/rtc_event_log_visualizer/alerts.cc @@ -79,7 +79,7 @@ void TriageHelper::AnalyzeStreamGaps(const ParsedRtcEventLog& parsed_log, int64_t seq_num = seq_num_unwrapper.Unwrap(packet.header.sequenceNumber); if (std::abs(seq_num - last_seq_num) > kMaxSeqNumJump) { - Alert(seq_num_alert, config_.GetCallTimeSec(packet.log_time_us()), + Alert(seq_num_alert, config_.GetCallTimeSec(packet.log_time()), seq_num_explanation); } last_seq_num = seq_num; @@ -89,7 +89,7 @@ void TriageHelper::AnalyzeStreamGaps(const ParsedRtcEventLog& parsed_log, if (std::abs(capture_time - last_capture_time) > kTicksPerMillisec * (kCaptureTimeGraceMs + packet.log_time_ms() - last_log_time_ms)) { - Alert(capture_time_alert, config_.GetCallTimeSec(packet.log_time_us()), + Alert(capture_time_alert, config_.GetCallTimeSec(packet.log_time()), capture_time_explanation); } last_capture_time = capture_time; @@ -140,7 +140,8 @@ void TriageHelper::AnalyzeTransmissionGaps(const ParsedRtcEventLog& parsed_log, int64_t duration = timestamp - last_rtp_time.value_or(0); if (last_rtp_time.has_value() && duration > kMaxRtpTransmissionGap) { // No packet sent/received for more than 500 ms. - Alert(rtp_alert, config_.GetCallTimeSec(timestamp), rtp_explanation); + Alert(rtp_alert, config_.GetCallTimeSec(Timestamp::Micros(timestamp)), + rtp_explanation); } last_rtp_time.emplace(timestamp); } @@ -155,7 +156,7 @@ void TriageHelper::AnalyzeTransmissionGaps(const ParsedRtcEventLog& parsed_log, int64_t duration = rtcp.log_time_us() - last_rtcp_time.value_or(0); if (last_rtcp_time.has_value() && duration > kMaxRtcpTransmissionGap) { // No feedback sent/received for more than 2000 ms. - Alert(rtcp_alert, config_.GetCallTimeSec(rtcp.log_time_us()), + Alert(rtcp_alert, config_.GetCallTimeSec(rtcp.log_time()), rtcp_explanation); } last_rtcp_time.emplace(rtcp.log_time_us()); @@ -169,7 +170,7 @@ void TriageHelper::AnalyzeTransmissionGaps(const ParsedRtcEventLog& parsed_log, int64_t duration = rtcp.log_time_us() - last_rtcp_time.value_or(0); if (last_rtcp_time.has_value() && duration > kMaxRtcpTransmissionGap) { // No feedback sent/received for more than 2000 ms. - Alert(rtcp_alert, config_.GetCallTimeSec(rtcp.log_time_us()), + Alert(rtcp_alert, config_.GetCallTimeSec(rtcp.log_time()), rtcp_explanation); } last_rtcp_time.emplace(rtcp.log_time_us()); @@ -189,7 +190,7 @@ void TriageHelper::AnalyzeLog(const ParsedRtcEventLog& parsed_log) { const int64_t segment_end_us = parsed_log.first_log_segment().stop_time_us(); - int64_t first_occurrence = parsed_log.last_timestamp(); + Timestamp first_occurrence = parsed_log.last_timestamp(); constexpr double kMaxLossFraction = 0.05; // Loss feedback int64_t total_lost_packets = 0; @@ -204,13 +205,14 @@ void TriageHelper::AnalyzeLog(const ParsedRtcEventLog& parsed_log) { total_lost_packets += lost_packets; total_expected_packets += bwe_update.expected_packets; if (bwe_update.fraction_lost >= 255 * kMaxLossFraction) { - first_occurrence = std::min(first_occurrence, bwe_update.log_time_us()); + first_occurrence = std::min(first_occurrence, bwe_update.log_time()); } } double avg_outgoing_loss = static_cast(total_lost_packets) / total_expected_packets; if (avg_outgoing_loss > kMaxLossFraction) { - Alert(TriageAlertType::kOutgoingHighLoss, first_occurrence, + Alert(TriageAlertType::kOutgoingHighLoss, + config_.GetCallTimeSec(first_occurrence), "More than 5% of outgoing packets lost."); } } diff --git a/rtc_tools/rtc_event_log_visualizer/analyze_audio.cc b/rtc_tools/rtc_event_log_visualizer/analyze_audio.cc index 69a753bf22..854c6d05ae 100644 --- a/rtc_tools/rtc_event_log_visualizer/analyze_audio.cc +++ b/rtc_tools/rtc_event_log_visualizer/analyze_audio.cc @@ -38,7 +38,7 @@ void CreateAudioEncoderTargetBitrateGraph(const ParsedRtcEventLog& parsed_log, return absl::nullopt; }; auto ToCallTime = [config](const LoggedAudioNetworkAdaptationEvent& packet) { - return config.GetCallTimeSec(packet.log_time_us()); + return config.GetCallTimeSec(packet.log_time()); }; ProcessPoints( ToCallTime, GetAnaBitrateBps, @@ -63,7 +63,7 @@ void CreateAudioEncoderFrameLengthGraph(const ParsedRtcEventLog& parsed_log, return absl::optional(); }; auto ToCallTime = [config](const LoggedAudioNetworkAdaptationEvent& packet) { - return config.GetCallTimeSec(packet.log_time_us()); + return config.GetCallTimeSec(packet.log_time()); }; ProcessPoints( ToCallTime, GetAnaFrameLengthMs, @@ -88,7 +88,7 @@ void CreateAudioEncoderPacketLossGraph(const ParsedRtcEventLog& parsed_log, return absl::optional(); }; auto ToCallTime = [config](const LoggedAudioNetworkAdaptationEvent& packet) { - return config.GetCallTimeSec(packet.log_time_us()); + return config.GetCallTimeSec(packet.log_time()); }; ProcessPoints( ToCallTime, GetAnaPacketLoss, @@ -114,7 +114,7 @@ void CreateAudioEncoderEnableFecGraph(const ParsedRtcEventLog& parsed_log, return absl::optional(); }; auto ToCallTime = [config](const LoggedAudioNetworkAdaptationEvent& packet) { - return config.GetCallTimeSec(packet.log_time_us()); + return config.GetCallTimeSec(packet.log_time()); }; ProcessPoints( ToCallTime, GetAnaFecEnabled, @@ -139,7 +139,7 @@ void CreateAudioEncoderEnableDtxGraph(const ParsedRtcEventLog& parsed_log, return absl::optional(); }; auto ToCallTime = [config](const LoggedAudioNetworkAdaptationEvent& packet) { - return config.GetCallTimeSec(packet.log_time_us()); + return config.GetCallTimeSec(packet.log_time()); }; ProcessPoints( ToCallTime, GetAnaDtxEnabled, @@ -164,7 +164,7 @@ void CreateAudioEncoderNumChannelsGraph(const ParsedRtcEventLog& parsed_log, return absl::optional(); }; auto ToCallTime = [config](const LoggedAudioNetworkAdaptationEvent& packet) { - return config.GetCallTimeSec(packet.log_time_us()); + return config.GetCallTimeSec(packet.log_time()); }; ProcessPoints( ToCallTime, GetAnaNumChannels, @@ -397,23 +397,23 @@ void CreateAudioJitterBufferGraph(const ParsedRtcEventLog& parsed_log, PointStyle::kHighlight); for (const auto& data : arrival_delay_ms) { - const float x = config.GetCallTimeSec(data.first * 1000); // ms to us. + const float x = config.GetCallTimeSec(Timestamp::Millis(data.first)); const float y = data.second; time_series_packet_arrival.points.emplace_back(TimeSeriesPoint(x, y)); } for (const auto& data : corrected_arrival_delay_ms) { - const float x = config.GetCallTimeSec(data.first * 1000); // ms to us. + const float x = config.GetCallTimeSec(Timestamp::Millis(data.first)); const float y = data.second; time_series_relative_packet_arrival.points.emplace_back( TimeSeriesPoint(x, y)); } for (const auto& data : playout_delay_ms) { - const float x = config.GetCallTimeSec(data.first * 1000); // ms to us. + const float x = config.GetCallTimeSec(Timestamp::Millis(data.first)); const float y = data.second; time_series_play_time.points.emplace_back(TimeSeriesPoint(x, y)); } for (const auto& data : target_delay_ms) { - const float x = config.GetCallTimeSec(data.first * 1000); // ms to us. + const float x = config.GetCallTimeSec(Timestamp::Millis(data.first)); const float y = data.second; time_series_target_time.points.emplace_back(TimeSeriesPoint(x, y)); } @@ -448,7 +448,7 @@ void CreateNetEqStatsGraphInternal( const std::vector>* data_vector = data_extractor(st.second.get()); for (const auto& data : *data_vector) { - const float time = config.GetCallTimeSec(data.first * 1000); // ms to us. + const float time = config.GetCallTimeSec(Timestamp::Millis(data.first)); const float value = stats_extractor(data.second); time_series[ssrc].points.emplace_back(TimeSeriesPoint(time, value)); } diff --git a/rtc_tools/rtc_event_log_visualizer/analyzer.cc b/rtc_tools/rtc_event_log_visualizer/analyzer.cc index b43801623c..4c718185df 100644 --- a/rtc_tools/rtc_event_log_visualizer/analyzer.cc +++ b/rtc_tools/rtc_event_log_visualizer/analyzer.cc @@ -214,7 +214,7 @@ TimeSeries CreateRtcpTypeTimeSeries(const std::vector& rtcp_list, int category_id) { TimeSeries time_series(rtcp_name, LineStyle::kNone, PointStyle::kHighlight); for (const auto& rtcp : rtcp_list) { - float x = config.GetCallTimeSec(rtcp.log_time_us()); + float x = config.GetCallTimeSec(rtcp.timestamp); float y = category_id; time_series.points.emplace_back(x, y); } @@ -346,20 +346,24 @@ std::string GetDirectionAsShortString(PacketDirection direction) { EventLogAnalyzer::EventLogAnalyzer(const ParsedRtcEventLog& log, bool normalize_time) : parsed_log_(log) { - config_.window_duration_ = 250000; - config_.step_ = 10000; + config_.window_duration_ = TimeDelta::Millis(250); + config_.step_ = TimeDelta::Millis(10); + if (!log.start_log_events().empty()) { + config_.rtc_to_utc_offset_ = log.start_log_events()[0].utc_time() - + log.start_log_events()[0].log_time(); + } config_.normalize_time_ = normalize_time; config_.begin_time_ = parsed_log_.first_timestamp(); config_.end_time_ = parsed_log_.last_timestamp(); if (config_.end_time_ < config_.begin_time_) { RTC_LOG(LS_WARNING) << "No useful events in the log."; - config_.begin_time_ = config_.end_time_ = 0; + config_.begin_time_ = config_.end_time_ = Timestamp::Zero(); } RTC_LOG(LS_INFO) << "Log is " - << (parsed_log_.last_timestamp() - - parsed_log_.first_timestamp()) / - 1000000 + << (parsed_log_.last_timestamp().ms() - + parsed_log_.first_timestamp().ms()) / + 1000 << " seconds long."; } @@ -367,9 +371,9 @@ EventLogAnalyzer::EventLogAnalyzer(const ParsedRtcEventLog& log, const AnalyzerConfig& config) : parsed_log_(log), config_(config) { RTC_LOG(LS_INFO) << "Log is " - << (parsed_log_.last_timestamp() - - parsed_log_.first_timestamp()) / - 1000000 + << (parsed_log_.last_timestamp().ms() - + parsed_log_.first_timestamp().ms()) / + 1000 << " seconds long."; } @@ -413,7 +417,7 @@ void EventLogAnalyzer::CreatePacketGraph(PacketDirection direction, return absl::optional(packet.total_length); }; auto ToCallTime = [this](const LoggedRtpPacket& packet) { - return this->config_.GetCallTimeSec(packet.log_time_us()); + return this->config_.GetCallTimeSec(packet.timestamp); }; ProcessPoints(ToCallTime, GetPacketSize, stream.packet_view, &time_series); @@ -469,7 +473,7 @@ void EventLogAnalyzer::CreateAccumulatedPacketsTimeSeries( const std::string& label) { TimeSeries time_series(label, LineStyle::kStep); for (size_t i = 0; i < packets.size(); i++) { - float x = config_.GetCallTimeSec(packets[i].log_time_us()); + float x = config_.GetCallTimeSec(packets[i].log_time()); time_series.points.emplace_back(x, i + 1); } plot->AppendTimeSeries(std::move(time_series)); @@ -545,17 +549,15 @@ void EventLogAnalyzer::CreateTotalPacketRateGraph(PacketDirection direction, // types using MovingAverage(). class LogTime { public: - explicit LogTime(int64_t log_time_us) : log_time_us_(log_time_us) {} - - int64_t log_time_us() const { return log_time_us_; } + explicit LogTime(Timestamp log_time) : log_time_(log_time) {} + Timestamp log_time() const { return log_time_; } private: - int64_t log_time_us_; + Timestamp log_time_; }; - std::vector packet_times; auto handle_rtp = [&](const LoggedRtpPacket& packet) { - packet_times.emplace_back(packet.log_time_us()); + packet_times.emplace_back(packet.log_time()); }; RtcEventProcessor process; for (const auto& stream : parsed_log_.rtp_packets_by_ssrc(direction)) { @@ -563,13 +565,13 @@ void EventLogAnalyzer::CreateTotalPacketRateGraph(PacketDirection direction, } if (direction == kIncomingPacket) { auto handle_incoming_rtcp = [&](const LoggedRtcpPacketIncoming& packet) { - packet_times.emplace_back(packet.log_time_us()); + packet_times.emplace_back(packet.log_time()); }; process.AddEvents(parsed_log_.incoming_rtcp_packets(), handle_incoming_rtcp); } else { auto handle_outgoing_rtcp = [&](const LoggedRtcpPacketOutgoing& packet) { - packet_times.emplace_back(packet.log_time_us()); + packet_times.emplace_back(packet.log_time()); }; process.AddEvents(parsed_log_.outgoing_rtcp_packets(), handle_outgoing_rtcp); @@ -599,7 +601,7 @@ void EventLogAnalyzer::CreatePlayoutGraph(Plot* plot) { absl::optional last_playout_ms; TimeSeries time_series(SsrcToString(ssrc), LineStyle::kBar); for (const auto& playout_event : playout_stream.second) { - float x = config_.GetCallTimeSec(playout_event.log_time_us()); + float x = config_.GetCallTimeSec(playout_event.log_time()); int64_t playout_time_ms = playout_event.log_time_ms(); // If there were no previous playouts, place the point on the x-axis. float y = playout_time_ms - last_playout_ms.value_or(playout_time_ms); @@ -626,7 +628,7 @@ void EventLogAnalyzer::CreateAudioLevelGraph(PacketDirection direction, LineStyle::kLine); for (auto& packet : stream.packet_view) { if (packet.header.extension.hasAudioLevel) { - float x = config_.GetCallTimeSec(packet.log_time_us()); + float x = config_.GetCallTimeSec(packet.log_time()); // The audio level is stored in -dBov (so e.g. -10 dBov is stored as 10) // Here we convert it to dBov. float y = static_cast(-packet.header.extension.audioLevel); @@ -662,7 +664,7 @@ void EventLogAnalyzer::CreateSequenceNumberGraph(Plot* plot) { return diff; }; auto ToCallTime = [this](const LoggedRtpPacketIncoming& packet) { - return this->config_.GetCallTimeSec(packet.log_time_us()); + return this->config_.GetCallTimeSec(packet.log_time()); }; ProcessPairs( ToCallTime, GetSequenceNumberDiff, stream.incoming_packets, @@ -691,8 +693,8 @@ void EventLogAnalyzer::CreateIncomingPacketLossGraph(Plot* plot) { LineStyle::kLine, PointStyle::kHighlight); // TODO(terelius): Should the window and step size be read from the class // instead? - const int64_t kWindowUs = 1000000; - const int64_t kStep = 1000000; + const TimeDelta kWindow = TimeDelta::Millis(1000); + const TimeDelta kStep = TimeDelta::Millis(1000); SeqNumUnwrapper unwrapper_; SeqNumUnwrapper prior_unwrapper_; size_t window_index_begin = 0; @@ -702,17 +704,17 @@ void EventLogAnalyzer::CreateIncomingPacketLossGraph(Plot* plot) { uint64_t highest_prior_seq_number = prior_unwrapper_.Unwrap(packets[0].rtp.header.sequenceNumber) - 1; - for (int64_t t = config_.begin_time_; t < config_.end_time_ + kStep; + for (Timestamp t = config_.begin_time_; t < config_.end_time_ + kStep; t += kStep) { while (window_index_end < packets.size() && - packets[window_index_end].rtp.log_time_us() < t) { + packets[window_index_end].rtp.log_time() < t) { uint64_t sequence_number = unwrapper_.Unwrap( packets[window_index_end].rtp.header.sequenceNumber); highest_seq_number = std::max(highest_seq_number, sequence_number); ++window_index_end; } while (window_index_begin < packets.size() && - packets[window_index_begin].rtp.log_time_us() < t - kWindowUs) { + packets[window_index_begin].rtp.log_time() < t - kWindow) { uint64_t sequence_number = prior_unwrapper_.Unwrap( packets[window_index_begin].rtp.header.sequenceNumber); highest_prior_seq_number = @@ -767,7 +769,7 @@ void EventLogAnalyzer::CreateIncomingDelayGraph(Plot* plot) { } auto ToCallTime = [this](const LoggedRtpPacketIncoming& packet) { - return this->config_.GetCallTimeSec(packet.log_time_us()); + return this->config_.GetCallTimeSec(packet.log_time()); }; auto ToNetworkDelay = [frequency_hz]( const LoggedRtpPacketIncoming& old_packet, @@ -803,7 +805,7 @@ void EventLogAnalyzer::CreateFractionLossGraph(Plot* plot) { TimeSeries time_series("Fraction lost", LineStyle::kLine, PointStyle::kHighlight); for (auto& bwe_update : parsed_log_.bwe_loss_updates()) { - float x = config_.GetCallTimeSec(bwe_update.log_time_us()); + float x = config_.GetCallTimeSec(bwe_update.log_time()); float y = static_cast(bwe_update.fraction_lost) / 255 * 100; time_series.points.emplace_back(x, y); } @@ -818,11 +820,11 @@ void EventLogAnalyzer::CreateFractionLossGraph(Plot* plot) { // Plot the total bandwidth used by all RTP streams. void EventLogAnalyzer::CreateTotalIncomingBitrateGraph(Plot* plot) { // TODO(terelius): This could be provided by the parser. - std::multimap packets_in_order; + std::multimap packets_in_order; for (const auto& stream : parsed_log_.incoming_rtp_packets_by_ssrc()) { for (const LoggedRtpPacketIncoming& packet : stream.incoming_packets) packets_in_order.insert( - std::make_pair(packet.rtp.log_time_us(), packet.rtp.total_length)); + std::make_pair(packet.rtp.log_time(), packet.rtp.total_length)); } auto window_begin = packets_in_order.begin(); @@ -832,7 +834,7 @@ void EventLogAnalyzer::CreateTotalIncomingBitrateGraph(Plot* plot) { if (!packets_in_order.empty()) { // Calculate a moving average of the bitrate and store in a TimeSeries. TimeSeries bitrate_series("Bitrate", LineStyle::kLine); - for (int64_t time = config_.begin_time_; + for (Timestamp time = config_.begin_time_; time < config_.end_time_ + config_.step_; time += config_.step_) { while (window_end != packets_in_order.end() && window_end->first < time) { bytes_in_window += window_end->second; @@ -845,7 +847,8 @@ void EventLogAnalyzer::CreateTotalIncomingBitrateGraph(Plot* plot) { ++window_begin; } float window_duration_in_seconds = - static_cast(config_.window_duration_) / kNumMicrosecsPerSec; + static_cast(config_.window_duration_.us()) / + kNumMicrosecsPerSec; float x = config_.GetCallTimeSec(time); float y = bytes_in_window * 8 / window_duration_in_seconds / 1000; bitrate_series.points.emplace_back(x, y); @@ -856,7 +859,7 @@ void EventLogAnalyzer::CreateTotalIncomingBitrateGraph(Plot* plot) { // Overlay the outgoing REMB over incoming bitrate. TimeSeries remb_series("Remb", LineStyle::kStep); for (const auto& rtcp : parsed_log_.rembs(kOutgoingPacket)) { - float x = config_.GetCallTimeSec(rtcp.log_time_us()); + float x = config_.GetCallTimeSec(rtcp.log_time()); float y = static_cast(rtcp.remb.bitrate_bps()) / 1000; remb_series.points.emplace_back(x, y); } @@ -884,11 +887,11 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, bool show_detector_state, bool show_alr_state) { // TODO(terelius): This could be provided by the parser. - std::multimap packets_in_order; + std::multimap packets_in_order; for (const auto& stream : parsed_log_.outgoing_rtp_packets_by_ssrc()) { for (const LoggedRtpPacketOutgoing& packet : stream.outgoing_packets) packets_in_order.insert( - std::make_pair(packet.rtp.log_time_us(), packet.rtp.total_length)); + std::make_pair(packet.rtp.log_time(), packet.rtp.total_length)); } auto window_begin = packets_in_order.begin(); @@ -898,7 +901,7 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, if (!packets_in_order.empty()) { // Calculate a moving average of the bitrate and store in a TimeSeries. TimeSeries bitrate_series("Bitrate", LineStyle::kLine); - for (int64_t time = config_.begin_time_; + for (Timestamp time = config_.begin_time_; time < config_.end_time_ + config_.step_; time += config_.step_) { while (window_end != packets_in_order.end() && window_end->first < time) { bytes_in_window += window_end->second; @@ -911,7 +914,8 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, ++window_begin; } float window_duration_in_seconds = - static_cast(config_.window_duration_) / kNumMicrosecsPerSec; + static_cast(config_.window_duration_.us()) / + kNumMicrosecsPerSec; float x = config_.GetCallTimeSec(time); float y = bytes_in_window * 8 / window_duration_in_seconds / 1000; bitrate_series.points.emplace_back(x, y); @@ -922,7 +926,7 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, // Overlay the send-side bandwidth estimate over the outgoing bitrate. TimeSeries loss_series("Loss-based estimate", LineStyle::kStep); for (auto& loss_update : parsed_log_.bwe_loss_updates()) { - float x = config_.GetCallTimeSec(loss_update.log_time_us()); + float x = config_.GetCallTimeSec(loss_update.log_time()); float y = static_cast(loss_update.bitrate_bps) / 1000; loss_series.points.emplace_back(x, y); } @@ -935,12 +939,12 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, IntervalSeries normal_series("Normal", "#c4ffc4", IntervalSeries::kHorizontal); IntervalSeries* last_series = &normal_series; - double last_detector_switch = 0.0; + float last_detector_switch = 0.0; BandwidthUsage last_detector_state = BandwidthUsage::kBwNormal; for (auto& delay_update : parsed_log_.bwe_delay_updates()) { - float x = config_.GetCallTimeSec(delay_update.log_time_us()); + float x = config_.GetCallTimeSec(delay_update.log_time()); float y = static_cast(delay_update.bitrate_bps) / 1000; if (last_detector_state != delay_update.detector_state) { @@ -967,12 +971,13 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, } RTC_CHECK(last_series); - last_series->intervals.emplace_back(last_detector_switch, config_.end_time_); + last_series->intervals.emplace_back(last_detector_switch, + config_.CallEndTimeSec()); TimeSeries created_series("Probe cluster created.", LineStyle::kNone, PointStyle::kHighlight); for (auto& cluster : parsed_log_.bwe_probe_cluster_created_events()) { - float x = config_.GetCallTimeSec(cluster.log_time_us()); + float x = config_.GetCallTimeSec(cluster.log_time()); float y = static_cast(cluster.bitrate_bps) / 1000; created_series.points.emplace_back(x, y); } @@ -980,7 +985,7 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, TimeSeries result_series("Probing results.", LineStyle::kNone, PointStyle::kHighlight); for (auto& result : parsed_log_.bwe_probe_success_events()) { - float x = config_.GetCallTimeSec(result.log_time_us()); + float x = config_.GetCallTimeSec(result.log_time()); float y = static_cast(result.bitrate_bps) / 1000; result_series.points.emplace_back(x, y); } @@ -988,17 +993,17 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, TimeSeries probe_failures_series("Probe failed", LineStyle::kNone, PointStyle::kHighlight); for (auto& failure : parsed_log_.bwe_probe_failure_events()) { - float x = config_.GetCallTimeSec(failure.log_time_us()); + float x = config_.GetCallTimeSec(failure.log_time()); probe_failures_series.points.emplace_back(x, 0); } IntervalSeries alr_state("ALR", "#555555", IntervalSeries::kHorizontal); bool previously_in_alr = false; - int64_t alr_start = 0; + Timestamp alr_start = Timestamp::Zero(); for (auto& alr : parsed_log_.alr_state_events()) { - float y = config_.GetCallTimeSec(alr.log_time_us()); + float y = config_.GetCallTimeSec(alr.log_time()); if (!previously_in_alr && alr.in_alr) { - alr_start = alr.log_time_us(); + alr_start = alr.log_time(); previously_in_alr = true; } else if (previously_in_alr && !alr.in_alr) { float x = config_.GetCallTimeSec(alr_start); @@ -1031,7 +1036,7 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, // Overlay the incoming REMB over the outgoing bitrate. TimeSeries remb_series("Remb", LineStyle::kStep); for (const auto& rtcp : parsed_log_.rembs(kIncomingPacket)) { - float x = config_.GetCallTimeSec(rtcp.log_time_us()); + float x = config_.GetCallTimeSec(rtcp.log_time()); float y = static_cast(rtcp.remb.bitrate_bps()) / 1000; remb_series.points.emplace_back(x, y); } @@ -1117,7 +1122,7 @@ void EventLogAnalyzer::CreateBitrateAllocationGraph(PacketDirection direction, std::make_pair(layer, TimeSeries(layer_name, LineStyle::kStep))); RTC_DCHECK(inserted); } - float x = config_.GetCallTimeSec(rtcp.log_time_us()); + float x = config_.GetCallTimeSec(rtcp.log_time()); float y = bitrate_item.target_bitrate_kbps; time_series_it->second.points.emplace_back(x, y); } @@ -1149,22 +1154,20 @@ void EventLogAnalyzer::CreateGoogCcSimulationGraph(Plot* plot) { [&](const NetworkControlUpdate& update, Timestamp at_time) { if (update.target_rate) { target_rates.points.emplace_back( - config_.GetCallTimeSec(at_time.us()), + config_.GetCallTimeSec(at_time), update.target_rate->target_rate.kbps()); } }); simulation.ProcessEventsInLog(parsed_log_); for (const auto& logged : parsed_log_.bwe_delay_updates()) - delay_based.points.emplace_back( - config_.GetCallTimeSec(logged.log_time_us()), - logged.bitrate_bps / 1000); + delay_based.points.emplace_back(config_.GetCallTimeSec(logged.log_time()), + logged.bitrate_bps / 1000); for (const auto& logged : parsed_log_.bwe_probe_success_events()) - probe_results.points.emplace_back( - config_.GetCallTimeSec(logged.log_time_us()), - logged.bitrate_bps / 1000); + probe_results.points.emplace_back(config_.GetCallTimeSec(logged.log_time()), + logged.bitrate_bps / 1000); for (const auto& logged : parsed_log_.bwe_loss_updates()) - loss_based.points.emplace_back(config_.GetCallTimeSec(logged.log_time_us()), + loss_based.points.emplace_back(config_.GetCallTimeSec(logged.log_time()), logged.bitrate_bps / 1000); plot->AppendTimeSeries(std::move(delay_based)); @@ -1324,7 +1327,7 @@ void EventLogAnalyzer::CreateSendSideBweSimulationGraph(Plot* plot) { } } - float x = config_.GetCallTimeSec(clock.TimeInMicroseconds()); + float x = config_.GetCallTimeSec(clock.CurrentTime()); float y = bitrate_bps.value_or(0) / 1000; acked_time_series.points.emplace_back(x, y); y = robust_throughput_estimator->bitrate() @@ -1347,7 +1350,7 @@ void EventLogAnalyzer::CreateSendSideBweSimulationGraph(Plot* plot) { if (observer.GetAndResetBitrateUpdated() || time_us - last_update_us >= 1e6) { uint32_t y = observer.last_bitrate_bps() / 1000; - float x = config_.GetCallTimeSec(clock.TimeInMicroseconds()); + float x = config_.GetCallTimeSec(clock.CurrentTime()); time_series.points.emplace_back(x, y); last_update_us = time_us; } @@ -1423,13 +1426,13 @@ void EventLogAnalyzer::CreateReceiveSideBweSimulationGraph(Plot* plot) { absl::optional bitrate_bps = acked_bitrate.Rate(arrival_time_ms); if (bitrate_bps) { uint32_t y = *bitrate_bps / 1000; - float x = config_.GetCallTimeSec(clock.TimeInMicroseconds()); + float x = config_.GetCallTimeSec(clock.CurrentTime()); acked_time_series.points.emplace_back(x, y); } if (remb_interceptor.GetAndResetBitrateUpdated() || clock.TimeInMicroseconds() - last_update_us >= 1e6) { uint32_t y = remb_interceptor.last_bitrate_bps() / 1000; - float x = config_.GetCallTimeSec(clock.TimeInMicroseconds()); + float x = config_.GetCallTimeSec(clock.CurrentTime()); time_series.points.emplace_back(x, y); last_update_us = clock.TimeInMicroseconds(); } @@ -1461,7 +1464,7 @@ void EventLogAnalyzer::CreateNetworkDelayFeedbackGraph(Plot* plot) { for (const auto& packet : matched_rtp_rtcp) { if (packet.arrival_time_ms == MatchedSendArrivalTimes::kNotReceived) continue; - float x = config_.GetCallTimeSec(1000 * packet.feedback_arrival_time_ms); + float x = config_.GetCallTimeSecFromMs(packet.feedback_arrival_time_ms); int64_t y = packet.arrival_time_ms - packet.send_time_ms; int64_t rtt_ms = packet.feedback_arrival_time_ms - packet.send_time_ms; min_rtt_ms = std::min(rtt_ms, min_rtt_ms); @@ -1530,7 +1533,7 @@ void EventLogAnalyzer::CreatePacerDelayGraph(Plot* plot) { double send_time_ms = static_cast(packet.rtp.log_time_us() - first_send_timestamp) / 1000; - float x = config_.GetCallTimeSec(packet.rtp.log_time_us()); + float x = config_.GetCallTimeSec(packet.rtp.log_time()); float y = send_time_ms - capture_time_ms; pacer_delay_series.points.emplace_back(x, y); } @@ -1551,7 +1554,7 @@ void EventLogAnalyzer::CreateTimestampGraph(PacketDirection direction, GetStreamName(parsed_log_, direction, stream.ssrc) + " capture-time", LineStyle::kLine, PointStyle::kHighlight); for (const auto& packet : stream.packet_view) { - float x = config_.GetCallTimeSec(packet.log_time_us()); + float x = config_.GetCallTimeSec(packet.log_time()); float y = packet.header.timestamp; rtp_timestamps.points.emplace_back(x, y); } @@ -1566,7 +1569,7 @@ void EventLogAnalyzer::CreateTimestampGraph(PacketDirection direction, for (const auto& rtcp : sender_reports) { if (rtcp.sr.sender_ssrc() != stream.ssrc) continue; - float x = config_.GetCallTimeSec(rtcp.log_time_us()); + float x = config_.GetCallTimeSec(rtcp.log_time()); float y = rtcp.sr.rtp_timestamp(); rtcp_timestamps.points.emplace_back(x, y); } @@ -1588,7 +1591,7 @@ void EventLogAnalyzer::CreateSenderAndReceiverReportPlot( std::map sr_reports_by_ssrc; const auto& sender_reports = parsed_log_.sender_reports(direction); for (const auto& rtcp : sender_reports) { - float x = config_.GetCallTimeSec(rtcp.log_time_us()); + float x = config_.GetCallTimeSec(rtcp.log_time()); uint32_t ssrc = rtcp.sr.sender_ssrc(); for (const auto& block : rtcp.sr.report_blocks()) { float y = fy(block); @@ -1610,7 +1613,7 @@ void EventLogAnalyzer::CreateSenderAndReceiverReportPlot( std::map rr_reports_by_ssrc; const auto& receiver_reports = parsed_log_.receiver_reports(direction); for (const auto& rtcp : receiver_reports) { - float x = config_.GetCallTimeSec(rtcp.log_time_us()); + float x = config_.GetCallTimeSec(rtcp.log_time()); uint32_t ssrc = rtcp.rr.sender_ssrc(); for (const auto& block : rtcp.rr.report_blocks()) { float y = fy(block); @@ -1649,7 +1652,7 @@ void EventLogAnalyzer::CreateIceCandidatePairConfigGraph(Plot* plot) { candidate_pair_desc_by_id_[config.candidate_pair_id] = candidate_pair_desc; } - float x = config_.GetCallTimeSec(config.log_time_us()); + float x = config_.GetCallTimeSec(config.log_time()); float y = static_cast(config.type); configs_by_cp_id[config.candidate_pair_id].points.emplace_back(x, y); } @@ -1706,7 +1709,7 @@ void EventLogAnalyzer::CreateIceConnectivityCheckGraph(Plot* plot) { GetCandidatePairLogDescriptionFromId(event.candidate_pair_id), LineStyle::kNone, PointStyle::kHighlight); } - float x = config_.GetCallTimeSec(event.log_time_us()); + float x = config_.GetCallTimeSec(event.log_time()); float y = static_cast(event.type) + kEventTypeOffset; checks_by_cp_id[event.candidate_pair_id].points.emplace_back(x, y); } @@ -1741,7 +1744,7 @@ void EventLogAnalyzer::CreateDtlsTransportStateGraph(Plot* plot) { TimeSeries states("DTLS Transport State", LineStyle::kNone, PointStyle::kHighlight); for (const auto& event : parsed_log_.dtls_transport_states()) { - float x = config_.GetCallTimeSec(event.log_time_us()); + float x = config_.GetCallTimeSec(event.log_time()); float y = static_cast(event.dtls_transport_state); states.points.emplace_back(x, y); } @@ -1763,7 +1766,7 @@ void EventLogAnalyzer::CreateDtlsWritableStateGraph(Plot* plot) { TimeSeries writable("DTLS Writable", LineStyle::kNone, PointStyle::kHighlight); for (const auto& event : parsed_log_.dtls_writable_states()) { - float x = config_.GetCallTimeSec(event.log_time_us()); + float x = config_.GetCallTimeSec(event.log_time()); float y = static_cast(event.writable); writable.points.emplace_back(x, y); } diff --git a/rtc_tools/rtc_event_log_visualizer/analyzer_common.h b/rtc_tools/rtc_event_log_visualizer/analyzer_common.h index a4305a708f..b0b556aa62 100644 --- a/rtc_tools/rtc_event_log_visualizer/analyzer_common.h +++ b/rtc_tools/rtc_event_log_visualizer/analyzer_common.h @@ -22,6 +22,7 @@ namespace webrtc { constexpr int kNumMicrosecsPerSec = 1000000; +constexpr int kNumMillisecsPerSec = 1000; constexpr float kLeftMargin = 0.01f; constexpr float kRightMargin = 0.02f; constexpr float kBottomMargin = 0.02f; @@ -29,25 +30,38 @@ constexpr float kTopMargin = 0.05f; class AnalyzerConfig { public: - float GetCallTimeSec(int64_t timestamp_us) const { - int64_t offset = normalize_time_ ? begin_time_ : 0; - return static_cast(timestamp_us - offset) / 1000000; + float GetCallTimeSec(Timestamp timestamp) const { + Timestamp offset = normalize_time_ ? begin_time_ : Timestamp::Zero(); + return static_cast((timestamp - offset).us()) / 1000000; + } + + float GetCallTimeSecFromMs(int64_t timestamp_ms) const { + return GetCallTimeSec(Timestamp::Millis(timestamp_ms)); } float CallBeginTimeSec() const { return GetCallTimeSec(begin_time_); } float CallEndTimeSec() const { return GetCallTimeSec(end_time_); } + int64_t CallTimeToUtcOffsetMs() { + if (normalize_time_) { + Timestamp utc_begin_time_ = begin_time_ + rtc_to_utc_offset_; + return utc_begin_time_.ms(); + } + return rtc_to_utc_offset_.ms(); + } + // Window and step size used for calculating moving averages, e.g. bitrate. - // The generated data points will be `step_` microseconds apart. - // Only events occurring at most `window_duration_` microseconds before the - // current data point will be part of the average. - int64_t window_duration_; - int64_t step_; + // The generated data points will be `step_.ms()` milliseconds apart. + // Only events occurring at most `window_duration_.ms()` milliseconds before + // the current data point will be part of the average. + TimeDelta window_duration_ = TimeDelta::Millis(250); + TimeDelta step_ = TimeDelta::Millis(10); // First and last events of the log. - int64_t begin_time_; - int64_t end_time_; + Timestamp begin_time_ = Timestamp::MinusInfinity(); + Timestamp end_time_ = Timestamp::MinusInfinity(); + TimeDelta rtc_to_utc_offset_ = TimeDelta::Zero(); bool normalize_time_; }; @@ -152,17 +166,17 @@ void MovingAverage( size_t window_index_end = 0; ResultType sum_in_window = 0; - for (int64_t t = config.begin_time_; t < config.end_time_ + config.step_; + for (Timestamp t = config.begin_time_; t < config.end_time_ + config.step_; t += config.step_) { while (window_index_end < data_view.size() && - data_view[window_index_end].log_time_us() < t) { + data_view[window_index_end].log_time() < t) { absl::optional value = fy(data_view[window_index_end]); if (value) sum_in_window += *value; ++window_index_end; } while (window_index_begin < data_view.size() && - data_view[window_index_begin].log_time_us() < + data_view[window_index_begin].log_time() < t - config.window_duration_) { absl::optional value = fy(data_view[window_index_begin]); if (value) @@ -170,7 +184,7 @@ void MovingAverage( ++window_index_begin; } float window_duration_s = - static_cast(config.window_duration_) / kNumMicrosecsPerSec; + static_cast(config.window_duration_.us()) / kNumMicrosecsPerSec; float x = config.GetCallTimeSec(t); float y = sum_in_window / window_duration_s; result->points.emplace_back(x, y); diff --git a/rtc_tools/rtc_event_log_visualizer/main.cc b/rtc_tools/rtc_event_log_visualizer/main.cc index ab4b7ebac1..6182b701df 100644 --- a/rtc_tools/rtc_event_log_visualizer/main.cc +++ b/rtc_tools/rtc_event_log_visualizer/main.cc @@ -261,8 +261,12 @@ int main(int argc, char* argv[]) { } webrtc::AnalyzerConfig config; - config.window_duration_ = 250000; - config.step_ = 10000; + config.window_duration_ = webrtc::TimeDelta::Millis(250); + config.step_ = webrtc::TimeDelta::Millis(10); + if (!parsed_log.start_log_events().empty()) { + config.rtc_to_utc_offset_ = parsed_log.start_log_events()[0].utc_time() - + parsed_log.start_log_events()[0].log_time(); + } config.normalize_time_ = absl::GetFlag(FLAGS_normalize_time); config.begin_time_ = parsed_log.first_timestamp(); config.end_time_ = parsed_log.last_timestamp(); @@ -275,6 +279,7 @@ int main(int argc, char* argv[]) { webrtc::EventLogAnalyzer analyzer(parsed_log, config); webrtc::PlotCollection collection; + collection.SetCallTimeToUtcOffsetMs(config.CallTimeToUtcOffsetMs()); PlotMap plots; plots.RegisterPlot("incoming_packet_sizes", [&](Plot* plot) { diff --git a/rtc_tools/rtc_event_log_visualizer/plot_base.cc b/rtc_tools/rtc_event_log_visualizer/plot_base.cc index 82533e6eb0..bf76a67bb5 100644 --- a/rtc_tools/rtc_event_log_visualizer/plot_base.cc +++ b/rtc_tools/rtc_event_log_visualizer/plot_base.cc @@ -307,13 +307,13 @@ void PlotCollection::PrintPythonCode(bool shared_xaxis) const { void PlotCollection::ExportProtobuf( webrtc::analytics::ChartCollection* collection) const { for (const auto& plot : plots_) { - // TODO(terelius): Ensure that there is no way to insert plots other than - // ProtobufPlots in a ProtobufPlotCollection. Needed to safely static_cast - // here. webrtc::analytics::Chart* protobuf_representation = collection->add_charts(); plot->ExportProtobuf(protobuf_representation); } + if (calltime_to_utc_ms_) { + collection->set_calltime_to_utc_ms(*calltime_to_utc_ms_); + } } Plot* PlotCollection::AppendNewPlot() { diff --git a/rtc_tools/rtc_event_log_visualizer/plot_base.h b/rtc_tools/rtc_event_log_visualizer/plot_base.h index a26146b5e5..dbc9535fc1 100644 --- a/rtc_tools/rtc_event_log_visualizer/plot_base.h +++ b/rtc_tools/rtc_event_log_visualizer/plot_base.h @@ -16,6 +16,7 @@ #include #include "absl/base/attributes.h" +#include "absl/types/optional.h" #include "rtc_base/ignore_wundef.h" RTC_PUSH_IGNORING_WUNDEF() @@ -194,6 +195,10 @@ class PlotCollection { virtual Plot* AppendNewPlot(); + void SetCallTimeToUtcOffsetMs(int64_t calltime_to_utc_ms) { + calltime_to_utc_ms_ = calltime_to_utc_ms; + } + // Replaces PythonPlotCollection::Draw() void PrintPythonCode(bool shared_xaxis) const; @@ -202,6 +207,7 @@ class PlotCollection { protected: std::vector> plots_; + absl::optional calltime_to_utc_ms_; }; } // namespace webrtc diff --git a/rtc_tools/rtc_event_log_visualizer/proto/chart.proto b/rtc_tools/rtc_event_log_visualizer/proto/chart.proto index e5960b2677..f82d9c1ead 100644 --- a/rtc_tools/rtc_event_log_visualizer/proto/chart.proto +++ b/rtc_tools/rtc_event_log_visualizer/proto/chart.proto @@ -33,4 +33,8 @@ message Chart { message ChartCollection { repeated Chart charts = 1; + // `calltime_to_utc_ms` is the UTC time (in ms) for the x-axis in the charts. + // In other words, time t ms in the charts corresponds to + // t+calltime_to_utc_ms ms in UTC time. + int64 calltime_to_utc_ms = 2; } From 3ed1dbb56eb95487964535dde68fb59dae841976 Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Wed, 23 Feb 2022 19:27:48 +0100 Subject: [PATCH 041/847] In RtpPacketReceived delete deprecated accessors for handling time in ms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: None Change-Id: I02a43a16e8d9bf3a1e2c9f6442a1c119620e1288 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252286 Auto-Submit: Danil Chapovalov Reviewed-by: Erik Språng Commit-Queue: Erik Språng Cr-Commit-Position: refs/heads/main@{#36067} --- modules/rtp_rtcp/source/rtp_packet_received.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/modules/rtp_rtcp/source/rtp_packet_received.h b/modules/rtp_rtcp/source/rtp_packet_received.h index 431d3f52be..f290a643a4 100644 --- a/modules/rtp_rtcp/source/rtp_packet_received.h +++ b/modules/rtp_rtcp/source/rtp_packet_received.h @@ -14,7 +14,6 @@ #include -#include "absl/base/attributes.h" #include "api/array_view.h" #include "api/ref_counted_base.h" #include "api/rtp_headers.h" @@ -49,15 +48,6 @@ class RtpPacketReceived : public RtpPacket { webrtc::Timestamp arrival_time() const { return arrival_time_; } void set_arrival_time(webrtc::Timestamp time) { arrival_time_ = time; } - ABSL_DEPRECATED("Use arrival_time() instead") - int64_t arrival_time_ms() const { - return arrival_time_.IsMinusInfinity() ? -1 : arrival_time_.ms(); - } - ABSL_DEPRECATED("Use set_arrival_time() instead") - void set_arrival_time_ms(int64_t time) { - arrival_time_ = webrtc::Timestamp::Millis(time); - } - // Flag if packet was recovered via RTX or FEC. bool recovered() const { return recovered_; } void set_recovered(bool value) { recovered_ = value; } From 7306c75c12e6dd70e1f1a0904b6bda347423a556 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Terelius?= Date: Thu, 24 Feb 2022 15:46:57 +0000 Subject: [PATCH 042/847] Revert "Reland "Refactor AnalyzerConfig to use Timestamps instead of microseconds."" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 7a992e21b9c3ff03aa34488a9c91fa580ca4faa6. Reason for revert: Breaks downstream build due to type change. Original change's description: > Reland "Refactor AnalyzerConfig to use Timestamps instead of microseconds." > > This is a reland of 43fb16921b29ecd3a2d87876dda75c575e05f66a > > Original change's description: > > Refactor AnalyzerConfig to use Timestamps instead of microseconds. > > > > Add optional offset-to-UTC parameter to output. This allows aligning > > the x-axis in the generated charts to other UTC-based logs. > > > > Bug: b/215140373 > > Change-Id: I65bcd295718acbb8c94e363907c1abc458067bfd > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/250203 > > Reviewed-by: Kristoffer Erlandsson > > Commit-Queue: Björn Terelius > > Cr-Commit-Position: refs/heads/main@{#35992} > > Bug: b/215140373 > Change-Id: Id2b88cc4b8078a97275d49a617581cbbd02d2c6f > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252380 > Reviewed-by: Kristoffer Erlandsson > Commit-Queue: Björn Terelius > Cr-Commit-Position: refs/heads/main@{#36066} Bug: b/215140373 Change-Id: I951ac26b8176e58da18e93835f13f6b9deb6d4fa No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252443 Auto-Submit: Björn Terelius Bot-Commit: rubber-stamper@appspot.gserviceaccount.com Commit-Queue: Björn Terelius Cr-Commit-Position: refs/heads/main@{#36068} --- .../rtc_event_log/events/logged_rtp_rtcp.h | 16 -- .../events/rtc_event_alr_state.h | 1 - .../rtc_event_audio_network_adaptation.h | 1 - .../events/rtc_event_audio_playout.h | 1 - .../rtc_event_audio_receive_stream_config.h | 1 - .../rtc_event_audio_send_stream_config.h | 1 - .../events/rtc_event_begin_log.h | 1 - .../events/rtc_event_bwe_update_delay_based.h | 1 - .../events/rtc_event_bwe_update_loss_based.h | 1 - .../events/rtc_event_dtls_transport_state.h | 1 - .../events/rtc_event_dtls_writable_state.h | 1 - .../rtc_event_log/events/rtc_event_end_log.h | 1 - .../events/rtc_event_frame_decoded.h | 1 - .../events/rtc_event_generic_ack_received.h | 1 - .../rtc_event_generic_packet_received.h | 1 - .../events/rtc_event_generic_packet_sent.h | 1 - .../events/rtc_event_ice_candidate_pair.h | 1 - .../rtc_event_ice_candidate_pair_config.h | 1 - .../events/rtc_event_probe_cluster_created.h | 1 - .../events/rtc_event_probe_result_failure.h | 1 - .../events/rtc_event_probe_result_success.h | 1 - .../events/rtc_event_remote_estimate.h | 1 - .../events/rtc_event_route_change.h | 1 - .../rtc_event_video_receive_stream_config.h | 1 - .../rtc_event_video_send_stream_config.h | 1 - logging/rtc_event_log/rtc_event_log_parser.cc | 24 +-- logging/rtc_event_log/rtc_event_log_parser.h | 8 +- .../rtc_event_log/rtc_event_log_unittest.cc | 4 +- rtc_tools/rtc_event_log_visualizer/alerts.cc | 18 +-- .../rtc_event_log_visualizer/analyze_audio.cc | 22 +-- .../rtc_event_log_visualizer/analyzer.cc | 149 +++++++++--------- .../analyzer_common.h | 42 ++--- rtc_tools/rtc_event_log_visualizer/main.cc | 9 +- .../rtc_event_log_visualizer/plot_base.cc | 6 +- .../rtc_event_log_visualizer/plot_base.h | 6 - .../proto/chart.proto | 4 - 36 files changed, 129 insertions(+), 203 deletions(-) diff --git a/logging/rtc_event_log/events/logged_rtp_rtcp.h b/logging/rtc_event_log/events/logged_rtp_rtcp.h index 053a16371d..179d70dd63 100644 --- a/logging/rtc_event_log/events/logged_rtp_rtcp.h +++ b/logging/rtc_event_log/events/logged_rtp_rtcp.h @@ -41,7 +41,6 @@ struct LoggedRtpPacket { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp; // TODO(terelius): This allocates space for 15 CSRCs even if none are used. @@ -58,7 +57,6 @@ struct LoggedRtpPacketIncoming { : rtp(timestamp, header, header_length, total_length) {} int64_t log_time_us() const { return rtp.timestamp.us(); } int64_t log_time_ms() const { return rtp.timestamp.ms(); } - Timestamp log_time() const { return rtp.timestamp; } LoggedRtpPacket rtp; }; @@ -71,7 +69,6 @@ struct LoggedRtpPacketOutgoing { : rtp(timestamp, header, header_length, total_length) {} int64_t log_time_us() const { return rtp.timestamp.us(); } int64_t log_time_ms() const { return rtp.timestamp.ms(); } - Timestamp log_time() const { return rtp.timestamp; } LoggedRtpPacket rtp; }; @@ -90,7 +87,6 @@ struct LoggedRtcpPacket { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp; std::vector raw_data; @@ -105,7 +101,6 @@ struct LoggedRtcpPacketIncoming { int64_t log_time_us() const { return rtcp.timestamp.us(); } int64_t log_time_ms() const { return rtcp.timestamp.ms(); } - Timestamp log_time() const { return rtcp.timestamp; } LoggedRtcpPacket rtcp; }; @@ -119,7 +114,6 @@ struct LoggedRtcpPacketOutgoing { int64_t log_time_us() const { return rtcp.timestamp.us(); } int64_t log_time_ms() const { return rtcp.timestamp.ms(); } - Timestamp log_time() const { return rtcp.timestamp; } LoggedRtcpPacket rtcp; }; @@ -132,7 +126,6 @@ struct LoggedRtcpPacketReceiverReport { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::ReceiverReport rr; @@ -146,7 +139,6 @@ struct LoggedRtcpPacketSenderReport { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::SenderReport sr; @@ -157,7 +149,6 @@ struct LoggedRtcpPacketExtendedReports { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::ExtendedReports xr; @@ -170,7 +161,6 @@ struct LoggedRtcpPacketRemb { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::Remb remb; @@ -183,7 +173,6 @@ struct LoggedRtcpPacketNack { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::Nack nack; @@ -194,7 +183,6 @@ struct LoggedRtcpPacketFir { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::Fir fir; @@ -205,7 +193,6 @@ struct LoggedRtcpPacketPli { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::Pli pli; @@ -222,7 +209,6 @@ struct LoggedRtcpPacketTransportFeedback { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::TransportFeedback transport_feedback; @@ -237,7 +223,6 @@ struct LoggedRtcpPacketLossNotification { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::LossNotification loss_notification; @@ -248,7 +233,6 @@ struct LoggedRtcpPacketBye { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::Bye bye; diff --git a/logging/rtc_event_log/events/rtc_event_alr_state.h b/logging/rtc_event_log/events/rtc_event_alr_state.h index 9f595ecd90..44e68a680e 100644 --- a/logging/rtc_event_log/events/rtc_event_alr_state.h +++ b/logging/rtc_event_log/events/rtc_event_alr_state.h @@ -32,7 +32,6 @@ struct LoggedAlrStateEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); bool in_alr; diff --git a/logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h b/logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h index d4cae3abfa..b9e919c2e8 100644 --- a/logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h +++ b/logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h @@ -31,7 +31,6 @@ struct LoggedAudioNetworkAdaptationEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); AudioEncoderRuntimeConfig config; diff --git a/logging/rtc_event_log/events/rtc_event_audio_playout.h b/logging/rtc_event_log/events/rtc_event_audio_playout.h index 196c3ca247..3788324d15 100644 --- a/logging/rtc_event_log/events/rtc_event_audio_playout.h +++ b/logging/rtc_event_log/events/rtc_event_audio_playout.h @@ -32,7 +32,6 @@ struct LoggedAudioPlayoutEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); uint32_t ssrc; diff --git a/logging/rtc_event_log/events/rtc_event_audio_receive_stream_config.h b/logging/rtc_event_log/events/rtc_event_audio_receive_stream_config.h index 9863e235af..ac8813c937 100644 --- a/logging/rtc_event_log/events/rtc_event_audio_receive_stream_config.h +++ b/logging/rtc_event_log/events/rtc_event_audio_receive_stream_config.h @@ -30,7 +30,6 @@ struct LoggedAudioRecvConfig { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtclog::StreamConfig config; diff --git a/logging/rtc_event_log/events/rtc_event_audio_send_stream_config.h b/logging/rtc_event_log/events/rtc_event_audio_send_stream_config.h index 550723bcf0..8b699e71cf 100644 --- a/logging/rtc_event_log/events/rtc_event_audio_send_stream_config.h +++ b/logging/rtc_event_log/events/rtc_event_audio_send_stream_config.h @@ -29,7 +29,6 @@ struct LoggedAudioSendConfig { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtclog::StreamConfig config; diff --git a/logging/rtc_event_log/events/rtc_event_begin_log.h b/logging/rtc_event_log/events/rtc_event_begin_log.h index f3b74c117e..8dc47b5a02 100644 --- a/logging/rtc_event_log/events/rtc_event_begin_log.h +++ b/logging/rtc_event_log/events/rtc_event_begin_log.h @@ -35,7 +35,6 @@ struct LoggedStartEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp utc_time() const { return utc_start_time; } diff --git a/logging/rtc_event_log/events/rtc_event_bwe_update_delay_based.h b/logging/rtc_event_log/events/rtc_event_bwe_update_delay_based.h index 796f119388..4f145de412 100644 --- a/logging/rtc_event_log/events/rtc_event_bwe_update_delay_based.h +++ b/logging/rtc_event_log/events/rtc_event_bwe_update_delay_based.h @@ -76,7 +76,6 @@ struct LoggedBweDelayBasedUpdate { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); int32_t bitrate_bps; diff --git a/logging/rtc_event_log/events/rtc_event_bwe_update_loss_based.h b/logging/rtc_event_log/events/rtc_event_bwe_update_loss_based.h index fd41b316e0..1caf818a0c 100644 --- a/logging/rtc_event_log/events/rtc_event_bwe_update_loss_based.h +++ b/logging/rtc_event_log/events/rtc_event_bwe_update_loss_based.h @@ -37,7 +37,6 @@ struct LoggedBweLossBasedUpdate { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); int32_t bitrate_bps; diff --git a/logging/rtc_event_log/events/rtc_event_dtls_transport_state.h b/logging/rtc_event_log/events/rtc_event_dtls_transport_state.h index b9af213256..c2496dd532 100644 --- a/logging/rtc_event_log/events/rtc_event_dtls_transport_state.h +++ b/logging/rtc_event_log/events/rtc_event_dtls_transport_state.h @@ -26,7 +26,6 @@ namespace webrtc { struct LoggedDtlsTransportState { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); DtlsTransportState dtls_transport_state; diff --git a/logging/rtc_event_log/events/rtc_event_dtls_writable_state.h b/logging/rtc_event_log/events/rtc_event_dtls_writable_state.h index c820f184d7..20221df9da 100644 --- a/logging/rtc_event_log/events/rtc_event_dtls_writable_state.h +++ b/logging/rtc_event_log/events/rtc_event_dtls_writable_state.h @@ -28,7 +28,6 @@ struct LoggedDtlsWritableState { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); bool writable; diff --git a/logging/rtc_event_log/events/rtc_event_end_log.h b/logging/rtc_event_log/events/rtc_event_end_log.h index 79648bdb8d..ed7770f339 100644 --- a/logging/rtc_event_log/events/rtc_event_end_log.h +++ b/logging/rtc_event_log/events/rtc_event_end_log.h @@ -32,7 +32,6 @@ struct LoggedStopEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::PlusInfinity(); }; diff --git a/logging/rtc_event_log/events/rtc_event_frame_decoded.h b/logging/rtc_event_log/events/rtc_event_frame_decoded.h index 91190faea9..db5162cd0d 100644 --- a/logging/rtc_event_log/events/rtc_event_frame_decoded.h +++ b/logging/rtc_event_log/events/rtc_event_frame_decoded.h @@ -29,7 +29,6 @@ namespace webrtc { struct LoggedFrameDecoded { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); int64_t render_time_ms; diff --git a/logging/rtc_event_log/events/rtc_event_generic_ack_received.h b/logging/rtc_event_log/events/rtc_event_generic_ack_received.h index 57fd7cd9a6..d1ad0f1fef 100644 --- a/logging/rtc_event_log/events/rtc_event_generic_ack_received.h +++ b/logging/rtc_event_log/events/rtc_event_generic_ack_received.h @@ -36,7 +36,6 @@ struct LoggedGenericAckReceived { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); int64_t packet_number; diff --git a/logging/rtc_event_log/events/rtc_event_generic_packet_received.h b/logging/rtc_event_log/events/rtc_event_generic_packet_received.h index a6006ca4d4..fddee67740 100644 --- a/logging/rtc_event_log/events/rtc_event_generic_packet_received.h +++ b/logging/rtc_event_log/events/rtc_event_generic_packet_received.h @@ -33,7 +33,6 @@ struct LoggedGenericPacketReceived { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); int64_t packet_number; diff --git a/logging/rtc_event_log/events/rtc_event_generic_packet_sent.h b/logging/rtc_event_log/events/rtc_event_generic_packet_sent.h index 903950a398..0f839ca949 100644 --- a/logging/rtc_event_log/events/rtc_event_generic_packet_sent.h +++ b/logging/rtc_event_log/events/rtc_event_generic_packet_sent.h @@ -37,7 +37,6 @@ struct LoggedGenericPacketSent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } size_t packet_length() const { return payload_length + padding_length + overhead_length; diff --git a/logging/rtc_event_log/events/rtc_event_ice_candidate_pair.h b/logging/rtc_event_log/events/rtc_event_ice_candidate_pair.h index bdacf15a59..85cf79735a 100644 --- a/logging/rtc_event_log/events/rtc_event_ice_candidate_pair.h +++ b/logging/rtc_event_log/events/rtc_event_ice_candidate_pair.h @@ -45,7 +45,6 @@ struct LoggedIceCandidatePairEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); IceCandidatePairEventType type; diff --git a/logging/rtc_event_log/events/rtc_event_ice_candidate_pair_config.h b/logging/rtc_event_log/events/rtc_event_ice_candidate_pair_config.h index e72d999cff..0dfbfc838a 100644 --- a/logging/rtc_event_log/events/rtc_event_ice_candidate_pair_config.h +++ b/logging/rtc_event_log/events/rtc_event_ice_candidate_pair_config.h @@ -72,7 +72,6 @@ enum class IceCandidateNetworkType { struct LoggedIceCandidatePairConfig { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); IceCandidatePairConfigType type; diff --git a/logging/rtc_event_log/events/rtc_event_probe_cluster_created.h b/logging/rtc_event_log/events/rtc_event_probe_cluster_created.h index ae6810c39d..b91d89c239 100644 --- a/logging/rtc_event_log/events/rtc_event_probe_cluster_created.h +++ b/logging/rtc_event_log/events/rtc_event_probe_cluster_created.h @@ -39,7 +39,6 @@ struct LoggedBweProbeClusterCreatedEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); int32_t id; diff --git a/logging/rtc_event_log/events/rtc_event_probe_result_failure.h b/logging/rtc_event_log/events/rtc_event_probe_result_failure.h index 1aa6e75cb7..ba4db75c66 100644 --- a/logging/rtc_event_log/events/rtc_event_probe_result_failure.h +++ b/logging/rtc_event_log/events/rtc_event_probe_result_failure.h @@ -40,7 +40,6 @@ struct LoggedBweProbeFailureEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); int32_t id; diff --git a/logging/rtc_event_log/events/rtc_event_probe_result_success.h b/logging/rtc_event_log/events/rtc_event_probe_result_success.h index 49d1abec5a..172e9aa2eb 100644 --- a/logging/rtc_event_log/events/rtc_event_probe_result_success.h +++ b/logging/rtc_event_log/events/rtc_event_probe_result_success.h @@ -33,7 +33,6 @@ struct LoggedBweProbeSuccessEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); int32_t id; diff --git a/logging/rtc_event_log/events/rtc_event_remote_estimate.h b/logging/rtc_event_log/events/rtc_event_remote_estimate.h index 4a39ecc597..17de63c475 100644 --- a/logging/rtc_event_log/events/rtc_event_remote_estimate.h +++ b/logging/rtc_event_log/events/rtc_event_remote_estimate.h @@ -28,7 +28,6 @@ struct LoggedRemoteEstimateEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); absl::optional link_capacity_lower; diff --git a/logging/rtc_event_log/events/rtc_event_route_change.h b/logging/rtc_event_log/events/rtc_event_route_change.h index bc1461d7bb..542d15e3b3 100644 --- a/logging/rtc_event_log/events/rtc_event_route_change.h +++ b/logging/rtc_event_log/events/rtc_event_route_change.h @@ -29,7 +29,6 @@ struct LoggedRouteChangeEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); bool connected; diff --git a/logging/rtc_event_log/events/rtc_event_video_receive_stream_config.h b/logging/rtc_event_log/events/rtc_event_video_receive_stream_config.h index 0be56c2065..f3380d1bb6 100644 --- a/logging/rtc_event_log/events/rtc_event_video_receive_stream_config.h +++ b/logging/rtc_event_log/events/rtc_event_video_receive_stream_config.h @@ -30,7 +30,6 @@ struct LoggedVideoRecvConfig { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtclog::StreamConfig config; diff --git a/logging/rtc_event_log/events/rtc_event_video_send_stream_config.h b/logging/rtc_event_log/events/rtc_event_video_send_stream_config.h index f1717b19ea..15c28999dc 100644 --- a/logging/rtc_event_log/events/rtc_event_video_send_stream_config.h +++ b/logging/rtc_event_log/events/rtc_event_video_send_stream_config.h @@ -30,7 +30,6 @@ struct LoggedVideoSendConfig { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } - Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtclog::StreamConfig config; diff --git a/logging/rtc_event_log/rtc_event_log_parser.cc b/logging/rtc_event_log/rtc_event_log_parser.cc index b4392e8088..f0d165bdb2 100644 --- a/logging/rtc_event_log/rtc_event_log_parser.cc +++ b/logging/rtc_event_log/rtc_event_log_parser.cc @@ -1110,8 +1110,8 @@ void ParsedRtcEventLog::Clear() { last_incoming_rtcp_packet_.clear(); - first_timestamp_ = Timestamp::PlusInfinity(); - last_timestamp_ = Timestamp::MinusInfinity(); + first_timestamp_ = std::numeric_limits::max(); + last_timestamp_ = std::numeric_limits::min(); first_log_segment_ = LogSegment(0, std::numeric_limits::max()); incoming_rtp_extensions_maps_.clear(); @@ -1232,8 +1232,8 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::ParseStream( // stream configurations and starting/stopping the log. // TODO(terelius): Figure out if we actually need to find the first and last // timestamp in the parser. It seems like this could be done by the caller. - first_timestamp_ = Timestamp::PlusInfinity(); - last_timestamp_ = Timestamp::MinusInfinity(); + first_timestamp_ = std::numeric_limits::max(); + last_timestamp_ = std::numeric_limits::min(); StoreFirstAndLastTimestamp(alr_state_events()); StoreFirstAndLastTimestamp(route_change_events()); for (const auto& audio_stream : audio_playout_events()) { @@ -1272,8 +1272,7 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::ParseStream( // event, we could use the timestamp of the the last previous regular event. auto start_iter = start_log_events().begin(); auto stop_iter = stop_log_events().begin(); - int64_t start_us = - first_timestamp().us_or(std::numeric_limits::max()); + int64_t start_us = first_timestamp(); int64_t next_start_us = std::numeric_limits::max(); int64_t stop_us = std::numeric_limits::max(); if (start_iter != start_log_events().end()) { @@ -1287,14 +1286,15 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::ParseStream( } stop_us = std::min(stop_us, next_start_us); if (stop_us == std::numeric_limits::max() && - !last_timestamp().IsMinusInfinity()) { - stop_us = last_timestamp().us(); + last_timestamp() != std::numeric_limits::min()) { + stop_us = last_timestamp(); } RTC_PARSE_CHECK_OR_RETURN_LE(start_us, stop_us); first_log_segment_ = LogSegment(start_us, stop_us); - if (first_timestamp_ > last_timestamp_) { - first_timestamp_ = last_timestamp_ = Timestamp::Zero(); + if (first_timestamp_ == std::numeric_limits::max() && + last_timestamp_ == std::numeric_limits::min()) { + first_timestamp_ = last_timestamp_ = 0; } return status; @@ -1563,8 +1563,8 @@ template void ParsedRtcEventLog::StoreFirstAndLastTimestamp(const std::vector& v) { if (v.empty()) return; - first_timestamp_ = std::min(first_timestamp_, v.front().log_time()); - last_timestamp_ = std::max(last_timestamp_, v.back().log_time()); + first_timestamp_ = std::min(first_timestamp_, v.front().log_time_us()); + last_timestamp_ = std::max(last_timestamp_, v.back().log_time_us()); } ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreParsedLegacyEvent( diff --git a/logging/rtc_event_log/rtc_event_log_parser.h b/logging/rtc_event_log/rtc_event_log_parser.h index 9ef4e347de..4a9ff3495f 100644 --- a/logging/rtc_event_log/rtc_event_log_parser.h +++ b/logging/rtc_event_log/rtc_event_log_parser.h @@ -643,8 +643,8 @@ class ParsedRtcEventLog { return decoded_frames_; } - Timestamp first_timestamp() const { return first_timestamp_; } - Timestamp last_timestamp() const { return last_timestamp_; } + int64_t first_timestamp() const { return first_timestamp_; } + int64_t last_timestamp() const { return last_timestamp_; } const LogSegment& first_log_segment() const { return first_log_segment_; } @@ -889,8 +889,8 @@ class ParsedRtcEventLog { std::vector last_incoming_rtcp_packet_; - Timestamp first_timestamp_ = Timestamp::PlusInfinity(); - Timestamp last_timestamp_ = Timestamp::MinusInfinity(); + int64_t first_timestamp_; + int64_t last_timestamp_; LogSegment first_log_segment_ = LogSegment(0, std::numeric_limits::max()); diff --git a/logging/rtc_event_log/rtc_event_log_unittest.cc b/logging/rtc_event_log/rtc_event_log_unittest.cc index 34904a5e02..8f32eecd8b 100644 --- a/logging/rtc_event_log/rtc_event_log_unittest.cc +++ b/logging/rtc_event_log/rtc_event_log_unittest.cc @@ -785,8 +785,8 @@ void RtcEventLogSession::ReadAndVerifyLog() { parsed_generic_acks_received[i]); } - EXPECT_EQ(first_timestamp_ms_, parsed_log.first_timestamp().ms()); - EXPECT_EQ(last_timestamp_ms_, parsed_log.last_timestamp().ms()); + EXPECT_EQ(first_timestamp_ms_, parsed_log.first_timestamp() / 1000); + EXPECT_EQ(last_timestamp_ms_, parsed_log.last_timestamp() / 1000); EXPECT_EQ(parsed_log.first_log_segment().start_time_ms(), std::min(start_time_us_ / 1000, first_timestamp_ms_)); diff --git a/rtc_tools/rtc_event_log_visualizer/alerts.cc b/rtc_tools/rtc_event_log_visualizer/alerts.cc index c0d8784fa8..2d1868fa28 100644 --- a/rtc_tools/rtc_event_log_visualizer/alerts.cc +++ b/rtc_tools/rtc_event_log_visualizer/alerts.cc @@ -79,7 +79,7 @@ void TriageHelper::AnalyzeStreamGaps(const ParsedRtcEventLog& parsed_log, int64_t seq_num = seq_num_unwrapper.Unwrap(packet.header.sequenceNumber); if (std::abs(seq_num - last_seq_num) > kMaxSeqNumJump) { - Alert(seq_num_alert, config_.GetCallTimeSec(packet.log_time()), + Alert(seq_num_alert, config_.GetCallTimeSec(packet.log_time_us()), seq_num_explanation); } last_seq_num = seq_num; @@ -89,7 +89,7 @@ void TriageHelper::AnalyzeStreamGaps(const ParsedRtcEventLog& parsed_log, if (std::abs(capture_time - last_capture_time) > kTicksPerMillisec * (kCaptureTimeGraceMs + packet.log_time_ms() - last_log_time_ms)) { - Alert(capture_time_alert, config_.GetCallTimeSec(packet.log_time()), + Alert(capture_time_alert, config_.GetCallTimeSec(packet.log_time_us()), capture_time_explanation); } last_capture_time = capture_time; @@ -140,8 +140,7 @@ void TriageHelper::AnalyzeTransmissionGaps(const ParsedRtcEventLog& parsed_log, int64_t duration = timestamp - last_rtp_time.value_or(0); if (last_rtp_time.has_value() && duration > kMaxRtpTransmissionGap) { // No packet sent/received for more than 500 ms. - Alert(rtp_alert, config_.GetCallTimeSec(Timestamp::Micros(timestamp)), - rtp_explanation); + Alert(rtp_alert, config_.GetCallTimeSec(timestamp), rtp_explanation); } last_rtp_time.emplace(timestamp); } @@ -156,7 +155,7 @@ void TriageHelper::AnalyzeTransmissionGaps(const ParsedRtcEventLog& parsed_log, int64_t duration = rtcp.log_time_us() - last_rtcp_time.value_or(0); if (last_rtcp_time.has_value() && duration > kMaxRtcpTransmissionGap) { // No feedback sent/received for more than 2000 ms. - Alert(rtcp_alert, config_.GetCallTimeSec(rtcp.log_time()), + Alert(rtcp_alert, config_.GetCallTimeSec(rtcp.log_time_us()), rtcp_explanation); } last_rtcp_time.emplace(rtcp.log_time_us()); @@ -170,7 +169,7 @@ void TriageHelper::AnalyzeTransmissionGaps(const ParsedRtcEventLog& parsed_log, int64_t duration = rtcp.log_time_us() - last_rtcp_time.value_or(0); if (last_rtcp_time.has_value() && duration > kMaxRtcpTransmissionGap) { // No feedback sent/received for more than 2000 ms. - Alert(rtcp_alert, config_.GetCallTimeSec(rtcp.log_time()), + Alert(rtcp_alert, config_.GetCallTimeSec(rtcp.log_time_us()), rtcp_explanation); } last_rtcp_time.emplace(rtcp.log_time_us()); @@ -190,7 +189,7 @@ void TriageHelper::AnalyzeLog(const ParsedRtcEventLog& parsed_log) { const int64_t segment_end_us = parsed_log.first_log_segment().stop_time_us(); - Timestamp first_occurrence = parsed_log.last_timestamp(); + int64_t first_occurrence = parsed_log.last_timestamp(); constexpr double kMaxLossFraction = 0.05; // Loss feedback int64_t total_lost_packets = 0; @@ -205,14 +204,13 @@ void TriageHelper::AnalyzeLog(const ParsedRtcEventLog& parsed_log) { total_lost_packets += lost_packets; total_expected_packets += bwe_update.expected_packets; if (bwe_update.fraction_lost >= 255 * kMaxLossFraction) { - first_occurrence = std::min(first_occurrence, bwe_update.log_time()); + first_occurrence = std::min(first_occurrence, bwe_update.log_time_us()); } } double avg_outgoing_loss = static_cast(total_lost_packets) / total_expected_packets; if (avg_outgoing_loss > kMaxLossFraction) { - Alert(TriageAlertType::kOutgoingHighLoss, - config_.GetCallTimeSec(first_occurrence), + Alert(TriageAlertType::kOutgoingHighLoss, first_occurrence, "More than 5% of outgoing packets lost."); } } diff --git a/rtc_tools/rtc_event_log_visualizer/analyze_audio.cc b/rtc_tools/rtc_event_log_visualizer/analyze_audio.cc index 854c6d05ae..69a753bf22 100644 --- a/rtc_tools/rtc_event_log_visualizer/analyze_audio.cc +++ b/rtc_tools/rtc_event_log_visualizer/analyze_audio.cc @@ -38,7 +38,7 @@ void CreateAudioEncoderTargetBitrateGraph(const ParsedRtcEventLog& parsed_log, return absl::nullopt; }; auto ToCallTime = [config](const LoggedAudioNetworkAdaptationEvent& packet) { - return config.GetCallTimeSec(packet.log_time()); + return config.GetCallTimeSec(packet.log_time_us()); }; ProcessPoints( ToCallTime, GetAnaBitrateBps, @@ -63,7 +63,7 @@ void CreateAudioEncoderFrameLengthGraph(const ParsedRtcEventLog& parsed_log, return absl::optional(); }; auto ToCallTime = [config](const LoggedAudioNetworkAdaptationEvent& packet) { - return config.GetCallTimeSec(packet.log_time()); + return config.GetCallTimeSec(packet.log_time_us()); }; ProcessPoints( ToCallTime, GetAnaFrameLengthMs, @@ -88,7 +88,7 @@ void CreateAudioEncoderPacketLossGraph(const ParsedRtcEventLog& parsed_log, return absl::optional(); }; auto ToCallTime = [config](const LoggedAudioNetworkAdaptationEvent& packet) { - return config.GetCallTimeSec(packet.log_time()); + return config.GetCallTimeSec(packet.log_time_us()); }; ProcessPoints( ToCallTime, GetAnaPacketLoss, @@ -114,7 +114,7 @@ void CreateAudioEncoderEnableFecGraph(const ParsedRtcEventLog& parsed_log, return absl::optional(); }; auto ToCallTime = [config](const LoggedAudioNetworkAdaptationEvent& packet) { - return config.GetCallTimeSec(packet.log_time()); + return config.GetCallTimeSec(packet.log_time_us()); }; ProcessPoints( ToCallTime, GetAnaFecEnabled, @@ -139,7 +139,7 @@ void CreateAudioEncoderEnableDtxGraph(const ParsedRtcEventLog& parsed_log, return absl::optional(); }; auto ToCallTime = [config](const LoggedAudioNetworkAdaptationEvent& packet) { - return config.GetCallTimeSec(packet.log_time()); + return config.GetCallTimeSec(packet.log_time_us()); }; ProcessPoints( ToCallTime, GetAnaDtxEnabled, @@ -164,7 +164,7 @@ void CreateAudioEncoderNumChannelsGraph(const ParsedRtcEventLog& parsed_log, return absl::optional(); }; auto ToCallTime = [config](const LoggedAudioNetworkAdaptationEvent& packet) { - return config.GetCallTimeSec(packet.log_time()); + return config.GetCallTimeSec(packet.log_time_us()); }; ProcessPoints( ToCallTime, GetAnaNumChannels, @@ -397,23 +397,23 @@ void CreateAudioJitterBufferGraph(const ParsedRtcEventLog& parsed_log, PointStyle::kHighlight); for (const auto& data : arrival_delay_ms) { - const float x = config.GetCallTimeSec(Timestamp::Millis(data.first)); + const float x = config.GetCallTimeSec(data.first * 1000); // ms to us. const float y = data.second; time_series_packet_arrival.points.emplace_back(TimeSeriesPoint(x, y)); } for (const auto& data : corrected_arrival_delay_ms) { - const float x = config.GetCallTimeSec(Timestamp::Millis(data.first)); + const float x = config.GetCallTimeSec(data.first * 1000); // ms to us. const float y = data.second; time_series_relative_packet_arrival.points.emplace_back( TimeSeriesPoint(x, y)); } for (const auto& data : playout_delay_ms) { - const float x = config.GetCallTimeSec(Timestamp::Millis(data.first)); + const float x = config.GetCallTimeSec(data.first * 1000); // ms to us. const float y = data.second; time_series_play_time.points.emplace_back(TimeSeriesPoint(x, y)); } for (const auto& data : target_delay_ms) { - const float x = config.GetCallTimeSec(Timestamp::Millis(data.first)); + const float x = config.GetCallTimeSec(data.first * 1000); // ms to us. const float y = data.second; time_series_target_time.points.emplace_back(TimeSeriesPoint(x, y)); } @@ -448,7 +448,7 @@ void CreateNetEqStatsGraphInternal( const std::vector>* data_vector = data_extractor(st.second.get()); for (const auto& data : *data_vector) { - const float time = config.GetCallTimeSec(Timestamp::Millis(data.first)); + const float time = config.GetCallTimeSec(data.first * 1000); // ms to us. const float value = stats_extractor(data.second); time_series[ssrc].points.emplace_back(TimeSeriesPoint(time, value)); } diff --git a/rtc_tools/rtc_event_log_visualizer/analyzer.cc b/rtc_tools/rtc_event_log_visualizer/analyzer.cc index 4c718185df..b43801623c 100644 --- a/rtc_tools/rtc_event_log_visualizer/analyzer.cc +++ b/rtc_tools/rtc_event_log_visualizer/analyzer.cc @@ -214,7 +214,7 @@ TimeSeries CreateRtcpTypeTimeSeries(const std::vector& rtcp_list, int category_id) { TimeSeries time_series(rtcp_name, LineStyle::kNone, PointStyle::kHighlight); for (const auto& rtcp : rtcp_list) { - float x = config.GetCallTimeSec(rtcp.timestamp); + float x = config.GetCallTimeSec(rtcp.log_time_us()); float y = category_id; time_series.points.emplace_back(x, y); } @@ -346,24 +346,20 @@ std::string GetDirectionAsShortString(PacketDirection direction) { EventLogAnalyzer::EventLogAnalyzer(const ParsedRtcEventLog& log, bool normalize_time) : parsed_log_(log) { - config_.window_duration_ = TimeDelta::Millis(250); - config_.step_ = TimeDelta::Millis(10); - if (!log.start_log_events().empty()) { - config_.rtc_to_utc_offset_ = log.start_log_events()[0].utc_time() - - log.start_log_events()[0].log_time(); - } + config_.window_duration_ = 250000; + config_.step_ = 10000; config_.normalize_time_ = normalize_time; config_.begin_time_ = parsed_log_.first_timestamp(); config_.end_time_ = parsed_log_.last_timestamp(); if (config_.end_time_ < config_.begin_time_) { RTC_LOG(LS_WARNING) << "No useful events in the log."; - config_.begin_time_ = config_.end_time_ = Timestamp::Zero(); + config_.begin_time_ = config_.end_time_ = 0; } RTC_LOG(LS_INFO) << "Log is " - << (parsed_log_.last_timestamp().ms() - - parsed_log_.first_timestamp().ms()) / - 1000 + << (parsed_log_.last_timestamp() - + parsed_log_.first_timestamp()) / + 1000000 << " seconds long."; } @@ -371,9 +367,9 @@ EventLogAnalyzer::EventLogAnalyzer(const ParsedRtcEventLog& log, const AnalyzerConfig& config) : parsed_log_(log), config_(config) { RTC_LOG(LS_INFO) << "Log is " - << (parsed_log_.last_timestamp().ms() - - parsed_log_.first_timestamp().ms()) / - 1000 + << (parsed_log_.last_timestamp() - + parsed_log_.first_timestamp()) / + 1000000 << " seconds long."; } @@ -417,7 +413,7 @@ void EventLogAnalyzer::CreatePacketGraph(PacketDirection direction, return absl::optional(packet.total_length); }; auto ToCallTime = [this](const LoggedRtpPacket& packet) { - return this->config_.GetCallTimeSec(packet.timestamp); + return this->config_.GetCallTimeSec(packet.log_time_us()); }; ProcessPoints(ToCallTime, GetPacketSize, stream.packet_view, &time_series); @@ -473,7 +469,7 @@ void EventLogAnalyzer::CreateAccumulatedPacketsTimeSeries( const std::string& label) { TimeSeries time_series(label, LineStyle::kStep); for (size_t i = 0; i < packets.size(); i++) { - float x = config_.GetCallTimeSec(packets[i].log_time()); + float x = config_.GetCallTimeSec(packets[i].log_time_us()); time_series.points.emplace_back(x, i + 1); } plot->AppendTimeSeries(std::move(time_series)); @@ -549,15 +545,17 @@ void EventLogAnalyzer::CreateTotalPacketRateGraph(PacketDirection direction, // types using MovingAverage(). class LogTime { public: - explicit LogTime(Timestamp log_time) : log_time_(log_time) {} - Timestamp log_time() const { return log_time_; } + explicit LogTime(int64_t log_time_us) : log_time_us_(log_time_us) {} + + int64_t log_time_us() const { return log_time_us_; } private: - Timestamp log_time_; + int64_t log_time_us_; }; + std::vector packet_times; auto handle_rtp = [&](const LoggedRtpPacket& packet) { - packet_times.emplace_back(packet.log_time()); + packet_times.emplace_back(packet.log_time_us()); }; RtcEventProcessor process; for (const auto& stream : parsed_log_.rtp_packets_by_ssrc(direction)) { @@ -565,13 +563,13 @@ void EventLogAnalyzer::CreateTotalPacketRateGraph(PacketDirection direction, } if (direction == kIncomingPacket) { auto handle_incoming_rtcp = [&](const LoggedRtcpPacketIncoming& packet) { - packet_times.emplace_back(packet.log_time()); + packet_times.emplace_back(packet.log_time_us()); }; process.AddEvents(parsed_log_.incoming_rtcp_packets(), handle_incoming_rtcp); } else { auto handle_outgoing_rtcp = [&](const LoggedRtcpPacketOutgoing& packet) { - packet_times.emplace_back(packet.log_time()); + packet_times.emplace_back(packet.log_time_us()); }; process.AddEvents(parsed_log_.outgoing_rtcp_packets(), handle_outgoing_rtcp); @@ -601,7 +599,7 @@ void EventLogAnalyzer::CreatePlayoutGraph(Plot* plot) { absl::optional last_playout_ms; TimeSeries time_series(SsrcToString(ssrc), LineStyle::kBar); for (const auto& playout_event : playout_stream.second) { - float x = config_.GetCallTimeSec(playout_event.log_time()); + float x = config_.GetCallTimeSec(playout_event.log_time_us()); int64_t playout_time_ms = playout_event.log_time_ms(); // If there were no previous playouts, place the point on the x-axis. float y = playout_time_ms - last_playout_ms.value_or(playout_time_ms); @@ -628,7 +626,7 @@ void EventLogAnalyzer::CreateAudioLevelGraph(PacketDirection direction, LineStyle::kLine); for (auto& packet : stream.packet_view) { if (packet.header.extension.hasAudioLevel) { - float x = config_.GetCallTimeSec(packet.log_time()); + float x = config_.GetCallTimeSec(packet.log_time_us()); // The audio level is stored in -dBov (so e.g. -10 dBov is stored as 10) // Here we convert it to dBov. float y = static_cast(-packet.header.extension.audioLevel); @@ -664,7 +662,7 @@ void EventLogAnalyzer::CreateSequenceNumberGraph(Plot* plot) { return diff; }; auto ToCallTime = [this](const LoggedRtpPacketIncoming& packet) { - return this->config_.GetCallTimeSec(packet.log_time()); + return this->config_.GetCallTimeSec(packet.log_time_us()); }; ProcessPairs( ToCallTime, GetSequenceNumberDiff, stream.incoming_packets, @@ -693,8 +691,8 @@ void EventLogAnalyzer::CreateIncomingPacketLossGraph(Plot* plot) { LineStyle::kLine, PointStyle::kHighlight); // TODO(terelius): Should the window and step size be read from the class // instead? - const TimeDelta kWindow = TimeDelta::Millis(1000); - const TimeDelta kStep = TimeDelta::Millis(1000); + const int64_t kWindowUs = 1000000; + const int64_t kStep = 1000000; SeqNumUnwrapper unwrapper_; SeqNumUnwrapper prior_unwrapper_; size_t window_index_begin = 0; @@ -704,17 +702,17 @@ void EventLogAnalyzer::CreateIncomingPacketLossGraph(Plot* plot) { uint64_t highest_prior_seq_number = prior_unwrapper_.Unwrap(packets[0].rtp.header.sequenceNumber) - 1; - for (Timestamp t = config_.begin_time_; t < config_.end_time_ + kStep; + for (int64_t t = config_.begin_time_; t < config_.end_time_ + kStep; t += kStep) { while (window_index_end < packets.size() && - packets[window_index_end].rtp.log_time() < t) { + packets[window_index_end].rtp.log_time_us() < t) { uint64_t sequence_number = unwrapper_.Unwrap( packets[window_index_end].rtp.header.sequenceNumber); highest_seq_number = std::max(highest_seq_number, sequence_number); ++window_index_end; } while (window_index_begin < packets.size() && - packets[window_index_begin].rtp.log_time() < t - kWindow) { + packets[window_index_begin].rtp.log_time_us() < t - kWindowUs) { uint64_t sequence_number = prior_unwrapper_.Unwrap( packets[window_index_begin].rtp.header.sequenceNumber); highest_prior_seq_number = @@ -769,7 +767,7 @@ void EventLogAnalyzer::CreateIncomingDelayGraph(Plot* plot) { } auto ToCallTime = [this](const LoggedRtpPacketIncoming& packet) { - return this->config_.GetCallTimeSec(packet.log_time()); + return this->config_.GetCallTimeSec(packet.log_time_us()); }; auto ToNetworkDelay = [frequency_hz]( const LoggedRtpPacketIncoming& old_packet, @@ -805,7 +803,7 @@ void EventLogAnalyzer::CreateFractionLossGraph(Plot* plot) { TimeSeries time_series("Fraction lost", LineStyle::kLine, PointStyle::kHighlight); for (auto& bwe_update : parsed_log_.bwe_loss_updates()) { - float x = config_.GetCallTimeSec(bwe_update.log_time()); + float x = config_.GetCallTimeSec(bwe_update.log_time_us()); float y = static_cast(bwe_update.fraction_lost) / 255 * 100; time_series.points.emplace_back(x, y); } @@ -820,11 +818,11 @@ void EventLogAnalyzer::CreateFractionLossGraph(Plot* plot) { // Plot the total bandwidth used by all RTP streams. void EventLogAnalyzer::CreateTotalIncomingBitrateGraph(Plot* plot) { // TODO(terelius): This could be provided by the parser. - std::multimap packets_in_order; + std::multimap packets_in_order; for (const auto& stream : parsed_log_.incoming_rtp_packets_by_ssrc()) { for (const LoggedRtpPacketIncoming& packet : stream.incoming_packets) packets_in_order.insert( - std::make_pair(packet.rtp.log_time(), packet.rtp.total_length)); + std::make_pair(packet.rtp.log_time_us(), packet.rtp.total_length)); } auto window_begin = packets_in_order.begin(); @@ -834,7 +832,7 @@ void EventLogAnalyzer::CreateTotalIncomingBitrateGraph(Plot* plot) { if (!packets_in_order.empty()) { // Calculate a moving average of the bitrate and store in a TimeSeries. TimeSeries bitrate_series("Bitrate", LineStyle::kLine); - for (Timestamp time = config_.begin_time_; + for (int64_t time = config_.begin_time_; time < config_.end_time_ + config_.step_; time += config_.step_) { while (window_end != packets_in_order.end() && window_end->first < time) { bytes_in_window += window_end->second; @@ -847,8 +845,7 @@ void EventLogAnalyzer::CreateTotalIncomingBitrateGraph(Plot* plot) { ++window_begin; } float window_duration_in_seconds = - static_cast(config_.window_duration_.us()) / - kNumMicrosecsPerSec; + static_cast(config_.window_duration_) / kNumMicrosecsPerSec; float x = config_.GetCallTimeSec(time); float y = bytes_in_window * 8 / window_duration_in_seconds / 1000; bitrate_series.points.emplace_back(x, y); @@ -859,7 +856,7 @@ void EventLogAnalyzer::CreateTotalIncomingBitrateGraph(Plot* plot) { // Overlay the outgoing REMB over incoming bitrate. TimeSeries remb_series("Remb", LineStyle::kStep); for (const auto& rtcp : parsed_log_.rembs(kOutgoingPacket)) { - float x = config_.GetCallTimeSec(rtcp.log_time()); + float x = config_.GetCallTimeSec(rtcp.log_time_us()); float y = static_cast(rtcp.remb.bitrate_bps()) / 1000; remb_series.points.emplace_back(x, y); } @@ -887,11 +884,11 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, bool show_detector_state, bool show_alr_state) { // TODO(terelius): This could be provided by the parser. - std::multimap packets_in_order; + std::multimap packets_in_order; for (const auto& stream : parsed_log_.outgoing_rtp_packets_by_ssrc()) { for (const LoggedRtpPacketOutgoing& packet : stream.outgoing_packets) packets_in_order.insert( - std::make_pair(packet.rtp.log_time(), packet.rtp.total_length)); + std::make_pair(packet.rtp.log_time_us(), packet.rtp.total_length)); } auto window_begin = packets_in_order.begin(); @@ -901,7 +898,7 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, if (!packets_in_order.empty()) { // Calculate a moving average of the bitrate and store in a TimeSeries. TimeSeries bitrate_series("Bitrate", LineStyle::kLine); - for (Timestamp time = config_.begin_time_; + for (int64_t time = config_.begin_time_; time < config_.end_time_ + config_.step_; time += config_.step_) { while (window_end != packets_in_order.end() && window_end->first < time) { bytes_in_window += window_end->second; @@ -914,8 +911,7 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, ++window_begin; } float window_duration_in_seconds = - static_cast(config_.window_duration_.us()) / - kNumMicrosecsPerSec; + static_cast(config_.window_duration_) / kNumMicrosecsPerSec; float x = config_.GetCallTimeSec(time); float y = bytes_in_window * 8 / window_duration_in_seconds / 1000; bitrate_series.points.emplace_back(x, y); @@ -926,7 +922,7 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, // Overlay the send-side bandwidth estimate over the outgoing bitrate. TimeSeries loss_series("Loss-based estimate", LineStyle::kStep); for (auto& loss_update : parsed_log_.bwe_loss_updates()) { - float x = config_.GetCallTimeSec(loss_update.log_time()); + float x = config_.GetCallTimeSec(loss_update.log_time_us()); float y = static_cast(loss_update.bitrate_bps) / 1000; loss_series.points.emplace_back(x, y); } @@ -939,12 +935,12 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, IntervalSeries normal_series("Normal", "#c4ffc4", IntervalSeries::kHorizontal); IntervalSeries* last_series = &normal_series; - float last_detector_switch = 0.0; + double last_detector_switch = 0.0; BandwidthUsage last_detector_state = BandwidthUsage::kBwNormal; for (auto& delay_update : parsed_log_.bwe_delay_updates()) { - float x = config_.GetCallTimeSec(delay_update.log_time()); + float x = config_.GetCallTimeSec(delay_update.log_time_us()); float y = static_cast(delay_update.bitrate_bps) / 1000; if (last_detector_state != delay_update.detector_state) { @@ -971,13 +967,12 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, } RTC_CHECK(last_series); - last_series->intervals.emplace_back(last_detector_switch, - config_.CallEndTimeSec()); + last_series->intervals.emplace_back(last_detector_switch, config_.end_time_); TimeSeries created_series("Probe cluster created.", LineStyle::kNone, PointStyle::kHighlight); for (auto& cluster : parsed_log_.bwe_probe_cluster_created_events()) { - float x = config_.GetCallTimeSec(cluster.log_time()); + float x = config_.GetCallTimeSec(cluster.log_time_us()); float y = static_cast(cluster.bitrate_bps) / 1000; created_series.points.emplace_back(x, y); } @@ -985,7 +980,7 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, TimeSeries result_series("Probing results.", LineStyle::kNone, PointStyle::kHighlight); for (auto& result : parsed_log_.bwe_probe_success_events()) { - float x = config_.GetCallTimeSec(result.log_time()); + float x = config_.GetCallTimeSec(result.log_time_us()); float y = static_cast(result.bitrate_bps) / 1000; result_series.points.emplace_back(x, y); } @@ -993,17 +988,17 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, TimeSeries probe_failures_series("Probe failed", LineStyle::kNone, PointStyle::kHighlight); for (auto& failure : parsed_log_.bwe_probe_failure_events()) { - float x = config_.GetCallTimeSec(failure.log_time()); + float x = config_.GetCallTimeSec(failure.log_time_us()); probe_failures_series.points.emplace_back(x, 0); } IntervalSeries alr_state("ALR", "#555555", IntervalSeries::kHorizontal); bool previously_in_alr = false; - Timestamp alr_start = Timestamp::Zero(); + int64_t alr_start = 0; for (auto& alr : parsed_log_.alr_state_events()) { - float y = config_.GetCallTimeSec(alr.log_time()); + float y = config_.GetCallTimeSec(alr.log_time_us()); if (!previously_in_alr && alr.in_alr) { - alr_start = alr.log_time(); + alr_start = alr.log_time_us(); previously_in_alr = true; } else if (previously_in_alr && !alr.in_alr) { float x = config_.GetCallTimeSec(alr_start); @@ -1036,7 +1031,7 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, // Overlay the incoming REMB over the outgoing bitrate. TimeSeries remb_series("Remb", LineStyle::kStep); for (const auto& rtcp : parsed_log_.rembs(kIncomingPacket)) { - float x = config_.GetCallTimeSec(rtcp.log_time()); + float x = config_.GetCallTimeSec(rtcp.log_time_us()); float y = static_cast(rtcp.remb.bitrate_bps()) / 1000; remb_series.points.emplace_back(x, y); } @@ -1122,7 +1117,7 @@ void EventLogAnalyzer::CreateBitrateAllocationGraph(PacketDirection direction, std::make_pair(layer, TimeSeries(layer_name, LineStyle::kStep))); RTC_DCHECK(inserted); } - float x = config_.GetCallTimeSec(rtcp.log_time()); + float x = config_.GetCallTimeSec(rtcp.log_time_us()); float y = bitrate_item.target_bitrate_kbps; time_series_it->second.points.emplace_back(x, y); } @@ -1154,20 +1149,22 @@ void EventLogAnalyzer::CreateGoogCcSimulationGraph(Plot* plot) { [&](const NetworkControlUpdate& update, Timestamp at_time) { if (update.target_rate) { target_rates.points.emplace_back( - config_.GetCallTimeSec(at_time), + config_.GetCallTimeSec(at_time.us()), update.target_rate->target_rate.kbps()); } }); simulation.ProcessEventsInLog(parsed_log_); for (const auto& logged : parsed_log_.bwe_delay_updates()) - delay_based.points.emplace_back(config_.GetCallTimeSec(logged.log_time()), - logged.bitrate_bps / 1000); + delay_based.points.emplace_back( + config_.GetCallTimeSec(logged.log_time_us()), + logged.bitrate_bps / 1000); for (const auto& logged : parsed_log_.bwe_probe_success_events()) - probe_results.points.emplace_back(config_.GetCallTimeSec(logged.log_time()), - logged.bitrate_bps / 1000); + probe_results.points.emplace_back( + config_.GetCallTimeSec(logged.log_time_us()), + logged.bitrate_bps / 1000); for (const auto& logged : parsed_log_.bwe_loss_updates()) - loss_based.points.emplace_back(config_.GetCallTimeSec(logged.log_time()), + loss_based.points.emplace_back(config_.GetCallTimeSec(logged.log_time_us()), logged.bitrate_bps / 1000); plot->AppendTimeSeries(std::move(delay_based)); @@ -1327,7 +1324,7 @@ void EventLogAnalyzer::CreateSendSideBweSimulationGraph(Plot* plot) { } } - float x = config_.GetCallTimeSec(clock.CurrentTime()); + float x = config_.GetCallTimeSec(clock.TimeInMicroseconds()); float y = bitrate_bps.value_or(0) / 1000; acked_time_series.points.emplace_back(x, y); y = robust_throughput_estimator->bitrate() @@ -1350,7 +1347,7 @@ void EventLogAnalyzer::CreateSendSideBweSimulationGraph(Plot* plot) { if (observer.GetAndResetBitrateUpdated() || time_us - last_update_us >= 1e6) { uint32_t y = observer.last_bitrate_bps() / 1000; - float x = config_.GetCallTimeSec(clock.CurrentTime()); + float x = config_.GetCallTimeSec(clock.TimeInMicroseconds()); time_series.points.emplace_back(x, y); last_update_us = time_us; } @@ -1426,13 +1423,13 @@ void EventLogAnalyzer::CreateReceiveSideBweSimulationGraph(Plot* plot) { absl::optional bitrate_bps = acked_bitrate.Rate(arrival_time_ms); if (bitrate_bps) { uint32_t y = *bitrate_bps / 1000; - float x = config_.GetCallTimeSec(clock.CurrentTime()); + float x = config_.GetCallTimeSec(clock.TimeInMicroseconds()); acked_time_series.points.emplace_back(x, y); } if (remb_interceptor.GetAndResetBitrateUpdated() || clock.TimeInMicroseconds() - last_update_us >= 1e6) { uint32_t y = remb_interceptor.last_bitrate_bps() / 1000; - float x = config_.GetCallTimeSec(clock.CurrentTime()); + float x = config_.GetCallTimeSec(clock.TimeInMicroseconds()); time_series.points.emplace_back(x, y); last_update_us = clock.TimeInMicroseconds(); } @@ -1464,7 +1461,7 @@ void EventLogAnalyzer::CreateNetworkDelayFeedbackGraph(Plot* plot) { for (const auto& packet : matched_rtp_rtcp) { if (packet.arrival_time_ms == MatchedSendArrivalTimes::kNotReceived) continue; - float x = config_.GetCallTimeSecFromMs(packet.feedback_arrival_time_ms); + float x = config_.GetCallTimeSec(1000 * packet.feedback_arrival_time_ms); int64_t y = packet.arrival_time_ms - packet.send_time_ms; int64_t rtt_ms = packet.feedback_arrival_time_ms - packet.send_time_ms; min_rtt_ms = std::min(rtt_ms, min_rtt_ms); @@ -1533,7 +1530,7 @@ void EventLogAnalyzer::CreatePacerDelayGraph(Plot* plot) { double send_time_ms = static_cast(packet.rtp.log_time_us() - first_send_timestamp) / 1000; - float x = config_.GetCallTimeSec(packet.rtp.log_time()); + float x = config_.GetCallTimeSec(packet.rtp.log_time_us()); float y = send_time_ms - capture_time_ms; pacer_delay_series.points.emplace_back(x, y); } @@ -1554,7 +1551,7 @@ void EventLogAnalyzer::CreateTimestampGraph(PacketDirection direction, GetStreamName(parsed_log_, direction, stream.ssrc) + " capture-time", LineStyle::kLine, PointStyle::kHighlight); for (const auto& packet : stream.packet_view) { - float x = config_.GetCallTimeSec(packet.log_time()); + float x = config_.GetCallTimeSec(packet.log_time_us()); float y = packet.header.timestamp; rtp_timestamps.points.emplace_back(x, y); } @@ -1569,7 +1566,7 @@ void EventLogAnalyzer::CreateTimestampGraph(PacketDirection direction, for (const auto& rtcp : sender_reports) { if (rtcp.sr.sender_ssrc() != stream.ssrc) continue; - float x = config_.GetCallTimeSec(rtcp.log_time()); + float x = config_.GetCallTimeSec(rtcp.log_time_us()); float y = rtcp.sr.rtp_timestamp(); rtcp_timestamps.points.emplace_back(x, y); } @@ -1591,7 +1588,7 @@ void EventLogAnalyzer::CreateSenderAndReceiverReportPlot( std::map sr_reports_by_ssrc; const auto& sender_reports = parsed_log_.sender_reports(direction); for (const auto& rtcp : sender_reports) { - float x = config_.GetCallTimeSec(rtcp.log_time()); + float x = config_.GetCallTimeSec(rtcp.log_time_us()); uint32_t ssrc = rtcp.sr.sender_ssrc(); for (const auto& block : rtcp.sr.report_blocks()) { float y = fy(block); @@ -1613,7 +1610,7 @@ void EventLogAnalyzer::CreateSenderAndReceiverReportPlot( std::map rr_reports_by_ssrc; const auto& receiver_reports = parsed_log_.receiver_reports(direction); for (const auto& rtcp : receiver_reports) { - float x = config_.GetCallTimeSec(rtcp.log_time()); + float x = config_.GetCallTimeSec(rtcp.log_time_us()); uint32_t ssrc = rtcp.rr.sender_ssrc(); for (const auto& block : rtcp.rr.report_blocks()) { float y = fy(block); @@ -1652,7 +1649,7 @@ void EventLogAnalyzer::CreateIceCandidatePairConfigGraph(Plot* plot) { candidate_pair_desc_by_id_[config.candidate_pair_id] = candidate_pair_desc; } - float x = config_.GetCallTimeSec(config.log_time()); + float x = config_.GetCallTimeSec(config.log_time_us()); float y = static_cast(config.type); configs_by_cp_id[config.candidate_pair_id].points.emplace_back(x, y); } @@ -1709,7 +1706,7 @@ void EventLogAnalyzer::CreateIceConnectivityCheckGraph(Plot* plot) { GetCandidatePairLogDescriptionFromId(event.candidate_pair_id), LineStyle::kNone, PointStyle::kHighlight); } - float x = config_.GetCallTimeSec(event.log_time()); + float x = config_.GetCallTimeSec(event.log_time_us()); float y = static_cast(event.type) + kEventTypeOffset; checks_by_cp_id[event.candidate_pair_id].points.emplace_back(x, y); } @@ -1744,7 +1741,7 @@ void EventLogAnalyzer::CreateDtlsTransportStateGraph(Plot* plot) { TimeSeries states("DTLS Transport State", LineStyle::kNone, PointStyle::kHighlight); for (const auto& event : parsed_log_.dtls_transport_states()) { - float x = config_.GetCallTimeSec(event.log_time()); + float x = config_.GetCallTimeSec(event.log_time_us()); float y = static_cast(event.dtls_transport_state); states.points.emplace_back(x, y); } @@ -1766,7 +1763,7 @@ void EventLogAnalyzer::CreateDtlsWritableStateGraph(Plot* plot) { TimeSeries writable("DTLS Writable", LineStyle::kNone, PointStyle::kHighlight); for (const auto& event : parsed_log_.dtls_writable_states()) { - float x = config_.GetCallTimeSec(event.log_time()); + float x = config_.GetCallTimeSec(event.log_time_us()); float y = static_cast(event.writable); writable.points.emplace_back(x, y); } diff --git a/rtc_tools/rtc_event_log_visualizer/analyzer_common.h b/rtc_tools/rtc_event_log_visualizer/analyzer_common.h index b0b556aa62..a4305a708f 100644 --- a/rtc_tools/rtc_event_log_visualizer/analyzer_common.h +++ b/rtc_tools/rtc_event_log_visualizer/analyzer_common.h @@ -22,7 +22,6 @@ namespace webrtc { constexpr int kNumMicrosecsPerSec = 1000000; -constexpr int kNumMillisecsPerSec = 1000; constexpr float kLeftMargin = 0.01f; constexpr float kRightMargin = 0.02f; constexpr float kBottomMargin = 0.02f; @@ -30,38 +29,25 @@ constexpr float kTopMargin = 0.05f; class AnalyzerConfig { public: - float GetCallTimeSec(Timestamp timestamp) const { - Timestamp offset = normalize_time_ ? begin_time_ : Timestamp::Zero(); - return static_cast((timestamp - offset).us()) / 1000000; - } - - float GetCallTimeSecFromMs(int64_t timestamp_ms) const { - return GetCallTimeSec(Timestamp::Millis(timestamp_ms)); + float GetCallTimeSec(int64_t timestamp_us) const { + int64_t offset = normalize_time_ ? begin_time_ : 0; + return static_cast(timestamp_us - offset) / 1000000; } float CallBeginTimeSec() const { return GetCallTimeSec(begin_time_); } float CallEndTimeSec() const { return GetCallTimeSec(end_time_); } - int64_t CallTimeToUtcOffsetMs() { - if (normalize_time_) { - Timestamp utc_begin_time_ = begin_time_ + rtc_to_utc_offset_; - return utc_begin_time_.ms(); - } - return rtc_to_utc_offset_.ms(); - } - // Window and step size used for calculating moving averages, e.g. bitrate. - // The generated data points will be `step_.ms()` milliseconds apart. - // Only events occurring at most `window_duration_.ms()` milliseconds before - // the current data point will be part of the average. - TimeDelta window_duration_ = TimeDelta::Millis(250); - TimeDelta step_ = TimeDelta::Millis(10); + // The generated data points will be `step_` microseconds apart. + // Only events occurring at most `window_duration_` microseconds before the + // current data point will be part of the average. + int64_t window_duration_; + int64_t step_; // First and last events of the log. - Timestamp begin_time_ = Timestamp::MinusInfinity(); - Timestamp end_time_ = Timestamp::MinusInfinity(); - TimeDelta rtc_to_utc_offset_ = TimeDelta::Zero(); + int64_t begin_time_; + int64_t end_time_; bool normalize_time_; }; @@ -166,17 +152,17 @@ void MovingAverage( size_t window_index_end = 0; ResultType sum_in_window = 0; - for (Timestamp t = config.begin_time_; t < config.end_time_ + config.step_; + for (int64_t t = config.begin_time_; t < config.end_time_ + config.step_; t += config.step_) { while (window_index_end < data_view.size() && - data_view[window_index_end].log_time() < t) { + data_view[window_index_end].log_time_us() < t) { absl::optional value = fy(data_view[window_index_end]); if (value) sum_in_window += *value; ++window_index_end; } while (window_index_begin < data_view.size() && - data_view[window_index_begin].log_time() < + data_view[window_index_begin].log_time_us() < t - config.window_duration_) { absl::optional value = fy(data_view[window_index_begin]); if (value) @@ -184,7 +170,7 @@ void MovingAverage( ++window_index_begin; } float window_duration_s = - static_cast(config.window_duration_.us()) / kNumMicrosecsPerSec; + static_cast(config.window_duration_) / kNumMicrosecsPerSec; float x = config.GetCallTimeSec(t); float y = sum_in_window / window_duration_s; result->points.emplace_back(x, y); diff --git a/rtc_tools/rtc_event_log_visualizer/main.cc b/rtc_tools/rtc_event_log_visualizer/main.cc index 6182b701df..ab4b7ebac1 100644 --- a/rtc_tools/rtc_event_log_visualizer/main.cc +++ b/rtc_tools/rtc_event_log_visualizer/main.cc @@ -261,12 +261,8 @@ int main(int argc, char* argv[]) { } webrtc::AnalyzerConfig config; - config.window_duration_ = webrtc::TimeDelta::Millis(250); - config.step_ = webrtc::TimeDelta::Millis(10); - if (!parsed_log.start_log_events().empty()) { - config.rtc_to_utc_offset_ = parsed_log.start_log_events()[0].utc_time() - - parsed_log.start_log_events()[0].log_time(); - } + config.window_duration_ = 250000; + config.step_ = 10000; config.normalize_time_ = absl::GetFlag(FLAGS_normalize_time); config.begin_time_ = parsed_log.first_timestamp(); config.end_time_ = parsed_log.last_timestamp(); @@ -279,7 +275,6 @@ int main(int argc, char* argv[]) { webrtc::EventLogAnalyzer analyzer(parsed_log, config); webrtc::PlotCollection collection; - collection.SetCallTimeToUtcOffsetMs(config.CallTimeToUtcOffsetMs()); PlotMap plots; plots.RegisterPlot("incoming_packet_sizes", [&](Plot* plot) { diff --git a/rtc_tools/rtc_event_log_visualizer/plot_base.cc b/rtc_tools/rtc_event_log_visualizer/plot_base.cc index bf76a67bb5..82533e6eb0 100644 --- a/rtc_tools/rtc_event_log_visualizer/plot_base.cc +++ b/rtc_tools/rtc_event_log_visualizer/plot_base.cc @@ -307,13 +307,13 @@ void PlotCollection::PrintPythonCode(bool shared_xaxis) const { void PlotCollection::ExportProtobuf( webrtc::analytics::ChartCollection* collection) const { for (const auto& plot : plots_) { + // TODO(terelius): Ensure that there is no way to insert plots other than + // ProtobufPlots in a ProtobufPlotCollection. Needed to safely static_cast + // here. webrtc::analytics::Chart* protobuf_representation = collection->add_charts(); plot->ExportProtobuf(protobuf_representation); } - if (calltime_to_utc_ms_) { - collection->set_calltime_to_utc_ms(*calltime_to_utc_ms_); - } } Plot* PlotCollection::AppendNewPlot() { diff --git a/rtc_tools/rtc_event_log_visualizer/plot_base.h b/rtc_tools/rtc_event_log_visualizer/plot_base.h index dbc9535fc1..a26146b5e5 100644 --- a/rtc_tools/rtc_event_log_visualizer/plot_base.h +++ b/rtc_tools/rtc_event_log_visualizer/plot_base.h @@ -16,7 +16,6 @@ #include #include "absl/base/attributes.h" -#include "absl/types/optional.h" #include "rtc_base/ignore_wundef.h" RTC_PUSH_IGNORING_WUNDEF() @@ -195,10 +194,6 @@ class PlotCollection { virtual Plot* AppendNewPlot(); - void SetCallTimeToUtcOffsetMs(int64_t calltime_to_utc_ms) { - calltime_to_utc_ms_ = calltime_to_utc_ms; - } - // Replaces PythonPlotCollection::Draw() void PrintPythonCode(bool shared_xaxis) const; @@ -207,7 +202,6 @@ class PlotCollection { protected: std::vector> plots_; - absl::optional calltime_to_utc_ms_; }; } // namespace webrtc diff --git a/rtc_tools/rtc_event_log_visualizer/proto/chart.proto b/rtc_tools/rtc_event_log_visualizer/proto/chart.proto index f82d9c1ead..e5960b2677 100644 --- a/rtc_tools/rtc_event_log_visualizer/proto/chart.proto +++ b/rtc_tools/rtc_event_log_visualizer/proto/chart.proto @@ -33,8 +33,4 @@ message Chart { message ChartCollection { repeated Chart charts = 1; - // `calltime_to_utc_ms` is the UTC time (in ms) for the x-axis in the charts. - // In other words, time t ms in the charts corresponds to - // t+calltime_to_utc_ms ms in UTC time. - int64 calltime_to_utc_ms = 2; } From a8c0d789ee43fb84bbabc314db4e584536fec05e Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Thu, 24 Feb 2022 10:01:53 -0800 Subject: [PATCH 043/847] Roll chromium_revision b4562c8dc8..c5c3b957ca (974583:974718) Change log: https://chromium.googlesource.com/chromium/src/+log/b4562c8dc8..c5c3b957ca Full diff: https://chromium.googlesource.com/chromium/src/+/b4562c8dc8..c5c3b957ca Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/187616c5fc..8c7254d87b * src/build: https://chromium.googlesource.com/chromium/src/build/+log/bcfb6fca6d..b6b7a3eb65 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/4eaa194b8b..2a2fe25738 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/629e78f5b3..04b71a078a * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/d2f57fb779..502712994d * src/third_party/boringssl/src: https://boringssl.googlesource.com/boringssl.git/+log/68addd2f71..4d955d20d2 * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/dfc6cffca9..cf4922dea8 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/bc929d3e94..7264b97e2c DEPS diff: https://chromium.googlesource.com/chromium/src/+/b4562c8dc8..c5c3b957ca/DEPS No update to Clang. BUG=None Change-Id: I2b31a937eaffc07cebc7eef0c009f62e179bd629 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252480 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36069} --- DEPS | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/DEPS b/DEPS index 12fda9d1c0..f9fdd59744 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': 'b4562c8dc867d02eac53a1cacfa8c01dcce85ec4', + 'chromium_revision': 'c5c3b957ca3ea4e222eb7ae8b4691574b6585be3', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@187616c5fc42d8f190b3931eacffb7223e83f262', + 'https://chromium.googlesource.com/chromium/src/base@8c7254d87b3ba24aef5cf7ac630baa32bb5bd90f', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@bcfb6fca6d9c1747faa96854e0e124deef6b458b', + 'https://chromium.googlesource.com/chromium/src/build@b6b7a3eb65fcb75cb5b1c729b67bdbde87385625', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@893aa038dd17d05f3c5ff5af98daebabc294a948', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@4eaa194b8b3c40af0f810417816f02bac7269b81', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@2a2fe2573898c06d8cb45ee0ea8850cd2577b292', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@629e78f5b3d5bf879409c9624095078d312be446', + 'https://chromium.googlesource.com/chromium/src/testing@04b71a078aafab1c64929249cdc72c80b2b1a24e', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@d2f57fb7795d3a9a59d98d3ce82898af35fbca75', + 'https://chromium.googlesource.com/chromium/src/third_party@502712994d918e9d56075f6f4b1912f2893d9aae', 'src/buildtools/linux64': { 'packages': [ @@ -136,7 +136,7 @@ deps = { }, 'src/third_party/boringssl/src': - 'https://boringssl.googlesource.com/boringssl.git@68addd2f719422cd00f44f06c330457269d3facf', + 'https://boringssl.googlesource.com/boringssl.git@4d955d20d27bcf3ae71df091ad17d95229a7eb56', 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': @@ -228,7 +228,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@dfc6cffca9b6a34068386915d50040c6bc142717', + 'https://android.googlesource.com/platform/external/perfetto.git@cf4922dea8779ff37f641b2e5b652f71509320dc', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@bc929d3e944c8dbe7d849a1de5aeb0141cd7fabc', + 'https://chromium.googlesource.com/chromium/src/tools@7264b97e2cff9f12180e741d397361f14f64b2e8', 'src/third_party/accessibility_test_framework': { 'packages': [ From ecd5ba15cb1bea32eafef85abbc091e43947dbb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Thu, 24 Feb 2022 13:59:13 +0100 Subject: [PATCH 044/847] Fix missing include of rtc_base/system/no_unique_address.h Bug: None Change-Id: I047c456cde647282824e8c51122ae53bef7cb7b3 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252440 Auto-Submit: Niels Moller Reviewed-by: Mark Foltz Commit-Queue: Mark Foltz Cr-Commit-Position: refs/heads/main@{#36070} --- modules/desktop_capture/BUILD.gn | 1 + .../linux/wayland/mouse_cursor_monitor_pipewire.h | 1 + 2 files changed, 2 insertions(+) diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn index 25ea1cb05a..03b135bf35 100644 --- a/modules/desktop_capture/BUILD.gn +++ b/modules/desktop_capture/BUILD.gn @@ -464,6 +464,7 @@ rtc_library("desktop_capture_generic") { "../../rtc_base:checks", "../../rtc_base/synchronization:mutex", "../../rtc_base/system:arch", + "../../rtc_base/system:no_unique_address", "../../rtc_base/system:rtc_export", "../../system_wrappers", "../../system_wrappers:metrics", diff --git a/modules/desktop_capture/linux/wayland/mouse_cursor_monitor_pipewire.h b/modules/desktop_capture/linux/wayland/mouse_cursor_monitor_pipewire.h index 8af4f879f8..da670bece9 100644 --- a/modules/desktop_capture/linux/wayland/mouse_cursor_monitor_pipewire.h +++ b/modules/desktop_capture/linux/wayland/mouse_cursor_monitor_pipewire.h @@ -20,6 +20,7 @@ #include "modules/desktop_capture/linux/wayland/shared_screencast_stream.h" #include "modules/desktop_capture/mouse_cursor.h" #include "modules/desktop_capture/mouse_cursor_monitor.h" +#include "rtc_base/system/no_unique_address.h" namespace webrtc { From 1535b0a34bca709cd6837407c381a9219c4ae3f1 Mon Sep 17 00:00:00 2001 From: Stefan Mitic Date: Thu, 24 Feb 2022 08:54:33 -0800 Subject: [PATCH 045/847] Add I444Buffer tests in video_frame_unittest.cc @nisse suggested to add test for I444Buffer to VideoFrameBuffer test in https://webrtc-review.googlesource.com/c/src/+/251303 and I agree that they should exist. Didn't get the time to add them before the change was merged, so here they are. I took the liberty of reworking the tests to extend support to any buffer type based on PlanarYuvBuffer (only limited by interface method implementations) but still retain the same functionality. Bug: webrtc:13669 Change-Id: I67998b635e05e1403e2dc6cfe3483590a5788453 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251460 Reviewed-by: Ilya Nikolaevskiy Reviewed-by: Harald Alvestrand Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#36071} --- common_video/video_frame_unittest.cc | 340 +++++++++++---------------- 1 file changed, 132 insertions(+), 208 deletions(-) diff --git a/common_video/video_frame_unittest.cc b/common_video/video_frame_unittest.cc index 9a70f07b34..b14ec599b7 100644 --- a/common_video/video_frame_unittest.cc +++ b/common_video/video_frame_unittest.cc @@ -15,6 +15,7 @@ #include "api/video/i010_buffer.h" #include "api/video/i420_buffer.h" +#include "api/video/i444_buffer.h" #include "api/video/nv12_buffer.h" #include "rtc_base/time_utils.h" #include "test/fake_texture_frame.h" @@ -25,114 +26,11 @@ namespace webrtc { namespace { -// Helper class to delegate calls to appropriate container. -class PlanarYuvBufferFactory { - public: - static rtc::scoped_refptr Create(VideoFrameBuffer::Type type, - int width, - int height) { - switch (type) { - case VideoFrameBuffer::Type::kI420: - return I420Buffer::Create(width, height); - case VideoFrameBuffer::Type::kI010: - return I010Buffer::Create(width, height); - default: - RTC_DCHECK_NOTREACHED(); - } - return nullptr; - } - - static rtc::scoped_refptr Copy(const VideoFrameBuffer& src) { - switch (src.type()) { - case VideoFrameBuffer::Type::kI420: - return I420Buffer::Copy(src); - case VideoFrameBuffer::Type::kI010: - return I010Buffer::Copy(*src.GetI010()); - default: - RTC_DCHECK_NOTREACHED(); - } - return nullptr; - } - - static rtc::scoped_refptr Rotate(const VideoFrameBuffer& src, - VideoRotation rotation) { - switch (src.type()) { - case VideoFrameBuffer::Type::kI420: - return I420Buffer::Rotate(src, rotation); - case VideoFrameBuffer::Type::kI010: - return I010Buffer::Rotate(*src.GetI010(), rotation); - default: - RTC_DCHECK_NOTREACHED(); - } - return nullptr; - } - - static rtc::scoped_refptr CropAndScaleFrom( - const VideoFrameBuffer& src, - int offset_x, - int offset_y, - int crop_width, - int crop_height) { - switch (src.type()) { - case VideoFrameBuffer::Type::kI420: { - rtc::scoped_refptr buffer = - I420Buffer::Create(crop_width, crop_height); - buffer->CropAndScaleFrom(*src.GetI420(), offset_x, offset_y, crop_width, - crop_height); - return buffer; - } - case VideoFrameBuffer::Type::kI010: { - rtc::scoped_refptr buffer = - I010Buffer::Create(crop_width, crop_height); - buffer->CropAndScaleFrom(*src.GetI010(), offset_x, offset_y, crop_width, - crop_height); - return buffer; - } - default: - RTC_DCHECK_NOTREACHED(); - } - return nullptr; - } - - static rtc::scoped_refptr CropAndScaleFrom( - const VideoFrameBuffer& src, - int crop_width, - int crop_height) { - const int out_width = - std::min(src.width(), crop_width * src.height() / crop_height); - const int out_height = - std::min(src.height(), crop_height * src.width() / crop_width); - return CropAndScaleFrom(src, (src.width() - out_width) / 2, - (src.height() - out_height) / 2, out_width, - out_height); - } - - static rtc::scoped_refptr - ScaleFrom(const VideoFrameBuffer& src, int crop_width, int crop_height) { - switch (src.type()) { - case VideoFrameBuffer::Type::kI420: { - rtc::scoped_refptr buffer = - I420Buffer::Create(crop_width, crop_height); - buffer->ScaleFrom(*src.GetI420()); - return buffer; - } - case VideoFrameBuffer::Type::kI010: { - rtc::scoped_refptr buffer = - I010Buffer::Create(crop_width, crop_height); - buffer->ScaleFrom(*src.GetI010()); - return buffer; - } - default: - RTC_DCHECK_NOTREACHED(); - } - return nullptr; - } -}; - -rtc::scoped_refptr CreateGradient(VideoFrameBuffer::Type type, - int width, - int height) { - rtc::scoped_refptr buffer(I420Buffer::Create(width, height)); +// Helper function to create a buffer and fill it with a gradient for +// PlanarYuvBuffer based buffers. +template +rtc::scoped_refptr CreateGradient(int width, int height) { + rtc::scoped_refptr buffer(T::Create(width, height)); // Initialize with gradient, Y = 128(x/w + y/h), U = 256 x/w, V = 256 y/h for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { @@ -150,13 +48,10 @@ rtc::scoped_refptr CreateGradient(VideoFrameBuffer::Type type, 255 * y / (chroma_height - 1); } } - if (type == VideoFrameBuffer::Type::kI420) - return buffer; - - RTC_DCHECK(type == VideoFrameBuffer::Type::kI010); - return I010Buffer::Copy(*buffer); + return buffer; } +// Helper function to create a buffer and fill it with a gradient. rtc::scoped_refptr CreateNV12Gradient(int width, int height) { rtc::scoped_refptr buffer(NV12Buffer::Create(width, height)); @@ -183,13 +78,16 @@ rtc::scoped_refptr CreateNV12Gradient(int width, // The offsets and sizes describe the rectangle extracted from the // original (gradient) frame, in relative coordinates where the // original frame correspond to the unit square, 0.0 <= x, y < 1.0. -void CheckCrop(const webrtc::I420BufferInterface& frame, +template +void CheckCrop(const T& frame, double offset_x, double offset_y, double rel_width, double rel_height) { int width = frame.width(); int height = frame.height(); + int plane_divider = frame.type() == VideoFrameBuffer::Type::kI444 ? 1 : 2; + // Check that pixel values in the corners match the gradient used // for initialization. for (int i = 0; i < 2; i++) { @@ -204,18 +102,23 @@ void CheckCrop(const webrtc::I420BufferInterface& frame, EXPECT_NEAR(frame.DataY()[x + y * frame.StrideY()] / 256.0, (orig_x + orig_y) / 2, 0.02); - EXPECT_NEAR(frame.DataU()[x / 2 + (y / 2) * frame.StrideU()] / 256.0, + EXPECT_NEAR(frame.DataU()[x / plane_divider + + (y / plane_divider) * frame.StrideU()] / + 256.0, orig_x, 0.02); - EXPECT_NEAR(frame.DataV()[x / 2 + (y / 2) * frame.StrideV()] / 256.0, + EXPECT_NEAR(frame.DataV()[x / plane_divider + + (y / plane_divider) * frame.StrideV()] / + 256.0, orig_y, 0.02); } } } +template void CheckRotate(int width, int height, webrtc::VideoRotation rotation, - const webrtc::I420BufferInterface& rotated) { + const T& rotated) { int rotated_width = width; int rotated_height = height; @@ -238,15 +141,18 @@ void CheckRotate(int width, } colors[] = {{0, 0, 0}, {127, 255, 0}, {255, 255, 255}, {127, 0, 255}}; int corner_offset = static_cast(rotation) / 90; + int plane_divider = rotated.type() == VideoFrameBuffer::Type::kI444 ? 1 : 2; for (int i = 0; i < 4; i++) { int j = (i + corner_offset) % 4; int x = corners[j].x * (rotated_width - 1); int y = corners[j].y * (rotated_height - 1); EXPECT_EQ(colors[i].y, rotated.DataY()[x + y * rotated.StrideY()]); EXPECT_EQ(colors[i].u, - rotated.DataU()[(x / 2) + (y / 2) * rotated.StrideU()]); + rotated.DataU()[(x / plane_divider) + + (y / plane_divider) * rotated.StrideU()]); EXPECT_EQ(colors[i].v, - rotated.DataV()[(x / 2) + (y / 2) * rotated.StrideV()]); + rotated.DataV()[(x / plane_divider) + + (y / plane_divider) * rotated.StrideV()]); } } @@ -344,101 +250,142 @@ TEST(TestVideoFrame, TextureInitialValues) { EXPECT_EQ(20, frame.timestamp_us()); } -class TestPlanarYuvBuffer - : public ::testing::TestWithParam {}; +template +class TestPlanarYuvBuffer : public ::testing::Test {}; +TYPED_TEST_SUITE_P(TestPlanarYuvBuffer); -rtc::scoped_refptr CreateAndFillBuffer() { - auto buf = I420Buffer::Create(20, 10); +template +rtc::scoped_refptr CreateAndFillBuffer() { + auto buf = T::Create(20, 10); memset(buf->MutableDataY(), 1, 200); - memset(buf->MutableDataU(), 2, 50); - memset(buf->MutableDataV(), 3, 50); - return buf; -} -TEST_P(TestPlanarYuvBuffer, Copy) { - rtc::scoped_refptr buf1; - switch (GetParam()) { - case VideoFrameBuffer::Type::kI420: { - buf1 = CreateAndFillBuffer(); - break; - } - case VideoFrameBuffer::Type::kI010: { - buf1 = I010Buffer::Copy(*CreateAndFillBuffer()); - break; - } - default: - RTC_DCHECK_NOTREACHED(); + if (buf->type() == VideoFrameBuffer::Type::kI444) { + memset(buf->MutableDataU(), 2, 200); + memset(buf->MutableDataV(), 3, 200); + } else { + memset(buf->MutableDataU(), 2, 50); + memset(buf->MutableDataV(), 3, 50); } - rtc::scoped_refptr buf2 = - PlanarYuvBufferFactory::Copy(*buf1); - EXPECT_TRUE(test::FrameBufsEqual(buf1->ToI420(), buf2->ToI420())); + return buf; } -TEST_P(TestPlanarYuvBuffer, Scale) { - rtc::scoped_refptr buf = - CreateGradient(GetParam(), 200, 100); - - // Pure scaling, no cropping. - rtc::scoped_refptr scaled_buffer = - PlanarYuvBufferFactory::ScaleFrom(*buf, 150, 75); - CheckCrop(*scaled_buffer->ToI420(), 0.0, 0.0, 1.0, 1.0); +TYPED_TEST_P(TestPlanarYuvBuffer, Copy) { + rtc::scoped_refptr buf1 = CreateAndFillBuffer(); + rtc::scoped_refptr buf2 = TypeParam::Copy(*buf1); + EXPECT_TRUE(test::FrameBufsEqual(buf1, buf2)); } -TEST_P(TestPlanarYuvBuffer, CropXCenter) { - rtc::scoped_refptr buf = - CreateGradient(GetParam(), 200, 100); +TYPED_TEST_P(TestPlanarYuvBuffer, CropXCenter) { + rtc::scoped_refptr buf = CreateGradient(200, 100); // Pure center cropping, no scaling. - rtc::scoped_refptr scaled_buffer = - PlanarYuvBufferFactory::CropAndScaleFrom(*buf, 50, 0, 100, 100); - CheckCrop(*scaled_buffer->ToI420(), 0.25, 0.0, 0.5, 1.0); + rtc::scoped_refptr scaled_buffer = TypeParam::Create(100, 100); + scaled_buffer->CropAndScaleFrom(*buf, 50, 0, 100, 100); + CheckCrop(*scaled_buffer, 0.25, 0.0, 0.5, 1.0); } -TEST_P(TestPlanarYuvBuffer, CropXNotCenter) { - rtc::scoped_refptr buf = - CreateGradient(GetParam(), 200, 100); +TYPED_TEST_P(TestPlanarYuvBuffer, CropXNotCenter) { + rtc::scoped_refptr buf = CreateGradient(200, 100); // Non-center cropping, no scaling. - rtc::scoped_refptr scaled_buffer = - PlanarYuvBufferFactory::CropAndScaleFrom(*buf, 25, 0, 100, 100); - CheckCrop(*scaled_buffer->ToI420(), 0.125, 0.0, 0.5, 1.0); + rtc::scoped_refptr scaled_buffer = TypeParam::Create(100, 100); + scaled_buffer->CropAndScaleFrom(*buf, 25, 0, 100, 100); + CheckCrop(*scaled_buffer, 0.125, 0.0, 0.5, 1.0); } -TEST_P(TestPlanarYuvBuffer, CropYCenter) { - rtc::scoped_refptr buf = - CreateGradient(GetParam(), 100, 200); +TYPED_TEST_P(TestPlanarYuvBuffer, CropYCenter) { + rtc::scoped_refptr buf = CreateGradient(100, 200); // Pure center cropping, no scaling. - rtc::scoped_refptr scaled_buffer = - PlanarYuvBufferFactory::CropAndScaleFrom(*buf, 0, 50, 100, 100); - CheckCrop(*scaled_buffer->ToI420(), 0.0, 0.25, 1.0, 0.5); + rtc::scoped_refptr scaled_buffer = TypeParam::Create(100, 100); + scaled_buffer->CropAndScaleFrom(*buf, 0, 50, 100, 100); + CheckCrop(*scaled_buffer, 0.0, 0.25, 1.0, 0.5); } -TEST_P(TestPlanarYuvBuffer, CropYNotCenter) { - rtc::scoped_refptr buf = - CreateGradient(GetParam(), 100, 200); +TYPED_TEST_P(TestPlanarYuvBuffer, CropYNotCenter) { + rtc::scoped_refptr buf = CreateGradient(100, 200); // Pure center cropping, no scaling. - rtc::scoped_refptr scaled_buffer = - PlanarYuvBufferFactory::CropAndScaleFrom(*buf, 0, 25, 100, 100); - CheckCrop(*scaled_buffer->ToI420(), 0.0, 0.125, 1.0, 0.5); + rtc::scoped_refptr scaled_buffer = TypeParam::Create(100, 100); + scaled_buffer->CropAndScaleFrom(*buf, 0, 25, 100, 100); + CheckCrop(*scaled_buffer, 0.0, 0.125, 1.0, 0.5); } -TEST_P(TestPlanarYuvBuffer, CropAndScale16x9) { - rtc::scoped_refptr buf = - CreateGradient(GetParam(), 640, 480); +TYPED_TEST_P(TestPlanarYuvBuffer, CropAndScale16x9) { + const int buffer_width = 640; + const int buffer_height = 480; + const int crop_width = 320; + const int crop_height = 180; + rtc::scoped_refptr buf = CreateGradient(640, 480); // Pure center cropping, no scaling. - rtc::scoped_refptr scaled_buffer = - PlanarYuvBufferFactory::CropAndScaleFrom(*buf, 320, 180); - CheckCrop(*scaled_buffer->ToI420(), 0.0, 0.125, 1.0, 0.75); + const int out_width = + std::min(buffer_width, crop_width * buffer_height / crop_height); + const int out_height = + std::min(buffer_height, crop_height * buffer_width / crop_width); + rtc::scoped_refptr scaled_buffer = + TypeParam::Create(out_width, out_height); + scaled_buffer->CropAndScaleFrom(*buf, (buffer_width - out_width) / 2, + (buffer_height - out_height) / 2, out_width, + out_height); + CheckCrop(*scaled_buffer, 0.0, 0.125, 1.0, 0.75); +} + +REGISTER_TYPED_TEST_SUITE_P(TestPlanarYuvBuffer, + Copy, + CropXCenter, + CropXNotCenter, + CropYCenter, + CropYNotCenter, + CropAndScale16x9); + +using TestTypesAll = ::testing::Types; +INSTANTIATE_TYPED_TEST_SUITE_P(All, TestPlanarYuvBuffer, TestTypesAll); + +template +class TestPlanarYuvBufferScale : public ::testing::Test {}; +TYPED_TEST_SUITE_P(TestPlanarYuvBufferScale); + +TYPED_TEST_P(TestPlanarYuvBufferScale, Scale) { + rtc::scoped_refptr buf = CreateGradient(200, 100); + + // Pure scaling, no cropping. + rtc::scoped_refptr scaled_buffer = TypeParam::Create(150, 75); + scaled_buffer->ScaleFrom(*buf); + CheckCrop(*scaled_buffer, 0.0, 0.0, 1.0, 1.0); } -INSTANTIATE_TEST_SUITE_P(All, - TestPlanarYuvBuffer, - ::testing::Values(VideoFrameBuffer::Type::kI420, - VideoFrameBuffer::Type::kI010)); +REGISTER_TYPED_TEST_SUITE_P(TestPlanarYuvBufferScale, Scale); + +using TestTypesScale = ::testing::Types; +INSTANTIATE_TYPED_TEST_SUITE_P(All, TestPlanarYuvBufferScale, TestTypesScale); + +template +class TestPlanarYuvBufferRotate : public ::testing::Test { + public: + std::vector RotationParams = { + kVideoRotation_0, kVideoRotation_90, kVideoRotation_180, + kVideoRotation_270}; +}; + +TYPED_TEST_SUITE_P(TestPlanarYuvBufferRotate); + +TYPED_TEST_P(TestPlanarYuvBufferRotate, Rotates) { + for (const webrtc::VideoRotation& rotation : this->RotationParams) { + rtc::scoped_refptr buffer = CreateGradient(640, 480); + rtc::scoped_refptr rotated_buffer = + TypeParam::Rotate(*buffer, rotation); + CheckRotate(640, 480, rotation, *rotated_buffer); + } +} + +REGISTER_TYPED_TEST_SUITE_P(TestPlanarYuvBufferRotate, Rotates); + +using TestTypesRotate = ::testing::Types; +INSTANTIATE_TYPED_TEST_SUITE_P(Rotate, + TestPlanarYuvBufferRotate, + TestTypesRotate); TEST(TestNV12Buffer, CropAndScale) { const int kSourceWidth = 640; @@ -469,29 +416,6 @@ TEST(TestNV12Buffer, CropAndScale) { kRelativeHeight); } -class TestPlanarYuvBufferRotate - : public ::testing::TestWithParam< - std::tuple> {}; - -TEST_P(TestPlanarYuvBufferRotate, Rotates) { - const webrtc::VideoRotation rotation = std::get<0>(GetParam()); - const VideoFrameBuffer::Type type = std::get<1>(GetParam()); - rtc::scoped_refptr buffer = CreateGradient(type, 640, 480); - rtc::scoped_refptr rotated_buffer = - PlanarYuvBufferFactory::Rotate(*buffer, rotation); - CheckRotate(640, 480, rotation, *rotated_buffer->ToI420()); -} - -INSTANTIATE_TEST_SUITE_P( - Rotate, - TestPlanarYuvBufferRotate, - ::testing::Combine(::testing::Values(kVideoRotation_0, - kVideoRotation_90, - kVideoRotation_180, - kVideoRotation_270), - ::testing::Values(VideoFrameBuffer::Type::kI420, - VideoFrameBuffer::Type::kI010))); - TEST(TestUpdateRect, CanCompare) { VideoFrame::UpdateRect a = {0, 0, 100, 200}; VideoFrame::UpdateRect b = {0, 0, 100, 200}; From 48cda468aa2343731e252a821f926b05411a1603 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Thu, 24 Feb 2022 14:01:49 -0800 Subject: [PATCH 046/847] Roll chromium_revision c5c3b957ca..ec76cb664e (974718:974851) Change log: https://chromium.googlesource.com/chromium/src/+log/c5c3b957ca..ec76cb664e Full diff: https://chromium.googlesource.com/chromium/src/+/c5c3b957ca..ec76cb664e Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/8c7254d87b..f7134a07e7 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/b6b7a3eb65..1182250c7c * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/2a2fe25738..cc97f3073d * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/04b71a078a..2db17150ca * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/502712994d..192c0c6ca7 * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/08a8050c47..62a74cf243 * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/2c668c866d..c1ab734908 * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/cf4922dea8..dfc6cffca9 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/7264b97e2c..5834f7f7df DEPS diff: https://chromium.googlesource.com/chromium/src/+/c5c3b957ca..ec76cb664e/DEPS No update to Clang. BUG=None Change-Id: I8c2e5bca3f4fd5549a60362385b1e3f7e36cadf0 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252501 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36072} --- DEPS | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/DEPS b/DEPS index f9fdd59744..8331bb8e42 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': 'c5c3b957ca3ea4e222eb7ae8b4691574b6585be3', + 'chromium_revision': 'ec76cb664ec63dba9ce7a1a0efb8aa18146aec46', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@8c7254d87b3ba24aef5cf7ac630baa32bb5bd90f', + 'https://chromium.googlesource.com/chromium/src/base@f7134a07e7b15d5168787bd7cb184d3dd8290332', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@b6b7a3eb65fcb75cb5b1c729b67bdbde87385625', + 'https://chromium.googlesource.com/chromium/src/build@1182250c7c5cba133acb13ca243ca8889fed5039', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@893aa038dd17d05f3c5ff5af98daebabc294a948', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@2a2fe2573898c06d8cb45ee0ea8850cd2577b292', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@cc97f3073d1c1c2ddcbf296809ae90d27d685e03', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@04b71a078aafab1c64929249cdc72c80b2b1a24e', + 'https://chromium.googlesource.com/chromium/src/testing@2db17150cafc5efbbe74ee7c6ccdeab7c6e1d631', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@502712994d918e9d56075f6f4b1912f2893d9aae', + 'https://chromium.googlesource.com/chromium/src/third_party@192c0c6ca733074577560085c73e153688306ae2', 'src/buildtools/linux64': { 'packages': [ @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@08a8050c47dc376c85ba2bda2ec4db2e1f7ea961', + 'https://chromium.googlesource.com/catapult.git@62a74cf243b4a63011f561ee10e57635a914df08', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@2c668c866d8678edbff7d10f99c03e82140242ec', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@c1ab734908f09df3d4c6672acd66c0cfcd584114', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -228,7 +228,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@cf4922dea8779ff37f641b2e5b652f71509320dc', + 'https://android.googlesource.com/platform/external/perfetto.git@dfc6cffca9b6a34068386915d50040c6bc142717', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@7264b97e2cff9f12180e741d397361f14f64b2e8', + 'https://chromium.googlesource.com/chromium/src/tools@5834f7f7df676466c1da21841094f015ee30490e', 'src/third_party/accessibility_test_framework': { 'packages': [ From 0825daf2edb16b8ecfa153b438fecdb5835d7a7d Mon Sep 17 00:00:00 2001 From: Jan Grulich Date: Mon, 21 Feb 2022 20:16:36 +0100 Subject: [PATCH 047/847] PipeWire capturer: search for epoxy headers We actually use headers from libepoxy (it's part of the sysroot) so this was removed accicentally in one of previous changes and it just magically worked as we include those headers with their full path Bug: webrtc:13429 Change-Id: I4f5684521a76287a725272ce3833daae673d9332 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252002 Reviewed-by: Alexander Cooper Commit-Queue: Alexander Cooper Cr-Commit-Position: refs/heads/main@{#36073} --- modules/desktop_capture/BUILD.gn | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn index 03b135bf35..6c855b9c1c 100644 --- a/modules/desktop_capture/BUILD.gn +++ b/modules/desktop_capture/BUILD.gn @@ -228,6 +228,10 @@ if (is_linux || is_chromeos) { pkg_config("egl") { packages = [ "egl" ] } + pkg_config("epoxy") { + packages = [ "epoxy" ] + ignore_libs = true + } pkg_config("libdrm") { packages = [ "libdrm" ] if (!rtc_link_pipewire) { @@ -577,6 +581,7 @@ rtc_library("desktop_capture_generic") { ":pipewire", ":gbm", ":egl", + ":epoxy", ":libdrm", ] From c5200da92e1c93607de0a971506ad1b805bb262a Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Thu, 24 Feb 2022 18:01:33 -0800 Subject: [PATCH 048/847] Roll chromium_revision ec76cb664e..2136e05894 (974851:974952) Change log: https://chromium.googlesource.com/chromium/src/+log/ec76cb664e..2136e05894 Full diff: https://chromium.googlesource.com/chromium/src/+/ec76cb664e..2136e05894 Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/f7134a07e7..42d67a004d * src/build: https://chromium.googlesource.com/chromium/src/build/+log/1182250c7c..f982200c74 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/cc97f3073d..14c5557274 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/2db17150ca..f039863bab * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/192c0c6ca7..84f3d6bf8f * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/c1ab734908..6b28c1ddef * src/third_party/icu: https://chromium.googlesource.com/chromium/deps/icu.git/+log/901474b180..1fa4e3959e * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/5834f7f7df..ebe914c964 DEPS diff: https://chromium.googlesource.com/chromium/src/+/ec76cb664e..2136e05894/DEPS No update to Clang. BUG=None Change-Id: I27c61ee5e8621e5cb7a28054d9874d012b18a87b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252540 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36074} --- DEPS | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/DEPS b/DEPS index 8331bb8e42..efff298956 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': 'ec76cb664ec63dba9ce7a1a0efb8aa18146aec46', + 'chromium_revision': '2136e058949005992a67a35f8e766825bcddf028', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@f7134a07e7b15d5168787bd7cb184d3dd8290332', + 'https://chromium.googlesource.com/chromium/src/base@42d67a004d1cf13b02017b474786a64fe259070f', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@1182250c7c5cba133acb13ca243ca8889fed5039', + 'https://chromium.googlesource.com/chromium/src/build@f982200c74b89119a69ba58fbcc90f1ee5f19d3f', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@893aa038dd17d05f3c5ff5af98daebabc294a948', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@cc97f3073d1c1c2ddcbf296809ae90d27d685e03', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@14c55572748e3f8c85656a160760e069d993b5e5', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@2db17150cafc5efbbe74ee7c6ccdeab7c6e1d631', + 'https://chromium.googlesource.com/chromium/src/testing@f039863bab0c8c0dec38717d2bfe6c9fa2c9c714', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@192c0c6ca733074577560085c73e153688306ae2', + 'https://chromium.googlesource.com/chromium/src/third_party@84f3d6bf8f0702eeaa0b565bb511cf9568e1df32', 'src/buildtools/linux64': { 'packages': [ @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@c1ab734908f09df3d4c6672acd66c0cfcd584114', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@6b28c1ddef177b44521ab5e8c438942c397a56d8', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -184,7 +184,7 @@ deps = { 'src/third_party/googletest/src': 'https://chromium.googlesource.com/external/github.com/google/googletest.git@c9461a9b55ba954df0489bab6420eb297bed846b', 'src/third_party/icu': { - 'url': 'https://chromium.googlesource.com/chromium/deps/icu.git@901474b1806d6b5a068606006dbb4c08e9974353', + 'url': 'https://chromium.googlesource.com/chromium/deps/icu.git@1fa4e3959ec6637182b7318ac1d382799454806d', }, 'src/third_party/jdk': { 'packages': [ @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@5834f7f7df676466c1da21841094f015ee30490e', + 'https://chromium.googlesource.com/chromium/src/tools@ebe914c9646b756b1768e1b8ada2ce2653b7e70d', 'src/third_party/accessibility_test_framework': { 'packages': [ From a23acdde9dbf3137516cd5e45649e6f81335580b Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Thu, 24 Feb 2022 20:02:05 -0800 Subject: [PATCH 049/847] Update WebRTC code version (2022-02-25T04:02:04). Bug: None Change-Id: I5ea00667b5f3a253dc42e67aed9487990b9502d9 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252543 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36075} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index b87c852b44..2a1f6485b5 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 2022-02-24T04:05:39"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-02-25T04:02:04"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From e4d3952bf0b05b825992f1023a106f3bcf34946e Mon Sep 17 00:00:00 2001 From: Taylor Brandstetter Date: Fri, 25 Feb 2022 02:48:18 +0000 Subject: [PATCH 050/847] Revert "Remove workaround in AutoSocketServerThread that isn't needed anymore." This reverts commit 44156fa024cbf12f052a35571ac91bc9907be6c3. Reason for revert: Needed in order to revert https://webrtc-review.googlesource.com/c/src/+/249941, which introduced a crash Original change's description: > Remove workaround in AutoSocketServerThread that isn't needed anymore. > > Cleanup steps for the Connection class have changed as of: > https://webrtc-review.googlesource.com/c/src/+/249941 > > However, it turns out that the PortTest suite still needs it, so the > workaround has migrated to there. > > Bug: none > Change-Id: Ia68f47b6c65b3a8fd5e8c04d70a43d15ba1a6422 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/250223 > Reviewed-by: Niels Moller > Commit-Queue: Tomas Gunnarsson > Cr-Commit-Position: refs/heads/main@{#35894} Bug: none Change-Id: I13a4a79ebcb864054d14c1ba7726e18e044e3bd4 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252542 Auto-Submit: Taylor Brandstetter Reviewed-by: Mirko Bonadei Commit-Queue: Mirko Bonadei Reviewed-by: Tomas Gunnarsson Commit-Queue: Tomas Gunnarsson Cr-Commit-Position: refs/heads/main@{#36076} --- p2p/base/port_unittest.cc | 7 ------- rtc_base/thread.cc | 5 +++++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/p2p/base/port_unittest.cc b/p2p/base/port_unittest.cc index 6ab40a66ad..b27a527477 100644 --- a/p2p/base/port_unittest.cc +++ b/p2p/base/port_unittest.cc @@ -415,13 +415,6 @@ class PortTest : public ::testing::Test, public sigslot::has_slots<> { role_conflict_(false), ports_destroyed_(0) {} - ~PortTest() { - // Workaround for tests that trigger async destruction of objects that we - // need to give an opportunity here to run, before proceeding with other - // teardown. - rtc::Thread::Current()->ProcessMessages(0); - } - protected: std::string password() { return password_; } diff --git a/rtc_base/thread.cc b/rtc_base/thread.cc index 307d499255..aaf6c19b82 100644 --- a/rtc_base/thread.cc +++ b/rtc_base/thread.cc @@ -1223,6 +1223,11 @@ AutoSocketServerThread::AutoSocketServerThread(SocketServer* ss) AutoSocketServerThread::~AutoSocketServerThread() { RTC_DCHECK(ThreadManager::Instance()->CurrentThread() == this); + // Some tests post destroy messages to this thread. To avoid memory + // leaks, we have to process those messages. In particular + // P2PTransportChannelPingTest, relying on the message posted in + // cricket::Connection::Destroy. + ProcessMessages(0); // Stop and destroy the thread before clearing it as the current thread. // Sometimes there are messages left in the Thread that will be // destroyed by DoDestroy, and sometimes the destructors of the message and/or From 9aa4aebee55a53b99b769199211ce21c86003194 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Fri, 25 Feb 2022 02:07:52 -0800 Subject: [PATCH 051/847] Roll chromium_revision 2136e05894..0e95c9b57e (974952:975060) Change log: https://chromium.googlesource.com/chromium/src/+log/2136e05894..0e95c9b57e Full diff: https://chromium.googlesource.com/chromium/src/+/2136e05894..0e95c9b57e Changed dependencies * src/build: https://chromium.googlesource.com/chromium/src/build/+log/f982200c74..9e7c4ed752 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/14c5557274..eac958fe5e * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/f039863bab..e867c867ab * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/84f3d6bf8f..aea4a23ebb * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/62a74cf243..392c66f379 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/ebe914c964..d6bfa6aaf0 DEPS diff: https://chromium.googlesource.com/chromium/src/+/2136e05894..0e95c9b57e/DEPS No update to Clang. BUG=None Change-Id: Iefa22a2d6b9e75b58b46691c35852d7b6ccbcb20 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252601 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36077} --- DEPS | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/DEPS b/DEPS index efff298956..2737aa5375 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': '2136e058949005992a67a35f8e766825bcddf028', + 'chromium_revision': '0e95c9b57ef0976c45e1bc745832f1cf7d12ce29', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -25,7 +25,7 @@ deps = { 'src/base': 'https://chromium.googlesource.com/chromium/src/base@42d67a004d1cf13b02017b474786a64fe259070f', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@f982200c74b89119a69ba58fbcc90f1ee5f19d3f', + 'https://chromium.googlesource.com/chromium/src/build@9e7c4ed7523b9e7e05f307facf3567a96eaad26e', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@893aa038dd17d05f3c5ff5af98daebabc294a948', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@14c55572748e3f8c85656a160760e069d993b5e5', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@eac958fe5ec2e399d0aced58e2f0c9de1bf6d495', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@f039863bab0c8c0dec38717d2bfe6c9fa2c9c714', + 'https://chromium.googlesource.com/chromium/src/testing@e867c867ab4646cebb173ea71fe979f8cae1c35d', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@84f3d6bf8f0702eeaa0b565bb511cf9568e1df32', + 'https://chromium.googlesource.com/chromium/src/third_party@aea4a23ebb9b8ce66942b58e2aa0c910b66f3385', 'src/buildtools/linux64': { 'packages': [ @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@62a74cf243b4a63011f561ee10e57635a914df08', + 'https://chromium.googlesource.com/catapult.git@392c66f379f22799379b5d10d577bb2a73b2723c', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@ebe914c9646b756b1768e1b8ada2ce2653b7e70d', + 'https://chromium.googlesource.com/chromium/src/tools@d6bfa6aaf05643ea82f54448a6e88dd388fd4cc5', 'src/third_party/accessibility_test_framework': { 'packages': [ From 05ea12e5136493a8977e0bb4a81a6ff8d06ec92f Mon Sep 17 00:00:00 2001 From: Taylor Brandstetter Date: Fri, 25 Feb 2022 02:28:35 +0000 Subject: [PATCH 052/847] Revert "Removing MessageHandler dependency from Connection." This reverts commit 3202e29f72b4f511fcf6e92ef9b0dcbfee6089ff. Reason for revert: Introduced a crash in the task posted by Destroy() Original change's description: > Removing MessageHandler dependency from Connection. > > Bug: webrtc:11988 > Change-Id: Ic35bb5baeafbda7210012dceb0d6d5f5b3eb95c9 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/249941 > Reviewed-by: Niels Moller > Commit-Queue: Tomas Gunnarsson > Cr-Commit-Position: refs/heads/main@{#35890} No-Try: True Bug: webrtc:11988 Change-Id: Ie70ee145fde75b8cf76b02784176970e7a78e001 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252541 Auto-Submit: Taylor Brandstetter Reviewed-by: Mirko Bonadei Owners-Override: Mirko Bonadei Reviewed-by: Tomas Gunnarsson Commit-Queue: Tomas Gunnarsson Cr-Commit-Position: refs/heads/main@{#36078} --- p2p/base/connection.cc | 36 ++++++++-------- p2p/base/connection.h | 8 +++- p2p/base/p2p_transport_channel_unittest.cc | 3 -- p2p/base/tcp_port.cc | 42 +++++++++++-------- p2p/base/tcp_port.h | 10 +++-- pc/scenario_tests/goog_cc_test.cc | 3 -- .../tests/remote_estimate_test.cc | 2 - .../tests/unsignaled_stream_test.cc | 2 - 8 files changed, 55 insertions(+), 51 deletions(-) diff --git a/p2p/base/connection.cc b/p2p/base/connection.cc index a04f318acb..8575d65945 100644 --- a/p2p/base/connection.cc +++ b/p2p/base/connection.cc @@ -18,7 +18,6 @@ #include #include "absl/algorithm/container.h" -#include "absl/memory/memory.h" #include "absl/strings/match.h" #include "p2p/base/port_allocator.h" #include "rtc_base/checks.h" @@ -834,25 +833,15 @@ void Connection::Prune() { void Connection::Destroy() { RTC_DCHECK_RUN_ON(network_thread_); - RTC_DLOG(LS_VERBOSE) << ToString() << ": Connection destroyed"; - - // Fire the 'destroyed' event before deleting the object. This is done - // intentionally to avoid a situation whereby the signal might have dangling - // pointers to objects that have been deleted by the time the async task - // that deletes the connection object runs. - SignalDestroyed(this); - SignalDestroyed.disconnect_all(); - + // TODO(deadbeef, nisse): This may leak if an application closes a + // PeerConnection and then quickly destroys the PeerConnectionFactory (along + // with the networking thread on which this message is posted). Also affects + // tests, with a workaround in + // AutoSocketServerThread::~AutoSocketServerThread. + RTC_LOG(LS_VERBOSE) << ToString() << ": Connection destroyed"; + // TODO(bugs.webrtc.org/11988): Use PostTask. + port_->thread()->Post(RTC_FROM_HERE, this, MSG_DELETE); LogCandidatePairConfig(webrtc::IceCandidatePairConfigType::kDestroyed); - - // Unwind the stack before deleting the object in case upstream callers - // need to refer to the Connection's state as part of teardown. - // NOTE: We move ownership of 'this' into the capture section of the lambda - // so that the object will always be deleted, including if PostTask fails. - // In such a case (only tests), deletion would happen inside of the call - // to `Destroy()`. - network_thread_->PostTask( - webrtc::ToQueuedTask([me = absl::WrapUnique(this)]() {})); } void Connection::FailAndDestroy() { @@ -1433,6 +1422,15 @@ void Connection::MaybeUpdatePeerReflexiveCandidate( } } +void Connection::OnMessage(rtc::Message* pmsg) { + RTC_DCHECK_RUN_ON(network_thread_); + RTC_DCHECK(pmsg->message_id == MSG_DELETE); + RTC_LOG(LS_INFO) << "Connection deleted with number of pings sent: " + << num_pings_sent_; + SignalDestroyed(this); + delete this; +} + int64_t Connection::last_received() const { RTC_DCHECK_RUN_ON(network_thread_); return std::max(last_data_received_, diff --git a/p2p/base/connection.h b/p2p/base/connection.h index 8254706318..c102194498 100644 --- a/p2p/base/connection.h +++ b/p2p/base/connection.h @@ -70,7 +70,9 @@ class ConnectionRequest : public StunRequest { // Represents a communication link between a port on the local client and a // port on the remote client. -class Connection : public CandidatePairInterface, public sigslot::has_slots<> { +class Connection : public CandidatePairInterface, + public rtc::MessageHandlerAutoCleanup, + public sigslot::has_slots<> { public: struct SentPing { SentPing(const std::string id, int64_t sent_time, uint32_t nomination) @@ -318,6 +320,8 @@ class Connection : public CandidatePairInterface, public sigslot::has_slots<> { void set_remote_nomination(uint32_t remote_nomination); protected: + enum { MSG_DELETE = 0, MSG_FIRST_AVAILABLE }; + // Constructs a new connection to the given remote port. Connection(Port* port, size_t index, const Candidate& candidate); @@ -347,6 +351,8 @@ class Connection : public CandidatePairInterface, public sigslot::has_slots<> { void set_state(IceCandidatePairState state); void set_connected(bool value); + void OnMessage(rtc::Message* pmsg) override; + // The local port where this connection sends and receives packets. Port* port() { return port_; } const Port* port() const { return port_; } diff --git a/p2p/base/p2p_transport_channel_unittest.cc b/p2p/base/p2p_transport_channel_unittest.cc index 0a24f8c030..7aed20a669 100644 --- a/p2p/base/p2p_transport_channel_unittest.cc +++ b/p2p/base/p2p_transport_channel_unittest.cc @@ -483,9 +483,6 @@ class P2PTransportChannelTestBase : public ::testing::Test, ep2_.cd1_.ch_.reset(); ep1_.cd2_.ch_.reset(); ep2_.cd2_.ch_.reset(); - // Process pending tasks that need to run for cleanup purposes such as - // pending deletion of Connection objects (see Connection::Destroy). - rtc::Thread::Current()->ProcessMessages(0); } P2PTransportChannel* ep1_ch1() { return ep1_.cd1_.ch_.get(); } P2PTransportChannel* ep1_ch2() { return ep1_.cd2_.ch_.get(); } diff --git a/p2p/base/tcp_port.cc b/p2p/base/tcp_port.cc index 445b0d03a5..9d542074a4 100644 --- a/p2p/base/tcp_port.cc +++ b/p2p/base/tcp_port.cc @@ -79,7 +79,6 @@ #include "rtc_base/logging.h" #include "rtc_base/net_helper.h" #include "rtc_base/rate_tracker.h" -#include "rtc_base/task_utils/to_queued_task.h" #include "rtc_base/third_party/sigslot/sigslot.h" namespace cricket { @@ -367,9 +366,7 @@ TCPConnection::TCPConnection(TCPPort* port, } } -TCPConnection::~TCPConnection() { - RTC_DCHECK_RUN_ON(network_thread_); -} +TCPConnection::~TCPConnection() {} int TCPConnection::Send(const void* data, size_t size, @@ -496,20 +493,11 @@ void TCPConnection::OnClose(rtc::AsyncPacketSocket* socket, int error) { // events. pretending_to_be_writable_ = true; - // If this connection can't become connected and writable again in 5 - // seconds, it's time to tear this down. This is the case for the original - // TCP connection on passive side during a reconnect. // We don't attempt reconnect right here. This is to avoid a case where the // shutdown is intentional and reconnect is not necessary. We only reconnect // when the connection is used to Send() or Ping(). - port()->thread()->PostDelayedTask( - webrtc::ToQueuedTask(network_safety_, - [this]() { - if (pretending_to_be_writable_) { - Destroy(); - } - }), - reconnection_timeout()); + port()->thread()->PostDelayed(RTC_FROM_HERE, reconnection_timeout(), this, + MSG_TCPCONNECTION_DELAYED_ONCLOSE); } else if (!pretending_to_be_writable_) { // OnClose could be called when the underneath socket times out during the // initial connect() (i.e. `pretending_to_be_writable_` is false) . We have @@ -519,6 +507,24 @@ void TCPConnection::OnClose(rtc::AsyncPacketSocket* socket, int error) { } } +void TCPConnection::OnMessage(rtc::Message* pmsg) { + switch (pmsg->message_id) { + case MSG_TCPCONNECTION_DELAYED_ONCLOSE: + // If this connection can't become connected and writable again in 5 + // seconds, it's time to tear this down. This is the case for the original + // TCP connection on passive side during a reconnect. + if (pretending_to_be_writable_) { + Destroy(); + } + break; + case MSG_TCPCONNECTION_FAILED_CREATE_SOCKET: + FailAndPrune(); + break; + default: + Connection::OnMessage(pmsg); + } +} + void TCPConnection::MaybeReconnect() { // Only reconnect for an outgoing TCPConnection when OnClose was signaled and // no outstanding reconnect is pending. @@ -570,13 +576,13 @@ void TCPConnection::CreateOutgoingTcpSocket() { } else { RTC_LOG(LS_WARNING) << ToString() << ": Failed to create connection to " << remote_candidate().address().ToSensitiveString(); - set_state(IceCandidatePairState::FAILED); // We can't FailAndPrune directly here. FailAndPrune and deletes all // the StunRequests from the request_map_. And if this is in the stack // of Connection::Ping(), we are still using the request. // Unwind the stack and defer the FailAndPrune. - port()->thread()->PostTask( - webrtc::ToQueuedTask(network_safety_, [this]() { FailAndPrune(); })); + set_state(IceCandidatePairState::FAILED); + port()->thread()->Post(RTC_FROM_HERE, this, + MSG_TCPCONNECTION_FAILED_CREATE_SOCKET); } } diff --git a/p2p/base/tcp_port.h b/p2p/base/tcp_port.h index 07d483cc3f..932af50aa4 100644 --- a/p2p/base/tcp_port.h +++ b/p2p/base/tcp_port.h @@ -20,7 +20,6 @@ #include "p2p/base/port.h" #include "rtc_base/async_packet_socket.h" #include "rtc_base/containers/flat_map.h" -#include "rtc_base/task_utils/pending_task_safety_flag.h" namespace cricket { @@ -136,6 +135,8 @@ class TCPConnection : public Connection { rtc::AsyncPacketSocket* socket() { return socket_.get(); } + void OnMessage(rtc::Message* pmsg) override; + // Allow test cases to overwrite the default timeout period. int reconnection_timeout() const { return reconnection_timeout_; } void set_reconnection_timeout(int timeout_in_ms) { @@ -143,6 +144,11 @@ class TCPConnection : public Connection { } protected: + enum { + MSG_TCPCONNECTION_DELAYED_ONCLOSE = Connection::MSG_FIRST_AVAILABLE, + MSG_TCPCONNECTION_FAILED_CREATE_SOCKET, + }; + // Set waiting_for_stun_binding_complete_ to false to allow data packets in // addition to what Port::OnConnectionRequestResponse does. void OnConnectionRequestResponse(ConnectionRequest* req, @@ -184,8 +190,6 @@ class TCPConnection : public Connection { // Allow test case to overwrite the default timeout period. int reconnection_timeout_; - webrtc::ScopedTaskSafety network_safety_; - friend class TCPPort; }; diff --git a/pc/scenario_tests/goog_cc_test.cc b/pc/scenario_tests/goog_cc_test.cc index f0a30dfd86..82ae47b0c7 100644 --- a/pc/scenario_tests/goog_cc_test.cc +++ b/pc/scenario_tests/goog_cc_test.cc @@ -100,9 +100,6 @@ TEST(GoogCcPeerScenarioTest, MAYBE_NoBweChangeFromVideoUnmute) { s.ProcessMessages(TimeDelta::Seconds(1)); EXPECT_GE(get_bwe(), initial_bwe); } - - caller->pc()->Close(); - callee->pc()->Close(); } } // namespace test diff --git a/test/peer_scenario/tests/remote_estimate_test.cc b/test/peer_scenario/tests/remote_estimate_test.cc index 9190f5c92e..429a5b4ef6 100644 --- a/test/peer_scenario/tests/remote_estimate_test.cc +++ b/test/peer_scenario/tests/remote_estimate_test.cc @@ -102,8 +102,6 @@ TEST(RemoteEstimateEndToEnd, AudioUsesAbsSendTimeExtension) { } }); RTC_CHECK(s.WaitAndProcess(&received_abs_send_time)); - caller->pc()->Close(); - callee->pc()->Close(); } } // namespace test } // namespace webrtc diff --git a/test/peer_scenario/tests/unsignaled_stream_test.cc b/test/peer_scenario/tests/unsignaled_stream_test.cc index 4f478b4b2a..5cb0405a62 100644 --- a/test/peer_scenario/tests/unsignaled_stream_test.cc +++ b/test/peer_scenario/tests/unsignaled_stream_test.cc @@ -254,8 +254,6 @@ TEST_P(UnsignaledStreamTest, ReplacesUnsignaledStreamOnCompletedSignaling) { }); EXPECT_TRUE(s.WaitAndProcess(&offer_exchange_done)); EXPECT_TRUE(s.WaitAndProcess(&second_sink.frame_observed_)); - caller->pc()->Close(); - callee->pc()->Close(); } INSTANTIATE_TEST_SUITE_P( From cb24158698e31cadd061c033d69ed962828b9e72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Terelius?= Date: Fri, 25 Feb 2022 08:22:38 +0000 Subject: [PATCH 053/847] Reland "Reland "Refactor AnalyzerConfig to use Timestamps instead of microseconds."" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 7306c75c12e6dd70e1f1a0904b6bda347423a556. Reason for revert: Downstream updated Original change's description: > Revert "Reland "Refactor AnalyzerConfig to use Timestamps instead of microseconds."" > > This reverts commit 7a992e21b9c3ff03aa34488a9c91fa580ca4faa6. > > Reason for revert: Breaks downstream build due to type change. > > Original change's description: > > Reland "Refactor AnalyzerConfig to use Timestamps instead of microseconds." > > > > This is a reland of 43fb16921b29ecd3a2d87876dda75c575e05f66a > > > > Original change's description: > > > Refactor AnalyzerConfig to use Timestamps instead of microseconds. > > > > > > Add optional offset-to-UTC parameter to output. This allows aligning > > > the x-axis in the generated charts to other UTC-based logs. > > > > > > Bug: b/215140373 > > > Change-Id: I65bcd295718acbb8c94e363907c1abc458067bfd > > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/250203 > > > Reviewed-by: Kristoffer Erlandsson > > > Commit-Queue: Björn Terelius > > > Cr-Commit-Position: refs/heads/main@{#35992} > > > > Bug: b/215140373 > > Change-Id: Id2b88cc4b8078a97275d49a617581cbbd02d2c6f > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252380 > > Reviewed-by: Kristoffer Erlandsson > > Commit-Queue: Björn Terelius > > Cr-Commit-Position: refs/heads/main@{#36066} > > Bug: b/215140373 > Change-Id: I951ac26b8176e58da18e93835f13f6b9deb6d4fa > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252443 > Auto-Submit: Björn Terelius > Bot-Commit: rubber-stamper@appspot.gserviceaccount.com > Commit-Queue: Björn Terelius > Cr-Commit-Position: refs/heads/main@{#36068} Bug: b/215140373 Change-Id: Ie2b9a961d1e09dbeabeb6bfb02b43c047df69515 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252582 Bot-Commit: rubber-stamper@appspot.gserviceaccount.com Commit-Queue: Björn Terelius Reviewed-by: Kristoffer Erlandsson Cr-Commit-Position: refs/heads/main@{#36079} --- .../rtc_event_log/events/logged_rtp_rtcp.h | 16 ++ .../events/rtc_event_alr_state.h | 1 + .../rtc_event_audio_network_adaptation.h | 1 + .../events/rtc_event_audio_playout.h | 1 + .../rtc_event_audio_receive_stream_config.h | 1 + .../rtc_event_audio_send_stream_config.h | 1 + .../events/rtc_event_begin_log.h | 1 + .../events/rtc_event_bwe_update_delay_based.h | 1 + .../events/rtc_event_bwe_update_loss_based.h | 1 + .../events/rtc_event_dtls_transport_state.h | 1 + .../events/rtc_event_dtls_writable_state.h | 1 + .../rtc_event_log/events/rtc_event_end_log.h | 1 + .../events/rtc_event_frame_decoded.h | 1 + .../events/rtc_event_generic_ack_received.h | 1 + .../rtc_event_generic_packet_received.h | 1 + .../events/rtc_event_generic_packet_sent.h | 1 + .../events/rtc_event_ice_candidate_pair.h | 1 + .../rtc_event_ice_candidate_pair_config.h | 1 + .../events/rtc_event_probe_cluster_created.h | 1 + .../events/rtc_event_probe_result_failure.h | 1 + .../events/rtc_event_probe_result_success.h | 1 + .../events/rtc_event_remote_estimate.h | 1 + .../events/rtc_event_route_change.h | 1 + .../rtc_event_video_receive_stream_config.h | 1 + .../rtc_event_video_send_stream_config.h | 1 + logging/rtc_event_log/rtc_event_log_parser.cc | 24 +-- logging/rtc_event_log/rtc_event_log_parser.h | 8 +- .../rtc_event_log/rtc_event_log_unittest.cc | 4 +- rtc_tools/rtc_event_log_visualizer/alerts.cc | 18 ++- .../rtc_event_log_visualizer/analyze_audio.cc | 22 +-- .../rtc_event_log_visualizer/analyzer.cc | 149 +++++++++--------- .../analyzer_common.h | 42 +++-- rtc_tools/rtc_event_log_visualizer/main.cc | 9 +- .../rtc_event_log_visualizer/plot_base.cc | 6 +- .../rtc_event_log_visualizer/plot_base.h | 6 + .../proto/chart.proto | 4 + 36 files changed, 203 insertions(+), 129 deletions(-) diff --git a/logging/rtc_event_log/events/logged_rtp_rtcp.h b/logging/rtc_event_log/events/logged_rtp_rtcp.h index 179d70dd63..053a16371d 100644 --- a/logging/rtc_event_log/events/logged_rtp_rtcp.h +++ b/logging/rtc_event_log/events/logged_rtp_rtcp.h @@ -41,6 +41,7 @@ struct LoggedRtpPacket { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp; // TODO(terelius): This allocates space for 15 CSRCs even if none are used. @@ -57,6 +58,7 @@ struct LoggedRtpPacketIncoming { : rtp(timestamp, header, header_length, total_length) {} int64_t log_time_us() const { return rtp.timestamp.us(); } int64_t log_time_ms() const { return rtp.timestamp.ms(); } + Timestamp log_time() const { return rtp.timestamp; } LoggedRtpPacket rtp; }; @@ -69,6 +71,7 @@ struct LoggedRtpPacketOutgoing { : rtp(timestamp, header, header_length, total_length) {} int64_t log_time_us() const { return rtp.timestamp.us(); } int64_t log_time_ms() const { return rtp.timestamp.ms(); } + Timestamp log_time() const { return rtp.timestamp; } LoggedRtpPacket rtp; }; @@ -87,6 +90,7 @@ struct LoggedRtcpPacket { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp; std::vector raw_data; @@ -101,6 +105,7 @@ struct LoggedRtcpPacketIncoming { int64_t log_time_us() const { return rtcp.timestamp.us(); } int64_t log_time_ms() const { return rtcp.timestamp.ms(); } + Timestamp log_time() const { return rtcp.timestamp; } LoggedRtcpPacket rtcp; }; @@ -114,6 +119,7 @@ struct LoggedRtcpPacketOutgoing { int64_t log_time_us() const { return rtcp.timestamp.us(); } int64_t log_time_ms() const { return rtcp.timestamp.ms(); } + Timestamp log_time() const { return rtcp.timestamp; } LoggedRtcpPacket rtcp; }; @@ -126,6 +132,7 @@ struct LoggedRtcpPacketReceiverReport { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::ReceiverReport rr; @@ -139,6 +146,7 @@ struct LoggedRtcpPacketSenderReport { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::SenderReport sr; @@ -149,6 +157,7 @@ struct LoggedRtcpPacketExtendedReports { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::ExtendedReports xr; @@ -161,6 +170,7 @@ struct LoggedRtcpPacketRemb { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::Remb remb; @@ -173,6 +183,7 @@ struct LoggedRtcpPacketNack { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::Nack nack; @@ -183,6 +194,7 @@ struct LoggedRtcpPacketFir { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::Fir fir; @@ -193,6 +205,7 @@ struct LoggedRtcpPacketPli { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::Pli pli; @@ -209,6 +222,7 @@ struct LoggedRtcpPacketTransportFeedback { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::TransportFeedback transport_feedback; @@ -223,6 +237,7 @@ struct LoggedRtcpPacketLossNotification { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::LossNotification loss_notification; @@ -233,6 +248,7 @@ struct LoggedRtcpPacketBye { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtcp::Bye bye; diff --git a/logging/rtc_event_log/events/rtc_event_alr_state.h b/logging/rtc_event_log/events/rtc_event_alr_state.h index 44e68a680e..9f595ecd90 100644 --- a/logging/rtc_event_log/events/rtc_event_alr_state.h +++ b/logging/rtc_event_log/events/rtc_event_alr_state.h @@ -32,6 +32,7 @@ struct LoggedAlrStateEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); bool in_alr; diff --git a/logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h b/logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h index b9e919c2e8..d4cae3abfa 100644 --- a/logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h +++ b/logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h @@ -31,6 +31,7 @@ struct LoggedAudioNetworkAdaptationEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); AudioEncoderRuntimeConfig config; diff --git a/logging/rtc_event_log/events/rtc_event_audio_playout.h b/logging/rtc_event_log/events/rtc_event_audio_playout.h index 3788324d15..196c3ca247 100644 --- a/logging/rtc_event_log/events/rtc_event_audio_playout.h +++ b/logging/rtc_event_log/events/rtc_event_audio_playout.h @@ -32,6 +32,7 @@ struct LoggedAudioPlayoutEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); uint32_t ssrc; diff --git a/logging/rtc_event_log/events/rtc_event_audio_receive_stream_config.h b/logging/rtc_event_log/events/rtc_event_audio_receive_stream_config.h index ac8813c937..9863e235af 100644 --- a/logging/rtc_event_log/events/rtc_event_audio_receive_stream_config.h +++ b/logging/rtc_event_log/events/rtc_event_audio_receive_stream_config.h @@ -30,6 +30,7 @@ struct LoggedAudioRecvConfig { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtclog::StreamConfig config; diff --git a/logging/rtc_event_log/events/rtc_event_audio_send_stream_config.h b/logging/rtc_event_log/events/rtc_event_audio_send_stream_config.h index 8b699e71cf..550723bcf0 100644 --- a/logging/rtc_event_log/events/rtc_event_audio_send_stream_config.h +++ b/logging/rtc_event_log/events/rtc_event_audio_send_stream_config.h @@ -29,6 +29,7 @@ struct LoggedAudioSendConfig { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtclog::StreamConfig config; diff --git a/logging/rtc_event_log/events/rtc_event_begin_log.h b/logging/rtc_event_log/events/rtc_event_begin_log.h index 8dc47b5a02..f3b74c117e 100644 --- a/logging/rtc_event_log/events/rtc_event_begin_log.h +++ b/logging/rtc_event_log/events/rtc_event_begin_log.h @@ -35,6 +35,7 @@ struct LoggedStartEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp utc_time() const { return utc_start_time; } diff --git a/logging/rtc_event_log/events/rtc_event_bwe_update_delay_based.h b/logging/rtc_event_log/events/rtc_event_bwe_update_delay_based.h index 4f145de412..796f119388 100644 --- a/logging/rtc_event_log/events/rtc_event_bwe_update_delay_based.h +++ b/logging/rtc_event_log/events/rtc_event_bwe_update_delay_based.h @@ -76,6 +76,7 @@ struct LoggedBweDelayBasedUpdate { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); int32_t bitrate_bps; diff --git a/logging/rtc_event_log/events/rtc_event_bwe_update_loss_based.h b/logging/rtc_event_log/events/rtc_event_bwe_update_loss_based.h index 1caf818a0c..fd41b316e0 100644 --- a/logging/rtc_event_log/events/rtc_event_bwe_update_loss_based.h +++ b/logging/rtc_event_log/events/rtc_event_bwe_update_loss_based.h @@ -37,6 +37,7 @@ struct LoggedBweLossBasedUpdate { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); int32_t bitrate_bps; diff --git a/logging/rtc_event_log/events/rtc_event_dtls_transport_state.h b/logging/rtc_event_log/events/rtc_event_dtls_transport_state.h index c2496dd532..b9af213256 100644 --- a/logging/rtc_event_log/events/rtc_event_dtls_transport_state.h +++ b/logging/rtc_event_log/events/rtc_event_dtls_transport_state.h @@ -26,6 +26,7 @@ namespace webrtc { struct LoggedDtlsTransportState { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); DtlsTransportState dtls_transport_state; diff --git a/logging/rtc_event_log/events/rtc_event_dtls_writable_state.h b/logging/rtc_event_log/events/rtc_event_dtls_writable_state.h index 20221df9da..c820f184d7 100644 --- a/logging/rtc_event_log/events/rtc_event_dtls_writable_state.h +++ b/logging/rtc_event_log/events/rtc_event_dtls_writable_state.h @@ -28,6 +28,7 @@ struct LoggedDtlsWritableState { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); bool writable; diff --git a/logging/rtc_event_log/events/rtc_event_end_log.h b/logging/rtc_event_log/events/rtc_event_end_log.h index ed7770f339..79648bdb8d 100644 --- a/logging/rtc_event_log/events/rtc_event_end_log.h +++ b/logging/rtc_event_log/events/rtc_event_end_log.h @@ -32,6 +32,7 @@ struct LoggedStopEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::PlusInfinity(); }; diff --git a/logging/rtc_event_log/events/rtc_event_frame_decoded.h b/logging/rtc_event_log/events/rtc_event_frame_decoded.h index db5162cd0d..91190faea9 100644 --- a/logging/rtc_event_log/events/rtc_event_frame_decoded.h +++ b/logging/rtc_event_log/events/rtc_event_frame_decoded.h @@ -29,6 +29,7 @@ namespace webrtc { struct LoggedFrameDecoded { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); int64_t render_time_ms; diff --git a/logging/rtc_event_log/events/rtc_event_generic_ack_received.h b/logging/rtc_event_log/events/rtc_event_generic_ack_received.h index d1ad0f1fef..57fd7cd9a6 100644 --- a/logging/rtc_event_log/events/rtc_event_generic_ack_received.h +++ b/logging/rtc_event_log/events/rtc_event_generic_ack_received.h @@ -36,6 +36,7 @@ struct LoggedGenericAckReceived { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); int64_t packet_number; diff --git a/logging/rtc_event_log/events/rtc_event_generic_packet_received.h b/logging/rtc_event_log/events/rtc_event_generic_packet_received.h index fddee67740..a6006ca4d4 100644 --- a/logging/rtc_event_log/events/rtc_event_generic_packet_received.h +++ b/logging/rtc_event_log/events/rtc_event_generic_packet_received.h @@ -33,6 +33,7 @@ struct LoggedGenericPacketReceived { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); int64_t packet_number; diff --git a/logging/rtc_event_log/events/rtc_event_generic_packet_sent.h b/logging/rtc_event_log/events/rtc_event_generic_packet_sent.h index 0f839ca949..903950a398 100644 --- a/logging/rtc_event_log/events/rtc_event_generic_packet_sent.h +++ b/logging/rtc_event_log/events/rtc_event_generic_packet_sent.h @@ -37,6 +37,7 @@ struct LoggedGenericPacketSent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } size_t packet_length() const { return payload_length + padding_length + overhead_length; diff --git a/logging/rtc_event_log/events/rtc_event_ice_candidate_pair.h b/logging/rtc_event_log/events/rtc_event_ice_candidate_pair.h index 85cf79735a..bdacf15a59 100644 --- a/logging/rtc_event_log/events/rtc_event_ice_candidate_pair.h +++ b/logging/rtc_event_log/events/rtc_event_ice_candidate_pair.h @@ -45,6 +45,7 @@ struct LoggedIceCandidatePairEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); IceCandidatePairEventType type; diff --git a/logging/rtc_event_log/events/rtc_event_ice_candidate_pair_config.h b/logging/rtc_event_log/events/rtc_event_ice_candidate_pair_config.h index 0dfbfc838a..e72d999cff 100644 --- a/logging/rtc_event_log/events/rtc_event_ice_candidate_pair_config.h +++ b/logging/rtc_event_log/events/rtc_event_ice_candidate_pair_config.h @@ -72,6 +72,7 @@ enum class IceCandidateNetworkType { struct LoggedIceCandidatePairConfig { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); IceCandidatePairConfigType type; diff --git a/logging/rtc_event_log/events/rtc_event_probe_cluster_created.h b/logging/rtc_event_log/events/rtc_event_probe_cluster_created.h index b91d89c239..ae6810c39d 100644 --- a/logging/rtc_event_log/events/rtc_event_probe_cluster_created.h +++ b/logging/rtc_event_log/events/rtc_event_probe_cluster_created.h @@ -39,6 +39,7 @@ struct LoggedBweProbeClusterCreatedEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); int32_t id; diff --git a/logging/rtc_event_log/events/rtc_event_probe_result_failure.h b/logging/rtc_event_log/events/rtc_event_probe_result_failure.h index ba4db75c66..1aa6e75cb7 100644 --- a/logging/rtc_event_log/events/rtc_event_probe_result_failure.h +++ b/logging/rtc_event_log/events/rtc_event_probe_result_failure.h @@ -40,6 +40,7 @@ struct LoggedBweProbeFailureEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); int32_t id; diff --git a/logging/rtc_event_log/events/rtc_event_probe_result_success.h b/logging/rtc_event_log/events/rtc_event_probe_result_success.h index 172e9aa2eb..49d1abec5a 100644 --- a/logging/rtc_event_log/events/rtc_event_probe_result_success.h +++ b/logging/rtc_event_log/events/rtc_event_probe_result_success.h @@ -33,6 +33,7 @@ struct LoggedBweProbeSuccessEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); int32_t id; diff --git a/logging/rtc_event_log/events/rtc_event_remote_estimate.h b/logging/rtc_event_log/events/rtc_event_remote_estimate.h index 17de63c475..4a39ecc597 100644 --- a/logging/rtc_event_log/events/rtc_event_remote_estimate.h +++ b/logging/rtc_event_log/events/rtc_event_remote_estimate.h @@ -28,6 +28,7 @@ struct LoggedRemoteEstimateEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); absl::optional link_capacity_lower; diff --git a/logging/rtc_event_log/events/rtc_event_route_change.h b/logging/rtc_event_log/events/rtc_event_route_change.h index 542d15e3b3..bc1461d7bb 100644 --- a/logging/rtc_event_log/events/rtc_event_route_change.h +++ b/logging/rtc_event_log/events/rtc_event_route_change.h @@ -29,6 +29,7 @@ struct LoggedRouteChangeEvent { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); bool connected; diff --git a/logging/rtc_event_log/events/rtc_event_video_receive_stream_config.h b/logging/rtc_event_log/events/rtc_event_video_receive_stream_config.h index f3380d1bb6..0be56c2065 100644 --- a/logging/rtc_event_log/events/rtc_event_video_receive_stream_config.h +++ b/logging/rtc_event_log/events/rtc_event_video_receive_stream_config.h @@ -30,6 +30,7 @@ struct LoggedVideoRecvConfig { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtclog::StreamConfig config; diff --git a/logging/rtc_event_log/events/rtc_event_video_send_stream_config.h b/logging/rtc_event_log/events/rtc_event_video_send_stream_config.h index 15c28999dc..f1717b19ea 100644 --- a/logging/rtc_event_log/events/rtc_event_video_send_stream_config.h +++ b/logging/rtc_event_log/events/rtc_event_video_send_stream_config.h @@ -30,6 +30,7 @@ struct LoggedVideoSendConfig { int64_t log_time_us() const { return timestamp.us(); } int64_t log_time_ms() const { return timestamp.ms(); } + Timestamp log_time() const { return timestamp; } Timestamp timestamp = Timestamp::MinusInfinity(); rtclog::StreamConfig config; diff --git a/logging/rtc_event_log/rtc_event_log_parser.cc b/logging/rtc_event_log/rtc_event_log_parser.cc index f0d165bdb2..b4392e8088 100644 --- a/logging/rtc_event_log/rtc_event_log_parser.cc +++ b/logging/rtc_event_log/rtc_event_log_parser.cc @@ -1110,8 +1110,8 @@ void ParsedRtcEventLog::Clear() { last_incoming_rtcp_packet_.clear(); - first_timestamp_ = std::numeric_limits::max(); - last_timestamp_ = std::numeric_limits::min(); + first_timestamp_ = Timestamp::PlusInfinity(); + last_timestamp_ = Timestamp::MinusInfinity(); first_log_segment_ = LogSegment(0, std::numeric_limits::max()); incoming_rtp_extensions_maps_.clear(); @@ -1232,8 +1232,8 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::ParseStream( // stream configurations and starting/stopping the log. // TODO(terelius): Figure out if we actually need to find the first and last // timestamp in the parser. It seems like this could be done by the caller. - first_timestamp_ = std::numeric_limits::max(); - last_timestamp_ = std::numeric_limits::min(); + first_timestamp_ = Timestamp::PlusInfinity(); + last_timestamp_ = Timestamp::MinusInfinity(); StoreFirstAndLastTimestamp(alr_state_events()); StoreFirstAndLastTimestamp(route_change_events()); for (const auto& audio_stream : audio_playout_events()) { @@ -1272,7 +1272,8 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::ParseStream( // event, we could use the timestamp of the the last previous regular event. auto start_iter = start_log_events().begin(); auto stop_iter = stop_log_events().begin(); - int64_t start_us = first_timestamp(); + int64_t start_us = + first_timestamp().us_or(std::numeric_limits::max()); int64_t next_start_us = std::numeric_limits::max(); int64_t stop_us = std::numeric_limits::max(); if (start_iter != start_log_events().end()) { @@ -1286,15 +1287,14 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::ParseStream( } stop_us = std::min(stop_us, next_start_us); if (stop_us == std::numeric_limits::max() && - last_timestamp() != std::numeric_limits::min()) { - stop_us = last_timestamp(); + !last_timestamp().IsMinusInfinity()) { + stop_us = last_timestamp().us(); } RTC_PARSE_CHECK_OR_RETURN_LE(start_us, stop_us); first_log_segment_ = LogSegment(start_us, stop_us); - if (first_timestamp_ == std::numeric_limits::max() && - last_timestamp_ == std::numeric_limits::min()) { - first_timestamp_ = last_timestamp_ = 0; + if (first_timestamp_ > last_timestamp_) { + first_timestamp_ = last_timestamp_ = Timestamp::Zero(); } return status; @@ -1563,8 +1563,8 @@ template void ParsedRtcEventLog::StoreFirstAndLastTimestamp(const std::vector& v) { if (v.empty()) return; - first_timestamp_ = std::min(first_timestamp_, v.front().log_time_us()); - last_timestamp_ = std::max(last_timestamp_, v.back().log_time_us()); + first_timestamp_ = std::min(first_timestamp_, v.front().log_time()); + last_timestamp_ = std::max(last_timestamp_, v.back().log_time()); } ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::StoreParsedLegacyEvent( diff --git a/logging/rtc_event_log/rtc_event_log_parser.h b/logging/rtc_event_log/rtc_event_log_parser.h index 4a9ff3495f..9ef4e347de 100644 --- a/logging/rtc_event_log/rtc_event_log_parser.h +++ b/logging/rtc_event_log/rtc_event_log_parser.h @@ -643,8 +643,8 @@ class ParsedRtcEventLog { return decoded_frames_; } - int64_t first_timestamp() const { return first_timestamp_; } - int64_t last_timestamp() const { return last_timestamp_; } + Timestamp first_timestamp() const { return first_timestamp_; } + Timestamp last_timestamp() const { return last_timestamp_; } const LogSegment& first_log_segment() const { return first_log_segment_; } @@ -889,8 +889,8 @@ class ParsedRtcEventLog { std::vector last_incoming_rtcp_packet_; - int64_t first_timestamp_; - int64_t last_timestamp_; + Timestamp first_timestamp_ = Timestamp::PlusInfinity(); + Timestamp last_timestamp_ = Timestamp::MinusInfinity(); LogSegment first_log_segment_ = LogSegment(0, std::numeric_limits::max()); diff --git a/logging/rtc_event_log/rtc_event_log_unittest.cc b/logging/rtc_event_log/rtc_event_log_unittest.cc index 8f32eecd8b..34904a5e02 100644 --- a/logging/rtc_event_log/rtc_event_log_unittest.cc +++ b/logging/rtc_event_log/rtc_event_log_unittest.cc @@ -785,8 +785,8 @@ void RtcEventLogSession::ReadAndVerifyLog() { parsed_generic_acks_received[i]); } - EXPECT_EQ(first_timestamp_ms_, parsed_log.first_timestamp() / 1000); - EXPECT_EQ(last_timestamp_ms_, parsed_log.last_timestamp() / 1000); + EXPECT_EQ(first_timestamp_ms_, parsed_log.first_timestamp().ms()); + EXPECT_EQ(last_timestamp_ms_, parsed_log.last_timestamp().ms()); EXPECT_EQ(parsed_log.first_log_segment().start_time_ms(), std::min(start_time_us_ / 1000, first_timestamp_ms_)); diff --git a/rtc_tools/rtc_event_log_visualizer/alerts.cc b/rtc_tools/rtc_event_log_visualizer/alerts.cc index 2d1868fa28..c0d8784fa8 100644 --- a/rtc_tools/rtc_event_log_visualizer/alerts.cc +++ b/rtc_tools/rtc_event_log_visualizer/alerts.cc @@ -79,7 +79,7 @@ void TriageHelper::AnalyzeStreamGaps(const ParsedRtcEventLog& parsed_log, int64_t seq_num = seq_num_unwrapper.Unwrap(packet.header.sequenceNumber); if (std::abs(seq_num - last_seq_num) > kMaxSeqNumJump) { - Alert(seq_num_alert, config_.GetCallTimeSec(packet.log_time_us()), + Alert(seq_num_alert, config_.GetCallTimeSec(packet.log_time()), seq_num_explanation); } last_seq_num = seq_num; @@ -89,7 +89,7 @@ void TriageHelper::AnalyzeStreamGaps(const ParsedRtcEventLog& parsed_log, if (std::abs(capture_time - last_capture_time) > kTicksPerMillisec * (kCaptureTimeGraceMs + packet.log_time_ms() - last_log_time_ms)) { - Alert(capture_time_alert, config_.GetCallTimeSec(packet.log_time_us()), + Alert(capture_time_alert, config_.GetCallTimeSec(packet.log_time()), capture_time_explanation); } last_capture_time = capture_time; @@ -140,7 +140,8 @@ void TriageHelper::AnalyzeTransmissionGaps(const ParsedRtcEventLog& parsed_log, int64_t duration = timestamp - last_rtp_time.value_or(0); if (last_rtp_time.has_value() && duration > kMaxRtpTransmissionGap) { // No packet sent/received for more than 500 ms. - Alert(rtp_alert, config_.GetCallTimeSec(timestamp), rtp_explanation); + Alert(rtp_alert, config_.GetCallTimeSec(Timestamp::Micros(timestamp)), + rtp_explanation); } last_rtp_time.emplace(timestamp); } @@ -155,7 +156,7 @@ void TriageHelper::AnalyzeTransmissionGaps(const ParsedRtcEventLog& parsed_log, int64_t duration = rtcp.log_time_us() - last_rtcp_time.value_or(0); if (last_rtcp_time.has_value() && duration > kMaxRtcpTransmissionGap) { // No feedback sent/received for more than 2000 ms. - Alert(rtcp_alert, config_.GetCallTimeSec(rtcp.log_time_us()), + Alert(rtcp_alert, config_.GetCallTimeSec(rtcp.log_time()), rtcp_explanation); } last_rtcp_time.emplace(rtcp.log_time_us()); @@ -169,7 +170,7 @@ void TriageHelper::AnalyzeTransmissionGaps(const ParsedRtcEventLog& parsed_log, int64_t duration = rtcp.log_time_us() - last_rtcp_time.value_or(0); if (last_rtcp_time.has_value() && duration > kMaxRtcpTransmissionGap) { // No feedback sent/received for more than 2000 ms. - Alert(rtcp_alert, config_.GetCallTimeSec(rtcp.log_time_us()), + Alert(rtcp_alert, config_.GetCallTimeSec(rtcp.log_time()), rtcp_explanation); } last_rtcp_time.emplace(rtcp.log_time_us()); @@ -189,7 +190,7 @@ void TriageHelper::AnalyzeLog(const ParsedRtcEventLog& parsed_log) { const int64_t segment_end_us = parsed_log.first_log_segment().stop_time_us(); - int64_t first_occurrence = parsed_log.last_timestamp(); + Timestamp first_occurrence = parsed_log.last_timestamp(); constexpr double kMaxLossFraction = 0.05; // Loss feedback int64_t total_lost_packets = 0; @@ -204,13 +205,14 @@ void TriageHelper::AnalyzeLog(const ParsedRtcEventLog& parsed_log) { total_lost_packets += lost_packets; total_expected_packets += bwe_update.expected_packets; if (bwe_update.fraction_lost >= 255 * kMaxLossFraction) { - first_occurrence = std::min(first_occurrence, bwe_update.log_time_us()); + first_occurrence = std::min(first_occurrence, bwe_update.log_time()); } } double avg_outgoing_loss = static_cast(total_lost_packets) / total_expected_packets; if (avg_outgoing_loss > kMaxLossFraction) { - Alert(TriageAlertType::kOutgoingHighLoss, first_occurrence, + Alert(TriageAlertType::kOutgoingHighLoss, + config_.GetCallTimeSec(first_occurrence), "More than 5% of outgoing packets lost."); } } diff --git a/rtc_tools/rtc_event_log_visualizer/analyze_audio.cc b/rtc_tools/rtc_event_log_visualizer/analyze_audio.cc index 69a753bf22..854c6d05ae 100644 --- a/rtc_tools/rtc_event_log_visualizer/analyze_audio.cc +++ b/rtc_tools/rtc_event_log_visualizer/analyze_audio.cc @@ -38,7 +38,7 @@ void CreateAudioEncoderTargetBitrateGraph(const ParsedRtcEventLog& parsed_log, return absl::nullopt; }; auto ToCallTime = [config](const LoggedAudioNetworkAdaptationEvent& packet) { - return config.GetCallTimeSec(packet.log_time_us()); + return config.GetCallTimeSec(packet.log_time()); }; ProcessPoints( ToCallTime, GetAnaBitrateBps, @@ -63,7 +63,7 @@ void CreateAudioEncoderFrameLengthGraph(const ParsedRtcEventLog& parsed_log, return absl::optional(); }; auto ToCallTime = [config](const LoggedAudioNetworkAdaptationEvent& packet) { - return config.GetCallTimeSec(packet.log_time_us()); + return config.GetCallTimeSec(packet.log_time()); }; ProcessPoints( ToCallTime, GetAnaFrameLengthMs, @@ -88,7 +88,7 @@ void CreateAudioEncoderPacketLossGraph(const ParsedRtcEventLog& parsed_log, return absl::optional(); }; auto ToCallTime = [config](const LoggedAudioNetworkAdaptationEvent& packet) { - return config.GetCallTimeSec(packet.log_time_us()); + return config.GetCallTimeSec(packet.log_time()); }; ProcessPoints( ToCallTime, GetAnaPacketLoss, @@ -114,7 +114,7 @@ void CreateAudioEncoderEnableFecGraph(const ParsedRtcEventLog& parsed_log, return absl::optional(); }; auto ToCallTime = [config](const LoggedAudioNetworkAdaptationEvent& packet) { - return config.GetCallTimeSec(packet.log_time_us()); + return config.GetCallTimeSec(packet.log_time()); }; ProcessPoints( ToCallTime, GetAnaFecEnabled, @@ -139,7 +139,7 @@ void CreateAudioEncoderEnableDtxGraph(const ParsedRtcEventLog& parsed_log, return absl::optional(); }; auto ToCallTime = [config](const LoggedAudioNetworkAdaptationEvent& packet) { - return config.GetCallTimeSec(packet.log_time_us()); + return config.GetCallTimeSec(packet.log_time()); }; ProcessPoints( ToCallTime, GetAnaDtxEnabled, @@ -164,7 +164,7 @@ void CreateAudioEncoderNumChannelsGraph(const ParsedRtcEventLog& parsed_log, return absl::optional(); }; auto ToCallTime = [config](const LoggedAudioNetworkAdaptationEvent& packet) { - return config.GetCallTimeSec(packet.log_time_us()); + return config.GetCallTimeSec(packet.log_time()); }; ProcessPoints( ToCallTime, GetAnaNumChannels, @@ -397,23 +397,23 @@ void CreateAudioJitterBufferGraph(const ParsedRtcEventLog& parsed_log, PointStyle::kHighlight); for (const auto& data : arrival_delay_ms) { - const float x = config.GetCallTimeSec(data.first * 1000); // ms to us. + const float x = config.GetCallTimeSec(Timestamp::Millis(data.first)); const float y = data.second; time_series_packet_arrival.points.emplace_back(TimeSeriesPoint(x, y)); } for (const auto& data : corrected_arrival_delay_ms) { - const float x = config.GetCallTimeSec(data.first * 1000); // ms to us. + const float x = config.GetCallTimeSec(Timestamp::Millis(data.first)); const float y = data.second; time_series_relative_packet_arrival.points.emplace_back( TimeSeriesPoint(x, y)); } for (const auto& data : playout_delay_ms) { - const float x = config.GetCallTimeSec(data.first * 1000); // ms to us. + const float x = config.GetCallTimeSec(Timestamp::Millis(data.first)); const float y = data.second; time_series_play_time.points.emplace_back(TimeSeriesPoint(x, y)); } for (const auto& data : target_delay_ms) { - const float x = config.GetCallTimeSec(data.first * 1000); // ms to us. + const float x = config.GetCallTimeSec(Timestamp::Millis(data.first)); const float y = data.second; time_series_target_time.points.emplace_back(TimeSeriesPoint(x, y)); } @@ -448,7 +448,7 @@ void CreateNetEqStatsGraphInternal( const std::vector>* data_vector = data_extractor(st.second.get()); for (const auto& data : *data_vector) { - const float time = config.GetCallTimeSec(data.first * 1000); // ms to us. + const float time = config.GetCallTimeSec(Timestamp::Millis(data.first)); const float value = stats_extractor(data.second); time_series[ssrc].points.emplace_back(TimeSeriesPoint(time, value)); } diff --git a/rtc_tools/rtc_event_log_visualizer/analyzer.cc b/rtc_tools/rtc_event_log_visualizer/analyzer.cc index b43801623c..4c718185df 100644 --- a/rtc_tools/rtc_event_log_visualizer/analyzer.cc +++ b/rtc_tools/rtc_event_log_visualizer/analyzer.cc @@ -214,7 +214,7 @@ TimeSeries CreateRtcpTypeTimeSeries(const std::vector& rtcp_list, int category_id) { TimeSeries time_series(rtcp_name, LineStyle::kNone, PointStyle::kHighlight); for (const auto& rtcp : rtcp_list) { - float x = config.GetCallTimeSec(rtcp.log_time_us()); + float x = config.GetCallTimeSec(rtcp.timestamp); float y = category_id; time_series.points.emplace_back(x, y); } @@ -346,20 +346,24 @@ std::string GetDirectionAsShortString(PacketDirection direction) { EventLogAnalyzer::EventLogAnalyzer(const ParsedRtcEventLog& log, bool normalize_time) : parsed_log_(log) { - config_.window_duration_ = 250000; - config_.step_ = 10000; + config_.window_duration_ = TimeDelta::Millis(250); + config_.step_ = TimeDelta::Millis(10); + if (!log.start_log_events().empty()) { + config_.rtc_to_utc_offset_ = log.start_log_events()[0].utc_time() - + log.start_log_events()[0].log_time(); + } config_.normalize_time_ = normalize_time; config_.begin_time_ = parsed_log_.first_timestamp(); config_.end_time_ = parsed_log_.last_timestamp(); if (config_.end_time_ < config_.begin_time_) { RTC_LOG(LS_WARNING) << "No useful events in the log."; - config_.begin_time_ = config_.end_time_ = 0; + config_.begin_time_ = config_.end_time_ = Timestamp::Zero(); } RTC_LOG(LS_INFO) << "Log is " - << (parsed_log_.last_timestamp() - - parsed_log_.first_timestamp()) / - 1000000 + << (parsed_log_.last_timestamp().ms() - + parsed_log_.first_timestamp().ms()) / + 1000 << " seconds long."; } @@ -367,9 +371,9 @@ EventLogAnalyzer::EventLogAnalyzer(const ParsedRtcEventLog& log, const AnalyzerConfig& config) : parsed_log_(log), config_(config) { RTC_LOG(LS_INFO) << "Log is " - << (parsed_log_.last_timestamp() - - parsed_log_.first_timestamp()) / - 1000000 + << (parsed_log_.last_timestamp().ms() - + parsed_log_.first_timestamp().ms()) / + 1000 << " seconds long."; } @@ -413,7 +417,7 @@ void EventLogAnalyzer::CreatePacketGraph(PacketDirection direction, return absl::optional(packet.total_length); }; auto ToCallTime = [this](const LoggedRtpPacket& packet) { - return this->config_.GetCallTimeSec(packet.log_time_us()); + return this->config_.GetCallTimeSec(packet.timestamp); }; ProcessPoints(ToCallTime, GetPacketSize, stream.packet_view, &time_series); @@ -469,7 +473,7 @@ void EventLogAnalyzer::CreateAccumulatedPacketsTimeSeries( const std::string& label) { TimeSeries time_series(label, LineStyle::kStep); for (size_t i = 0; i < packets.size(); i++) { - float x = config_.GetCallTimeSec(packets[i].log_time_us()); + float x = config_.GetCallTimeSec(packets[i].log_time()); time_series.points.emplace_back(x, i + 1); } plot->AppendTimeSeries(std::move(time_series)); @@ -545,17 +549,15 @@ void EventLogAnalyzer::CreateTotalPacketRateGraph(PacketDirection direction, // types using MovingAverage(). class LogTime { public: - explicit LogTime(int64_t log_time_us) : log_time_us_(log_time_us) {} - - int64_t log_time_us() const { return log_time_us_; } + explicit LogTime(Timestamp log_time) : log_time_(log_time) {} + Timestamp log_time() const { return log_time_; } private: - int64_t log_time_us_; + Timestamp log_time_; }; - std::vector packet_times; auto handle_rtp = [&](const LoggedRtpPacket& packet) { - packet_times.emplace_back(packet.log_time_us()); + packet_times.emplace_back(packet.log_time()); }; RtcEventProcessor process; for (const auto& stream : parsed_log_.rtp_packets_by_ssrc(direction)) { @@ -563,13 +565,13 @@ void EventLogAnalyzer::CreateTotalPacketRateGraph(PacketDirection direction, } if (direction == kIncomingPacket) { auto handle_incoming_rtcp = [&](const LoggedRtcpPacketIncoming& packet) { - packet_times.emplace_back(packet.log_time_us()); + packet_times.emplace_back(packet.log_time()); }; process.AddEvents(parsed_log_.incoming_rtcp_packets(), handle_incoming_rtcp); } else { auto handle_outgoing_rtcp = [&](const LoggedRtcpPacketOutgoing& packet) { - packet_times.emplace_back(packet.log_time_us()); + packet_times.emplace_back(packet.log_time()); }; process.AddEvents(parsed_log_.outgoing_rtcp_packets(), handle_outgoing_rtcp); @@ -599,7 +601,7 @@ void EventLogAnalyzer::CreatePlayoutGraph(Plot* plot) { absl::optional last_playout_ms; TimeSeries time_series(SsrcToString(ssrc), LineStyle::kBar); for (const auto& playout_event : playout_stream.second) { - float x = config_.GetCallTimeSec(playout_event.log_time_us()); + float x = config_.GetCallTimeSec(playout_event.log_time()); int64_t playout_time_ms = playout_event.log_time_ms(); // If there were no previous playouts, place the point on the x-axis. float y = playout_time_ms - last_playout_ms.value_or(playout_time_ms); @@ -626,7 +628,7 @@ void EventLogAnalyzer::CreateAudioLevelGraph(PacketDirection direction, LineStyle::kLine); for (auto& packet : stream.packet_view) { if (packet.header.extension.hasAudioLevel) { - float x = config_.GetCallTimeSec(packet.log_time_us()); + float x = config_.GetCallTimeSec(packet.log_time()); // The audio level is stored in -dBov (so e.g. -10 dBov is stored as 10) // Here we convert it to dBov. float y = static_cast(-packet.header.extension.audioLevel); @@ -662,7 +664,7 @@ void EventLogAnalyzer::CreateSequenceNumberGraph(Plot* plot) { return diff; }; auto ToCallTime = [this](const LoggedRtpPacketIncoming& packet) { - return this->config_.GetCallTimeSec(packet.log_time_us()); + return this->config_.GetCallTimeSec(packet.log_time()); }; ProcessPairs( ToCallTime, GetSequenceNumberDiff, stream.incoming_packets, @@ -691,8 +693,8 @@ void EventLogAnalyzer::CreateIncomingPacketLossGraph(Plot* plot) { LineStyle::kLine, PointStyle::kHighlight); // TODO(terelius): Should the window and step size be read from the class // instead? - const int64_t kWindowUs = 1000000; - const int64_t kStep = 1000000; + const TimeDelta kWindow = TimeDelta::Millis(1000); + const TimeDelta kStep = TimeDelta::Millis(1000); SeqNumUnwrapper unwrapper_; SeqNumUnwrapper prior_unwrapper_; size_t window_index_begin = 0; @@ -702,17 +704,17 @@ void EventLogAnalyzer::CreateIncomingPacketLossGraph(Plot* plot) { uint64_t highest_prior_seq_number = prior_unwrapper_.Unwrap(packets[0].rtp.header.sequenceNumber) - 1; - for (int64_t t = config_.begin_time_; t < config_.end_time_ + kStep; + for (Timestamp t = config_.begin_time_; t < config_.end_time_ + kStep; t += kStep) { while (window_index_end < packets.size() && - packets[window_index_end].rtp.log_time_us() < t) { + packets[window_index_end].rtp.log_time() < t) { uint64_t sequence_number = unwrapper_.Unwrap( packets[window_index_end].rtp.header.sequenceNumber); highest_seq_number = std::max(highest_seq_number, sequence_number); ++window_index_end; } while (window_index_begin < packets.size() && - packets[window_index_begin].rtp.log_time_us() < t - kWindowUs) { + packets[window_index_begin].rtp.log_time() < t - kWindow) { uint64_t sequence_number = prior_unwrapper_.Unwrap( packets[window_index_begin].rtp.header.sequenceNumber); highest_prior_seq_number = @@ -767,7 +769,7 @@ void EventLogAnalyzer::CreateIncomingDelayGraph(Plot* plot) { } auto ToCallTime = [this](const LoggedRtpPacketIncoming& packet) { - return this->config_.GetCallTimeSec(packet.log_time_us()); + return this->config_.GetCallTimeSec(packet.log_time()); }; auto ToNetworkDelay = [frequency_hz]( const LoggedRtpPacketIncoming& old_packet, @@ -803,7 +805,7 @@ void EventLogAnalyzer::CreateFractionLossGraph(Plot* plot) { TimeSeries time_series("Fraction lost", LineStyle::kLine, PointStyle::kHighlight); for (auto& bwe_update : parsed_log_.bwe_loss_updates()) { - float x = config_.GetCallTimeSec(bwe_update.log_time_us()); + float x = config_.GetCallTimeSec(bwe_update.log_time()); float y = static_cast(bwe_update.fraction_lost) / 255 * 100; time_series.points.emplace_back(x, y); } @@ -818,11 +820,11 @@ void EventLogAnalyzer::CreateFractionLossGraph(Plot* plot) { // Plot the total bandwidth used by all RTP streams. void EventLogAnalyzer::CreateTotalIncomingBitrateGraph(Plot* plot) { // TODO(terelius): This could be provided by the parser. - std::multimap packets_in_order; + std::multimap packets_in_order; for (const auto& stream : parsed_log_.incoming_rtp_packets_by_ssrc()) { for (const LoggedRtpPacketIncoming& packet : stream.incoming_packets) packets_in_order.insert( - std::make_pair(packet.rtp.log_time_us(), packet.rtp.total_length)); + std::make_pair(packet.rtp.log_time(), packet.rtp.total_length)); } auto window_begin = packets_in_order.begin(); @@ -832,7 +834,7 @@ void EventLogAnalyzer::CreateTotalIncomingBitrateGraph(Plot* plot) { if (!packets_in_order.empty()) { // Calculate a moving average of the bitrate and store in a TimeSeries. TimeSeries bitrate_series("Bitrate", LineStyle::kLine); - for (int64_t time = config_.begin_time_; + for (Timestamp time = config_.begin_time_; time < config_.end_time_ + config_.step_; time += config_.step_) { while (window_end != packets_in_order.end() && window_end->first < time) { bytes_in_window += window_end->second; @@ -845,7 +847,8 @@ void EventLogAnalyzer::CreateTotalIncomingBitrateGraph(Plot* plot) { ++window_begin; } float window_duration_in_seconds = - static_cast(config_.window_duration_) / kNumMicrosecsPerSec; + static_cast(config_.window_duration_.us()) / + kNumMicrosecsPerSec; float x = config_.GetCallTimeSec(time); float y = bytes_in_window * 8 / window_duration_in_seconds / 1000; bitrate_series.points.emplace_back(x, y); @@ -856,7 +859,7 @@ void EventLogAnalyzer::CreateTotalIncomingBitrateGraph(Plot* plot) { // Overlay the outgoing REMB over incoming bitrate. TimeSeries remb_series("Remb", LineStyle::kStep); for (const auto& rtcp : parsed_log_.rembs(kOutgoingPacket)) { - float x = config_.GetCallTimeSec(rtcp.log_time_us()); + float x = config_.GetCallTimeSec(rtcp.log_time()); float y = static_cast(rtcp.remb.bitrate_bps()) / 1000; remb_series.points.emplace_back(x, y); } @@ -884,11 +887,11 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, bool show_detector_state, bool show_alr_state) { // TODO(terelius): This could be provided by the parser. - std::multimap packets_in_order; + std::multimap packets_in_order; for (const auto& stream : parsed_log_.outgoing_rtp_packets_by_ssrc()) { for (const LoggedRtpPacketOutgoing& packet : stream.outgoing_packets) packets_in_order.insert( - std::make_pair(packet.rtp.log_time_us(), packet.rtp.total_length)); + std::make_pair(packet.rtp.log_time(), packet.rtp.total_length)); } auto window_begin = packets_in_order.begin(); @@ -898,7 +901,7 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, if (!packets_in_order.empty()) { // Calculate a moving average of the bitrate and store in a TimeSeries. TimeSeries bitrate_series("Bitrate", LineStyle::kLine); - for (int64_t time = config_.begin_time_; + for (Timestamp time = config_.begin_time_; time < config_.end_time_ + config_.step_; time += config_.step_) { while (window_end != packets_in_order.end() && window_end->first < time) { bytes_in_window += window_end->second; @@ -911,7 +914,8 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, ++window_begin; } float window_duration_in_seconds = - static_cast(config_.window_duration_) / kNumMicrosecsPerSec; + static_cast(config_.window_duration_.us()) / + kNumMicrosecsPerSec; float x = config_.GetCallTimeSec(time); float y = bytes_in_window * 8 / window_duration_in_seconds / 1000; bitrate_series.points.emplace_back(x, y); @@ -922,7 +926,7 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, // Overlay the send-side bandwidth estimate over the outgoing bitrate. TimeSeries loss_series("Loss-based estimate", LineStyle::kStep); for (auto& loss_update : parsed_log_.bwe_loss_updates()) { - float x = config_.GetCallTimeSec(loss_update.log_time_us()); + float x = config_.GetCallTimeSec(loss_update.log_time()); float y = static_cast(loss_update.bitrate_bps) / 1000; loss_series.points.emplace_back(x, y); } @@ -935,12 +939,12 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, IntervalSeries normal_series("Normal", "#c4ffc4", IntervalSeries::kHorizontal); IntervalSeries* last_series = &normal_series; - double last_detector_switch = 0.0; + float last_detector_switch = 0.0; BandwidthUsage last_detector_state = BandwidthUsage::kBwNormal; for (auto& delay_update : parsed_log_.bwe_delay_updates()) { - float x = config_.GetCallTimeSec(delay_update.log_time_us()); + float x = config_.GetCallTimeSec(delay_update.log_time()); float y = static_cast(delay_update.bitrate_bps) / 1000; if (last_detector_state != delay_update.detector_state) { @@ -967,12 +971,13 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, } RTC_CHECK(last_series); - last_series->intervals.emplace_back(last_detector_switch, config_.end_time_); + last_series->intervals.emplace_back(last_detector_switch, + config_.CallEndTimeSec()); TimeSeries created_series("Probe cluster created.", LineStyle::kNone, PointStyle::kHighlight); for (auto& cluster : parsed_log_.bwe_probe_cluster_created_events()) { - float x = config_.GetCallTimeSec(cluster.log_time_us()); + float x = config_.GetCallTimeSec(cluster.log_time()); float y = static_cast(cluster.bitrate_bps) / 1000; created_series.points.emplace_back(x, y); } @@ -980,7 +985,7 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, TimeSeries result_series("Probing results.", LineStyle::kNone, PointStyle::kHighlight); for (auto& result : parsed_log_.bwe_probe_success_events()) { - float x = config_.GetCallTimeSec(result.log_time_us()); + float x = config_.GetCallTimeSec(result.log_time()); float y = static_cast(result.bitrate_bps) / 1000; result_series.points.emplace_back(x, y); } @@ -988,17 +993,17 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, TimeSeries probe_failures_series("Probe failed", LineStyle::kNone, PointStyle::kHighlight); for (auto& failure : parsed_log_.bwe_probe_failure_events()) { - float x = config_.GetCallTimeSec(failure.log_time_us()); + float x = config_.GetCallTimeSec(failure.log_time()); probe_failures_series.points.emplace_back(x, 0); } IntervalSeries alr_state("ALR", "#555555", IntervalSeries::kHorizontal); bool previously_in_alr = false; - int64_t alr_start = 0; + Timestamp alr_start = Timestamp::Zero(); for (auto& alr : parsed_log_.alr_state_events()) { - float y = config_.GetCallTimeSec(alr.log_time_us()); + float y = config_.GetCallTimeSec(alr.log_time()); if (!previously_in_alr && alr.in_alr) { - alr_start = alr.log_time_us(); + alr_start = alr.log_time(); previously_in_alr = true; } else if (previously_in_alr && !alr.in_alr) { float x = config_.GetCallTimeSec(alr_start); @@ -1031,7 +1036,7 @@ void EventLogAnalyzer::CreateTotalOutgoingBitrateGraph(Plot* plot, // Overlay the incoming REMB over the outgoing bitrate. TimeSeries remb_series("Remb", LineStyle::kStep); for (const auto& rtcp : parsed_log_.rembs(kIncomingPacket)) { - float x = config_.GetCallTimeSec(rtcp.log_time_us()); + float x = config_.GetCallTimeSec(rtcp.log_time()); float y = static_cast(rtcp.remb.bitrate_bps()) / 1000; remb_series.points.emplace_back(x, y); } @@ -1117,7 +1122,7 @@ void EventLogAnalyzer::CreateBitrateAllocationGraph(PacketDirection direction, std::make_pair(layer, TimeSeries(layer_name, LineStyle::kStep))); RTC_DCHECK(inserted); } - float x = config_.GetCallTimeSec(rtcp.log_time_us()); + float x = config_.GetCallTimeSec(rtcp.log_time()); float y = bitrate_item.target_bitrate_kbps; time_series_it->second.points.emplace_back(x, y); } @@ -1149,22 +1154,20 @@ void EventLogAnalyzer::CreateGoogCcSimulationGraph(Plot* plot) { [&](const NetworkControlUpdate& update, Timestamp at_time) { if (update.target_rate) { target_rates.points.emplace_back( - config_.GetCallTimeSec(at_time.us()), + config_.GetCallTimeSec(at_time), update.target_rate->target_rate.kbps()); } }); simulation.ProcessEventsInLog(parsed_log_); for (const auto& logged : parsed_log_.bwe_delay_updates()) - delay_based.points.emplace_back( - config_.GetCallTimeSec(logged.log_time_us()), - logged.bitrate_bps / 1000); + delay_based.points.emplace_back(config_.GetCallTimeSec(logged.log_time()), + logged.bitrate_bps / 1000); for (const auto& logged : parsed_log_.bwe_probe_success_events()) - probe_results.points.emplace_back( - config_.GetCallTimeSec(logged.log_time_us()), - logged.bitrate_bps / 1000); + probe_results.points.emplace_back(config_.GetCallTimeSec(logged.log_time()), + logged.bitrate_bps / 1000); for (const auto& logged : parsed_log_.bwe_loss_updates()) - loss_based.points.emplace_back(config_.GetCallTimeSec(logged.log_time_us()), + loss_based.points.emplace_back(config_.GetCallTimeSec(logged.log_time()), logged.bitrate_bps / 1000); plot->AppendTimeSeries(std::move(delay_based)); @@ -1324,7 +1327,7 @@ void EventLogAnalyzer::CreateSendSideBweSimulationGraph(Plot* plot) { } } - float x = config_.GetCallTimeSec(clock.TimeInMicroseconds()); + float x = config_.GetCallTimeSec(clock.CurrentTime()); float y = bitrate_bps.value_or(0) / 1000; acked_time_series.points.emplace_back(x, y); y = robust_throughput_estimator->bitrate() @@ -1347,7 +1350,7 @@ void EventLogAnalyzer::CreateSendSideBweSimulationGraph(Plot* plot) { if (observer.GetAndResetBitrateUpdated() || time_us - last_update_us >= 1e6) { uint32_t y = observer.last_bitrate_bps() / 1000; - float x = config_.GetCallTimeSec(clock.TimeInMicroseconds()); + float x = config_.GetCallTimeSec(clock.CurrentTime()); time_series.points.emplace_back(x, y); last_update_us = time_us; } @@ -1423,13 +1426,13 @@ void EventLogAnalyzer::CreateReceiveSideBweSimulationGraph(Plot* plot) { absl::optional bitrate_bps = acked_bitrate.Rate(arrival_time_ms); if (bitrate_bps) { uint32_t y = *bitrate_bps / 1000; - float x = config_.GetCallTimeSec(clock.TimeInMicroseconds()); + float x = config_.GetCallTimeSec(clock.CurrentTime()); acked_time_series.points.emplace_back(x, y); } if (remb_interceptor.GetAndResetBitrateUpdated() || clock.TimeInMicroseconds() - last_update_us >= 1e6) { uint32_t y = remb_interceptor.last_bitrate_bps() / 1000; - float x = config_.GetCallTimeSec(clock.TimeInMicroseconds()); + float x = config_.GetCallTimeSec(clock.CurrentTime()); time_series.points.emplace_back(x, y); last_update_us = clock.TimeInMicroseconds(); } @@ -1461,7 +1464,7 @@ void EventLogAnalyzer::CreateNetworkDelayFeedbackGraph(Plot* plot) { for (const auto& packet : matched_rtp_rtcp) { if (packet.arrival_time_ms == MatchedSendArrivalTimes::kNotReceived) continue; - float x = config_.GetCallTimeSec(1000 * packet.feedback_arrival_time_ms); + float x = config_.GetCallTimeSecFromMs(packet.feedback_arrival_time_ms); int64_t y = packet.arrival_time_ms - packet.send_time_ms; int64_t rtt_ms = packet.feedback_arrival_time_ms - packet.send_time_ms; min_rtt_ms = std::min(rtt_ms, min_rtt_ms); @@ -1530,7 +1533,7 @@ void EventLogAnalyzer::CreatePacerDelayGraph(Plot* plot) { double send_time_ms = static_cast(packet.rtp.log_time_us() - first_send_timestamp) / 1000; - float x = config_.GetCallTimeSec(packet.rtp.log_time_us()); + float x = config_.GetCallTimeSec(packet.rtp.log_time()); float y = send_time_ms - capture_time_ms; pacer_delay_series.points.emplace_back(x, y); } @@ -1551,7 +1554,7 @@ void EventLogAnalyzer::CreateTimestampGraph(PacketDirection direction, GetStreamName(parsed_log_, direction, stream.ssrc) + " capture-time", LineStyle::kLine, PointStyle::kHighlight); for (const auto& packet : stream.packet_view) { - float x = config_.GetCallTimeSec(packet.log_time_us()); + float x = config_.GetCallTimeSec(packet.log_time()); float y = packet.header.timestamp; rtp_timestamps.points.emplace_back(x, y); } @@ -1566,7 +1569,7 @@ void EventLogAnalyzer::CreateTimestampGraph(PacketDirection direction, for (const auto& rtcp : sender_reports) { if (rtcp.sr.sender_ssrc() != stream.ssrc) continue; - float x = config_.GetCallTimeSec(rtcp.log_time_us()); + float x = config_.GetCallTimeSec(rtcp.log_time()); float y = rtcp.sr.rtp_timestamp(); rtcp_timestamps.points.emplace_back(x, y); } @@ -1588,7 +1591,7 @@ void EventLogAnalyzer::CreateSenderAndReceiverReportPlot( std::map sr_reports_by_ssrc; const auto& sender_reports = parsed_log_.sender_reports(direction); for (const auto& rtcp : sender_reports) { - float x = config_.GetCallTimeSec(rtcp.log_time_us()); + float x = config_.GetCallTimeSec(rtcp.log_time()); uint32_t ssrc = rtcp.sr.sender_ssrc(); for (const auto& block : rtcp.sr.report_blocks()) { float y = fy(block); @@ -1610,7 +1613,7 @@ void EventLogAnalyzer::CreateSenderAndReceiverReportPlot( std::map rr_reports_by_ssrc; const auto& receiver_reports = parsed_log_.receiver_reports(direction); for (const auto& rtcp : receiver_reports) { - float x = config_.GetCallTimeSec(rtcp.log_time_us()); + float x = config_.GetCallTimeSec(rtcp.log_time()); uint32_t ssrc = rtcp.rr.sender_ssrc(); for (const auto& block : rtcp.rr.report_blocks()) { float y = fy(block); @@ -1649,7 +1652,7 @@ void EventLogAnalyzer::CreateIceCandidatePairConfigGraph(Plot* plot) { candidate_pair_desc_by_id_[config.candidate_pair_id] = candidate_pair_desc; } - float x = config_.GetCallTimeSec(config.log_time_us()); + float x = config_.GetCallTimeSec(config.log_time()); float y = static_cast(config.type); configs_by_cp_id[config.candidate_pair_id].points.emplace_back(x, y); } @@ -1706,7 +1709,7 @@ void EventLogAnalyzer::CreateIceConnectivityCheckGraph(Plot* plot) { GetCandidatePairLogDescriptionFromId(event.candidate_pair_id), LineStyle::kNone, PointStyle::kHighlight); } - float x = config_.GetCallTimeSec(event.log_time_us()); + float x = config_.GetCallTimeSec(event.log_time()); float y = static_cast(event.type) + kEventTypeOffset; checks_by_cp_id[event.candidate_pair_id].points.emplace_back(x, y); } @@ -1741,7 +1744,7 @@ void EventLogAnalyzer::CreateDtlsTransportStateGraph(Plot* plot) { TimeSeries states("DTLS Transport State", LineStyle::kNone, PointStyle::kHighlight); for (const auto& event : parsed_log_.dtls_transport_states()) { - float x = config_.GetCallTimeSec(event.log_time_us()); + float x = config_.GetCallTimeSec(event.log_time()); float y = static_cast(event.dtls_transport_state); states.points.emplace_back(x, y); } @@ -1763,7 +1766,7 @@ void EventLogAnalyzer::CreateDtlsWritableStateGraph(Plot* plot) { TimeSeries writable("DTLS Writable", LineStyle::kNone, PointStyle::kHighlight); for (const auto& event : parsed_log_.dtls_writable_states()) { - float x = config_.GetCallTimeSec(event.log_time_us()); + float x = config_.GetCallTimeSec(event.log_time()); float y = static_cast(event.writable); writable.points.emplace_back(x, y); } diff --git a/rtc_tools/rtc_event_log_visualizer/analyzer_common.h b/rtc_tools/rtc_event_log_visualizer/analyzer_common.h index a4305a708f..b0b556aa62 100644 --- a/rtc_tools/rtc_event_log_visualizer/analyzer_common.h +++ b/rtc_tools/rtc_event_log_visualizer/analyzer_common.h @@ -22,6 +22,7 @@ namespace webrtc { constexpr int kNumMicrosecsPerSec = 1000000; +constexpr int kNumMillisecsPerSec = 1000; constexpr float kLeftMargin = 0.01f; constexpr float kRightMargin = 0.02f; constexpr float kBottomMargin = 0.02f; @@ -29,25 +30,38 @@ constexpr float kTopMargin = 0.05f; class AnalyzerConfig { public: - float GetCallTimeSec(int64_t timestamp_us) const { - int64_t offset = normalize_time_ ? begin_time_ : 0; - return static_cast(timestamp_us - offset) / 1000000; + float GetCallTimeSec(Timestamp timestamp) const { + Timestamp offset = normalize_time_ ? begin_time_ : Timestamp::Zero(); + return static_cast((timestamp - offset).us()) / 1000000; + } + + float GetCallTimeSecFromMs(int64_t timestamp_ms) const { + return GetCallTimeSec(Timestamp::Millis(timestamp_ms)); } float CallBeginTimeSec() const { return GetCallTimeSec(begin_time_); } float CallEndTimeSec() const { return GetCallTimeSec(end_time_); } + int64_t CallTimeToUtcOffsetMs() { + if (normalize_time_) { + Timestamp utc_begin_time_ = begin_time_ + rtc_to_utc_offset_; + return utc_begin_time_.ms(); + } + return rtc_to_utc_offset_.ms(); + } + // Window and step size used for calculating moving averages, e.g. bitrate. - // The generated data points will be `step_` microseconds apart. - // Only events occurring at most `window_duration_` microseconds before the - // current data point will be part of the average. - int64_t window_duration_; - int64_t step_; + // The generated data points will be `step_.ms()` milliseconds apart. + // Only events occurring at most `window_duration_.ms()` milliseconds before + // the current data point will be part of the average. + TimeDelta window_duration_ = TimeDelta::Millis(250); + TimeDelta step_ = TimeDelta::Millis(10); // First and last events of the log. - int64_t begin_time_; - int64_t end_time_; + Timestamp begin_time_ = Timestamp::MinusInfinity(); + Timestamp end_time_ = Timestamp::MinusInfinity(); + TimeDelta rtc_to_utc_offset_ = TimeDelta::Zero(); bool normalize_time_; }; @@ -152,17 +166,17 @@ void MovingAverage( size_t window_index_end = 0; ResultType sum_in_window = 0; - for (int64_t t = config.begin_time_; t < config.end_time_ + config.step_; + for (Timestamp t = config.begin_time_; t < config.end_time_ + config.step_; t += config.step_) { while (window_index_end < data_view.size() && - data_view[window_index_end].log_time_us() < t) { + data_view[window_index_end].log_time() < t) { absl::optional value = fy(data_view[window_index_end]); if (value) sum_in_window += *value; ++window_index_end; } while (window_index_begin < data_view.size() && - data_view[window_index_begin].log_time_us() < + data_view[window_index_begin].log_time() < t - config.window_duration_) { absl::optional value = fy(data_view[window_index_begin]); if (value) @@ -170,7 +184,7 @@ void MovingAverage( ++window_index_begin; } float window_duration_s = - static_cast(config.window_duration_) / kNumMicrosecsPerSec; + static_cast(config.window_duration_.us()) / kNumMicrosecsPerSec; float x = config.GetCallTimeSec(t); float y = sum_in_window / window_duration_s; result->points.emplace_back(x, y); diff --git a/rtc_tools/rtc_event_log_visualizer/main.cc b/rtc_tools/rtc_event_log_visualizer/main.cc index ab4b7ebac1..6182b701df 100644 --- a/rtc_tools/rtc_event_log_visualizer/main.cc +++ b/rtc_tools/rtc_event_log_visualizer/main.cc @@ -261,8 +261,12 @@ int main(int argc, char* argv[]) { } webrtc::AnalyzerConfig config; - config.window_duration_ = 250000; - config.step_ = 10000; + config.window_duration_ = webrtc::TimeDelta::Millis(250); + config.step_ = webrtc::TimeDelta::Millis(10); + if (!parsed_log.start_log_events().empty()) { + config.rtc_to_utc_offset_ = parsed_log.start_log_events()[0].utc_time() - + parsed_log.start_log_events()[0].log_time(); + } config.normalize_time_ = absl::GetFlag(FLAGS_normalize_time); config.begin_time_ = parsed_log.first_timestamp(); config.end_time_ = parsed_log.last_timestamp(); @@ -275,6 +279,7 @@ int main(int argc, char* argv[]) { webrtc::EventLogAnalyzer analyzer(parsed_log, config); webrtc::PlotCollection collection; + collection.SetCallTimeToUtcOffsetMs(config.CallTimeToUtcOffsetMs()); PlotMap plots; plots.RegisterPlot("incoming_packet_sizes", [&](Plot* plot) { diff --git a/rtc_tools/rtc_event_log_visualizer/plot_base.cc b/rtc_tools/rtc_event_log_visualizer/plot_base.cc index 82533e6eb0..bf76a67bb5 100644 --- a/rtc_tools/rtc_event_log_visualizer/plot_base.cc +++ b/rtc_tools/rtc_event_log_visualizer/plot_base.cc @@ -307,13 +307,13 @@ void PlotCollection::PrintPythonCode(bool shared_xaxis) const { void PlotCollection::ExportProtobuf( webrtc::analytics::ChartCollection* collection) const { for (const auto& plot : plots_) { - // TODO(terelius): Ensure that there is no way to insert plots other than - // ProtobufPlots in a ProtobufPlotCollection. Needed to safely static_cast - // here. webrtc::analytics::Chart* protobuf_representation = collection->add_charts(); plot->ExportProtobuf(protobuf_representation); } + if (calltime_to_utc_ms_) { + collection->set_calltime_to_utc_ms(*calltime_to_utc_ms_); + } } Plot* PlotCollection::AppendNewPlot() { diff --git a/rtc_tools/rtc_event_log_visualizer/plot_base.h b/rtc_tools/rtc_event_log_visualizer/plot_base.h index a26146b5e5..dbc9535fc1 100644 --- a/rtc_tools/rtc_event_log_visualizer/plot_base.h +++ b/rtc_tools/rtc_event_log_visualizer/plot_base.h @@ -16,6 +16,7 @@ #include #include "absl/base/attributes.h" +#include "absl/types/optional.h" #include "rtc_base/ignore_wundef.h" RTC_PUSH_IGNORING_WUNDEF() @@ -194,6 +195,10 @@ class PlotCollection { virtual Plot* AppendNewPlot(); + void SetCallTimeToUtcOffsetMs(int64_t calltime_to_utc_ms) { + calltime_to_utc_ms_ = calltime_to_utc_ms; + } + // Replaces PythonPlotCollection::Draw() void PrintPythonCode(bool shared_xaxis) const; @@ -202,6 +207,7 @@ class PlotCollection { protected: std::vector> plots_; + absl::optional calltime_to_utc_ms_; }; } // namespace webrtc diff --git a/rtc_tools/rtc_event_log_visualizer/proto/chart.proto b/rtc_tools/rtc_event_log_visualizer/proto/chart.proto index e5960b2677..f82d9c1ead 100644 --- a/rtc_tools/rtc_event_log_visualizer/proto/chart.proto +++ b/rtc_tools/rtc_event_log_visualizer/proto/chart.proto @@ -33,4 +33,8 @@ message Chart { message ChartCollection { repeated Chart charts = 1; + // `calltime_to_utc_ms` is the UTC time (in ms) for the x-axis in the charts. + // In other words, time t ms in the charts corresponds to + // t+calltime_to_utc_ms ms in UTC time. + int64 calltime_to_utc_ms = 2; } From 1e98e7bf92e54461650801e95226be4e60c71a80 Mon Sep 17 00:00:00 2001 From: Victor Boivie Date: Thu, 24 Feb 2022 22:44:45 +0100 Subject: [PATCH 054/847] p2p: Add field trial WebRTC-SetSocketReceiveBuffer This field trial sets a non-zero receive buffer on the media UDP socket with the intention to result in less packet loss in situations when the application can't read packets fast enough from the socket. This can be due to e.g. external factors, e.g. operating system not scheduling the application for a longer time, or due to internal factors, e.g. slow processing, a long running garbage collector, and more. The size as set as the field trial parameter, as e.g. WebRTC-SetSocketReceiveBuffer/Enabled-250/ to set it to 250kb. Bug: webrtc:13753 Change-Id: Iae38d0db0c595d6e0148a2fdeb85ee8895e90560 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252581 Reviewed-by: Jonas Oreland Commit-Queue: Victor Boivie Cr-Commit-Position: refs/heads/main@{#36080} --- p2p/base/p2p_transport_channel.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/p2p/base/p2p_transport_channel.cc b/p2p/base/p2p_transport_channel.cc index 9fe9cac948..5667bc516b 100644 --- a/p2p/base/p2p_transport_channel.cc +++ b/p2p/base/p2p_transport_channel.cc @@ -786,6 +786,16 @@ void P2PTransportChannel::SetIceConfig(const IceConfig& config) { SetOption(rtc::Socket::OPT_DSCP, *field_trials_.override_dscp); } + std::string field_trial_string = + webrtc::field_trial::FindFullName("WebRTC-SetSocketReceiveBuffer"); + int receive_buffer_size_kb = 0; + sscanf(field_trial_string.c_str(), "Enabled-%d", &receive_buffer_size_kb); + if (receive_buffer_size_kb > 0) { + RTC_LOG(LS_INFO) << "Set WebRTC-SetSocketReceiveBuffer: Enabled and set to " + << receive_buffer_size_kb << "kb"; + SetOption(rtc::Socket::OPT_RCVBUF, receive_buffer_size_kb * 1024); + } + RTC_DCHECK(ValidateIceConfig(config_).ok()); } From 0cb1cfa69ebb3a75de39f6d75d5448314c558575 Mon Sep 17 00:00:00 2001 From: Mirko Bonadei Date: Fri, 25 Feb 2022 10:45:32 +0000 Subject: [PATCH 055/847] Reland "Removing MessageHandler dependency from Connection." This reverts commit 05ea12e5136493a8977e0bb4a81a6ff8d06ec92f. Reason for revert: Speculative revert. Original change's description: > Revert "Removing MessageHandler dependency from Connection." > > This reverts commit 3202e29f72b4f511fcf6e92ef9b0dcbfee6089ff. > > Reason for revert: Introduced a crash in the task posted by Destroy() > > Original change's description: > > Removing MessageHandler dependency from Connection. > > > > Bug: webrtc:11988 > > Change-Id: Ic35bb5baeafbda7210012dceb0d6d5f5b3eb95c9 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/249941 > > Reviewed-by: Niels Moller > > Commit-Queue: Tomas Gunnarsson > > Cr-Commit-Position: refs/heads/main@{#35890} > > No-Try: True > Bug: webrtc:11988 > Change-Id: Ie70ee145fde75b8cf76b02784176970e7a78e001 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252541 > Auto-Submit: Taylor Brandstetter > Reviewed-by: Mirko Bonadei > Owners-Override: Mirko Bonadei > Reviewed-by: Tomas Gunnarsson > Commit-Queue: Tomas Gunnarsson > Cr-Commit-Position: refs/heads/main@{#36078} No-Try: True Bug: webrtc:11988 Change-Id: Idfd42d016e81d4352839c33dcb4ea3b0dafea08b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252584 Owners-Override: Mirko Bonadei Bot-Commit: rubber-stamper@appspot.gserviceaccount.com Commit-Queue: Mirko Bonadei Cr-Commit-Position: refs/heads/main@{#36081} --- p2p/base/connection.cc | 36 ++++++++-------- p2p/base/connection.h | 8 +--- p2p/base/p2p_transport_channel_unittest.cc | 3 ++ p2p/base/tcp_port.cc | 42 ++++++++----------- p2p/base/tcp_port.h | 10 ++--- pc/scenario_tests/goog_cc_test.cc | 3 ++ .../tests/remote_estimate_test.cc | 2 + .../tests/unsignaled_stream_test.cc | 2 + 8 files changed, 51 insertions(+), 55 deletions(-) diff --git a/p2p/base/connection.cc b/p2p/base/connection.cc index 8575d65945..a04f318acb 100644 --- a/p2p/base/connection.cc +++ b/p2p/base/connection.cc @@ -18,6 +18,7 @@ #include #include "absl/algorithm/container.h" +#include "absl/memory/memory.h" #include "absl/strings/match.h" #include "p2p/base/port_allocator.h" #include "rtc_base/checks.h" @@ -833,15 +834,25 @@ void Connection::Prune() { void Connection::Destroy() { RTC_DCHECK_RUN_ON(network_thread_); - // TODO(deadbeef, nisse): This may leak if an application closes a - // PeerConnection and then quickly destroys the PeerConnectionFactory (along - // with the networking thread on which this message is posted). Also affects - // tests, with a workaround in - // AutoSocketServerThread::~AutoSocketServerThread. - RTC_LOG(LS_VERBOSE) << ToString() << ": Connection destroyed"; - // TODO(bugs.webrtc.org/11988): Use PostTask. - port_->thread()->Post(RTC_FROM_HERE, this, MSG_DELETE); + RTC_DLOG(LS_VERBOSE) << ToString() << ": Connection destroyed"; + + // Fire the 'destroyed' event before deleting the object. This is done + // intentionally to avoid a situation whereby the signal might have dangling + // pointers to objects that have been deleted by the time the async task + // that deletes the connection object runs. + SignalDestroyed(this); + SignalDestroyed.disconnect_all(); + LogCandidatePairConfig(webrtc::IceCandidatePairConfigType::kDestroyed); + + // Unwind the stack before deleting the object in case upstream callers + // need to refer to the Connection's state as part of teardown. + // NOTE: We move ownership of 'this' into the capture section of the lambda + // so that the object will always be deleted, including if PostTask fails. + // In such a case (only tests), deletion would happen inside of the call + // to `Destroy()`. + network_thread_->PostTask( + webrtc::ToQueuedTask([me = absl::WrapUnique(this)]() {})); } void Connection::FailAndDestroy() { @@ -1422,15 +1433,6 @@ void Connection::MaybeUpdatePeerReflexiveCandidate( } } -void Connection::OnMessage(rtc::Message* pmsg) { - RTC_DCHECK_RUN_ON(network_thread_); - RTC_DCHECK(pmsg->message_id == MSG_DELETE); - RTC_LOG(LS_INFO) << "Connection deleted with number of pings sent: " - << num_pings_sent_; - SignalDestroyed(this); - delete this; -} - int64_t Connection::last_received() const { RTC_DCHECK_RUN_ON(network_thread_); return std::max(last_data_received_, diff --git a/p2p/base/connection.h b/p2p/base/connection.h index c102194498..8254706318 100644 --- a/p2p/base/connection.h +++ b/p2p/base/connection.h @@ -70,9 +70,7 @@ class ConnectionRequest : public StunRequest { // Represents a communication link between a port on the local client and a // port on the remote client. -class Connection : public CandidatePairInterface, - public rtc::MessageHandlerAutoCleanup, - public sigslot::has_slots<> { +class Connection : public CandidatePairInterface, public sigslot::has_slots<> { public: struct SentPing { SentPing(const std::string id, int64_t sent_time, uint32_t nomination) @@ -320,8 +318,6 @@ class Connection : public CandidatePairInterface, void set_remote_nomination(uint32_t remote_nomination); protected: - enum { MSG_DELETE = 0, MSG_FIRST_AVAILABLE }; - // Constructs a new connection to the given remote port. Connection(Port* port, size_t index, const Candidate& candidate); @@ -351,8 +347,6 @@ class Connection : public CandidatePairInterface, void set_state(IceCandidatePairState state); void set_connected(bool value); - void OnMessage(rtc::Message* pmsg) override; - // The local port where this connection sends and receives packets. Port* port() { return port_; } const Port* port() const { return port_; } diff --git a/p2p/base/p2p_transport_channel_unittest.cc b/p2p/base/p2p_transport_channel_unittest.cc index 7aed20a669..0a24f8c030 100644 --- a/p2p/base/p2p_transport_channel_unittest.cc +++ b/p2p/base/p2p_transport_channel_unittest.cc @@ -483,6 +483,9 @@ class P2PTransportChannelTestBase : public ::testing::Test, ep2_.cd1_.ch_.reset(); ep1_.cd2_.ch_.reset(); ep2_.cd2_.ch_.reset(); + // Process pending tasks that need to run for cleanup purposes such as + // pending deletion of Connection objects (see Connection::Destroy). + rtc::Thread::Current()->ProcessMessages(0); } P2PTransportChannel* ep1_ch1() { return ep1_.cd1_.ch_.get(); } P2PTransportChannel* ep1_ch2() { return ep1_.cd2_.ch_.get(); } diff --git a/p2p/base/tcp_port.cc b/p2p/base/tcp_port.cc index 9d542074a4..445b0d03a5 100644 --- a/p2p/base/tcp_port.cc +++ b/p2p/base/tcp_port.cc @@ -79,6 +79,7 @@ #include "rtc_base/logging.h" #include "rtc_base/net_helper.h" #include "rtc_base/rate_tracker.h" +#include "rtc_base/task_utils/to_queued_task.h" #include "rtc_base/third_party/sigslot/sigslot.h" namespace cricket { @@ -366,7 +367,9 @@ TCPConnection::TCPConnection(TCPPort* port, } } -TCPConnection::~TCPConnection() {} +TCPConnection::~TCPConnection() { + RTC_DCHECK_RUN_ON(network_thread_); +} int TCPConnection::Send(const void* data, size_t size, @@ -493,11 +496,20 @@ void TCPConnection::OnClose(rtc::AsyncPacketSocket* socket, int error) { // events. pretending_to_be_writable_ = true; + // If this connection can't become connected and writable again in 5 + // seconds, it's time to tear this down. This is the case for the original + // TCP connection on passive side during a reconnect. // We don't attempt reconnect right here. This is to avoid a case where the // shutdown is intentional and reconnect is not necessary. We only reconnect // when the connection is used to Send() or Ping(). - port()->thread()->PostDelayed(RTC_FROM_HERE, reconnection_timeout(), this, - MSG_TCPCONNECTION_DELAYED_ONCLOSE); + port()->thread()->PostDelayedTask( + webrtc::ToQueuedTask(network_safety_, + [this]() { + if (pretending_to_be_writable_) { + Destroy(); + } + }), + reconnection_timeout()); } else if (!pretending_to_be_writable_) { // OnClose could be called when the underneath socket times out during the // initial connect() (i.e. `pretending_to_be_writable_` is false) . We have @@ -507,24 +519,6 @@ void TCPConnection::OnClose(rtc::AsyncPacketSocket* socket, int error) { } } -void TCPConnection::OnMessage(rtc::Message* pmsg) { - switch (pmsg->message_id) { - case MSG_TCPCONNECTION_DELAYED_ONCLOSE: - // If this connection can't become connected and writable again in 5 - // seconds, it's time to tear this down. This is the case for the original - // TCP connection on passive side during a reconnect. - if (pretending_to_be_writable_) { - Destroy(); - } - break; - case MSG_TCPCONNECTION_FAILED_CREATE_SOCKET: - FailAndPrune(); - break; - default: - Connection::OnMessage(pmsg); - } -} - void TCPConnection::MaybeReconnect() { // Only reconnect for an outgoing TCPConnection when OnClose was signaled and // no outstanding reconnect is pending. @@ -576,13 +570,13 @@ void TCPConnection::CreateOutgoingTcpSocket() { } else { RTC_LOG(LS_WARNING) << ToString() << ": Failed to create connection to " << remote_candidate().address().ToSensitiveString(); + set_state(IceCandidatePairState::FAILED); // We can't FailAndPrune directly here. FailAndPrune and deletes all // the StunRequests from the request_map_. And if this is in the stack // of Connection::Ping(), we are still using the request. // Unwind the stack and defer the FailAndPrune. - set_state(IceCandidatePairState::FAILED); - port()->thread()->Post(RTC_FROM_HERE, this, - MSG_TCPCONNECTION_FAILED_CREATE_SOCKET); + port()->thread()->PostTask( + webrtc::ToQueuedTask(network_safety_, [this]() { FailAndPrune(); })); } } diff --git a/p2p/base/tcp_port.h b/p2p/base/tcp_port.h index 932af50aa4..07d483cc3f 100644 --- a/p2p/base/tcp_port.h +++ b/p2p/base/tcp_port.h @@ -20,6 +20,7 @@ #include "p2p/base/port.h" #include "rtc_base/async_packet_socket.h" #include "rtc_base/containers/flat_map.h" +#include "rtc_base/task_utils/pending_task_safety_flag.h" namespace cricket { @@ -135,8 +136,6 @@ class TCPConnection : public Connection { rtc::AsyncPacketSocket* socket() { return socket_.get(); } - void OnMessage(rtc::Message* pmsg) override; - // Allow test cases to overwrite the default timeout period. int reconnection_timeout() const { return reconnection_timeout_; } void set_reconnection_timeout(int timeout_in_ms) { @@ -144,11 +143,6 @@ class TCPConnection : public Connection { } protected: - enum { - MSG_TCPCONNECTION_DELAYED_ONCLOSE = Connection::MSG_FIRST_AVAILABLE, - MSG_TCPCONNECTION_FAILED_CREATE_SOCKET, - }; - // Set waiting_for_stun_binding_complete_ to false to allow data packets in // addition to what Port::OnConnectionRequestResponse does. void OnConnectionRequestResponse(ConnectionRequest* req, @@ -190,6 +184,8 @@ class TCPConnection : public Connection { // Allow test case to overwrite the default timeout period. int reconnection_timeout_; + webrtc::ScopedTaskSafety network_safety_; + friend class TCPPort; }; diff --git a/pc/scenario_tests/goog_cc_test.cc b/pc/scenario_tests/goog_cc_test.cc index 82ae47b0c7..f0a30dfd86 100644 --- a/pc/scenario_tests/goog_cc_test.cc +++ b/pc/scenario_tests/goog_cc_test.cc @@ -100,6 +100,9 @@ TEST(GoogCcPeerScenarioTest, MAYBE_NoBweChangeFromVideoUnmute) { s.ProcessMessages(TimeDelta::Seconds(1)); EXPECT_GE(get_bwe(), initial_bwe); } + + caller->pc()->Close(); + callee->pc()->Close(); } } // namespace test diff --git a/test/peer_scenario/tests/remote_estimate_test.cc b/test/peer_scenario/tests/remote_estimate_test.cc index 429a5b4ef6..9190f5c92e 100644 --- a/test/peer_scenario/tests/remote_estimate_test.cc +++ b/test/peer_scenario/tests/remote_estimate_test.cc @@ -102,6 +102,8 @@ TEST(RemoteEstimateEndToEnd, AudioUsesAbsSendTimeExtension) { } }); RTC_CHECK(s.WaitAndProcess(&received_abs_send_time)); + caller->pc()->Close(); + callee->pc()->Close(); } } // namespace test } // namespace webrtc diff --git a/test/peer_scenario/tests/unsignaled_stream_test.cc b/test/peer_scenario/tests/unsignaled_stream_test.cc index 5cb0405a62..4f478b4b2a 100644 --- a/test/peer_scenario/tests/unsignaled_stream_test.cc +++ b/test/peer_scenario/tests/unsignaled_stream_test.cc @@ -254,6 +254,8 @@ TEST_P(UnsignaledStreamTest, ReplacesUnsignaledStreamOnCompletedSignaling) { }); EXPECT_TRUE(s.WaitAndProcess(&offer_exchange_done)); EXPECT_TRUE(s.WaitAndProcess(&second_sink.frame_observed_)); + caller->pc()->Close(); + callee->pc()->Close(); } INSTANTIATE_TEST_SUITE_P( From 83829687815e5d72234e24bf23b31140a8e830be Mon Sep 17 00:00:00 2001 From: Mirko Bonadei Date: Fri, 25 Feb 2022 11:03:15 +0000 Subject: [PATCH 056/847] Reland "Remove workaround in AutoSocketServerThread that isn't needed anymore." This reverts commit e4d3952bf0b05b825992f1023a106f3bcf34946e. Reason for revert: Speculative revert. Original change's description: > Revert "Remove workaround in AutoSocketServerThread that isn't needed anymore." > > This reverts commit 44156fa024cbf12f052a35571ac91bc9907be6c3. > > Reason for revert: Needed in order to revert https://webrtc-review.googlesource.com/c/src/+/249941, which introduced a crash > > Original change's description: > > Remove workaround in AutoSocketServerThread that isn't needed anymore. > > > > Cleanup steps for the Connection class have changed as of: > > https://webrtc-review.googlesource.com/c/src/+/249941 > > > > However, it turns out that the PortTest suite still needs it, so the > > workaround has migrated to there. > > > > Bug: none > > Change-Id: Ia68f47b6c65b3a8fd5e8c04d70a43d15ba1a6422 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/250223 > > Reviewed-by: Niels Moller > > Commit-Queue: Tomas Gunnarsson > > Cr-Commit-Position: refs/heads/main@{#35894} > > Bug: none > Change-Id: I13a4a79ebcb864054d14c1ba7726e18e044e3bd4 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252542 > Auto-Submit: Taylor Brandstetter > Reviewed-by: Mirko Bonadei > Commit-Queue: Mirko Bonadei > Reviewed-by: Tomas Gunnarsson > Commit-Queue: Tomas Gunnarsson > Cr-Commit-Position: refs/heads/main@{#36076} No-Try: True Bug: none Change-Id: If39bb2f26349c42c2377ed9f80c26eb18d90869f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252585 Bot-Commit: rubber-stamper@appspot.gserviceaccount.com Reviewed-by: Tomas Gunnarsson Commit-Queue: Mirko Bonadei Cr-Commit-Position: refs/heads/main@{#36082} --- p2p/base/port_unittest.cc | 7 +++++++ rtc_base/thread.cc | 5 ----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/p2p/base/port_unittest.cc b/p2p/base/port_unittest.cc index b27a527477..6ab40a66ad 100644 --- a/p2p/base/port_unittest.cc +++ b/p2p/base/port_unittest.cc @@ -415,6 +415,13 @@ class PortTest : public ::testing::Test, public sigslot::has_slots<> { role_conflict_(false), ports_destroyed_(0) {} + ~PortTest() { + // Workaround for tests that trigger async destruction of objects that we + // need to give an opportunity here to run, before proceeding with other + // teardown. + rtc::Thread::Current()->ProcessMessages(0); + } + protected: std::string password() { return password_; } diff --git a/rtc_base/thread.cc b/rtc_base/thread.cc index aaf6c19b82..307d499255 100644 --- a/rtc_base/thread.cc +++ b/rtc_base/thread.cc @@ -1223,11 +1223,6 @@ AutoSocketServerThread::AutoSocketServerThread(SocketServer* ss) AutoSocketServerThread::~AutoSocketServerThread() { RTC_DCHECK(ThreadManager::Instance()->CurrentThread() == this); - // Some tests post destroy messages to this thread. To avoid memory - // leaks, we have to process those messages. In particular - // P2PTransportChannelPingTest, relying on the message posted in - // cricket::Connection::Destroy. - ProcessMessages(0); // Stop and destroy the thread before clearing it as the current thread. // Sometimes there are messages left in the Thread that will be // destroyed by DoDestroy, and sometimes the destructors of the message and/or From 385eb9714daa80306d2f92d36678c42892dab555 Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Fri, 25 Feb 2022 16:08:58 +0100 Subject: [PATCH 057/847] Represent RtpPacketToSend::capture_time with Timestamp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:13757 Change-Id: I0ede22cd34e3a59afe1477d8edd495dce64e3242 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252586 Reviewed-by: Erik Språng Reviewed-by: Rasmus Brandt Commit-Queue: Danil Chapovalov Cr-Commit-Position: refs/heads/main@{#36083} --- api/video/BUILD.gn | 1 + api/video/video_timing.cc | 9 +++ api/video/video_timing.h | 3 + modules/pacing/paced_sender.cc | 2 +- modules/pacing/pacing_controller_unittest.cc | 4 +- modules/pacing/task_queue_paced_sender.cc | 2 +- .../deprecated_rtp_sender_egress.cc | 10 +-- modules/rtp_rtcp/source/flexfec_sender.cc | 2 +- modules/rtp_rtcp/source/packet_sequencer.cc | 13 ++-- .../source/packet_sequencer_unittest.cc | 16 ++--- modules/rtp_rtcp/source/rtp_packet_history.cc | 2 +- .../source/rtp_packet_history_unittest.cc | 12 ++-- modules/rtp_rtcp/source/rtp_packet_to_send.h | 52 +++++++++++++--- modules/rtp_rtcp/source/rtp_sender.cc | 14 ++--- modules/rtp_rtcp/source/rtp_sender_audio.cc | 4 +- modules/rtp_rtcp/source/rtp_sender_egress.cc | 10 +-- .../source/rtp_sender_egress_unittest.cc | 4 +- .../rtp_rtcp/source/rtp_sender_unittest.cc | 61 ++++++++++--------- modules/rtp_rtcp/source/rtp_sender_video.cc | 4 +- 19 files changed, 138 insertions(+), 87 deletions(-) diff --git a/api/video/BUILD.gn b/api/video/BUILD.gn index 9fd28914b2..fcea278f82 100644 --- a/api/video/BUILD.gn +++ b/api/video/BUILD.gn @@ -31,6 +31,7 @@ rtc_library("video_rtp_headers") { "../../rtc_base:rtc_base_approved", "../../rtc_base/system:rtc_export", "../units:data_rate", + "../units:time_delta", ] absl_deps = [ "//third_party/abseil-cpp/absl/container:inlined_vector", diff --git a/api/video/video_timing.cc b/api/video/video_timing.cc index df1bc4857a..0483c20e66 100644 --- a/api/video/video_timing.cc +++ b/api/video/video_timing.cc @@ -11,6 +11,7 @@ #include "api/video/video_timing.h" #include "api/array_view.h" +#include "api/units/time_delta.h" #include "rtc_base/logging.h" #include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/strings/string_builder.h" @@ -25,6 +26,14 @@ uint16_t VideoSendTiming::GetDeltaCappedMs(int64_t base_ms, int64_t time_ms) { return rtc::saturated_cast(time_ms - base_ms); } +uint16_t VideoSendTiming::GetDeltaCappedMs(TimeDelta delta) { + if (delta < TimeDelta::Zero()) { + RTC_DLOG(LS_ERROR) << "Delta " << delta.ms() + << "ms expected to be positive"; + } + return rtc::saturated_cast(delta.ms()); +} + TimingFrameInfo::TimingFrameInfo() : rtp_timestamp(0), capture_time_ms(-1), diff --git a/api/video/video_timing.h b/api/video/video_timing.h index dd8febb3db..698477a81a 100644 --- a/api/video/video_timing.h +++ b/api/video/video_timing.h @@ -16,6 +16,8 @@ #include #include +#include "api/units/time_delta.h" + namespace webrtc { // Video timing timestamps in ms counted from capture_time_ms of a frame. @@ -34,6 +36,7 @@ struct VideoSendTiming { // https://webrtc.org/experiments/rtp-hdrext/video-timing/ extension stores // 16-bit deltas of timestamps from packet capture time. static uint16_t GetDeltaCappedMs(int64_t base_ms, int64_t time_ms); + static uint16_t GetDeltaCappedMs(TimeDelta delta); uint16_t encode_start_delta_ms; uint16_t encode_finish_delta_ms; diff --git a/modules/pacing/paced_sender.cc b/modules/pacing/paced_sender.cc index acc492db92..2b2d064ef4 100644 --- a/modules/pacing/paced_sender.cc +++ b/modules/pacing/paced_sender.cc @@ -124,7 +124,7 @@ void PacedSender::EnqueuePackets( packet->SequenceNumber(), "rtp_timestamp", packet->Timestamp()); - RTC_DCHECK_GE(packet->capture_time_ms(), 0); + RTC_DCHECK_GE(packet->capture_time(), Timestamp::Zero()); pacing_controller_.EnqueuePacket(std::move(packet)); } } diff --git a/modules/pacing/pacing_controller_unittest.cc b/modules/pacing/pacing_controller_unittest.cc index e7634cd8d5..a24960d896 100644 --- a/modules/pacing/pacing_controller_unittest.cc +++ b/modules/pacing/pacing_controller_unittest.cc @@ -60,7 +60,7 @@ std::unique_ptr BuildPacket(RtpPacketMediaType type, packet->set_packet_type(type); packet->SetSsrc(ssrc); packet->SetSequenceNumber(sequence_number); - packet->set_capture_time_ms(capture_time_ms); + packet->set_capture_time(Timestamp::Millis(capture_time_ms)); packet->SetPayloadSize(size); return packet; } @@ -73,7 +73,7 @@ class MockPacingControllerCallback : public PacingController::PacketSender { void SendPacket(std::unique_ptr packet, const PacedPacketInfo& cluster_info) override { SendPacket(packet->Ssrc(), packet->SequenceNumber(), - packet->capture_time_ms(), + packet->capture_time().ms(), packet->packet_type() == RtpPacketMediaType::kRetransmission, packet->packet_type() == RtpPacketMediaType::kPadding); } diff --git a/modules/pacing/task_queue_paced_sender.cc b/modules/pacing/task_queue_paced_sender.cc index c58241fdd8..c392a88720 100644 --- a/modules/pacing/task_queue_paced_sender.cc +++ b/modules/pacing/task_queue_paced_sender.cc @@ -141,7 +141,7 @@ void TaskQueuePacedSender::EnqueuePackets( RTC_DCHECK_RUN_ON(&task_queue_); for (auto& packet : packets_) { packet_size_.Apply(1, packet->size()); - RTC_DCHECK_GE(packet->capture_time_ms(), 0); + RTC_DCHECK_GE(packet->capture_time(), Timestamp::Zero()); pacing_controller_.EnqueuePacket(std::move(packet)); } MaybeProcessPackets(Timestamp::MinusInfinity()); diff --git a/modules/rtp_rtcp/source/deprecated/deprecated_rtp_sender_egress.cc b/modules/rtp_rtcp/source/deprecated/deprecated_rtp_sender_egress.cc index c5c06840d2..9cef33165c 100644 --- a/modules/rtp_rtcp/source/deprecated/deprecated_rtp_sender_egress.cc +++ b/modules/rtp_rtcp/source/deprecated/deprecated_rtp_sender_egress.cc @@ -156,7 +156,7 @@ void DEPRECATED_RtpSenderEgress::SendPacket( // In case of VideoTimingExtension, since it's present not in every packet, // data after rtp header may be corrupted if these packets are protected by // the FEC. - int64_t diff_ms = now_ms - packet->capture_time_ms(); + int64_t diff_ms = now_ms - packet->capture_time().ms(); if (packet->HasExtension()) { packet->SetExtension(kTimestampTicksPerMs * diff_ms); } @@ -167,9 +167,9 @@ void DEPRECATED_RtpSenderEgress::SendPacket( if (packet->HasExtension()) { if (populate_network2_timestamp_) { - packet->set_network2_time_ms(now_ms); + packet->set_network2_time(Timestamp::Millis(now_ms)); } else { - packet->set_pacer_exit_time_ms(now_ms); + packet->set_pacer_exit_time(Timestamp::Millis(now_ms)); } } @@ -190,8 +190,8 @@ void DEPRECATED_RtpSenderEgress::SendPacket( if (packet->packet_type() != RtpPacketMediaType::kPadding && packet->packet_type() != RtpPacketMediaType::kRetransmission) { - UpdateDelayStatistics(packet->capture_time_ms(), now_ms, packet_ssrc); - UpdateOnSendPacket(options.packet_id, packet->capture_time_ms(), + UpdateDelayStatistics(packet->capture_time().ms(), now_ms, packet_ssrc); + UpdateOnSendPacket(options.packet_id, packet->capture_time().ms(), packet_ssrc); } diff --git a/modules/rtp_rtcp/source/flexfec_sender.cc b/modules/rtp_rtcp/source/flexfec_sender.cc index 071829f1c0..f6fe06e0e4 100644 --- a/modules/rtp_rtcp/source/flexfec_sender.cc +++ b/modules/rtp_rtcp/source/flexfec_sender.cc @@ -142,7 +142,7 @@ std::vector> FlexfecSender::GetFecPackets() { clock_->TimeInMilliseconds())); // Set "capture time" so that the TransmissionOffset header extension // can be set by the RTPSender. - fec_packet_to_send->set_capture_time_ms(clock_->TimeInMilliseconds()); + fec_packet_to_send->set_capture_time(clock_->CurrentTime()); fec_packet_to_send->SetSsrc(ssrc_); // Reserve extensions, if registered. These will be set by the RTPSender. fec_packet_to_send->ReserveExtension(); diff --git a/modules/rtp_rtcp/source/packet_sequencer.cc b/modules/rtp_rtcp/source/packet_sequencer.cc index 037542ddbd..55edd768a8 100644 --- a/modules/rtp_rtcp/source/packet_sequencer.cc +++ b/modules/rtp_rtcp/source/packet_sequencer.cc @@ -99,7 +99,7 @@ void PacketSequencer::UpdateLastPacketState(const RtpPacketToSend& packet) { // Save timestamps to generate timestamp field and extensions for the padding. last_rtp_timestamp_ = packet.Timestamp(); last_timestamp_time_ms_ = clock_->TimeInMilliseconds(); - last_capture_time_ms_ = packet.capture_time_ms(); + last_capture_time_ms_ = packet.capture_time().ms(); } void PacketSequencer::PopulatePaddingFields(RtpPacketToSend& packet) { @@ -107,7 +107,7 @@ void PacketSequencer::PopulatePaddingFields(RtpPacketToSend& packet) { RTC_DCHECK(CanSendPaddingOnMediaSsrc()); packet.SetTimestamp(last_rtp_timestamp_); - packet.set_capture_time_ms(last_capture_time_ms_); + packet.set_capture_time(Timestamp::Millis(last_capture_time_ms_)); packet.SetPayloadType(last_payload_type_); return; } @@ -119,7 +119,7 @@ void PacketSequencer::PopulatePaddingFields(RtpPacketToSend& packet) { } packet.SetTimestamp(last_rtp_timestamp_); - packet.set_capture_time_ms(last_capture_time_ms_); + packet.set_capture_time(Timestamp::Millis(last_capture_time_ms_)); // Only change the timestamp of padding packets sent over RTX. // Padding only packets over RTP has to be sent as part of a media @@ -129,9 +129,10 @@ void PacketSequencer::PopulatePaddingFields(RtpPacketToSend& packet) { packet.SetTimestamp(packet.Timestamp() + (now_ms - last_timestamp_time_ms_) * kTimestampTicksPerMs); - if (packet.capture_time_ms() > 0) { - packet.set_capture_time_ms(packet.capture_time_ms() + - (now_ms - last_timestamp_time_ms_)); + if (packet.capture_time() > Timestamp::Zero()) { + packet.set_capture_time( + packet.capture_time() + + TimeDelta::Millis(now_ms - last_timestamp_time_ms_)); } } } diff --git a/modules/rtp_rtcp/source/packet_sequencer_unittest.cc b/modules/rtp_rtcp/source/packet_sequencer_unittest.cc index b82e76541c..d892863768 100644 --- a/modules/rtp_rtcp/source/packet_sequencer_unittest.cc +++ b/modules/rtp_rtcp/source/packet_sequencer_unittest.cc @@ -41,10 +41,10 @@ class PacketSequencerTest : public ::testing::Test { packet.set_packet_type(type); packet.SetSsrc(ssrc); packet.SetSequenceNumber(kDefaultSequenceNumber); - packet.set_capture_time_ms(clock_.TimeInMilliseconds()); + packet.set_capture_time(clock_.CurrentTime()); packet.SetTimestamp( kStartRtpTimestamp + - static_cast(packet.capture_time_ms() - kStartTime.ms())); + static_cast(packet.capture_time().ms() - kStartTime.ms())); return packet; } @@ -152,7 +152,7 @@ TEST_F(PacketSequencerTest, UpdatesPaddingBasedOnLastMediaPacket) { EXPECT_EQ(padding_packet.SequenceNumber(), kMediaStartSequenceNumber + 1); EXPECT_EQ(padding_packet.PayloadType(), kMediaPayloadType); EXPECT_EQ(padding_packet.Timestamp(), media_packet.Timestamp()); - EXPECT_EQ(padding_packet.capture_time_ms(), media_packet.capture_time_ms()); + EXPECT_EQ(padding_packet.capture_time(), media_packet.capture_time()); } TEST_F(PacketSequencerTest, UpdatesPaddingBasedOnLastRedPacket) { @@ -181,7 +181,7 @@ TEST_F(PacketSequencerTest, UpdatesPaddingBasedOnLastRedPacket) { EXPECT_EQ(padding_packet.SequenceNumber(), kMediaStartSequenceNumber + 1); EXPECT_EQ(padding_packet.PayloadType(), kMediaPayloadType + 1); EXPECT_EQ(padding_packet.Timestamp(), media_packet.Timestamp()); - EXPECT_EQ(padding_packet.capture_time_ms(), media_packet.capture_time_ms()); + EXPECT_EQ(padding_packet.capture_time(), media_packet.capture_time()); } TEST_F(PacketSequencerTest, DoesNotUpdateFieldsOnPayloadPadding) { @@ -201,7 +201,7 @@ TEST_F(PacketSequencerTest, DoesNotUpdateFieldsOnPayloadPadding) { padding_packet.SetPayloadSize(100); padding_packet.SetPayloadType(kMediaPayloadType + 1); padding_packet.SetTimestamp(kStartRtpTimestamp + 1); - padding_packet.set_capture_time_ms(kStartTime.ms() + 1); + padding_packet.set_capture_time(kStartTime + TimeDelta::Millis(1)); sequencer_.set_rtx_sequence_number(kRtxStartSequenceNumber); sequencer_.Sequence(padding_packet); @@ -209,7 +209,7 @@ TEST_F(PacketSequencerTest, DoesNotUpdateFieldsOnPayloadPadding) { EXPECT_EQ(padding_packet.SequenceNumber(), kRtxStartSequenceNumber); EXPECT_EQ(padding_packet.PayloadType(), kMediaPayloadType + 1); EXPECT_EQ(padding_packet.Timestamp(), kStartRtpTimestamp + 1); - EXPECT_EQ(padding_packet.capture_time_ms(), kStartTime.ms() + 1); + EXPECT_EQ(padding_packet.capture_time(), kStartTime + TimeDelta::Millis(1)); } TEST_F(PacketSequencerTest, UpdatesRtxPaddingBasedOnLastMediaPacket) { @@ -242,8 +242,8 @@ TEST_F(PacketSequencerTest, UpdatesRtxPaddingBasedOnLastMediaPacket) { EXPECT_EQ( padding_packet.Timestamp(), media_packet.Timestamp() + (kTimeDelta.ms() * kTimestampTicksPerMs)); - EXPECT_EQ(padding_packet.capture_time_ms(), - media_packet.capture_time_ms() + kTimeDelta.ms()); + EXPECT_EQ(padding_packet.capture_time(), + media_packet.capture_time() + kTimeDelta); } } // namespace diff --git a/modules/rtp_rtcp/source/rtp_packet_history.cc b/modules/rtp_rtcp/source/rtp_packet_history.cc index fe5ccc708e..0bfb043448 100644 --- a/modules/rtp_rtcp/source/rtp_packet_history.cc +++ b/modules/rtp_rtcp/source/rtp_packet_history.cc @@ -492,7 +492,7 @@ RtpPacketHistory::PacketState RtpPacketHistory::StoredPacketToPacketState( RtpPacketHistory::PacketState state; state.rtp_sequence_number = stored_packet.packet_->SequenceNumber(); state.send_time_ms = stored_packet.send_time_ms_; - state.capture_time_ms = stored_packet.packet_->capture_time_ms(); + state.capture_time_ms = stored_packet.packet_->capture_time().ms(); state.ssrc = stored_packet.packet_->Ssrc(); state.packet_size = stored_packet.packet_->size(); state.times_retransmitted = stored_packet.times_retransmitted(); diff --git a/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc b/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc index 90e984a78c..ef9ce593b5 100644 --- a/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc @@ -45,7 +45,7 @@ class RtpPacketHistoryTest : public ::testing::TestWithParam { // Payload, ssrc, timestamp and extensions are irrelevant for this tests. std::unique_ptr packet(new RtpPacketToSend(nullptr)); packet->SetSequenceNumber(seq_num); - packet->set_capture_time_ms(fake_clock_.TimeInMilliseconds()); + packet->set_capture_time(fake_clock_.CurrentTime()); packet->set_allow_retransmission(true); return packet; } @@ -122,9 +122,9 @@ TEST_P(RtpPacketHistoryTest, PutRtpPacket) { TEST_P(RtpPacketHistoryTest, GetRtpPacket) { hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 10); - int64_t capture_time_ms = 1; + Timestamp capture_time = Timestamp::Millis(1); std::unique_ptr packet = CreateRtpPacket(kStartSeqNum); - packet->set_capture_time_ms(capture_time_ms); + packet->set_capture_time(capture_time); rtc::CopyOnWriteBuffer buffer = packet->Buffer(); hist_.PutRtpPacket(std::move(packet), absl::nullopt); @@ -132,7 +132,7 @@ TEST_P(RtpPacketHistoryTest, GetRtpPacket) { hist_.GetPacketAndSetSendTime(kStartSeqNum); EXPECT_TRUE(packet_out); EXPECT_EQ(buffer, packet_out->Buffer()); - EXPECT_EQ(capture_time_ms, packet_out->capture_time_ms()); + EXPECT_EQ(capture_time, packet_out->capture_time()); } TEST_P(RtpPacketHistoryTest, PacketStateIsCorrect) { @@ -212,7 +212,7 @@ TEST_P(RtpPacketHistoryTest, MinResendTimeWithoutPacer) { hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 10); hist_.SetRtt(kMinRetransmitIntervalMs); - int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); + Timestamp capture_time = fake_clock_.CurrentTime(); std::unique_ptr packet = CreateRtpPacket(kStartSeqNum); size_t len = packet->size(); hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMilliseconds()); @@ -222,7 +222,7 @@ TEST_P(RtpPacketHistoryTest, MinResendTimeWithoutPacer) { packet = hist_.GetPacketAndSetSendTime(kStartSeqNum); EXPECT_TRUE(packet); EXPECT_EQ(len, packet->size()); - EXPECT_EQ(capture_time_ms, packet->capture_time_ms()); + EXPECT_EQ(packet->capture_time(), capture_time); // Second retransmission - advance time to just before retransmission OK. fake_clock_.AdvanceTimeMilliseconds(kMinRetransmitIntervalMs - 1); diff --git a/modules/rtp_rtcp/source/rtp_packet_to_send.h b/modules/rtp_rtcp/source/rtp_packet_to_send.h index 12341ef6cf..9b3bbf673a 100644 --- a/modules/rtp_rtcp/source/rtp_packet_to_send.h +++ b/modules/rtp_rtcp/source/rtp_packet_to_send.h @@ -15,10 +15,12 @@ #include +#include "absl/base/attributes.h" #include "absl/types/optional.h" #include "api/array_view.h" #include "api/ref_counted_base.h" #include "api/scoped_refptr.h" +#include "api/units/timestamp.h" #include "api/video/video_timing.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/source/rtp_header_extensions.h" @@ -44,9 +46,15 @@ class RtpPacketToSend : public RtpPacket { ~RtpPacketToSend(); // Time in local time base as close as it can to frame capture time. - int64_t capture_time_ms() const { return capture_time_ms_; } - - void set_capture_time_ms(int64_t time) { capture_time_ms_ = time; } + webrtc::Timestamp capture_time() const { return capture_time_; } + void set_capture_time(webrtc::Timestamp time) { capture_time_ = time; } + + ABSL_DEPRECATED("Use capture_time() instead") + int64_t capture_time_ms() const { return capture_time_.ms_or(-1); } + ABSL_DEPRECATED("Use set_capture_time() instead") + void set_capture_time_ms(int64_t time) { + capture_time_ = webrtc::Timestamp::Millis(time); + } void set_packet_type(RtpPacketMediaType type) { packet_type_ = type; } absl::optional packet_type() const { @@ -77,27 +85,55 @@ class RtpPacketToSend : public RtpPacket { additional_data_ = std::move(data); } + void set_packetization_finish_time(webrtc::Timestamp time) { + SetExtension( + VideoSendTiming::GetDeltaCappedMs(time - capture_time_), + VideoTimingExtension::kPacketizationFinishDeltaOffset); + } + + void set_pacer_exit_time(webrtc::Timestamp time) { + SetExtension( + VideoSendTiming::GetDeltaCappedMs(time - capture_time_), + VideoTimingExtension::kPacerExitDeltaOffset); + } + + void set_network_time(webrtc::Timestamp time) { + SetExtension( + VideoSendTiming::GetDeltaCappedMs(time - capture_time_), + VideoTimingExtension::kNetworkTimestampDeltaOffset); + } + + void set_network2_time(webrtc::Timestamp time) { + SetExtension( + VideoSendTiming::GetDeltaCappedMs(time - capture_time_), + VideoTimingExtension::kNetwork2TimestampDeltaOffset); + } + + ABSL_DEPRECATED("Use set_packetization_finish_time() instead") void set_packetization_finish_time_ms(int64_t time) { SetExtension( - VideoSendTiming::GetDeltaCappedMs(capture_time_ms_, time), + VideoSendTiming::GetDeltaCappedMs(capture_time_.ms_or(0), time), VideoTimingExtension::kPacketizationFinishDeltaOffset); } + ABSL_DEPRECATED("Use set_pacer_exit_time() instead") void set_pacer_exit_time_ms(int64_t time) { SetExtension( - VideoSendTiming::GetDeltaCappedMs(capture_time_ms_, time), + VideoSendTiming::GetDeltaCappedMs(capture_time_.ms_or(0), time), VideoTimingExtension::kPacerExitDeltaOffset); } + ABSL_DEPRECATED("Use set_network_time() instead") void set_network_time_ms(int64_t time) { SetExtension( - VideoSendTiming::GetDeltaCappedMs(capture_time_ms_, time), + VideoSendTiming::GetDeltaCappedMs(capture_time_.ms_or(0), time), VideoTimingExtension::kNetworkTimestampDeltaOffset); } + ABSL_DEPRECATED("Use set_network2_time() instead") void set_network2_time_ms(int64_t time) { SetExtension( - VideoSendTiming::GetDeltaCappedMs(capture_time_ms_, time), + VideoSendTiming::GetDeltaCappedMs(capture_time_.ms_or(0), time), VideoTimingExtension::kNetwork2TimestampDeltaOffset); } @@ -121,7 +157,7 @@ class RtpPacketToSend : public RtpPacket { bool is_red() const { return is_red_; } private: - int64_t capture_time_ms_ = 0; + webrtc::Timestamp capture_time_ = webrtc::Timestamp::Zero(); absl::optional packet_type_; bool allow_retransmission_ = false; absl::optional retransmitted_sequence_number_; diff --git a/modules/rtp_rtcp/source/rtp_sender.cc b/modules/rtp_rtcp/source/rtp_sender.cc index c3321d8723..a9bc57f7ca 100644 --- a/modules/rtp_rtcp/source/rtp_sender.cc +++ b/modules/rtp_rtcp/source/rtp_sender.cc @@ -484,13 +484,11 @@ std::vector> RTPSender::GeneratePadding( bool RTPSender::SendToNetwork(std::unique_ptr packet) { RTC_DCHECK(packet); - int64_t now_ms = clock_->TimeInMilliseconds(); - auto packet_type = packet->packet_type(); RTC_CHECK(packet_type) << "Packet type must be set before sending."; - if (packet->capture_time_ms() <= 0) { - packet->set_capture_time_ms(now_ms); + if (packet->capture_time() <= Timestamp::Zero()) { + packet->set_capture_time(clock_->CurrentTime()); } std::vector> packets; @@ -503,13 +501,13 @@ bool RTPSender::SendToNetwork(std::unique_ptr packet) { void RTPSender::EnqueuePackets( std::vector> packets) { RTC_DCHECK(!packets.empty()); - int64_t now_ms = clock_->TimeInMilliseconds(); + Timestamp now = clock_->CurrentTime(); for (auto& packet : packets) { RTC_DCHECK(packet); RTC_CHECK(packet->packet_type().has_value()) << "Packet type must be set before sending."; - if (packet->capture_time_ms() <= 0) { - packet->set_capture_time_ms(now_ms); + if (packet->capture_time() <= Timestamp::Zero()) { + packet->set_capture_time(now); } } @@ -726,7 +724,7 @@ std::unique_ptr RTPSender::BuildRtxPacket( rtx_packet->set_additional_data(packet.additional_data()); // Copy capture time so e.g. TransmissionOffset is correctly set. - rtx_packet->set_capture_time_ms(packet.capture_time_ms()); + rtx_packet->set_capture_time(packet.capture_time()); return rtx_packet; } diff --git a/modules/rtp_rtcp/source/rtp_sender_audio.cc b/modules/rtp_rtcp/source/rtp_sender_audio.cc index 207d1ca045..c0a8075306 100644 --- a/modules/rtp_rtcp/source/rtp_sender_audio.cc +++ b/modules/rtp_rtcp/source/rtp_sender_audio.cc @@ -272,7 +272,7 @@ bool RTPSenderAudio::SendAudio(AudioFrameType frame_type, packet->SetMarker(MarkerBit(frame_type, payload_type)); packet->SetPayloadType(payload_type); packet->SetTimestamp(rtp_timestamp); - packet->set_capture_time_ms(clock_->TimeInMilliseconds()); + packet->set_capture_time(clock_->CurrentTime()); // Update audio level extension, if included. packet->SetExtension( frame_type == AudioFrameType::kAudioFrameSpeech, audio_level_dbov); @@ -370,7 +370,7 @@ bool RTPSenderAudio::SendTelephoneEventPacket(bool ended, packet->SetMarker(marker_bit); packet->SetSsrc(rtp_sender_->SSRC()); packet->SetTimestamp(dtmf_timestamp); - packet->set_capture_time_ms(clock_->TimeInMilliseconds()); + packet->set_capture_time(clock_->CurrentTime()); // Create DTMF data. uint8_t* dtmfbuffer = packet->AllocatePayload(kDtmfSize); diff --git a/modules/rtp_rtcp/source/rtp_sender_egress.cc b/modules/rtp_rtcp/source/rtp_sender_egress.cc index eb55378083..b34b54c1fa 100644 --- a/modules/rtp_rtcp/source/rtp_sender_egress.cc +++ b/modules/rtp_rtcp/source/rtp_sender_egress.cc @@ -225,7 +225,7 @@ void RtpSenderEgress::SendPacket(RtpPacketToSend* packet, // In case of VideoTimingExtension, since it's present not in every packet, // data after rtp header may be corrupted if these packets are protected by // the FEC. - int64_t diff_ms = now_ms - packet->capture_time_ms(); + int64_t diff_ms = now_ms - packet->capture_time().ms(); if (packet->HasExtension()) { packet->SetExtension(kTimestampTicksPerMs * diff_ms); } @@ -236,9 +236,9 @@ void RtpSenderEgress::SendPacket(RtpPacketToSend* packet, if (packet->HasExtension()) { if (populate_network2_timestamp_) { - packet->set_network2_time_ms(now_ms); + packet->set_network2_time(Timestamp::Millis(now_ms)); } else { - packet->set_pacer_exit_time_ms(now_ms); + packet->set_pacer_exit_time(Timestamp::Millis(now_ms)); } } @@ -265,8 +265,8 @@ void RtpSenderEgress::SendPacket(RtpPacketToSend* packet, if (packet->packet_type() != RtpPacketMediaType::kPadding && packet->packet_type() != RtpPacketMediaType::kRetransmission) { - UpdateDelayStatistics(packet->capture_time_ms(), now_ms, packet_ssrc); - UpdateOnSendPacket(options.packet_id, packet->capture_time_ms(), + UpdateDelayStatistics(packet->capture_time().ms(), now_ms, packet_ssrc); + UpdateOnSendPacket(options.packet_id, packet->capture_time().ms(), packet_ssrc); } diff --git a/modules/rtp_rtcp/source/rtp_sender_egress_unittest.cc b/modules/rtp_rtcp/source/rtp_sender_egress_unittest.cc index 0f2a218ae4..3d345b1727 100644 --- a/modules/rtp_rtcp/source/rtp_sender_egress_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_sender_egress_unittest.cc @@ -184,7 +184,7 @@ class RtpSenderEgressTest : public ::testing::TestWithParam { packet->set_packet_type(RtpPacketMediaType::kVideo); packet->SetMarker(marker_bit); packet->SetTimestamp(capture_time_ms * 90); - packet->set_capture_time_ms(capture_time_ms); + packet->set_capture_time(Timestamp::Millis(capture_time_ms)); packet->SetSequenceNumber(sequence_number_++); return packet; } @@ -756,7 +756,7 @@ TEST_P(RtpSenderEgressTest, SendPacketUpdatesExtensions) { std::unique_ptr sender = CreateRtpSenderEgress(); std::unique_ptr packet = BuildRtpPacket(); - packet->set_packetization_finish_time_ms(clock_->TimeInMilliseconds()); + packet->set_packetization_finish_time(clock_->CurrentTime()); const int32_t kDiffMs = 10; time_controller_.AdvanceTime(TimeDelta::Millis(kDiffMs)); diff --git a/modules/rtp_rtcp/source/rtp_sender_unittest.cc b/modules/rtp_rtcp/source/rtp_sender_unittest.cc index 99c2c8087a..0582d71453 100644 --- a/modules/rtp_rtcp/source/rtp_sender_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_sender_unittest.cc @@ -198,7 +198,7 @@ class RtpSenderTest : public ::testing::Test { packet->set_packet_type(RtpPacketMediaType::kVideo); packet->SetMarker(marker_bit); packet->SetTimestamp(timestamp); - packet->set_capture_time_ms(capture_time_ms); + packet->set_capture_time(Timestamp::Millis(capture_time_ms)); return packet; } @@ -354,13 +354,12 @@ TEST_F(RtpSenderTest, PaddingAlwaysAllowedOnAudio) { TEST_F(RtpSenderTest, SendToNetworkForwardsPacketsToPacer) { auto packet = BuildRtpPacket(kPayload, kMarkerBit, kTimestamp, 0); - int64_t now_ms = clock_->TimeInMilliseconds(); + Timestamp now = clock_->CurrentTime(); - EXPECT_CALL( - mock_paced_sender_, - EnqueuePackets(ElementsAre(AllOf( - Pointee(Property(&RtpPacketToSend::Ssrc, kSsrc)), - Pointee(Property(&RtpPacketToSend::capture_time_ms, now_ms)))))); + EXPECT_CALL(mock_paced_sender_, + EnqueuePackets(ElementsAre(AllOf( + Pointee(Property(&RtpPacketToSend::Ssrc, kSsrc)), + Pointee(Property(&RtpPacketToSend::capture_time, now)))))); EXPECT_TRUE( rtp_sender_->SendToNetwork(std::make_unique(*packet))); } @@ -378,7 +377,8 @@ TEST_F(RtpSenderTest, ReSendPacketForwardsPacketsToPacer) { EnqueuePackets(ElementsAre(AllOf( Pointee(Property(&RtpPacketToSend::Ssrc, kSsrc)), Pointee(Property(&RtpPacketToSend::SequenceNumber, kSeqNum)), - Pointee(Property(&RtpPacketToSend::capture_time_ms, now_ms)), + Pointee(Property(&RtpPacketToSend::capture_time, + Timestamp::Millis(now_ms))), Pointee(Property(&RtpPacketToSend::packet_type, RtpPacketMediaType::kRetransmission)))))); EXPECT_TRUE(rtp_sender_->ReSendPacket(kSeqNum)); @@ -527,10 +527,11 @@ TEST_F(RtpSenderTest, UpdatesTimestampsOnPlainRtxPadding) { // Start by sending one media packet. EXPECT_CALL( mock_paced_sender_, - EnqueuePackets(ElementsAre(AllOf( - Pointee(Property(&RtpPacketToSend::padding_size, 0u)), - Pointee(Property(&RtpPacketToSend::Timestamp, start_timestamp)), - Pointee(Property(&RtpPacketToSend::capture_time_ms, start_time)))))); + EnqueuePackets(ElementsAre( + AllOf(Pointee(Property(&RtpPacketToSend::padding_size, 0u)), + Pointee(Property(&RtpPacketToSend::Timestamp, start_timestamp)), + Pointee(Property(&RtpPacketToSend::capture_time, + Timestamp::Millis(start_time))))))); std::unique_ptr media_packet = SendPacket(start_time, /*payload_size=*/600); sequencer_->Sequence(*media_packet); @@ -546,8 +547,8 @@ TEST_F(RtpSenderTest, UpdatesTimestampsOnPlainRtxPadding) { Property(&RtpPacketToSend::padding_size, kMaxPaddingLength), Property(&RtpPacketToSend::Timestamp, start_timestamp + (kTimestampTicksPerMs * kTimeDiff.ms())), - Property(&RtpPacketToSend::capture_time_ms, - start_time + kTimeDiff.ms()))))); + Property(&RtpPacketToSend::capture_time, + Timestamp::Millis(start_time) + kTimeDiff))))); } TEST_F(RtpSenderTest, KeepsTimestampsOnPayloadPadding) { @@ -563,10 +564,11 @@ TEST_F(RtpSenderTest, KeepsTimestampsOnPayloadPadding) { // Start by sending one media packet and putting in the packet history. EXPECT_CALL( mock_paced_sender_, - EnqueuePackets(ElementsAre(AllOf( - Pointee(Property(&RtpPacketToSend::padding_size, 0u)), - Pointee(Property(&RtpPacketToSend::Timestamp, start_timestamp)), - Pointee(Property(&RtpPacketToSend::capture_time_ms, start_time)))))); + EnqueuePackets(ElementsAre( + AllOf(Pointee(Property(&RtpPacketToSend::padding_size, 0u)), + Pointee(Property(&RtpPacketToSend::Timestamp, start_timestamp)), + Pointee(Property(&RtpPacketToSend::capture_time, + Timestamp::Millis(start_time))))))); std::unique_ptr media_packet = SendPacket(start_time, kPayloadSize); packet_history_->PutRtpPacket(std::move(media_packet), start_time); @@ -576,14 +578,14 @@ TEST_F(RtpSenderTest, KeepsTimestampsOnPayloadPadding) { time_controller_.AdvanceTime(kTimeDiff); // Timestamps on payload padding should be set to original. - EXPECT_THAT( - GeneratePadding(/*target_size_bytes=*/100), - Each(AllOf( - Pointee(Property(&RtpPacketToSend::padding_size, 0u)), - Pointee(Property(&RtpPacketToSend::payload_size, - kPayloadSize + kRtxHeaderSize)), - Pointee(Property(&RtpPacketToSend::Timestamp, start_timestamp)), - Pointee(Property(&RtpPacketToSend::capture_time_ms, start_time))))); + EXPECT_THAT(GeneratePadding(/*target_size_bytes=*/100), + Each(AllOf(Pointee(Property(&RtpPacketToSend::padding_size, 0u)), + Pointee(Property(&RtpPacketToSend::payload_size, + kPayloadSize + kRtxHeaderSize)), + Pointee(Property(&RtpPacketToSend::Timestamp, + start_timestamp)), + Pointee(Property(&RtpPacketToSend::capture_time, + Timestamp::Millis(start_time)))))); } // Test that the MID header extension is included on sent packets when @@ -1273,9 +1275,10 @@ TEST_F(RtpSenderTest, SetsCaptureTimeOnRtxRetransmissions) { // preserved. time_controller_.AdvanceTime(TimeDelta::Millis(10)); - EXPECT_CALL(mock_paced_sender_, - EnqueuePackets(ElementsAre(Pointee(Property( - &RtpPacketToSend::capture_time_ms, start_time_ms))))); + EXPECT_CALL( + mock_paced_sender_, + EnqueuePackets(ElementsAre(Pointee(Property( + &RtpPacketToSend::capture_time, Timestamp::Millis(start_time_ms)))))); EXPECT_GT(rtp_sender_->ReSendPacket(kSeqNum), 0); } diff --git a/modules/rtp_rtcp/source/rtp_sender_video.cc b/modules/rtp_rtcp/source/rtp_sender_video.cc index da5dad5839..6d6ba33600 100644 --- a/modules/rtp_rtcp/source/rtp_sender_video.cc +++ b/modules/rtp_rtcp/source/rtp_sender_video.cc @@ -534,7 +534,7 @@ bool RTPSenderVideo::SendVideo( RTC_DCHECK_LE(packet_capacity, single_packet->capacity()); single_packet->SetPayloadType(payload_type); single_packet->SetTimestamp(rtp_timestamp); - single_packet->set_capture_time_ms(capture_time_ms); + single_packet->set_capture_time(Timestamp::Millis(capture_time_ms)); // Construct the absolute capture time extension if not provided. if (!video_header.absolute_capture_time.has_value()) { @@ -695,7 +695,7 @@ bool RTPSenderVideo::SendVideo( // Put packetization finish timestamp into extension. if (packet->HasExtension()) { - packet->set_packetization_finish_time_ms(clock_->TimeInMilliseconds()); + packet->set_packetization_finish_time(clock_->CurrentTime()); } packet->set_fec_protect_packet(use_fec); From a33a28f36061300596ae313554895bbade4c8747 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Fri, 25 Feb 2022 10:02:16 -0800 Subject: [PATCH 058/847] Roll chromium_revision 0e95c9b57e..d418bb1e88 (975060:975168) Change log: https://chromium.googlesource.com/chromium/src/+log/0e95c9b57e..d418bb1e88 Full diff: https://chromium.googlesource.com/chromium/src/+/0e95c9b57e..d418bb1e88 Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/42d67a004d..2dfd7c2422 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/9e7c4ed752..1825abc1e5 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/eac958fe5e..603214b04e * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/aea4a23ebb..d4b6f1bfd0 * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/dfc6cffca9..7a29efcb91 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/d6bfa6aaf0..eeb2fef42d DEPS diff: https://chromium.googlesource.com/chromium/src/+/0e95c9b57e..d418bb1e88/DEPS No update to Clang. BUG=None Change-Id: I0f1b3184d01ca231f311191f13c91fb92c74bcf6 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252640 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36084} --- DEPS | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/DEPS b/DEPS index 2737aa5375..9a01f15c96 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': '0e95c9b57ef0976c45e1bc745832f1cf7d12ce29', + 'chromium_revision': 'd418bb1e88693f04bb2c6b31820125576529c0d2', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@42d67a004d1cf13b02017b474786a64fe259070f', + 'https://chromium.googlesource.com/chromium/src/base@2dfd7c24223bc3cb05a167fab0b8bd98571faa66', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@9e7c4ed7523b9e7e05f307facf3567a96eaad26e', + 'https://chromium.googlesource.com/chromium/src/build@1825abc1e53c0d637d60d68cf8426468d208f3d8', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@893aa038dd17d05f3c5ff5af98daebabc294a948', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@eac958fe5ec2e399d0aced58e2f0c9de1bf6d495', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@603214b04e0305d320622fbc906e2f00915533d5', 'condition': 'checkout_ios', }, 'src/testing': 'https://chromium.googlesource.com/chromium/src/testing@e867c867ab4646cebb173ea71fe979f8cae1c35d', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@aea4a23ebb9b8ce66942b58e2aa0c910b66f3385', + 'https://chromium.googlesource.com/chromium/src/third_party@d4b6f1bfd064dcb2f189dabba08062ffba573923', 'src/buildtools/linux64': { 'packages': [ @@ -228,7 +228,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@dfc6cffca9b6a34068386915d50040c6bc142717', + 'https://android.googlesource.com/platform/external/perfetto.git@7a29efcb91ff562d9fbb61b9490ef8f71983b9f2', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@d6bfa6aaf05643ea82f54448a6e88dd388fd4cc5', + 'https://chromium.googlesource.com/chromium/src/tools@eeb2fef42d2a80b811638747a720a02bee0c8fa6', 'src/third_party/accessibility_test_framework': { 'packages': [ From 7c2e958711aaa17fc03b937bf0657230e7bb1dde Mon Sep 17 00:00:00 2001 From: Tomas Gunnarsson Date: Fri, 25 Feb 2022 23:36:24 +0100 Subject: [PATCH 059/847] Add a guard against double delete to Connection::Destroy Bug: webrtc:13752 Change-Id: I80345fe2e560773f9f98f850def386ec53ae798f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252660 Reviewed-by: Taylor Brandstetter Commit-Queue: Tomas Gunnarsson Cr-Commit-Position: refs/heads/main@{#36085} --- p2p/base/connection.cc | 5 +++++ p2p/base/connection.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/p2p/base/connection.cc b/p2p/base/connection.cc index a04f318acb..1d674e2bcb 100644 --- a/p2p/base/connection.cc +++ b/p2p/base/connection.cc @@ -834,6 +834,11 @@ void Connection::Prune() { void Connection::Destroy() { RTC_DCHECK_RUN_ON(network_thread_); + if (pending_delete_) + return; + + pending_delete_ = true; + RTC_DLOG(LS_VERBOSE) << ToString() << ": Connection destroyed"; // Fire the 'destroyed' event before deleting the object. This is done diff --git a/p2p/base/connection.h b/p2p/base/connection.h index 8254706318..a7b3490757 100644 --- a/p2p/base/connection.h +++ b/p2p/base/connection.h @@ -366,6 +366,9 @@ class Connection : public CandidatePairInterface, public sigslot::has_slots<> { rtc::RateTracker recv_rate_tracker_; rtc::RateTracker send_rate_tracker_; int64_t last_send_data_ = 0; + // Set to true when deletion has been scheduled and must not be done again. + // See `Destroy()` for more details. + bool pending_delete_ RTC_GUARDED_BY(network_thread_) = false; private: // Update the local candidate based on the mapped address attribute. From 1db3c7435eb868713c4b362bda032ebf65c22478 Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Fri, 25 Feb 2022 20:02:51 -0800 Subject: [PATCH 060/847] Update WebRTC code version (2022-02-26T04:02:50). Bug: None Change-Id: I891285668308f55a7c96115e1e74e8922229f193 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252628 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36086} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index 2a1f6485b5..fcab04477f 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 2022-02-25T04:02:04"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-02-26T04:02:50"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From 56db8d09529d5ba92d24954a1d78a90c8ea2cd85 Mon Sep 17 00:00:00 2001 From: Tomas Gunnarsson Date: Sat, 26 Feb 2022 10:32:51 +0000 Subject: [PATCH 061/847] Revert "Represent RtpPacketToSend::capture_time with Timestamp" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 385eb9714daa80306d2f92d36678c42892dab555. Reason for revert: Causes problems downstream: # # Fatal error in: rtc_base/units/unit_base.h, line 122 # last system error: 0 # Check failed: value >= 0 (-234 vs. 0) Original change's description: > Represent RtpPacketToSend::capture_time with Timestamp > > Bug: webrtc:13757 > Change-Id: I0ede22cd34e3a59afe1477d8edd495dce64e3242 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252586 > Reviewed-by: Erik Språng > Reviewed-by: Rasmus Brandt > Commit-Queue: Danil Chapovalov > Cr-Commit-Position: refs/heads/main@{#36083} Bug: webrtc:13757 Change-Id: I8442abd438be8726cf671d0f372d50ecfac6847e No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252720 Auto-Submit: Tomas Gunnarsson Bot-Commit: rubber-stamper@appspot.gserviceaccount.com Commit-Queue: Tomas Gunnarsson Cr-Commit-Position: refs/heads/main@{#36087} --- api/video/BUILD.gn | 1 - api/video/video_timing.cc | 9 --- api/video/video_timing.h | 3 - modules/pacing/paced_sender.cc | 2 +- modules/pacing/pacing_controller_unittest.cc | 4 +- modules/pacing/task_queue_paced_sender.cc | 2 +- .../deprecated_rtp_sender_egress.cc | 10 +-- modules/rtp_rtcp/source/flexfec_sender.cc | 2 +- modules/rtp_rtcp/source/packet_sequencer.cc | 13 ++-- .../source/packet_sequencer_unittest.cc | 16 ++--- modules/rtp_rtcp/source/rtp_packet_history.cc | 2 +- .../source/rtp_packet_history_unittest.cc | 12 ++-- modules/rtp_rtcp/source/rtp_packet_to_send.h | 52 +++------------- modules/rtp_rtcp/source/rtp_sender.cc | 14 +++-- modules/rtp_rtcp/source/rtp_sender_audio.cc | 4 +- modules/rtp_rtcp/source/rtp_sender_egress.cc | 10 +-- .../source/rtp_sender_egress_unittest.cc | 4 +- .../rtp_rtcp/source/rtp_sender_unittest.cc | 61 +++++++++---------- modules/rtp_rtcp/source/rtp_sender_video.cc | 4 +- 19 files changed, 87 insertions(+), 138 deletions(-) diff --git a/api/video/BUILD.gn b/api/video/BUILD.gn index fcea278f82..9fd28914b2 100644 --- a/api/video/BUILD.gn +++ b/api/video/BUILD.gn @@ -31,7 +31,6 @@ rtc_library("video_rtp_headers") { "../../rtc_base:rtc_base_approved", "../../rtc_base/system:rtc_export", "../units:data_rate", - "../units:time_delta", ] absl_deps = [ "//third_party/abseil-cpp/absl/container:inlined_vector", diff --git a/api/video/video_timing.cc b/api/video/video_timing.cc index 0483c20e66..df1bc4857a 100644 --- a/api/video/video_timing.cc +++ b/api/video/video_timing.cc @@ -11,7 +11,6 @@ #include "api/video/video_timing.h" #include "api/array_view.h" -#include "api/units/time_delta.h" #include "rtc_base/logging.h" #include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/strings/string_builder.h" @@ -26,14 +25,6 @@ uint16_t VideoSendTiming::GetDeltaCappedMs(int64_t base_ms, int64_t time_ms) { return rtc::saturated_cast(time_ms - base_ms); } -uint16_t VideoSendTiming::GetDeltaCappedMs(TimeDelta delta) { - if (delta < TimeDelta::Zero()) { - RTC_DLOG(LS_ERROR) << "Delta " << delta.ms() - << "ms expected to be positive"; - } - return rtc::saturated_cast(delta.ms()); -} - TimingFrameInfo::TimingFrameInfo() : rtp_timestamp(0), capture_time_ms(-1), diff --git a/api/video/video_timing.h b/api/video/video_timing.h index 698477a81a..dd8febb3db 100644 --- a/api/video/video_timing.h +++ b/api/video/video_timing.h @@ -16,8 +16,6 @@ #include #include -#include "api/units/time_delta.h" - namespace webrtc { // Video timing timestamps in ms counted from capture_time_ms of a frame. @@ -36,7 +34,6 @@ struct VideoSendTiming { // https://webrtc.org/experiments/rtp-hdrext/video-timing/ extension stores // 16-bit deltas of timestamps from packet capture time. static uint16_t GetDeltaCappedMs(int64_t base_ms, int64_t time_ms); - static uint16_t GetDeltaCappedMs(TimeDelta delta); uint16_t encode_start_delta_ms; uint16_t encode_finish_delta_ms; diff --git a/modules/pacing/paced_sender.cc b/modules/pacing/paced_sender.cc index 2b2d064ef4..acc492db92 100644 --- a/modules/pacing/paced_sender.cc +++ b/modules/pacing/paced_sender.cc @@ -124,7 +124,7 @@ void PacedSender::EnqueuePackets( packet->SequenceNumber(), "rtp_timestamp", packet->Timestamp()); - RTC_DCHECK_GE(packet->capture_time(), Timestamp::Zero()); + RTC_DCHECK_GE(packet->capture_time_ms(), 0); pacing_controller_.EnqueuePacket(std::move(packet)); } } diff --git a/modules/pacing/pacing_controller_unittest.cc b/modules/pacing/pacing_controller_unittest.cc index a24960d896..e7634cd8d5 100644 --- a/modules/pacing/pacing_controller_unittest.cc +++ b/modules/pacing/pacing_controller_unittest.cc @@ -60,7 +60,7 @@ std::unique_ptr BuildPacket(RtpPacketMediaType type, packet->set_packet_type(type); packet->SetSsrc(ssrc); packet->SetSequenceNumber(sequence_number); - packet->set_capture_time(Timestamp::Millis(capture_time_ms)); + packet->set_capture_time_ms(capture_time_ms); packet->SetPayloadSize(size); return packet; } @@ -73,7 +73,7 @@ class MockPacingControllerCallback : public PacingController::PacketSender { void SendPacket(std::unique_ptr packet, const PacedPacketInfo& cluster_info) override { SendPacket(packet->Ssrc(), packet->SequenceNumber(), - packet->capture_time().ms(), + packet->capture_time_ms(), packet->packet_type() == RtpPacketMediaType::kRetransmission, packet->packet_type() == RtpPacketMediaType::kPadding); } diff --git a/modules/pacing/task_queue_paced_sender.cc b/modules/pacing/task_queue_paced_sender.cc index c392a88720..c58241fdd8 100644 --- a/modules/pacing/task_queue_paced_sender.cc +++ b/modules/pacing/task_queue_paced_sender.cc @@ -141,7 +141,7 @@ void TaskQueuePacedSender::EnqueuePackets( RTC_DCHECK_RUN_ON(&task_queue_); for (auto& packet : packets_) { packet_size_.Apply(1, packet->size()); - RTC_DCHECK_GE(packet->capture_time(), Timestamp::Zero()); + RTC_DCHECK_GE(packet->capture_time_ms(), 0); pacing_controller_.EnqueuePacket(std::move(packet)); } MaybeProcessPackets(Timestamp::MinusInfinity()); diff --git a/modules/rtp_rtcp/source/deprecated/deprecated_rtp_sender_egress.cc b/modules/rtp_rtcp/source/deprecated/deprecated_rtp_sender_egress.cc index 9cef33165c..c5c06840d2 100644 --- a/modules/rtp_rtcp/source/deprecated/deprecated_rtp_sender_egress.cc +++ b/modules/rtp_rtcp/source/deprecated/deprecated_rtp_sender_egress.cc @@ -156,7 +156,7 @@ void DEPRECATED_RtpSenderEgress::SendPacket( // In case of VideoTimingExtension, since it's present not in every packet, // data after rtp header may be corrupted if these packets are protected by // the FEC. - int64_t diff_ms = now_ms - packet->capture_time().ms(); + int64_t diff_ms = now_ms - packet->capture_time_ms(); if (packet->HasExtension()) { packet->SetExtension(kTimestampTicksPerMs * diff_ms); } @@ -167,9 +167,9 @@ void DEPRECATED_RtpSenderEgress::SendPacket( if (packet->HasExtension()) { if (populate_network2_timestamp_) { - packet->set_network2_time(Timestamp::Millis(now_ms)); + packet->set_network2_time_ms(now_ms); } else { - packet->set_pacer_exit_time(Timestamp::Millis(now_ms)); + packet->set_pacer_exit_time_ms(now_ms); } } @@ -190,8 +190,8 @@ void DEPRECATED_RtpSenderEgress::SendPacket( if (packet->packet_type() != RtpPacketMediaType::kPadding && packet->packet_type() != RtpPacketMediaType::kRetransmission) { - UpdateDelayStatistics(packet->capture_time().ms(), now_ms, packet_ssrc); - UpdateOnSendPacket(options.packet_id, packet->capture_time().ms(), + UpdateDelayStatistics(packet->capture_time_ms(), now_ms, packet_ssrc); + UpdateOnSendPacket(options.packet_id, packet->capture_time_ms(), packet_ssrc); } diff --git a/modules/rtp_rtcp/source/flexfec_sender.cc b/modules/rtp_rtcp/source/flexfec_sender.cc index f6fe06e0e4..071829f1c0 100644 --- a/modules/rtp_rtcp/source/flexfec_sender.cc +++ b/modules/rtp_rtcp/source/flexfec_sender.cc @@ -142,7 +142,7 @@ std::vector> FlexfecSender::GetFecPackets() { clock_->TimeInMilliseconds())); // Set "capture time" so that the TransmissionOffset header extension // can be set by the RTPSender. - fec_packet_to_send->set_capture_time(clock_->CurrentTime()); + fec_packet_to_send->set_capture_time_ms(clock_->TimeInMilliseconds()); fec_packet_to_send->SetSsrc(ssrc_); // Reserve extensions, if registered. These will be set by the RTPSender. fec_packet_to_send->ReserveExtension(); diff --git a/modules/rtp_rtcp/source/packet_sequencer.cc b/modules/rtp_rtcp/source/packet_sequencer.cc index 55edd768a8..037542ddbd 100644 --- a/modules/rtp_rtcp/source/packet_sequencer.cc +++ b/modules/rtp_rtcp/source/packet_sequencer.cc @@ -99,7 +99,7 @@ void PacketSequencer::UpdateLastPacketState(const RtpPacketToSend& packet) { // Save timestamps to generate timestamp field and extensions for the padding. last_rtp_timestamp_ = packet.Timestamp(); last_timestamp_time_ms_ = clock_->TimeInMilliseconds(); - last_capture_time_ms_ = packet.capture_time().ms(); + last_capture_time_ms_ = packet.capture_time_ms(); } void PacketSequencer::PopulatePaddingFields(RtpPacketToSend& packet) { @@ -107,7 +107,7 @@ void PacketSequencer::PopulatePaddingFields(RtpPacketToSend& packet) { RTC_DCHECK(CanSendPaddingOnMediaSsrc()); packet.SetTimestamp(last_rtp_timestamp_); - packet.set_capture_time(Timestamp::Millis(last_capture_time_ms_)); + packet.set_capture_time_ms(last_capture_time_ms_); packet.SetPayloadType(last_payload_type_); return; } @@ -119,7 +119,7 @@ void PacketSequencer::PopulatePaddingFields(RtpPacketToSend& packet) { } packet.SetTimestamp(last_rtp_timestamp_); - packet.set_capture_time(Timestamp::Millis(last_capture_time_ms_)); + packet.set_capture_time_ms(last_capture_time_ms_); // Only change the timestamp of padding packets sent over RTX. // Padding only packets over RTP has to be sent as part of a media @@ -129,10 +129,9 @@ void PacketSequencer::PopulatePaddingFields(RtpPacketToSend& packet) { packet.SetTimestamp(packet.Timestamp() + (now_ms - last_timestamp_time_ms_) * kTimestampTicksPerMs); - if (packet.capture_time() > Timestamp::Zero()) { - packet.set_capture_time( - packet.capture_time() + - TimeDelta::Millis(now_ms - last_timestamp_time_ms_)); + if (packet.capture_time_ms() > 0) { + packet.set_capture_time_ms(packet.capture_time_ms() + + (now_ms - last_timestamp_time_ms_)); } } } diff --git a/modules/rtp_rtcp/source/packet_sequencer_unittest.cc b/modules/rtp_rtcp/source/packet_sequencer_unittest.cc index d892863768..b82e76541c 100644 --- a/modules/rtp_rtcp/source/packet_sequencer_unittest.cc +++ b/modules/rtp_rtcp/source/packet_sequencer_unittest.cc @@ -41,10 +41,10 @@ class PacketSequencerTest : public ::testing::Test { packet.set_packet_type(type); packet.SetSsrc(ssrc); packet.SetSequenceNumber(kDefaultSequenceNumber); - packet.set_capture_time(clock_.CurrentTime()); + packet.set_capture_time_ms(clock_.TimeInMilliseconds()); packet.SetTimestamp( kStartRtpTimestamp + - static_cast(packet.capture_time().ms() - kStartTime.ms())); + static_cast(packet.capture_time_ms() - kStartTime.ms())); return packet; } @@ -152,7 +152,7 @@ TEST_F(PacketSequencerTest, UpdatesPaddingBasedOnLastMediaPacket) { EXPECT_EQ(padding_packet.SequenceNumber(), kMediaStartSequenceNumber + 1); EXPECT_EQ(padding_packet.PayloadType(), kMediaPayloadType); EXPECT_EQ(padding_packet.Timestamp(), media_packet.Timestamp()); - EXPECT_EQ(padding_packet.capture_time(), media_packet.capture_time()); + EXPECT_EQ(padding_packet.capture_time_ms(), media_packet.capture_time_ms()); } TEST_F(PacketSequencerTest, UpdatesPaddingBasedOnLastRedPacket) { @@ -181,7 +181,7 @@ TEST_F(PacketSequencerTest, UpdatesPaddingBasedOnLastRedPacket) { EXPECT_EQ(padding_packet.SequenceNumber(), kMediaStartSequenceNumber + 1); EXPECT_EQ(padding_packet.PayloadType(), kMediaPayloadType + 1); EXPECT_EQ(padding_packet.Timestamp(), media_packet.Timestamp()); - EXPECT_EQ(padding_packet.capture_time(), media_packet.capture_time()); + EXPECT_EQ(padding_packet.capture_time_ms(), media_packet.capture_time_ms()); } TEST_F(PacketSequencerTest, DoesNotUpdateFieldsOnPayloadPadding) { @@ -201,7 +201,7 @@ TEST_F(PacketSequencerTest, DoesNotUpdateFieldsOnPayloadPadding) { padding_packet.SetPayloadSize(100); padding_packet.SetPayloadType(kMediaPayloadType + 1); padding_packet.SetTimestamp(kStartRtpTimestamp + 1); - padding_packet.set_capture_time(kStartTime + TimeDelta::Millis(1)); + padding_packet.set_capture_time_ms(kStartTime.ms() + 1); sequencer_.set_rtx_sequence_number(kRtxStartSequenceNumber); sequencer_.Sequence(padding_packet); @@ -209,7 +209,7 @@ TEST_F(PacketSequencerTest, DoesNotUpdateFieldsOnPayloadPadding) { EXPECT_EQ(padding_packet.SequenceNumber(), kRtxStartSequenceNumber); EXPECT_EQ(padding_packet.PayloadType(), kMediaPayloadType + 1); EXPECT_EQ(padding_packet.Timestamp(), kStartRtpTimestamp + 1); - EXPECT_EQ(padding_packet.capture_time(), kStartTime + TimeDelta::Millis(1)); + EXPECT_EQ(padding_packet.capture_time_ms(), kStartTime.ms() + 1); } TEST_F(PacketSequencerTest, UpdatesRtxPaddingBasedOnLastMediaPacket) { @@ -242,8 +242,8 @@ TEST_F(PacketSequencerTest, UpdatesRtxPaddingBasedOnLastMediaPacket) { EXPECT_EQ( padding_packet.Timestamp(), media_packet.Timestamp() + (kTimeDelta.ms() * kTimestampTicksPerMs)); - EXPECT_EQ(padding_packet.capture_time(), - media_packet.capture_time() + kTimeDelta); + EXPECT_EQ(padding_packet.capture_time_ms(), + media_packet.capture_time_ms() + kTimeDelta.ms()); } } // namespace diff --git a/modules/rtp_rtcp/source/rtp_packet_history.cc b/modules/rtp_rtcp/source/rtp_packet_history.cc index 0bfb043448..fe5ccc708e 100644 --- a/modules/rtp_rtcp/source/rtp_packet_history.cc +++ b/modules/rtp_rtcp/source/rtp_packet_history.cc @@ -492,7 +492,7 @@ RtpPacketHistory::PacketState RtpPacketHistory::StoredPacketToPacketState( RtpPacketHistory::PacketState state; state.rtp_sequence_number = stored_packet.packet_->SequenceNumber(); state.send_time_ms = stored_packet.send_time_ms_; - state.capture_time_ms = stored_packet.packet_->capture_time().ms(); + state.capture_time_ms = stored_packet.packet_->capture_time_ms(); state.ssrc = stored_packet.packet_->Ssrc(); state.packet_size = stored_packet.packet_->size(); state.times_retransmitted = stored_packet.times_retransmitted(); diff --git a/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc b/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc index ef9ce593b5..90e984a78c 100644 --- a/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc @@ -45,7 +45,7 @@ class RtpPacketHistoryTest : public ::testing::TestWithParam { // Payload, ssrc, timestamp and extensions are irrelevant for this tests. std::unique_ptr packet(new RtpPacketToSend(nullptr)); packet->SetSequenceNumber(seq_num); - packet->set_capture_time(fake_clock_.CurrentTime()); + packet->set_capture_time_ms(fake_clock_.TimeInMilliseconds()); packet->set_allow_retransmission(true); return packet; } @@ -122,9 +122,9 @@ TEST_P(RtpPacketHistoryTest, PutRtpPacket) { TEST_P(RtpPacketHistoryTest, GetRtpPacket) { hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 10); - Timestamp capture_time = Timestamp::Millis(1); + int64_t capture_time_ms = 1; std::unique_ptr packet = CreateRtpPacket(kStartSeqNum); - packet->set_capture_time(capture_time); + packet->set_capture_time_ms(capture_time_ms); rtc::CopyOnWriteBuffer buffer = packet->Buffer(); hist_.PutRtpPacket(std::move(packet), absl::nullopt); @@ -132,7 +132,7 @@ TEST_P(RtpPacketHistoryTest, GetRtpPacket) { hist_.GetPacketAndSetSendTime(kStartSeqNum); EXPECT_TRUE(packet_out); EXPECT_EQ(buffer, packet_out->Buffer()); - EXPECT_EQ(capture_time, packet_out->capture_time()); + EXPECT_EQ(capture_time_ms, packet_out->capture_time_ms()); } TEST_P(RtpPacketHistoryTest, PacketStateIsCorrect) { @@ -212,7 +212,7 @@ TEST_P(RtpPacketHistoryTest, MinResendTimeWithoutPacer) { hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 10); hist_.SetRtt(kMinRetransmitIntervalMs); - Timestamp capture_time = fake_clock_.CurrentTime(); + int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); std::unique_ptr packet = CreateRtpPacket(kStartSeqNum); size_t len = packet->size(); hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMilliseconds()); @@ -222,7 +222,7 @@ TEST_P(RtpPacketHistoryTest, MinResendTimeWithoutPacer) { packet = hist_.GetPacketAndSetSendTime(kStartSeqNum); EXPECT_TRUE(packet); EXPECT_EQ(len, packet->size()); - EXPECT_EQ(packet->capture_time(), capture_time); + EXPECT_EQ(capture_time_ms, packet->capture_time_ms()); // Second retransmission - advance time to just before retransmission OK. fake_clock_.AdvanceTimeMilliseconds(kMinRetransmitIntervalMs - 1); diff --git a/modules/rtp_rtcp/source/rtp_packet_to_send.h b/modules/rtp_rtcp/source/rtp_packet_to_send.h index 9b3bbf673a..12341ef6cf 100644 --- a/modules/rtp_rtcp/source/rtp_packet_to_send.h +++ b/modules/rtp_rtcp/source/rtp_packet_to_send.h @@ -15,12 +15,10 @@ #include -#include "absl/base/attributes.h" #include "absl/types/optional.h" #include "api/array_view.h" #include "api/ref_counted_base.h" #include "api/scoped_refptr.h" -#include "api/units/timestamp.h" #include "api/video/video_timing.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/source/rtp_header_extensions.h" @@ -46,15 +44,9 @@ class RtpPacketToSend : public RtpPacket { ~RtpPacketToSend(); // Time in local time base as close as it can to frame capture time. - webrtc::Timestamp capture_time() const { return capture_time_; } - void set_capture_time(webrtc::Timestamp time) { capture_time_ = time; } - - ABSL_DEPRECATED("Use capture_time() instead") - int64_t capture_time_ms() const { return capture_time_.ms_or(-1); } - ABSL_DEPRECATED("Use set_capture_time() instead") - void set_capture_time_ms(int64_t time) { - capture_time_ = webrtc::Timestamp::Millis(time); - } + int64_t capture_time_ms() const { return capture_time_ms_; } + + void set_capture_time_ms(int64_t time) { capture_time_ms_ = time; } void set_packet_type(RtpPacketMediaType type) { packet_type_ = type; } absl::optional packet_type() const { @@ -85,55 +77,27 @@ class RtpPacketToSend : public RtpPacket { additional_data_ = std::move(data); } - void set_packetization_finish_time(webrtc::Timestamp time) { - SetExtension( - VideoSendTiming::GetDeltaCappedMs(time - capture_time_), - VideoTimingExtension::kPacketizationFinishDeltaOffset); - } - - void set_pacer_exit_time(webrtc::Timestamp time) { - SetExtension( - VideoSendTiming::GetDeltaCappedMs(time - capture_time_), - VideoTimingExtension::kPacerExitDeltaOffset); - } - - void set_network_time(webrtc::Timestamp time) { - SetExtension( - VideoSendTiming::GetDeltaCappedMs(time - capture_time_), - VideoTimingExtension::kNetworkTimestampDeltaOffset); - } - - void set_network2_time(webrtc::Timestamp time) { - SetExtension( - VideoSendTiming::GetDeltaCappedMs(time - capture_time_), - VideoTimingExtension::kNetwork2TimestampDeltaOffset); - } - - ABSL_DEPRECATED("Use set_packetization_finish_time() instead") void set_packetization_finish_time_ms(int64_t time) { SetExtension( - VideoSendTiming::GetDeltaCappedMs(capture_time_.ms_or(0), time), + VideoSendTiming::GetDeltaCappedMs(capture_time_ms_, time), VideoTimingExtension::kPacketizationFinishDeltaOffset); } - ABSL_DEPRECATED("Use set_pacer_exit_time() instead") void set_pacer_exit_time_ms(int64_t time) { SetExtension( - VideoSendTiming::GetDeltaCappedMs(capture_time_.ms_or(0), time), + VideoSendTiming::GetDeltaCappedMs(capture_time_ms_, time), VideoTimingExtension::kPacerExitDeltaOffset); } - ABSL_DEPRECATED("Use set_network_time() instead") void set_network_time_ms(int64_t time) { SetExtension( - VideoSendTiming::GetDeltaCappedMs(capture_time_.ms_or(0), time), + VideoSendTiming::GetDeltaCappedMs(capture_time_ms_, time), VideoTimingExtension::kNetworkTimestampDeltaOffset); } - ABSL_DEPRECATED("Use set_network2_time() instead") void set_network2_time_ms(int64_t time) { SetExtension( - VideoSendTiming::GetDeltaCappedMs(capture_time_.ms_or(0), time), + VideoSendTiming::GetDeltaCappedMs(capture_time_ms_, time), VideoTimingExtension::kNetwork2TimestampDeltaOffset); } @@ -157,7 +121,7 @@ class RtpPacketToSend : public RtpPacket { bool is_red() const { return is_red_; } private: - webrtc::Timestamp capture_time_ = webrtc::Timestamp::Zero(); + int64_t capture_time_ms_ = 0; absl::optional packet_type_; bool allow_retransmission_ = false; absl::optional retransmitted_sequence_number_; diff --git a/modules/rtp_rtcp/source/rtp_sender.cc b/modules/rtp_rtcp/source/rtp_sender.cc index a9bc57f7ca..c3321d8723 100644 --- a/modules/rtp_rtcp/source/rtp_sender.cc +++ b/modules/rtp_rtcp/source/rtp_sender.cc @@ -484,11 +484,13 @@ std::vector> RTPSender::GeneratePadding( bool RTPSender::SendToNetwork(std::unique_ptr packet) { RTC_DCHECK(packet); + int64_t now_ms = clock_->TimeInMilliseconds(); + auto packet_type = packet->packet_type(); RTC_CHECK(packet_type) << "Packet type must be set before sending."; - if (packet->capture_time() <= Timestamp::Zero()) { - packet->set_capture_time(clock_->CurrentTime()); + if (packet->capture_time_ms() <= 0) { + packet->set_capture_time_ms(now_ms); } std::vector> packets; @@ -501,13 +503,13 @@ bool RTPSender::SendToNetwork(std::unique_ptr packet) { void RTPSender::EnqueuePackets( std::vector> packets) { RTC_DCHECK(!packets.empty()); - Timestamp now = clock_->CurrentTime(); + int64_t now_ms = clock_->TimeInMilliseconds(); for (auto& packet : packets) { RTC_DCHECK(packet); RTC_CHECK(packet->packet_type().has_value()) << "Packet type must be set before sending."; - if (packet->capture_time() <= Timestamp::Zero()) { - packet->set_capture_time(now); + if (packet->capture_time_ms() <= 0) { + packet->set_capture_time_ms(now_ms); } } @@ -724,7 +726,7 @@ std::unique_ptr RTPSender::BuildRtxPacket( rtx_packet->set_additional_data(packet.additional_data()); // Copy capture time so e.g. TransmissionOffset is correctly set. - rtx_packet->set_capture_time(packet.capture_time()); + rtx_packet->set_capture_time_ms(packet.capture_time_ms()); return rtx_packet; } diff --git a/modules/rtp_rtcp/source/rtp_sender_audio.cc b/modules/rtp_rtcp/source/rtp_sender_audio.cc index c0a8075306..207d1ca045 100644 --- a/modules/rtp_rtcp/source/rtp_sender_audio.cc +++ b/modules/rtp_rtcp/source/rtp_sender_audio.cc @@ -272,7 +272,7 @@ bool RTPSenderAudio::SendAudio(AudioFrameType frame_type, packet->SetMarker(MarkerBit(frame_type, payload_type)); packet->SetPayloadType(payload_type); packet->SetTimestamp(rtp_timestamp); - packet->set_capture_time(clock_->CurrentTime()); + packet->set_capture_time_ms(clock_->TimeInMilliseconds()); // Update audio level extension, if included. packet->SetExtension( frame_type == AudioFrameType::kAudioFrameSpeech, audio_level_dbov); @@ -370,7 +370,7 @@ bool RTPSenderAudio::SendTelephoneEventPacket(bool ended, packet->SetMarker(marker_bit); packet->SetSsrc(rtp_sender_->SSRC()); packet->SetTimestamp(dtmf_timestamp); - packet->set_capture_time(clock_->CurrentTime()); + packet->set_capture_time_ms(clock_->TimeInMilliseconds()); // Create DTMF data. uint8_t* dtmfbuffer = packet->AllocatePayload(kDtmfSize); diff --git a/modules/rtp_rtcp/source/rtp_sender_egress.cc b/modules/rtp_rtcp/source/rtp_sender_egress.cc index b34b54c1fa..eb55378083 100644 --- a/modules/rtp_rtcp/source/rtp_sender_egress.cc +++ b/modules/rtp_rtcp/source/rtp_sender_egress.cc @@ -225,7 +225,7 @@ void RtpSenderEgress::SendPacket(RtpPacketToSend* packet, // In case of VideoTimingExtension, since it's present not in every packet, // data after rtp header may be corrupted if these packets are protected by // the FEC. - int64_t diff_ms = now_ms - packet->capture_time().ms(); + int64_t diff_ms = now_ms - packet->capture_time_ms(); if (packet->HasExtension()) { packet->SetExtension(kTimestampTicksPerMs * diff_ms); } @@ -236,9 +236,9 @@ void RtpSenderEgress::SendPacket(RtpPacketToSend* packet, if (packet->HasExtension()) { if (populate_network2_timestamp_) { - packet->set_network2_time(Timestamp::Millis(now_ms)); + packet->set_network2_time_ms(now_ms); } else { - packet->set_pacer_exit_time(Timestamp::Millis(now_ms)); + packet->set_pacer_exit_time_ms(now_ms); } } @@ -265,8 +265,8 @@ void RtpSenderEgress::SendPacket(RtpPacketToSend* packet, if (packet->packet_type() != RtpPacketMediaType::kPadding && packet->packet_type() != RtpPacketMediaType::kRetransmission) { - UpdateDelayStatistics(packet->capture_time().ms(), now_ms, packet_ssrc); - UpdateOnSendPacket(options.packet_id, packet->capture_time().ms(), + UpdateDelayStatistics(packet->capture_time_ms(), now_ms, packet_ssrc); + UpdateOnSendPacket(options.packet_id, packet->capture_time_ms(), packet_ssrc); } diff --git a/modules/rtp_rtcp/source/rtp_sender_egress_unittest.cc b/modules/rtp_rtcp/source/rtp_sender_egress_unittest.cc index 3d345b1727..0f2a218ae4 100644 --- a/modules/rtp_rtcp/source/rtp_sender_egress_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_sender_egress_unittest.cc @@ -184,7 +184,7 @@ class RtpSenderEgressTest : public ::testing::TestWithParam { packet->set_packet_type(RtpPacketMediaType::kVideo); packet->SetMarker(marker_bit); packet->SetTimestamp(capture_time_ms * 90); - packet->set_capture_time(Timestamp::Millis(capture_time_ms)); + packet->set_capture_time_ms(capture_time_ms); packet->SetSequenceNumber(sequence_number_++); return packet; } @@ -756,7 +756,7 @@ TEST_P(RtpSenderEgressTest, SendPacketUpdatesExtensions) { std::unique_ptr sender = CreateRtpSenderEgress(); std::unique_ptr packet = BuildRtpPacket(); - packet->set_packetization_finish_time(clock_->CurrentTime()); + packet->set_packetization_finish_time_ms(clock_->TimeInMilliseconds()); const int32_t kDiffMs = 10; time_controller_.AdvanceTime(TimeDelta::Millis(kDiffMs)); diff --git a/modules/rtp_rtcp/source/rtp_sender_unittest.cc b/modules/rtp_rtcp/source/rtp_sender_unittest.cc index 0582d71453..99c2c8087a 100644 --- a/modules/rtp_rtcp/source/rtp_sender_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_sender_unittest.cc @@ -198,7 +198,7 @@ class RtpSenderTest : public ::testing::Test { packet->set_packet_type(RtpPacketMediaType::kVideo); packet->SetMarker(marker_bit); packet->SetTimestamp(timestamp); - packet->set_capture_time(Timestamp::Millis(capture_time_ms)); + packet->set_capture_time_ms(capture_time_ms); return packet; } @@ -354,12 +354,13 @@ TEST_F(RtpSenderTest, PaddingAlwaysAllowedOnAudio) { TEST_F(RtpSenderTest, SendToNetworkForwardsPacketsToPacer) { auto packet = BuildRtpPacket(kPayload, kMarkerBit, kTimestamp, 0); - Timestamp now = clock_->CurrentTime(); + int64_t now_ms = clock_->TimeInMilliseconds(); - EXPECT_CALL(mock_paced_sender_, - EnqueuePackets(ElementsAre(AllOf( - Pointee(Property(&RtpPacketToSend::Ssrc, kSsrc)), - Pointee(Property(&RtpPacketToSend::capture_time, now)))))); + EXPECT_CALL( + mock_paced_sender_, + EnqueuePackets(ElementsAre(AllOf( + Pointee(Property(&RtpPacketToSend::Ssrc, kSsrc)), + Pointee(Property(&RtpPacketToSend::capture_time_ms, now_ms)))))); EXPECT_TRUE( rtp_sender_->SendToNetwork(std::make_unique(*packet))); } @@ -377,8 +378,7 @@ TEST_F(RtpSenderTest, ReSendPacketForwardsPacketsToPacer) { EnqueuePackets(ElementsAre(AllOf( Pointee(Property(&RtpPacketToSend::Ssrc, kSsrc)), Pointee(Property(&RtpPacketToSend::SequenceNumber, kSeqNum)), - Pointee(Property(&RtpPacketToSend::capture_time, - Timestamp::Millis(now_ms))), + Pointee(Property(&RtpPacketToSend::capture_time_ms, now_ms)), Pointee(Property(&RtpPacketToSend::packet_type, RtpPacketMediaType::kRetransmission)))))); EXPECT_TRUE(rtp_sender_->ReSendPacket(kSeqNum)); @@ -527,11 +527,10 @@ TEST_F(RtpSenderTest, UpdatesTimestampsOnPlainRtxPadding) { // Start by sending one media packet. EXPECT_CALL( mock_paced_sender_, - EnqueuePackets(ElementsAre( - AllOf(Pointee(Property(&RtpPacketToSend::padding_size, 0u)), - Pointee(Property(&RtpPacketToSend::Timestamp, start_timestamp)), - Pointee(Property(&RtpPacketToSend::capture_time, - Timestamp::Millis(start_time))))))); + EnqueuePackets(ElementsAre(AllOf( + Pointee(Property(&RtpPacketToSend::padding_size, 0u)), + Pointee(Property(&RtpPacketToSend::Timestamp, start_timestamp)), + Pointee(Property(&RtpPacketToSend::capture_time_ms, start_time)))))); std::unique_ptr media_packet = SendPacket(start_time, /*payload_size=*/600); sequencer_->Sequence(*media_packet); @@ -547,8 +546,8 @@ TEST_F(RtpSenderTest, UpdatesTimestampsOnPlainRtxPadding) { Property(&RtpPacketToSend::padding_size, kMaxPaddingLength), Property(&RtpPacketToSend::Timestamp, start_timestamp + (kTimestampTicksPerMs * kTimeDiff.ms())), - Property(&RtpPacketToSend::capture_time, - Timestamp::Millis(start_time) + kTimeDiff))))); + Property(&RtpPacketToSend::capture_time_ms, + start_time + kTimeDiff.ms()))))); } TEST_F(RtpSenderTest, KeepsTimestampsOnPayloadPadding) { @@ -564,11 +563,10 @@ TEST_F(RtpSenderTest, KeepsTimestampsOnPayloadPadding) { // Start by sending one media packet and putting in the packet history. EXPECT_CALL( mock_paced_sender_, - EnqueuePackets(ElementsAre( - AllOf(Pointee(Property(&RtpPacketToSend::padding_size, 0u)), - Pointee(Property(&RtpPacketToSend::Timestamp, start_timestamp)), - Pointee(Property(&RtpPacketToSend::capture_time, - Timestamp::Millis(start_time))))))); + EnqueuePackets(ElementsAre(AllOf( + Pointee(Property(&RtpPacketToSend::padding_size, 0u)), + Pointee(Property(&RtpPacketToSend::Timestamp, start_timestamp)), + Pointee(Property(&RtpPacketToSend::capture_time_ms, start_time)))))); std::unique_ptr media_packet = SendPacket(start_time, kPayloadSize); packet_history_->PutRtpPacket(std::move(media_packet), start_time); @@ -578,14 +576,14 @@ TEST_F(RtpSenderTest, KeepsTimestampsOnPayloadPadding) { time_controller_.AdvanceTime(kTimeDiff); // Timestamps on payload padding should be set to original. - EXPECT_THAT(GeneratePadding(/*target_size_bytes=*/100), - Each(AllOf(Pointee(Property(&RtpPacketToSend::padding_size, 0u)), - Pointee(Property(&RtpPacketToSend::payload_size, - kPayloadSize + kRtxHeaderSize)), - Pointee(Property(&RtpPacketToSend::Timestamp, - start_timestamp)), - Pointee(Property(&RtpPacketToSend::capture_time, - Timestamp::Millis(start_time)))))); + EXPECT_THAT( + GeneratePadding(/*target_size_bytes=*/100), + Each(AllOf( + Pointee(Property(&RtpPacketToSend::padding_size, 0u)), + Pointee(Property(&RtpPacketToSend::payload_size, + kPayloadSize + kRtxHeaderSize)), + Pointee(Property(&RtpPacketToSend::Timestamp, start_timestamp)), + Pointee(Property(&RtpPacketToSend::capture_time_ms, start_time))))); } // Test that the MID header extension is included on sent packets when @@ -1275,10 +1273,9 @@ TEST_F(RtpSenderTest, SetsCaptureTimeOnRtxRetransmissions) { // preserved. time_controller_.AdvanceTime(TimeDelta::Millis(10)); - EXPECT_CALL( - mock_paced_sender_, - EnqueuePackets(ElementsAre(Pointee(Property( - &RtpPacketToSend::capture_time, Timestamp::Millis(start_time_ms)))))); + EXPECT_CALL(mock_paced_sender_, + EnqueuePackets(ElementsAre(Pointee(Property( + &RtpPacketToSend::capture_time_ms, start_time_ms))))); EXPECT_GT(rtp_sender_->ReSendPacket(kSeqNum), 0); } diff --git a/modules/rtp_rtcp/source/rtp_sender_video.cc b/modules/rtp_rtcp/source/rtp_sender_video.cc index 6d6ba33600..da5dad5839 100644 --- a/modules/rtp_rtcp/source/rtp_sender_video.cc +++ b/modules/rtp_rtcp/source/rtp_sender_video.cc @@ -534,7 +534,7 @@ bool RTPSenderVideo::SendVideo( RTC_DCHECK_LE(packet_capacity, single_packet->capacity()); single_packet->SetPayloadType(payload_type); single_packet->SetTimestamp(rtp_timestamp); - single_packet->set_capture_time(Timestamp::Millis(capture_time_ms)); + single_packet->set_capture_time_ms(capture_time_ms); // Construct the absolute capture time extension if not provided. if (!video_header.absolute_capture_time.has_value()) { @@ -695,7 +695,7 @@ bool RTPSenderVideo::SendVideo( // Put packetization finish timestamp into extension. if (packet->HasExtension()) { - packet->set_packetization_finish_time(clock_->CurrentTime()); + packet->set_packetization_finish_time_ms(clock_->TimeInMilliseconds()); } packet->set_fec_protect_packet(use_fec); From 1dddc7f7f9593fb96226b2e00f60a7f1f125401f Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Sat, 26 Feb 2022 04:02:17 -0800 Subject: [PATCH 062/847] Roll chromium_revision d418bb1e88..5688012168 (975168:975461) Change log: https://chromium.googlesource.com/chromium/src/+log/d418bb1e88..5688012168 Full diff: https://chromium.googlesource.com/chromium/src/+/d418bb1e88..5688012168 Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/2dfd7c2422..402f200100 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/1825abc1e5..48b4cff6a5 * src/buildtools/third_party/libunwind/trunk: https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git/+log/8cd7191937..2ea265b95a * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/603214b04e..5969559967 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/e867c867ab..e5a7a6719a * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/d4b6f1bfd0..dd5821349b * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/392c66f379..666eff907b * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/7a29efcb91..5b5f79bbdb * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/eeb2fef42d..21f13c8e61 DEPS diff: https://chromium.googlesource.com/chromium/src/+/d418bb1e88..5688012168/DEPS No update to Clang. BUG=None Change-Id: Ia7352e67f0d96bcb1f69b95ac41621215c1dcdad Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252740 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36088} --- DEPS | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/DEPS b/DEPS index 9a01f15c96..1e0a29c840 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': 'd418bb1e88693f04bb2c6b31820125576529c0d2', + 'chromium_revision': '5688012168805e9d67c29ea3aa7271b594404d7b', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@2dfd7c24223bc3cb05a167fab0b8bd98571faa66', + 'https://chromium.googlesource.com/chromium/src/base@402f2001000a6c4f3106b89e549f4066d315e5c0', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@1825abc1e53c0d637d60d68cf8426468d208f3d8', + 'https://chromium.googlesource.com/chromium/src/build@48b4cff6a547de252f958d79ff88598992c46d7c', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@893aa038dd17d05f3c5ff5af98daebabc294a948', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@603214b04e0305d320622fbc906e2f00915533d5', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@596955996740cbb569121fa463648a74e503babb', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@e867c867ab4646cebb173ea71fe979f8cae1c35d', + 'https://chromium.googlesource.com/chromium/src/testing@e5a7a6719aa1d4975a8e2f4ee52ee6bf194db7ae', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@d4b6f1bfd064dcb2f189dabba08062ffba573923', + 'https://chromium.googlesource.com/chromium/src/third_party@dd5821349bc531875a1b79f6e62386dc6e9a4efa', 'src/buildtools/linux64': { 'packages': [ @@ -80,7 +80,7 @@ deps = { 'src/buildtools/third_party/libc++abi/trunk': 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git@738dc100c61890744f9e78cac27c71d0a2190781', 'src/buildtools/third_party/libunwind/trunk': - 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git@8cd7191937c9341646c88e39eae63ccd692ace91', + 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git@2ea265b95a08e4a98fab16b327119788b8e50a69', 'src/tools/clang/dsymutil': { 'packages': [ @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@392c66f379f22799379b5d10d577bb2a73b2723c', + 'https://chromium.googlesource.com/catapult.git@666eff907b58ca7b4c82c0fae4c6e1d24f223ea0', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -228,7 +228,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@7a29efcb91ff562d9fbb61b9490ef8f71983b9f2', + 'https://android.googlesource.com/platform/external/perfetto.git@5b5f79bbdb2a2d59c88f02394cac1b08298a3da7', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@eeb2fef42d2a80b811638747a720a02bee0c8fa6', + 'https://chromium.googlesource.com/chromium/src/tools@21f13c8e61ed1bbdeb412f57adfb5fc1adc3076e', 'src/third_party/accessibility_test_framework': { 'packages': [ From 52d6c57c6fca017b698fb3eb0af0669be6b3cf5a Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Sat, 26 Feb 2022 20:02:16 -0800 Subject: [PATCH 063/847] Update WebRTC code version (2022-02-27T04:02:16). Bug: None Change-Id: I224b7dfb956c9455b5730e0b41dd450a202756bf Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252842 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36089} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index fcab04477f..1e8fb28960 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 2022-02-26T04:02:50"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-02-27T04:02:16"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From 8e5a64ae7e74ecb0d8eee4690e44acb758a4bbea Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Sun, 27 Feb 2022 06:01:59 -0800 Subject: [PATCH 064/847] Roll chromium_revision 5688012168..b566a7ee01 (975461:975563) Change log: https://chromium.googlesource.com/chromium/src/+log/5688012168..b566a7ee01 Full diff: https://chromium.googlesource.com/chromium/src/+/5688012168..b566a7ee01 Changed dependencies * src/build: https://chromium.googlesource.com/chromium/src/build/+log/48b4cff6a5..6f29f6c02a * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/5969559967..d3d38e3db5 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/e5a7a6719a..d607f42a01 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/dd5821349b..8b03c87b78 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/21f13c8e61..b5781f6627 DEPS diff: https://chromium.googlesource.com/chromium/src/+/5688012168..b566a7ee01/DEPS No update to Clang. BUG=None Change-Id: I0add0830e1e04482c1c7285e2ae80ba57b43a9d1 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252881 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36090} --- DEPS | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/DEPS b/DEPS index 1e0a29c840..f61adb1339 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': '5688012168805e9d67c29ea3aa7271b594404d7b', + 'chromium_revision': 'b566a7ee0184648cdac54041265dc0197a320b82', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -25,7 +25,7 @@ deps = { 'src/base': 'https://chromium.googlesource.com/chromium/src/base@402f2001000a6c4f3106b89e549f4066d315e5c0', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@48b4cff6a547de252f958d79ff88598992c46d7c', + 'https://chromium.googlesource.com/chromium/src/build@6f29f6c02a8328288c09cbb491111e1463703d3f', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@893aa038dd17d05f3c5ff5af98daebabc294a948', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@596955996740cbb569121fa463648a74e503babb', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@d3d38e3db57c34455cc702f0ea2037f678939df4', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@e5a7a6719aa1d4975a8e2f4ee52ee6bf194db7ae', + 'https://chromium.googlesource.com/chromium/src/testing@d607f42a019bf73d83554b6e8976b20d13068765', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@dd5821349bc531875a1b79f6e62386dc6e9a4efa', + 'https://chromium.googlesource.com/chromium/src/third_party@8b03c87b78e860510bdec9fd71a61a1f93bdc9d7', 'src/buildtools/linux64': { 'packages': [ @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@21f13c8e61ed1bbdeb412f57adfb5fc1adc3076e', + 'https://chromium.googlesource.com/chromium/src/tools@b5781f66279c35071e23677aa251ed08259e86a8', 'src/third_party/accessibility_test_framework': { 'packages': [ From c5f6201131c530c12ab5fcad7917902ccbffccc9 Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Sun, 27 Feb 2022 20:03:35 -0800 Subject: [PATCH 065/847] Update WebRTC code version (2022-02-28T04:03:34). Bug: None Change-Id: I9a9770fff882ecd0b1d0a7c4dc3e26b110fbee1c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252886 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36091} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index 1e8fb28960..12fbc9bcc7 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 2022-02-27T04:02:16"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-02-28T04:03:34"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From 6ccd74816a00a81bac9d9a27392d08b9802138ff Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Sun, 27 Feb 2022 22:02:01 -0800 Subject: [PATCH 066/847] Roll chromium_revision b566a7ee01..45ec87b29f (975563:975667) Change log: https://chromium.googlesource.com/chromium/src/+log/b566a7ee01..45ec87b29f Full diff: https://chromium.googlesource.com/chromium/src/+/b566a7ee01..45ec87b29f Changed dependencies * src/build: https://chromium.googlesource.com/chromium/src/build/+log/6f29f6c02a..3651f40a5d * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/d3d38e3db5..9f0a2dddd9 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/d607f42a01..8bf5b5b5e9 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/8b03c87b78..16c2bd0c52 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/b5781f6627..d82d1d5395 DEPS diff: https://chromium.googlesource.com/chromium/src/+/b566a7ee01..45ec87b29f/DEPS No update to Clang. BUG=None Change-Id: Id61fa205e94fd43a88ff4234c9a4e029c9e2be10 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252921 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36092} --- DEPS | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/DEPS b/DEPS index f61adb1339..9d3e3c008c 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': 'b566a7ee0184648cdac54041265dc0197a320b82', + 'chromium_revision': '45ec87b29fb536932d3c26d6cf236128a872a14b', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -25,7 +25,7 @@ deps = { 'src/base': 'https://chromium.googlesource.com/chromium/src/base@402f2001000a6c4f3106b89e549f4066d315e5c0', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@6f29f6c02a8328288c09cbb491111e1463703d3f', + 'https://chromium.googlesource.com/chromium/src/build@3651f40a5dd644c7f853a1e41ba6871e0bcf4fb5', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@893aa038dd17d05f3c5ff5af98daebabc294a948', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@d3d38e3db57c34455cc702f0ea2037f678939df4', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@9f0a2dddd9b1c282bb9ebd79f40e42bf0eb349f4', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@d607f42a019bf73d83554b6e8976b20d13068765', + 'https://chromium.googlesource.com/chromium/src/testing@8bf5b5b5e992d3734d89e29421aec1e177c13af7', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@8b03c87b78e860510bdec9fd71a61a1f93bdc9d7', + 'https://chromium.googlesource.com/chromium/src/third_party@16c2bd0c5228c45b9dd6691257ac8a0a3bf30be5', 'src/buildtools/linux64': { 'packages': [ @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@b5781f66279c35071e23677aa251ed08259e86a8', + 'https://chromium.googlesource.com/chromium/src/tools@d82d1d5395429329981926389acec572d6e86ebf', 'src/third_party/accessibility_test_framework': { 'packages': [ From 9af4aa7cf498540ff1a3a5b92fe8463079f17d32 Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Sun, 27 Feb 2022 21:10:55 +0000 Subject: [PATCH 067/847] Reland "Represent RtpPacketToSend::capture_time with Timestamp" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 56db8d09529d5ba92d24954a1d78a90c8ea2cd85. Reason for revert: downstream problem addressed Original change's description: > Revert "Represent RtpPacketToSend::capture_time with Timestamp" > > This reverts commit 385eb9714daa80306d2f92d36678c42892dab555. > > Reason for revert: Causes problems downstream: > > # > # Fatal error in: rtc_base/units/unit_base.h, line 122 > # last system error: 0 > # Check failed: value >= 0 (-234 vs. 0) > > Original change's description: > > Represent RtpPacketToSend::capture_time with Timestamp > > > > Bug: webrtc:13757 > > Change-Id: I0ede22cd34e3a59afe1477d8edd495dce64e3242 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252586 > > Reviewed-by: Erik Språng > > Reviewed-by: Rasmus Brandt > > Commit-Queue: Danil Chapovalov > > Cr-Commit-Position: refs/heads/main@{#36083} > > Bug: webrtc:13757 > Change-Id: I8442abd438be8726cf671d0f372d50ecfac6847e > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252720 > Auto-Submit: Tomas Gunnarsson > Bot-Commit: rubber-stamper@appspot.gserviceaccount.com > Commit-Queue: Tomas Gunnarsson > Cr-Commit-Position: refs/heads/main@{#36087} Bug: webrtc:13757 Change-Id: I1fa852757480116f35deb2b6c3c27800bdf5e197 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252781 Reviewed-by: Rasmus Brandt Reviewed-by: Erik Språng Reviewed-by: Tomas Gunnarsson Commit-Queue: Danil Chapovalov Cr-Commit-Position: refs/heads/main@{#36093} --- api/video/BUILD.gn | 1 + api/video/video_timing.cc | 9 +++ api/video/video_timing.h | 3 + modules/pacing/paced_sender.cc | 2 +- modules/pacing/pacing_controller_unittest.cc | 4 +- modules/pacing/task_queue_paced_sender.cc | 2 +- .../deprecated_rtp_sender_egress.cc | 10 +-- modules/rtp_rtcp/source/flexfec_sender.cc | 2 +- modules/rtp_rtcp/source/packet_sequencer.cc | 13 ++-- .../source/packet_sequencer_unittest.cc | 16 ++--- modules/rtp_rtcp/source/rtp_packet_history.cc | 2 +- .../source/rtp_packet_history_unittest.cc | 12 ++-- modules/rtp_rtcp/source/rtp_packet_to_send.h | 52 +++++++++++++--- modules/rtp_rtcp/source/rtp_sender.cc | 14 ++--- modules/rtp_rtcp/source/rtp_sender_audio.cc | 4 +- modules/rtp_rtcp/source/rtp_sender_egress.cc | 10 +-- .../source/rtp_sender_egress_unittest.cc | 4 +- .../rtp_rtcp/source/rtp_sender_unittest.cc | 61 ++++++++++--------- modules/rtp_rtcp/source/rtp_sender_video.cc | 4 +- 19 files changed, 138 insertions(+), 87 deletions(-) diff --git a/api/video/BUILD.gn b/api/video/BUILD.gn index 9fd28914b2..fcea278f82 100644 --- a/api/video/BUILD.gn +++ b/api/video/BUILD.gn @@ -31,6 +31,7 @@ rtc_library("video_rtp_headers") { "../../rtc_base:rtc_base_approved", "../../rtc_base/system:rtc_export", "../units:data_rate", + "../units:time_delta", ] absl_deps = [ "//third_party/abseil-cpp/absl/container:inlined_vector", diff --git a/api/video/video_timing.cc b/api/video/video_timing.cc index df1bc4857a..0483c20e66 100644 --- a/api/video/video_timing.cc +++ b/api/video/video_timing.cc @@ -11,6 +11,7 @@ #include "api/video/video_timing.h" #include "api/array_view.h" +#include "api/units/time_delta.h" #include "rtc_base/logging.h" #include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/strings/string_builder.h" @@ -25,6 +26,14 @@ uint16_t VideoSendTiming::GetDeltaCappedMs(int64_t base_ms, int64_t time_ms) { return rtc::saturated_cast(time_ms - base_ms); } +uint16_t VideoSendTiming::GetDeltaCappedMs(TimeDelta delta) { + if (delta < TimeDelta::Zero()) { + RTC_DLOG(LS_ERROR) << "Delta " << delta.ms() + << "ms expected to be positive"; + } + return rtc::saturated_cast(delta.ms()); +} + TimingFrameInfo::TimingFrameInfo() : rtp_timestamp(0), capture_time_ms(-1), diff --git a/api/video/video_timing.h b/api/video/video_timing.h index dd8febb3db..698477a81a 100644 --- a/api/video/video_timing.h +++ b/api/video/video_timing.h @@ -16,6 +16,8 @@ #include #include +#include "api/units/time_delta.h" + namespace webrtc { // Video timing timestamps in ms counted from capture_time_ms of a frame. @@ -34,6 +36,7 @@ struct VideoSendTiming { // https://webrtc.org/experiments/rtp-hdrext/video-timing/ extension stores // 16-bit deltas of timestamps from packet capture time. static uint16_t GetDeltaCappedMs(int64_t base_ms, int64_t time_ms); + static uint16_t GetDeltaCappedMs(TimeDelta delta); uint16_t encode_start_delta_ms; uint16_t encode_finish_delta_ms; diff --git a/modules/pacing/paced_sender.cc b/modules/pacing/paced_sender.cc index acc492db92..2b2d064ef4 100644 --- a/modules/pacing/paced_sender.cc +++ b/modules/pacing/paced_sender.cc @@ -124,7 +124,7 @@ void PacedSender::EnqueuePackets( packet->SequenceNumber(), "rtp_timestamp", packet->Timestamp()); - RTC_DCHECK_GE(packet->capture_time_ms(), 0); + RTC_DCHECK_GE(packet->capture_time(), Timestamp::Zero()); pacing_controller_.EnqueuePacket(std::move(packet)); } } diff --git a/modules/pacing/pacing_controller_unittest.cc b/modules/pacing/pacing_controller_unittest.cc index e7634cd8d5..a24960d896 100644 --- a/modules/pacing/pacing_controller_unittest.cc +++ b/modules/pacing/pacing_controller_unittest.cc @@ -60,7 +60,7 @@ std::unique_ptr BuildPacket(RtpPacketMediaType type, packet->set_packet_type(type); packet->SetSsrc(ssrc); packet->SetSequenceNumber(sequence_number); - packet->set_capture_time_ms(capture_time_ms); + packet->set_capture_time(Timestamp::Millis(capture_time_ms)); packet->SetPayloadSize(size); return packet; } @@ -73,7 +73,7 @@ class MockPacingControllerCallback : public PacingController::PacketSender { void SendPacket(std::unique_ptr packet, const PacedPacketInfo& cluster_info) override { SendPacket(packet->Ssrc(), packet->SequenceNumber(), - packet->capture_time_ms(), + packet->capture_time().ms(), packet->packet_type() == RtpPacketMediaType::kRetransmission, packet->packet_type() == RtpPacketMediaType::kPadding); } diff --git a/modules/pacing/task_queue_paced_sender.cc b/modules/pacing/task_queue_paced_sender.cc index c58241fdd8..c392a88720 100644 --- a/modules/pacing/task_queue_paced_sender.cc +++ b/modules/pacing/task_queue_paced_sender.cc @@ -141,7 +141,7 @@ void TaskQueuePacedSender::EnqueuePackets( RTC_DCHECK_RUN_ON(&task_queue_); for (auto& packet : packets_) { packet_size_.Apply(1, packet->size()); - RTC_DCHECK_GE(packet->capture_time_ms(), 0); + RTC_DCHECK_GE(packet->capture_time(), Timestamp::Zero()); pacing_controller_.EnqueuePacket(std::move(packet)); } MaybeProcessPackets(Timestamp::MinusInfinity()); diff --git a/modules/rtp_rtcp/source/deprecated/deprecated_rtp_sender_egress.cc b/modules/rtp_rtcp/source/deprecated/deprecated_rtp_sender_egress.cc index c5c06840d2..9cef33165c 100644 --- a/modules/rtp_rtcp/source/deprecated/deprecated_rtp_sender_egress.cc +++ b/modules/rtp_rtcp/source/deprecated/deprecated_rtp_sender_egress.cc @@ -156,7 +156,7 @@ void DEPRECATED_RtpSenderEgress::SendPacket( // In case of VideoTimingExtension, since it's present not in every packet, // data after rtp header may be corrupted if these packets are protected by // the FEC. - int64_t diff_ms = now_ms - packet->capture_time_ms(); + int64_t diff_ms = now_ms - packet->capture_time().ms(); if (packet->HasExtension()) { packet->SetExtension(kTimestampTicksPerMs * diff_ms); } @@ -167,9 +167,9 @@ void DEPRECATED_RtpSenderEgress::SendPacket( if (packet->HasExtension()) { if (populate_network2_timestamp_) { - packet->set_network2_time_ms(now_ms); + packet->set_network2_time(Timestamp::Millis(now_ms)); } else { - packet->set_pacer_exit_time_ms(now_ms); + packet->set_pacer_exit_time(Timestamp::Millis(now_ms)); } } @@ -190,8 +190,8 @@ void DEPRECATED_RtpSenderEgress::SendPacket( if (packet->packet_type() != RtpPacketMediaType::kPadding && packet->packet_type() != RtpPacketMediaType::kRetransmission) { - UpdateDelayStatistics(packet->capture_time_ms(), now_ms, packet_ssrc); - UpdateOnSendPacket(options.packet_id, packet->capture_time_ms(), + UpdateDelayStatistics(packet->capture_time().ms(), now_ms, packet_ssrc); + UpdateOnSendPacket(options.packet_id, packet->capture_time().ms(), packet_ssrc); } diff --git a/modules/rtp_rtcp/source/flexfec_sender.cc b/modules/rtp_rtcp/source/flexfec_sender.cc index 071829f1c0..f6fe06e0e4 100644 --- a/modules/rtp_rtcp/source/flexfec_sender.cc +++ b/modules/rtp_rtcp/source/flexfec_sender.cc @@ -142,7 +142,7 @@ std::vector> FlexfecSender::GetFecPackets() { clock_->TimeInMilliseconds())); // Set "capture time" so that the TransmissionOffset header extension // can be set by the RTPSender. - fec_packet_to_send->set_capture_time_ms(clock_->TimeInMilliseconds()); + fec_packet_to_send->set_capture_time(clock_->CurrentTime()); fec_packet_to_send->SetSsrc(ssrc_); // Reserve extensions, if registered. These will be set by the RTPSender. fec_packet_to_send->ReserveExtension(); diff --git a/modules/rtp_rtcp/source/packet_sequencer.cc b/modules/rtp_rtcp/source/packet_sequencer.cc index 037542ddbd..55edd768a8 100644 --- a/modules/rtp_rtcp/source/packet_sequencer.cc +++ b/modules/rtp_rtcp/source/packet_sequencer.cc @@ -99,7 +99,7 @@ void PacketSequencer::UpdateLastPacketState(const RtpPacketToSend& packet) { // Save timestamps to generate timestamp field and extensions for the padding. last_rtp_timestamp_ = packet.Timestamp(); last_timestamp_time_ms_ = clock_->TimeInMilliseconds(); - last_capture_time_ms_ = packet.capture_time_ms(); + last_capture_time_ms_ = packet.capture_time().ms(); } void PacketSequencer::PopulatePaddingFields(RtpPacketToSend& packet) { @@ -107,7 +107,7 @@ void PacketSequencer::PopulatePaddingFields(RtpPacketToSend& packet) { RTC_DCHECK(CanSendPaddingOnMediaSsrc()); packet.SetTimestamp(last_rtp_timestamp_); - packet.set_capture_time_ms(last_capture_time_ms_); + packet.set_capture_time(Timestamp::Millis(last_capture_time_ms_)); packet.SetPayloadType(last_payload_type_); return; } @@ -119,7 +119,7 @@ void PacketSequencer::PopulatePaddingFields(RtpPacketToSend& packet) { } packet.SetTimestamp(last_rtp_timestamp_); - packet.set_capture_time_ms(last_capture_time_ms_); + packet.set_capture_time(Timestamp::Millis(last_capture_time_ms_)); // Only change the timestamp of padding packets sent over RTX. // Padding only packets over RTP has to be sent as part of a media @@ -129,9 +129,10 @@ void PacketSequencer::PopulatePaddingFields(RtpPacketToSend& packet) { packet.SetTimestamp(packet.Timestamp() + (now_ms - last_timestamp_time_ms_) * kTimestampTicksPerMs); - if (packet.capture_time_ms() > 0) { - packet.set_capture_time_ms(packet.capture_time_ms() + - (now_ms - last_timestamp_time_ms_)); + if (packet.capture_time() > Timestamp::Zero()) { + packet.set_capture_time( + packet.capture_time() + + TimeDelta::Millis(now_ms - last_timestamp_time_ms_)); } } } diff --git a/modules/rtp_rtcp/source/packet_sequencer_unittest.cc b/modules/rtp_rtcp/source/packet_sequencer_unittest.cc index b82e76541c..d892863768 100644 --- a/modules/rtp_rtcp/source/packet_sequencer_unittest.cc +++ b/modules/rtp_rtcp/source/packet_sequencer_unittest.cc @@ -41,10 +41,10 @@ class PacketSequencerTest : public ::testing::Test { packet.set_packet_type(type); packet.SetSsrc(ssrc); packet.SetSequenceNumber(kDefaultSequenceNumber); - packet.set_capture_time_ms(clock_.TimeInMilliseconds()); + packet.set_capture_time(clock_.CurrentTime()); packet.SetTimestamp( kStartRtpTimestamp + - static_cast(packet.capture_time_ms() - kStartTime.ms())); + static_cast(packet.capture_time().ms() - kStartTime.ms())); return packet; } @@ -152,7 +152,7 @@ TEST_F(PacketSequencerTest, UpdatesPaddingBasedOnLastMediaPacket) { EXPECT_EQ(padding_packet.SequenceNumber(), kMediaStartSequenceNumber + 1); EXPECT_EQ(padding_packet.PayloadType(), kMediaPayloadType); EXPECT_EQ(padding_packet.Timestamp(), media_packet.Timestamp()); - EXPECT_EQ(padding_packet.capture_time_ms(), media_packet.capture_time_ms()); + EXPECT_EQ(padding_packet.capture_time(), media_packet.capture_time()); } TEST_F(PacketSequencerTest, UpdatesPaddingBasedOnLastRedPacket) { @@ -181,7 +181,7 @@ TEST_F(PacketSequencerTest, UpdatesPaddingBasedOnLastRedPacket) { EXPECT_EQ(padding_packet.SequenceNumber(), kMediaStartSequenceNumber + 1); EXPECT_EQ(padding_packet.PayloadType(), kMediaPayloadType + 1); EXPECT_EQ(padding_packet.Timestamp(), media_packet.Timestamp()); - EXPECT_EQ(padding_packet.capture_time_ms(), media_packet.capture_time_ms()); + EXPECT_EQ(padding_packet.capture_time(), media_packet.capture_time()); } TEST_F(PacketSequencerTest, DoesNotUpdateFieldsOnPayloadPadding) { @@ -201,7 +201,7 @@ TEST_F(PacketSequencerTest, DoesNotUpdateFieldsOnPayloadPadding) { padding_packet.SetPayloadSize(100); padding_packet.SetPayloadType(kMediaPayloadType + 1); padding_packet.SetTimestamp(kStartRtpTimestamp + 1); - padding_packet.set_capture_time_ms(kStartTime.ms() + 1); + padding_packet.set_capture_time(kStartTime + TimeDelta::Millis(1)); sequencer_.set_rtx_sequence_number(kRtxStartSequenceNumber); sequencer_.Sequence(padding_packet); @@ -209,7 +209,7 @@ TEST_F(PacketSequencerTest, DoesNotUpdateFieldsOnPayloadPadding) { EXPECT_EQ(padding_packet.SequenceNumber(), kRtxStartSequenceNumber); EXPECT_EQ(padding_packet.PayloadType(), kMediaPayloadType + 1); EXPECT_EQ(padding_packet.Timestamp(), kStartRtpTimestamp + 1); - EXPECT_EQ(padding_packet.capture_time_ms(), kStartTime.ms() + 1); + EXPECT_EQ(padding_packet.capture_time(), kStartTime + TimeDelta::Millis(1)); } TEST_F(PacketSequencerTest, UpdatesRtxPaddingBasedOnLastMediaPacket) { @@ -242,8 +242,8 @@ TEST_F(PacketSequencerTest, UpdatesRtxPaddingBasedOnLastMediaPacket) { EXPECT_EQ( padding_packet.Timestamp(), media_packet.Timestamp() + (kTimeDelta.ms() * kTimestampTicksPerMs)); - EXPECT_EQ(padding_packet.capture_time_ms(), - media_packet.capture_time_ms() + kTimeDelta.ms()); + EXPECT_EQ(padding_packet.capture_time(), + media_packet.capture_time() + kTimeDelta); } } // namespace diff --git a/modules/rtp_rtcp/source/rtp_packet_history.cc b/modules/rtp_rtcp/source/rtp_packet_history.cc index fe5ccc708e..0bfb043448 100644 --- a/modules/rtp_rtcp/source/rtp_packet_history.cc +++ b/modules/rtp_rtcp/source/rtp_packet_history.cc @@ -492,7 +492,7 @@ RtpPacketHistory::PacketState RtpPacketHistory::StoredPacketToPacketState( RtpPacketHistory::PacketState state; state.rtp_sequence_number = stored_packet.packet_->SequenceNumber(); state.send_time_ms = stored_packet.send_time_ms_; - state.capture_time_ms = stored_packet.packet_->capture_time_ms(); + state.capture_time_ms = stored_packet.packet_->capture_time().ms(); state.ssrc = stored_packet.packet_->Ssrc(); state.packet_size = stored_packet.packet_->size(); state.times_retransmitted = stored_packet.times_retransmitted(); diff --git a/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc b/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc index 90e984a78c..ef9ce593b5 100644 --- a/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc @@ -45,7 +45,7 @@ class RtpPacketHistoryTest : public ::testing::TestWithParam { // Payload, ssrc, timestamp and extensions are irrelevant for this tests. std::unique_ptr packet(new RtpPacketToSend(nullptr)); packet->SetSequenceNumber(seq_num); - packet->set_capture_time_ms(fake_clock_.TimeInMilliseconds()); + packet->set_capture_time(fake_clock_.CurrentTime()); packet->set_allow_retransmission(true); return packet; } @@ -122,9 +122,9 @@ TEST_P(RtpPacketHistoryTest, PutRtpPacket) { TEST_P(RtpPacketHistoryTest, GetRtpPacket) { hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 10); - int64_t capture_time_ms = 1; + Timestamp capture_time = Timestamp::Millis(1); std::unique_ptr packet = CreateRtpPacket(kStartSeqNum); - packet->set_capture_time_ms(capture_time_ms); + packet->set_capture_time(capture_time); rtc::CopyOnWriteBuffer buffer = packet->Buffer(); hist_.PutRtpPacket(std::move(packet), absl::nullopt); @@ -132,7 +132,7 @@ TEST_P(RtpPacketHistoryTest, GetRtpPacket) { hist_.GetPacketAndSetSendTime(kStartSeqNum); EXPECT_TRUE(packet_out); EXPECT_EQ(buffer, packet_out->Buffer()); - EXPECT_EQ(capture_time_ms, packet_out->capture_time_ms()); + EXPECT_EQ(capture_time, packet_out->capture_time()); } TEST_P(RtpPacketHistoryTest, PacketStateIsCorrect) { @@ -212,7 +212,7 @@ TEST_P(RtpPacketHistoryTest, MinResendTimeWithoutPacer) { hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 10); hist_.SetRtt(kMinRetransmitIntervalMs); - int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); + Timestamp capture_time = fake_clock_.CurrentTime(); std::unique_ptr packet = CreateRtpPacket(kStartSeqNum); size_t len = packet->size(); hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMilliseconds()); @@ -222,7 +222,7 @@ TEST_P(RtpPacketHistoryTest, MinResendTimeWithoutPacer) { packet = hist_.GetPacketAndSetSendTime(kStartSeqNum); EXPECT_TRUE(packet); EXPECT_EQ(len, packet->size()); - EXPECT_EQ(capture_time_ms, packet->capture_time_ms()); + EXPECT_EQ(packet->capture_time(), capture_time); // Second retransmission - advance time to just before retransmission OK. fake_clock_.AdvanceTimeMilliseconds(kMinRetransmitIntervalMs - 1); diff --git a/modules/rtp_rtcp/source/rtp_packet_to_send.h b/modules/rtp_rtcp/source/rtp_packet_to_send.h index 12341ef6cf..9b3bbf673a 100644 --- a/modules/rtp_rtcp/source/rtp_packet_to_send.h +++ b/modules/rtp_rtcp/source/rtp_packet_to_send.h @@ -15,10 +15,12 @@ #include +#include "absl/base/attributes.h" #include "absl/types/optional.h" #include "api/array_view.h" #include "api/ref_counted_base.h" #include "api/scoped_refptr.h" +#include "api/units/timestamp.h" #include "api/video/video_timing.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/source/rtp_header_extensions.h" @@ -44,9 +46,15 @@ class RtpPacketToSend : public RtpPacket { ~RtpPacketToSend(); // Time in local time base as close as it can to frame capture time. - int64_t capture_time_ms() const { return capture_time_ms_; } - - void set_capture_time_ms(int64_t time) { capture_time_ms_ = time; } + webrtc::Timestamp capture_time() const { return capture_time_; } + void set_capture_time(webrtc::Timestamp time) { capture_time_ = time; } + + ABSL_DEPRECATED("Use capture_time() instead") + int64_t capture_time_ms() const { return capture_time_.ms_or(-1); } + ABSL_DEPRECATED("Use set_capture_time() instead") + void set_capture_time_ms(int64_t time) { + capture_time_ = webrtc::Timestamp::Millis(time); + } void set_packet_type(RtpPacketMediaType type) { packet_type_ = type; } absl::optional packet_type() const { @@ -77,27 +85,55 @@ class RtpPacketToSend : public RtpPacket { additional_data_ = std::move(data); } + void set_packetization_finish_time(webrtc::Timestamp time) { + SetExtension( + VideoSendTiming::GetDeltaCappedMs(time - capture_time_), + VideoTimingExtension::kPacketizationFinishDeltaOffset); + } + + void set_pacer_exit_time(webrtc::Timestamp time) { + SetExtension( + VideoSendTiming::GetDeltaCappedMs(time - capture_time_), + VideoTimingExtension::kPacerExitDeltaOffset); + } + + void set_network_time(webrtc::Timestamp time) { + SetExtension( + VideoSendTiming::GetDeltaCappedMs(time - capture_time_), + VideoTimingExtension::kNetworkTimestampDeltaOffset); + } + + void set_network2_time(webrtc::Timestamp time) { + SetExtension( + VideoSendTiming::GetDeltaCappedMs(time - capture_time_), + VideoTimingExtension::kNetwork2TimestampDeltaOffset); + } + + ABSL_DEPRECATED("Use set_packetization_finish_time() instead") void set_packetization_finish_time_ms(int64_t time) { SetExtension( - VideoSendTiming::GetDeltaCappedMs(capture_time_ms_, time), + VideoSendTiming::GetDeltaCappedMs(capture_time_.ms_or(0), time), VideoTimingExtension::kPacketizationFinishDeltaOffset); } + ABSL_DEPRECATED("Use set_pacer_exit_time() instead") void set_pacer_exit_time_ms(int64_t time) { SetExtension( - VideoSendTiming::GetDeltaCappedMs(capture_time_ms_, time), + VideoSendTiming::GetDeltaCappedMs(capture_time_.ms_or(0), time), VideoTimingExtension::kPacerExitDeltaOffset); } + ABSL_DEPRECATED("Use set_network_time() instead") void set_network_time_ms(int64_t time) { SetExtension( - VideoSendTiming::GetDeltaCappedMs(capture_time_ms_, time), + VideoSendTiming::GetDeltaCappedMs(capture_time_.ms_or(0), time), VideoTimingExtension::kNetworkTimestampDeltaOffset); } + ABSL_DEPRECATED("Use set_network2_time() instead") void set_network2_time_ms(int64_t time) { SetExtension( - VideoSendTiming::GetDeltaCappedMs(capture_time_ms_, time), + VideoSendTiming::GetDeltaCappedMs(capture_time_.ms_or(0), time), VideoTimingExtension::kNetwork2TimestampDeltaOffset); } @@ -121,7 +157,7 @@ class RtpPacketToSend : public RtpPacket { bool is_red() const { return is_red_; } private: - int64_t capture_time_ms_ = 0; + webrtc::Timestamp capture_time_ = webrtc::Timestamp::Zero(); absl::optional packet_type_; bool allow_retransmission_ = false; absl::optional retransmitted_sequence_number_; diff --git a/modules/rtp_rtcp/source/rtp_sender.cc b/modules/rtp_rtcp/source/rtp_sender.cc index c3321d8723..a9bc57f7ca 100644 --- a/modules/rtp_rtcp/source/rtp_sender.cc +++ b/modules/rtp_rtcp/source/rtp_sender.cc @@ -484,13 +484,11 @@ std::vector> RTPSender::GeneratePadding( bool RTPSender::SendToNetwork(std::unique_ptr packet) { RTC_DCHECK(packet); - int64_t now_ms = clock_->TimeInMilliseconds(); - auto packet_type = packet->packet_type(); RTC_CHECK(packet_type) << "Packet type must be set before sending."; - if (packet->capture_time_ms() <= 0) { - packet->set_capture_time_ms(now_ms); + if (packet->capture_time() <= Timestamp::Zero()) { + packet->set_capture_time(clock_->CurrentTime()); } std::vector> packets; @@ -503,13 +501,13 @@ bool RTPSender::SendToNetwork(std::unique_ptr packet) { void RTPSender::EnqueuePackets( std::vector> packets) { RTC_DCHECK(!packets.empty()); - int64_t now_ms = clock_->TimeInMilliseconds(); + Timestamp now = clock_->CurrentTime(); for (auto& packet : packets) { RTC_DCHECK(packet); RTC_CHECK(packet->packet_type().has_value()) << "Packet type must be set before sending."; - if (packet->capture_time_ms() <= 0) { - packet->set_capture_time_ms(now_ms); + if (packet->capture_time() <= Timestamp::Zero()) { + packet->set_capture_time(now); } } @@ -726,7 +724,7 @@ std::unique_ptr RTPSender::BuildRtxPacket( rtx_packet->set_additional_data(packet.additional_data()); // Copy capture time so e.g. TransmissionOffset is correctly set. - rtx_packet->set_capture_time_ms(packet.capture_time_ms()); + rtx_packet->set_capture_time(packet.capture_time()); return rtx_packet; } diff --git a/modules/rtp_rtcp/source/rtp_sender_audio.cc b/modules/rtp_rtcp/source/rtp_sender_audio.cc index 207d1ca045..c0a8075306 100644 --- a/modules/rtp_rtcp/source/rtp_sender_audio.cc +++ b/modules/rtp_rtcp/source/rtp_sender_audio.cc @@ -272,7 +272,7 @@ bool RTPSenderAudio::SendAudio(AudioFrameType frame_type, packet->SetMarker(MarkerBit(frame_type, payload_type)); packet->SetPayloadType(payload_type); packet->SetTimestamp(rtp_timestamp); - packet->set_capture_time_ms(clock_->TimeInMilliseconds()); + packet->set_capture_time(clock_->CurrentTime()); // Update audio level extension, if included. packet->SetExtension( frame_type == AudioFrameType::kAudioFrameSpeech, audio_level_dbov); @@ -370,7 +370,7 @@ bool RTPSenderAudio::SendTelephoneEventPacket(bool ended, packet->SetMarker(marker_bit); packet->SetSsrc(rtp_sender_->SSRC()); packet->SetTimestamp(dtmf_timestamp); - packet->set_capture_time_ms(clock_->TimeInMilliseconds()); + packet->set_capture_time(clock_->CurrentTime()); // Create DTMF data. uint8_t* dtmfbuffer = packet->AllocatePayload(kDtmfSize); diff --git a/modules/rtp_rtcp/source/rtp_sender_egress.cc b/modules/rtp_rtcp/source/rtp_sender_egress.cc index eb55378083..b34b54c1fa 100644 --- a/modules/rtp_rtcp/source/rtp_sender_egress.cc +++ b/modules/rtp_rtcp/source/rtp_sender_egress.cc @@ -225,7 +225,7 @@ void RtpSenderEgress::SendPacket(RtpPacketToSend* packet, // In case of VideoTimingExtension, since it's present not in every packet, // data after rtp header may be corrupted if these packets are protected by // the FEC. - int64_t diff_ms = now_ms - packet->capture_time_ms(); + int64_t diff_ms = now_ms - packet->capture_time().ms(); if (packet->HasExtension()) { packet->SetExtension(kTimestampTicksPerMs * diff_ms); } @@ -236,9 +236,9 @@ void RtpSenderEgress::SendPacket(RtpPacketToSend* packet, if (packet->HasExtension()) { if (populate_network2_timestamp_) { - packet->set_network2_time_ms(now_ms); + packet->set_network2_time(Timestamp::Millis(now_ms)); } else { - packet->set_pacer_exit_time_ms(now_ms); + packet->set_pacer_exit_time(Timestamp::Millis(now_ms)); } } @@ -265,8 +265,8 @@ void RtpSenderEgress::SendPacket(RtpPacketToSend* packet, if (packet->packet_type() != RtpPacketMediaType::kPadding && packet->packet_type() != RtpPacketMediaType::kRetransmission) { - UpdateDelayStatistics(packet->capture_time_ms(), now_ms, packet_ssrc); - UpdateOnSendPacket(options.packet_id, packet->capture_time_ms(), + UpdateDelayStatistics(packet->capture_time().ms(), now_ms, packet_ssrc); + UpdateOnSendPacket(options.packet_id, packet->capture_time().ms(), packet_ssrc); } diff --git a/modules/rtp_rtcp/source/rtp_sender_egress_unittest.cc b/modules/rtp_rtcp/source/rtp_sender_egress_unittest.cc index 0f2a218ae4..3d345b1727 100644 --- a/modules/rtp_rtcp/source/rtp_sender_egress_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_sender_egress_unittest.cc @@ -184,7 +184,7 @@ class RtpSenderEgressTest : public ::testing::TestWithParam { packet->set_packet_type(RtpPacketMediaType::kVideo); packet->SetMarker(marker_bit); packet->SetTimestamp(capture_time_ms * 90); - packet->set_capture_time_ms(capture_time_ms); + packet->set_capture_time(Timestamp::Millis(capture_time_ms)); packet->SetSequenceNumber(sequence_number_++); return packet; } @@ -756,7 +756,7 @@ TEST_P(RtpSenderEgressTest, SendPacketUpdatesExtensions) { std::unique_ptr sender = CreateRtpSenderEgress(); std::unique_ptr packet = BuildRtpPacket(); - packet->set_packetization_finish_time_ms(clock_->TimeInMilliseconds()); + packet->set_packetization_finish_time(clock_->CurrentTime()); const int32_t kDiffMs = 10; time_controller_.AdvanceTime(TimeDelta::Millis(kDiffMs)); diff --git a/modules/rtp_rtcp/source/rtp_sender_unittest.cc b/modules/rtp_rtcp/source/rtp_sender_unittest.cc index 99c2c8087a..0582d71453 100644 --- a/modules/rtp_rtcp/source/rtp_sender_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_sender_unittest.cc @@ -198,7 +198,7 @@ class RtpSenderTest : public ::testing::Test { packet->set_packet_type(RtpPacketMediaType::kVideo); packet->SetMarker(marker_bit); packet->SetTimestamp(timestamp); - packet->set_capture_time_ms(capture_time_ms); + packet->set_capture_time(Timestamp::Millis(capture_time_ms)); return packet; } @@ -354,13 +354,12 @@ TEST_F(RtpSenderTest, PaddingAlwaysAllowedOnAudio) { TEST_F(RtpSenderTest, SendToNetworkForwardsPacketsToPacer) { auto packet = BuildRtpPacket(kPayload, kMarkerBit, kTimestamp, 0); - int64_t now_ms = clock_->TimeInMilliseconds(); + Timestamp now = clock_->CurrentTime(); - EXPECT_CALL( - mock_paced_sender_, - EnqueuePackets(ElementsAre(AllOf( - Pointee(Property(&RtpPacketToSend::Ssrc, kSsrc)), - Pointee(Property(&RtpPacketToSend::capture_time_ms, now_ms)))))); + EXPECT_CALL(mock_paced_sender_, + EnqueuePackets(ElementsAre(AllOf( + Pointee(Property(&RtpPacketToSend::Ssrc, kSsrc)), + Pointee(Property(&RtpPacketToSend::capture_time, now)))))); EXPECT_TRUE( rtp_sender_->SendToNetwork(std::make_unique(*packet))); } @@ -378,7 +377,8 @@ TEST_F(RtpSenderTest, ReSendPacketForwardsPacketsToPacer) { EnqueuePackets(ElementsAre(AllOf( Pointee(Property(&RtpPacketToSend::Ssrc, kSsrc)), Pointee(Property(&RtpPacketToSend::SequenceNumber, kSeqNum)), - Pointee(Property(&RtpPacketToSend::capture_time_ms, now_ms)), + Pointee(Property(&RtpPacketToSend::capture_time, + Timestamp::Millis(now_ms))), Pointee(Property(&RtpPacketToSend::packet_type, RtpPacketMediaType::kRetransmission)))))); EXPECT_TRUE(rtp_sender_->ReSendPacket(kSeqNum)); @@ -527,10 +527,11 @@ TEST_F(RtpSenderTest, UpdatesTimestampsOnPlainRtxPadding) { // Start by sending one media packet. EXPECT_CALL( mock_paced_sender_, - EnqueuePackets(ElementsAre(AllOf( - Pointee(Property(&RtpPacketToSend::padding_size, 0u)), - Pointee(Property(&RtpPacketToSend::Timestamp, start_timestamp)), - Pointee(Property(&RtpPacketToSend::capture_time_ms, start_time)))))); + EnqueuePackets(ElementsAre( + AllOf(Pointee(Property(&RtpPacketToSend::padding_size, 0u)), + Pointee(Property(&RtpPacketToSend::Timestamp, start_timestamp)), + Pointee(Property(&RtpPacketToSend::capture_time, + Timestamp::Millis(start_time))))))); std::unique_ptr media_packet = SendPacket(start_time, /*payload_size=*/600); sequencer_->Sequence(*media_packet); @@ -546,8 +547,8 @@ TEST_F(RtpSenderTest, UpdatesTimestampsOnPlainRtxPadding) { Property(&RtpPacketToSend::padding_size, kMaxPaddingLength), Property(&RtpPacketToSend::Timestamp, start_timestamp + (kTimestampTicksPerMs * kTimeDiff.ms())), - Property(&RtpPacketToSend::capture_time_ms, - start_time + kTimeDiff.ms()))))); + Property(&RtpPacketToSend::capture_time, + Timestamp::Millis(start_time) + kTimeDiff))))); } TEST_F(RtpSenderTest, KeepsTimestampsOnPayloadPadding) { @@ -563,10 +564,11 @@ TEST_F(RtpSenderTest, KeepsTimestampsOnPayloadPadding) { // Start by sending one media packet and putting in the packet history. EXPECT_CALL( mock_paced_sender_, - EnqueuePackets(ElementsAre(AllOf( - Pointee(Property(&RtpPacketToSend::padding_size, 0u)), - Pointee(Property(&RtpPacketToSend::Timestamp, start_timestamp)), - Pointee(Property(&RtpPacketToSend::capture_time_ms, start_time)))))); + EnqueuePackets(ElementsAre( + AllOf(Pointee(Property(&RtpPacketToSend::padding_size, 0u)), + Pointee(Property(&RtpPacketToSend::Timestamp, start_timestamp)), + Pointee(Property(&RtpPacketToSend::capture_time, + Timestamp::Millis(start_time))))))); std::unique_ptr media_packet = SendPacket(start_time, kPayloadSize); packet_history_->PutRtpPacket(std::move(media_packet), start_time); @@ -576,14 +578,14 @@ TEST_F(RtpSenderTest, KeepsTimestampsOnPayloadPadding) { time_controller_.AdvanceTime(kTimeDiff); // Timestamps on payload padding should be set to original. - EXPECT_THAT( - GeneratePadding(/*target_size_bytes=*/100), - Each(AllOf( - Pointee(Property(&RtpPacketToSend::padding_size, 0u)), - Pointee(Property(&RtpPacketToSend::payload_size, - kPayloadSize + kRtxHeaderSize)), - Pointee(Property(&RtpPacketToSend::Timestamp, start_timestamp)), - Pointee(Property(&RtpPacketToSend::capture_time_ms, start_time))))); + EXPECT_THAT(GeneratePadding(/*target_size_bytes=*/100), + Each(AllOf(Pointee(Property(&RtpPacketToSend::padding_size, 0u)), + Pointee(Property(&RtpPacketToSend::payload_size, + kPayloadSize + kRtxHeaderSize)), + Pointee(Property(&RtpPacketToSend::Timestamp, + start_timestamp)), + Pointee(Property(&RtpPacketToSend::capture_time, + Timestamp::Millis(start_time)))))); } // Test that the MID header extension is included on sent packets when @@ -1273,9 +1275,10 @@ TEST_F(RtpSenderTest, SetsCaptureTimeOnRtxRetransmissions) { // preserved. time_controller_.AdvanceTime(TimeDelta::Millis(10)); - EXPECT_CALL(mock_paced_sender_, - EnqueuePackets(ElementsAre(Pointee(Property( - &RtpPacketToSend::capture_time_ms, start_time_ms))))); + EXPECT_CALL( + mock_paced_sender_, + EnqueuePackets(ElementsAre(Pointee(Property( + &RtpPacketToSend::capture_time, Timestamp::Millis(start_time_ms)))))); EXPECT_GT(rtp_sender_->ReSendPacket(kSeqNum), 0); } diff --git a/modules/rtp_rtcp/source/rtp_sender_video.cc b/modules/rtp_rtcp/source/rtp_sender_video.cc index da5dad5839..6d6ba33600 100644 --- a/modules/rtp_rtcp/source/rtp_sender_video.cc +++ b/modules/rtp_rtcp/source/rtp_sender_video.cc @@ -534,7 +534,7 @@ bool RTPSenderVideo::SendVideo( RTC_DCHECK_LE(packet_capacity, single_packet->capacity()); single_packet->SetPayloadType(payload_type); single_packet->SetTimestamp(rtp_timestamp); - single_packet->set_capture_time_ms(capture_time_ms); + single_packet->set_capture_time(Timestamp::Millis(capture_time_ms)); // Construct the absolute capture time extension if not provided. if (!video_header.absolute_capture_time.has_value()) { @@ -695,7 +695,7 @@ bool RTPSenderVideo::SendVideo( // Put packetization finish timestamp into extension. if (packet->HasExtension()) { - packet->set_packetization_finish_time_ms(clock_->TimeInMilliseconds()); + packet->set_packetization_finish_time(clock_->CurrentTime()); } packet->set_fec_protect_packet(use_fec); From c2b1bad4c87a43d7e1af85e809d5abe04baf3104 Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Wed, 23 Feb 2022 20:15:20 +0100 Subject: [PATCH 068/847] In RtcpTransceiver use TimeDelta instead of raw int to represent time Bug: webrtc:8239, webrtc:13757 Change-Id: Idda3fe5761665b4b3fedaf2dd1a28bb0119ae1f1 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252287 Reviewed-by: Emil Lundmark Commit-Queue: Danil Chapovalov Cr-Commit-Position: refs/heads/main@{#36094} --- .../source/rtcp_transceiver_config.cc | 8 +++---- .../rtp_rtcp/source/rtcp_transceiver_config.h | 4 ++-- .../rtp_rtcp/source/rtcp_transceiver_impl.cc | 14 +++++------ .../rtp_rtcp/source/rtcp_transceiver_impl.h | 2 +- .../source/rtcp_transceiver_impl_unittest.cc | 24 +++++++++---------- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/modules/rtp_rtcp/source/rtcp_transceiver_config.cc b/modules/rtp_rtcp/source/rtcp_transceiver_config.cc index 02c0fef9f9..dea6286096 100644 --- a/modules/rtp_rtcp/source/rtcp_transceiver_config.cc +++ b/modules/rtp_rtcp/source/rtcp_transceiver_config.cc @@ -48,13 +48,13 @@ bool RtcpTransceiverConfig::Validate() const { RTC_LOG(LS_ERROR) << debug_id << "outgoing transport must be set"; return false; } - if (initial_report_delay_ms < 0) { - RTC_LOG(LS_ERROR) << debug_id << "delay " << initial_report_delay_ms + if (initial_report_delay < TimeDelta::Zero()) { + RTC_LOG(LS_ERROR) << debug_id << "delay " << initial_report_delay.ms() << "ms before first report shouldn't be negative."; return false; } - if (report_period_ms <= 0) { - RTC_LOG(LS_ERROR) << debug_id << "period " << report_period_ms + if (report_period <= TimeDelta::Zero()) { + RTC_LOG(LS_ERROR) << debug_id << "period " << report_period.ms() << "ms between reports should be positive."; return false; } diff --git a/modules/rtp_rtcp/source/rtcp_transceiver_config.h b/modules/rtp_rtcp/source/rtcp_transceiver_config.h index 2400f9b908..34789dbd0b 100644 --- a/modules/rtp_rtcp/source/rtcp_transceiver_config.h +++ b/modules/rtp_rtcp/source/rtcp_transceiver_config.h @@ -149,10 +149,10 @@ struct RtcpTransceiverConfig { // Initial state if `outgoing_transport` ready to accept packets. bool initial_ready_to_send = true; // Delay before 1st periodic compound packet. - int initial_report_delay_ms = 500; + TimeDelta initial_report_delay = TimeDelta::Millis(500); // Period between periodic compound packets. - int report_period_ms = 1000; + TimeDelta report_period = TimeDelta::Seconds(1); // // Flags for features and experiments. diff --git a/modules/rtp_rtcp/source/rtcp_transceiver_impl.cc b/modules/rtp_rtcp/source/rtcp_transceiver_impl.cc index 5909af93ce..382e9f19ff 100644 --- a/modules/rtp_rtcp/source/rtcp_transceiver_impl.cc +++ b/modules/rtp_rtcp/source/rtcp_transceiver_impl.cc @@ -100,7 +100,7 @@ RtcpTransceiverImpl::RtcpTransceiverImpl(const RtcpTransceiverConfig& config) : config_(config), ready_to_send_(config.initial_ready_to_send) { RTC_CHECK(config_.Validate()); if (ready_to_send_ && config_.schedule_periodic_compound_packets) { - SchedulePeriodicCompoundPackets(config_.initial_report_delay_ms); + SchedulePeriodicCompoundPackets(config_.initial_report_delay); } } @@ -159,7 +159,7 @@ void RtcpTransceiverImpl::SetReadyToSend(bool ready) { periodic_task_handle_.Stop(); if (!ready_to_send_ && ready) // Restart periodic sending. - SchedulePeriodicCompoundPackets(config_.report_period_ms / 2); + SchedulePeriodicCompoundPackets(config_.report_period / 2); } ready_to_send_ = ready; } @@ -470,16 +470,16 @@ void RtcpTransceiverImpl::ReschedulePeriodicCompoundPackets() { return; periodic_task_handle_.Stop(); RTC_DCHECK(ready_to_send_); - SchedulePeriodicCompoundPackets(config_.report_period_ms); + SchedulePeriodicCompoundPackets(config_.report_period); } -void RtcpTransceiverImpl::SchedulePeriodicCompoundPackets(int64_t delay_ms) { - periodic_task_handle_ = RepeatingTaskHandle::DelayedStart( - config_.task_queue, TimeDelta::Millis(delay_ms), [this] { +void RtcpTransceiverImpl::SchedulePeriodicCompoundPackets(TimeDelta delay) { + periodic_task_handle_ = + RepeatingTaskHandle::DelayedStart(config_.task_queue, delay, [this] { RTC_DCHECK(config_.schedule_periodic_compound_packets); RTC_DCHECK(ready_to_send_); SendPeriodicCompoundPacket(); - return TimeDelta::Millis(config_.report_period_ms); + return config_.report_period; }); } diff --git a/modules/rtp_rtcp/source/rtcp_transceiver_impl.h b/modules/rtp_rtcp/source/rtcp_transceiver_impl.h index 8dc50b89e6..be9a98188e 100644 --- a/modules/rtp_rtcp/source/rtcp_transceiver_impl.h +++ b/modules/rtp_rtcp/source/rtcp_transceiver_impl.h @@ -116,7 +116,7 @@ class RtcpTransceiverImpl { rtc::ArrayView report_blocks); void ReschedulePeriodicCompoundPackets(); - void SchedulePeriodicCompoundPackets(int64_t delay_ms); + void SchedulePeriodicCompoundPackets(TimeDelta delay); // Appends RTCP sender and receiver reports to the `sender`. // Both sender and receiver reports may have attached report blocks. // Uses up to `config_.max_packet_size - reserved_bytes` diff --git a/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc b/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc index 82bfadecef..744b4eb6a2 100644 --- a/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc @@ -111,7 +111,7 @@ class MockNetworkLinkRtcpObserver : public NetworkLinkRtcpObserver { // Since some tests will need to wait for this period, make it small to avoid // slowing tests too much. As long as there are test bots with high scheduler // granularity, small period should be ok. -constexpr int kReportPeriodMs = 10; +constexpr TimeDelta kReportPeriod = TimeDelta::Millis(10); // On some systems task queue might be slow, instead of guessing right // grace period, use very large timeout, 100x larger expected wait time. // Use finite timeout to fail tests rather than hang them. @@ -176,8 +176,8 @@ RtcpTransceiverConfig DefaultTestConfig() { config.clock = &null_clock; config.outgoing_transport = &null_transport; config.schedule_periodic_compound_packets = false; - config.initial_report_delay_ms = 10; - config.report_period_ms = kReportPeriodMs; + config.initial_report_delay = TimeDelta::Millis(10); + config.report_period = kReportPeriod; return config; } @@ -246,7 +246,7 @@ TEST(RtcpTransceiverImplTest, DelaysSendingFirstCompondPacket) { RtcpTransceiverConfig config; config.clock = &clock; config.outgoing_transport = &transport; - config.initial_report_delay_ms = 10; + config.initial_report_delay = TimeDelta::Millis(10); config.task_queue = queue.Get(); absl::optional rtcp_transceiver; @@ -254,7 +254,7 @@ TEST(RtcpTransceiverImplTest, DelaysSendingFirstCompondPacket) { queue.PostTask([&] { rtcp_transceiver.emplace(config); }); EXPECT_TRUE(transport.WaitPacket()); - EXPECT_GE(rtc::TimeMillis() - started_ms, config.initial_report_delay_ms); + EXPECT_GE(rtc::TimeMillis() - started_ms, config.initial_report_delay.ms()); // Cleanup. rtc::Event done; @@ -273,8 +273,8 @@ TEST(RtcpTransceiverImplTest, PeriodicallySendsPackets) { RtcpTransceiverConfig config; config.clock = &clock; config.outgoing_transport = &transport; - config.initial_report_delay_ms = 0; - config.report_period_ms = kReportPeriodMs; + config.initial_report_delay = TimeDelta::Zero(); + config.report_period = kReportPeriod; config.task_queue = queue.Get(); absl::optional rtcp_transceiver; int64_t time_just_before_1st_packet_ms = 0; @@ -290,7 +290,7 @@ TEST(RtcpTransceiverImplTest, PeriodicallySendsPackets) { int64_t time_just_after_2nd_packet_ms = rtc::TimeMillis(); EXPECT_GE(time_just_after_2nd_packet_ms - time_just_before_1st_packet_ms, - config.report_period_ms - 1); + config.report_period.ms() - 1); // Cleanup. rtc::Event done; @@ -309,8 +309,8 @@ TEST(RtcpTransceiverImplTest, SendCompoundPacketDelaysPeriodicSendPackets) { RtcpTransceiverConfig config; config.clock = &clock; config.outgoing_transport = &transport; - config.initial_report_delay_ms = 0; - config.report_period_ms = kReportPeriodMs; + config.initial_report_delay = TimeDelta::Zero(); + config.report_period = kReportPeriod; config.task_queue = queue.Get(); absl::optional rtcp_transceiver; queue.PostTask([&] { rtcp_transceiver.emplace(config); }); @@ -326,7 +326,7 @@ TEST(RtcpTransceiverImplTest, SendCompoundPacketDelaysPeriodicSendPackets) { rtcp_transceiver->SendCompoundPacket(); non_periodic.Set(); }, - config.report_period_ms / 2); + (config.report_period / 2).ms()); // Though non-periodic packet is scheduled just in between periodic, due to // small period and task queue flakiness it migth end-up 1ms after next // periodic packet. To be sure duration after non-periodic packet is tested @@ -338,7 +338,7 @@ TEST(RtcpTransceiverImplTest, SendCompoundPacketDelaysPeriodicSendPackets) { int64_t time_of_last_periodic_packet_ms = rtc::TimeMillis(); EXPECT_GE(time_of_last_periodic_packet_ms - time_of_non_periodic_packet_ms, - config.report_period_ms - 1); + config.report_period.ms() - 1); // Cleanup. rtc::Event done; From 5a5a775a88e9e417e3f6e4084f80642475045b19 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Mon, 28 Feb 2022 08:02:24 -0800 Subject: [PATCH 069/847] Roll chromium_revision 45ec87b29f..49eada12dd (975667:975776) Change log: https://chromium.googlesource.com/chromium/src/+log/45ec87b29f..49eada12dd Full diff: https://chromium.googlesource.com/chromium/src/+/45ec87b29f..49eada12dd Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/402f200100..e15c62baac * src/build: https://chromium.googlesource.com/chromium/src/build/+log/3651f40a5d..08f54b6250 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/9f0a2dddd9..6e5f66b2b7 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/8bf5b5b5e9..f6930e6ad1 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/16c2bd0c52..fbde1dab6d * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/5b5f79bbdb..5bc4f42913 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/d82d1d5395..087435a449 DEPS diff: https://chromium.googlesource.com/chromium/src/+/45ec87b29f..49eada12dd/DEPS No update to Clang. BUG=None Change-Id: I62dbe86d0f3579d2ba94cf85e812e665d1af04ab Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253001 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36095} --- DEPS | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/DEPS b/DEPS index 9d3e3c008c..1b0ae68f5b 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': '45ec87b29fb536932d3c26d6cf236128a872a14b', + 'chromium_revision': '49eada12dd53a0d40b9cd90c8c9e2a308abe4964', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@402f2001000a6c4f3106b89e549f4066d315e5c0', + 'https://chromium.googlesource.com/chromium/src/base@e15c62baacbde34e85b9466555aa84e7bcbfed09', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@3651f40a5dd644c7f853a1e41ba6871e0bcf4fb5', + 'https://chromium.googlesource.com/chromium/src/build@08f54b625068aad62ef4362bbc6e4ea77237d08d', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@893aa038dd17d05f3c5ff5af98daebabc294a948', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@9f0a2dddd9b1c282bb9ebd79f40e42bf0eb349f4', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@6e5f66b2b761772f7e1d8cbae62eee81ff6900a2', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@8bf5b5b5e992d3734d89e29421aec1e177c13af7', + 'https://chromium.googlesource.com/chromium/src/testing@f6930e6ad1dc51e441333d5e82b0f8ef4ef3423d', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@16c2bd0c5228c45b9dd6691257ac8a0a3bf30be5', + 'https://chromium.googlesource.com/chromium/src/third_party@fbde1dab6dc0d4e7fb4a677d95976374bb7066ac', 'src/buildtools/linux64': { 'packages': [ @@ -228,7 +228,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@5b5f79bbdb2a2d59c88f02394cac1b08298a3da7', + 'https://android.googlesource.com/platform/external/perfetto.git@5bc4f42913ff638c5471e46ffb6cfcfb89bf71aa', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@d82d1d5395429329981926389acec572d6e86ebf', + 'https://chromium.googlesource.com/chromium/src/tools@087435a4490c2e799b741ee558ee6413e7a6a18d', 'src/third_party/accessibility_test_framework': { 'packages': [ From 141007668cf12f06c6fc4d49706ab87ddc9e82a0 Mon Sep 17 00:00:00 2001 From: Per Kjellander Date: Thu, 24 Feb 2022 17:10:30 +0100 Subject: [PATCH 070/847] Add field trial for limiting probes and delay based estimates to link capacity. Allow delay based estimate to increase up to 85% of the current NetworkStateEstimate even if in ALR. The estimate may not increase higher than that. WebRTC-Bwe-EstimateBoundedIncrease/ratio:0.85,ignore_acked:true Bug: none Change-Id: I6f34af7fab03082ca168e624ddea06f216790fbc Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252442 Reviewed-by: Stefan Holmer Commit-Queue: Per Kjellander Cr-Commit-Position: refs/heads/main@{#36096} --- .../aimd_rate_control.cc | 52 ++++++++------ .../aimd_rate_control.h | 9 ++- .../aimd_rate_control_unittest.cc | 68 +++++++++++++++++++ 3 files changed, 105 insertions(+), 24 deletions(-) diff --git a/modules/remote_bitrate_estimator/aimd_rate_control.cc b/modules/remote_bitrate_estimator/aimd_rate_control.cc index a3da2b5f2d..bf1d431879 100644 --- a/modules/remote_bitrate_estimator/aimd_rate_control.cc +++ b/modules/remote_bitrate_estimator/aimd_rate_control.cc @@ -95,11 +95,12 @@ AimdRateControl::AimdRateControl(const WebRtcKeyValueConfig* key_value_config, estimate_bounded_backoff_( IsNotDisabled(*key_value_config, "WebRTC-Bwe-EstimateBoundedBackoff")), - estimate_bounded_increase_( - IsNotDisabled(*key_value_config, - "WebRTC-Bwe-EstimateBoundedIncrease")), initial_backoff_interval_("initial_backoff_interval"), link_capacity_fix_("link_capacity_fix") { + ParseFieldTrial( + {&disable_estimate_bounded_increase_, &estimate_bounded_increase_ratio_, + &ignore_throughput_limit_if_network_estimate_}, + key_value_config->Lookup("WebRTC-Bwe-EstimateBoundedIncrease")); // E.g // WebRTC-BweAimdRateControlConfig/initial_backoff_interval:100ms/ ParseFieldTrial({&initial_backoff_interval_, &link_capacity_fix_}, @@ -272,27 +273,34 @@ void AimdRateControl::ChangeBitrate(const RateControlInput& input, ChangeState(input, at_time); - // We limit the new bitrate based on the troughput to avoid unlimited bitrate - // increases. We allow a bit more lag at very low rates to not too easily get - // stuck if the encoder produces uneven outputs. - const DataRate troughput_based_limit = - 1.5 * estimated_throughput + DataRate::KilobitsPerSec(10); - switch (rate_control_state_) { case RateControlState::kRcHold: break; - case RateControlState::kRcIncrease: + case RateControlState::kRcIncrease: { if (estimated_throughput > link_capacity_.UpperBound()) link_capacity_.Reset(); - // Do not increase the delay based estimate in alr since the estimator - // will not be able to get transport feedback necessary to detect if - // the new estimate is correct. - // If we have previously increased above the limit (for instance due to - // probing), we don't allow further changes. - if (current_bitrate_ < troughput_based_limit && - !(send_side_ && in_alr_ && no_bitrate_increase_in_alr_)) { + // We limit the new bitrate based on the troughput to avoid unlimited + // bitrate increases. We allow a bit more lag at very low rates to not too + // easily get stuck if the encoder produces uneven outputs. + DataRate increase_limit = + 1.5 * estimated_throughput + DataRate::KilobitsPerSec(10); + if (ignore_throughput_limit_if_network_estimate_ && network_estimate_ && + network_estimate_->link_capacity_upper.IsFinite()) { + // If we have a Network estimate, we do allow the estimate to increase. + increase_limit = network_estimate_->link_capacity_upper * + estimate_bounded_increase_ratio_.Get(); + } else if (send_side_ && in_alr_ && no_bitrate_increase_in_alr_) { + // Do not increase the delay based estimate in alr since the estimator + // will not be able to get transport feedback necessary to detect if + // the new estimate is correct. + // If we have previously increased above the limit (for instance due to + // probing), we don't allow further changes. + increase_limit = current_bitrate_; + } + + if (current_bitrate_ < increase_limit) { DataRate increased_bitrate = DataRate::MinusInfinity(); if (link_capacity_.has_estimate()) { // The link_capacity estimate is reset if the measured throughput @@ -309,11 +317,11 @@ void AimdRateControl::ChangeBitrate(const RateControlInput& input, at_time, time_last_bitrate_change_, current_bitrate_); increased_bitrate = current_bitrate_ + multiplicative_increase; } - new_bitrate = std::min(increased_bitrate, troughput_based_limit); + new_bitrate = std::min(increased_bitrate, increase_limit); } - time_last_bitrate_change_ = at_time; break; + } case RateControlState::kRcDecrease: { DataRate decreased_bitrate = DataRate::PlusInfinity(); @@ -368,8 +376,10 @@ void AimdRateControl::ChangeBitrate(const RateControlInput& input, } DataRate AimdRateControl::ClampBitrate(DataRate new_bitrate) const { - if (estimate_bounded_increase_ && network_estimate_) { - DataRate upper_bound = network_estimate_->link_capacity_upper; + if (!disable_estimate_bounded_increase_ && network_estimate_ && + network_estimate_->link_capacity_upper.IsFinite()) { + DataRate upper_bound = network_estimate_->link_capacity_upper * + estimate_bounded_increase_ratio_.Get(); new_bitrate = std::min(new_bitrate, upper_bound); } new_bitrate = std::max(new_bitrate, min_configured_bitrate_); diff --git a/modules/remote_bitrate_estimator/aimd_rate_control.h b/modules/remote_bitrate_estimator/aimd_rate_control.h index 3e0d541b60..12dec32b4d 100644 --- a/modules/remote_bitrate_estimator/aimd_rate_control.h +++ b/modules/remote_bitrate_estimator/aimd_rate_control.h @@ -107,9 +107,12 @@ class AimdRateControl { // Use estimated link capacity lower bound if it is higher than the // acknowledged rate when backing off due to overuse. const bool estimate_bounded_backoff_; - // Use estimated link capacity upper bound as upper limit for increasing - // bitrate over the acknowledged rate. - const bool estimate_bounded_increase_; + // If false, uses estimated link capacity upper bound * + // `estimate_bounded_increase_ratio_` as upper limit for the estimate. + FieldTrialFlag disable_estimate_bounded_increase_{"Disabled"}; + FieldTrialParameter estimate_bounded_increase_ratio_{"ratio", 1.0}; + FieldTrialParameter ignore_throughput_limit_if_network_estimate_{ + "ignore_acked", false}; absl::optional last_decrease_; FieldTrialOptional initial_backoff_interval_; FieldTrialFlag link_capacity_fix_; diff --git a/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc b/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc index 6cbccf6b7b..34aafb4f91 100644 --- a/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc +++ b/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc @@ -274,4 +274,72 @@ TEST(AimdRateControlTest, EstimateIncreaseWhileNotInAlr) { kInitialBitrateBps); } +TEST(AimdRateControlTest, EstimateNotLimitedByNetworkEstimateIfDisabled) { + test::ScopedFieldTrials override_field_trials( + "WebRTC-Bwe-EstimateBoundedIncrease/Disabled/"); + auto states = CreateAimdRateControlStates(/*send_side=*/true); + constexpr int kInitialBitrateBps = 123000; + SetEstimate(states, kInitialBitrateBps); + states.aimd_rate_control->SetInApplicationLimitedRegion(false); + NetworkStateEstimate network_estimate; + network_estimate.link_capacity_upper = DataRate::KilobitsPerSec(150); + states.aimd_rate_control->SetNetworkStateEstimate(network_estimate); + + for (int i = 0; i < 100; ++i) { + UpdateRateControl(states, BandwidthUsage::kBwNormal, absl::nullopt, + states.simulated_clock->TimeInMilliseconds()); + states.simulated_clock->AdvanceTimeMilliseconds(100); + } + EXPECT_GT(states.aimd_rate_control->LatestEstimate(), + network_estimate.link_capacity_upper); +} + +TEST(AimdRateControlTest, EstimateLimitedByNetworkEstimateInAlrIfSet) { + // Even if alr is detected, the delay based estimator is allowed to increase + // up to a percentage of upper link capacity. + test::ScopedFieldTrials override_field_trials( + "WebRTC-Bwe-EstimateBoundedIncrease/ratio:0.85,ignore_acked:true/" + "WebRTC-DontIncreaseDelayBasedBweInAlr/Enabled/"); + auto states = CreateAimdRateControlStates(/*send_side=*/true); + constexpr int kInitialBitrateBps = 123000; + SetEstimate(states, kInitialBitrateBps); + states.aimd_rate_control->SetInApplicationLimitedRegion(true); + + NetworkStateEstimate network_estimate; + network_estimate.link_capacity_upper = DataRate::KilobitsPerSec(200); + states.aimd_rate_control->SetNetworkStateEstimate(network_estimate); + for (int i = 0; i < 100; ++i) { + UpdateRateControl(states, BandwidthUsage::kBwNormal, absl::nullopt, + states.simulated_clock->TimeInMilliseconds()); + states.simulated_clock->AdvanceTimeMilliseconds(100); + } + EXPECT_EQ(states.aimd_rate_control->LatestEstimate(), + network_estimate.link_capacity_upper * 0.85); +} + +TEST(AimdRateControlTest, EstimateDoesNotIncreaseInAlrIfNetworkEstimateNotSet) { + // 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. + test::ScopedFieldTrials override_field_trials( + "WebRTC-Bwe-EstimateBoundedIncrease/ratio:0.85,ignore_acked:true/" + "WebRTC-DontIncreaseDelayBasedBweInAlr/Enabled/"); + auto states = CreateAimdRateControlStates(/*send_side=*/true); + constexpr int kInitialBitrateBps = 123000; + SetEstimate(states, kInitialBitrateBps); + states.aimd_rate_control->SetInApplicationLimitedRegion(true); + UpdateRateControl(states, BandwidthUsage::kBwNormal, kInitialBitrateBps, + states.simulated_clock->TimeInMilliseconds()); + ASSERT_EQ(states.aimd_rate_control->LatestEstimate().bps(), + kInitialBitrateBps); + + for (int i = 0; i < 100; ++i) { + UpdateRateControl(states, BandwidthUsage::kBwNormal, absl::nullopt, + states.simulated_clock->TimeInMilliseconds()); + states.simulated_clock->AdvanceTimeMilliseconds(100); + } + EXPECT_EQ(states.aimd_rate_control->LatestEstimate().bps(), + kInitialBitrateBps); +} + } // namespace webrtc From 07e021c780c1600faaf5945e05bd1f91075a7fb3 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Mon, 28 Feb 2022 14:01:44 -0800 Subject: [PATCH 071/847] Roll chromium_revision 49eada12dd..e7e24761b3 (975776:975961) Change log: https://chromium.googlesource.com/chromium/src/+log/49eada12dd..e7e24761b3 Full diff: https://chromium.googlesource.com/chromium/src/+/49eada12dd..e7e24761b3 Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/e15c62baac..8b8ac0f913 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/08f54b6250..23792fc6dd * src/buildtools/linux64: git_revision:0725d7827575b239594fbc8fd5192873a1d62f44..git_revision:e3f114f46537152cfbdb553015518d1db1b812fd * src/buildtools/mac: git_revision:0725d7827575b239594fbc8fd5192873a1d62f44..git_revision:e3f114f46537152cfbdb553015518d1db1b812fd * src/buildtools/win: git_revision:0725d7827575b239594fbc8fd5192873a1d62f44..git_revision:e3f114f46537152cfbdb553015518d1db1b812fd * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/6e5f66b2b7..3857cf82d1 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/f6930e6ad1..a19dd7d755 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/fbde1dab6d..87a4c1f6ca * src/third_party/dav1d/libdav1d: https://chromium.googlesource.com/external/github.com/videolan/dav1d.git/+log/cce2b0564d..b010080fea * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/6b28c1ddef..c9a747c5ed * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/5bc4f42913..134b9ef223 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/087435a449..c1d5031d2a DEPS diff: https://chromium.googlesource.com/chromium/src/+/49eada12dd..e7e24761b3/DEPS No update to Clang. BUG=None Change-Id: Icf0d1686c405a73fa0eeae9139f757d239fd4917 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253060 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36097} --- DEPS | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/DEPS b/DEPS index 1b0ae68f5b..f79ab23177 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': '49eada12dd53a0d40b9cd90c8c9e2a308abe4964', + 'chromium_revision': 'e7e24761b37a7f09c1e52ecacb936153f1d3db85', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@e15c62baacbde34e85b9466555aa84e7bcbfed09', + 'https://chromium.googlesource.com/chromium/src/base@8b8ac0f91306077f0c3d0936ab4d288de9b1795c', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@08f54b625068aad62ef4362bbc6e4ea77237d08d', + 'https://chromium.googlesource.com/chromium/src/build@23792fc6ddda5d51f92b8b545822fa351c8d8e97', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@893aa038dd17d05f3c5ff5af98daebabc294a948', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,19 +34,19 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@6e5f66b2b761772f7e1d8cbae62eee81ff6900a2', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@3857cf82d1bae197e2f46fcdb69da3c868d39b93', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@f6930e6ad1dc51e441333d5e82b0f8ef4ef3423d', + 'https://chromium.googlesource.com/chromium/src/testing@a19dd7d755aa34a8a9d5a30cfa051f97b05af27f', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@fbde1dab6dc0d4e7fb4a677d95976374bb7066ac', + 'https://chromium.googlesource.com/chromium/src/third_party@87a4c1f6ca358ea7c77e77dbacb7a3e076645b7c', 'src/buildtools/linux64': { 'packages': [ { 'package': 'gn/gn/linux-amd64', - 'version': 'git_revision:0725d7827575b239594fbc8fd5192873a1d62f44', + 'version': 'git_revision:e3f114f46537152cfbdb553015518d1db1b812fd', } ], 'dep_type': 'cipd', @@ -56,7 +56,7 @@ deps = { 'packages': [ { 'package': 'gn/gn/mac-${{arch}}', - 'version': 'git_revision:0725d7827575b239594fbc8fd5192873a1d62f44', + 'version': 'git_revision:e3f114f46537152cfbdb553015518d1db1b812fd', } ], 'dep_type': 'cipd', @@ -66,7 +66,7 @@ deps = { 'packages': [ { 'package': 'gn/gn/windows-amd64', - 'version': 'git_revision:0725d7827575b239594fbc8fd5192873a1d62f44', + 'version': 'git_revision:e3f114f46537152cfbdb553015518d1db1b812fd', } ], 'dep_type': 'cipd', @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@6b28c1ddef177b44521ab5e8c438942c397a56d8', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@c9a747c5ed646001df33e798c62bbac0d27c8d08', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -220,7 +220,7 @@ deps = { 'src/third_party/libsrtp': 'https://chromium.googlesource.com/chromium/deps/libsrtp.git@5b7c744eb8310250ccc534f3f86a2015b3887a0a', 'src/third_party/dav1d/libdav1d': - 'https://chromium.googlesource.com/external/github.com/videolan/dav1d.git@cce2b0564d3b0aa1a5e4ec0c561b6a1b8497cebb', + 'https://chromium.googlesource.com/external/github.com/videolan/dav1d.git@b010080fea75435327fc90824bb4d8035722b3cb', 'src/third_party/libaom/source/libaom': 'https://aomedia.googlesource.com/aom.git@a08d3f6c329a25744712578a70715e5cfd749759', 'src/third_party/libunwindstack': { @@ -228,7 +228,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@5bc4f42913ff638c5471e46ffb6cfcfb89bf71aa', + 'https://android.googlesource.com/platform/external/perfetto.git@134b9ef223989bd7ceaa32de04a6a10ed3946ec5', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@087435a4490c2e799b741ee558ee6413e7a6a18d', + 'https://chromium.googlesource.com/chromium/src/tools@c1d5031d2ae59afa5f9abb0d1c70a809adc7145b', 'src/third_party/accessibility_test_framework': { 'packages': [ From 7601fd7677dde711736794bb4b927777f55bc4be Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Mon, 28 Feb 2022 20:08:07 -0800 Subject: [PATCH 072/847] Roll chromium_revision e7e24761b3..cfa2b8c65a (975961:976087) Change log: https://chromium.googlesource.com/chromium/src/+log/e7e24761b3..cfa2b8c65a Full diff: https://chromium.googlesource.com/chromium/src/+/e7e24761b3..cfa2b8c65a Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/8b8ac0f913..78ef4ca402 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/23792fc6dd..15cbd56453 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/3857cf82d1..8215caa039 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/a19dd7d755..14ff931d6b * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/87a4c1f6ca..2ded82c42c * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/666eff907b..2cfdaa8ce0 * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/c9a747c5ed..ca9706d139 * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/134b9ef223..54ba566cdd * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/c1d5031d2a..71ce93cbdb * src/tools/luci-go: git_revision:582e828c5a8aaf5cdd0ad1d5465fb9092b71eab8..git_revision:a1616e207f0d9c24beefe848ee899b7a73efcb70 * src/tools/luci-go: git_revision:582e828c5a8aaf5cdd0ad1d5465fb9092b71eab8..git_revision:a1616e207f0d9c24beefe848ee899b7a73efcb70 DEPS diff: https://chromium.googlesource.com/chromium/src/+/e7e24761b3..cfa2b8c65a/DEPS No update to Clang. BUG=None Change-Id: If0fec2da524c26f51a3a1f9ce298305346591ae9 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253082 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36098} --- DEPS | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/DEPS b/DEPS index f79ab23177..fb6ca64a0a 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': 'e7e24761b37a7f09c1e52ecacb936153f1d3db85', + 'chromium_revision': 'cfa2b8c65afd1d0474da0c84d4df8c61ca1d70f9', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@8b8ac0f91306077f0c3d0936ab4d288de9b1795c', + 'https://chromium.googlesource.com/chromium/src/base@78ef4ca4024482be44b68953d360c4e7f79eed6f', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@23792fc6ddda5d51f92b8b545822fa351c8d8e97', + 'https://chromium.googlesource.com/chromium/src/build@15cbd564537d55ed78d13f4c629fb83cf52773dd', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@893aa038dd17d05f3c5ff5af98daebabc294a948', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@3857cf82d1bae197e2f46fcdb69da3c868d39b93', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@8215caa03922de192f4f9b022c8a0b800678fe96', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@a19dd7d755aa34a8a9d5a30cfa051f97b05af27f', + 'https://chromium.googlesource.com/chromium/src/testing@14ff931d6bb2d8bcb3306394f5285f1883942396', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@87a4c1f6ca358ea7c77e77dbacb7a3e076645b7c', + 'https://chromium.googlesource.com/chromium/src/third_party@2ded82c42c3ed8d41e7e794e5ebdf86a0c165697', 'src/buildtools/linux64': { 'packages': [ @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@666eff907b58ca7b4c82c0fae4c6e1d24f223ea0', + 'https://chromium.googlesource.com/catapult.git@2cfdaa8ce0e0c959b01c0280a93be107788b7d24', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@c9a747c5ed646001df33e798c62bbac0d27c8d08', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@ca9706d13903f1efabb4ce6ea04d6f8340fb88c5', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -228,7 +228,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@134b9ef223989bd7ceaa32de04a6a10ed3946ec5', + 'https://android.googlesource.com/platform/external/perfetto.git@54ba566cdda23803c888afe5b664005be30d06e0', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@c1d5031d2ae59afa5f9abb0d1c70a809adc7145b', + 'https://chromium.googlesource.com/chromium/src/tools@71ce93cbdb8b093482ec1c1f2538b62301cbc8f9', 'src/third_party/accessibility_test_framework': { 'packages': [ @@ -489,11 +489,11 @@ deps = { 'packages': [ { 'package': 'infra/tools/luci/isolate/${{platform}}', - 'version': 'git_revision:582e828c5a8aaf5cdd0ad1d5465fb9092b71eab8', + 'version': 'git_revision:a1616e207f0d9c24beefe848ee899b7a73efcb70', }, { 'package': 'infra/tools/luci/swarming/${{platform}}', - 'version': 'git_revision:582e828c5a8aaf5cdd0ad1d5465fb9092b71eab8', + 'version': 'git_revision:a1616e207f0d9c24beefe848ee899b7a73efcb70', }, ], 'dep_type': 'cipd', From c6d3a7a69148ddb5a54f41265deaff84d4801b8d Mon Sep 17 00:00:00 2001 From: Per Kjellander Date: Thu, 24 Feb 2022 17:32:12 +0100 Subject: [PATCH 073/847] Ensure returned delay based estimate from probe can be clamped by AimdRateControl AimdRateControl can potentially clamp bitrate in SetEstimate. DelayBasedBwe::MaybeUpdateEstimate should therefore check the result before using the probe bitrate. Otherwise, BWE may drop on next update. Bug: none Change-Id: I8b1b3549a2bcd981e941b1cc802c984828d68261 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252444 Reviewed-by: Stefan Holmer Commit-Queue: Per Kjellander Cr-Commit-Position: refs/heads/main@{#36099} --- modules/congestion_controller/goog_cc/delay_based_bwe.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/congestion_controller/goog_cc/delay_based_bwe.cc b/modules/congestion_controller/goog_cc/delay_based_bwe.cc index 2ae5441ef4..01dfbc44e4 100644 --- a/modules/congestion_controller/goog_cc/delay_based_bwe.cc +++ b/modules/congestion_controller/goog_cc/delay_based_bwe.cc @@ -243,8 +243,8 @@ DelayBasedBwe::Result DelayBasedBwe::MaybeUpdateEstimate( if (probe_bitrate) { result.probe = true; result.updated = true; - result.target_bitrate = *probe_bitrate; rate_control_.SetEstimate(*probe_bitrate, at_time); + result.target_bitrate = rate_control_.LatestEstimate(); } else { result.updated = UpdateEstimate(at_time, acked_bitrate, &result.target_bitrate); From d4ff12f219369ac56ea7d6b7cdb81750b5bbd795 Mon Sep 17 00:00:00 2001 From: Evan Shrubsole Date: Tue, 1 Mar 2022 10:16:11 +0100 Subject: [PATCH 074/847] Increment frame count once for duplicate frame with FrameBuffer3 R=philipel@webrtc.org Change-Id: I9a961417f86fd1f968a42730249d479e3ebd4784 Bug: webrtc:13343, webrtc:13755 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252583 Reviewed-by: Ilya Nikolaevskiy Reviewed-by: Philip Eliasson Commit-Queue: Evan Shrubsole Cr-Commit-Position: refs/heads/main@{#36100} --- video/BUILD.gn | 1 + video/frame_buffer_proxy.cc | 40 ++++++++++++++--- video/frame_buffer_proxy_unittest.cc | 67 +++++++++++++++++++++++++++- 3 files changed, 99 insertions(+), 9 deletions(-) diff --git a/video/BUILD.gn b/video/BUILD.gn index caa4f6d8dc..e8f7417b08 100644 --- a/video/BUILD.gn +++ b/video/BUILD.gn @@ -309,6 +309,7 @@ rtc_library("frame_buffer_proxy") { "../api/metronome", "../api/task_queue", "../api/video:encoded_frame", + "../api/video:video_rtp_headers", "../modules/video_coding", "../modules/video_coding:frame_buffer", "../modules/video_coding:frame_helpers", diff --git a/video/frame_buffer_proxy.cc b/video/frame_buffer_proxy.cc index a2e5406ece..31aa86f7ab 100644 --- a/video/frame_buffer_proxy.cc +++ b/video/frame_buffer_proxy.cc @@ -17,6 +17,8 @@ #include "absl/base/attributes.h" #include "absl/functional/bind_front.h" #include "api/sequence_checker.h" +#include "api/video/encoded_frame.h" +#include "api/video/video_content_type.h" #include "modules/video_coding/frame_buffer2.h" #include "modules/video_coding/frame_buffer3.h" #include "modules/video_coding/frame_helpers.h" @@ -138,6 +140,25 @@ static constexpr int kMaxFramesHistory = 1 << 13; // low-latency renderer is used. static constexpr size_t kZeroPlayoutDelayDefaultMaxDecodeQueueSize = 8; +struct FrameMetadata { + explicit FrameMetadata(const EncodedFrame& frame) + : is_last_spatial_layer(frame.is_last_spatial_layer), + is_keyframe(frame.is_keyframe()), + size(frame.size()), + contentType(frame.contentType()), + delayed_by_retransmission(frame.delayed_by_retransmission()), + rtp_timestamp(frame.Timestamp()), + receive_time(frame.ReceivedTime()) {} + + const bool is_last_spatial_layer; + const bool is_keyframe; + const size_t size; + const VideoContentType contentType; + const bool delayed_by_retransmission; + const uint32_t rtp_timestamp; + const int64_t receive_time; +}; + // Encapsulates use of the new frame buffer for use in VideoReceiveStream. This // behaves the same as the FrameBuffer2Proxy but uses frame_buffer3 instead. // Responsibilities from frame_buffer2, like stats, jitter and frame timing @@ -218,14 +239,19 @@ class FrameBuffer3Proxy : public FrameBufferProxy { absl::optional InsertFrame( std::unique_ptr frame) override { RTC_DCHECK_RUN_ON(&worker_sequence_checker_); - if (frame->is_last_spatial_layer) - stats_proxy_->OnCompleteFrame(frame->is_keyframe(), frame->size(), - frame->contentType()); - if (!frame->delayed_by_retransmission()) - timing_->IncomingTimestamp(frame->Timestamp(), frame->ReceivedTime()); - + FrameMetadata metadata(*frame); + int complete_units = buffer_->GetTotalNumberOfContinuousTemporalUnits(); buffer_->InsertFrame(std::move(frame)); - MaybeScheduleFrameForRelease(); + // Don't update stats or frame timing if the inserted frame did not complete + // a new temporal layer. + if (complete_units < buffer_->GetTotalNumberOfContinuousTemporalUnits()) { + stats_proxy_->OnCompleteFrame(metadata.is_keyframe, metadata.size, + metadata.contentType); + if (!metadata.delayed_by_retransmission) + timing_->IncomingTimestamp(metadata.rtp_timestamp, + metadata.receive_time); + MaybeScheduleFrameForRelease(); + } return buffer_->LastContinuousFrameId(); } diff --git a/video/frame_buffer_proxy_unittest.cc b/video/frame_buffer_proxy_unittest.cc index 073d30b5de..81e5bd2ffd 100644 --- a/video/frame_buffer_proxy_unittest.cc +++ b/video/frame_buffer_proxy_unittest.cc @@ -198,6 +198,12 @@ class VCMReceiveStatisticsCallbackMock : public VCMReceiveStatisticsCallback { (const TimingFrameInfo& info), (override)); }; + +bool IsFrameBuffer2Enabled() { + return field_trial::FindFullName("WebRTC-FrameBuffer3") + .find("arm:FrameBuffer2") != std::string::npos; +} + } // namespace constexpr auto kMaxWaitForKeyframe = TimeDelta::Millis(500); @@ -635,6 +641,64 @@ TEST_P(FrameBufferProxyTest, TestStatsCallback) { time_controller_.AdvanceTime(TimeDelta::Zero()); } +TEST_P(FrameBufferProxyTest, FrameCompleteCalledOnceForDuplicateFrame) { + EXPECT_CALL(stats_callback_, + OnCompleteFrame(true, kFrameSize, VideoContentType::UNSPECIFIED)) + .Times(1); + + StartNextDecodeForceKeyframe(); + proxy_->InsertFrame(Builder().Id(0).Time(0).AsLast().Build()); + proxy_->InsertFrame(Builder().Id(0).Time(0).AsLast().Build()); + // Flush stats posted on the decode queue. + time_controller_.AdvanceTime(TimeDelta::Zero()); +} + +TEST_P(FrameBufferProxyTest, FrameCompleteCalledOnceForSingleTemporalUnit) { + StartNextDecodeForceKeyframe(); + + // `OnCompleteFrame` should not be called for the first two frames since they + // do not complete the temporal layer. + EXPECT_CALL(stats_callback_, OnCompleteFrame(_, _, _)).Times(0); + proxy_->InsertFrame(Builder().Id(0).Time(0).Build()); + proxy_->InsertFrame(Builder().Id(1).Time(0).Refs({0}).Build()); + time_controller_.AdvanceTime(TimeDelta::Zero()); + // Flush stats posted on the decode queue. + ::testing::Mock::VerifyAndClearExpectations(&stats_callback_); + + // Note that this frame is not marked as a keyframe since the last spatial + // layer has dependencies. + EXPECT_CALL(stats_callback_, + OnCompleteFrame(false, kFrameSize, VideoContentType::UNSPECIFIED)) + .Times(1); + proxy_->InsertFrame(Builder().Id(2).Time(0).Refs({0, 1}).AsLast().Build()); + // Flush stats posted on the decode queue. + time_controller_.AdvanceTime(TimeDelta::Zero()); +} + +TEST_P(FrameBufferProxyTest, FrameCompleteCalledOnceForCompleteTemporalUnit) { + // FrameBuffer2 logs the complete frame on the arrival of the last layer. + if (IsFrameBuffer2Enabled()) + return; + StartNextDecodeForceKeyframe(); + + // `OnCompleteFrame` should not be called for the first two frames since they + // do not complete the temporal layer. Frame 1 arrives later, at which time + // this frame can finally be considered complete. + EXPECT_CALL(stats_callback_, OnCompleteFrame(_, _, _)).Times(0); + proxy_->InsertFrame(Builder().Id(0).Time(0).Build()); + proxy_->InsertFrame(Builder().Id(2).Time(0).Refs({0, 1}).AsLast().Build()); + time_controller_.AdvanceTime(TimeDelta::Zero()); + // Flush stats posted on the decode queue. + ::testing::Mock::VerifyAndClearExpectations(&stats_callback_); + + EXPECT_CALL(stats_callback_, + OnCompleteFrame(false, kFrameSize, VideoContentType::UNSPECIFIED)) + .Times(1); + proxy_->InsertFrame(Builder().Id(1).Time(0).Refs({0}).Build()); + // Flush stats posted on the decode queue. + time_controller_.AdvanceTime(TimeDelta::Zero()); +} + // Note: This test takes a long time to run if the fake metronome is active. // Since the test needs to wait for the timestamp to rollover, it has a fake // delay of around 6.5 hours. Even though time is simulated, this will be @@ -690,8 +754,7 @@ TEST_P(FrameBufferProxyTest, NextFrameWithOldTimestamp) { .AsLast() .Build()); // FrameBuffer2 drops the frame, while FrameBuffer3 will continue the stream. - if (field_trial::FindFullName("WebRTC-FrameBuffer3") - .find("arm:FrameBuffer2") == std::string::npos) { + if (!IsFrameBuffer2Enabled()) { EXPECT_THAT(WaitForFrameOrTimeout(kFps30Delay), Frame(WithId(2))); } else { EXPECT_THAT(WaitForFrameOrTimeout(kMaxWaitForFrame), TimedOut()); From 82900408488fd734ce39d1f254251c833692b461 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Tue, 1 Mar 2022 04:02:04 -0800 Subject: [PATCH 075/847] Roll chromium_revision cfa2b8c65a..6e70e8eefd (976087:976191) Change log: https://chromium.googlesource.com/chromium/src/+log/cfa2b8c65a..6e70e8eefd Full diff: https://chromium.googlesource.com/chromium/src/+/cfa2b8c65a..6e70e8eefd Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/78ef4ca402..2c3f10d296 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/15cbd56453..6b6ba00571 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/8215caa039..d487126e91 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/14ff931d6b..9d8d8b3e7e * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/2ded82c42c..d14b82e7e2 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/71ce93cbdb..e18670641d DEPS diff: https://chromium.googlesource.com/chromium/src/+/cfa2b8c65a..6e70e8eefd/DEPS No update to Clang. BUG=None Change-Id: I36b432393c02c16b7338691dadee582fe90e99ea Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253086 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36101} --- DEPS | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/DEPS b/DEPS index fb6ca64a0a..62df956a16 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': 'cfa2b8c65afd1d0474da0c84d4df8c61ca1d70f9', + 'chromium_revision': '6e70e8eefd1bc0b644fab3a3e91ec99ff212cbc7', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@78ef4ca4024482be44b68953d360c4e7f79eed6f', + 'https://chromium.googlesource.com/chromium/src/base@2c3f10d2961fc17e6c3b45a972899628a78d859a', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@15cbd564537d55ed78d13f4c629fb83cf52773dd', + 'https://chromium.googlesource.com/chromium/src/build@6b6ba00571e4db0c43fa4e3e26bfd22b93dcb8cd', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@893aa038dd17d05f3c5ff5af98daebabc294a948', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@8215caa03922de192f4f9b022c8a0b800678fe96', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@d487126e91540fa90232f2243bbe2a2f2383ed0d', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@14ff931d6bb2d8bcb3306394f5285f1883942396', + 'https://chromium.googlesource.com/chromium/src/testing@9d8d8b3e7e1f9a58c3c8297a535935f41d6dbaae', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@2ded82c42c3ed8d41e7e794e5ebdf86a0c165697', + 'https://chromium.googlesource.com/chromium/src/third_party@d14b82e7e2d1708f646a73be671b0a739550905b', 'src/buildtools/linux64': { 'packages': [ @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@71ce93cbdb8b093482ec1c1f2538b62301cbc8f9', + 'https://chromium.googlesource.com/chromium/src/tools@e18670641dd11ffaef1d8f85f78a117d5819e16d', 'src/third_party/accessibility_test_framework': { 'packages': [ From 4d278e2caf07d6e627c9d5f67b20f6ecfb63cdd5 Mon Sep 17 00:00:00 2001 From: Ali Tofigh Date: Tue, 1 Mar 2022 10:32:20 +0100 Subject: [PATCH 076/847] Adopt absl::string_view in function parameters under audio/ This is part of a large-scale effort to adopt absl::string_view throughout the WebRTC code base. As a first step, function parameters of type 'const std::string&' are being converted to absl::string_view. Bug: webrtc:13579 Change-Id: Ib4618fad3bff2902cd3a4730506aca300949d76c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252982 Reviewed-by: Stefan Holmer Commit-Queue: Ali Tofigh Cr-Commit-Position: refs/heads/main@{#36102} --- audio/BUILD.gn | 6 +++++- audio/audio_receive_stream.cc | 4 ++-- audio/audio_receive_stream.h | 3 ++- audio/test/pc_low_bandwidth_audio_test.cc | 6 ++++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/audio/BUILD.gn b/audio/BUILD.gn index 23976ab45f..b31ab0451e 100644 --- a/audio/BUILD.gn +++ b/audio/BUILD.gn @@ -104,6 +104,7 @@ rtc_library("audio") { ] absl_deps = [ "//third_party/abseil-cpp/absl/memory", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } @@ -225,7 +226,10 @@ if (rtc_include_tests) { "../test/pc/e2e:network_quality_metrics_reporter", "//testing/gtest", ] - absl_deps = [ "//third_party/abseil-cpp/absl/flags:flag" ] + absl_deps = [ + "//third_party/abseil-cpp/absl/flags:flag", + "//third_party/abseil-cpp/absl/strings", + ] if (is_android) { deps += [ "//testing/android/native_test:native_test_native_code" ] } diff --git a/audio/audio_receive_stream.cc b/audio/audio_receive_stream.cc index 6f2444901b..6717878abb 100644 --- a/audio/audio_receive_stream.cc +++ b/audio/audio_receive_stream.cc @@ -453,9 +453,9 @@ void AudioReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) { channel_receive_->ReceivedRTCPPacket(packet, length); } -void AudioReceiveStream::SetSyncGroup(const std::string& sync_group) { +void AudioReceiveStream::SetSyncGroup(absl::string_view sync_group) { RTC_DCHECK_RUN_ON(&packet_sequence_checker_); - config_.sync_group = sync_group; + config_.sync_group = std::string(sync_group); } void AudioReceiveStream::SetLocalSsrc(uint32_t local_ssrc) { diff --git a/audio/audio_receive_stream.h b/audio/audio_receive_stream.h index ee518c645b..3f4675cd72 100644 --- a/audio/audio_receive_stream.h +++ b/audio/audio_receive_stream.h @@ -16,6 +16,7 @@ #include #include +#include "absl/strings/string_view.h" #include "api/audio/audio_mixer.h" #include "api/neteq/neteq_factory.h" #include "api/rtp_headers.h" @@ -121,7 +122,7 @@ class AudioReceiveStream final : public webrtc::AudioReceiveStream, void AssociateSendStream(AudioSendStream* send_stream); void DeliverRtcp(const uint8_t* packet, size_t length); - void SetSyncGroup(const std::string& sync_group); + void SetSyncGroup(absl::string_view sync_group); void SetLocalSsrc(uint32_t local_ssrc); diff --git a/audio/test/pc_low_bandwidth_audio_test.cc b/audio/test/pc_low_bandwidth_audio_test.cc index 9cecc8dd41..0364670b91 100644 --- a/audio/test/pc_low_bandwidth_audio_test.cc +++ b/audio/test/pc_low_bandwidth_audio_test.cc @@ -12,6 +12,7 @@ #include "absl/flags/declare.h" #include "absl/flags/flag.h" +#include "absl/strings/string_view.h" #include "api/test/create_network_emulation_manager.h" #include "api/test/create_peerconnection_quality_test_fixture.h" #include "api/test/network_emulation_manager.h" @@ -71,14 +72,15 @@ CreateTwoNetworkLinks(NetworkEmulationManager* emulation, } std::unique_ptr -CreateTestFixture(const std::string& test_case_name, +CreateTestFixture(absl::string_view test_case_name, TimeController& time_controller, std::pair network_links, rtc::FunctionView alice_configurer, rtc::FunctionView bob_configurer) { auto fixture = webrtc_pc_e2e::CreatePeerConnectionE2EQualityTestFixture( - test_case_name, time_controller, /*audio_quality_analyzer=*/nullptr, + std::string(test_case_name), time_controller, + /*audio_quality_analyzer=*/nullptr, /*video_quality_analyzer=*/nullptr); fixture->AddPeer(network_links.first->network_dependencies(), alice_configurer); From 42da5a9a10ad0f87df299d5efc51146cf3d7cfdf Mon Sep 17 00:00:00 2001 From: Jonas Oreland Date: Tue, 1 Mar 2022 13:55:37 +0100 Subject: [PATCH 077/847] Keep RTCTransportStats on P2PTransportChannel. This cl/ changes so that the RTCTransportStats bytes/packets sent/recevied is computed in P2PTransportChannel. Previously they were computed by aggregating over the Connections, but that does not work when Connections are created and destroyed. Bug: webrtc:13769 Change-Id: Ia97dfae70b5aced897d4813ec007ba61bc032f87 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253100 Reviewed-by: Harald Alvestrand Commit-Queue: Jonas Oreland Cr-Commit-Position: refs/heads/main@{#36103} --- p2p/base/ice_transport_internal.h | 9 +++ p2p/base/p2p_transport_channel.cc | 13 ++++ p2p/base/p2p_transport_channel.h | 6 ++ p2p/base/p2p_transport_channel_unittest.cc | 75 ++++++++++++++++++++++ pc/rtc_stats_collector.cc | 17 +++-- pc/rtc_stats_collector_unittest.cc | 21 +++--- 6 files changed, 123 insertions(+), 18 deletions(-) diff --git a/p2p/base/ice_transport_internal.h b/p2p/base/ice_transport_internal.h index 20730e1cfd..e1171d4a74 100644 --- a/p2p/base/ice_transport_internal.h +++ b/p2p/base/ice_transport_internal.h @@ -38,6 +38,15 @@ struct IceTransportStats { // Initially 0 and 1 once the first candidate pair has been selected. // The counter is increase also when "unselecting" a connection. uint32_t selected_candidate_pair_changes = 0; + + // Bytes/packets sent/received. + // note: Is not the same as sum(connection_infos.bytes_sent) + // as connections are created and destroyed while the ICE transport + // is alive. + uint64_t bytes_sent = 0; + uint64_t bytes_received = 0; + uint64_t packets_sent = 0; + uint64_t packets_received = 0; }; typedef std::vector Candidates; diff --git a/p2p/base/p2p_transport_channel.cc b/p2p/base/p2p_transport_channel.cc index 5667bc516b..f95534b3e0 100644 --- a/p2p/base/p2p_transport_channel.cc +++ b/p2p/base/p2p_transport_channel.cc @@ -1608,6 +1608,7 @@ int P2PTransportChannel::SendPacket(const char* data, return -1; } + packets_sent_++; last_sent_packet_id_ = options.packet_id; rtc::PacketOptions modified_options(options); modified_options.info_signaled_after_sent.packet_type = @@ -1616,7 +1617,10 @@ int P2PTransportChannel::SendPacket(const char* data, if (sent <= 0) { RTC_DCHECK(sent < 0); error_ = selected_connection_->GetError(); + return sent; } + + bytes_sent_ += sent; return sent; } @@ -1643,6 +1647,11 @@ bool P2PTransportChannel::GetStats(IceTransportStats* ice_transport_stats) { ice_transport_stats->selected_candidate_pair_changes = selected_candidate_pair_changes_; + + ice_transport_stats->bytes_sent = bytes_sent_; + ice_transport_stats->bytes_received = bytes_received_; + ice_transport_stats->packets_sent = packets_sent_; + ice_transport_stats->packets_received = packets_received_; return true; } @@ -2238,6 +2247,8 @@ void P2PTransportChannel::OnReadPacket(Connection* connection, if (connection == selected_connection_) { // Let the client know of an incoming packet + packets_received_++; + bytes_received_ += len; RTC_DCHECK(connection->last_data_received() >= last_data_received_ms_); last_data_received_ms_ = std::max(last_data_received_ms_, connection->last_data_received()); @@ -2249,6 +2260,8 @@ void P2PTransportChannel::OnReadPacket(Connection* connection, if (!FindConnection(connection)) return; + packets_received_++; + bytes_received_ += len; RTC_DCHECK(connection->last_data_received() >= last_data_received_ms_); last_data_received_ms_ = std::max(last_data_received_ms_, connection->last_data_received()); diff --git a/p2p/base/p2p_transport_channel.h b/p2p/base/p2p_transport_channel.h index d06234603c..a1c2de04a7 100644 --- a/p2p/base/p2p_transport_channel.h +++ b/p2p/base/p2p_transport_channel.h @@ -490,6 +490,12 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal { Candidate candidate, const webrtc::AsyncDnsResolverResult& result); + // Bytes/packets sent/received on this channel. + uint64_t bytes_sent_ = 0; + uint64_t bytes_received_ = 0; + uint64_t packets_sent_ = 0; + uint64_t packets_received_ = 0; + // Number of times the selected_connection_ has been modified. uint32_t selected_candidate_pair_changes_ = 0; diff --git a/p2p/base/p2p_transport_channel_unittest.cc b/p2p/base/p2p_transport_channel_unittest.cc index 0a24f8c030..79bb2a340c 100644 --- a/p2p/base/p2p_transport_channel_unittest.cc +++ b/p2p/base/p2p_transport_channel_unittest.cc @@ -1373,6 +1373,81 @@ TEST_F(P2PTransportChannelTest, GetStats) { EXPECT_EQ(36U, best_conn_info->sent_discarded_bytes); EXPECT_EQ(10 * 36U, best_conn_info->recv_total_bytes); EXPECT_EQ(10U, best_conn_info->packets_received); + + EXPECT_EQ(10 * 36U, ice_transport_stats.bytes_sent); + EXPECT_EQ(10 * 36U, ice_transport_stats.bytes_received); + + DestroyChannels(); +} + +TEST_F(P2PTransportChannelTest, GetStatsSwitchConnection) { + rtc::ScopedFakeClock clock; + IceConfig continual_gathering_config = + CreateIceConfig(1000, GATHER_CONTINUALLY); + + ConfigureEndpoints(OPEN, OPEN, kDefaultPortAllocatorFlags, + kDefaultPortAllocatorFlags); + + AddAddress(0, kAlternateAddrs[1], "rmnet0", rtc::ADAPTER_TYPE_CELLULAR); + + CreateChannels(continual_gathering_config, continual_gathering_config); + EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->receiving() && ep1_ch1()->writable() && + ep2_ch1()->receiving() && + ep2_ch1()->writable(), + kMediumTimeout, clock); + // Sends and receives 10 packets. + TestSendRecv(&clock); + + IceTransportStats ice_transport_stats; + ASSERT_TRUE(ep1_ch1()->GetStats(&ice_transport_stats)); + ASSERT_GE(ice_transport_stats.connection_infos.size(), 2u); + ASSERT_GE(ice_transport_stats.candidate_stats_list.size(), 2u); + EXPECT_EQ(ice_transport_stats.selected_candidate_pair_changes, 1u); + + ConnectionInfo* best_conn_info = nullptr; + for (ConnectionInfo& info : ice_transport_stats.connection_infos) { + if (info.best_connection) { + best_conn_info = &info; + break; + } + } + ASSERT_TRUE(best_conn_info != nullptr); + EXPECT_TRUE(best_conn_info->new_connection); + EXPECT_TRUE(best_conn_info->receiving); + EXPECT_TRUE(best_conn_info->writable); + EXPECT_FALSE(best_conn_info->timeout); + + EXPECT_EQ(10 * 36U, best_conn_info->sent_total_bytes); + EXPECT_EQ(10 * 36U, best_conn_info->recv_total_bytes); + EXPECT_EQ(10 * 36U, ice_transport_stats.bytes_sent); + EXPECT_EQ(10 * 36U, ice_transport_stats.bytes_received); + + auto old_selected_connection = ep1_ch1()->selected_connection(); + ep1_ch1()->RemoveConnectionForTest( + const_cast(old_selected_connection)); + + EXPECT_TRUE_SIMULATED_WAIT(ep1_ch1()->selected_connection() != nullptr, + kMediumTimeout, clock); + + // Sends and receives 10 packets. + TestSendRecv(&clock); + + IceTransportStats ice_transport_stats2; + ASSERT_TRUE(ep1_ch1()->GetStats(&ice_transport_stats2)); + + int64_t sum_bytes_sent = 0; + int64_t sum_bytes_received = 0; + for (ConnectionInfo& info : ice_transport_stats.connection_infos) { + sum_bytes_sent += info.sent_total_bytes; + sum_bytes_received += info.recv_total_bytes; + } + + EXPECT_EQ(10 * 36U, sum_bytes_sent); + EXPECT_EQ(10 * 36U, sum_bytes_received); + + EXPECT_EQ(20 * 36U, ice_transport_stats2.bytes_sent); + EXPECT_EQ(20 * 36U, ice_transport_stats2.bytes_received); + DestroyChannels(); } diff --git a/pc/rtc_stats_collector.cc b/pc/rtc_stats_collector.cc index 13c62ec975..0ed8c14d51 100644 --- a/pc/rtc_stats_collector.cc +++ b/pc/rtc_stats_collector.cc @@ -2042,21 +2042,20 @@ void RTCStatsCollector::ProduceTransportStats_n( new RTCTransportStats(RTCTransportStatsIDFromTransportChannel( transport_name, channel_stats.component), timestamp_us)); - transport_stats->bytes_sent = 0; - transport_stats->packets_sent = 0; - transport_stats->bytes_received = 0; - transport_stats->packets_received = 0; + transport_stats->packets_sent = + channel_stats.ice_transport_stats.packets_sent; + transport_stats->packets_received = + channel_stats.ice_transport_stats.packets_received; + transport_stats->bytes_sent = + channel_stats.ice_transport_stats.bytes_sent; + transport_stats->bytes_received = + channel_stats.ice_transport_stats.bytes_received; transport_stats->dtls_state = DtlsTransportStateToRTCDtlsTransportState(channel_stats.dtls_state); transport_stats->selected_candidate_pair_changes = channel_stats.ice_transport_stats.selected_candidate_pair_changes; for (const cricket::ConnectionInfo& info : channel_stats.ice_transport_stats.connection_infos) { - *transport_stats->bytes_sent += info.sent_total_bytes; - *transport_stats->packets_sent += - info.sent_total_packets - info.sent_discarded_packets; - *transport_stats->bytes_received += info.recv_total_bytes; - *transport_stats->packets_received += info.packets_received; if (info.best_connection) { transport_stats->selected_candidate_pair_id = RTCIceCandidatePairStatsIDFromConnectionInfo(info); diff --git a/pc/rtc_stats_collector_unittest.cc b/pc/rtc_stats_collector_unittest.cc index d33760abcb..ec44b4dbe1 100644 --- a/pc/rtc_stats_collector_unittest.cc +++ b/pc/rtc_stats_collector_unittest.cc @@ -2419,6 +2419,10 @@ TEST_F(RTCStatsCollectorTest, CollectRTCTransportStats) { rtp_transport_channel_stats.ice_transport_stats.connection_infos.push_back( rtp_connection_info); rtp_transport_channel_stats.dtls_state = DtlsTransportState::kNew; + rtp_transport_channel_stats.ice_transport_stats.bytes_sent = 42; + rtp_transport_channel_stats.ice_transport_stats.packets_sent = 1; + rtp_transport_channel_stats.ice_transport_stats.bytes_received = 1337; + rtp_transport_channel_stats.ice_transport_stats.packets_received = 4; rtp_transport_channel_stats.ice_transport_stats .selected_candidate_pair_changes = 1; pc_->SetTransportStats(kTransportName, {rtp_transport_channel_stats}); @@ -2457,6 +2461,10 @@ TEST_F(RTCStatsCollectorTest, CollectRTCTransportStats) { rtcp_transport_channel_stats.ice_transport_stats.connection_infos.push_back( rtcp_connection_info); rtcp_transport_channel_stats.dtls_state = DtlsTransportState::kConnecting; + rtcp_transport_channel_stats.ice_transport_stats.bytes_sent = 1337; + rtcp_transport_channel_stats.ice_transport_stats.packets_sent = 1; + rtcp_transport_channel_stats.ice_transport_stats.bytes_received = 42; + rtcp_transport_channel_stats.ice_transport_stats.packets_received = 4; pc_->SetTransportStats(kTransportName, {rtp_transport_channel_stats, rtcp_transport_channel_stats}); @@ -2562,11 +2570,6 @@ TEST_F(RTCStatsCollectorTest, CollectRTCTransportStatsWithCrypto) { rtp_connection_info.best_connection = false; rtp_connection_info.local_candidate = *rtp_local_candidate.get(); rtp_connection_info.remote_candidate = *rtp_remote_candidate.get(); - rtp_connection_info.sent_total_bytes = 42; - rtp_connection_info.recv_total_bytes = 1337; - rtp_connection_info.sent_total_packets = 3; - rtp_connection_info.sent_discarded_packets = 2; - rtp_connection_info.packets_received = 4; cricket::TransportChannelStats rtp_transport_channel_stats; rtp_transport_channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP; rtp_transport_channel_stats.ice_transport_stats.connection_infos.push_back( @@ -2588,12 +2591,12 @@ TEST_F(RTCStatsCollectorTest, CollectRTCTransportStatsWithCrypto) { "RTCTransport_transport_" + rtc::ToString(cricket::ICE_CANDIDATE_COMPONENT_RTP), report->timestamp_us()); - expected_rtp_transport.bytes_sent = 42; - expected_rtp_transport.packets_sent = 1; - expected_rtp_transport.bytes_received = 1337; - expected_rtp_transport.packets_received = 4; expected_rtp_transport.dtls_state = RTCDtlsTransportState::kConnected; expected_rtp_transport.selected_candidate_pair_changes = 1; + expected_rtp_transport.bytes_sent = 0; + expected_rtp_transport.bytes_received = 0; + expected_rtp_transport.packets_sent = 0; + expected_rtp_transport.packets_received = 0; // Crypto parameters expected_rtp_transport.tls_version = "0203"; expected_rtp_transport.dtls_cipher = "TLS_RSA_WITH_AES_128_CBC_SHA"; From 7619b7c078729208ef3376092fc945dba0abeeee Mon Sep 17 00:00:00 2001 From: Evan Shrubsole Date: Tue, 1 Mar 2022 10:42:44 +0100 Subject: [PATCH 078/847] Add tests for FrameBuffer3 and SyncDecoding in PC Integration Tests Change-Id: I04ae6a694599a535347c29706e5ad40cba58155b Bug: webrtc:13672 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251721 Reviewed-by: Stefan Holmer Commit-Queue: Evan Shrubsole Cr-Commit-Position: refs/heads/main@{#36104} --- pc/BUILD.gn | 1 + pc/peer_connection_integrationtest.cc | 28 +++++++++++------- pc/test/integration_test_helpers.cc | 42 +++++++++++++++++++++++++++ pc/test/integration_test_helpers.h | 23 +++++++++++++++ 4 files changed, 84 insertions(+), 10 deletions(-) diff --git a/pc/BUILD.gn b/pc/BUILD.gn index c088e2cdaf..32d114444f 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -1989,6 +1989,7 @@ if (rtc_include_tests && !build_with_chromium) { "../rtc_base:timeutils", "../rtc_base/synchronization:mutex", "../rtc_base/task_utils:pending_task_safety_flag", + "../rtc_base/task_utils:repeating_task", "../rtc_base/task_utils:to_queued_task", "../rtc_base/third_party/base64", "../rtc_base/third_party/sigslot", diff --git a/pc/peer_connection_integrationtest.cc b/pc/peer_connection_integrationtest.cc index 1ee85c3be6..1e17fa1869 100644 --- a/pc/peer_connection_integrationtest.cc +++ b/pc/peer_connection_integrationtest.cc @@ -96,10 +96,12 @@ namespace { class PeerConnectionIntegrationTest : public PeerConnectionIntegrationBaseTest, - public ::testing::WithParamInterface { + public ::testing::WithParamInterface< + std::tuple> { protected: PeerConnectionIntegrationTest() - : PeerConnectionIntegrationBaseTest(GetParam()) {} + : PeerConnectionIntegrationBaseTest(std::get<0>(GetParam()), + std::get<1>(GetParam())) {} }; // Fake clock must be set before threads are started to prevent race on @@ -3516,15 +3518,21 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, } } -INSTANTIATE_TEST_SUITE_P(PeerConnectionIntegrationTest, - PeerConnectionIntegrationTest, - Values(SdpSemantics::kPlanB, - SdpSemantics::kUnifiedPlan)); +INSTANTIATE_TEST_SUITE_P( + PeerConnectionIntegrationTest, + PeerConnectionIntegrationTest, + Combine(Values(SdpSemantics::kPlanB, SdpSemantics::kUnifiedPlan), + Values("WebRTC-FrameBuffer3/arm:FrameBuffer2/", + "WebRTC-FrameBuffer3/arm:FrameBuffer3/", + "WebRTC-FrameBuffer3/arm:SyncDecoding/"))); -INSTANTIATE_TEST_SUITE_P(PeerConnectionIntegrationTest, - PeerConnectionIntegrationTestWithFakeClock, - Values(SdpSemantics::kPlanB, - SdpSemantics::kUnifiedPlan)); +INSTANTIATE_TEST_SUITE_P( + PeerConnectionIntegrationTest, + PeerConnectionIntegrationTestWithFakeClock, + Combine(Values(SdpSemantics::kPlanB, SdpSemantics::kUnifiedPlan), + Values("WebRTC-FrameBuffer3/arm:FrameBuffer2/", + "WebRTC-FrameBuffer3/arm:FrameBuffer3/", + "WebRTC-FrameBuffer3/arm:SyncDecoding/"))); // Tests that verify interoperability between Plan B and Unified Plan // PeerConnections. diff --git a/pc/test/integration_test_helpers.cc b/pc/test/integration_test_helpers.cc index 10e4f455ba..3f07f361fc 100644 --- a/pc/test/integration_test_helpers.cc +++ b/pc/test/integration_test_helpers.cc @@ -56,4 +56,46 @@ int FindFirstMediaStatsIndexByKind( return -1; } +TaskQueueMetronome::TaskQueueMetronome(TaskQueueFactory* factory, + TimeDelta tick_period) + : tick_period_(tick_period), + queue_(factory->CreateTaskQueue("MetronomeQueue", + TaskQueueFactory::Priority::HIGH)) { + tick_task_ = RepeatingTaskHandle::Start(queue_.Get(), [this] { + MutexLock lock(&mutex_); + for (auto* listener : listeners_) { + listener->OnTickTaskQueue()->PostTask( + ToQueuedTask([listener] { listener->OnTick(); })); + } + return tick_period_; + }); +} + +TaskQueueMetronome::~TaskQueueMetronome() { + RTC_DCHECK(listeners_.empty()); + rtc::Event stop_event; + queue_.PostTask([this, &stop_event] { + tick_task_.Stop(); + stop_event.Set(); + }); + stop_event.Wait(1000); +} + +void TaskQueueMetronome::AddListener(TickListener* listener) { + MutexLock lock(&mutex_); + auto [it, inserted] = listeners_.insert(listener); + RTC_DCHECK(inserted); +} + +void TaskQueueMetronome::RemoveListener(TickListener* listener) { + MutexLock lock(&mutex_); + auto it = listeners_.find(listener); + RTC_DCHECK(it != listeners_.end()); + listeners_.erase(it); +} + +TimeDelta TaskQueueMetronome::TickPeriod() const { + return tick_period_; +} + } // namespace webrtc diff --git a/pc/test/integration_test_helpers.h b/pc/test/integration_test_helpers.h index 2a455fd6cf..99ad8af4b5 100644 --- a/pc/test/integration_test_helpers.h +++ b/pc/test/integration_test_helpers.h @@ -95,6 +95,7 @@ #include "pc/test/mock_peer_connection_observers.h" #include "pc/video_track_source.h" #include "rtc_base/checks.h" +#include "rtc_base/event.h" #include "rtc_base/fake_clock.h" #include "rtc_base/fake_mdns_responder.h" #include "rtc_base/fake_network.h" @@ -111,9 +112,11 @@ #include "rtc_base/socket_address.h" #include "rtc_base/ssl_stream_adapter.h" #include "rtc_base/task_utils/pending_task_safety_flag.h" +#include "rtc_base/task_utils/repeating_task.h" #include "rtc_base/task_utils/to_queued_task.h" #include "rtc_base/test_certificate_verifier.h" #include "rtc_base/thread.h" +#include "rtc_base/thread_annotations.h" #include "rtc_base/time_utils.h" #include "rtc_base/virtual_socket_server.h" #include "system_wrappers/include/metrics.h" @@ -172,6 +175,24 @@ int FindFirstMediaStatsIndexByKind( const std::vector& media_stats_vec); +class TaskQueueMetronome : public webrtc::Metronome { + public: + TaskQueueMetronome(TaskQueueFactory* factory, TimeDelta tick_period); + ~TaskQueueMetronome() override; + + // webrtc::Metronome implementation. + void AddListener(TickListener* listener) override; + void RemoveListener(TickListener* listener) override; + TimeDelta TickPeriod() const override; + + private: + Mutex mutex_; + const TimeDelta tick_period_; + std::set listeners_ RTC_GUARDED_BY(mutex_); + RepeatingTaskHandle tick_task_; + rtc::TaskQueue queue_; +}; + class SignalingMessageReceiver { public: virtual void ReceiveSdpMessage(SdpType type, const std::string& msg) = 0; @@ -735,6 +756,8 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, pc_factory_dependencies.task_queue_factory = webrtc::CreateDefaultTaskQueueFactory(); pc_factory_dependencies.trials = std::make_unique(); + pc_factory_dependencies.metronome = std::make_unique( + pc_factory_dependencies.task_queue_factory.get(), TimeDelta::Millis(8)); cricket::MediaEngineDependencies media_deps; media_deps.task_queue_factory = pc_factory_dependencies.task_queue_factory.get(); From c1ed7ef491f83c83b90bafae2f1b72b0f68673a7 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Tue, 1 Mar 2022 10:02:33 -0800 Subject: [PATCH 079/847] Roll chromium_revision 6e70e8eefd..3c219c13d3 (976191:976297) Change log: https://chromium.googlesource.com/chromium/src/+log/6e70e8eefd..3c219c13d3 Full diff: https://chromium.googlesource.com/chromium/src/+/6e70e8eefd..3c219c13d3 Changed dependencies * src/build: https://chromium.googlesource.com/chromium/src/build/+log/6b6ba00571..2a53b6c0cd * src/buildtools/linux64: git_revision:e3f114f46537152cfbdb553015518d1db1b812fd..git_revision:d7c2209cebcfe37f46dba7be4e1a7000ffc342fb * src/buildtools/mac: git_revision:e3f114f46537152cfbdb553015518d1db1b812fd..git_revision:d7c2209cebcfe37f46dba7be4e1a7000ffc342fb * src/buildtools/third_party/libunwind/trunk: https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git/+log/2ea265b95a..d1c7f92b8b * src/buildtools/win: git_revision:e3f114f46537152cfbdb553015518d1db1b812fd..git_revision:d7c2209cebcfe37f46dba7be4e1a7000ffc342fb * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/d487126e91..03ed7e4bd5 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/9d8d8b3e7e..912f58bd45 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/d14b82e7e2..566a36179b * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/e18670641d..d580756862 DEPS diff: https://chromium.googlesource.com/chromium/src/+/6e70e8eefd..3c219c13d3/DEPS No update to Clang. BUG=None Change-Id: I9631ba8292e52edac785806f719c47ac799d6e45 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253180 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36105} --- DEPS | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/DEPS b/DEPS index 62df956a16..1e7828c8aa 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': '6e70e8eefd1bc0b644fab3a3e91ec99ff212cbc7', + 'chromium_revision': '3c219c13d35e3d409708bd275c825c9e3f3b996e', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -25,7 +25,7 @@ deps = { 'src/base': 'https://chromium.googlesource.com/chromium/src/base@2c3f10d2961fc17e6c3b45a972899628a78d859a', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@6b6ba00571e4db0c43fa4e3e26bfd22b93dcb8cd', + 'https://chromium.googlesource.com/chromium/src/build@2a53b6c0cd2c99507f354ccb94fa772dc655f6ea', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@893aa038dd17d05f3c5ff5af98daebabc294a948', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,19 +34,19 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@d487126e91540fa90232f2243bbe2a2f2383ed0d', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@03ed7e4bd59994b2011a654a8e31033619ddd90a', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@9d8d8b3e7e1f9a58c3c8297a535935f41d6dbaae', + 'https://chromium.googlesource.com/chromium/src/testing@912f58bd45b07f7ef83c109ff831e1807cf26515', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@d14b82e7e2d1708f646a73be671b0a739550905b', + 'https://chromium.googlesource.com/chromium/src/third_party@566a36179b8d30eb760b81a2459b938604d0cc6e', 'src/buildtools/linux64': { 'packages': [ { 'package': 'gn/gn/linux-amd64', - 'version': 'git_revision:e3f114f46537152cfbdb553015518d1db1b812fd', + 'version': 'git_revision:d7c2209cebcfe37f46dba7be4e1a7000ffc342fb', } ], 'dep_type': 'cipd', @@ -56,7 +56,7 @@ deps = { 'packages': [ { 'package': 'gn/gn/mac-${{arch}}', - 'version': 'git_revision:e3f114f46537152cfbdb553015518d1db1b812fd', + 'version': 'git_revision:d7c2209cebcfe37f46dba7be4e1a7000ffc342fb', } ], 'dep_type': 'cipd', @@ -66,7 +66,7 @@ deps = { 'packages': [ { 'package': 'gn/gn/windows-amd64', - 'version': 'git_revision:e3f114f46537152cfbdb553015518d1db1b812fd', + 'version': 'git_revision:d7c2209cebcfe37f46dba7be4e1a7000ffc342fb', } ], 'dep_type': 'cipd', @@ -80,7 +80,7 @@ deps = { 'src/buildtools/third_party/libc++abi/trunk': 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git@738dc100c61890744f9e78cac27c71d0a2190781', 'src/buildtools/third_party/libunwind/trunk': - 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git@2ea265b95a08e4a98fab16b327119788b8e50a69', + 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git@d1c7f92b8b0bff8d9f710ca40e44563a63db376e', 'src/tools/clang/dsymutil': { 'packages': [ @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@e18670641dd11ffaef1d8f85f78a117d5819e16d', + 'https://chromium.googlesource.com/chromium/src/tools@d580756862272ffd68f13ea5c32a3993044f6879', 'src/third_party/accessibility_test_framework': { 'packages': [ From b93e2240f1653b82e24553e092bbab84337774af Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Tue, 1 Mar 2022 16:02:00 -0800 Subject: [PATCH 080/847] Roll chromium_revision 3c219c13d3..7c22988b10 (976297:976475) Change log: https://chromium.googlesource.com/chromium/src/+log/3c219c13d3..7c22988b10 Full diff: https://chromium.googlesource.com/chromium/src/+/3c219c13d3..7c22988b10 Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/2c3f10d296..e87c822a9d * src/build: https://chromium.googlesource.com/chromium/src/build/+log/2a53b6c0cd..aabb6b9fdd * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/03ed7e4bd5..b28def56aa * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/912f58bd45..cd7ad61e12 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/566a36179b..942a7273f7 * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/2cfdaa8ce0..d62cc7b294 * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/ca9706d139..a255e4064a * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/d580756862..eafb007f40 DEPS diff: https://chromium.googlesource.com/chromium/src/+/3c219c13d3..7c22988b10/DEPS No update to Clang. BUG=None Change-Id: I9c51a916dff87c6419bff62b739b42727a1df9e7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253202 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36106} --- DEPS | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/DEPS b/DEPS index 1e7828c8aa..493dcb7169 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': '3c219c13d35e3d409708bd275c825c9e3f3b996e', + 'chromium_revision': '7c22988b10a4778682a21264b4a54b9e1a77eebd', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@2c3f10d2961fc17e6c3b45a972899628a78d859a', + 'https://chromium.googlesource.com/chromium/src/base@e87c822a9da28aaa2af65492988b2866b620cc9c', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@2a53b6c0cd2c99507f354ccb94fa772dc655f6ea', + 'https://chromium.googlesource.com/chromium/src/build@aabb6b9fdd229f629a940a271d9eb5d74d99d1d2', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@893aa038dd17d05f3c5ff5af98daebabc294a948', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@03ed7e4bd59994b2011a654a8e31033619ddd90a', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@b28def56aa6f11d9e219c7ed728b554c279abc24', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@912f58bd45b07f7ef83c109ff831e1807cf26515', + 'https://chromium.googlesource.com/chromium/src/testing@cd7ad61e12ece0d69a545f1444ef42671ceebff1', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@566a36179b8d30eb760b81a2459b938604d0cc6e', + 'https://chromium.googlesource.com/chromium/src/third_party@942a7273f73670ebc4ce9cb626df7df6f2c8cf1c', 'src/buildtools/linux64': { 'packages': [ @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@2cfdaa8ce0e0c959b01c0280a93be107788b7d24', + 'https://chromium.googlesource.com/catapult.git@d62cc7b2945f2197f62dc94aef9290848533486f', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@ca9706d13903f1efabb4ce6ea04d6f8340fb88c5', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@a255e4064ae55e05e306aa595b12c047638e6b8c', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@d580756862272ffd68f13ea5c32a3993044f6879', + 'https://chromium.googlesource.com/chromium/src/tools@eafb007f409cfe56b0ab6fd2263c02aee240bd76', 'src/third_party/accessibility_test_framework': { 'packages': [ From 5823c55b17bb531bf0f5b11edcc747a189cc1922 Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Tue, 1 Mar 2022 20:04:17 -0800 Subject: [PATCH 081/847] Update WebRTC code version (2022-03-02T04:04:16). Bug: None Change-Id: Iafc1813828d91438ec9a34395dfc2a39d68e21cd Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253204 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36107} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index 12fbc9bcc7..41e1071a4c 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 2022-02-28T04:03:34"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-03-02T04:04:16"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From 1dfb9f4db6c1b1c4ab1d99dc41d46c2c57637eb9 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Wed, 2 Mar 2022 00:01:36 -0800 Subject: [PATCH 082/847] Roll chromium_revision 7c22988b10..73bb0a55b9 (976475:976576) Change log: https://chromium.googlesource.com/chromium/src/+log/7c22988b10..73bb0a55b9 Full diff: https://chromium.googlesource.com/chromium/src/+/7c22988b10..73bb0a55b9 Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/e87c822a9d..7664dd78db * src/build: https://chromium.googlesource.com/chromium/src/build/+log/aabb6b9fdd..e795961f78 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/b28def56aa..d8405f85ea * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/cd7ad61e12..ef3ff558a7 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/942a7273f7..ac3013beaf * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/a255e4064a..1c22c511d0 * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/54ba566cdd..d041e6e3ff * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/eafb007f40..5ef85e6e4f DEPS diff: https://chromium.googlesource.com/chromium/src/+/7c22988b10..73bb0a55b9/DEPS No update to Clang. BUG=None Change-Id: If66314c646f6db7393d437489d8e7f2aba34cf59 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253207 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36108} --- DEPS | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/DEPS b/DEPS index 493dcb7169..a3a34c60b0 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': '7c22988b10a4778682a21264b4a54b9e1a77eebd', + 'chromium_revision': '73bb0a55b9d1d3895287959d75cab51fa8600c12', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@e87c822a9da28aaa2af65492988b2866b620cc9c', + 'https://chromium.googlesource.com/chromium/src/base@7664dd78db1a2ddb9eb2363701718ba7622db7f0', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@aabb6b9fdd229f629a940a271d9eb5d74d99d1d2', + 'https://chromium.googlesource.com/chromium/src/build@e795961f78aa92537c1fc4735518e4c50519d14c', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@893aa038dd17d05f3c5ff5af98daebabc294a948', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@b28def56aa6f11d9e219c7ed728b554c279abc24', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@d8405f85ea3cdb04d86f40b2a0d0d16697cb7926', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@cd7ad61e12ece0d69a545f1444ef42671ceebff1', + 'https://chromium.googlesource.com/chromium/src/testing@ef3ff558a72fcf96e1ac36426ec179787aa085d2', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@942a7273f73670ebc4ce9cb626df7df6f2c8cf1c', + 'https://chromium.googlesource.com/chromium/src/third_party@ac3013beaf469ec80c491f6a4bc245a9df82a027', 'src/buildtools/linux64': { 'packages': [ @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@a255e4064ae55e05e306aa595b12c047638e6b8c', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@1c22c511d02b4c4e02173297bcb8f2df3d3b4f66', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -228,7 +228,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@54ba566cdda23803c888afe5b664005be30d06e0', + 'https://android.googlesource.com/platform/external/perfetto.git@d041e6e3ffe64223b6c9bbb3b066f8ab59873c02', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@eafb007f409cfe56b0ab6fd2263c02aee240bd76', + 'https://chromium.googlesource.com/chromium/src/tools@5ef85e6e4f64389eabcafe4bc4e94a97532c3677', 'src/third_party/accessibility_test_framework': { 'packages': [ From f08e2663aae9a323a4e1001e35c1d0ee16433f4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Bostr=C3=B6m?= Date: Wed, 2 Mar 2022 10:12:56 +0100 Subject: [PATCH 083/847] Delete kAlwaysAllowPayloadTypeDemuxingFieldTrialName flag. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This flag was used as a kill switch in case turning off payload type demuxing in some Unified Plan cases (https://crbug.com/webrtc/12814) would cause any issues. That landed way back in M93 and no issues were ever reported, so time to clean up the flag. Bug: webrtc:12814 Change-Id: I1970936131384dc0be1cd118e6b0ac877b8c289c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253240 Auto-Submit: Henrik Boström Commit-Queue: Henrik Boström Reviewed-by: Harald Alvestrand Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#36109} --- pc/sdp_offer_answer.cc | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/pc/sdp_offer_answer.cc b/pc/sdp_offer_answer.cc index 2f4a88c68f..69588350ab 100644 --- a/pc/sdp_offer_answer.cc +++ b/pc/sdp_offer_answer.cc @@ -91,9 +91,6 @@ namespace { typedef webrtc::PeerConnectionInterface::RTCOfferAnswerOptions RTCOfferAnswerOptions; -constexpr const char* kAlwaysAllowPayloadTypeDemuxingFieldTrialName = - "WebRTC-AlwaysAllowPayloadTypeDemuxing"; - // Error messages const char kInvalidSdp[] = "Invalid session description."; const char kInvalidCandidates[] = "Description contains invalid candidates."; @@ -5090,13 +5087,6 @@ bool SdpOfferAnswerHandler::UpdatePayloadTypeDemuxingState( bool bundled_pt_demux_allowed_video = !IsUnifiedPlan() || mid_header_extension_missing_video || pt_demuxing_has_been_used_video_; - // Kill switch for the above change. - if (field_trial::IsEnabled(kAlwaysAllowPayloadTypeDemuxingFieldTrialName)) { - // TODO(https://crbug.com/webrtc/12814): If disabling PT-based demux does - // not trigger regressions, remove this kill switch. - bundled_pt_demux_allowed_audio = true; - bundled_pt_demux_allowed_video = true; - } // Gather all updates ahead of time so that all channels can be updated in a // single Invoke; necessary due to thread guards. From 0d13bbd4b124bb0afedf26d58da6b19812ab022d Mon Sep 17 00:00:00 2001 From: Jonas Oreland Date: Wed, 2 Mar 2022 11:17:36 +0100 Subject: [PATCH 084/847] Extend RTCIceCandidateStats with non-standard network_adapter_type This cl/ extends the RTCIceCandidateStats object with network_adapter_type and vpn, so that it maps the underlying WebRTC objects completly. Bug: webrtc:13773 Change-Id: I5cf79972c60ca6bf2a127dc96fa90811263ba6fd Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253241 Reviewed-by: Harald Alvestrand Commit-Queue: Jonas Oreland Cr-Commit-Position: refs/heads/main@{#36110} --- api/candidate.h | 8 ++++++ api/stats/rtcstats_objects.h | 17 ++++++++++++ p2p/base/port.cc | 1 + pc/rtc_stats_collector.cc | 44 ++++++++++++++++++++++++++++-- pc/rtc_stats_collector_unittest.cc | 29 ++++++++++++++++---- pc/rtc_stats_integrationtest.cc | 5 ++++ stats/rtcstats_objects.cc | 12 ++++++-- 7 files changed, 105 insertions(+), 11 deletions(-) diff --git a/api/candidate.h b/api/candidate.h index ecfdee3fcb..b8aaebc14a 100644 --- a/api/candidate.h +++ b/api/candidate.h @@ -109,6 +109,13 @@ class RTC_EXPORT Candidate { network_type_ = network_type; } + rtc::AdapterType underlying_type_for_vpn() const { + return underlying_type_for_vpn_; + } + void set_underlying_type_for_vpn(rtc::AdapterType network_type) { + underlying_type_for_vpn_ = network_type; + } + // Candidates in a new generation replace those in the old generation. uint32_t generation() const { return generation_; } void set_generation(uint32_t generation) { generation_ = generation; } @@ -195,6 +202,7 @@ class RTC_EXPORT Candidate { std::string type_; std::string network_name_; rtc::AdapterType network_type_; + rtc::AdapterType underlying_type_for_vpn_; uint32_t generation_; std::string foundation_; rtc::SocketAddress related_address_; diff --git a/api/stats/rtcstats_objects.h b/api/stats/rtcstats_objects.h index f38d962e15..ccaf095e3d 100644 --- a/api/stats/rtcstats_objects.h +++ b/api/stats/rtcstats_objects.h @@ -106,6 +106,20 @@ class RTC_EXPORT RTCCertificateStats final : public RTCStats { RTCStatsMember issuer_certificate_id; }; +// Non standard extension mapping to rtc::AdapterType +struct RTCNetworkAdapterType { + static constexpr char kUnknown[] = "unknown"; + static constexpr char kEthernet[] = "ethernet"; + static constexpr char kWifi[] = "wifi"; + static constexpr char kCellular[] = "cellular"; + static constexpr char kLoopback[] = "loopback"; + static constexpr char kAny[] = "any"; + static constexpr char kCellular2g[] = "cellular2g"; + static constexpr char kCellular3g[] = "cellular3g"; + static constexpr char kCellular4g[] = "cellular4g"; + static constexpr char kCellular5g[] = "cellular5g"; +}; + // https://w3c.github.io/webrtc-stats/#codec-dict* class RTC_EXPORT RTCCodecStats final : public RTCStats { public: @@ -227,6 +241,9 @@ class RTC_EXPORT RTCIceCandidateStats : public RTCStats { RTCStatsMember priority; RTCStatsMember url; + RTCNonStandardStatsMember vpn; + RTCNonStandardStatsMember network_adapter_type; + protected: RTCIceCandidateStats(const std::string& id, int64_t timestamp_us, diff --git a/p2p/base/port.cc b/p2p/base/port.cc index c616658fba..5d3552b7f6 100644 --- a/p2p/base/port.cc +++ b/p2p/base/port.cc @@ -276,6 +276,7 @@ void Port::AddAddress(const rtc::SocketAddress& address, c.set_tcptype(tcptype); c.set_network_name(network_->name()); c.set_network_type(network_->type()); + c.set_underlying_type_for_vpn(network_->underlying_type_for_vpn()); c.set_url(url); c.set_related_address(related_address); diff --git a/pc/rtc_stats_collector.cc b/pc/rtc_stats_collector.cc index 0ed8c14d51..c965161b0e 100644 --- a/pc/rtc_stats_collector.cc +++ b/pc/rtc_stats_collector.cc @@ -230,7 +230,7 @@ const char* DtlsTransportStateToRTCDtlsTransportState( } } -const char* NetworkAdapterTypeToStatsType(rtc::AdapterType type) { +const char* NetworkTypeToStatsType(rtc::AdapterType type) { switch (type) { case rtc::ADAPTER_TYPE_CELLULAR: case rtc::ADAPTER_TYPE_CELLULAR_2G: @@ -253,6 +253,36 @@ const char* NetworkAdapterTypeToStatsType(rtc::AdapterType type) { return nullptr; } +absl::string_view NetworkTypeToStatsNetworkAdapterType(rtc::AdapterType type) { + switch (type) { + case rtc::ADAPTER_TYPE_CELLULAR: + return RTCNetworkAdapterType::kCellular; + case rtc::ADAPTER_TYPE_CELLULAR_2G: + return RTCNetworkAdapterType::kCellular2g; + case rtc::ADAPTER_TYPE_CELLULAR_3G: + return RTCNetworkAdapterType::kCellular3g; + case rtc::ADAPTER_TYPE_CELLULAR_4G: + return RTCNetworkAdapterType::kCellular4g; + case rtc::ADAPTER_TYPE_CELLULAR_5G: + return RTCNetworkAdapterType::kCellular5g; + case rtc::ADAPTER_TYPE_ETHERNET: + return RTCNetworkAdapterType::kEthernet; + case rtc::ADAPTER_TYPE_WIFI: + return RTCNetworkAdapterType::kWifi; + case rtc::ADAPTER_TYPE_UNKNOWN: + return RTCNetworkAdapterType::kUnknown; + case rtc::ADAPTER_TYPE_LOOPBACK: + return RTCNetworkAdapterType::kLoopback; + case rtc::ADAPTER_TYPE_ANY: + return RTCNetworkAdapterType::kAny; + case rtc::ADAPTER_TYPE_VPN: + /* should not be handled here. Vpn is modelled as a bool */ + break; + } + RTC_DCHECK_NOTREACHED(); + return nullptr; +} + const char* QualityLimitationReasonToRTCQualityLimitationReason( QualityLimitationReason reason) { switch (reason) { @@ -733,7 +763,7 @@ const std::string& ProduceIceCandidateStats(int64_t timestamp_us, candidate_stats->transport_id = transport_id; if (is_local) { candidate_stats->network_type = - NetworkAdapterTypeToStatsType(candidate.network_type()); + NetworkTypeToStatsType(candidate.network_type()); const std::string& candidate_type = candidate.type(); const std::string& relay_protocol = candidate.relay_protocol(); const std::string& url = candidate.url(); @@ -752,6 +782,16 @@ const std::string& ProduceIceCandidateStats(int64_t timestamp_us, candidate_stats->url = url; } } + if (candidate.network_type() == rtc::ADAPTER_TYPE_VPN) { + candidate_stats->vpn = true; + candidate_stats->network_adapter_type = + std::string(NetworkTypeToStatsNetworkAdapterType( + candidate.underlying_type_for_vpn())); + } else { + candidate_stats->vpn = false; + candidate_stats->network_adapter_type = std::string( + NetworkTypeToStatsNetworkAdapterType(candidate.network_type())); + } } else { // We don't expect to know the adapter type of remote candidates. RTC_DCHECK_EQ(rtc::ADAPTER_TYPE_UNKNOWN, candidate.network_type()); diff --git a/pc/rtc_stats_collector_unittest.cc b/pc/rtc_stats_collector_unittest.cc index ec44b4dbe1..1438615ee6 100644 --- a/pc/rtc_stats_collector_unittest.cc +++ b/pc/rtc_stats_collector_unittest.cc @@ -216,11 +216,14 @@ std::unique_ptr CreateFakeCandidate( const std::string& protocol, const rtc::AdapterType adapter_type, const std::string& candidate_type, - uint32_t priority) { + uint32_t priority, + const rtc::AdapterType underlying_type_for_vpn = + rtc::ADAPTER_TYPE_UNKNOWN) { std::unique_ptr candidate(new cricket::Candidate()); candidate->set_address(rtc::SocketAddress(hostname, port)); candidate->set_protocol(protocol); candidate->set_network_type(adapter_type); + candidate->set_underlying_type_for_vpn(underlying_type_for_vpn); candidate->set_type(candidate_type); candidate->set_priority(priority); return candidate; @@ -1256,9 +1259,9 @@ TEST_F(RTCStatsCollectorTest, CollectRTCDataChannelStats) { TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { // Candidates in the first transport stats. - std::unique_ptr a_local_host = - CreateFakeCandidate("1.2.3.4", 5, "a_local_host's protocol", - rtc::ADAPTER_TYPE_VPN, cricket::LOCAL_PORT_TYPE, 0); + std::unique_ptr a_local_host = CreateFakeCandidate( + "1.2.3.4", 5, "a_local_host's protocol", rtc::ADAPTER_TYPE_VPN, + cricket::LOCAL_PORT_TYPE, 0, rtc::ADAPTER_TYPE_ETHERNET); RTCLocalIceCandidateStats expected_a_local_host( "RTCIceCandidate_" + a_local_host->id(), 0); expected_a_local_host.transport_id = "RTCTransport_a_0"; @@ -1269,6 +1272,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { expected_a_local_host.protocol = "a_local_host's protocol"; expected_a_local_host.candidate_type = "host"; expected_a_local_host.priority = 0; + expected_a_local_host.vpn = true; + expected_a_local_host.network_adapter_type = RTCNetworkAdapterType::kEthernet; std::unique_ptr a_remote_srflx = CreateFakeCandidate( "6.7.8.9", 10, "remote_srflx's protocol", rtc::ADAPTER_TYPE_UNKNOWN, @@ -1284,8 +1289,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { expected_a_remote_srflx.priority = 1; std::unique_ptr a_local_prflx = CreateFakeCandidate( - "11.12.13.14", 15, "a_local_prflx's protocol", rtc::ADAPTER_TYPE_CELLULAR, - cricket::PRFLX_PORT_TYPE, 2); + "11.12.13.14", 15, "a_local_prflx's protocol", + rtc::ADAPTER_TYPE_CELLULAR_2G, cricket::PRFLX_PORT_TYPE, 2); RTCLocalIceCandidateStats expected_a_local_prflx( "RTCIceCandidate_" + a_local_prflx->id(), 0); expected_a_local_prflx.transport_id = "RTCTransport_a_0"; @@ -1296,6 +1301,9 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { expected_a_local_prflx.protocol = "a_local_prflx's protocol"; expected_a_local_prflx.candidate_type = "prflx"; expected_a_local_prflx.priority = 2; + expected_a_local_prflx.vpn = false; + expected_a_local_prflx.network_adapter_type = + RTCNetworkAdapterType::kCellular2g; std::unique_ptr a_remote_relay = CreateFakeCandidate( "16.17.18.19", 20, "a_remote_relay's protocol", rtc::ADAPTER_TYPE_UNKNOWN, @@ -1328,6 +1336,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { expected_a_local_relay.candidate_type = "relay"; expected_a_local_relay.priority = 1; expected_a_local_relay.url = "turn:url1"; + expected_a_local_relay.vpn = false; + expected_a_local_relay.network_adapter_type = RTCNetworkAdapterType::kUnknown; std::unique_ptr a_local_relay_prflx = CreateFakeCandidate( "11.12.13.20", 22, "a_local_relay_prflx's protocol", @@ -1345,6 +1355,9 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { expected_a_local_relay_prflx.relay_protocol = "udp"; expected_a_local_relay_prflx.candidate_type = "prflx"; expected_a_local_relay_prflx.priority = 1; + expected_a_local_relay_prflx.vpn = false; + expected_a_local_relay_prflx.network_adapter_type = + RTCNetworkAdapterType::kUnknown; // Candidates in the second transport stats. std::unique_ptr b_local = @@ -1360,6 +1373,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { expected_b_local.protocol = "b_local's protocol"; expected_b_local.candidate_type = "host"; expected_b_local.priority = 42; + expected_b_local.vpn = false; + expected_b_local.network_adapter_type = RTCNetworkAdapterType::kWifi; std::unique_ptr b_remote = CreateFakeCandidate( "42.42.42.42", 42, "b_remote's protocol", rtc::ADAPTER_TYPE_UNKNOWN, @@ -1594,6 +1609,8 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidatePairStats) { expected_local_candidate.protocol = "protocol"; expected_local_candidate.candidate_type = "host"; expected_local_candidate.priority = 42; + expected_local_candidate.vpn = false; + expected_local_candidate.network_adapter_type = RTCNetworkAdapterType::kWifi; ASSERT_TRUE(report->Get(expected_local_candidate.id())); EXPECT_EQ(expected_local_candidate, report->Get(expected_local_candidate.id()) diff --git a/pc/rtc_stats_integrationtest.cc b/pc/rtc_stats_integrationtest.cc index be9cd6fbc0..085f0636a4 100644 --- a/pc/rtc_stats_integrationtest.cc +++ b/pc/rtc_stats_integrationtest.cc @@ -521,6 +521,7 @@ class RTCStatsReportVerifier { candidate_pair.consent_requests_sent); verifier.TestMemberIsUndefined(candidate_pair.consent_responses_received); verifier.TestMemberIsUndefined(candidate_pair.consent_responses_sent); + return verifier.ExpectAllMembersSuccessfullyTested(); } @@ -531,8 +532,12 @@ class RTCStatsReportVerifier { verifier.TestMemberIsDefined(candidate.is_remote); if (*candidate.is_remote) { verifier.TestMemberIsUndefined(candidate.network_type); + verifier.TestMemberIsUndefined(candidate.network_adapter_type); + verifier.TestMemberIsUndefined(candidate.vpn); } else { verifier.TestMemberIsDefined(candidate.network_type); + verifier.TestMemberIsDefined(candidate.network_adapter_type); + verifier.TestMemberIsDefined(candidate.vpn); } verifier.TestMemberIsDefined(candidate.ip); verifier.TestMemberIsDefined(candidate.address); diff --git a/stats/rtcstats_objects.cc b/stats/rtcstats_objects.cc index 961d17c7eb..3b962b68ae 100644 --- a/stats/rtcstats_objects.cc +++ b/stats/rtcstats_objects.cc @@ -277,7 +277,9 @@ WEBRTC_RTCSTATS_IMPL(RTCIceCandidateStats, RTCStats, "abstract-ice-candidate", &relay_protocol, &candidate_type, &priority, - &url) + &url, + &vpn, + &network_adapter_type) // clang-format on RTCIceCandidateStats::RTCIceCandidateStats(const std::string& id, @@ -299,7 +301,9 @@ RTCIceCandidateStats::RTCIceCandidateStats(std::string&& id, relay_protocol("relayProtocol"), candidate_type("candidateType"), priority("priority"), - url("url") {} + url("url"), + vpn("vpn"), + network_adapter_type("networkAdapterType") {} RTCIceCandidateStats::RTCIceCandidateStats(const RTCIceCandidateStats& other) : RTCStats(other.id(), other.timestamp_us()), @@ -313,7 +317,9 @@ RTCIceCandidateStats::RTCIceCandidateStats(const RTCIceCandidateStats& other) relay_protocol(other.relay_protocol), candidate_type(other.candidate_type), priority(other.priority), - url(other.url) {} + url(other.url), + vpn(other.vpn), + network_adapter_type(other.network_adapter_type) {} RTCIceCandidateStats::~RTCIceCandidateStats() {} From 9558ab41eb4de39c62cda2dd1e559f5814a3a0c7 Mon Sep 17 00:00:00 2001 From: Shuhai Peng Date: Wed, 2 Mar 2022 20:07:25 +0800 Subject: [PATCH 085/847] remove NV12 to I420 conversion in webrtc AV1 Encoder. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit libaom supports for NV12 inputs for encoding av1 stream. It will reduce unnecessary conversion from NV12 to I420 format. (https://bugs.chromium.org/p/aomedia/issues/detail?id=3232&q=3232&can=2) Bug: webrtc:13746 Change-Id: I1407227d1690b3f63cb6581eef5d587e5f418892 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251920 Reviewed-by: Erik Språng Reviewed-by: Ilya Nikolaevskiy Commit-Queue: Shuhai Peng Cr-Commit-Position: refs/heads/main@{#36111} --- .../codecs/av1/libaom_av1_encoder.cc | 109 +++++++++++++----- video/video_stream_encoder_unittest.cc | 2 +- 2 files changed, 82 insertions(+), 29 deletions(-) diff --git a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc index 79a31d9baa..b47dab9834 100644 --- a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc +++ b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc @@ -105,6 +105,8 @@ class LibaomAv1Encoder final : public VideoEncoder { // Configures the encoder which buffers next frame updates and can reference. void SetSvcRefFrameConfig( const ScalableVideoController::LayerFrameConfig& layer_frame); + // If pixel format doesn't match, then reallocate. + void MaybeRewrapImgWithFormat(const aom_img_fmt_t fmt); std::unique_ptr svc_controller_; bool inited_; @@ -228,11 +230,10 @@ int LibaomAv1Encoder::InitEncode(const VideoCodec* codec_settings, cfg_.g_pass = AOM_RC_ONE_PASS; // One-pass rate control cfg_.g_lag_in_frames = kLagInFrames; // No look ahead when lag equals 0. - // Creating a wrapper to the image - setting image data to nullptr. Actual - // pointer will be set in encode. Setting align to 1, as it is meaningless - // (actual memory is not allocated). - frame_for_encode_ = - aom_img_alloc(nullptr, AOM_IMG_FMT_I420, cfg_.g_w, cfg_.g_h, 1); + if (frame_for_encode_ != nullptr) { + aom_img_free(frame_for_encode_); + frame_for_encode_ = nullptr; + } // Flag options: AOM_CODEC_USE_PSNR and AOM_CODEC_USE_HIGHBITDEPTH aom_codec_flags_t flags = 0; @@ -555,6 +556,21 @@ int32_t LibaomAv1Encoder::Release() { return WEBRTC_VIDEO_CODEC_OK; } +void LibaomAv1Encoder::MaybeRewrapImgWithFormat(const aom_img_fmt_t fmt) { + if (!frame_for_encode_) { + frame_for_encode_ = + aom_img_wrap(nullptr, fmt, cfg_.g_w, cfg_.g_h, 1, nullptr); + + } else if (frame_for_encode_->fmt != fmt) { + RTC_LOG(LS_INFO) << "Switching AV1 encoder pixel format to " + << (fmt == AOM_IMG_FMT_NV12 ? "NV12" : "I420"); + aom_img_free(frame_for_encode_); + frame_for_encode_ = + aom_img_wrap(nullptr, fmt, cfg_.g_w, cfg_.g_h, 1, nullptr); + } + // else no-op since the image is already in the right format. +} + int32_t LibaomAv1Encoder::Encode( const VideoFrame& frame, const std::vector* frame_types) { @@ -574,38 +590,74 @@ int32_t LibaomAv1Encoder::Encode( return WEBRTC_VIDEO_CODEC_ERROR; } + rtc::scoped_refptr buffer = frame.video_frame_buffer(); + absl::InlinedVector + supported_formats = {VideoFrameBuffer::Type::kI420, + VideoFrameBuffer::Type::kNV12}; + rtc::scoped_refptr mapped_buffer; + if (buffer->type() != VideoFrameBuffer::Type::kNative) { + // `buffer` is already mapped. + mapped_buffer = buffer; + } else { + // Attempt to map to one of the supported formats. + mapped_buffer = buffer->GetMappedFrameBuffer(supported_formats); + } + // Convert input frame to I420, if needed. - VideoFrame prepped_input_frame = frame; - if (prepped_input_frame.video_frame_buffer()->type() != - VideoFrameBuffer::Type::kI420 && - prepped_input_frame.video_frame_buffer()->type() != - VideoFrameBuffer::Type::kI420A) { + if (!mapped_buffer || + (absl::c_find(supported_formats, mapped_buffer->type()) == + supported_formats.end() && + mapped_buffer->type() != VideoFrameBuffer::Type::kI420A)) { rtc::scoped_refptr converted_buffer( - prepped_input_frame.video_frame_buffer()->ToI420()); + mapped_buffer->ToI420()); if (!converted_buffer) { RTC_LOG(LS_ERROR) << "Failed to convert " << VideoFrameBufferTypeToString( - prepped_input_frame.video_frame_buffer()->type()) + frame.video_frame_buffer()->type()) << " image to I420. Can't encode frame."; return WEBRTC_VIDEO_CODEC_ENCODER_FAILURE; } RTC_CHECK(converted_buffer->type() == VideoFrameBuffer::Type::kI420 || converted_buffer->type() == VideoFrameBuffer::Type::kI420A); - prepped_input_frame = VideoFrame(converted_buffer, frame.timestamp(), - frame.render_time_ms(), frame.rotation()); - } - - // Set frame_for_encode_ data pointers and strides. - auto i420_buffer = prepped_input_frame.video_frame_buffer()->GetI420(); - frame_for_encode_->planes[AOM_PLANE_Y] = - const_cast(i420_buffer->DataY()); - frame_for_encode_->planes[AOM_PLANE_U] = - const_cast(i420_buffer->DataU()); - frame_for_encode_->planes[AOM_PLANE_V] = - const_cast(i420_buffer->DataV()); - frame_for_encode_->stride[AOM_PLANE_Y] = i420_buffer->StrideY(); - frame_for_encode_->stride[AOM_PLANE_U] = i420_buffer->StrideU(); - frame_for_encode_->stride[AOM_PLANE_V] = i420_buffer->StrideV(); + + mapped_buffer = converted_buffer; + } + + switch (mapped_buffer->type()) { + case VideoFrameBuffer::Type::kI420: + case VideoFrameBuffer::Type::kI420A: { + // Set frame_for_encode_ data pointers and strides. + MaybeRewrapImgWithFormat(AOM_IMG_FMT_I420); + auto i420_buffer = mapped_buffer->GetI420(); + RTC_DCHECK(i420_buffer); + frame_for_encode_->planes[AOM_PLANE_Y] = + const_cast(i420_buffer->DataY()); + frame_for_encode_->planes[AOM_PLANE_U] = + const_cast(i420_buffer->DataU()); + frame_for_encode_->planes[AOM_PLANE_V] = + const_cast(i420_buffer->DataV()); + frame_for_encode_->stride[AOM_PLANE_Y] = i420_buffer->StrideY(); + frame_for_encode_->stride[AOM_PLANE_U] = i420_buffer->StrideU(); + frame_for_encode_->stride[AOM_PLANE_V] = i420_buffer->StrideV(); + break; + } + case VideoFrameBuffer::Type::kNV12: { + MaybeRewrapImgWithFormat(AOM_IMG_FMT_NV12); + const NV12BufferInterface* nv12_buffer = mapped_buffer->GetNV12(); + RTC_DCHECK(nv12_buffer); + frame_for_encode_->planes[AOM_PLANE_Y] = + const_cast(nv12_buffer->DataY()); + frame_for_encode_->planes[AOM_PLANE_U] = + const_cast(nv12_buffer->DataUV()); + frame_for_encode_->planes[AOM_PLANE_V] = nullptr; + frame_for_encode_->stride[AOM_PLANE_Y] = nv12_buffer->StrideY(); + frame_for_encode_->stride[AOM_PLANE_U] = nv12_buffer->StrideUV(); + frame_for_encode_->stride[AOM_PLANE_V] = 0; + break; + } + default: + return WEBRTC_VIDEO_CODEC_ENCODER_FAILURE; + } const uint32_t duration = kRtpTicksPerSecond / static_cast(encoder_settings_.maxFramerate); @@ -805,7 +857,8 @@ VideoEncoder::EncoderInfo LibaomAv1Encoder::GetEncoderInfo() const { info.has_trusted_rate_controller = true; info.is_hardware_accelerated = false; info.scaling_settings = VideoEncoder::ScalingSettings(kMinQindex, kMaxQindex); - info.preferred_pixel_formats = {VideoFrameBuffer::Type::kI420}; + info.preferred_pixel_formats = {VideoFrameBuffer::Type::kI420, + VideoFrameBuffer::Type::kNV12}; if (SvcEnabled()) { for (int sid = 0; sid < svc_params_->number_spatial_layers; ++sid) { info.fps_allocation[sid].resize(svc_params_->number_temporal_layers); diff --git a/video/video_stream_encoder_unittest.cc b/video/video_stream_encoder_unittest.cc index aea1988df9..b1ff12ed11 100644 --- a/video/video_stream_encoder_unittest.cc +++ b/video/video_stream_encoder_unittest.cc @@ -8694,7 +8694,7 @@ constexpr std::pair kVP8DisallowConversion = constexpr std::pair kVP9DisallowConversion = std::make_pair(kVideoCodecVP9, /*allow_i420_conversion=*/false); constexpr std::pair kAV1AllowConversion = - std::make_pair(kVideoCodecAV1, /*allow_i420_conversion=*/true); + std::make_pair(kVideoCodecAV1, /*allow_i420_conversion=*/false); constexpr std::pair kMultiplexDisallowConversion = std::make_pair(kVideoCodecMultiplex, /*allow_i420_conversion=*/false); #if defined(WEBRTC_USE_H264) From d6cdf80072a2a087e98b2ac387314eccd07f6318 Mon Sep 17 00:00:00 2001 From: Evan Shrubsole Date: Wed, 2 Mar 2022 15:13:55 +0100 Subject: [PATCH 086/847] Use Timestamp and TimeDelta in VCMTiming * Switches TimestampExtrapolator to use Timestamp as well. Bug: webrtc:13589 Change-Id: I042be5d693068553d2e8eb92fa532092d77bd7ef Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/249993 Reviewed-by: Tomas Gunnarsson Commit-Queue: Evan Shrubsole Cr-Commit-Position: refs/heads/main@{#36112} --- api/video/BUILD.gn | 6 +- api/video/encoded_frame.cc | 8 + api/video/encoded_frame.h | 7 + modules/video_coding/BUILD.gn | 3 + modules/video_coding/frame_buffer2.cc | 68 ++--- modules/video_coding/frame_buffer2.h | 2 +- .../video_coding/frame_buffer2_unittest.cc | 79 +++--- modules/video_coding/frame_helpers.cc | 22 +- modules/video_coding/frame_helpers.h | 7 +- modules/video_coding/generic_decoder.cc | 2 +- modules/video_coding/receiver.cc | 23 +- modules/video_coding/receiver_unittest.cc | 19 +- modules/video_coding/timing.cc | 237 ++++++++-------- modules/video_coding/timing.h | 79 +++--- modules/video_coding/timing_unittest.cc | 256 +++++++++--------- modules/video_coding/video_receiver.cc | 5 +- rtc_base/time/BUILD.gn | 2 + rtc_base/time/timestamp_extrapolator.cc | 60 ++-- rtc_base/time/timestamp_extrapolator.h | 15 +- video/frame_buffer_proxy.cc | 52 ++-- video/frame_buffer_proxy_unittest.cc | 17 +- video/frame_decode_timing.cc | 7 +- video/frame_decode_timing_unittest.cc | 14 +- video/video_receive_stream2.cc | 8 +- video/video_receive_stream2_unittest.cc | 24 +- video/video_stream_decoder_impl.cc | 7 +- 26 files changed, 528 insertions(+), 501 deletions(-) diff --git a/api/video/BUILD.gn b/api/video/BUILD.gn index fcea278f82..34b7f22575 100644 --- a/api/video/BUILD.gn +++ b/api/video/BUILD.gn @@ -149,7 +149,11 @@ rtc_library("encoded_frame") { "encoded_frame.h", ] - deps = [ "../../modules/video_coding:encoded_frame" ] + deps = [ + "../../modules/video_coding:encoded_frame", + "../units:timestamp", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } rtc_library("rtp_video_frame_assembler") { diff --git a/api/video/encoded_frame.cc b/api/video/encoded_frame.cc index 86d1a698a7..56d199f30f 100644 --- a/api/video/encoded_frame.cc +++ b/api/video/encoded_frame.cc @@ -10,8 +10,16 @@ #include "api/video/encoded_frame.h" +#include "absl/types/optional.h" + namespace webrtc { +absl::optional EncodedFrame::RenderTimestamp() const { + return RenderTimeMs() >= 0 + ? absl::make_optional(Timestamp::Millis(RenderTimeMs())) + : absl::nullopt; +} + bool EncodedFrame::delayed_by_retransmission() const { return false; } diff --git a/api/video/encoded_frame.h b/api/video/encoded_frame.h index 3ef26caf6e..610c988ebd 100644 --- a/api/video/encoded_frame.h +++ b/api/video/encoded_frame.h @@ -14,6 +14,8 @@ #include #include +#include "absl/types/optional.h" +#include "api/units/timestamp.h" #include "modules/video_coding/encoded_frame.h" namespace webrtc { @@ -30,10 +32,15 @@ class EncodedFrame : public webrtc::VCMEncodedFrame { virtual ~EncodedFrame() {} // When this frame was received. + // TODO(bugs.webrtc.org/13756): Use Timestamp instead of int. virtual int64_t ReceivedTime() const = 0; // When this frame should be rendered. + // TODO(bugs.webrtc.org/13756): Use Timestamp instead of int. virtual int64_t RenderTime() const = 0; + // Returns a Timestamp from `RenderTime`, or nullopt if there is no + // render time. + absl::optional RenderTimestamp() const; // This information is currently needed by the timing calculation class. // TODO(philipel): Remove this function when a new timing class has diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn index 1a3d54e7b9..3ac8751776 100644 --- a/modules/video_coding/BUILD.gn +++ b/modules/video_coding/BUILD.gn @@ -190,6 +190,7 @@ rtc_library("timing") { deps = [ "../../api/units:time_delta", "../../api/video:video_rtp_headers", + "../../rtc_base:logging", "../../rtc_base:macromagic", "../../rtc_base:rtc_numerics", "../../rtc_base/experiments:field_trial_parser", @@ -1144,7 +1145,9 @@ if (rtc_include_tests) { "../../api:videocodec_test_fixture_api", "../../api/task_queue:default_task_queue_factory", "../../api/test/video:function_video_factory", + "../../api/units:frequency", "../../api/units:time_delta", + "../../api/units:timestamp", "../../api/video:builtin_video_bitrate_allocator_factory", "../../api/video:encoded_frame", "../../api/video:render_resolution", diff --git a/modules/video_coding/frame_buffer2.cc b/modules/video_coding/frame_buffer2.cc index b15db96364..b17cc944f6 100644 --- a/modules/video_coding/frame_buffer2.cc +++ b/modules/video_coding/frame_buffer2.cc @@ -104,7 +104,7 @@ void FrameBuffer::NextFrame(int64_t max_wait_time_ms, void FrameBuffer::StartWaitForNextFrameOnQueue() { RTC_DCHECK(callback_queue_); RTC_DCHECK(!callback_task_.Running()); - int64_t wait_ms = FindNextFrame(clock_->TimeInMilliseconds()); + int64_t wait_ms = FindNextFrame(clock_->CurrentTime()); callback_task_ = RepeatingTaskHandle::DelayedStart( callback_queue_->Get(), TimeDelta::Millis(wait_ms), [this] { @@ -118,13 +118,12 @@ void FrameBuffer::StartWaitForNextFrameOnQueue() { if (!frames_to_decode_.empty()) { // We have frames, deliver! frame = GetNextFrame(); - timing_->SetLastDecodeScheduledTimestamp( - clock_->TimeInMilliseconds()); + timing_->SetLastDecodeScheduledTimestamp(clock_->CurrentTime()); } else if (clock_->TimeInMilliseconds() < latest_return_time_ms_) { // If there's no frames to decode and there is still time left, it // means that the frame buffer was cleared between creation and // execution of this task. Continue waiting for the remaining time. - int64_t wait_ms = FindNextFrame(clock_->TimeInMilliseconds()); + int64_t wait_ms = FindNextFrame(clock_->CurrentTime()); return TimeDelta::Millis(wait_ms); } frame_handler = std::move(frame_handler_); @@ -137,8 +136,8 @@ void FrameBuffer::StartWaitForNextFrameOnQueue() { TaskQueueBase::DelayPrecision::kHigh); } -int64_t FrameBuffer::FindNextFrame(int64_t now_ms) { - int64_t wait_ms = latest_return_time_ms_ - now_ms; +int64_t FrameBuffer::FindNextFrame(Timestamp now) { + int64_t wait_ms = latest_return_time_ms_ - now.ms(); frames_to_decode_.clear(); // `last_continuous_frame_` may be empty below, but nullopt is smaller @@ -217,14 +216,16 @@ int64_t FrameBuffer::FindNextFrame(int64_t now_ms) { frames_to_decode_ = std::move(current_superframe); - if (frame->RenderTime() == -1) { - frame->SetRenderTime(timing_->RenderTimeMs(frame->Timestamp(), now_ms)); + absl::optional render_time = frame->RenderTimestamp(); + if (!render_time) { + render_time = timing_->RenderTime(frame->Timestamp(), now); + frame->SetRenderTime(render_time->ms()); } bool too_many_frames_queued = frames_.size() > zero_playout_delay_max_decode_queue_size_ ? true : false; - wait_ms = timing_->MaxWaitingTime(frame->RenderTime(), now_ms, - too_many_frames_queued); + wait_ms = + timing_->MaxWaitingTime(*render_time, now, too_many_frames_queued).ms(); // This will cause the frame buffer to prefer high framerate rather // than high resolution in the case of the decoder not decoding fast @@ -236,14 +237,14 @@ int64_t FrameBuffer::FindNextFrame(int64_t now_ms) { break; } - wait_ms = std::min(wait_ms, latest_return_time_ms_ - now_ms); + wait_ms = std::min(wait_ms, latest_return_time_ms_ - now.ms()); wait_ms = std::max(wait_ms, 0); return wait_ms; } std::unique_ptr FrameBuffer::GetNextFrame() { RTC_DCHECK_RUN_ON(&callback_checker_); - int64_t now_ms = clock_->TimeInMilliseconds(); + Timestamp now = clock_->CurrentTime(); // TODO(ilnik): remove `frames_out` use frames_to_decode_ directly. std::vector> frames_out; @@ -251,21 +252,21 @@ std::unique_ptr FrameBuffer::GetNextFrame() { bool superframe_delayed_by_retransmission = false; size_t superframe_size = 0; const EncodedFrame& first_frame = *frames_to_decode_[0]->second.frame; - int64_t render_time_ms = first_frame.RenderTime(); + absl::optional render_time = first_frame.RenderTimestamp(); int64_t receive_time_ms = first_frame.ReceivedTime(); // Gracefully handle bad RTP timestamps and render time issues. - if (FrameHasBadRenderTiming(first_frame.RenderTimeMs(), now_ms, - timing_->TargetVideoDelay())) { + if (!render_time || + FrameHasBadRenderTiming(*render_time, now, timing_->TargetVideoDelay())) { jitter_estimator_.Reset(); timing_->Reset(); - render_time_ms = timing_->RenderTimeMs(first_frame.Timestamp(), now_ms); + render_time = timing_->RenderTime(first_frame.Timestamp(), now); } for (FrameMap::iterator& frame_it : frames_to_decode_) { RTC_DCHECK(frame_it != frames_.end()); std::unique_ptr frame = std::move(frame_it->second.frame); - frame->SetRenderTime(render_time_ms); + frame->SetRenderTime(render_time->ms()); superframe_delayed_by_retransmission |= frame->delayed_by_retransmission(); receive_time_ms = std::max(receive_time_ms, frame->ReceivedTime()); @@ -305,9 +306,9 @@ std::unique_ptr FrameBuffer::GetNextFrame() { rtt_mult = rtt_mult_settings_->rtt_mult_setting; rtt_mult_add_cap_ms = rtt_mult_settings_->rtt_mult_add_cap_ms; } - timing_->SetJitterDelay( - jitter_estimator_.GetJitterEstimate(rtt_mult, rtt_mult_add_cap_ms)); - timing_->UpdateCurrentDelay(render_time_ms, now_ms); + timing_->SetJitterDelay(TimeDelta::Millis( + jitter_estimator_.GetJitterEstimate(rtt_mult, rtt_mult_add_cap_ms))); + timing_->UpdateCurrentDelay(*render_time, now); } else { if (RttMultExperiment::RttMultEnabled()) jitter_estimator_.FrameNacked(); @@ -446,8 +447,10 @@ int64_t FrameBuffer::InsertFrame(std::unique_ptr frame) { if (!UpdateFrameInfoWithIncomingFrame(*frame, info)) return last_continuous_frame_id; - if (!frame->delayed_by_retransmission()) - timing_->IncomingTimestamp(frame->Timestamp(), frame->ReceivedTime()); + // If ReceiveTime is negative then it is not a valid timestamp. + if (!frame->delayed_by_retransmission() && frame->ReceivedTime() >= 0) + timing_->IncomingTimestamp(frame->Timestamp(), + Timestamp::Millis(frame->ReceivedTime())); // It can happen that a frame will be reported as fully received even if a // lower spatial layer frame is missing. @@ -591,18 +594,17 @@ void FrameBuffer::UpdateJitterDelay() { if (!stats_callback_) return; - int max_decode_ms; - int current_delay_ms; - int target_delay_ms; - int jitter_buffer_ms; - int min_playout_delay_ms; - int render_delay_ms; - if (timing_->GetTimings(&max_decode_ms, ¤t_delay_ms, &target_delay_ms, - &jitter_buffer_ms, &min_playout_delay_ms, - &render_delay_ms)) { + TimeDelta max_decode = TimeDelta::Zero(); + TimeDelta current_delay = TimeDelta::Zero(); + TimeDelta target_delay = TimeDelta::Zero(); + TimeDelta jitter_buffer = TimeDelta::Zero(); + TimeDelta min_playout_delay = TimeDelta::Zero(); + TimeDelta render_delay = TimeDelta::Zero(); + if (timing_->GetTimings(&max_decode, ¤t_delay, &target_delay, + &jitter_buffer, &min_playout_delay, &render_delay)) { stats_callback_->OnFrameBufferTimingsUpdated( - max_decode_ms, current_delay_ms, target_delay_ms, jitter_buffer_ms, - min_playout_delay_ms, render_delay_ms); + max_decode.ms(), current_delay.ms(), target_delay.ms(), + jitter_buffer.ms(), min_playout_delay.ms(), render_delay.ms()); } } diff --git a/modules/video_coding/frame_buffer2.h b/modules/video_coding/frame_buffer2.h index f2e515c8ee..5cefa8b0d8 100644 --- a/modules/video_coding/frame_buffer2.h +++ b/modules/video_coding/frame_buffer2.h @@ -118,7 +118,7 @@ class FrameBuffer { // Check that the references of `frame` are valid. bool ValidReferences(const EncodedFrame& frame) const; - int64_t FindNextFrame(int64_t now_ms) RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_); + int64_t FindNextFrame(Timestamp now) RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_); std::unique_ptr GetNextFrame() RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_); diff --git a/modules/video_coding/frame_buffer2_unittest.cc b/modules/video_coding/frame_buffer2_unittest.cc index be838c748e..4811635d64 100644 --- a/modules/video_coding/frame_buffer2_unittest.cc +++ b/modules/video_coding/frame_buffer2_unittest.cc @@ -16,6 +16,8 @@ #include #include +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "modules/video_coding/frame_object.h" #include "modules/video_coding/jitter_estimator.h" #include "modules/video_coding/timing.h" @@ -40,56 +42,55 @@ class VCMTimingFake : public VCMTiming { public: explicit VCMTimingFake(Clock* clock) : VCMTiming(clock) {} - int64_t RenderTimeMs(uint32_t frame_timestamp, - int64_t now_ms) const override { - if (last_ms_ == -1) { - last_ms_ = now_ms + kDelayMs; + Timestamp RenderTime(uint32_t frame_timestamp, Timestamp now) const override { + if (last_render_time_.IsMinusInfinity()) { + last_render_time_ = now + kDelay; last_timestamp_ = frame_timestamp; } - uint32_t diff = MinDiff(frame_timestamp, last_timestamp_); + auto diff = MinDiff(frame_timestamp, last_timestamp_); + auto timeDiff = TimeDelta::Millis(diff / 90); if (AheadOf(frame_timestamp, last_timestamp_)) - last_ms_ += diff / 90; + last_render_time_ += timeDiff; else - last_ms_ -= diff / 90; + last_render_time_ -= timeDiff; last_timestamp_ = frame_timestamp; - return last_ms_; + return last_render_time_; } - int64_t MaxWaitingTime(int64_t render_time_ms, - int64_t now_ms, - bool too_many_frames_queued) const override { - return render_time_ms - now_ms - kDecodeTime; + TimeDelta MaxWaitingTime(Timestamp render_time, + Timestamp now, + bool too_many_frames_queued) const override { + return render_time - now - kDecodeTime; } - bool GetTimings(int* max_decode_ms, - int* current_delay_ms, - int* target_delay_ms, - int* jitter_buffer_ms, - int* min_playout_delay_ms, - int* render_delay_ms) const override { + bool GetTimings(TimeDelta* max_decode, + TimeDelta* current_delay, + TimeDelta* target_delay, + TimeDelta* jitter_buffer, + TimeDelta* min_playout_delay, + TimeDelta* render_delay) const override { return true; } - int GetCurrentJitter() { - int max_decode_ms; - int current_delay_ms; - int target_delay_ms; - int jitter_buffer_ms; - int min_playout_delay_ms; - int render_delay_ms; - VCMTiming::GetTimings(&max_decode_ms, ¤t_delay_ms, &target_delay_ms, - &jitter_buffer_ms, &min_playout_delay_ms, - &render_delay_ms); - return jitter_buffer_ms; + TimeDelta GetCurrentJitter() { + TimeDelta max_decode = TimeDelta::Zero(); + TimeDelta current_delay = TimeDelta::Zero(); + TimeDelta target_delay = TimeDelta::Zero(); + TimeDelta jitter_buffer = TimeDelta::Zero(); + TimeDelta min_playout_delay = TimeDelta::Zero(); + TimeDelta render_delay = TimeDelta::Zero(); + VCMTiming::GetTimings(&max_decode, ¤t_delay, &target_delay, + &jitter_buffer, &min_playout_delay, &render_delay); + return jitter_buffer; } private: - static constexpr int kDelayMs = 50; - static constexpr int kDecodeTime = kDelayMs / 2; + static constexpr TimeDelta kDelay = TimeDelta::Millis(50); + const TimeDelta kDecodeTime = kDelay / 2; mutable uint32_t last_timestamp_ = 0; - mutable int64_t last_ms_ = -1; + mutable Timestamp last_render_time_ = Timestamp::MinusInfinity(); }; class FrameObjectFake : public EncodedFrame { @@ -120,12 +121,12 @@ class VCMReceiveStatisticsCallbackMock : public VCMReceiveStatisticsCallback { MOCK_METHOD(void, OnDroppedFrames, (uint32_t frames_dropped), (override)); MOCK_METHOD(void, OnFrameBufferTimingsUpdated, - (int max_decode_ms, - int current_delay_ms, - int target_delay_ms, - int jitter_buffer_ms, - int min_playout_delay_ms, - int render_delay_ms), + (int max_decode, + int current_delay, + int target_delay, + int jitter_buffer, + int min_playout_delay, + int render_delay), (override)); MOCK_METHOD(void, OnTimingFrameInfoUpdated, @@ -474,7 +475,7 @@ TEST_F(TestFrameBuffer2, ProtectionModeNackFEC) { ExtractFrame(); ExtractFrame(); ASSERT_EQ(4u, frames_.size()); - EXPECT_LT(timing_.GetCurrentJitter(), kRttMs); + EXPECT_LT(timing_.GetCurrentJitter().ms(), kRttMs); } TEST_F(TestFrameBuffer2, NoContinuousFrame) { diff --git a/modules/video_coding/frame_helpers.cc b/modules/video_coding/frame_helpers.cc index 870f198dc4..08b47ef547 100644 --- a/modules/video_coding/frame_helpers.cc +++ b/modules/video_coding/frame_helpers.cc @@ -16,29 +16,29 @@ namespace webrtc { -bool FrameHasBadRenderTiming(int64_t render_time_ms, - int64_t now_ms, - int target_video_delay) { +bool FrameHasBadRenderTiming(Timestamp render_time, + Timestamp now, + TimeDelta target_video_delay) { // Zero render time means render immediately. - if (render_time_ms == 0) { + if (render_time.IsZero()) { return false; } - if (render_time_ms < 0) { + if (render_time < Timestamp::Zero()) { return true; } - const int64_t kMaxVideoDelayMs = 10000; - if (std::abs(render_time_ms - now_ms) > kMaxVideoDelayMs) { - int frame_delay = static_cast(std::abs(render_time_ms - now_ms)); + constexpr TimeDelta kMaxVideoDelay = TimeDelta::Millis(10000); + TimeDelta frame_delay = (render_time - now).Abs(); + if (frame_delay > kMaxVideoDelay) { RTC_LOG(LS_WARNING) << "A frame about to be decoded is out of the configured " "delay bounds (" - << frame_delay << " > " << kMaxVideoDelayMs + << frame_delay.ms() << " > " << kMaxVideoDelay.ms() << "). Resetting the video jitter buffer."; return true; } - if (target_video_delay > kMaxVideoDelayMs) { + if (target_video_delay > kMaxVideoDelay) { RTC_LOG(LS_WARNING) << "The video target delay has grown larger than " - << kMaxVideoDelayMs << " ms."; + << kMaxVideoDelay.ms() << " ms."; return true; } return false; diff --git a/modules/video_coding/frame_helpers.h b/modules/video_coding/frame_helpers.h index e329d03706..b6d7b0f144 100644 --- a/modules/video_coding/frame_helpers.h +++ b/modules/video_coding/frame_helpers.h @@ -18,10 +18,9 @@ namespace webrtc { -// TODO(https://bugs.webrtc.org/13589): Switch to using Timestamp and TimeDelta. -bool FrameHasBadRenderTiming(int64_t render_time_ms, - int64_t now_ms, - int target_video_delay); +bool FrameHasBadRenderTiming(Timestamp render_time, + Timestamp now, + TimeDelta target_video_delay); std::unique_ptr CombineAndDeleteFrames( absl::InlinedVector, 4> frames); diff --git a/modules/video_coding/generic_decoder.cc b/modules/video_coding/generic_decoder.cc index fe59d5c7f1..4b55f85b96 100644 --- a/modules/video_coding/generic_decoder.cc +++ b/modules/video_coding/generic_decoder.cc @@ -142,7 +142,7 @@ void VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage, const TimeDelta decode_time = decode_time_ms ? TimeDelta::Millis(*decode_time_ms) : now - *frameInfo->decodeStart; - _timing->StopDecodeTimer(decode_time.ms(), now.ms()); + _timing->StopDecodeTimer(decode_time, now); decodedImage.set_processing_time( {*frameInfo->decodeStart, *frameInfo->decodeStart + decode_time}); diff --git a/modules/video_coding/receiver.cc b/modules/video_coding/receiver.cc index e156a1c28d..e09a056948 100644 --- a/modules/video_coding/receiver.cc +++ b/modules/video_coding/receiver.cc @@ -69,7 +69,7 @@ int32_t VCMReceiver::InsertPacket(const VCMPacket& packet) { // We don't want to include timestamps which have suffered from // retransmission here, since we compensate with extra retransmission // delay within the jitter estimate. - timing_->IncomingTimestamp(packet.timestamp, clock_->TimeInMilliseconds()); + timing_->IncomingTimestamp(packet.timestamp, clock_->CurrentTime()); } return VCM_OK; } @@ -94,16 +94,18 @@ VCMEncodedFrame* VCMReceiver::FrameForDecoding(uint16_t max_wait_time_ms, } if (min_playout_delay_ms >= 0) - timing_->set_min_playout_delay(min_playout_delay_ms); + timing_->set_min_playout_delay(TimeDelta::Millis(min_playout_delay_ms)); if (max_playout_delay_ms >= 0) - timing_->set_max_playout_delay(max_playout_delay_ms); + timing_->set_max_playout_delay(TimeDelta::Millis(max_playout_delay_ms)); // We have a frame - Set timing and render timestamp. - timing_->SetJitterDelay(jitter_buffer_.EstimatedJitterMs()); - const int64_t now_ms = clock_->TimeInMilliseconds(); + timing_->SetJitterDelay( + TimeDelta::Millis(jitter_buffer_.EstimatedJitterMs())); + const Timestamp now = clock_->CurrentTime(); + const int64_t now_ms = now.ms(); timing_->UpdateCurrentDelay(frame_timestamp); - render_time_ms = timing_->RenderTimeMs(frame_timestamp, now_ms); + render_time_ms = timing_->RenderTime(frame_timestamp, now).ms(); // Check render timing. bool timing_error = false; // Assume that render timing errors are due to changes in the video stream. @@ -117,7 +119,7 @@ VCMEncodedFrame* VCMReceiver::FrameForDecoding(uint16_t max_wait_time_ms, << frame_delay << " > " << max_video_delay_ms_ << "). Resetting the video jitter buffer."; timing_error = true; - } else if (static_cast(timing_->TargetVideoDelay()) > + } else if (static_cast(timing_->TargetVideoDelay().ms()) > max_video_delay_ms_) { RTC_LOG(LS_WARNING) << "The video target delay has grown larger than " << max_video_delay_ms_ @@ -140,8 +142,11 @@ VCMEncodedFrame* VCMReceiver::FrameForDecoding(uint16_t max_wait_time_ms, uint16_t new_max_wait_time = static_cast(VCM_MAX(available_wait_time, 0)); uint32_t wait_time_ms = rtc::saturated_cast( - timing_->MaxWaitingTime(render_time_ms, clock_->TimeInMilliseconds(), - /*too_many_frames_queued=*/false)); + timing_ + ->MaxWaitingTime(Timestamp::Millis(render_time_ms), + clock_->CurrentTime(), + /*too_many_frames_queued=*/false) + .ms()); if (new_max_wait_time < wait_time_ms) { // We're not allowed to wait until the frame is supposed to be rendered, // waiting as long as we're allowed to avoid busy looping, and then return diff --git a/modules/video_coding/receiver_unittest.cc b/modules/video_coding/receiver_unittest.cc index 1b6ee34bd7..73c88a5800 100644 --- a/modules/video_coding/receiver_unittest.cc +++ b/modules/video_coding/receiver_unittest.cc @@ -124,7 +124,7 @@ TEST_F(TestVCMReceiver, NonDecodableDuration_OneIncomplete) { const int kMinDelayMs = 500; receiver_.SetNackSettings(kMaxNackListSize, kMaxPacketAgeToNack, kMaxNonDecodableDuration); - timing_.set_min_playout_delay(kMinDelayMs); + timing_.set_min_playout_delay(TimeDelta::Millis(kMinDelayMs)); int64_t key_frame_inserted = clock_.TimeInMilliseconds(); EXPECT_GE(InsertFrame(VideoFrameType::kVideoFrameKey, true), kNoError); // Insert an incomplete frame. @@ -152,7 +152,7 @@ TEST_F(TestVCMReceiver, NonDecodableDuration_NoTrigger) { const int kMinDelayMs = 500; receiver_.SetNackSettings(kMaxNackListSize, kMaxPacketAgeToNack, kMaxNonDecodableDuration); - timing_.set_min_playout_delay(kMinDelayMs); + timing_.set_min_playout_delay(TimeDelta::Millis(kMinDelayMs)); int64_t key_frame_inserted = clock_.TimeInMilliseconds(); EXPECT_GE(InsertFrame(VideoFrameType::kVideoFrameKey, true), kNoError); // Insert an incomplete frame. @@ -182,7 +182,7 @@ TEST_F(TestVCMReceiver, NonDecodableDuration_NoTrigger2) { const int kMinDelayMs = 500; receiver_.SetNackSettings(kMaxNackListSize, kMaxPacketAgeToNack, kMaxNonDecodableDuration); - timing_.set_min_playout_delay(kMinDelayMs); + timing_.set_min_playout_delay(TimeDelta::Millis(kMinDelayMs)); int64_t key_frame_inserted = clock_.TimeInMilliseconds(); EXPECT_GE(InsertFrame(VideoFrameType::kVideoFrameKey, true), kNoError); // Insert enough frames to have too long non-decodable sequence, except that @@ -212,7 +212,7 @@ TEST_F(TestVCMReceiver, NonDecodableDuration_KeyFrameAfterIncompleteFrames) { const int kMinDelayMs = 500; receiver_.SetNackSettings(kMaxNackListSize, kMaxPacketAgeToNack, kMaxNonDecodableDuration); - timing_.set_min_playout_delay(kMinDelayMs); + timing_.set_min_playout_delay(TimeDelta::Millis(kMinDelayMs)); int64_t key_frame_inserted = clock_.TimeInMilliseconds(); EXPECT_GE(InsertFrame(VideoFrameType::kVideoFrameKey, true), kNoError); // Insert an incomplete frame. @@ -448,9 +448,9 @@ TEST_F(VCMReceiverTimingTest, FrameForDecodingPreferLateDecoding) { int64_t arrive_timestamps[kNumFrames]; int64_t render_timestamps[kNumFrames]; - int render_delay_ms; - int max_decode_ms; - int dummy; + TimeDelta render_delay_ms = TimeDelta::Zero(); + TimeDelta max_decode_ms = TimeDelta::Zero(); + TimeDelta dummy = TimeDelta::Zero(); timing_.GetTimings(&max_decode_ms, &dummy, &dummy, &dummy, &dummy, &render_delay_ms); @@ -479,8 +479,9 @@ TEST_F(VCMReceiverTimingTest, FrameForDecodingPreferLateDecoding) { receiver_.FrameForDecoding(kMaxWaitTime, prefer_late_decoding); int64_t end_time = clock_.TimeInMilliseconds(); if (frame) { - EXPECT_EQ(frame->RenderTimeMs() - max_decode_ms - render_delay_ms, - end_time); + EXPECT_EQ( + frame->RenderTimeMs() - max_decode_ms.ms() - render_delay_ms.ms(), + end_time); receiver_.ReleaseFrame(frame); ++num_frames_return; } else { diff --git a/modules/video_coding/timing.cc b/modules/video_coding/timing.cc index df98416905..89159f6a3a 100644 --- a/modules/video_coding/timing.cc +++ b/modules/video_coding/timing.cc @@ -12,6 +12,7 @@ #include +#include "api/units/time_delta.h" #include "rtc_base/experiments/field_trial_parser.h" #include "rtc_base/time/timestamp_extrapolator.h" #include "system_wrappers/include/clock.h" @@ -19,27 +20,27 @@ namespace webrtc { namespace { + // Default pacing that is used for the low-latency renderer path. constexpr TimeDelta kZeroPlayoutDelayDefaultMinPacing = TimeDelta::Millis(8); } // namespace VCMTiming::VCMTiming(Clock* clock) : clock_(clock), - ts_extrapolator_(std::make_unique( - clock_->TimeInMilliseconds())), + ts_extrapolator_( + std::make_unique(clock_->CurrentTime())), codec_timer_(std::make_unique()), - render_delay_ms_(kDefaultRenderDelayMs), - min_playout_delay_ms_(0), - max_playout_delay_ms_(10000), - jitter_delay_ms_(0), - current_delay_ms_(0), + render_delay_(kDefaultRenderDelay), + min_playout_delay_(TimeDelta::Zero()), + max_playout_delay_(TimeDelta::Seconds(10)), + jitter_delay_(TimeDelta::Zero()), + current_delay_(TimeDelta::Zero()), prev_frame_timestamp_(0), - timing_frame_info_(), num_decoded_frames_(0), low_latency_renderer_enabled_("enabled", true), zero_playout_delay_min_pacing_("min_pacing", kZeroPlayoutDelayDefaultMinPacing), - last_decode_scheduled_ts_(0) { + last_decode_scheduled_(Timestamp::Zero()) { ParseFieldTrial({&low_latency_renderer_enabled_}, field_trial::FindFullName("WebRTC-LowLatencyRenderer")); ParseFieldTrial({&zero_playout_delay_min_pacing_}, @@ -48,218 +49,208 @@ VCMTiming::VCMTiming(Clock* clock) void VCMTiming::Reset() { MutexLock lock(&mutex_); - ts_extrapolator_->Reset(clock_->TimeInMilliseconds()); + ts_extrapolator_->Reset(clock_->CurrentTime()); codec_timer_ = std::make_unique(); - render_delay_ms_ = kDefaultRenderDelayMs; - min_playout_delay_ms_ = 0; - jitter_delay_ms_ = 0; - current_delay_ms_ = 0; + render_delay_ = kDefaultRenderDelay; + min_playout_delay_ = TimeDelta::Zero(); + jitter_delay_ = TimeDelta::Zero(); + current_delay_ = TimeDelta::Zero(); prev_frame_timestamp_ = 0; } -void VCMTiming::set_render_delay(int render_delay_ms) { +void VCMTiming::set_render_delay(TimeDelta render_delay) { MutexLock lock(&mutex_); - render_delay_ms_ = render_delay_ms; + render_delay_ = render_delay; } -void VCMTiming::set_min_playout_delay(int min_playout_delay_ms) { +void VCMTiming::set_min_playout_delay(TimeDelta min_playout_delay) { MutexLock lock(&mutex_); - min_playout_delay_ms_ = min_playout_delay_ms; + min_playout_delay_ = min_playout_delay; } -int VCMTiming::min_playout_delay() { +TimeDelta VCMTiming::min_playout_delay() { MutexLock lock(&mutex_); - return min_playout_delay_ms_; + return min_playout_delay_; } -void VCMTiming::set_max_playout_delay(int max_playout_delay_ms) { +void VCMTiming::set_max_playout_delay(TimeDelta max_playout_delay) { MutexLock lock(&mutex_); - max_playout_delay_ms_ = max_playout_delay_ms; + max_playout_delay_ = max_playout_delay; } -int VCMTiming::max_playout_delay() { +TimeDelta VCMTiming::max_playout_delay() { MutexLock lock(&mutex_); - return max_playout_delay_ms_; + return max_playout_delay_; } -void VCMTiming::SetJitterDelay(int jitter_delay_ms) { +void VCMTiming::SetJitterDelay(TimeDelta jitter_delay) { MutexLock lock(&mutex_); - if (jitter_delay_ms != jitter_delay_ms_) { - jitter_delay_ms_ = jitter_delay_ms; + if (jitter_delay != jitter_delay_) { + jitter_delay_ = jitter_delay; // When in initial state, set current delay to minimum delay. - if (current_delay_ms_ == 0) { - current_delay_ms_ = jitter_delay_ms_; + if (current_delay_.IsZero()) { + current_delay_ = jitter_delay_; } } } void VCMTiming::UpdateCurrentDelay(uint32_t frame_timestamp) { MutexLock lock(&mutex_); - int target_delay_ms = TargetDelayInternal(); + TimeDelta target_delay = TargetDelayInternal(); - if (current_delay_ms_ == 0) { + if (current_delay_.IsZero()) { // Not initialized, set current delay to target. - current_delay_ms_ = target_delay_ms; - } else if (target_delay_ms != current_delay_ms_) { - int64_t delay_diff_ms = - static_cast(target_delay_ms) - current_delay_ms_; + current_delay_ = target_delay; + } else if (target_delay != current_delay_) { + TimeDelta delay_diff = target_delay - current_delay_; // Never change the delay with more than 100 ms every second. If we're // changing the delay in too large steps we will get noticeable freezes. By // limiting the change we can increase the delay in smaller steps, which // will be experienced as the video is played in slow motion. When lowering // the delay the video will be played at a faster pace. - int64_t max_change_ms = 0; + TimeDelta max_change = TimeDelta::Zero(); if (frame_timestamp < 0x0000ffff && prev_frame_timestamp_ > 0xffff0000) { // wrap - max_change_ms = kDelayMaxChangeMsPerS * - (frame_timestamp + (static_cast(1) << 32) - - prev_frame_timestamp_) / - 90000; + max_change = + TimeDelta::Millis(kDelayMaxChangeMsPerS * + (frame_timestamp + (static_cast(1) << 32) - + prev_frame_timestamp_) / + 90000); } else { - max_change_ms = kDelayMaxChangeMsPerS * - (frame_timestamp - prev_frame_timestamp_) / 90000; + max_change = + TimeDelta::Millis(kDelayMaxChangeMsPerS * + (frame_timestamp - prev_frame_timestamp_) / 90000); } - if (max_change_ms <= 0) { + if (max_change <= TimeDelta::Zero()) { // Any changes less than 1 ms are truncated and will be postponed. // Negative change will be due to reordering and should be ignored. return; } - delay_diff_ms = std::max(delay_diff_ms, -max_change_ms); - delay_diff_ms = std::min(delay_diff_ms, max_change_ms); + delay_diff = std::max(delay_diff, -max_change); + delay_diff = std::min(delay_diff, max_change); - current_delay_ms_ = current_delay_ms_ + delay_diff_ms; + current_delay_ = current_delay_ + delay_diff; } prev_frame_timestamp_ = frame_timestamp; } -void VCMTiming::UpdateCurrentDelay(int64_t render_time_ms, - int64_t actual_decode_time_ms) { +void VCMTiming::UpdateCurrentDelay(Timestamp render_time, + Timestamp actual_decode_time) { MutexLock lock(&mutex_); - uint32_t target_delay_ms = TargetDelayInternal(); - int64_t delayed_ms = - actual_decode_time_ms - - (render_time_ms - RequiredDecodeTimeMs() - render_delay_ms_); - if (delayed_ms < 0) { + TimeDelta target_delay = TargetDelayInternal(); + TimeDelta delayed = + (actual_decode_time - render_time) + RequiredDecodeTime() + render_delay_; + if (delayed < TimeDelta::Zero()) { return; } - if (current_delay_ms_ + delayed_ms <= target_delay_ms) { - current_delay_ms_ += delayed_ms; + if (current_delay_ + delayed <= target_delay) { + current_delay_ += delayed; } else { - current_delay_ms_ = target_delay_ms; + current_delay_ = target_delay; } } -void VCMTiming::StopDecodeTimer(uint32_t /*time_stamp*/, - int32_t decode_time_ms, - int64_t now_ms, - int64_t /*render_time_ms*/) { - StopDecodeTimer(decode_time_ms, now_ms); -} - -void VCMTiming::StopDecodeTimer(int32_t decode_time_ms, int64_t now_ms) { +void VCMTiming::StopDecodeTimer(TimeDelta decode_time, Timestamp now) { MutexLock lock(&mutex_); - codec_timer_->AddTiming(decode_time_ms, now_ms); - RTC_DCHECK_GE(decode_time_ms, 0); + codec_timer_->AddTiming(decode_time.ms(), now.ms()); + RTC_DCHECK_GE(decode_time, TimeDelta::Zero()); ++num_decoded_frames_; } -void VCMTiming::IncomingTimestamp(uint32_t time_stamp, int64_t now_ms) { +void VCMTiming::IncomingTimestamp(uint32_t rtp_timestamp, Timestamp now) { MutexLock lock(&mutex_); - ts_extrapolator_->Update(now_ms, time_stamp); + ts_extrapolator_->Update(now, rtp_timestamp); } -int64_t VCMTiming::RenderTimeMs(uint32_t frame_timestamp, - int64_t now_ms) const { +Timestamp VCMTiming::RenderTime(uint32_t frame_timestamp, Timestamp now) const { MutexLock lock(&mutex_); - return RenderTimeMsInternal(frame_timestamp, now_ms); + return RenderTimeInternal(frame_timestamp, now); } void VCMTiming::SetLastDecodeScheduledTimestamp( - int64_t last_decode_scheduled_ts) { + Timestamp last_decode_scheduled) { MutexLock lock(&mutex_); - last_decode_scheduled_ts_ = last_decode_scheduled_ts; + last_decode_scheduled_ = last_decode_scheduled; } -int64_t VCMTiming::RenderTimeMsInternal(uint32_t frame_timestamp, - int64_t now_ms) const { - constexpr int kLowLatencyRendererMaxPlayoutDelayMs = 500; - if (min_playout_delay_ms_ == 0 && - (max_playout_delay_ms_ == 0 || +Timestamp VCMTiming::RenderTimeInternal(uint32_t frame_timestamp, + Timestamp now) const { + constexpr TimeDelta kLowLatencyRendererMaxPlayoutDelay = + TimeDelta::Millis(500); + if (min_playout_delay_.IsZero() && + (max_playout_delay_.IsZero() || (low_latency_renderer_enabled_ && - max_playout_delay_ms_ <= kLowLatencyRendererMaxPlayoutDelayMs))) { + max_playout_delay_ <= kLowLatencyRendererMaxPlayoutDelay))) { // Render as soon as possible or with low-latency renderer algorithm. - return 0; + return Timestamp::Zero(); } // Note that TimestampExtrapolator::ExtrapolateLocalTime is not a const // method; it mutates the object's wraparound state. - int64_t estimated_complete_time_ms = - ts_extrapolator_->ExtrapolateLocalTime(frame_timestamp); - if (estimated_complete_time_ms == -1) { - estimated_complete_time_ms = now_ms; - } - - // Make sure the actual delay stays in the range of `min_playout_delay_ms_` - // and `max_playout_delay_ms_`. - int actual_delay = std::max(current_delay_ms_, min_playout_delay_ms_); - actual_delay = std::min(actual_delay, max_playout_delay_ms_); - return estimated_complete_time_ms + actual_delay; + Timestamp estimated_complete_time = + ts_extrapolator_->ExtrapolateLocalTime(frame_timestamp).value_or(now); + + // Make sure the actual delay stays in the range of `min_playout_delay_` + // and `max_playout_delay_`. + TimeDelta actual_delay = + current_delay_.Clamped(min_playout_delay_, max_playout_delay_); + return estimated_complete_time + actual_delay; } -int VCMTiming::RequiredDecodeTimeMs() const { +TimeDelta VCMTiming::RequiredDecodeTime() const { const int decode_time_ms = codec_timer_->RequiredDecodeTimeMs(); RTC_DCHECK_GE(decode_time_ms, 0); - return decode_time_ms; + return TimeDelta::Millis(decode_time_ms); } -int64_t VCMTiming::MaxWaitingTime(int64_t render_time_ms, - int64_t now_ms, - bool too_many_frames_queued) const { +TimeDelta VCMTiming::MaxWaitingTime(Timestamp render_time, + Timestamp now, + bool too_many_frames_queued) const { MutexLock lock(&mutex_); - if (render_time_ms == 0 && zero_playout_delay_min_pacing_->us() > 0 && - min_playout_delay_ms_ == 0 && max_playout_delay_ms_ > 0) { - // `render_time_ms` == 0 indicates that the frame should be decoded and + if (render_time.IsZero() && zero_playout_delay_min_pacing_->us() > 0 && + min_playout_delay_.IsZero() && max_playout_delay_ > TimeDelta::Zero()) { + // `render_time` == 0 indicates that the frame should be decoded and // rendered as soon as possible. However, the decoder can be choked if too // many frames are sent at once. Therefore, limit the interframe delay to // |zero_playout_delay_min_pacing_| unless too many frames are queued in // which case the frames are sent to the decoder at once. if (too_many_frames_queued) { - return 0; + return TimeDelta::Zero(); } - int64_t earliest_next_decode_start_time = - last_decode_scheduled_ts_ + zero_playout_delay_min_pacing_->ms(); - int64_t max_wait_time_ms = now_ms >= earliest_next_decode_start_time - ? 0 - : earliest_next_decode_start_time - now_ms; - return max_wait_time_ms; + Timestamp earliest_next_decode_start_time = + last_decode_scheduled_ + zero_playout_delay_min_pacing_; + TimeDelta max_wait_time = now >= earliest_next_decode_start_time + ? TimeDelta::Zero() + : earliest_next_decode_start_time - now; + return max_wait_time; } - return render_time_ms - now_ms - RequiredDecodeTimeMs() - render_delay_ms_; + return render_time - now - RequiredDecodeTime() - render_delay_; } -int VCMTiming::TargetVideoDelay() const { +TimeDelta VCMTiming::TargetVideoDelay() const { MutexLock lock(&mutex_); return TargetDelayInternal(); } -int VCMTiming::TargetDelayInternal() const { - return std::max(min_playout_delay_ms_, - jitter_delay_ms_ + RequiredDecodeTimeMs() + render_delay_ms_); +TimeDelta VCMTiming::TargetDelayInternal() const { + return std::max(min_playout_delay_, + jitter_delay_ + RequiredDecodeTime() + render_delay_); } -bool VCMTiming::GetTimings(int* max_decode_ms, - int* current_delay_ms, - int* target_delay_ms, - int* jitter_buffer_ms, - int* min_playout_delay_ms, - int* render_delay_ms) const { +bool VCMTiming::GetTimings(TimeDelta* max_decode, + TimeDelta* current_delay, + TimeDelta* target_delay, + TimeDelta* jitter_buffer, + TimeDelta* min_playout_delay, + TimeDelta* render_delay) const { MutexLock lock(&mutex_); - *max_decode_ms = RequiredDecodeTimeMs(); - *current_delay_ms = current_delay_ms_; - *target_delay_ms = TargetDelayInternal(); - *jitter_buffer_ms = jitter_delay_ms_; - *min_playout_delay_ms = min_playout_delay_ms_; - *render_delay_ms = render_delay_ms_; + *max_decode = RequiredDecodeTime(); + *current_delay = current_delay_; + *target_delay = TargetDelayInternal(); + *jitter_buffer = jitter_delay_; + *min_playout_delay = min_playout_delay_; + *render_delay = render_delay_; return (num_decoded_frames_ > 0); } diff --git a/modules/video_coding/timing.h b/modules/video_coding/timing.h index 07c12e919a..8ab2f685ec 100644 --- a/modules/video_coding/timing.h +++ b/modules/video_coding/timing.h @@ -29,6 +29,9 @@ class TimestampExtrapolator; class VCMTiming { public: + static constexpr auto kDefaultRenderDelay = TimeDelta::Millis(10); + static constexpr auto kDelayMaxChangeMsPerS = 100; + explicit VCMTiming(Clock* clock); virtual ~VCMTiming() = default; @@ -36,19 +39,19 @@ class VCMTiming { void Reset(); // Set the amount of time needed to render an image. Defaults to 10 ms. - void set_render_delay(int render_delay_ms); + void set_render_delay(TimeDelta render_delay); // Set the minimum time the video must be delayed on the receiver to // get the desired jitter buffer level. - void SetJitterDelay(int required_delay_ms); + void SetJitterDelay(TimeDelta required_delay); - // Set/get the minimum playout delay from capture to render in ms. - void set_min_playout_delay(int min_playout_delay_ms); - int min_playout_delay(); + // Set/get the minimum playout delay from capture to render. + void set_min_playout_delay(TimeDelta min_playout_delay); + TimeDelta min_playout_delay(); // Set/get the maximum playout delay from capture to render in ms. - void set_max_playout_delay(int max_playout_delay_ms); - int max_playout_delay(); + void set_max_playout_delay(TimeDelta max_playout_delay); + TimeDelta max_playout_delay(); // Increases or decreases the current delay to get closer to the target delay. // Calculates how long it has been since the previous call to this function, @@ -59,51 +62,44 @@ class VCMTiming { // Given the actual decode time in ms and the render time in ms for a frame, // this function calculates how late the frame is and increases the delay // accordingly. - void UpdateCurrentDelay(int64_t render_time_ms, - int64_t actual_decode_time_ms); + void UpdateCurrentDelay(Timestamp render_time, Timestamp actual_decode_time); // Stops the decoder timer, should be called when the decoder returns a frame // or when the decoded frame callback is called. - void StopDecodeTimer(int32_t decode_time_ms, int64_t now_ms); - // TODO(kron): Remove once downstream projects has been changed to use the - // above function. - void StopDecodeTimer(uint32_t time_stamp, - int32_t decode_time_ms, - int64_t now_ms, - int64_t render_time_ms); + void StopDecodeTimer(TimeDelta decode_time, Timestamp now); // Used to report that a frame is passed to decoding. Updates the timestamp // filter which is used to map between timestamps and receiver system time. - void IncomingTimestamp(uint32_t time_stamp, int64_t last_packet_time_ms); + void IncomingTimestamp(uint32_t rtp_timestamp, Timestamp last_packet_time); // Returns the receiver system time when the frame with timestamp // `frame_timestamp` should be rendered, assuming that the system time - // currently is `now_ms`. - virtual int64_t RenderTimeMs(uint32_t frame_timestamp, int64_t now_ms) const; + // currently is `now`. + virtual Timestamp RenderTime(uint32_t frame_timestamp, Timestamp now) const; // Returns the maximum time in ms that we can wait for a frame to become - // complete before we must pass it to the decoder. render_time_ms==0 indicates + // complete before we must pass it to the decoder. render_time==0 indicates // that the frames should be processed as quickly as possible, with possibly // only a small delay added to make sure that the decoder is not overloaded. // In this case, the parameter too_many_frames_queued is used to signal that // the decode queue is full and that the frame should be decoded as soon as // possible. - virtual int64_t MaxWaitingTime(int64_t render_time_ms, - int64_t now_ms, - bool too_many_frames_queued) const; + virtual TimeDelta MaxWaitingTime(Timestamp render_time, + Timestamp now, + bool too_many_frames_queued) const; // Returns the current target delay which is required delay + decode time + // render delay. - int TargetVideoDelay() const; + TimeDelta TargetVideoDelay() const; // Return current timing information. Returns true if the first frame has been // decoded, false otherwise. - virtual bool GetTimings(int* max_decode_ms, - int* current_delay_ms, - int* target_delay_ms, - int* jitter_buffer_ms, - int* min_playout_delay_ms, - int* render_delay_ms) const; + virtual bool GetTimings(TimeDelta* max_decode, + TimeDelta* current_delay, + TimeDelta* target_delay, + TimeDelta* jitter_buffer, + TimeDelta* min_playout_delay, + TimeDelta* render_delay) const; void SetTimingFrameInfo(const TimingFrameInfo& info); absl::optional GetTimingFrameInfo(); @@ -113,16 +109,13 @@ class VCMTiming { absl::optional MaxCompositionDelayInFrames() const; // Updates the last time a frame was scheduled for decoding. - void SetLastDecodeScheduledTimestamp(int64_t last_decode_scheduled_ts); - - enum { kDefaultRenderDelayMs = 10 }; - enum { kDelayMaxChangeMsPerS = 100 }; + void SetLastDecodeScheduledTimestamp(Timestamp last_decode_scheduled); protected: - int RequiredDecodeTimeMs() const RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_); - int64_t RenderTimeMsInternal(uint32_t frame_timestamp, int64_t now_ms) const + TimeDelta RequiredDecodeTime() const RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_); + Timestamp RenderTimeInternal(uint32_t frame_timestamp, Timestamp now) const RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_); - int TargetDelayInternal() const RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_); + TimeDelta TargetDelayInternal() const RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_); private: mutable Mutex mutex_; @@ -131,16 +124,16 @@ class VCMTiming { RTC_PT_GUARDED_BY(mutex_); std::unique_ptr codec_timer_ RTC_GUARDED_BY(mutex_) RTC_PT_GUARDED_BY(mutex_); - int render_delay_ms_ RTC_GUARDED_BY(mutex_); + TimeDelta render_delay_ RTC_GUARDED_BY(mutex_); // Best-effort playout delay range for frames from capture to render. // The receiver tries to keep the delay between `min_playout_delay_ms_` // and `max_playout_delay_ms_` taking the network jitter into account. // A special case is where min_playout_delay_ms_ = max_playout_delay_ms_ = 0, // in which case the receiver tries to play the frames as they arrive. - int min_playout_delay_ms_ RTC_GUARDED_BY(mutex_); - int max_playout_delay_ms_ RTC_GUARDED_BY(mutex_); - int jitter_delay_ms_ RTC_GUARDED_BY(mutex_); - int current_delay_ms_ RTC_GUARDED_BY(mutex_); + TimeDelta min_playout_delay_ RTC_GUARDED_BY(mutex_); + TimeDelta max_playout_delay_ RTC_GUARDED_BY(mutex_); + TimeDelta jitter_delay_ RTC_GUARDED_BY(mutex_); + TimeDelta current_delay_ RTC_GUARDED_BY(mutex_); uint32_t prev_frame_timestamp_ RTC_GUARDED_BY(mutex_); absl::optional timing_frame_info_ RTC_GUARDED_BY(mutex_); size_t num_decoded_frames_ RTC_GUARDED_BY(mutex_); @@ -158,7 +151,7 @@ class VCMTiming { // Timestamp at which the last frame was scheduled to be sent to the decoder. // Used only when the RTP header extension playout delay is set to min=0 ms // which is indicated by a render time set to 0. - int64_t last_decode_scheduled_ts_ RTC_GUARDED_BY(mutex_); + Timestamp last_decode_scheduled_ RTC_GUARDED_BY(mutex_); }; } // namespace webrtc diff --git a/modules/video_coding/timing_unittest.cc b/modules/video_coding/timing_unittest.cc index 71de1fe3da..1f5c12f7f4 100644 --- a/modules/video_coding/timing_unittest.cc +++ b/modules/video_coding/timing_unittest.cc @@ -10,13 +10,18 @@ #include "modules/video_coding/timing.h" +#include "api/units/frequency.h" +#include "api/units/time_delta.h" #include "system_wrappers/include/clock.h" #include "test/field_trial.h" #include "test/gtest.h" namespace webrtc { namespace { -const int kFps = 25; + +constexpr Frequency k25Fps = Frequency::Hertz(25); +constexpr Frequency k90kHz = Frequency::KiloHertz(90); + } // namespace TEST(ReceiverTimingTest, JitterDelay) { @@ -29,102 +34,105 @@ TEST(ReceiverTimingTest, JitterDelay) { timing.Reset(); - timing.IncomingTimestamp(timestamp, clock.TimeInMilliseconds()); - uint32_t jitter_delay_ms = 20; - timing.SetJitterDelay(jitter_delay_ms); + timing.IncomingTimestamp(timestamp, clock.CurrentTime()); + TimeDelta jitter_delay = TimeDelta::Millis(20); + timing.SetJitterDelay(jitter_delay); timing.UpdateCurrentDelay(timestamp); - timing.set_render_delay(0); - uint32_t wait_time_ms = timing.MaxWaitingTime( - timing.RenderTimeMs(timestamp, clock.TimeInMilliseconds()), - clock.TimeInMilliseconds(), /*too_many_frames_queued=*/false); + timing.set_render_delay(TimeDelta::Zero()); + auto wait_time = timing.MaxWaitingTime( + timing.RenderTime(timestamp, clock.CurrentTime()), clock.CurrentTime(), + /*too_many_frames_queued=*/false); // First update initializes the render time. Since we have no decode delay - // we get wait_time_ms = renderTime - now - renderDelay = jitter. - EXPECT_EQ(jitter_delay_ms, wait_time_ms); + // we get wait_time = renderTime - now - renderDelay = jitter. + EXPECT_EQ(jitter_delay, wait_time); - jitter_delay_ms += VCMTiming::kDelayMaxChangeMsPerS + 10; + jitter_delay += TimeDelta::Millis(VCMTiming::kDelayMaxChangeMsPerS + 10); timestamp += 90000; clock.AdvanceTimeMilliseconds(1000); - timing.SetJitterDelay(jitter_delay_ms); + timing.SetJitterDelay(jitter_delay); timing.UpdateCurrentDelay(timestamp); - wait_time_ms = timing.MaxWaitingTime( - timing.RenderTimeMs(timestamp, clock.TimeInMilliseconds()), - clock.TimeInMilliseconds(), /*too_many_frames_queued=*/false); + wait_time = timing.MaxWaitingTime( + timing.RenderTime(timestamp, clock.CurrentTime()), clock.CurrentTime(), + /*too_many_frames_queued=*/false); // Since we gradually increase the delay we only get 100 ms every second. - EXPECT_EQ(jitter_delay_ms - 10, wait_time_ms); + EXPECT_EQ(jitter_delay - TimeDelta::Millis(10), wait_time); timestamp += 90000; clock.AdvanceTimeMilliseconds(1000); timing.UpdateCurrentDelay(timestamp); - wait_time_ms = timing.MaxWaitingTime( - timing.RenderTimeMs(timestamp, clock.TimeInMilliseconds()), - clock.TimeInMilliseconds(), /*too_many_frames_queued=*/false); - EXPECT_EQ(jitter_delay_ms, wait_time_ms); + wait_time = timing.MaxWaitingTime( + timing.RenderTime(timestamp, clock.CurrentTime()), clock.CurrentTime(), + /*too_many_frames_queued=*/false); + EXPECT_EQ(jitter_delay, wait_time); // Insert frames without jitter, verify that this gives the exact wait time. const int kNumFrames = 300; for (int i = 0; i < kNumFrames; i++) { - clock.AdvanceTimeMilliseconds(1000 / kFps); - timestamp += 90000 / kFps; - timing.IncomingTimestamp(timestamp, clock.TimeInMilliseconds()); + clock.AdvanceTime(1 / k25Fps); + timestamp += k90kHz / k25Fps; + timing.IncomingTimestamp(timestamp, clock.CurrentTime()); } timing.UpdateCurrentDelay(timestamp); - wait_time_ms = timing.MaxWaitingTime( - timing.RenderTimeMs(timestamp, clock.TimeInMilliseconds()), - clock.TimeInMilliseconds(), /*too_many_frames_queued=*/false); - EXPECT_EQ(jitter_delay_ms, wait_time_ms); + wait_time = timing.MaxWaitingTime( + timing.RenderTime(timestamp, clock.CurrentTime()), clock.CurrentTime(), + /*too_many_frames_queued=*/false); + EXPECT_EQ(jitter_delay, wait_time); // Add decode time estimates for 1 second. - const uint32_t kDecodeTimeMs = 10; - for (int i = 0; i < kFps; i++) { - clock.AdvanceTimeMilliseconds(kDecodeTimeMs); - timing.StopDecodeTimer(kDecodeTimeMs, clock.TimeInMilliseconds()); - timestamp += 90000 / kFps; - clock.AdvanceTimeMilliseconds(1000 / kFps - kDecodeTimeMs); - timing.IncomingTimestamp(timestamp, clock.TimeInMilliseconds()); + const TimeDelta kDecodeTime = TimeDelta::Millis(10); + for (int i = 0; i < k25Fps.hertz(); i++) { + clock.AdvanceTime(kDecodeTime); + timing.StopDecodeTimer(kDecodeTime, clock.CurrentTime()); + timestamp += k90kHz / k25Fps; + clock.AdvanceTime(1 / k25Fps - kDecodeTime); + timing.IncomingTimestamp(timestamp, clock.CurrentTime()); } timing.UpdateCurrentDelay(timestamp); - wait_time_ms = timing.MaxWaitingTime( - timing.RenderTimeMs(timestamp, clock.TimeInMilliseconds()), - clock.TimeInMilliseconds(), /*too_many_frames_queued=*/false); - EXPECT_EQ(jitter_delay_ms, wait_time_ms); + wait_time = timing.MaxWaitingTime( + timing.RenderTime(timestamp, clock.CurrentTime()), clock.CurrentTime(), + /*too_many_frames_queued=*/false); + EXPECT_EQ(jitter_delay, wait_time); - const int kMinTotalDelayMs = 200; - timing.set_min_playout_delay(kMinTotalDelayMs); + const TimeDelta kMinTotalDelay = TimeDelta::Millis(200); + timing.set_min_playout_delay(kMinTotalDelay); clock.AdvanceTimeMilliseconds(5000); timestamp += 5 * 90000; timing.UpdateCurrentDelay(timestamp); - const int kRenderDelayMs = 10; - timing.set_render_delay(kRenderDelayMs); - wait_time_ms = timing.MaxWaitingTime( - timing.RenderTimeMs(timestamp, clock.TimeInMilliseconds()), - clock.TimeInMilliseconds(), /*too_many_frames_queued=*/false); + const TimeDelta kRenderDelay = TimeDelta::Millis(10); + timing.set_render_delay(kRenderDelay); + wait_time = timing.MaxWaitingTime( + timing.RenderTime(timestamp, clock.CurrentTime()), clock.CurrentTime(), + /*too_many_frames_queued=*/false); // We should at least have kMinTotalDelayMs - decodeTime (10) - renderTime // (10) to wait. - EXPECT_EQ(kMinTotalDelayMs - kDecodeTimeMs - kRenderDelayMs, wait_time_ms); + EXPECT_EQ(kMinTotalDelay - kDecodeTime - kRenderDelay, wait_time); // The total video delay should be equal to the min total delay. - EXPECT_EQ(kMinTotalDelayMs, timing.TargetVideoDelay()); + EXPECT_EQ(kMinTotalDelay, timing.TargetVideoDelay()); // Reset playout delay. - timing.set_min_playout_delay(0); + timing.set_min_playout_delay(TimeDelta::Zero()); clock.AdvanceTimeMilliseconds(5000); timestamp += 5 * 90000; timing.UpdateCurrentDelay(timestamp); } TEST(ReceiverTimingTest, TimestampWrapAround) { - SimulatedClock clock(0); + constexpr auto kStartTime = Timestamp::Millis(1337); + SimulatedClock clock(kStartTime); VCMTiming timing(&clock); + // Provoke a wrap-around. The fifth frame will have wrapped at 25 fps. - uint32_t timestamp = 0xFFFFFFFFu - 3 * 90000 / kFps; + constexpr uint32_t kRtpTicksPerFrame = k90kHz / k25Fps; + uint32_t timestamp = 0xFFFFFFFFu - 3 * kRtpTicksPerFrame; for (int i = 0; i < 5; ++i) { - timing.IncomingTimestamp(timestamp, clock.TimeInMilliseconds()); - clock.AdvanceTimeMilliseconds(1000 / kFps); - timestamp += 90000 / kFps; - EXPECT_EQ(3 * 1000 / kFps, - timing.RenderTimeMs(0xFFFFFFFFu, clock.TimeInMilliseconds())); - EXPECT_EQ(3 * 1000 / kFps + 1, - timing.RenderTimeMs(89u, // One ms later in 90 kHz. - clock.TimeInMilliseconds())); + timing.IncomingTimestamp(timestamp, clock.CurrentTime()); + clock.AdvanceTime(1 / k25Fps); + timestamp += kRtpTicksPerFrame; + EXPECT_EQ(kStartTime + 3 / k25Fps, + timing.RenderTime(0xFFFFFFFFu, clock.CurrentTime())); + // One ms later in 90 kHz. + EXPECT_EQ(kStartTime + 3 / k25Fps + TimeDelta::Millis(1), + timing.RenderTime(89u, clock.CurrentTime())); } } @@ -132,85 +140,85 @@ TEST(ReceiverTimingTest, MaxWaitingTimeIsZeroForZeroRenderTime) { // This is the default path when the RTP playout delay header extension is set // to min==0 and max==0. constexpr int64_t kStartTimeUs = 3.15e13; // About one year in us. - constexpr int64_t kTimeDeltaMs = 1000.0 / 60.0; - constexpr int64_t kZeroRenderTimeMs = 0; + constexpr TimeDelta kTimeDelta = 1 / Frequency::Hertz(60); + constexpr Timestamp kZeroRenderTime = Timestamp::Zero(); SimulatedClock clock(kStartTimeUs); VCMTiming timing(&clock); timing.Reset(); - timing.set_max_playout_delay(0); + timing.set_max_playout_delay(TimeDelta::Zero()); for (int i = 0; i < 10; ++i) { - clock.AdvanceTimeMilliseconds(kTimeDeltaMs); - int64_t now_ms = clock.TimeInMilliseconds(); - EXPECT_LT(timing.MaxWaitingTime(kZeroRenderTimeMs, now_ms, + clock.AdvanceTime(kTimeDelta); + Timestamp now = clock.CurrentTime(); + EXPECT_LT(timing.MaxWaitingTime(kZeroRenderTime, now, /*too_many_frames_queued=*/false), - 0); + TimeDelta::Zero()); } // Another frame submitted at the same time also returns a negative max // waiting time. - int64_t now_ms = clock.TimeInMilliseconds(); - EXPECT_LT(timing.MaxWaitingTime(kZeroRenderTimeMs, now_ms, + Timestamp now = clock.CurrentTime(); + EXPECT_LT(timing.MaxWaitingTime(kZeroRenderTime, now, /*too_many_frames_queued=*/false), - 0); + TimeDelta::Zero()); // MaxWaitingTime should be less than zero even if there's a burst of frames. - EXPECT_LT(timing.MaxWaitingTime(kZeroRenderTimeMs, now_ms, + EXPECT_LT(timing.MaxWaitingTime(kZeroRenderTime, now, /*too_many_frames_queued=*/false), - 0); - EXPECT_LT(timing.MaxWaitingTime(kZeroRenderTimeMs, now_ms, + TimeDelta::Zero()); + EXPECT_LT(timing.MaxWaitingTime(kZeroRenderTime, now, /*too_many_frames_queued=*/false), - 0); - EXPECT_LT(timing.MaxWaitingTime(kZeroRenderTimeMs, now_ms, + TimeDelta::Zero()); + EXPECT_LT(timing.MaxWaitingTime(kZeroRenderTime, now, /*too_many_frames_queued=*/false), - 0); + TimeDelta::Zero()); } TEST(ReceiverTimingTest, MaxWaitingTimeZeroDelayPacingExperiment) { // The minimum pacing is enabled by a field trial and active if the RTP // playout delay header extension is set to min==0. - constexpr int64_t kMinPacingMs = 3; + constexpr TimeDelta kMinPacing = TimeDelta::Millis(3); test::ScopedFieldTrials override_field_trials( "WebRTC-ZeroPlayoutDelay/min_pacing:3ms/"); constexpr int64_t kStartTimeUs = 3.15e13; // About one year in us. - constexpr int64_t kTimeDeltaMs = 1000.0 / 60.0; - constexpr int64_t kZeroRenderTimeMs = 0; + constexpr TimeDelta kTimeDelta = 1 / Frequency::Hertz(60); + constexpr auto kZeroRenderTime = Timestamp::Zero(); SimulatedClock clock(kStartTimeUs); VCMTiming timing(&clock); timing.Reset(); // MaxWaitingTime() returns zero for evenly spaced video frames. for (int i = 0; i < 10; ++i) { - clock.AdvanceTimeMilliseconds(kTimeDeltaMs); - int64_t now_ms = clock.TimeInMilliseconds(); - EXPECT_EQ(timing.MaxWaitingTime(kZeroRenderTimeMs, now_ms, + clock.AdvanceTime(kTimeDelta); + Timestamp now = clock.CurrentTime(); + EXPECT_EQ(timing.MaxWaitingTime(kZeroRenderTime, now, /*too_many_frames_queued=*/false), - 0); - timing.SetLastDecodeScheduledTimestamp(now_ms); + TimeDelta::Zero()); + timing.SetLastDecodeScheduledTimestamp(now); } // Another frame submitted at the same time is paced according to the field // trial setting. - int64_t now_ms = clock.TimeInMilliseconds(); - EXPECT_EQ(timing.MaxWaitingTime(kZeroRenderTimeMs, now_ms, + auto now = clock.CurrentTime(); + EXPECT_EQ(timing.MaxWaitingTime(kZeroRenderTime, now, /*too_many_frames_queued=*/false), - kMinPacingMs); + kMinPacing); // If there's a burst of frames, the wait time is calculated based on next // decode time. - EXPECT_EQ(timing.MaxWaitingTime(kZeroRenderTimeMs, now_ms, + EXPECT_EQ(timing.MaxWaitingTime(kZeroRenderTime, now, /*too_many_frames_queued=*/false), - kMinPacingMs); - EXPECT_EQ(timing.MaxWaitingTime(kZeroRenderTimeMs, now_ms, + kMinPacing); + EXPECT_EQ(timing.MaxWaitingTime(kZeroRenderTime, now, /*too_many_frames_queued=*/false), - kMinPacingMs); + kMinPacing); // Allow a few ms to pass, this should be subtracted from the MaxWaitingTime. - constexpr int64_t kTwoMs = 2; - clock.AdvanceTimeMilliseconds(kTwoMs); - now_ms = clock.TimeInMilliseconds(); - EXPECT_EQ(timing.MaxWaitingTime(kZeroRenderTimeMs, now_ms, + constexpr TimeDelta kTwoMs = TimeDelta::Millis(2); + clock.AdvanceTime(kTwoMs); + now = clock.CurrentTime(); + EXPECT_EQ(timing.MaxWaitingTime(kZeroRenderTime, now, /*too_many_frames_queued=*/false), - kMinPacingMs - kTwoMs); + kMinPacing - kTwoMs); // A frame is decoded at the current time, the wait time should be restored to // pacing delay. - timing.SetLastDecodeScheduledTimestamp(now_ms); - EXPECT_EQ(timing.MaxWaitingTime(kZeroRenderTimeMs, now_ms, + timing.SetLastDecodeScheduledTimestamp(now); + EXPECT_EQ(timing.MaxWaitingTime(kZeroRenderTime, now, /*too_many_frames_queued=*/false), - kMinPacingMs); + kMinPacing); } TEST(ReceiverTimingTest, DefaultMaxWaitingTimeUnaffectedByPacingExperiment) { @@ -219,65 +227,65 @@ TEST(ReceiverTimingTest, DefaultMaxWaitingTimeUnaffectedByPacingExperiment) { test::ScopedFieldTrials override_field_trials( "WebRTC-ZeroPlayoutDelay/min_pacing:3ms/"); constexpr int64_t kStartTimeUs = 3.15e13; // About one year in us. - constexpr int64_t kTimeDeltaMs = 1000.0 / 60.0; + const TimeDelta kTimeDelta = TimeDelta::Millis(1000.0 / 60.0); SimulatedClock clock(kStartTimeUs); VCMTiming timing(&clock); timing.Reset(); - clock.AdvanceTimeMilliseconds(kTimeDeltaMs); - int64_t now_ms = clock.TimeInMilliseconds(); - int64_t render_time_ms = now_ms + 30; + clock.AdvanceTime(kTimeDelta); + auto now = clock.CurrentTime(); + Timestamp render_time = now + TimeDelta::Millis(30); // Estimate the internal processing delay from the first frame. - int64_t estimated_processing_delay = - (render_time_ms - now_ms) - - timing.MaxWaitingTime(render_time_ms, now_ms, + TimeDelta estimated_processing_delay = + (render_time - now) - + timing.MaxWaitingTime(render_time, now, /*too_many_frames_queued=*/false); - EXPECT_GT(estimated_processing_delay, 0); + EXPECT_GT(estimated_processing_delay, TimeDelta::Zero()); // Any other frame submitted at the same time should be scheduled according to // its render time. for (int i = 0; i < 5; ++i) { - render_time_ms += kTimeDeltaMs; - EXPECT_EQ(timing.MaxWaitingTime(render_time_ms, now_ms, + render_time += kTimeDelta; + EXPECT_EQ(timing.MaxWaitingTime(render_time, now, /*too_many_frames_queued=*/false), - render_time_ms - now_ms - estimated_processing_delay); + render_time - now - estimated_processing_delay); } } -TEST(ReceiverTiminTest, MaxWaitingTimeReturnsZeroIfTooManyFramesQueuedIsTrue) { +TEST(ReceiverTimingTest, MaxWaitingTimeReturnsZeroIfTooManyFramesQueuedIsTrue) { // The minimum pacing is enabled by a field trial and active if the RTP // playout delay header extension is set to min==0. - constexpr int64_t kMinPacingMs = 3; + constexpr TimeDelta kMinPacing = TimeDelta::Millis(3); test::ScopedFieldTrials override_field_trials( "WebRTC-ZeroPlayoutDelay/min_pacing:3ms/"); constexpr int64_t kStartTimeUs = 3.15e13; // About one year in us. - constexpr int64_t kTimeDeltaMs = 1000.0 / 60.0; - constexpr int64_t kZeroRenderTimeMs = 0; + const TimeDelta kTimeDelta = TimeDelta::Millis(1000.0 / 60.0); + constexpr auto kZeroRenderTime = Timestamp::Zero(); SimulatedClock clock(kStartTimeUs); VCMTiming timing(&clock); timing.Reset(); // MaxWaitingTime() returns zero for evenly spaced video frames. for (int i = 0; i < 10; ++i) { - clock.AdvanceTimeMilliseconds(kTimeDeltaMs); - int64_t now_ms = clock.TimeInMilliseconds(); - EXPECT_EQ(timing.MaxWaitingTime(kZeroRenderTimeMs, now_ms, + clock.AdvanceTime(kTimeDelta); + auto now = clock.CurrentTime(); + EXPECT_EQ(timing.MaxWaitingTime(kZeroRenderTime, now, /*too_many_frames_queued=*/false), - 0); - timing.SetLastDecodeScheduledTimestamp(now_ms); + TimeDelta::Zero()); + timing.SetLastDecodeScheduledTimestamp(now); } // Another frame submitted at the same time is paced according to the field // trial setting. - int64_t now_ms = clock.TimeInMilliseconds(); - EXPECT_EQ(timing.MaxWaitingTime(kZeroRenderTimeMs, now_ms, + auto now_ms = clock.CurrentTime(); + EXPECT_EQ(timing.MaxWaitingTime(kZeroRenderTime, now_ms, /*too_many_frames_queued=*/false), - kMinPacingMs); + kMinPacing); // MaxWaitingTime returns 0 even if there's a burst of frames if // too_many_frames_queued is set to true. - EXPECT_EQ(timing.MaxWaitingTime(kZeroRenderTimeMs, now_ms, + EXPECT_EQ(timing.MaxWaitingTime(kZeroRenderTime, now_ms, /*too_many_frames_queued=*/true), - 0); - EXPECT_EQ(timing.MaxWaitingTime(kZeroRenderTimeMs, now_ms, + TimeDelta::Zero()); + EXPECT_EQ(timing.MaxWaitingTime(kZeroRenderTime, now_ms, /*too_many_frames_queued=*/true), - 0); + TimeDelta::Zero()); } } // namespace webrtc diff --git a/modules/video_coding/video_receiver.cc b/modules/video_coding/video_receiver.cc index 079de6de14..055d524a58 100644 --- a/modules/video_coding/video_receiver.cc +++ b/modules/video_coding/video_receiver.cc @@ -203,8 +203,9 @@ int32_t VideoReceiver::Decode(uint16_t maxWaitTimeMs) { } // If this frame was too late, we should adjust the delay accordingly - _timing->UpdateCurrentDelay(frame->RenderTimeMs(), - clock_->TimeInMilliseconds()); + if (frame->RenderTimeMs() > 0) + _timing->UpdateCurrentDelay(Timestamp::Millis(frame->RenderTimeMs()), + clock_->CurrentTime()); if (first_frame_received_()) { RTC_LOG(LS_INFO) << "Received first complete decodable video frame"; diff --git a/rtc_base/time/BUILD.gn b/rtc_base/time/BUILD.gn index 9a1d99b610..890695dfeb 100644 --- a/rtc_base/time/BUILD.gn +++ b/rtc_base/time/BUILD.gn @@ -17,4 +17,6 @@ rtc_library("timestamp_extrapolator") { "timestamp_extrapolator.cc", "timestamp_extrapolator.h", ] + deps = [ "../../api/units:timestamp" ] + absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } diff --git a/rtc_base/time/timestamp_extrapolator.cc b/rtc_base/time/timestamp_extrapolator.cc index 99445284dc..521b5ba4c4 100644 --- a/rtc_base/time/timestamp_extrapolator.cc +++ b/rtc_base/time/timestamp_extrapolator.cc @@ -12,10 +12,13 @@ #include +#include "absl/types/optional.h" + namespace webrtc { -TimestampExtrapolator::TimestampExtrapolator(int64_t start_ms) - : _startMs(0), +TimestampExtrapolator::TimestampExtrapolator(Timestamp start) + : _start(Timestamp::Zero()), + _prev(Timestamp::Zero()), _firstTimestamp(0), _wrapArounds(0), _prevUnwrappedTimestamp(-1), @@ -30,12 +33,12 @@ TimestampExtrapolator::TimestampExtrapolator(int64_t start_ms) _accDrift(6600), // in timestamp ticks, i.e. 15 ms _accMaxError(7000), _pP11(1e10) { - Reset(start_ms); + Reset(start); } -void TimestampExtrapolator::Reset(int64_t start_ms) { - _startMs = start_ms; - _prevMs = _startMs; +void TimestampExtrapolator::Reset(Timestamp start) { + _start = start; + _prev = _start; _firstTimestamp = 0; _w[0] = 90.0; _w[1] = 0; @@ -51,17 +54,18 @@ void TimestampExtrapolator::Reset(int64_t start_ms) { _detectorAccumulatorNeg = 0; } -void TimestampExtrapolator::Update(int64_t tMs, uint32_t ts90khz) { - if (tMs - _prevMs > 10e3) { +void TimestampExtrapolator::Update(Timestamp now, uint32_t ts90khz) { + if (now - _prev > TimeDelta::Seconds(10)) { // Ten seconds without a complete frame. // Reset the extrapolator - Reset(tMs); + Reset(now); } else { - _prevMs = tMs; + _prev = now; } // Remove offset to prevent badly scaled matrices - tMs -= _startMs; + const TimeDelta offset = now - _start; + double tMs = offset.ms(); CheckForWrapArounds(ts90khz); @@ -79,7 +83,7 @@ void TimestampExtrapolator::Update(int64_t tMs, uint32_t ts90khz) { } double residual = (static_cast(unwrapped_ts90khz) - _firstTimestamp) - - static_cast(tMs) * _w[0] - _w[1]; + tMs * _w[0] - _w[1]; if (DelayChangeDetection(residual) && _packetCount >= _startUpFilterDelayInPackets) { // A sudden change of average network delay has been detected. @@ -123,32 +127,28 @@ void TimestampExtrapolator::Update(int64_t tMs, uint32_t ts90khz) { } } -int64_t TimestampExtrapolator::ExtrapolateLocalTime(uint32_t timestamp90khz) { - int64_t localTimeMs = 0; +absl::optional TimestampExtrapolator::ExtrapolateLocalTime( + uint32_t timestamp90khz) { CheckForWrapArounds(timestamp90khz); double unwrapped_ts90khz = static_cast(timestamp90khz) + _wrapArounds * ((static_cast(1) << 32) - 1); if (_packetCount == 0) { - localTimeMs = -1; + return absl::nullopt; } else if (_packetCount < _startUpFilterDelayInPackets) { - localTimeMs = - _prevMs + - static_cast( - static_cast(unwrapped_ts90khz - _prevUnwrappedTimestamp) / - 90.0 + - 0.5); + auto diffMs = static_cast( + static_cast(unwrapped_ts90khz - _prevUnwrappedTimestamp) / + 90.0 + + 0.5); + return _prev + TimeDelta::Millis(diffMs); + } else if (_w[0] < 1e-3) { + return _start; } else { - if (_w[0] < 1e-3) { - localTimeMs = _startMs; - } else { - double timestampDiff = - unwrapped_ts90khz - static_cast(_firstTimestamp); - localTimeMs = static_cast(static_cast(_startMs) + - (timestampDiff - _w[1]) / _w[0] + 0.5); - } + double timestampDiff = + unwrapped_ts90khz - static_cast(_firstTimestamp); + auto diffMs = static_cast((timestampDiff - _w[1]) / _w[0] + 0.5); + return _start + TimeDelta::Millis(diffMs); } - return localTimeMs; } // Investigates if the timestamp clock has overflowed since the last timestamp diff --git a/rtc_base/time/timestamp_extrapolator.h b/rtc_base/time/timestamp_extrapolator.h index b325d2cbaa..df56eea986 100644 --- a/rtc_base/time/timestamp_extrapolator.h +++ b/rtc_base/time/timestamp_extrapolator.h @@ -13,23 +13,26 @@ #include +#include "absl/types/optional.h" +#include "api/units/timestamp.h" + namespace webrtc { // Not thread safe. class TimestampExtrapolator { public: - explicit TimestampExtrapolator(int64_t start_ms); - void Update(int64_t tMs, uint32_t ts90khz); - int64_t ExtrapolateLocalTime(uint32_t timestamp90khz); - void Reset(int64_t start_ms); + explicit TimestampExtrapolator(Timestamp start); + void Update(Timestamp now, uint32_t ts90khz); + absl::optional ExtrapolateLocalTime(uint32_t timestamp90khz); + void Reset(Timestamp start); private: void CheckForWrapArounds(uint32_t ts90khz); bool DelayChangeDetection(double error); double _w[2]; double _pP[2][2]; - int64_t _startMs; - int64_t _prevMs; + Timestamp _start; + Timestamp _prev; uint32_t _firstTimestamp; int32_t _wrapArounds; int64_t _prevUnwrappedTimestamp; diff --git a/video/frame_buffer_proxy.cc b/video/frame_buffer_proxy.cc index 31aa86f7ab..d277a368ef 100644 --- a/video/frame_buffer_proxy.cc +++ b/video/frame_buffer_proxy.cc @@ -148,7 +148,7 @@ struct FrameMetadata { contentType(frame.contentType()), delayed_by_retransmission(frame.delayed_by_retransmission()), rtp_timestamp(frame.Timestamp()), - receive_time(frame.ReceivedTime()) {} + receive_time_ms(frame.ReceivedTime()) {} const bool is_last_spatial_layer; const bool is_keyframe; @@ -156,7 +156,7 @@ struct FrameMetadata { const VideoContentType contentType; const bool delayed_by_retransmission; const uint32_t rtp_timestamp; - const int64_t receive_time; + const int64_t receive_time_ms; }; // Encapsulates use of the new frame buffer for use in VideoReceiveStream. This @@ -247,9 +247,12 @@ class FrameBuffer3Proxy : public FrameBufferProxy { if (complete_units < buffer_->GetTotalNumberOfContinuousTemporalUnits()) { stats_proxy_->OnCompleteFrame(metadata.is_keyframe, metadata.size, metadata.contentType); - if (!metadata.delayed_by_retransmission) + RTC_DCHECK_GE(metadata.receive_time_ms, 0) + << "Frame receive time must be positive for received frames, was " + << metadata.receive_time_ms << "."; + if (!metadata.delayed_by_retransmission && metadata.receive_time_ms >= 0) timing_->IncomingTimestamp(metadata.rtp_timestamp, - metadata.receive_time); + Timestamp::Millis(metadata.receive_time_ms)); MaybeScheduleFrameForRelease(); } @@ -293,7 +296,7 @@ class FrameBuffer3Proxy : public FrameBufferProxy { timeout_tracker_.OnEncodedFrameReleased(); - int64_t now_ms = clock_->TimeInMilliseconds(); + Timestamp now = clock_->CurrentTime(); bool superframe_delayed_by_retransmission = false; size_t superframe_size = 0; const EncodedFrame& first_frame = *frames.front(); @@ -303,12 +306,11 @@ class FrameBuffer3Proxy : public FrameBufferProxy { keyframe_required_ = false; // Gracefully handle bad RTP timestamps and render time issues. - if (FrameHasBadRenderTiming(render_time.ms(), now_ms, + if (FrameHasBadRenderTiming(render_time, now, timing_->TargetVideoDelay())) { jitter_estimator_.Reset(); timing_->Reset(); - render_time = Timestamp::Millis( - timing_->RenderTimeMs(first_frame.Timestamp(), now_ms)); + render_time = timing_->RenderTime(first_frame.Timestamp(), now); } for (std::unique_ptr& frame : frames) { @@ -334,9 +336,9 @@ class FrameBuffer3Proxy : public FrameBufferProxy { rtt_mult = rtt_mult_settings_->rtt_mult_setting; rtt_mult_add_cap_ms = rtt_mult_settings_->rtt_mult_add_cap_ms; } - timing_->SetJitterDelay( - jitter_estimator_.GetJitterEstimate(rtt_mult, rtt_mult_add_cap_ms)); - timing_->UpdateCurrentDelay(render_time.ms(), now_ms); + timing_->SetJitterDelay(TimeDelta::Millis( + jitter_estimator_.GetJitterEstimate(rtt_mult, rtt_mult_add_cap_ms))); + timing_->UpdateCurrentDelay(render_time, now); } else if (RttMultExperiment::RttMultEnabled()) { jitter_estimator_.FrameNacked(); } @@ -349,7 +351,7 @@ class FrameBuffer3Proxy : public FrameBufferProxy { std::unique_ptr frame = CombineAndDeleteFrames(std::move(frames)); - timing_->SetLastDecodeScheduledTimestamp(now_ms); + timing_->SetLastDecodeScheduledTimestamp(now); decoder_ready_for_new_frame_ = false; // VideoReceiveStream2 wants frames on the decoder thread. @@ -399,18 +401,18 @@ class FrameBuffer3Proxy : public FrameBufferProxy { } void UpdateJitterDelay() { - int max_decode_ms; - int current_delay_ms; - int target_delay_ms; - int jitter_buffer_ms; - int min_playout_delay_ms; - int render_delay_ms; - if (timing_->GetTimings(&max_decode_ms, ¤t_delay_ms, &target_delay_ms, - &jitter_buffer_ms, &min_playout_delay_ms, - &render_delay_ms)) { + TimeDelta max_decode = TimeDelta::Zero(); + TimeDelta current_delay = TimeDelta::Zero(); + TimeDelta target_delay = TimeDelta::Zero(); + TimeDelta jitter_buffer = TimeDelta::Zero(); + TimeDelta min_playout_delay = TimeDelta::Zero(); + TimeDelta render_delay = TimeDelta::Zero(); + if (timing_->GetTimings(&max_decode, ¤t_delay, &target_delay, + &jitter_buffer, &min_playout_delay, + &render_delay)) { stats_proxy_->OnFrameBufferTimingsUpdated( - max_decode_ms, current_delay_ms, target_delay_ms, jitter_buffer_ms, - min_playout_delay_ms, render_delay_ms); + max_decode.ms(), current_delay.ms(), target_delay.ms(), + jitter_buffer.ms(), min_playout_delay.ms(), render_delay.ms()); } } @@ -437,8 +439,8 @@ class FrameBuffer3Proxy : public FrameBufferProxy { } // Found keyframe - decode right away. if (next_frame.front()->is_keyframe()) { - auto render_time = Timestamp::Millis(timing_->RenderTimeMs( - next_frame.front()->Timestamp(), clock_->TimeInMilliseconds())); + auto render_time = timing_->RenderTime(next_frame.front()->Timestamp(), + clock_->CurrentTime()); OnFrameReady(std::move(next_frame), render_time); return; } diff --git a/video/frame_buffer_proxy_unittest.cc b/video/frame_buffer_proxy_unittest.cc index 81e5bd2ffd..e7307fd4ac 100644 --- a/video/frame_buffer_proxy_unittest.cc +++ b/video/frame_buffer_proxy_unittest.cc @@ -233,7 +233,7 @@ class FrameBufferProxyFixture kMaxWaitForFrame, &decode_sync_)) { // Avoid starting with negative render times. - timing_.set_min_playout_delay(10); + timing_.set_min_playout_delay(TimeDelta::Millis(10)); ON_CALL(stats_callback_, OnDroppedFrames) .WillByDefault( @@ -631,8 +631,7 @@ TEST_P(FrameBufferProxyTest, TestStatsCallback) { EXPECT_CALL(stats_callback_, OnFrameBufferTimingsUpdated); // Fake timing having received decoded frame. - timing_.StopDecodeTimer(clock_->TimeInMicroseconds() + 1, - clock_->TimeInMilliseconds()); + timing_.StopDecodeTimer(TimeDelta::Millis(1), clock_->CurrentTime()); StartNextDecodeForceKeyframe(); proxy_->InsertFrame(Builder().Id(0).Time(0).AsLast().Build()); EXPECT_THAT(WaitForFrameOrTimeout(TimeDelta::Zero()), Frame(WithId(0))); @@ -775,8 +774,8 @@ TEST_P(LowLatencyFrameBufferProxyTest, FramesDecodedInstantlyWithLowLatencyRendering) { // Initial keyframe. StartNextDecodeForceKeyframe(); - timing_.set_min_playout_delay(0); - timing_.set_max_playout_delay(10); + timing_.set_min_playout_delay(TimeDelta::Zero()); + timing_.set_max_playout_delay(TimeDelta::Millis(10)); auto frame = Builder().Id(0).Time(0).AsLast().Build(); // Playout delay of 0 implies low-latency rendering. frame->SetPlayoutDelay({0, 10}); @@ -798,8 +797,8 @@ TEST_P(LowLatencyFrameBufferProxyTest, TEST_P(LowLatencyFrameBufferProxyTest, ZeroPlayoutDelayFullQueue) { // Initial keyframe. StartNextDecodeForceKeyframe(); - timing_.set_min_playout_delay(0); - timing_.set_max_playout_delay(10); + timing_.set_min_playout_delay(TimeDelta::Zero()); + timing_.set_max_playout_delay(TimeDelta::Millis(10)); auto frame = Builder().Id(0).Time(0).AsLast().Build(); // Playout delay of 0 implies low-latency rendering. frame->SetPlayoutDelay({0, 10}); @@ -822,8 +821,8 @@ TEST_P(LowLatencyFrameBufferProxyTest, ZeroPlayoutDelayFullQueue) { TEST_P(LowLatencyFrameBufferProxyTest, MinMaxDelayZeroLowLatencyMode) { // Initial keyframe. StartNextDecodeForceKeyframe(); - timing_.set_min_playout_delay(0); - timing_.set_max_playout_delay(0); + timing_.set_min_playout_delay(TimeDelta::Zero()); + timing_.set_max_playout_delay(TimeDelta::Zero()); auto frame = Builder().Id(0).Time(0).AsLast().Build(); // Playout delay of 0 implies low-latency rendering. frame->SetPlayoutDelay({0, 0}); diff --git a/video/frame_decode_timing.cc b/video/frame_decode_timing.cc index ddc60302ef..c683834502 100644 --- a/video/frame_decode_timing.cc +++ b/video/frame_decode_timing.cc @@ -30,10 +30,9 @@ FrameDecodeTiming::OnFrameBufferUpdated(uint32_t next_temporal_unit_rtp, uint32_t last_temporal_unit_rtp, bool too_many_frames_queued) { const Timestamp now = clock_->CurrentTime(); - Timestamp render_time = Timestamp::Millis( - timing_->RenderTimeMs(next_temporal_unit_rtp, now.ms())); - TimeDelta max_wait = TimeDelta::Millis(timing_->MaxWaitingTime( - render_time.ms(), now.ms(), too_many_frames_queued)); + Timestamp render_time = timing_->RenderTime(next_temporal_unit_rtp, now); + TimeDelta max_wait = + timing_->MaxWaitingTime(render_time, now, too_many_frames_queued); // If the delay is not too far in the past, or this is the last decodable // frame then it is the best frame to be decoded. Otherwise, fast-forward diff --git a/video/frame_decode_timing_unittest.cc b/video/frame_decode_timing_unittest.cc index ac5bf9ef10..0d99847e73 100644 --- a/video/frame_decode_timing_unittest.cc +++ b/video/frame_decode_timing_unittest.cc @@ -32,20 +32,18 @@ class FakeVCMTiming : public webrtc::VCMTiming { public: explicit FakeVCMTiming(Clock* clock) : webrtc::VCMTiming(clock) {} - int64_t RenderTimeMs(uint32_t frame_timestamp, - int64_t now_ms) const override { + Timestamp RenderTime(uint32_t frame_timestamp, Timestamp now) const override { RTC_DCHECK(render_time_map_.contains(frame_timestamp)); auto it = render_time_map_.find(frame_timestamp); - return it->second.ms(); + return it->second; } - int64_t MaxWaitingTime(int64_t render_time_ms, - int64_t now_ms, - bool too_many_frames_queued) const override { - auto render_time = Timestamp::Millis(render_time_ms); + TimeDelta MaxWaitingTime(Timestamp render_time, + Timestamp now, + bool too_many_frames_queued) const override { RTC_DCHECK(wait_time_map_.contains(render_time)); auto it = wait_time_map_.find(render_time); - return it->second.ms(); + return it->second; } void SetTimes(uint32_t frame_timestamp, diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc index 5436c0156e..290180b8c6 100644 --- a/video/video_receive_stream2.cc +++ b/video/video_receive_stream2.cc @@ -269,7 +269,7 @@ VideoReceiveStream2::VideoReceiveStream2( decoder_payload_types.insert(decoder.payload_type); } - timing_->set_render_delay(config_.render_delay_ms); + timing_->set_render_delay(TimeDelta::Millis(config_.render_delay_ms)); frame_buffer_ = FrameBufferProxy::CreateFromFieldTrial( clock_, call_->worker_thread(), timing_.get(), &stats_proxy_, @@ -710,7 +710,7 @@ absl::optional VideoReceiveStream2::GetInfo() const { if (!info) return absl::nullopt; - info->current_delay_ms = timing_->TargetVideoDelay(); + info->current_delay_ms = timing_->TargetVideoDelay().ms(); return info; } @@ -970,7 +970,7 @@ void VideoReceiveStream2::UpdatePlayoutDelays() const { std::max({frame_minimum_playout_delay_ms_, base_minimum_playout_delay_ms_, syncable_minimum_playout_delay_ms_}); if (minimum_delay_ms >= 0) { - timing_->set_min_playout_delay(minimum_delay_ms); + timing_->set_min_playout_delay(TimeDelta::Millis(minimum_delay_ms)); if (frame_minimum_playout_delay_ms_ == 0 && frame_maximum_playout_delay_ms_ > 0 && low_latency_renderer_enabled_) { // TODO(kron): Estimate frame rate from video stream. @@ -991,7 +991,7 @@ void VideoReceiveStream2::UpdatePlayoutDelays() const { const int maximum_delay_ms = frame_maximum_playout_delay_ms_; if (maximum_delay_ms >= 0) { - timing_->set_max_playout_delay(maximum_delay_ms); + timing_->set_max_playout_delay(TimeDelta::Millis(maximum_delay_ms)); } } diff --git a/video/video_receive_stream2_unittest.cc b/video/video_receive_stream2_unittest.cc index 3c6640a711..213df389c3 100644 --- a/video/video_receive_stream2_unittest.cc +++ b/video/video_receive_stream2_unittest.cc @@ -163,30 +163,30 @@ TEST_F(VideoReceiveStream2Test, PlayoutDelay) { test_frame->SetPlayoutDelay(kPlayoutDelayMs); video_receive_stream_->OnCompleteFrame(std::move(test_frame)); - EXPECT_EQ(kPlayoutDelayMs.min_ms, timing_->min_playout_delay()); - EXPECT_EQ(kPlayoutDelayMs.max_ms, timing_->max_playout_delay()); + EXPECT_EQ(kPlayoutDelayMs.min_ms, timing_->min_playout_delay().ms()); + EXPECT_EQ(kPlayoutDelayMs.max_ms, timing_->max_playout_delay().ms()); // Check that the biggest minimum delay is chosen. video_receive_stream_->SetMinimumPlayoutDelay(400); - EXPECT_EQ(400, timing_->min_playout_delay()); + EXPECT_EQ(400, timing_->min_playout_delay().ms()); // Check base minimum delay validation. EXPECT_FALSE(video_receive_stream_->SetBaseMinimumPlayoutDelayMs(12345)); EXPECT_FALSE(video_receive_stream_->SetBaseMinimumPlayoutDelayMs(-1)); EXPECT_TRUE(video_receive_stream_->SetBaseMinimumPlayoutDelayMs(500)); - EXPECT_EQ(500, timing_->min_playout_delay()); + EXPECT_EQ(500, timing_->min_playout_delay().ms()); // Check that intermidiate values are remembered and the biggest remembered // is chosen. video_receive_stream_->SetBaseMinimumPlayoutDelayMs(0); - EXPECT_EQ(400, timing_->min_playout_delay()); + EXPECT_EQ(400, timing_->min_playout_delay().ms()); video_receive_stream_->SetMinimumPlayoutDelay(0); - EXPECT_EQ(123, timing_->min_playout_delay()); + EXPECT_EQ(123, timing_->min_playout_delay().ms()); } TEST_F(VideoReceiveStream2Test, PlayoutDelayPreservesDefaultMaxValue) { - const int default_max_playout_latency = timing_->max_playout_delay(); + const TimeDelta default_max_playout_latency = timing_->max_playout_delay(); const VideoPlayoutDelay kPlayoutDelayMs = {123, -1}; std::unique_ptr test_frame(new FrameObjectFake()); @@ -196,13 +196,13 @@ TEST_F(VideoReceiveStream2Test, PlayoutDelayPreservesDefaultMaxValue) { video_receive_stream_->OnCompleteFrame(std::move(test_frame)); // Ensure that -1 preserves default maximum value from `timing_`. - EXPECT_EQ(kPlayoutDelayMs.min_ms, timing_->min_playout_delay()); - EXPECT_NE(kPlayoutDelayMs.max_ms, timing_->max_playout_delay()); + EXPECT_EQ(kPlayoutDelayMs.min_ms, timing_->min_playout_delay().ms()); + EXPECT_NE(kPlayoutDelayMs.max_ms, timing_->max_playout_delay().ms()); EXPECT_EQ(default_max_playout_latency, timing_->max_playout_delay()); } TEST_F(VideoReceiveStream2Test, PlayoutDelayPreservesDefaultMinValue) { - const int default_min_playout_latency = timing_->min_playout_delay(); + const TimeDelta default_min_playout_latency = timing_->min_playout_delay(); const VideoPlayoutDelay kPlayoutDelayMs = {-1, 321}; std::unique_ptr test_frame(new FrameObjectFake()); @@ -212,8 +212,8 @@ TEST_F(VideoReceiveStream2Test, PlayoutDelayPreservesDefaultMinValue) { video_receive_stream_->OnCompleteFrame(std::move(test_frame)); // Ensure that -1 preserves default minimum value from `timing_`. - EXPECT_NE(kPlayoutDelayMs.min_ms, timing_->min_playout_delay()); - EXPECT_EQ(kPlayoutDelayMs.max_ms, timing_->max_playout_delay()); + EXPECT_NE(kPlayoutDelayMs.min_ms, timing_->min_playout_delay().ms()); + EXPECT_EQ(kPlayoutDelayMs.max_ms, timing_->max_playout_delay().ms()); EXPECT_EQ(default_min_playout_latency, timing_->min_playout_delay()); } diff --git a/video/video_stream_decoder_impl.cc b/video/video_stream_decoder_impl.cc index bbd67ee257..907b8b0dbc 100644 --- a/video/video_stream_decoder_impl.cc +++ b/video/video_stream_decoder_impl.cc @@ -70,11 +70,11 @@ void VideoStreamDecoderImpl::OnFrame(std::unique_ptr frame) { } void VideoStreamDecoderImpl::SetMinPlayoutDelay(TimeDelta min_delay) { - timing_.set_min_playout_delay(min_delay.ms()); + timing_.set_min_playout_delay(min_delay); } void VideoStreamDecoderImpl::SetMaxPlayoutDelay(TimeDelta max_delay) { - timing_.set_max_playout_delay(max_delay.ms()); + timing_.set_max_playout_delay(max_delay); } VideoDecoder* VideoStreamDecoderImpl::GetDecoder(int payload_type) { @@ -258,7 +258,8 @@ void VideoStreamDecoderImpl::OnDecodedFrameCallback( Timestamp::Millis(frame_info->decode_start_time_ms + *decode_time_ms)}); decoded_image.set_timestamp_us(frame_info->render_time_us); - timing_.StopDecodeTimer(*decode_time_ms, decode_stop_time_ms); + timing_.StopDecodeTimer(TimeDelta::Millis(*decode_time_ms), + Timestamp::Millis(decode_stop_time_ms)); callbacks_->OnDecodedFrame(decoded_image, callback_info); }); From 5cd7d2aa0f93d7051956f34929a525151012601b Mon Sep 17 00:00:00 2001 From: Alessio Bazzica Date: Wed, 2 Mar 2022 16:31:50 +0100 Subject: [PATCH 087/847] audioproc_f: fix AGC1 digital adaptive flag bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - missing negation causes the opposite behavior when `analog_agc_disable_digital_adaptive` is used - flag replaced with `analog_agc_use_digital_adaptive_controller` which is less error-prone Bug: webrtc:7494 Change-Id: If9e0ba4fc9e539c73269faf9096ca782620dac6d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251322 Reviewed-by: Per Åhgren Commit-Queue: Alessio Bazzica Cr-Commit-Position: refs/heads/main@{#36113} --- .../test/audio_processing_simulator.cc | 4 ++-- .../test/audio_processing_simulator.h | 2 +- modules/audio_processing/test/audioproc_float_impl.cc | 11 ++++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/audio_processing/test/audio_processing_simulator.cc b/modules/audio_processing/test/audio_processing_simulator.cc index 4915648fa9..5923fc34f6 100644 --- a/modules/audio_processing/test/audio_processing_simulator.cc +++ b/modules/audio_processing/test/audio_processing_simulator.cc @@ -565,9 +565,9 @@ void AudioProcessingSimulator::ConfigureAudioProcessor() { apm_config.gain_controller1.analog_gain_controller.enabled = *settings_.use_analog_agc; } - if (settings_.analog_agc_disable_digital_adaptive) { + if (settings_.analog_agc_use_digital_adaptive_controller) { apm_config.gain_controller1.analog_gain_controller.enable_digital_adaptive = - *settings_.analog_agc_disable_digital_adaptive; + *settings_.analog_agc_use_digital_adaptive_controller; } if (settings_.maximum_internal_processing_rate) { diff --git a/modules/audio_processing/test/audio_processing_simulator.h b/modules/audio_processing/test/audio_processing_simulator.h index af76d7e1c9..71f8eab160 100644 --- a/modules/audio_processing/test/audio_processing_simulator.h +++ b/modules/audio_processing/test/audio_processing_simulator.h @@ -106,7 +106,7 @@ struct SimulationSettings { absl::optional use_ts; absl::optional use_analog_agc; absl::optional use_all; - absl::optional analog_agc_disable_digital_adaptive; + absl::optional analog_agc_use_digital_adaptive_controller; absl::optional agc_mode; absl::optional agc_target_level; absl::optional use_agc_limiter; diff --git a/modules/audio_processing/test/audioproc_float_impl.cc b/modules/audio_processing/test/audioproc_float_impl.cc index aab1881913..9055b64081 100644 --- a/modules/audio_processing/test/audioproc_float_impl.cc +++ b/modules/audio_processing/test/audioproc_float_impl.cc @@ -123,10 +123,10 @@ ABSL_FLAG(bool, "Activate all of the default components (will be overridden by any " "other settings)"); ABSL_FLAG(int, - analog_agc_disable_digital_adaptive, + analog_agc_use_digital_adaptive_controller, kParameterNotSpecifiedValue, - "Force-deactivate (1) digital adaptation in " - "experimental AGC. Digital adaptation is active by default (0)."); + "Activate (1) or deactivate (0) digital adaptation in AGC1. " + "Digital adaptation is active by default."); ABSL_FLAG(int, agc_mode, kParameterNotSpecifiedValue, @@ -412,8 +412,9 @@ SimulationSettings CreateSettings() { SetSettingIfSpecified(absl::GetFlag(FLAGS_ts), &settings.use_ts); SetSettingIfFlagSet(absl::GetFlag(FLAGS_analog_agc), &settings.use_analog_agc); - SetSettingIfFlagSet(absl::GetFlag(FLAGS_analog_agc_disable_digital_adaptive), - &settings.analog_agc_disable_digital_adaptive); + SetSettingIfFlagSet( + absl::GetFlag(FLAGS_analog_agc_use_digital_adaptive_controller), + &settings.analog_agc_use_digital_adaptive_controller); SetSettingIfSpecified(absl::GetFlag(FLAGS_agc_mode), &settings.agc_mode); SetSettingIfSpecified(absl::GetFlag(FLAGS_agc_target_level), &settings.agc_target_level); From 66557e1af3f95a70753e782224d13a6186ed0d2e Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Wed, 2 Mar 2022 15:58:59 +0000 Subject: [PATCH 088/847] Revert "remove NV12 to I420 conversion in webrtc AV1 Encoder." MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 9558ab41eb4de39c62cda2dd1e559f5814a3a0c7. Reason for revert: speculative revert: breaks downstream project Original change's description: > remove NV12 to I420 conversion in webrtc AV1 Encoder. > > libaom supports for NV12 inputs for encoding av1 stream. It will reduce > unnecessary conversion from NV12 to I420 format. > (https://bugs.chromium.org/p/aomedia/issues/detail?id=3232&q=3232&can=2) > > Bug: webrtc:13746 > Change-Id: I1407227d1690b3f63cb6581eef5d587e5f418892 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251920 > Reviewed-by: Erik Språng > Reviewed-by: Ilya Nikolaevskiy > Commit-Queue: Shuhai Peng > Cr-Commit-Position: refs/heads/main@{#36111} Bug: webrtc:13746 Change-Id: Ie928f7f5b5992337a9d186fa70b7fdec20a33f00 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253122 Bot-Commit: rubber-stamper@appspot.gserviceaccount.com Reviewed-by: Mirko Bonadei Commit-Queue: Artem Titov Owners-Override: Artem Titov Owners-Override: Mirko Bonadei Cr-Commit-Position: refs/heads/main@{#36114} --- .../codecs/av1/libaom_av1_encoder.cc | 109 +++++------------- video/video_stream_encoder_unittest.cc | 2 +- 2 files changed, 29 insertions(+), 82 deletions(-) diff --git a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc index b47dab9834..79a31d9baa 100644 --- a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc +++ b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc @@ -105,8 +105,6 @@ class LibaomAv1Encoder final : public VideoEncoder { // Configures the encoder which buffers next frame updates and can reference. void SetSvcRefFrameConfig( const ScalableVideoController::LayerFrameConfig& layer_frame); - // If pixel format doesn't match, then reallocate. - void MaybeRewrapImgWithFormat(const aom_img_fmt_t fmt); std::unique_ptr svc_controller_; bool inited_; @@ -230,10 +228,11 @@ int LibaomAv1Encoder::InitEncode(const VideoCodec* codec_settings, cfg_.g_pass = AOM_RC_ONE_PASS; // One-pass rate control cfg_.g_lag_in_frames = kLagInFrames; // No look ahead when lag equals 0. - if (frame_for_encode_ != nullptr) { - aom_img_free(frame_for_encode_); - frame_for_encode_ = nullptr; - } + // Creating a wrapper to the image - setting image data to nullptr. Actual + // pointer will be set in encode. Setting align to 1, as it is meaningless + // (actual memory is not allocated). + frame_for_encode_ = + aom_img_alloc(nullptr, AOM_IMG_FMT_I420, cfg_.g_w, cfg_.g_h, 1); // Flag options: AOM_CODEC_USE_PSNR and AOM_CODEC_USE_HIGHBITDEPTH aom_codec_flags_t flags = 0; @@ -556,21 +555,6 @@ int32_t LibaomAv1Encoder::Release() { return WEBRTC_VIDEO_CODEC_OK; } -void LibaomAv1Encoder::MaybeRewrapImgWithFormat(const aom_img_fmt_t fmt) { - if (!frame_for_encode_) { - frame_for_encode_ = - aom_img_wrap(nullptr, fmt, cfg_.g_w, cfg_.g_h, 1, nullptr); - - } else if (frame_for_encode_->fmt != fmt) { - RTC_LOG(LS_INFO) << "Switching AV1 encoder pixel format to " - << (fmt == AOM_IMG_FMT_NV12 ? "NV12" : "I420"); - aom_img_free(frame_for_encode_); - frame_for_encode_ = - aom_img_wrap(nullptr, fmt, cfg_.g_w, cfg_.g_h, 1, nullptr); - } - // else no-op since the image is already in the right format. -} - int32_t LibaomAv1Encoder::Encode( const VideoFrame& frame, const std::vector* frame_types) { @@ -590,74 +574,38 @@ int32_t LibaomAv1Encoder::Encode( return WEBRTC_VIDEO_CODEC_ERROR; } - rtc::scoped_refptr buffer = frame.video_frame_buffer(); - absl::InlinedVector - supported_formats = {VideoFrameBuffer::Type::kI420, - VideoFrameBuffer::Type::kNV12}; - rtc::scoped_refptr mapped_buffer; - if (buffer->type() != VideoFrameBuffer::Type::kNative) { - // `buffer` is already mapped. - mapped_buffer = buffer; - } else { - // Attempt to map to one of the supported formats. - mapped_buffer = buffer->GetMappedFrameBuffer(supported_formats); - } - // Convert input frame to I420, if needed. - if (!mapped_buffer || - (absl::c_find(supported_formats, mapped_buffer->type()) == - supported_formats.end() && - mapped_buffer->type() != VideoFrameBuffer::Type::kI420A)) { + VideoFrame prepped_input_frame = frame; + if (prepped_input_frame.video_frame_buffer()->type() != + VideoFrameBuffer::Type::kI420 && + prepped_input_frame.video_frame_buffer()->type() != + VideoFrameBuffer::Type::kI420A) { rtc::scoped_refptr converted_buffer( - mapped_buffer->ToI420()); + prepped_input_frame.video_frame_buffer()->ToI420()); if (!converted_buffer) { RTC_LOG(LS_ERROR) << "Failed to convert " << VideoFrameBufferTypeToString( - frame.video_frame_buffer()->type()) + prepped_input_frame.video_frame_buffer()->type()) << " image to I420. Can't encode frame."; return WEBRTC_VIDEO_CODEC_ENCODER_FAILURE; } RTC_CHECK(converted_buffer->type() == VideoFrameBuffer::Type::kI420 || converted_buffer->type() == VideoFrameBuffer::Type::kI420A); - - mapped_buffer = converted_buffer; - } - - switch (mapped_buffer->type()) { - case VideoFrameBuffer::Type::kI420: - case VideoFrameBuffer::Type::kI420A: { - // Set frame_for_encode_ data pointers and strides. - MaybeRewrapImgWithFormat(AOM_IMG_FMT_I420); - auto i420_buffer = mapped_buffer->GetI420(); - RTC_DCHECK(i420_buffer); - frame_for_encode_->planes[AOM_PLANE_Y] = - const_cast(i420_buffer->DataY()); - frame_for_encode_->planes[AOM_PLANE_U] = - const_cast(i420_buffer->DataU()); - frame_for_encode_->planes[AOM_PLANE_V] = - const_cast(i420_buffer->DataV()); - frame_for_encode_->stride[AOM_PLANE_Y] = i420_buffer->StrideY(); - frame_for_encode_->stride[AOM_PLANE_U] = i420_buffer->StrideU(); - frame_for_encode_->stride[AOM_PLANE_V] = i420_buffer->StrideV(); - break; - } - case VideoFrameBuffer::Type::kNV12: { - MaybeRewrapImgWithFormat(AOM_IMG_FMT_NV12); - const NV12BufferInterface* nv12_buffer = mapped_buffer->GetNV12(); - RTC_DCHECK(nv12_buffer); - frame_for_encode_->planes[AOM_PLANE_Y] = - const_cast(nv12_buffer->DataY()); - frame_for_encode_->planes[AOM_PLANE_U] = - const_cast(nv12_buffer->DataUV()); - frame_for_encode_->planes[AOM_PLANE_V] = nullptr; - frame_for_encode_->stride[AOM_PLANE_Y] = nv12_buffer->StrideY(); - frame_for_encode_->stride[AOM_PLANE_U] = nv12_buffer->StrideUV(); - frame_for_encode_->stride[AOM_PLANE_V] = 0; - break; - } - default: - return WEBRTC_VIDEO_CODEC_ENCODER_FAILURE; - } + prepped_input_frame = VideoFrame(converted_buffer, frame.timestamp(), + frame.render_time_ms(), frame.rotation()); + } + + // Set frame_for_encode_ data pointers and strides. + auto i420_buffer = prepped_input_frame.video_frame_buffer()->GetI420(); + frame_for_encode_->planes[AOM_PLANE_Y] = + const_cast(i420_buffer->DataY()); + frame_for_encode_->planes[AOM_PLANE_U] = + const_cast(i420_buffer->DataU()); + frame_for_encode_->planes[AOM_PLANE_V] = + const_cast(i420_buffer->DataV()); + frame_for_encode_->stride[AOM_PLANE_Y] = i420_buffer->StrideY(); + frame_for_encode_->stride[AOM_PLANE_U] = i420_buffer->StrideU(); + frame_for_encode_->stride[AOM_PLANE_V] = i420_buffer->StrideV(); const uint32_t duration = kRtpTicksPerSecond / static_cast(encoder_settings_.maxFramerate); @@ -857,8 +805,7 @@ VideoEncoder::EncoderInfo LibaomAv1Encoder::GetEncoderInfo() const { info.has_trusted_rate_controller = true; info.is_hardware_accelerated = false; info.scaling_settings = VideoEncoder::ScalingSettings(kMinQindex, kMaxQindex); - info.preferred_pixel_formats = {VideoFrameBuffer::Type::kI420, - VideoFrameBuffer::Type::kNV12}; + info.preferred_pixel_formats = {VideoFrameBuffer::Type::kI420}; if (SvcEnabled()) { for (int sid = 0; sid < svc_params_->number_spatial_layers; ++sid) { info.fps_allocation[sid].resize(svc_params_->number_temporal_layers); diff --git a/video/video_stream_encoder_unittest.cc b/video/video_stream_encoder_unittest.cc index b1ff12ed11..aea1988df9 100644 --- a/video/video_stream_encoder_unittest.cc +++ b/video/video_stream_encoder_unittest.cc @@ -8694,7 +8694,7 @@ constexpr std::pair kVP8DisallowConversion = constexpr std::pair kVP9DisallowConversion = std::make_pair(kVideoCodecVP9, /*allow_i420_conversion=*/false); constexpr std::pair kAV1AllowConversion = - std::make_pair(kVideoCodecAV1, /*allow_i420_conversion=*/false); + std::make_pair(kVideoCodecAV1, /*allow_i420_conversion=*/true); constexpr std::pair kMultiplexDisallowConversion = std::make_pair(kVideoCodecMultiplex, /*allow_i420_conversion=*/false); #if defined(WEBRTC_USE_H264) From 63b54ec896e17ca5a28eab5fed4a606619a38a63 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Wed, 2 Mar 2022 08:03:10 -0800 Subject: [PATCH 089/847] Roll chromium_revision 73bb0a55b9..a797b62bc8 (976576:976680) Change log: https://chromium.googlesource.com/chromium/src/+log/73bb0a55b9..a797b62bc8 Full diff: https://chromium.googlesource.com/chromium/src/+/73bb0a55b9..a797b62bc8 Changed dependencies * src/build: https://chromium.googlesource.com/chromium/src/build/+log/e795961f78..4d94be0a53 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/d8405f85ea..7cb58f816a * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/ef3ff558a7..778f1ff21a * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/ac3013beaf..f5db9971fa * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/d041e6e3ff..a930f3799c * src/third_party/r8: cEv1yyfxfmP_MaZrG22cR7YPc7hehgHAZd82lRx0DFAC..ZI5RPjew7GhVFtcZytIe_Sv91Pljm5KmhVan6HWxj8YC * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/5ef85e6e4f..57b2e41ea8 DEPS diff: https://chromium.googlesource.com/chromium/src/+/73bb0a55b9..a797b62bc8/DEPS No update to Clang. BUG=None Change-Id: I374e76703e9bba0f5251a80dd7c0e76071d789bf Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253211 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36115} --- DEPS | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/DEPS b/DEPS index a3a34c60b0..b68b5436eb 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': '73bb0a55b9d1d3895287959d75cab51fa8600c12', + 'chromium_revision': 'a797b62bc8f8094637f8007f42e46e3a050ec811', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -25,7 +25,7 @@ deps = { 'src/base': 'https://chromium.googlesource.com/chromium/src/base@7664dd78db1a2ddb9eb2363701718ba7622db7f0', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@e795961f78aa92537c1fc4735518e4c50519d14c', + 'https://chromium.googlesource.com/chromium/src/build@4d94be0a535c3ff00764b058803ac35a228828a7', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@893aa038dd17d05f3c5ff5af98daebabc294a948', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@d8405f85ea3cdb04d86f40b2a0d0d16697cb7926', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@7cb58f816a22d316c33fc04b6bdcc18d95a2cac1', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@ef3ff558a72fcf96e1ac36426ec179787aa085d2', + 'https://chromium.googlesource.com/chromium/src/testing@778f1ff21aaf4005d36c8a89fa8e4629cc5f27da', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@ac3013beaf469ec80c491f6a4bc245a9df82a027', + 'https://chromium.googlesource.com/chromium/src/third_party@f5db9971fa37ecfe193aec1d7854ca8d8f8f14f6', 'src/buildtools/linux64': { 'packages': [ @@ -228,7 +228,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@d041e6e3ffe64223b6c9bbb3b066f8ab59873c02', + 'https://android.googlesource.com/platform/external/perfetto.git@a930f3799c34bedb97a76b2292ac02b3bc053ccb', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -253,7 +253,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/r8', - 'version': 'cEv1yyfxfmP_MaZrG22cR7YPc7hehgHAZd82lRx0DFAC', + 'version': 'ZI5RPjew7GhVFtcZytIe_Sv91Pljm5KmhVan6HWxj8YC', }, ], 'condition': 'checkout_android', @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@5ef85e6e4f64389eabcafe4bc4e94a97532c3677', + 'https://chromium.googlesource.com/chromium/src/tools@57b2e41ea8dfdd005c23d95b16ab5b91ed1998e2', 'src/third_party/accessibility_test_framework': { 'packages': [ From b36f6896c8067568873e54ecfa2b0a61dd1ffc6d Mon Sep 17 00:00:00 2001 From: Byoungchan Lee Date: Thu, 3 Mar 2022 05:55:22 +0900 Subject: [PATCH 090/847] Add SequenceChecker on Notifier Bug: None Change-Id: I85e80576d92ddae55a3fbd144338d9c57fb80065 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252520 Reviewed-by: Artem Titov Auto-Submit: Daniel.L (Byoungchan) Lee Reviewed-by: Harald Alvestrand Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#36116} --- api/BUILD.gn | 2 ++ api/DEPS | 4 ++++ api/notifier.h | 12 ++++++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/api/BUILD.gn b/api/BUILD.gn index 12e0c5cafa..9d9bf55b8b 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn @@ -116,10 +116,12 @@ rtc_library("media_stream_interface") { ":audio_options_api", ":rtp_parameters", ":scoped_refptr", + ":sequence_checker", ":video_track_source_constraints", "../modules/audio_processing:audio_processing_statistics", "../rtc_base:checks", "../rtc_base:refcount", + "../rtc_base/system:no_unique_address", "../rtc_base/system:rtc_export", "video:recordable_encoded_frame", "video:video_frame", diff --git a/api/DEPS b/api/DEPS index ff493bf77f..bdeab0ade6 100644 --- a/api/DEPS +++ b/api/DEPS @@ -274,6 +274,10 @@ specific_include_rules = { "+rtc_base/ref_counted_object.h", ], + "notifier\.h": [ + "+rtc_base/system/no_unique_address.h", + ], + "simulated_network\.h": [ "+rtc_base/random.h", "+rtc_base/thread_annotations.h", diff --git a/api/notifier.h b/api/notifier.h index c03b1049eb..fc2480e00a 100644 --- a/api/notifier.h +++ b/api/notifier.h @@ -14,7 +14,9 @@ #include #include "api/media_stream_interface.h" +#include "api/sequence_checker.h" #include "rtc_base/checks.h" +#include "rtc_base/system/no_unique_address.h" namespace webrtc { @@ -23,14 +25,16 @@ namespace webrtc { template class Notifier : public T { public: - Notifier() {} + Notifier() { sequence_checker_.Detach(); } virtual void RegisterObserver(ObserverInterface* observer) { + RTC_DCHECK_RUN_ON(&sequence_checker_); RTC_DCHECK(observer != nullptr); observers_.push_back(observer); } virtual void UnregisterObserver(ObserverInterface* observer) { + RTC_DCHECK_RUN_ON(&sequence_checker_); for (std::list::iterator it = observers_.begin(); it != observers_.end(); it++) { if (*it == observer) { @@ -41,6 +45,7 @@ class Notifier : public T { } void FireOnChanged() { + RTC_DCHECK_RUN_ON(&sequence_checker_); // Copy the list of observers to avoid a crash if the observer object // unregisters as a result of the OnChanged() call. If the same list is used // UnregisterObserver will affect the list make the iterator invalid. @@ -52,7 +57,10 @@ class Notifier : public T { } protected: - std::list observers_; + std::list observers_ RTC_GUARDED_BY(sequence_checker_); + + private: + RTC_NO_UNIQUE_ADDRESS SequenceChecker sequence_checker_; }; } // namespace webrtc From 5544338f6bb71005cfc3f4673c016301558f812d Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Wed, 2 Mar 2022 14:02:36 -0800 Subject: [PATCH 091/847] Roll chromium_revision a797b62bc8..43d357affd (976680:976829) Change log: https://chromium.googlesource.com/chromium/src/+log/a797b62bc8..43d357affd Full diff: https://chromium.googlesource.com/chromium/src/+/a797b62bc8..43d357affd Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/7664dd78db..d385116c24 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/4d94be0a53..6db0c8ef95 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/7cb58f816a..c2e598dc20 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/778f1ff21a..d41c34a878 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/f5db9971fa..97276a539b * src/third_party/android_deps/libs/com_google_errorprone_error_prone_annotations: version:2@2.10.0.cr0..version:2@2.9.0.cr0 * src/third_party/android_deps/libs/org_ow2_asm_asm: version:2@9.0.cr0..version:2@9.2.cr1 * src/third_party/android_deps/libs/org_ow2_asm_asm_analysis: version:2@9.0.cr0..version:2@9.2.cr1 * src/third_party/android_deps/libs/org_ow2_asm_asm_commons: version:2@9.0.cr0..version:2@9.2.cr1 * src/third_party/android_deps/libs/org_ow2_asm_asm_tree: version:2@9.0.cr0..version:2@9.2.cr1 * src/third_party/android_deps/libs/org_ow2_asm_asm_util: version:2@9.0.cr0..version:2@9.2.cr1 * src/third_party/android_deps/libs/org_robolectric_annotations: version:2@4.6.1.cr0..version:2@4.7.3.cr1 * src/third_party/android_deps/libs/org_robolectric_junit: version:2@4.6.1.cr0..version:2@4.7.3.cr1 * src/third_party/android_deps/libs/org_robolectric_pluginapi: version:2@4.6.1.cr0..version:2@4.7.3.cr1 * src/third_party/android_deps/libs/org_robolectric_plugins_maven_dependency_resolver: version:2@4.6.1.cr0..version:2@4.7.3.cr1 * src/third_party/android_deps/libs/org_robolectric_resources: version:2@4.6.1.cr0..version:2@4.7.3.cr1 * src/third_party/android_deps/libs/org_robolectric_robolectric: version:2@4.6.1.cr0..version:2@4.7.3.cr1 * src/third_party/android_deps/libs/org_robolectric_sandbox: version:2@4.6.1.cr0..version:2@4.7.3.cr1 * src/third_party/android_deps/libs/org_robolectric_shadowapi: version:2@4.6.1.cr0..version:2@4.7.3.cr1 * src/third_party/android_deps/libs/org_robolectric_shadows_framework: version:2@4.6.1.cr0..version:2@4.7.3.cr1 * src/third_party/android_deps/libs/org_robolectric_shadows_multidex: version:2@4.6.1.cr1..version:2@4.7.3.cr1 * src/third_party/android_deps/libs/org_robolectric_shadows_playservices: version:2@4.6.1.cr0..version:2@4.7.3.cr1 * src/third_party/android_deps/libs/org_robolectric_utils: version:2@4.6.1.cr0..version:2@4.7.3.cr1 * src/third_party/android_deps/libs/org_robolectric_utils_reflector: version:2@4.6.1.cr0..version:2@4.7.3.cr1 * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/1c22c511d0..c0af61c8dd * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/a930f3799c..3a7d7533ce * src/third_party/robolectric: FihBToFLI9o7fW09ZtQ_5YruQy6sDWMo1Pv0g97eAxEC..WZ96VJuhBM63xzHb-_E72Tf46M9yIbfia6basI1YG4EC * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/57b2e41ea8..b77b9fda3c Added dependency * src/third_party/android_deps/libs/org_robolectric_nativeruntime DEPS diff: https://chromium.googlesource.com/chromium/src/+/a797b62bc8..43d357affd/DEPS No update to Clang. BUG=None Change-Id: I94dabff90af885c8f2da254e3d77ee0db0f249a2 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253280 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36117} --- DEPS | 69 +++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/DEPS b/DEPS index b68b5436eb..2aef7cabfa 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': 'a797b62bc8f8094637f8007f42e46e3a050ec811', + 'chromium_revision': '43d357affd6c303265e2c3e76ad578e22a1916f2', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@7664dd78db1a2ddb9eb2363701718ba7622db7f0', + 'https://chromium.googlesource.com/chromium/src/base@d385116c249aee1083458f79ee527581b9da35af', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@4d94be0a535c3ff00764b058803ac35a228828a7', + 'https://chromium.googlesource.com/chromium/src/build@6db0c8ef95b3a98c878f33133a1848b92250bef9', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@893aa038dd17d05f3c5ff5af98daebabc294a948', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@7cb58f816a22d316c33fc04b6bdcc18d95a2cac1', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@c2e598dc20b7e7944f6b187cb622e4eb8c1e53d7', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@778f1ff21aaf4005d36c8a89fa8e4629cc5f27da', + 'https://chromium.googlesource.com/chromium/src/testing@d41c34a878e571103228baa9ccadb28d6d85dfec', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@f5db9971fa37ecfe193aec1d7854ca8d8f8f14f6', + 'https://chromium.googlesource.com/chromium/src/third_party@97276a539b79e9ab591c2ee57661de4daab49395', 'src/buildtools/linux64': { 'packages': [ @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@1c22c511d02b4c4e02173297bcb8f2df3d3b4f66', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@c0af61c8dd0fee6a483aacbf64a57d46ba80355e', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -228,7 +228,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@a930f3799c34bedb97a76b2292ac02b3bc053ccb', + 'https://android.googlesource.com/platform/external/perfetto.git@3a7d7533cecebf657e35406980bf1afb5fcd23b2', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@57b2e41ea8dfdd005c23d95b16ab5b91ed1998e2', + 'https://chromium.googlesource.com/chromium/src/tools@b77b9fda3c226831ec8295a6a46f8ec8fea4f332', 'src/third_party/accessibility_test_framework': { 'packages': [ @@ -456,7 +456,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/robolectric', - 'version': 'FihBToFLI9o7fW09ZtQ_5YruQy6sDWMo1Pv0g97eAxEC', + 'version': 'WZ96VJuhBM63xzHb-_E72Tf46M9yIbfia6basI1YG4EC', }, ], 'condition': 'checkout_android', @@ -1397,7 +1397,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_errorprone_error_prone_annotations', - 'version': 'version:2@2.10.0.cr0', + 'version': 'version:2@2.9.0.cr0', }, ], 'condition': 'checkout_android', @@ -1936,7 +1936,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_ow2_asm_asm', - 'version': 'version:2@9.0.cr0', + 'version': 'version:2@9.2.cr1', }, ], 'condition': 'checkout_android', @@ -1947,7 +1947,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_ow2_asm_asm_analysis', - 'version': 'version:2@9.0.cr0', + 'version': 'version:2@9.2.cr1', }, ], 'condition': 'checkout_android', @@ -1958,7 +1958,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_ow2_asm_asm_commons', - 'version': 'version:2@9.0.cr0', + 'version': 'version:2@9.2.cr1', }, ], 'condition': 'checkout_android', @@ -1969,7 +1969,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_ow2_asm_asm_tree', - 'version': 'version:2@9.0.cr0', + 'version': 'version:2@9.2.cr1', }, ], 'condition': 'checkout_android', @@ -1980,7 +1980,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_ow2_asm_asm_util', - 'version': 'version:2@9.0.cr0', + 'version': 'version:2@9.2.cr1', }, ], 'condition': 'checkout_android', @@ -2002,7 +2002,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_annotations', - 'version': 'version:2@4.6.1.cr0', + 'version': 'version:2@4.7.3.cr1', }, ], 'condition': 'checkout_android', @@ -2013,7 +2013,18 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_junit', - 'version': 'version:2@4.6.1.cr0', + 'version': 'version:2@4.7.3.cr1', + }, + ], + 'condition': 'checkout_android', + 'dep_type': 'cipd', + }, + + 'src/third_party/android_deps/libs/org_robolectric_nativeruntime': { + 'packages': [ + { + 'package': 'chromium/third_party/android_deps/libs/org_robolectric_nativeruntime', + 'version': 'version:2@4.7.3.cr0', }, ], 'condition': 'checkout_android', @@ -2024,7 +2035,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_pluginapi', - 'version': 'version:2@4.6.1.cr0', + 'version': 'version:2@4.7.3.cr1', }, ], 'condition': 'checkout_android', @@ -2035,7 +2046,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_plugins_maven_dependency_resolver', - 'version': 'version:2@4.6.1.cr0', + 'version': 'version:2@4.7.3.cr1', }, ], 'condition': 'checkout_android', @@ -2046,7 +2057,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_resources', - 'version': 'version:2@4.6.1.cr0', + 'version': 'version:2@4.7.3.cr1', }, ], 'condition': 'checkout_android', @@ -2057,7 +2068,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_robolectric', - 'version': 'version:2@4.6.1.cr0', + 'version': 'version:2@4.7.3.cr1', }, ], 'condition': 'checkout_android', @@ -2068,7 +2079,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_sandbox', - 'version': 'version:2@4.6.1.cr0', + 'version': 'version:2@4.7.3.cr1', }, ], 'condition': 'checkout_android', @@ -2079,7 +2090,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_shadowapi', - 'version': 'version:2@4.6.1.cr0', + 'version': 'version:2@4.7.3.cr1', }, ], 'condition': 'checkout_android', @@ -2090,7 +2101,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_shadows_framework', - 'version': 'version:2@4.6.1.cr0', + 'version': 'version:2@4.7.3.cr1', }, ], 'condition': 'checkout_android', @@ -2101,7 +2112,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_shadows_multidex', - 'version': 'version:2@4.6.1.cr1', + 'version': 'version:2@4.7.3.cr1', }, ], 'condition': 'checkout_android', @@ -2112,7 +2123,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_shadows_playservices', - 'version': 'version:2@4.6.1.cr0', + 'version': 'version:2@4.7.3.cr1', }, ], 'condition': 'checkout_android', @@ -2123,7 +2134,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_utils', - 'version': 'version:2@4.6.1.cr0', + 'version': 'version:2@4.7.3.cr1', }, ], 'condition': 'checkout_android', @@ -2134,7 +2145,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_utils_reflector', - 'version': 'version:2@4.6.1.cr0', + 'version': 'version:2@4.7.3.cr1', }, ], 'condition': 'checkout_android', From f57d74f205e4ada2c9459353d810645ae1b8b15e Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Wed, 2 Mar 2022 20:03:53 -0800 Subject: [PATCH 092/847] Update WebRTC code version (2022-03-03T04:03:51). Bug: None Change-Id: Icd9da3a2cef4c9c0a1c3bf2b2936d03c6a6276ec Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253340 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36118} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index 41e1071a4c..10628cca3f 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 2022-03-02T04:04:16"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-03-03T04:03:51"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From 3c9a96b830ce95dc661b5a034f538651ccd5e7c6 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Thu, 3 Mar 2022 04:02:11 -0800 Subject: [PATCH 093/847] Roll chromium_revision 43d357affd..fed3329cf1 (976829:977049) Change log: https://chromium.googlesource.com/chromium/src/+log/43d357affd..fed3329cf1 Full diff: https://chromium.googlesource.com/chromium/src/+/43d357affd..fed3329cf1 Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/d385116c24..d3223195a8 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/6db0c8ef95..e6ef2e3b0b * src/buildtools: https://chromium.googlesource.com/chromium/src/buildtools/+log/893aa038dd..113dd1badb * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/c2e598dc20..ccdad02575 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/d41c34a878..4ad24bcc57 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/97276a539b..56ac406f30 * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/d62cc7b294..4a800603ab * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/c0af61c8dd..4bda2abfcf * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/3a7d7533ce..11de3dcf8b * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/b77b9fda3c..ad2f70bd0c DEPS diff: https://chromium.googlesource.com/chromium/src/+/43d357affd..fed3329cf1/DEPS No update to Clang. BUG=None Change-Id: I26451573aacec766c74761b41ccdfbe701ac2d5e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253420 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36119} --- DEPS | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/DEPS b/DEPS index 2aef7cabfa..1ac25ff92a 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': '43d357affd6c303265e2c3e76ad578e22a1916f2', + 'chromium_revision': 'fed3329cf133f231b0845f5880229b6de9597193', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,24 +23,24 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@d385116c249aee1083458f79ee527581b9da35af', + 'https://chromium.googlesource.com/chromium/src/base@d3223195a835db92b2f3c541053efbba1ee28e92', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@6db0c8ef95b3a98c878f33133a1848b92250bef9', + 'https://chromium.googlesource.com/chromium/src/build@e6ef2e3b0b3b441312d57d9ff3df0b38b3aa44b3', 'src/buildtools': - 'https://chromium.googlesource.com/chromium/src/buildtools@893aa038dd17d05f3c5ff5af98daebabc294a948', + 'https://chromium.googlesource.com/chromium/src/buildtools@113dd1badbcbffea108a8c95ac7c89c22bfd25f3', # 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@c2e598dc20b7e7944f6b187cb622e4eb8c1e53d7', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@ccdad025758d3bff01fdcb62372779ab7c6d0517', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@d41c34a878e571103228baa9ccadb28d6d85dfec', + 'https://chromium.googlesource.com/chromium/src/testing@4ad24bcc579e270e1452687cd470c6bdaf52110f', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@97276a539b79e9ab591c2ee57661de4daab49395', + 'https://chromium.googlesource.com/chromium/src/third_party@56ac406f30ba750fd96f9e29869b8216a97dd72c', 'src/buildtools/linux64': { 'packages': [ @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@d62cc7b2945f2197f62dc94aef9290848533486f', + 'https://chromium.googlesource.com/catapult.git@4a800603ab8a7e9e2569ec63fe618501d5f8145e', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@c0af61c8dd0fee6a483aacbf64a57d46ba80355e', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@4bda2abfcf6e5debf6e0463f987a8432a56e06e1', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -228,7 +228,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@3a7d7533cecebf657e35406980bf1afb5fcd23b2', + 'https://android.googlesource.com/platform/external/perfetto.git@11de3dcf8b4e4c727906a0fb055b5493e9d2de82', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@b77b9fda3c226831ec8295a6a46f8ec8fea4f332', + 'https://chromium.googlesource.com/chromium/src/tools@ad2f70bd0caa652782e5dbb02e3c50cf2f09dd40', 'src/third_party/accessibility_test_framework': { 'packages': [ From b663cfaae43a3f5c29cfa0ef8941690ca3c485fc Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Thu, 3 Mar 2022 14:32:52 +0100 Subject: [PATCH 094/847] Cleanup RtpPacketHistory from unused features MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit history no longer used for storing unsent packets and for legacy pacer. Bug: None Change-Id: I639c37de66857a64c620e80df6288fa6ce8326d4 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253260 Reviewed-by: Erik Språng Commit-Queue: Danil Chapovalov Cr-Commit-Position: refs/heads/main@{#36120} --- modules/rtp_rtcp/source/rtp_packet_history.cc | 109 ++------ modules/rtp_rtcp/source/rtp_packet_history.h | 46 +--- .../source/rtp_packet_history_unittest.cc | 246 ++++-------------- modules/rtp_rtcp/source/rtp_sender.cc | 19 +- .../source/rtp_sender_egress_unittest.cc | 32 +-- 5 files changed, 90 insertions(+), 362 deletions(-) diff --git a/modules/rtp_rtcp/source/rtp_packet_history.cc b/modules/rtp_rtcp/source/rtp_packet_history.cc index 0bfb043448..eda3ecdee5 100644 --- a/modules/rtp_rtcp/source/rtp_packet_history.cc +++ b/modules/rtp_rtcp/source/rtp_packet_history.cc @@ -29,20 +29,13 @@ constexpr int64_t RtpPacketHistory::kMinPacketDurationMs; constexpr int RtpPacketHistory::kMinPacketDurationRtt; constexpr int RtpPacketHistory::kPacketCullingDelayFactor; -RtpPacketHistory::PacketState::PacketState() = default; -RtpPacketHistory::PacketState::PacketState(const PacketState&) = default; -RtpPacketHistory::PacketState::~PacketState() = default; - RtpPacketHistory::StoredPacket::StoredPacket( std::unique_ptr packet, - absl::optional send_time_ms, + int64_t send_time_ms, uint64_t insert_order) : send_time_ms_(send_time_ms), packet_(std::move(packet)), - // No send time indicates packet is not sent immediately, but instead will - // be put in the pacer queue and later retrieved via - // GetPacketAndSetSendTime(). - pending_transmission_(!send_time_ms.has_value()), + pending_transmission_(false), insert_order_(insert_order), times_retransmitted_(0) {} @@ -120,7 +113,7 @@ void RtpPacketHistory::SetRtt(int64_t rtt_ms) { } void RtpPacketHistory::PutRtpPacket(std::unique_ptr packet, - absl::optional send_time_ms) { + int64_t send_time_ms) { RTC_DCHECK(packet); MutexLock lock(&lock_); int64_t now_ms = clock_->TimeInMilliseconds(); @@ -145,11 +138,11 @@ void RtpPacketHistory::PutRtpPacket(std::unique_ptr packet, // Packet to be inserted ahead of first packet, expand front. for (; packet_index < 0; ++packet_index) { - packet_history_.emplace_front(nullptr, absl::nullopt, 0); + packet_history_.emplace_front(); } // Packet to be inserted behind last packet, expand back. while (static_cast(packet_history_.size()) <= packet_index) { - packet_history_.emplace_back(nullptr, absl::nullopt, 0); + packet_history_.emplace_back(); } RTC_DCHECK_GE(packet_index, 0); @@ -168,36 +161,6 @@ void RtpPacketHistory::PutRtpPacket(std::unique_ptr packet, } } -std::unique_ptr RtpPacketHistory::GetPacketAndSetSendTime( - uint16_t sequence_number) { - MutexLock lock(&lock_); - if (mode_ == StorageMode::kDisabled) { - return nullptr; - } - - StoredPacket* packet = GetStoredPacket(sequence_number); - if (packet == nullptr) { - return nullptr; - } - - int64_t now_ms = clock_->TimeInMilliseconds(); - if (!VerifyRtt(*packet, now_ms)) { - return nullptr; - } - - if (packet->send_time_ms_) { - packet->IncrementTimesRetransmitted( - enable_padding_prio_ ? &padding_priority_ : nullptr); - } - - // Update send-time and mark as no long in pacer queue. - packet->send_time_ms_ = now_ms; - packet->pending_transmission_ = false; - - // Return copy of packet instance since it may need to be retransmitted. - return std::make_unique(*packet->packet_); -} - std::unique_ptr RtpPacketHistory::GetPacketAndMarkAsPending( uint16_t sequence_number) { return GetPacketAndMarkAsPending( @@ -251,8 +214,6 @@ void RtpPacketHistory::MarkPacketAsSent(uint16_t sequence_number) { return; } - RTC_DCHECK(packet->send_time_ms_); - // Update send-time, mark as no longer in pacer queue, and increment // transmission count. packet->send_time_ms_ = clock_->TimeInMilliseconds(); @@ -261,41 +222,37 @@ void RtpPacketHistory::MarkPacketAsSent(uint16_t sequence_number) { : nullptr); } -absl::optional RtpPacketHistory::GetPacketState( - uint16_t sequence_number) const { +bool RtpPacketHistory::GetPacketState(uint16_t sequence_number) const { MutexLock lock(&lock_); if (mode_ == StorageMode::kDisabled) { - return absl::nullopt; + return false; } int packet_index = GetPacketIndex(sequence_number); if (packet_index < 0 || static_cast(packet_index) >= packet_history_.size()) { - return absl::nullopt; + return false; } const StoredPacket& packet = packet_history_[packet_index]; if (packet.packet_ == nullptr) { - return absl::nullopt; + return false; } if (!VerifyRtt(packet, clock_->TimeInMilliseconds())) { - return absl::nullopt; + return false; } - return StoredPacketToPacketState(packet); + return true; } bool RtpPacketHistory::VerifyRtt(const RtpPacketHistory::StoredPacket& packet, int64_t now_ms) const { - if (packet.send_time_ms_) { - // Send-time already set, this check must be for a retransmission. - if (packet.times_retransmitted() > 0 && - now_ms < *packet.send_time_ms_ + rtt_ms_) { - // This packet has already been retransmitted once, and the time since - // that even is lower than on RTT. Ignore request as this packet is - // likely already in the network pipe. - return false; - } + if (packet.times_retransmitted() > 0 && + now_ms < packet.send_time_ms_ + rtt_ms_) { + // This packet has already been retransmitted once, and the time since + // that even is lower than on RTT. Ignore request as this packet is + // likely already in the network pipe. + return false; } return true; @@ -368,21 +325,6 @@ void RtpPacketHistory::CullAcknowledgedPackets( } } -bool RtpPacketHistory::SetPendingTransmission(uint16_t sequence_number) { - MutexLock lock(&lock_); - if (mode_ == StorageMode::kDisabled) { - return false; - } - - StoredPacket* packet = GetStoredPacket(sequence_number); - if (packet == nullptr) { - return false; - } - - packet->pending_transmission_ = true; - return true; -} - void RtpPacketHistory::Clear() { MutexLock lock(&lock_); Reset(); @@ -410,13 +352,13 @@ void RtpPacketHistory::CullOldPackets(int64_t now_ms) { return; } - if (*stored_packet.send_time_ms_ + packet_duration_ms > now_ms) { + if (stored_packet.send_time_ms_ + packet_duration_ms > now_ms) { // Don't cull packets too early to avoid failed retransmission requests. return; } if (packet_history_.size() >= number_to_store_ || - *stored_packet.send_time_ms_ + + stored_packet.send_time_ms_ + (packet_duration_ms * kPacketCullingDelayFactor) <= now_ms) { // Too many packets in history, or this packet has timed out. Remove it @@ -487,17 +429,4 @@ RtpPacketHistory::StoredPacket* RtpPacketHistory::GetStoredPacket( return &packet_history_[index]; } -RtpPacketHistory::PacketState RtpPacketHistory::StoredPacketToPacketState( - const RtpPacketHistory::StoredPacket& stored_packet) { - RtpPacketHistory::PacketState state; - state.rtp_sequence_number = stored_packet.packet_->SequenceNumber(); - state.send_time_ms = stored_packet.send_time_ms_; - state.capture_time_ms = stored_packet.packet_->capture_time().ms(); - state.ssrc = stored_packet.packet_->Ssrc(); - state.packet_size = stored_packet.packet_->size(); - state.times_retransmitted = stored_packet.times_retransmitted(); - state.pending_transmission = stored_packet.pending_transmission_; - return state; -} - } // namespace webrtc diff --git a/modules/rtp_rtcp/source/rtp_packet_history.h b/modules/rtp_rtcp/source/rtp_packet_history.h index f87ad4d550..18cef0aa13 100644 --- a/modules/rtp_rtcp/source/rtp_packet_history.h +++ b/modules/rtp_rtcp/source/rtp_packet_history.h @@ -35,22 +35,6 @@ class RtpPacketHistory { // packets as they time out or as signaled as received. }; - // Snapshot indicating the state of a packet in the history. - struct PacketState { - PacketState(); - PacketState(const PacketState&); - ~PacketState(); - - uint16_t rtp_sequence_number = 0; - absl::optional send_time_ms; - int64_t capture_time_ms = 0; - uint32_t ssrc = 0; - size_t packet_size = 0; - // Number of times RE-transmitted, ie not including the first transmission. - size_t times_retransmitted = 0; - bool pending_transmission = false; - }; - // Maximum number of packets we ever allow in the history. static constexpr size_t kMaxCapacity = 9600; // Maximum number of entries in prioritized queue of padding packets. @@ -78,15 +62,8 @@ class RtpPacketHistory { // a packet in the history before we are reasonably sure it has been received. void SetRtt(int64_t rtt_ms); - // If `send_time` is set, packet was sent without using pacer, so state will - // be set accordingly. void PutRtpPacket(std::unique_ptr packet, - absl::optional send_time_ms); - - // Gets stored RTP packet corresponding to the input |sequence number|. - // Returns nullptr if packet is not found or was (re)sent too recently. - std::unique_ptr GetPacketAndSetSendTime( - uint16_t sequence_number); + int64_t send_time_ms); // Gets stored RTP packet corresponding to the input |sequence number|. // Returns nullptr if packet is not found or was (re)sent too recently. @@ -109,9 +86,9 @@ class RtpPacketHistory { // counter. Marks the packet as no longer being in the pacer queue. void MarkPacketAsSent(uint16_t sequence_number); - // Similar to GetPacketAndSetSendTime(), but only returns a snapshot of the - // current state for packet, and never updates internal state. - absl::optional GetPacketState(uint16_t sequence_number) const; + // Returns true if history contains packet with `sequence_number` and it can + // be retransmitted. + bool GetPacketState(uint16_t sequence_number) const; // Get the packet (if any) from the history, that is deemed most likely to // the remote side. This is calculated from heuristics such as packet age @@ -130,11 +107,6 @@ class RtpPacketHistory { // Cull packets that have been acknowledged as received by the remote end. void CullAcknowledgedPackets(rtc::ArrayView sequence_numbers); - // Mark packet as queued for transmission. This will prevent premature - // removal or duplicate retransmissions in the pacer queue. - // Returns true if status was set, false if packet was not found. - bool SetPendingTransmission(uint16_t sequence_number); - // Remove all pending packets from the history, but keep storage mode and // capacity. void Clear(); @@ -146,8 +118,9 @@ class RtpPacketHistory { class StoredPacket { public: + StoredPacket() = default; StoredPacket(std::unique_ptr packet, - absl::optional send_time_ms, + int64_t send_time_ms, uint64_t insert_order); StoredPacket(StoredPacket&&); StoredPacket& operator=(StoredPacket&&); @@ -158,7 +131,7 @@ class RtpPacketHistory { void IncrementTimesRetransmitted(PacketPrioritySet* priority_set); // The time of last transmission, including retransmissions. - absl::optional send_time_ms_; + int64_t send_time_ms_; // The actual packet. std::unique_ptr packet_; @@ -178,8 +151,7 @@ class RtpPacketHistory { bool operator()(StoredPacket* lhs, StoredPacket* rhs) const; }; - // Helper method used by GetPacketAndSetSendTime() and GetPacketState() to - // check if packet has too recently been sent. + // Helper method to check if packet has too recently been sent. bool VerifyRtt(const StoredPacket& packet, int64_t now_ms) const RTC_EXCLUSIVE_LOCKS_REQUIRED(lock_); void Reset() RTC_EXCLUSIVE_LOCKS_REQUIRED(lock_); @@ -192,8 +164,6 @@ class RtpPacketHistory { RTC_EXCLUSIVE_LOCKS_REQUIRED(lock_); StoredPacket* GetStoredPacket(uint16_t sequence_number) RTC_EXCLUSIVE_LOCKS_REQUIRED(lock_); - static PacketState StoredPacketToPacketState( - const StoredPacket& stored_packet); Clock* const clock_; const bool enable_padding_prio_; diff --git a/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc b/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc index ef9ce593b5..ffe167c5f6 100644 --- a/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc @@ -63,8 +63,8 @@ TEST_P(RtpPacketHistoryTest, SetStoreStatus) { TEST_P(RtpPacketHistoryTest, ClearsHistoryAfterSetStoreStatus) { hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 10); - // Store a packet, but with send-time. It should then not be removed. - hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), absl::nullopt); + hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), + fake_clock_.TimeInMilliseconds()); EXPECT_TRUE(hist_.GetPacketState(kStartSeqNum)); // Changing store status, even to the current one, will clear the history. @@ -74,17 +74,19 @@ TEST_P(RtpPacketHistoryTest, ClearsHistoryAfterSetStoreStatus) { TEST_P(RtpPacketHistoryTest, StartSeqResetAfterReset) { hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 10); - // Store a packet, but with send-time. It should then not be removed. - hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), absl::nullopt); - EXPECT_TRUE(hist_.GetPacketState(kStartSeqNum)); + hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), + fake_clock_.TimeInMilliseconds()); + // Mark packet as pending so it won't be removed. + EXPECT_TRUE(hist_.GetPacketAndMarkAsPending(kStartSeqNum)); // Changing store status, to clear the history. hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 10); EXPECT_FALSE(hist_.GetPacketState(kStartSeqNum)); // Add a new packet. - hist_.PutRtpPacket(CreateRtpPacket(To16u(kStartSeqNum + 1)), absl::nullopt); - EXPECT_TRUE(hist_.GetPacketState(To16u(kStartSeqNum + 1))); + hist_.PutRtpPacket(CreateRtpPacket(To16u(kStartSeqNum + 1)), + fake_clock_.TimeInMilliseconds()); + EXPECT_TRUE(hist_.GetPacketAndMarkAsPending(To16u(kStartSeqNum + 1))); // Advance time past where packet expires. fake_clock_.AdvanceTimeMilliseconds( @@ -92,7 +94,8 @@ TEST_P(RtpPacketHistoryTest, StartSeqResetAfterReset) { RtpPacketHistory::kMinPacketDurationMs); // Add one more packet and verify no state left from packet before reset. - hist_.PutRtpPacket(CreateRtpPacket(To16u(kStartSeqNum + 2)), absl::nullopt); + hist_.PutRtpPacket(CreateRtpPacket(To16u(kStartSeqNum + 2)), + fake_clock_.TimeInMilliseconds()); EXPECT_FALSE(hist_.GetPacketState(kStartSeqNum)); EXPECT_TRUE(hist_.GetPacketState(To16u(kStartSeqNum + 1))); EXPECT_TRUE(hist_.GetPacketState(To16u(kStartSeqNum + 2))); @@ -101,7 +104,7 @@ TEST_P(RtpPacketHistoryTest, StartSeqResetAfterReset) { TEST_P(RtpPacketHistoryTest, NoStoreStatus) { EXPECT_EQ(StorageMode::kDisabled, hist_.GetStorageMode()); std::unique_ptr packet = CreateRtpPacket(kStartSeqNum); - hist_.PutRtpPacket(std::move(packet), absl::nullopt); + hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMilliseconds()); // Packet should not be stored. EXPECT_FALSE(hist_.GetPacketState(kStartSeqNum)); } @@ -116,7 +119,7 @@ TEST_P(RtpPacketHistoryTest, PutRtpPacket) { std::unique_ptr packet = CreateRtpPacket(kStartSeqNum); EXPECT_FALSE(hist_.GetPacketState(kStartSeqNum)); - hist_.PutRtpPacket(std::move(packet), absl::nullopt); + hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMilliseconds()); EXPECT_TRUE(hist_.GetPacketState(kStartSeqNum)); } @@ -126,88 +129,16 @@ TEST_P(RtpPacketHistoryTest, GetRtpPacket) { std::unique_ptr packet = CreateRtpPacket(kStartSeqNum); packet->set_capture_time(capture_time); rtc::CopyOnWriteBuffer buffer = packet->Buffer(); - hist_.PutRtpPacket(std::move(packet), absl::nullopt); + hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMilliseconds()); std::unique_ptr packet_out = - hist_.GetPacketAndSetSendTime(kStartSeqNum); - EXPECT_TRUE(packet_out); + hist_.GetPacketAndMarkAsPending(kStartSeqNum); + ASSERT_TRUE(packet_out); EXPECT_EQ(buffer, packet_out->Buffer()); EXPECT_EQ(capture_time, packet_out->capture_time()); } -TEST_P(RtpPacketHistoryTest, PacketStateIsCorrect) { - const uint32_t kSsrc = 92384762; - const int64_t kRttMs = 100; - hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 10); - hist_.SetRtt(kRttMs); - std::unique_ptr packet = CreateRtpPacket(kStartSeqNum); - packet->SetSsrc(kSsrc); - packet->SetPayloadSize(1234); - const size_t packet_size = packet->size(); - - hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMilliseconds()); - - absl::optional state = - hist_.GetPacketState(kStartSeqNum); - ASSERT_TRUE(state); - EXPECT_EQ(state->rtp_sequence_number, kStartSeqNum); - EXPECT_EQ(state->send_time_ms, fake_clock_.TimeInMilliseconds()); - EXPECT_EQ(state->capture_time_ms, fake_clock_.TimeInMilliseconds()); - EXPECT_EQ(state->ssrc, kSsrc); - EXPECT_EQ(state->packet_size, packet_size); - EXPECT_EQ(state->times_retransmitted, 0u); - - fake_clock_.AdvanceTimeMilliseconds(1); - EXPECT_TRUE(hist_.GetPacketAndSetSendTime(kStartSeqNum)); - fake_clock_.AdvanceTimeMilliseconds(kRttMs + 1); - - state = hist_.GetPacketState(kStartSeqNum); - ASSERT_TRUE(state); - EXPECT_EQ(state->times_retransmitted, 1u); -} - -TEST_P(RtpPacketHistoryTest, MinResendTimeWithPacer) { - static const int64_t kMinRetransmitIntervalMs = 100; - - hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 10); - hist_.SetRtt(kMinRetransmitIntervalMs); - int64_t capture_time_ms = fake_clock_.TimeInMilliseconds(); - std::unique_ptr packet = CreateRtpPacket(kStartSeqNum); - size_t len = packet->size(); - hist_.PutRtpPacket(std::move(packet), absl::nullopt); - - // First transmission: TimeToSendPacket() call from pacer. - EXPECT_TRUE(hist_.GetPacketAndSetSendTime(kStartSeqNum)); - - // First retransmission - allow early retransmission. - fake_clock_.AdvanceTimeMilliseconds(1); - - // With pacer there's two calls to history: - // 1) When the NACK request arrived, use GetPacketState() to see if the - // packet is there and verify RTT constraints. Then we use the ssrc - // and sequence number to enqueue the retransmission in the pacer - // 2) When the pacer determines that it is time to send the packet, it calls - // GetPacketAndSetSendTime(). - absl::optional packet_state = - hist_.GetPacketState(kStartSeqNum); - EXPECT_TRUE(packet_state); - EXPECT_EQ(len, packet_state->packet_size); - EXPECT_EQ(capture_time_ms, packet_state->capture_time_ms); - - // Retransmission was allowed, next send it from pacer. - EXPECT_TRUE(hist_.GetPacketAndSetSendTime(kStartSeqNum)); - - // Second retransmission - advance time to just before retransmission OK. - fake_clock_.AdvanceTimeMilliseconds(kMinRetransmitIntervalMs - 1); - EXPECT_FALSE(hist_.GetPacketState(kStartSeqNum)); - - // Advance time to just after retransmission OK. - fake_clock_.AdvanceTimeMilliseconds(1); - EXPECT_TRUE(hist_.GetPacketState(kStartSeqNum)); - EXPECT_TRUE(hist_.GetPacketAndSetSendTime(kStartSeqNum)); -} - -TEST_P(RtpPacketHistoryTest, MinResendTimeWithoutPacer) { +TEST_P(RtpPacketHistoryTest, MinResendTime) { static const int64_t kMinRetransmitIntervalMs = 100; hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 10); @@ -219,18 +150,19 @@ TEST_P(RtpPacketHistoryTest, MinResendTimeWithoutPacer) { // First retransmission - allow early retransmission. fake_clock_.AdvanceTimeMilliseconds(1); - packet = hist_.GetPacketAndSetSendTime(kStartSeqNum); - EXPECT_TRUE(packet); + packet = hist_.GetPacketAndMarkAsPending(kStartSeqNum); + ASSERT_TRUE(packet); EXPECT_EQ(len, packet->size()); EXPECT_EQ(packet->capture_time(), capture_time); + hist_.MarkPacketAsSent(kStartSeqNum); // Second retransmission - advance time to just before retransmission OK. fake_clock_.AdvanceTimeMilliseconds(kMinRetransmitIntervalMs - 1); - EXPECT_FALSE(hist_.GetPacketAndSetSendTime(kStartSeqNum)); + EXPECT_FALSE(hist_.GetPacketAndMarkAsPending(kStartSeqNum)); // Advance time to just after retransmission OK. fake_clock_.AdvanceTimeMilliseconds(1); - EXPECT_TRUE(hist_.GetPacketAndSetSendTime(kStartSeqNum)); + EXPECT_TRUE(hist_.GetPacketAndMarkAsPending(kStartSeqNum)); } TEST_P(RtpPacketHistoryTest, RemovesOldestSentPacketWhenAtMaxSize) { @@ -275,8 +207,9 @@ TEST_P(RtpPacketHistoryTest, RemovesOldestPacketWhenAtMaxCapacity) { for (size_t i = 0; i < kMaxNumPackets; ++i) { std::unique_ptr packet = CreateRtpPacket(To16u(kStartSeqNum + i)); - // Don't mark packets as sent, preventing them from being removed. - hist_.PutRtpPacket(std::move(packet), absl::nullopt); + hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMilliseconds()); + // Mark packets as pending, preventing it from being removed. + hist_.GetPacketAndMarkAsPending(To16u(kStartSeqNum + i)); } // First packet should still be there. @@ -329,39 +262,6 @@ TEST_P(RtpPacketHistoryTest, RemovesLowestPrioPaddingWhenAtMaxCapacity) { EXPECT_EQ(packet->SequenceNumber(), To16u(kStartSeqNum + kMaxNumPackets)); } -TEST_P(RtpPacketHistoryTest, DontRemoveUnsentPackets) { - const size_t kMaxNumPackets = 10; - hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, kMaxNumPackets); - - // Add packets until the buffer is full. - for (size_t i = 0; i < kMaxNumPackets; ++i) { - // Mark packets as unsent. - hist_.PutRtpPacket(CreateRtpPacket(To16u(kStartSeqNum + i)), absl::nullopt); - } - fake_clock_.AdvanceTimeMilliseconds(RtpPacketHistory::kMinPacketDurationMs); - - // First packet should still be there. - EXPECT_TRUE(hist_.GetPacketState(kStartSeqNum)); - - // History is full, but old packets not sent, so allow expansion. - hist_.PutRtpPacket(CreateRtpPacket(To16u(kStartSeqNum + kMaxNumPackets)), - fake_clock_.TimeInMilliseconds()); - EXPECT_TRUE(hist_.GetPacketState(kStartSeqNum)); - - // Set all packet as sent and advance time past min packet duration time, - // otherwise packets till still be prevented from being removed. - for (size_t i = 0; i <= kMaxNumPackets; ++i) { - EXPECT_TRUE(hist_.GetPacketAndSetSendTime(To16u(kStartSeqNum + i))); - } - fake_clock_.AdvanceTimeMilliseconds(RtpPacketHistory::kMinPacketDurationMs); - // Add a new packet, this means the two oldest ones will be culled. - hist_.PutRtpPacket(CreateRtpPacket(To16u(kStartSeqNum + kMaxNumPackets + 1)), - fake_clock_.TimeInMilliseconds()); - EXPECT_FALSE(hist_.GetPacketState(kStartSeqNum)); - EXPECT_FALSE(hist_.GetPacketState(To16u(kStartSeqNum + 1))); - EXPECT_TRUE(hist_.GetPacketState(To16u(kStartSeqNum + 2))); -} - TEST_P(RtpPacketHistoryTest, DontRemoveTooRecentlyTransmittedPackets) { // Set size to remove old packets as soon as possible. hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 1); @@ -476,29 +376,26 @@ TEST_P(RtpPacketHistoryTest, CullWithAcks) { std::unique_ptr packet = CreateRtpPacket(kStartSeqNum); packet->SetPayloadSize(50); hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMilliseconds()); - hist_.GetPacketAndSetSendTime(kStartSeqNum); fake_clock_.AdvanceTimeMilliseconds(33); packet = CreateRtpPacket(To16u(kStartSeqNum + 1)); packet->SetPayloadSize(50); hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMilliseconds()); - hist_.GetPacketAndSetSendTime(To16u(kStartSeqNum + 1)); fake_clock_.AdvanceTimeMilliseconds(33); packet = CreateRtpPacket(To16u(kStartSeqNum + 2)); packet->SetPayloadSize(50); hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMilliseconds()); - hist_.GetPacketAndSetSendTime(To16u(kStartSeqNum + 2)); - EXPECT_TRUE(hist_.GetPacketState(kStartSeqNum).has_value()); - EXPECT_TRUE(hist_.GetPacketState(To16u(kStartSeqNum + 1)).has_value()); - EXPECT_TRUE(hist_.GetPacketState(To16u(kStartSeqNum + 2)).has_value()); + EXPECT_TRUE(hist_.GetPacketState(kStartSeqNum)); + EXPECT_TRUE(hist_.GetPacketState(To16u(kStartSeqNum + 1))); + EXPECT_TRUE(hist_.GetPacketState(To16u(kStartSeqNum + 2))); // Remove middle one using ack, check that only that one is gone. std::vector acked_sequence_numbers = {To16u(kStartSeqNum + 1)}; hist_.CullAcknowledgedPackets(acked_sequence_numbers); - EXPECT_TRUE(hist_.GetPacketState(kStartSeqNum).has_value()); - EXPECT_FALSE(hist_.GetPacketState(To16u(kStartSeqNum + 1)).has_value()); - EXPECT_TRUE(hist_.GetPacketState(To16u(kStartSeqNum + 2)).has_value()); + EXPECT_TRUE(hist_.GetPacketState(kStartSeqNum)); + EXPECT_FALSE(hist_.GetPacketState(To16u(kStartSeqNum + 1))); + EXPECT_TRUE(hist_.GetPacketState(To16u(kStartSeqNum + 2))); // Advance time to where second packet would have expired, verify first packet // is removed. @@ -506,58 +403,16 @@ TEST_P(RtpPacketHistoryTest, CullWithAcks) { fake_clock_.AdvanceTimeMilliseconds(second_packet_expiry_time - fake_clock_.TimeInMilliseconds()); hist_.SetRtt(1); // Trigger culling of old packets. - EXPECT_FALSE(hist_.GetPacketState(kStartSeqNum).has_value()); - EXPECT_FALSE(hist_.GetPacketState(To16u(kStartSeqNum + 1)).has_value()); - EXPECT_TRUE(hist_.GetPacketState(To16u(kStartSeqNum + 2)).has_value()); + EXPECT_FALSE(hist_.GetPacketState(kStartSeqNum)); + EXPECT_FALSE(hist_.GetPacketState(To16u(kStartSeqNum + 1))); + EXPECT_TRUE(hist_.GetPacketState(To16u(kStartSeqNum + 2))); // Advance to where last packet expires, verify all gone. fake_clock_.AdvanceTimeMilliseconds(33); hist_.SetRtt(1); // Trigger culling of old packets. - EXPECT_FALSE(hist_.GetPacketState(kStartSeqNum).has_value()); - EXPECT_FALSE(hist_.GetPacketState(To16u(kStartSeqNum + 1)).has_value()); - EXPECT_FALSE(hist_.GetPacketState(To16u(kStartSeqNum + 2)).has_value()); -} - -TEST_P(RtpPacketHistoryTest, SetsPendingTransmissionState) { - const int64_t kRttMs = RtpPacketHistory::kMinPacketDurationMs * 2; - hist_.SetRtt(kRttMs); - - // Set size to remove old packets as soon as possible. - hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 1); - - // Add a packet, without send time, indicating it's in pacer queue. - hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), - /* send_time_ms = */ absl::nullopt); - - // Packet is pending transmission. - absl::optional packet_state = - hist_.GetPacketState(kStartSeqNum); - ASSERT_TRUE(packet_state.has_value()); - EXPECT_TRUE(packet_state->pending_transmission); - - // Packet sent, state should be back to non-pending. - EXPECT_TRUE(hist_.GetPacketAndSetSendTime(kStartSeqNum)); - packet_state = hist_.GetPacketState(kStartSeqNum); - ASSERT_TRUE(packet_state.has_value()); - EXPECT_FALSE(packet_state->pending_transmission); - - // Time for a retransmission. - fake_clock_.AdvanceTimeMilliseconds(kRttMs); - EXPECT_TRUE(hist_.SetPendingTransmission(kStartSeqNum)); - packet_state = hist_.GetPacketState(kStartSeqNum); - ASSERT_TRUE(packet_state.has_value()); - EXPECT_TRUE(packet_state->pending_transmission); - - // Packet sent. - EXPECT_TRUE(hist_.GetPacketAndSetSendTime(kStartSeqNum)); - // Too early for retransmission. - ASSERT_FALSE(hist_.GetPacketState(kStartSeqNum).has_value()); - - // Retransmission allowed again, it's not in a pending state. - fake_clock_.AdvanceTimeMilliseconds(kRttMs); - packet_state = hist_.GetPacketState(kStartSeqNum); - ASSERT_TRUE(packet_state.has_value()); - EXPECT_FALSE(packet_state->pending_transmission); + EXPECT_FALSE(hist_.GetPacketState(kStartSeqNum)); + EXPECT_FALSE(hist_.GetPacketState(To16u(kStartSeqNum + 1))); + EXPECT_FALSE(hist_.GetPacketState(To16u(kStartSeqNum + 2))); } TEST_P(RtpPacketHistoryTest, GetPacketAndSetSent) { @@ -647,21 +502,17 @@ TEST_P(RtpPacketHistoryTest, DontRemovePendingTransmissions) { // Advance clock to just before packet timeout. fake_clock_.AdvanceTimeMilliseconds(kPacketTimeoutMs - 1); // Mark as enqueued in pacer. - EXPECT_TRUE(hist_.SetPendingTransmission(kStartSeqNum)); + EXPECT_TRUE(hist_.GetPacketAndMarkAsPending(kStartSeqNum)); // Advance clock to where packet would have timed out. It should still // be there and pending. fake_clock_.AdvanceTimeMilliseconds(1); - absl::optional packet_state = - hist_.GetPacketState(kStartSeqNum); - ASSERT_TRUE(packet_state.has_value()); - EXPECT_TRUE(packet_state->pending_transmission); + EXPECT_TRUE(hist_.GetPacketState(kStartSeqNum)); // Packet sent. Now it can be removed. - EXPECT_TRUE(hist_.GetPacketAndSetSendTime(kStartSeqNum)); + hist_.MarkPacketAsSent(kStartSeqNum); hist_.SetRtt(kRttMs); // Force culling of old packets. - packet_state = hist_.GetPacketState(kStartSeqNum); - ASSERT_FALSE(packet_state.has_value()); + EXPECT_FALSE(hist_.GetPacketState(kStartSeqNum)); } TEST_P(RtpPacketHistoryTest, PrioritizedPayloadPadding) { @@ -716,11 +567,11 @@ TEST_P(RtpPacketHistoryTest, NoPendingPacketAsPadding) { EXPECT_EQ(hist_.GetPayloadPaddingPacket()->SequenceNumber(), kStartSeqNum); // If packet is pending retransmission, don't try to use it as padding. - hist_.SetPendingTransmission(kStartSeqNum); + hist_.GetPacketAndMarkAsPending(kStartSeqNum); EXPECT_EQ(nullptr, hist_.GetPayloadPaddingPacket()); // Market it as no longer pending, should be usable as padding again. - hist_.GetPacketAndSetSendTime(kStartSeqNum); + hist_.MarkPacketAsSent(kStartSeqNum); EXPECT_EQ(hist_.GetPayloadPaddingPacket()->SequenceNumber(), kStartSeqNum); } @@ -766,29 +617,22 @@ TEST_P(RtpPacketHistoryTest, OutOfOrderInsertRemoval) { // Insert packets, out of order, including both forwards and backwards // sequence number wraps. const int seq_offsets[] = {0, 1, -1, 2, -2, 3, -3}; - const int64_t start_time_ms = fake_clock_.TimeInMilliseconds(); for (int offset : seq_offsets) { uint16_t seq_no = To16u(kStartSeqNum + offset); std::unique_ptr packet = CreateRtpPacket(seq_no); packet->SetPayloadSize(50); hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMilliseconds()); - hist_.GetPacketAndSetSendTime(seq_no); fake_clock_.AdvanceTimeMilliseconds(33); } // Check packet are there and remove them in the same out-of-order fashion. - int64_t expected_time_offset_ms = 0; for (int offset : seq_offsets) { uint16_t seq_no = To16u(kStartSeqNum + offset); - absl::optional packet_state = - hist_.GetPacketState(seq_no); - ASSERT_TRUE(packet_state.has_value()); - EXPECT_EQ(packet_state->send_time_ms, - start_time_ms + expected_time_offset_ms); + EXPECT_TRUE(hist_.GetPacketState(seq_no)); std::vector acked_sequence_numbers = {seq_no}; hist_.CullAcknowledgedPackets(acked_sequence_numbers); - expected_time_offset_ms += 33; + EXPECT_FALSE(hist_.GetPacketState(seq_no)); } } diff --git a/modules/rtp_rtcp/source/rtp_sender.cc b/modules/rtp_rtcp/source/rtp_sender.cc index a9bc57f7ca..f644c7d64a 100644 --- a/modules/rtp_rtcp/source/rtp_sender.cc +++ b/modules/rtp_rtcp/source/rtp_sender.cc @@ -286,16 +286,7 @@ void RTPSender::SetRtxPayloadType(int payload_type, } int32_t RTPSender::ReSendPacket(uint16_t packet_id) { - // Try to find packet in RTP packet history. Also verify RTT here, so that we - // don't retransmit too often. - absl::optional stored_packet = - packet_history_->GetPacketState(packet_id); - if (!stored_packet || stored_packet->pending_transmission) { - // Packet not found or already queued for retransmission, ignore. - return 0; - } - - const int32_t packet_size = static_cast(stored_packet->packet_size); + int32_t packet_size = 0; const bool rtx = (RtxStatus() & kRtxRetransmitted) > 0; std::unique_ptr packet = @@ -304,6 +295,7 @@ int32_t RTPSender::ReSendPacket(uint16_t packet_id) { // Check if we're overusing retransmission bitrate. // TODO(sprang): Add histograms for nack success or failure // reasons. + packet_size = stored_packet.size(); std::unique_ptr retransmit_packet; if (retransmission_rate_limiter_ && !retransmission_rate_limiter_->TryUseRate(packet_size)) { @@ -321,7 +313,14 @@ int32_t RTPSender::ReSendPacket(uint16_t packet_id) { } return retransmit_packet; }); + if (packet_size == 0) { + // Packet not found or already queued for retransmission, ignore. + RTC_DCHECK(!packet); + return 0; + } if (!packet) { + // Packet was found, but lambda helper above chose not to create + // `retransmit_packet` out of it. return -1; } packet->set_packet_type(RtpPacketMediaType::kRetransmission); diff --git a/modules/rtp_rtcp/source/rtp_sender_egress_unittest.cc b/modules/rtp_rtcp/source/rtp_sender_egress_unittest.cc index 3d345b1727..ee7123b112 100644 --- a/modules/rtp_rtcp/source/rtp_sender_egress_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_sender_egress_unittest.cc @@ -496,8 +496,7 @@ TEST_P(RtpSenderEgressTest, DoesNotPutNotRetransmittablePacketsInHistory) { std::unique_ptr packet = BuildRtpPacket(); packet->set_allow_retransmission(false); sender->SendPacket(packet.get(), PacedPacketInfo()); - EXPECT_FALSE( - packet_history_.GetPacketState(packet->SequenceNumber()).has_value()); + EXPECT_FALSE(packet_history_.GetPacketState(packet->SequenceNumber())); } TEST_P(RtpSenderEgressTest, PutsRetransmittablePacketsInHistory) { @@ -508,10 +507,7 @@ TEST_P(RtpSenderEgressTest, PutsRetransmittablePacketsInHistory) { std::unique_ptr packet = BuildRtpPacket(); packet->set_allow_retransmission(true); sender->SendPacket(packet.get(), PacedPacketInfo()); - EXPECT_THAT( - packet_history_.GetPacketState(packet->SequenceNumber()), - Optional( - Field(&RtpPacketHistory::PacketState::pending_transmission, false))); + EXPECT_TRUE(packet_history_.GetPacketState(packet->SequenceNumber())); } TEST_P(RtpSenderEgressTest, DoesNotPutNonMediaInHistory) { @@ -527,22 +523,20 @@ TEST_P(RtpSenderEgressTest, DoesNotPutNonMediaInHistory) { retransmission->set_retransmitted_sequence_number( retransmission->SequenceNumber()); sender->SendPacket(retransmission.get(), PacedPacketInfo()); - EXPECT_FALSE(packet_history_.GetPacketState(retransmission->SequenceNumber()) - .has_value()); + EXPECT_FALSE( + packet_history_.GetPacketState(retransmission->SequenceNumber())); std::unique_ptr fec = BuildRtpPacket(); fec->set_allow_retransmission(true); fec->set_packet_type(RtpPacketMediaType::kForwardErrorCorrection); sender->SendPacket(fec.get(), PacedPacketInfo()); - EXPECT_FALSE( - packet_history_.GetPacketState(fec->SequenceNumber()).has_value()); + EXPECT_FALSE(packet_history_.GetPacketState(fec->SequenceNumber())); std::unique_ptr padding = BuildRtpPacket(); padding->set_allow_retransmission(true); padding->set_packet_type(RtpPacketMediaType::kPadding); sender->SendPacket(padding.get(), PacedPacketInfo()); - EXPECT_FALSE( - packet_history_.GetPacketState(padding->SequenceNumber()).has_value()); + EXPECT_FALSE(packet_history_.GetPacketState(padding->SequenceNumber())); } TEST_P(RtpSenderEgressTest, UpdatesSendStatusOfRetransmittedPackets) { @@ -554,10 +548,7 @@ TEST_P(RtpSenderEgressTest, UpdatesSendStatusOfRetransmittedPackets) { std::unique_ptr media_packet = BuildRtpPacket(); media_packet->set_allow_retransmission(true); sender->SendPacket(media_packet.get(), PacedPacketInfo()); - EXPECT_THAT( - packet_history_.GetPacketState(media_packet->SequenceNumber()), - Optional( - Field(&RtpPacketHistory::PacketState::pending_transmission, false))); + EXPECT_TRUE(packet_history_.GetPacketState(media_packet->SequenceNumber())); // Simulate a retransmission, marking the packet as pending. std::unique_ptr retransmission = @@ -565,16 +556,11 @@ TEST_P(RtpSenderEgressTest, UpdatesSendStatusOfRetransmittedPackets) { retransmission->set_retransmitted_sequence_number( media_packet->SequenceNumber()); retransmission->set_packet_type(RtpPacketMediaType::kRetransmission); - EXPECT_THAT(packet_history_.GetPacketState(media_packet->SequenceNumber()), - Optional(Field( - &RtpPacketHistory::PacketState::pending_transmission, true))); + EXPECT_TRUE(packet_history_.GetPacketState(media_packet->SequenceNumber())); // Simulate packet leaving pacer, the packet should be marked as non-pending. sender->SendPacket(retransmission.get(), PacedPacketInfo()); - EXPECT_THAT( - packet_history_.GetPacketState(media_packet->SequenceNumber()), - Optional( - Field(&RtpPacketHistory::PacketState::pending_transmission, false))); + EXPECT_TRUE(packet_history_.GetPacketState(media_packet->SequenceNumber())); } TEST_P(RtpSenderEgressTest, StreamDataCountersCallbacks) { From 3e64739a76ca6130088817c6da189d53308a8e40 Mon Sep 17 00:00:00 2001 From: Jonas Oreland Date: Thu, 3 Mar 2022 13:50:50 +0100 Subject: [PATCH 095/847] Add support for caching networks based on NetworkCallback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change adds a cache for networks in the SimpleNetworkCallback that is already registered, allowing the cache to be used preferentially as opposed to the deprecated getAllNetworks call. This is a fork of https://webrtc-review.googlesource.com/c/src/+/251401 - adds field trials for new behavior - removes test that did not work - add (poor) test of field trials - remove the "network_monitor_java" build target (that I could not find any reference to...) Bug: webrtc:13741 Change-Id: I2829c2f1940d4b42455d8e1a2217cf15c133e22b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252284 Reviewed-by: Xavier Lepaul‎ Commit-Queue: Jonas Oreland Cr-Commit-Position: refs/heads/main@{#36121} --- sdk/android/BUILD.gn | 18 --- .../org/webrtc/NetworkMonitorAutoDetect.java | 104 ++++++++++++++---- .../src/org/webrtc/NetworkMonitorTest.java | 88 ++++++++++++++- 3 files changed, 169 insertions(+), 41 deletions(-) diff --git a/sdk/android/BUILD.gn b/sdk/android/BUILD.gn index 85ec5f7f99..e0b8b0c81c 100644 --- a/sdk/android/BUILD.gn +++ b/sdk/android/BUILD.gn @@ -537,24 +537,6 @@ if (is_android) { "//third_party/androidx:androidx_annotation_annotation_java", ] } - - rtc_android_library("network_monitor_java") { - visibility = [ "*" ] - sources = [ - "api/org/webrtc/NetworkChangeDetector.java", - "api/org/webrtc/NetworkChangeDetectorFactory.java", - "api/org/webrtc/NetworkMonitor.java", - "api/org/webrtc/NetworkMonitorAutoDetect.java", - ] - deps = [ - ":base_java", - ":logging_java", - "//rtc_base:base_java", - "//third_party/android_deps:com_android_support_support_annotations_java", - "//third_party/androidx:androidx_annotation_annotation_java", - ] - srcjar_deps = [ "//rtc_base:network_monitor_enums" ] - } } if (current_os == "linux" || is_android) { diff --git a/sdk/android/api/org/webrtc/NetworkMonitorAutoDetect.java b/sdk/android/api/org/webrtc/NetworkMonitorAutoDetect.java index 771059eb08..052e7c80a9 100644 --- a/sdk/android/api/org/webrtc/NetworkMonitorAutoDetect.java +++ b/sdk/android/api/org/webrtc/NetworkMonitorAutoDetect.java @@ -29,13 +29,18 @@ import android.net.wifi.p2p.WifiP2pManager; import android.os.Build; import android.telephony.TelephonyManager; +import androidx.annotation.GuardedBy; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.annotation.VisibleForTesting; import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.util.ArrayList; import java.util.Collections; +import java.util.HashSet; import java.util.List; +import java.util.Set; /** * Borrowed from Chromium's @@ -87,16 +92,23 @@ public int getUnderlyingNetworkSubtypeForVpn() { return underlyingNetworkSubtypeForVpn; } } - /** - * The methods in this class get called when the network changes if the callback - * is registered with a proper network request. It is only available in Android Lollipop - * and above. - */ + @SuppressLint("NewApi") - private class SimpleNetworkCallback extends NetworkCallback { + @VisibleForTesting() + class SimpleNetworkCallback extends NetworkCallback { + @GuardedBy("availableNetworks") final Set availableNetworks; + + SimpleNetworkCallback(Set availableNetworks) { + this.availableNetworks = availableNetworks; + } + @Override public void onAvailable(Network network) { Logging.d(TAG, "Network becomes available: " + network.toString()); + + synchronized (availableNetworks) { + availableNetworks.add(network); + } onNetworkChanged(network); } @@ -130,6 +142,10 @@ public void onLosing(Network network, int maxMsToLive) { @Override public void onLost(Network network) { Logging.d(TAG, "Network " + network.toString() + " is disconnected"); + + synchronized (availableNetworks) { + availableNetworks.remove(network); + } observer.onNetworkDisconnect(networkToNetId(network)); } @@ -149,15 +165,40 @@ static class ConnectivityManagerDelegate { */ @Nullable private final ConnectivityManager connectivityManager; - ConnectivityManagerDelegate(Context context) { - connectivityManager = - (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); + /** + * Note: The availableNetworks set is instantiated in NetworkMonitorAutoDetect + * and the instance is mutated by SimpleNetworkCallback. + */ + @NonNull @GuardedBy("availableNetworks") private final Set availableNetworks; + + /** field trials */ + private final boolean getAllNetworksFromCache; + private final boolean requestVPN; + private final boolean includeOtherUidNetworks; + + ConnectivityManagerDelegate(Context context, Set availableNetworks) { + this((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE), + availableNetworks, + PeerConnectionFactory.fieldTrialsFindFullName("WebRTC-NetworkMonitorAutoDetect")); } - // For testing. - ConnectivityManagerDelegate() { - // All the methods below should be overridden. - connectivityManager = null; + @VisibleForTesting + ConnectivityManagerDelegate(ConnectivityManager connectivityManager, + Set availableNetworks, String fieldTrials) { + this.connectivityManager = connectivityManager; + this.availableNetworks = availableNetworks; + this.getAllNetworksFromCache = checkFieldTrial(fieldTrials, "getAllNetworksFromCache", false); + this.requestVPN = checkFieldTrial(fieldTrials, "requestVPN", false); + this.includeOtherUidNetworks = checkFieldTrial(fieldTrials, "includeOtherUidNetworks", false); + } + + private static boolean checkFieldTrial(String fieldTrials, String key, boolean defaultValue) { + if (fieldTrials.contains(key + "/Enabled")) { + return true; + } else if (fieldTrials.contains(key + "/Disabled")) { + return false; + } + return defaultValue; } /** @@ -265,6 +306,13 @@ Network[] getAllNetworks() { if (connectivityManager == null) { return new Network[0]; } + + if (supportNetworkCallback() && getAllNetworksFromCache) { + synchronized (availableNetworks) { + return availableNetworks.toArray(new Network[0]); + } + } + return connectivityManager.getAllNetworks(); } @@ -385,14 +433,26 @@ boolean hasInternetCapability(Network network) { && capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); } + @SuppressLint("NewApi") + @VisibleForTesting() + NetworkRequest createNetworkRequest() { + // Requests the following capabilities by default: NOT_VPN, NOT_RESTRICTED, TRUSTED + NetworkRequest.Builder builder = + new NetworkRequest.Builder().addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); + + if (requestVPN) { + builder.removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN); + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && includeOtherUidNetworks) { + builder.setIncludeOtherUidNetworks(true); + } + return builder.build(); + } + /** Only callable on Lollipop and newer releases. */ @SuppressLint("NewApi") public void registerNetworkCallback(NetworkCallback networkCallback) { - connectivityManager.registerNetworkCallback( - new NetworkRequest.Builder() - .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) - .build(), - networkCallback); + connectivityManager.registerNetworkCallback(createNetworkRequest(), networkCallback); } /** Only callable on Lollipop and newer releases. */ @@ -424,7 +484,7 @@ public void releaseCallback(NetworkCallback networkCallback) { } public boolean supportNetworkCallback() { - return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && connectivityManager != null; + return connectivityManager != null; } } @@ -567,6 +627,8 @@ private void onWifiP2pStateChange(int state) { private WifiDirectManagerDelegate wifiDirectManagerDelegate; private static boolean includeWifiDirect; + @GuardedBy("availableNetworks") final Set availableNetworks = new HashSet<>(); + private boolean isRegistered; private NetworkChangeDetector.ConnectionType connectionType; private String wifiSSID; @@ -576,7 +638,7 @@ private void onWifiP2pStateChange(int state) { public NetworkMonitorAutoDetect(NetworkChangeDetector.Observer observer, Context context) { this.observer = observer; this.context = context; - connectivityManagerDelegate = new ConnectivityManagerDelegate(context); + connectivityManagerDelegate = new ConnectivityManagerDelegate(context, availableNetworks); wifiManagerDelegate = new WifiManagerDelegate(context); final NetworkState networkState = connectivityManagerDelegate.getNetworkState(); @@ -600,7 +662,7 @@ public NetworkMonitorAutoDetect(NetworkChangeDetector.Observer observer, Context tempNetworkCallback = null; } mobileNetworkCallback = tempNetworkCallback; - allNetworkCallback = new SimpleNetworkCallback(); + allNetworkCallback = new SimpleNetworkCallback(availableNetworks); connectivityManagerDelegate.registerNetworkCallback(allNetworkCallback); } else { mobileNetworkCallback = null; diff --git a/sdk/android/instrumentationtests/src/org/webrtc/NetworkMonitorTest.java b/sdk/android/instrumentationtests/src/org/webrtc/NetworkMonitorTest.java index a30292c5cb..a80cd952c8 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/NetworkMonitorTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/NetworkMonitorTest.java @@ -10,17 +10,22 @@ package org.webrtc; +import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.CALLS_REAL_METHODS; +import static org.mockito.Mockito.mock; import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import android.net.ConnectivityManager; import android.net.Network; +import android.net.NetworkCapabilities; +import android.net.NetworkRequest; import android.os.Build; import android.os.Handler; import android.os.Looper; @@ -28,7 +33,11 @@ import androidx.annotation.Nullable; import androidx.test.filters.MediumTest; import androidx.test.filters.SmallTest; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.chromium.base.test.BaseJUnit4ClassRunner; import org.chromium.base.test.UiThreadTest; import org.junit.Before; @@ -39,6 +48,7 @@ import org.webrtc.NetworkChangeDetector.NetworkInformation; import org.webrtc.NetworkMonitorAutoDetect.ConnectivityManagerDelegate; import org.webrtc.NetworkMonitorAutoDetect.NetworkState; +import org.webrtc.NetworkMonitorAutoDetect.SimpleNetworkCallback; /** * Tests for org.webrtc.NetworkMonitor. @@ -83,6 +93,14 @@ private static class MockConnectivityManagerDelegate extends ConnectivityManager private int underlyingNetworkTypeForVpn; private int underlyingNetworkSubtypeForVpn; + MockConnectivityManagerDelegate() { + this(new HashSet<>(), ""); + } + + MockConnectivityManagerDelegate(Set availableNetworks, String fieldTrialsString) { + super(null, availableNetworks, fieldTrialsString); + } + @Override public NetworkState getNetworkState() { return new NetworkState(activeNetworkExists, networkType, networkSubtype, @@ -275,8 +293,8 @@ public void testNetworkMonitorJavaObservers() throws InterruptedException { @UiThreadTest @SmallTest public void testConnectivityManagerDelegateDoesNotCrash() { - ConnectivityManagerDelegate delegate = - new ConnectivityManagerDelegate(InstrumentationRegistry.getTargetContext()); + ConnectivityManagerDelegate delegate = new ConnectivityManagerDelegate( + InstrumentationRegistry.getTargetContext(), new HashSet<>()); delegate.getNetworkState(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Network[] networks = delegate.getAllNetworks(); @@ -288,6 +306,72 @@ public void testConnectivityManagerDelegateDoesNotCrash() { } } + /** Tests that ConnectivityManagerDelegate preferentially reads from the cache */ + @Test + @SmallTest + public void testConnectivityManagerDelegatePreferentiallyReadsFromCache() { + final Set availableNetworks = new HashSet<>(); + ConnectivityManagerDelegate delegate = new ConnectivityManagerDelegate( + (ConnectivityManager) InstrumentationRegistry.getTargetContext().getSystemService( + Context.CONNECTIVITY_SERVICE), + availableNetworks, "getAllNetworksFromCache/Enabled/"); + + Network[] networks = delegate.getAllNetworks(); + assertTrue(networks.length == 0); + + final Network mockNetwork = mock(Network.class); + availableNetworks.add(mockNetwork); + + assertArrayEquals(new Network[] {mockNetwork}, delegate.getAllNetworks()); + } + + /** Tests field trial parsing */ + + @Test + @SmallTest + public void testConnectivityManager_requestVPN_disabled() { + NetworkRequest request = getNetworkRequestForFieldTrials("requestVPN/Disabled"); + assertTrue(request.equals(new NetworkRequest.Builder() + .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) + .build())); + } + + @Test + @SmallTest + public void testConnectivityManager_requestVPN_enabled() { + NetworkRequest request = getNetworkRequestForFieldTrials("requestVPN/Enabled"); + assertTrue(request.equals(new NetworkRequest.Builder() + .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) + .removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN) + .build())); + } + + @Test + @SmallTest + public void testConnectivityManager_includeOtherUidNetworks_disabled() { + NetworkRequest request = getNetworkRequestForFieldTrials("includeOtherUidNetworks/Disabled"); + assertTrue(request.equals(new NetworkRequest.Builder() + .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) + .build())); + } + + @Test + @SmallTest + public void testConnectivityManager_includeOtherUidNetworks_enabled() { + NetworkRequest request = getNetworkRequestForFieldTrials("includeOtherUidNetworks/Enabled"); + NetworkRequest.Builder builder = + new NetworkRequest.Builder().addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + builder.setIncludeOtherUidNetworks(true); + } + assertTrue(request.equals(builder.build())); + } + + private NetworkRequest getNetworkRequestForFieldTrials(String fieldTrials) { + return new ConnectivityManagerDelegate(null, new HashSet<>(), fieldTrials) + .createNetworkRequest(); + } + /** * Tests that NetworkMonitorAutoDetect queryable APIs don't crash. This test cannot rely * on having any active network connections so it cannot usefully check results, but it can at From 45623a3c0f49e656fbd181faa90281a4dfc0e629 Mon Sep 17 00:00:00 2001 From: Evan Shrubsole Date: Thu, 3 Mar 2022 13:46:56 +0100 Subject: [PATCH 096/847] Remove operator= from VCMJitterEstimator and VCMRttFilter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I70846d9cdc17d904585a18983acee7980292e62e Bug: None Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253301 Reviewed-by: Erik Språng Commit-Queue: Evan Shrubsole Cr-Commit-Position: refs/heads/main@{#36122} --- modules/video_coding/jitter_estimator.cc | 26 ------------------------ modules/video_coding/jitter_estimator.h | 3 ++- modules/video_coding/rtt_filter.cc | 15 -------------- modules/video_coding/rtt_filter.h | 4 ++-- 4 files changed, 4 insertions(+), 44 deletions(-) diff --git a/modules/video_coding/jitter_estimator.cc b/modules/video_coding/jitter_estimator.cc index 87848aec06..38ce35b61e 100644 --- a/modules/video_coding/jitter_estimator.cc +++ b/modules/video_coding/jitter_estimator.cc @@ -58,32 +58,6 @@ VCMJitterEstimator::VCMJitterEstimator(Clock* clock) VCMJitterEstimator::~VCMJitterEstimator() {} -VCMJitterEstimator& VCMJitterEstimator::operator=( - const VCMJitterEstimator& rhs) { - if (this != &rhs) { - memcpy(_thetaCov, rhs._thetaCov, sizeof(_thetaCov)); - memcpy(_Qcov, rhs._Qcov, sizeof(_Qcov)); - - _avgFrameSize = rhs._avgFrameSize; - _varFrameSize = rhs._varFrameSize; - _maxFrameSize = rhs._maxFrameSize; - _fsSum = rhs._fsSum; - _fsCount = rhs._fsCount; - _lastUpdateT = rhs._lastUpdateT; - _prevEstimate = rhs._prevEstimate; - _prevFrameSize = rhs._prevFrameSize; - _avgNoise = rhs._avgNoise; - _alphaCount = rhs._alphaCount; - _filterJitterEstimate = rhs._filterJitterEstimate; - _startupCount = rhs._startupCount; - _latestNackTimestamp = rhs._latestNackTimestamp; - _nackCount = rhs._nackCount; - _rttFilter = rhs._rttFilter; - clock_ = rhs.clock_; - } - return *this; -} - // Resets the JitterEstimate. void VCMJitterEstimator::Reset() { _theta[0] = 1 / (512e3 / 8); diff --git a/modules/video_coding/jitter_estimator.h b/modules/video_coding/jitter_estimator.h index 1d69b95769..ee8f264329 100644 --- a/modules/video_coding/jitter_estimator.h +++ b/modules/video_coding/jitter_estimator.h @@ -22,7 +22,8 @@ class VCMJitterEstimator { public: explicit VCMJitterEstimator(Clock* clock); virtual ~VCMJitterEstimator(); - VCMJitterEstimator& operator=(const VCMJitterEstimator& rhs); + VCMJitterEstimator(const VCMJitterEstimator&) = delete; + VCMJitterEstimator& operator=(const VCMJitterEstimator&) = delete; // Resets the estimate to the initial state. void Reset(); diff --git a/modules/video_coding/rtt_filter.cc b/modules/video_coding/rtt_filter.cc index 75813a46ad..773ff6867e 100644 --- a/modules/video_coding/rtt_filter.cc +++ b/modules/video_coding/rtt_filter.cc @@ -26,21 +26,6 @@ VCMRttFilter::VCMRttFilter() Reset(); } -VCMRttFilter& VCMRttFilter::operator=(const VCMRttFilter& rhs) { - if (this != &rhs) { - _gotNonZeroUpdate = rhs._gotNonZeroUpdate; - _avgRtt = rhs._avgRtt; - _varRtt = rhs._varRtt; - _maxRtt = rhs._maxRtt; - _filtFactCount = rhs._filtFactCount; - _jumpCount = rhs._jumpCount; - _driftCount = rhs._driftCount; - memcpy(_jumpBuf, rhs._jumpBuf, sizeof(_jumpBuf)); - memcpy(_driftBuf, rhs._driftBuf, sizeof(_driftBuf)); - } - return *this; -} - void VCMRttFilter::Reset() { _gotNonZeroUpdate = false; _avgRtt = 0; diff --git a/modules/video_coding/rtt_filter.h b/modules/video_coding/rtt_filter.h index 073fabb85b..bc4f56d2b9 100644 --- a/modules/video_coding/rtt_filter.h +++ b/modules/video_coding/rtt_filter.h @@ -18,8 +18,8 @@ namespace webrtc { class VCMRttFilter { public: VCMRttFilter(); - - VCMRttFilter& operator=(const VCMRttFilter& rhs); + VCMRttFilter(const VCMRttFilter&) = delete; + VCMRttFilter& operator=(const VCMRttFilter&) = delete; // Resets the filter. void Reset(); From ff05c5c805e2a7652507c3f610c66e4676268933 Mon Sep 17 00:00:00 2001 From: Philipp Hancke Date: Thu, 3 Mar 2022 12:09:16 +0100 Subject: [PATCH 097/847] audio/red: cleanup killswitch this has been enable by default since M96 BUG=webrtc:11640 Change-Id: I5d310d3929882007211eae12bc3ac1366107ca87 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253400 Reviewed-by: Harald Alvestrand Commit-Queue: Philipp Hancke Cr-Commit-Position: refs/heads/main@{#36123} --- media/engine/webrtc_voice_engine.cc | 37 +++++++------------- media/engine/webrtc_voice_engine.h | 5 --- media/engine/webrtc_voice_engine_unittest.cc | 12 ------- 3 files changed, 13 insertions(+), 41 deletions(-) diff --git a/media/engine/webrtc_voice_engine.cc b/media/engine/webrtc_voice_engine.cc index 829cb82af1..7f01b95642 100644 --- a/media/engine/webrtc_voice_engine.cc +++ b/media/engine/webrtc_voice_engine.cc @@ -210,11 +210,6 @@ bool IsEnabled(const webrtc::WebRtcKeyValueConfig& config, return absl::StartsWith(config.Lookup(trial), "Enabled"); } -bool IsDisabled(const webrtc::WebRtcKeyValueConfig& config, - absl::string_view trial) { - return absl::StartsWith(config.Lookup(trial), "Disabled"); -} - struct AdaptivePtimeConfig { bool enabled = false; webrtc::DataRate min_payload_bitrate = webrtc::DataRate::KilobitsPerSec(16); @@ -311,8 +306,6 @@ WebRtcVoiceEngine::WebRtcVoiceEngine( audio_mixer_(audio_mixer), apm_(audio_processing), audio_frame_processor_(audio_frame_processor), - audio_red_for_opus_enabled_( - !IsDisabled(trials, "WebRTC-Audio-Red-For-Opus")), minimized_remsampling_on_mobile_trial_enabled_( IsEnabled(trials, "WebRTC-Audio-MinimizeResamplingOnMobile")) { // This may be called from any thread, so detach thread checkers. @@ -738,7 +731,7 @@ std::vector WebRtcVoiceEngine::CollectCodecs( out.push_back(codec); - if (codec.name == kOpusCodecName && audio_red_for_opus_enabled_) { + if (codec.name == kOpusCodecName) { std::string redFmtp = rtc::ToString(codec.id) + "/" + rtc::ToString(codec.id); map_format({kRedCodecName, 48000, 2, {{"", redFmtp}}}, &out); @@ -1311,9 +1304,7 @@ WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel( engine_(engine), call_(call), audio_config_(config.audio), - crypto_options_(crypto_options), - audio_red_for_opus_enabled_( - !IsDisabled(call->trials(), "WebRTC-Audio-Red-For-Opus")) { + crypto_options_(crypto_options) { network_thread_checker_.Detach(); RTC_LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel"; RTC_DCHECK(call); @@ -1574,7 +1565,7 @@ bool WebRtcVoiceMediaChannel::SetRecvCodecs( } auto format = AudioCodecToSdpAudioFormat(codec); if (!IsCodec(codec, kCnCodecName) && !IsCodec(codec, kDtmfCodecName) && - (!audio_red_for_opus_enabled_ || !IsCodec(codec, kRedCodecName)) && + !IsCodec(codec, kRedCodecName) && !engine()->decoder_factory_->IsSupportedDecoder(format)) { RTC_LOG(LS_ERROR) << "Unsupported codec: " << rtc::ToString(format); return false; @@ -1760,19 +1751,17 @@ bool WebRtcVoiceMediaChannel::SetSendCodecs( } } - if (audio_red_for_opus_enabled_) { - // Loop through the codecs to find the RED codec that matches opus - // with respect to clockrate and number of channels. - size_t red_codec_position = 0; - for (const AudioCodec& red_codec : codecs) { - if (red_codec_position < send_codec_position && - IsCodec(red_codec, kRedCodecName) && - CheckRedParameters(red_codec, *send_codec_spec)) { - send_codec_spec->red_payload_type = red_codec.id; - break; - } - red_codec_position++; + // Loop through the codecs to find the RED codec that matches opus + // with respect to clockrate and number of channels. + size_t red_codec_position = 0; + for (const AudioCodec& red_codec : codecs) { + if (red_codec_position < send_codec_position && + IsCodec(red_codec, kRedCodecName) && + CheckRedParameters(red_codec, *send_codec_spec)) { + send_codec_spec->red_payload_type = red_codec.id; + break; } + red_codec_position++; } if (send_codec_spec_ != send_codec_spec) { diff --git a/media/engine/webrtc_voice_engine.h b/media/engine/webrtc_voice_engine.h index 1061d7a129..1a0b54472e 100644 --- a/media/engine/webrtc_voice_engine.h +++ b/media/engine/webrtc_voice_engine.h @@ -130,9 +130,6 @@ class WebRtcVoiceEngine final : public VoiceEngineInterface { int audio_jitter_buffer_min_delay_ms_ = 0; bool audio_jitter_buffer_enable_rtx_handling_ = false; - // If this field is enabled, we will negotiate and use RFC 2198 - // redundancy for opus audio. - const bool audio_red_for_opus_enabled_; const bool minimized_remsampling_on_mobile_trial_enabled_; }; @@ -325,8 +322,6 @@ class WebRtcVoiceMediaChannel final : public VoiceMediaChannel, // Unsignaled streams have an option to have a frame decryptor set on them. rtc::scoped_refptr unsignaled_frame_decryptor_; - - const bool audio_red_for_opus_enabled_; }; } // namespace cricket diff --git a/media/engine/webrtc_voice_engine_unittest.cc b/media/engine/webrtc_voice_engine_unittest.cc index ad15a638bb..a9f4f22cdc 100644 --- a/media/engine/webrtc_voice_engine_unittest.cc +++ b/media/engine/webrtc_voice_engine_unittest.cc @@ -1035,18 +1035,6 @@ TEST_P(WebRtcVoiceEngineTestFake, RecvRedDefault) { {112, {"red", 48000, 2, {{"", "111/111"}}}}}))); } -// Test that we disable Opus/Red with the kill switch. -TEST_P(WebRtcVoiceEngineTestFake, RecvRed) { - webrtc::test::ScopedFieldTrials override_field_trials( - "WebRTC-Audio-Red-For-Opus/Disabled/"); - - EXPECT_TRUE(SetupRecvStream()); - cricket::AudioRecvParameters parameters; - parameters.codecs.push_back(kOpusCodec); - parameters.codecs.push_back(kRed48000Codec); - EXPECT_FALSE(channel_->SetRecvParameters(parameters)); -} - TEST_P(WebRtcVoiceEngineTestFake, SetSendBandwidthAuto) { EXPECT_TRUE(SetupSendStream()); From c4752d00357ff5013b7e7fe8962d2ddff4799139 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Thu, 3 Mar 2022 10:01:15 -0800 Subject: [PATCH 098/847] Roll chromium_revision fed3329cf1..3a95422d09 (977049:977175) Change log: https://chromium.googlesource.com/chromium/src/+log/fed3329cf1..3a95422d09 Full diff: https://chromium.googlesource.com/chromium/src/+/fed3329cf1..3a95422d09 Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/d3223195a8..788cb408df * src/build: https://chromium.googlesource.com/chromium/src/build/+log/e6ef2e3b0b..144e0edbce * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/ccdad02575..cc3cbcf858 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/4ad24bcc57..1e9b8e3aa4 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/56ac406f30..3188e54bf1 * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/11de3dcf8b..b6557e37c4 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/ad2f70bd0c..1bc9ddc973 DEPS diff: https://chromium.googlesource.com/chromium/src/+/fed3329cf1..3a95422d09/DEPS No update to Clang. BUG=None Change-Id: I0d047d785e21b222727c12321134be9fe0dd8cdc Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253460 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36124} --- DEPS | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/DEPS b/DEPS index 1ac25ff92a..656707e9af 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': 'fed3329cf133f231b0845f5880229b6de9597193', + 'chromium_revision': '3a95422d09079e1c0ee1a047e35b02fda4fbf5fd', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@d3223195a835db92b2f3c541053efbba1ee28e92', + 'https://chromium.googlesource.com/chromium/src/base@788cb408df824742ba1e759253b76b801ec8ef00', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@e6ef2e3b0b3b441312d57d9ff3df0b38b3aa44b3', + 'https://chromium.googlesource.com/chromium/src/build@144e0edbce9de3bba10ed9c7c09c21f2306ec723', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@113dd1badbcbffea108a8c95ac7c89c22bfd25f3', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@ccdad025758d3bff01fdcb62372779ab7c6d0517', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@cc3cbcf858a0a22c854172975f0676220bf49443', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@4ad24bcc579e270e1452687cd470c6bdaf52110f', + 'https://chromium.googlesource.com/chromium/src/testing@1e9b8e3aa40f258dd79908fd8cb362f790f0fc13', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@56ac406f30ba750fd96f9e29869b8216a97dd72c', + 'https://chromium.googlesource.com/chromium/src/third_party@3188e54bf17fe01375f97724d1de34f9c995d155', 'src/buildtools/linux64': { 'packages': [ @@ -228,7 +228,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@11de3dcf8b4e4c727906a0fb055b5493e9d2de82', + 'https://android.googlesource.com/platform/external/perfetto.git@b6557e37c41e01d2cb0508b4c6583e23e2838a17', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@ad2f70bd0caa652782e5dbb02e3c50cf2f09dd40', + 'https://chromium.googlesource.com/chromium/src/tools@1bc9ddc9730f748d9abd7a6b36c9c12f7d9d437e', 'src/third_party/accessibility_test_framework': { 'packages': [ From 15ee87fe0ea8d25177b2e87b2530e55bd1a501e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CMichael?= Date: Thu, 3 Mar 2022 12:09:02 -0600 Subject: [PATCH 099/847] Use VideoCodec complexity to determine AV1 encoder cpu_speed. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:13744 Change-Id: Ib6d62dcdf7346d886c0aca09735c7d5c1f3e2455 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252340 Reviewed-by: Erik Språng Auto-Submit: Michael Horowitz Commit-Queue: Michael Horowitz Cr-Commit-Position: refs/heads/main@{#36125} --- .../codecs/av1/libaom_av1_encoder.cc | 59 +++++++++++++------ .../codecs/test/videocodec_test_av1.cc | 7 ++- 2 files changed, 45 insertions(+), 21 deletions(-) diff --git a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc index 79a31d9baa..0e427be915 100644 --- a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc +++ b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc @@ -49,21 +49,6 @@ constexpr int kLagInFrames = 0; // No look ahead. constexpr int kRtpTicksPerSecond = 90000; constexpr float kMinimumFrameRate = 1.0; -// Only positive speeds, range for real-time coding currently is: 6 - 8. -// Lower means slower/better quality, higher means fastest/lower quality. -int GetCpuSpeed(int width, int height, int number_of_cores) { - // For smaller resolutions, use lower speed setting (get some coding gain at - // the cost of increased encoding complexity). - if (number_of_cores > 4 && width * height < 320 * 180) - return 6; - else if (width * height >= 1280 * 720) - return 9; - else if (width * height >= 640 * 360) - return 8; - else - return 7; -} - aom_superblock_size_t GetSuperblockSize(int width, int height, int threads) { int resolution = width * height; if (threads >= 4 && resolution >= 960 * 540 && resolution < 1920 * 1080) @@ -93,6 +78,9 @@ class LibaomAv1Encoder final : public VideoEncoder { EncoderInfo GetEncoderInfo() const override; private: + // Get value to be used for encoder cpu_speed setting + int GetCpuSpeed(int width, int height); + // Determine number of encoder threads to use. int NumberOfThreads(int width, int height, int number_of_cores); @@ -247,9 +235,8 @@ int LibaomAv1Encoder::InitEncode(const VideoCodec* codec_settings, inited_ = true; // Set control parameters - ret = aom_codec_control( - &ctx_, AOME_SET_CPUUSED, - GetCpuSpeed(cfg_.g_w, cfg_.g_h, settings.number_of_cores)); + ret = aom_codec_control(&ctx_, AOME_SET_CPUUSED, + GetCpuSpeed(cfg_.g_w, cfg_.g_h)); if (ret != AOM_CODEC_OK) { RTC_LOG(LS_WARNING) << "LibaomAv1Encoder::EncodeInit returned " << ret << " on control AV1E_SET_CPUUSED."; @@ -419,6 +406,42 @@ int LibaomAv1Encoder::InitEncode(const VideoCodec* codec_settings, return WEBRTC_VIDEO_CODEC_OK; } +// Only positive speeds, range for real-time coding currently is: 6 - 8. +// Lower means slower/better quality, higher means fastest/lower quality. +int LibaomAv1Encoder::GetCpuSpeed(int width, int height) { + // For smaller resolutions, use lower speed setting (get some coding gain at + // the cost of increased encoding complexity). + switch (encoder_settings_.GetVideoEncoderComplexity()) { + case VideoCodecComplexity::kComplexityHigh: + if (width * height <= 320 * 180) + return 8; + else if (width * height <= 640 * 360) + return 9; + else + return 10; + case VideoCodecComplexity::kComplexityHigher: + if (width * height <= 320 * 180) + return 7; + else if (width * height <= 640 * 360) + return 8; + else if (width * height <= 1280 * 720) + return 9; + else + return 10; + case VideoCodecComplexity::kComplexityMax: + if (width * height <= 320 * 180) + return 6; + else if (width * height <= 640 * 360) + return 7; + else if (width * height <= 1280 * 720) + return 8; + else + return 9; + default: + return 10; + } +} + int LibaomAv1Encoder::NumberOfThreads(int width, int height, int number_of_cores) { diff --git a/modules/video_coding/codecs/test/videocodec_test_av1.cc b/modules/video_coding/codecs/test/videocodec_test_av1.cc index af619e1f63..3a7f61edc1 100644 --- a/modules/video_coding/codecs/test/videocodec_test_av1.cc +++ b/modules/video_coding/codecs/test/videocodec_test_av1.cc @@ -61,7 +61,7 @@ TEST_P(VideoCodecTestAv1, HighBitrate) { std::vector rc_thresholds = { {12, 1, 0, 1, 0.3, 0.1, 0, 1}}; - std::vector quality_thresholds = {{37, 34, 0.94, 0.915}}; + std::vector quality_thresholds = {{37, 34, 0.94, 0.91}}; fixture->RunTest(rate_profiles, &rc_thresholds, &quality_thresholds, nullptr); } @@ -78,7 +78,7 @@ TEST_P(VideoCodecTestAv1, VeryLowBitrate) { std::vector rc_thresholds = { {15, 8, 75, 2, 2, 2, 2, 1}}; - std::vector quality_thresholds = {{28, 25, 0.70, 0.60}}; + std::vector quality_thresholds = {{28, 24.9, 0.70, 0.55}}; fixture->RunTest(rate_profiles, &rc_thresholds, &quality_thresholds, nullptr); } @@ -99,7 +99,8 @@ TEST_P(VideoCodecTestAv1, Hd) { std::vector rc_thresholds = { {13, 3, 0, 1, 0.3, 0.1, 0, 1}}; - std::vector quality_thresholds = {{36, 31.6, 0.93, 0.87}}; + std::vector quality_thresholds = { + {36, 31.55, 0.925, 0.865}}; fixture->RunTest(rate_profiles, &rc_thresholds, &quality_thresholds, nullptr); } From b0044c1c539bfde6ee603e3a76e21121596f367b Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Thu, 3 Mar 2022 12:03:05 -0800 Subject: [PATCH 100/847] Roll chromium_revision 3a95422d09..5b7eadb779 (977175:977286) Change log: https://chromium.googlesource.com/chromium/src/+log/3a95422d09..5b7eadb779 Full diff: https://chromium.googlesource.com/chromium/src/+/3a95422d09..5b7eadb779 Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/788cb408df..0eacf31b03 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/144e0edbce..669b2d5d4f * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/cc3cbcf858..f7051993f8 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/1e9b8e3aa4..a306bffb72 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/3188e54bf1..51432177ed * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/4a800603ab..74f773b8a5 * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/b6557e37c4..9d1b2dd686 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/1bc9ddc973..c9af8f4dda DEPS diff: https://chromium.googlesource.com/chromium/src/+/3a95422d09..5b7eadb779/DEPS No update to Clang. BUG=None Change-Id: I577ce84e5bfb230ed95ff10cc67b4693c6fd3618 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253480 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36126} --- DEPS | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/DEPS b/DEPS index 656707e9af..7c4daa868c 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': '3a95422d09079e1c0ee1a047e35b02fda4fbf5fd', + 'chromium_revision': '5b7eadb779005e0b4f020f1c75406985e53ee3c7', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@788cb408df824742ba1e759253b76b801ec8ef00', + 'https://chromium.googlesource.com/chromium/src/base@0eacf31b03f7240b7bf2f771404959885dc1a264', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@144e0edbce9de3bba10ed9c7c09c21f2306ec723', + 'https://chromium.googlesource.com/chromium/src/build@669b2d5d4f39031b5589df2ad57cb5a9a54d63c4', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@113dd1badbcbffea108a8c95ac7c89c22bfd25f3', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@cc3cbcf858a0a22c854172975f0676220bf49443', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@f7051993f8d4fe12d541423aeab5a971ebd5e380', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@1e9b8e3aa40f258dd79908fd8cb362f790f0fc13', + 'https://chromium.googlesource.com/chromium/src/testing@a306bffb7266d557d2c5f075df5bcc237a6aa3b6', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@3188e54bf17fe01375f97724d1de34f9c995d155', + 'https://chromium.googlesource.com/chromium/src/third_party@51432177ed65b71062b3d7173139feda692572d9', 'src/buildtools/linux64': { 'packages': [ @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@4a800603ab8a7e9e2569ec63fe618501d5f8145e', + 'https://chromium.googlesource.com/catapult.git@74f773b8a535b0a4dd401229ae4caef2c972c417', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -228,7 +228,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@b6557e37c41e01d2cb0508b4c6583e23e2838a17', + 'https://android.googlesource.com/platform/external/perfetto.git@9d1b2dd68697e0b5d912c18674cadd1c16ef5790', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@1bc9ddc9730f748d9abd7a6b36c9c12f7d9d437e', + 'https://chromium.googlesource.com/chromium/src/tools@c9af8f4dda73bdbfeaf3c33fe94efa6e89fb8809', 'src/third_party/accessibility_test_framework': { 'packages': [ From c27ae393034be57ae9f98e71b1c6ee9810c426cd Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Thu, 3 Mar 2022 20:04:22 -0800 Subject: [PATCH 101/847] Roll chromium_revision 5b7eadb779..df57ae05f5 (977286:977476) Change log: https://chromium.googlesource.com/chromium/src/+log/5b7eadb779..df57ae05f5 Full diff: https://chromium.googlesource.com/chromium/src/+/5b7eadb779..df57ae05f5 Changed dependencies * src/build: https://chromium.googlesource.com/chromium/src/build/+log/669b2d5d4f..d6d9d1be7b * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/f7051993f8..883eb7a3a5 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/a306bffb72..c5a152d433 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/51432177ed..717f087337 * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/74f773b8a5..4756e385c6 * src/third_party/dav1d/libdav1d: https://chromium.googlesource.com/external/github.com/videolan/dav1d.git/+log/b010080fea..3262e3d0c8 * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/4bda2abfcf..e210b54290 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/c9af8f4dda..141e2e9b26 DEPS diff: https://chromium.googlesource.com/chromium/src/+/5b7eadb779..df57ae05f5/DEPS No update to Clang. BUG=None Change-Id: Ic5dd9505033792418e77364ba2016fe84518ae9b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253520 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36127} --- DEPS | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/DEPS b/DEPS index 7c4daa868c..d646204284 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': '5b7eadb779005e0b4f020f1c75406985e53ee3c7', + 'chromium_revision': 'df57ae05f5feec2800ea0d573fb7f6fd7ce77098', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -25,7 +25,7 @@ deps = { 'src/base': 'https://chromium.googlesource.com/chromium/src/base@0eacf31b03f7240b7bf2f771404959885dc1a264', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@669b2d5d4f39031b5589df2ad57cb5a9a54d63c4', + 'https://chromium.googlesource.com/chromium/src/build@d6d9d1be7b8923c68cc54e37f464eb8a972549a9', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@113dd1badbcbffea108a8c95ac7c89c22bfd25f3', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@f7051993f8d4fe12d541423aeab5a971ebd5e380', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@883eb7a3a5b0d77d2b5c2a5fac97a329a9c4688b', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@a306bffb7266d557d2c5f075df5bcc237a6aa3b6', + 'https://chromium.googlesource.com/chromium/src/testing@c5a152d433d8cf6c4e98a0a0138bd294384e20c5', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@51432177ed65b71062b3d7173139feda692572d9', + 'https://chromium.googlesource.com/chromium/src/third_party@717f087337963e08064c45d314112dee428176a8', 'src/buildtools/linux64': { 'packages': [ @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@74f773b8a535b0a4dd401229ae4caef2c972c417', + 'https://chromium.googlesource.com/catapult.git@4756e385c6030e3da50cc5ea3724bdecea1fe7e6', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@4bda2abfcf6e5debf6e0463f987a8432a56e06e1', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@e210b542901532a862e9c9d025f5f72121c97316', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -220,7 +220,7 @@ deps = { 'src/third_party/libsrtp': 'https://chromium.googlesource.com/chromium/deps/libsrtp.git@5b7c744eb8310250ccc534f3f86a2015b3887a0a', 'src/third_party/dav1d/libdav1d': - 'https://chromium.googlesource.com/external/github.com/videolan/dav1d.git@b010080fea75435327fc90824bb4d8035722b3cb', + 'https://chromium.googlesource.com/external/github.com/videolan/dav1d.git@3262e3d0c89c83389e5bec32d7d81564077e2687', 'src/third_party/libaom/source/libaom': 'https://aomedia.googlesource.com/aom.git@a08d3f6c329a25744712578a70715e5cfd749759', 'src/third_party/libunwindstack': { @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@c9af8f4dda73bdbfeaf3c33fe94efa6e89fb8809', + 'https://chromium.googlesource.com/chromium/src/tools@141e2e9b26e49b0080332125c7e2bbe0e69e3684', 'src/third_party/accessibility_test_framework': { 'packages': [ From 8afdfdc728e39f9aaf3a636dd077178a66c63914 Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Thu, 3 Mar 2022 20:05:36 -0800 Subject: [PATCH 102/847] Update WebRTC code version (2022-03-04T04:05:35). Bug: None Change-Id: Ief14d9362637b03c0b1473949699a5e772375f1a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253521 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36128} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index 10628cca3f..041c62b042 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 2022-03-03T04:03:51"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-03-04T04:05:35"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From 251eca20a5ae35c01c8902ef0d42b04e2c5d2816 Mon Sep 17 00:00:00 2001 From: Jeremy Leconte Date: Fri, 4 Mar 2022 05:39:04 +0100 Subject: [PATCH 103/847] Add missing tests to the default target. Bug: webrtc:11411 Change-Id: Ie73ed767f4631a68734cd78e8a4e2da40959c28d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253381 Reviewed-by: Mirko Bonadei Commit-Queue: Jeremy Leconte Cr-Commit-Position: refs/heads/main@{#36129} --- BUILD.gn | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/BUILD.gn b/BUILD.gn index fa4fcace49..aaa1260088 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -81,6 +81,13 @@ if (!build_with_chromium) { # see bugs.webrtc.org/11027#c5. deps += [ ":webrtc_lib_link_test" ] } + if (is_ios) { + deps += [ + "examples:apprtcmobile_tests", + "sdk:sdk_framework_unittests", + "sdk:sdk_unittests", + ] + } if (is_android) { deps += [ "examples:android_examples_junit_tests", @@ -92,7 +99,7 @@ if (!build_with_chromium) { } if (rtc_enable_protobuf) { deps += [ - "audio:low_bandwidth_audio_test", + "audio:low_bandwidth_audio_perf_test", "logging:rtc_event_log_rtp_dump", "tools_webrtc/perf:webrtc_dashboard_upload", ] From 25b73cdb967bcc50ac0b2d96402181005a07ed96 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Fri, 4 Mar 2022 02:05:11 -0800 Subject: [PATCH 104/847] Roll chromium_revision df57ae05f5..a85d99a8b9 (977476:977584) Change log: https://chromium.googlesource.com/chromium/src/+log/df57ae05f5..a85d99a8b9 Full diff: https://chromium.googlesource.com/chromium/src/+/df57ae05f5..a85d99a8b9 Changed dependencies * src/build: https://chromium.googlesource.com/chromium/src/build/+log/d6d9d1be7b..fbd9d68e74 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/883eb7a3a5..5298d5dbf1 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/c5a152d433..34da09f87f * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/717f087337..780d067922 * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/4756e385c6..10d8471fc7 * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/e210b54290..df1a3c0bb8 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/141e2e9b26..146011e098 * src/tools/luci-go: git_revision:a1616e207f0d9c24beefe848ee899b7a73efcb70..git_revision:cb424e70e75136736a86359ef070aa96425fe7a3 * src/tools/luci-go: git_revision:a1616e207f0d9c24beefe848ee899b7a73efcb70..git_revision:cb424e70e75136736a86359ef070aa96425fe7a3 DEPS diff: https://chromium.googlesource.com/chromium/src/+/df57ae05f5..a85d99a8b9/DEPS No update to Clang. BUG=None Change-Id: I6c58d4b892828f71a2199a66ae60463e62cf48cd Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253561 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36130} --- DEPS | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/DEPS b/DEPS index d646204284..e3a1628d8b 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': 'df57ae05f5feec2800ea0d573fb7f6fd7ce77098', + 'chromium_revision': 'a85d99a8b918ce933b4626fb114368084e78f6af', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -25,7 +25,7 @@ deps = { 'src/base': 'https://chromium.googlesource.com/chromium/src/base@0eacf31b03f7240b7bf2f771404959885dc1a264', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@d6d9d1be7b8923c68cc54e37f464eb8a972549a9', + 'https://chromium.googlesource.com/chromium/src/build@fbd9d68e74e48207ee56e3e7eb03f67ada32018b', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@113dd1badbcbffea108a8c95ac7c89c22bfd25f3', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@883eb7a3a5b0d77d2b5c2a5fac97a329a9c4688b', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@5298d5dbf1d22694ff6e7a1118dd7d5fd5177b60', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@c5a152d433d8cf6c4e98a0a0138bd294384e20c5', + 'https://chromium.googlesource.com/chromium/src/testing@34da09f87f2f25e97b463eb1ac550297d8f588d2', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@717f087337963e08064c45d314112dee428176a8', + 'https://chromium.googlesource.com/chromium/src/third_party@780d067922d63686a8e0aa92164906ace2112ce6', 'src/buildtools/linux64': { 'packages': [ @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@4756e385c6030e3da50cc5ea3724bdecea1fe7e6', + 'https://chromium.googlesource.com/catapult.git@10d8471fc78e1b76fac51b2cc07f5086fe92a2f2', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@e210b542901532a862e9c9d025f5f72121c97316', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@df1a3c0bb803ef47515f26a65d7dfba924f7853e', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@141e2e9b26e49b0080332125c7e2bbe0e69e3684', + 'https://chromium.googlesource.com/chromium/src/tools@146011e09857794de599e17d4cd2ad84f4e0c8de', 'src/third_party/accessibility_test_framework': { 'packages': [ @@ -489,11 +489,11 @@ deps = { 'packages': [ { 'package': 'infra/tools/luci/isolate/${{platform}}', - 'version': 'git_revision:a1616e207f0d9c24beefe848ee899b7a73efcb70', + 'version': 'git_revision:cb424e70e75136736a86359ef070aa96425fe7a3', }, { 'package': 'infra/tools/luci/swarming/${{platform}}', - 'version': 'git_revision:a1616e207f0d9c24beefe848ee899b7a73efcb70', + 'version': 'git_revision:cb424e70e75136736a86359ef070aa96425fe7a3', }, ], 'dep_type': 'cipd', From fabc3a5aa724a8409c539915374f1154f819d322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Fri, 4 Mar 2022 14:19:48 +0100 Subject: [PATCH 105/847] Add script to generate ssl_roots.h from Mozilla's CA bundle Bug: webrtc:11710 Change-Id: I6eac35a111f89f3c74ce8c2ffc0ab607ad881be2 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253220 Reviewed-by: Christoffer Jansson Reviewed-by: Harald Alvestrand Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#36131} --- tools_webrtc/sslroots/README.md | 12 ++-- tools_webrtc/sslroots/generate_sslroots.py | 64 +++++++++++++--------- 2 files changed, 43 insertions(+), 33 deletions(-) diff --git a/tools_webrtc/sslroots/README.md b/tools_webrtc/sslroots/README.md index 594d9ab4f5..0184a412a9 100644 --- a/tools_webrtc/sslroots/README.md +++ b/tools_webrtc/sslroots/README.md @@ -4,20 +4,18 @@ This directory contains a script to generate the content of [rtc_base/ssl_roots.h][ssl-roots-header], to update the SSL roots shipped by WebRTC follow this instructions: -1. Download roots.pem from [pki.goog][pki-goog]. +1. Download roots.pem from [pki.goog][pki-goog] or [curl.se][mozilla-cacert] 2. Launch the script: ``` -$ vpython3 tools_webrtc/sslroots/generate_sslroots.py roots.pem +$ vpython3 tools_webrtc/sslroots/generate_sslroots.py ``` -3. Step 2 should have generated an ssl_roots.h file right next to roots.pem. +3. Step 2 should have generated an ssl_roots.h file right next to the pem file. -4. Open rtc_base/ssl_roots.h, manually remove the old certificates and paste - the ones from the ssl_roots.h file. - -5. Delete the generated ssl_roots.h and roots.pem before creating the CL. +4. Overwrite rtc_base/ssl_roots.h with the newly generated one. [ssl-roots-header]: https://cs.chromium.org/chromium/src/third_party/webrtc/rtc_base/ssl_roots.h [pki-goog]: https://www.google.com/url?q=https://pki.google.com/roots.pem +[mozila-cacert]: https://curl.se/ca/cacert.pem diff --git a/tools_webrtc/sslroots/generate_sslroots.py b/tools_webrtc/sslroots/generate_sslroots.py index 2cd0c89950..e2da02935d 100644 --- a/tools_webrtc/sslroots/generate_sslroots.py +++ b/tools_webrtc/sslroots/generate_sslroots.py @@ -11,19 +11,22 @@ """This is a tool to transform a crt file into a C/C++ header. Usage: -generate_sslroots.py cert_file.crt [--verbose | -v] [--full_cert | -f] +python3 generate_sslroots.py certfile.pem [--verbose | -v] [--full_cert | -f] Arguments: -v Print output while running. -f Add public key and certificate name. Default is to skip and reduce generated file size. + +The supported cert files are: + - Google: https://pki.goog/roots.pem + - Mozilla: https://curl.se/docs/caextract.html """ import subprocess from optparse import OptionParser import os import re -import string _GENERATED_FILE = 'ssl_roots.h' _PREFIX = '__generated__' @@ -38,6 +41,7 @@ _INT_TYPE = 'size_t' _CHAR_TYPE = 'unsigned char* const' _VERBOSE = 'verbose' +_MOZILLA_BUNDLE_CHECK = '## Certificate data from Mozilla as of:' def main(): @@ -49,24 +53,34 @@ def main(): if len(args) < 1: parser.error('No crt file specified.') return - root_dir = _SplitCrt(args[0], options) - _GenCFiles(root_dir, options) + root_dir, bundle_type = _SplitCrt(args[0], options) + _GenCFiles(root_dir, options, bundle_type) _Cleanup(root_dir) def _SplitCrt(source_file, options): sub_file_blocks = [] label_name = '' + prev_line = None root_dir = os.path.dirname(os.path.abspath(source_file)) + '/' _PrintOutput(root_dir, options) - f = open(source_file) - for line in f: - if line.startswith('# Label: '): + lines = None + with open(source_file) as f: + lines = f.readlines() + mozilla_bundle = any(l.startswith(_MOZILLA_BUNDLE_CHECK) for l in lines) + for line in lines: + if line.startswith('#'): + if mozilla_bundle: + continue + if line.startswith('# Label: '): + sub_file_blocks.append(line) + label = re.search(r'\".*\"', line) + temp_label = label.group(0) + end = len(temp_label) - 1 + label_name = _SafeName(temp_label[1:end]) + if mozilla_bundle and line.startswith('==='): sub_file_blocks.append(line) - label = re.search(r'\".*\"', line) - temp_label = label.group(0) - end = len(temp_label) - 1 - label_name = _SafeName(temp_label[1:end]) + label_name = _SafeName(prev_line) elif line.startswith('-----END CERTIFICATE-----'): sub_file_blocks.append(line) new_file_name = root_dir + _PREFIX + label_name + _EXTENSION @@ -78,13 +92,13 @@ def _SplitCrt(source_file, options): sub_file_blocks = [] else: sub_file_blocks.append(line) - f.close() - return root_dir + prev_line = line + return root_dir, 'Mozilla' if mozilla_bundle else 'Google' -def _GenCFiles(root_dir, options): +def _GenCFiles(root_dir, options, bundle_type): output_header_file = open(root_dir + _GENERATED_FILE, 'w') - output_header_file.write(_CreateOutputHeader()) + output_header_file.write(_CreateOutputHeader(bundle_type)) if options.full_cert: subject_name_list = _CreateArraySectionHeader(_SUBJECT_NAME_VARIABLE, _CHAR_TYPE, options) @@ -151,7 +165,7 @@ def _CreateCertSection(root_dir, source_file, label, options): return filtered_output, cert_size -def _CreateOutputHeader(): +def _CreateOutputHeader(bundle_type): output = ('/*\n' ' * Copyright 2004 The WebRTC Project Authors. All rights ' 'reserved.\n' @@ -166,20 +180,18 @@ def _CreateOutputHeader(): ' */\n\n' '#ifndef RTC_BASE_SSL_ROOTS_H_\n' '#define RTC_BASE_SSL_ROOTS_H_\n\n' - '// This file is the root certificates in C form that are needed to' - ' connect to\n// Google.\n\n' - '// It was generated with the following command line:\n' - '// > vpython3 tools_webrtc/sslroots/generate_sslroots.py' - '\n// https://pki.goog/roots.pem\n\n' + '// This file is the root certificates in C form.\n\n' + '// It was generated with the following script:\n' + '// tools_webrtc/sslroots/generate_sslroots.py' + ' %s_CA_bundle.pem\n\n' '// clang-format off\n' '// Don\'t bother formatting generated code,\n' - '// also it would breaks subject/issuer lines.\n\n') + '// also it would breaks subject/issuer lines.\n\n' % bundle_type) return output def _CreateOutputFooter(): - output = ('// clang-format on\n\n#endif // RTC_BASE_SSL_ROOTS_H_\n') - return output + return '// clang-format on\n\n#endif // RTC_BASE_SSL_ROOTS_H_\n' def _CreateArraySectionHeader(type_name, type_type, options): @@ -197,11 +209,11 @@ def _CreateArraySectionFooter(): def _SafeName(original_file_name): - bad_chars = ' -./\\()áéíőú' + bad_chars = ' -./\\()áéíőú\r\n' replacement_chars = '' for _ in bad_chars: replacement_chars += '_' - translation_table = string.maketrans(bad_chars, replacement_chars) + translation_table = str.maketrans(bad_chars, replacement_chars) return original_file_name.translate(translation_table) From a2ee9234b426dcd7c8c1134fac9b17cee7a606df Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Fri, 4 Mar 2022 15:03:02 +0100 Subject: [PATCH 106/847] Migrate to Timestamp and TimeDelta types in RtpPacketHistory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:13757 Change-Id: Ie542fca50b97fe9dc450e45da40f05e2b66c7da5 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252981 Reviewed-by: Erik Språng Commit-Queue: Danil Chapovalov Cr-Commit-Position: refs/heads/main@{#36132} --- .../deprecated_rtp_sender_egress.cc | 2 +- modules/rtp_rtcp/source/rtp_packet_history.cc | 60 +++--- modules/rtp_rtcp/source/rtp_packet_history.h | 34 +++- .../source/rtp_packet_history_unittest.cc | 182 +++++++++--------- modules/rtp_rtcp/source/rtp_rtcp_impl.cc | 2 +- modules/rtp_rtcp/source/rtp_rtcp_impl2.cc | 2 +- modules/rtp_rtcp/source/rtp_sender.cc | 2 +- modules/rtp_rtcp/source/rtp_sender_egress.cc | 2 +- .../rtp_rtcp/source/rtp_sender_unittest.cc | 54 +++--- 9 files changed, 173 insertions(+), 167 deletions(-) diff --git a/modules/rtp_rtcp/source/deprecated/deprecated_rtp_sender_egress.cc b/modules/rtp_rtcp/source/deprecated/deprecated_rtp_sender_egress.cc index 9cef33165c..db6b50a449 100644 --- a/modules/rtp_rtcp/source/deprecated/deprecated_rtp_sender_egress.cc +++ b/modules/rtp_rtcp/source/deprecated/deprecated_rtp_sender_egress.cc @@ -201,7 +201,7 @@ void DEPRECATED_RtpSenderEgress::SendPacket( // actual sending fails. if (is_media && packet->allow_retransmission()) { packet_history_->PutRtpPacket(std::make_unique(*packet), - now_ms); + Timestamp::Millis(now_ms)); } else if (packet->retransmitted_sequence_number()) { packet_history_->MarkPacketAsSent(*packet->retransmitted_sequence_number()); } diff --git a/modules/rtp_rtcp/source/rtp_packet_history.cc b/modules/rtp_rtcp/source/rtp_packet_history.cc index eda3ecdee5..c8d400a985 100644 --- a/modules/rtp_rtcp/source/rtp_packet_history.cc +++ b/modules/rtp_rtcp/source/rtp_packet_history.cc @@ -23,19 +23,13 @@ namespace webrtc { -constexpr size_t RtpPacketHistory::kMaxCapacity; -constexpr size_t RtpPacketHistory::kMaxPaddingHistory; -constexpr int64_t RtpPacketHistory::kMinPacketDurationMs; -constexpr int RtpPacketHistory::kMinPacketDurationRtt; -constexpr int RtpPacketHistory::kPacketCullingDelayFactor; - RtpPacketHistory::StoredPacket::StoredPacket( std::unique_ptr packet, - int64_t send_time_ms, + Timestamp send_time, uint64_t insert_order) - : send_time_ms_(send_time_ms), - packet_(std::move(packet)), + : packet_(std::move(packet)), pending_transmission_(false), + send_time_(send_time), insert_order_(insert_order), times_retransmitted_(0) {} @@ -78,7 +72,7 @@ RtpPacketHistory::RtpPacketHistory(Clock* clock, bool enable_padding_prio) enable_padding_prio_(enable_padding_prio), number_to_store_(0), mode_(StorageMode::kDisabled), - rtt_ms_(-1), + rtt_(TimeDelta::MinusInfinity()), packets_inserted_(0) {} RtpPacketHistory::~RtpPacketHistory() {} @@ -100,29 +94,28 @@ RtpPacketHistory::StorageMode RtpPacketHistory::GetStorageMode() const { return mode_; } -void RtpPacketHistory::SetRtt(int64_t rtt_ms) { +void RtpPacketHistory::SetRtt(TimeDelta rtt) { MutexLock lock(&lock_); - RTC_DCHECK_GE(rtt_ms, 0); - rtt_ms_ = rtt_ms; + RTC_DCHECK_GE(rtt, TimeDelta::Zero()); + rtt_ = rtt; // If storage is not disabled, packets will be removed after a timeout // that depends on the RTT. Changing the RTT may thus cause some packets // become "old" and subject to removal. if (mode_ != StorageMode::kDisabled) { - CullOldPackets(clock_->TimeInMilliseconds()); + CullOldPackets(); } } void RtpPacketHistory::PutRtpPacket(std::unique_ptr packet, - int64_t send_time_ms) { + Timestamp send_time) { RTC_DCHECK(packet); MutexLock lock(&lock_); - int64_t now_ms = clock_->TimeInMilliseconds(); if (mode_ == StorageMode::kDisabled) { return; } RTC_DCHECK(packet->allow_retransmission()); - CullOldPackets(now_ms); + CullOldPackets(); // Store packet. const uint16_t rtp_seq_no = packet->SequenceNumber(); @@ -150,7 +143,7 @@ void RtpPacketHistory::PutRtpPacket(std::unique_ptr packet, RTC_DCHECK(packet_history_[packet_index].packet_ == nullptr); packet_history_[packet_index] = - StoredPacket(std::move(packet), send_time_ms, packets_inserted_++); + StoredPacket(std::move(packet), send_time, packets_inserted_++); if (enable_padding_prio_) { if (padding_priority_.size() >= kMaxPaddingHistory - 1) { @@ -188,7 +181,7 @@ std::unique_ptr RtpPacketHistory::GetPacketAndMarkAsPending( return nullptr; } - if (!VerifyRtt(*packet, clock_->TimeInMilliseconds())) { + if (!VerifyRtt(*packet)) { // Packet already resent within too short a time window, ignore. return nullptr; } @@ -216,7 +209,7 @@ void RtpPacketHistory::MarkPacketAsSent(uint16_t sequence_number) { // Update send-time, mark as no longer in pacer queue, and increment // transmission count. - packet->send_time_ms_ = clock_->TimeInMilliseconds(); + packet->set_send_time(clock_->CurrentTime()); packet->pending_transmission_ = false; packet->IncrementTimesRetransmitted(enable_padding_prio_ ? &padding_priority_ : nullptr); @@ -238,17 +231,17 @@ bool RtpPacketHistory::GetPacketState(uint16_t sequence_number) const { return false; } - if (!VerifyRtt(packet, clock_->TimeInMilliseconds())) { + if (!VerifyRtt(packet)) { return false; } return true; } -bool RtpPacketHistory::VerifyRtt(const RtpPacketHistory::StoredPacket& packet, - int64_t now_ms) const { +bool RtpPacketHistory::VerifyRtt( + const RtpPacketHistory::StoredPacket& packet) const { if (packet.times_retransmitted() > 0 && - now_ms < packet.send_time_ms_ + rtt_ms_) { + clock_->CurrentTime() - packet.send_time() < rtt_) { // This packet has already been retransmitted once, and the time since // that even is lower than on RTT. Ignore request as this packet is // likely already in the network pipe. @@ -305,7 +298,7 @@ std::unique_ptr RtpPacketHistory::GetPayloadPaddingPacket( return nullptr; } - best_packet->send_time_ms_ = clock_->TimeInMilliseconds(); + best_packet->set_send_time(clock_->CurrentTime()); best_packet->IncrementTimesRetransmitted( enable_padding_prio_ ? &padding_priority_ : nullptr); @@ -335,9 +328,12 @@ void RtpPacketHistory::Reset() { padding_priority_.clear(); } -void RtpPacketHistory::CullOldPackets(int64_t now_ms) { - int64_t packet_duration_ms = - std::max(kMinPacketDurationRtt * rtt_ms_, kMinPacketDurationMs); +void RtpPacketHistory::CullOldPackets() { + Timestamp now = clock_->CurrentTime(); + TimeDelta packet_duration = + rtt_.IsFinite() + ? std::max(kMinPacketDurationRtt * rtt_, kMinPacketDuration) + : kMinPacketDuration; while (!packet_history_.empty()) { if (packet_history_.size() >= kMaxCapacity) { // We have reached the absolute max capacity, remove one packet @@ -352,15 +348,15 @@ void RtpPacketHistory::CullOldPackets(int64_t now_ms) { return; } - if (stored_packet.send_time_ms_ + packet_duration_ms > now_ms) { + if (stored_packet.send_time() + packet_duration > now) { // Don't cull packets too early to avoid failed retransmission requests. return; } if (packet_history_.size() >= number_to_store_ || - stored_packet.send_time_ms_ + - (packet_duration_ms * kPacketCullingDelayFactor) <= - now_ms) { + stored_packet.send_time() + + (packet_duration * kPacketCullingDelayFactor) <= + now) { // Too many packets in history, or this packet has timed out. Remove it // and continue. RemovePacket(0); diff --git a/modules/rtp_rtcp/source/rtp_packet_history.h b/modules/rtp_rtcp/source/rtp_packet_history.h index 18cef0aa13..390fd98e08 100644 --- a/modules/rtp_rtcp/source/rtp_packet_history.h +++ b/modules/rtp_rtcp/source/rtp_packet_history.h @@ -15,9 +15,13 @@ #include #include #include +#include #include +#include "absl/base/attributes.h" #include "api/function_view.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/thread_annotations.h" @@ -39,8 +43,8 @@ class RtpPacketHistory { static constexpr size_t kMaxCapacity = 9600; // Maximum number of entries in prioritized queue of padding packets. static constexpr size_t kMaxPaddingHistory = 63; - // Don't remove packets within max(1000ms, 3x RTT). - static constexpr int64_t kMinPacketDurationMs = 1000; + // Don't remove packets within max(1 second, 3x RTT). + static constexpr TimeDelta kMinPacketDuration = TimeDelta::Seconds(1); static constexpr int kMinPacketDurationRtt = 3; // With kStoreAndCull, always remove packets after 3x max(1000ms, 3x rtt). static constexpr int kPacketCullingDelayFactor = 3; @@ -60,10 +64,19 @@ class RtpPacketHistory { // Set RTT, used to avoid premature retransmission and to prevent over-writing // a packet in the history before we are reasonably sure it has been received. - void SetRtt(int64_t rtt_ms); + ABSL_DEPRECATED("Use SetRtt below that takes TimeDelta") + void SetRtt(int64_t rtt_ms) { SetRtt(TimeDelta::Millis(rtt_ms)); } + + void SetRtt(TimeDelta rtt); + + ABSL_DEPRECATED("Use PutRtpPacket below that take Timestamp") + void PutRtpPacket(std::unique_ptr packet, + int64_t send_time_ms) { + PutRtpPacket(std::move(packet), Timestamp::Millis(send_time_ms)); + } void PutRtpPacket(std::unique_ptr packet, - int64_t send_time_ms); + Timestamp send_time); // Gets stored RTP packet corresponding to the input |sequence number|. // Returns nullptr if packet is not found or was (re)sent too recently. @@ -120,7 +133,7 @@ class RtpPacketHistory { public: StoredPacket() = default; StoredPacket(std::unique_ptr packet, - int64_t send_time_ms, + Timestamp send_time, uint64_t insert_order); StoredPacket(StoredPacket&&); StoredPacket& operator=(StoredPacket&&); @@ -131,7 +144,8 @@ class RtpPacketHistory { void IncrementTimesRetransmitted(PacketPrioritySet* priority_set); // The time of last transmission, including retransmissions. - int64_t send_time_ms_; + Timestamp send_time() const { return send_time_; } + void set_send_time(Timestamp value) { send_time_ = value; } // The actual packet. std::unique_ptr packet_; @@ -140,6 +154,8 @@ class RtpPacketHistory { bool pending_transmission_; private: + Timestamp send_time_ = Timestamp::Zero(); + // Unique number per StoredPacket, incremented by one for each added // packet. Used to sort on insert order. uint64_t insert_order_; @@ -152,10 +168,10 @@ class RtpPacketHistory { }; // Helper method to check if packet has too recently been sent. - bool VerifyRtt(const StoredPacket& packet, int64_t now_ms) const + bool VerifyRtt(const StoredPacket& packet) const RTC_EXCLUSIVE_LOCKS_REQUIRED(lock_); void Reset() RTC_EXCLUSIVE_LOCKS_REQUIRED(lock_); - void CullOldPackets(int64_t now_ms) RTC_EXCLUSIVE_LOCKS_REQUIRED(lock_); + void CullOldPackets() RTC_EXCLUSIVE_LOCKS_REQUIRED(lock_); // Removes the packet from the history, and context/mapping that has been // stored. Returns the RTP packet instance contained within the StoredPacket. std::unique_ptr RemovePacket(int packet_index) @@ -170,7 +186,7 @@ class RtpPacketHistory { mutable Mutex lock_; size_t number_to_store_ RTC_GUARDED_BY(lock_); StorageMode mode_ RTC_GUARDED_BY(lock_); - int64_t rtt_ms_ RTC_GUARDED_BY(lock_); + TimeDelta rtt_ RTC_GUARDED_BY(lock_); // Queue of stored packets, ordered by sequence number, with older packets in // the front and new packets being added to the back. Note that there may be diff --git a/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc b/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc index ffe167c5f6..f50541849e 100644 --- a/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_packet_history_unittest.cc @@ -64,7 +64,7 @@ TEST_P(RtpPacketHistoryTest, SetStoreStatus) { TEST_P(RtpPacketHistoryTest, ClearsHistoryAfterSetStoreStatus) { hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 10); hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), - fake_clock_.TimeInMilliseconds()); + /*send_time=*/fake_clock_.CurrentTime()); EXPECT_TRUE(hist_.GetPacketState(kStartSeqNum)); // Changing store status, even to the current one, will clear the history. @@ -75,7 +75,7 @@ TEST_P(RtpPacketHistoryTest, ClearsHistoryAfterSetStoreStatus) { TEST_P(RtpPacketHistoryTest, StartSeqResetAfterReset) { hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 10); hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), - fake_clock_.TimeInMilliseconds()); + /*send_time=*/fake_clock_.CurrentTime()); // Mark packet as pending so it won't be removed. EXPECT_TRUE(hist_.GetPacketAndMarkAsPending(kStartSeqNum)); @@ -85,17 +85,16 @@ TEST_P(RtpPacketHistoryTest, StartSeqResetAfterReset) { // Add a new packet. hist_.PutRtpPacket(CreateRtpPacket(To16u(kStartSeqNum + 1)), - fake_clock_.TimeInMilliseconds()); + /*send_time=*/fake_clock_.CurrentTime()); EXPECT_TRUE(hist_.GetPacketAndMarkAsPending(To16u(kStartSeqNum + 1))); // Advance time past where packet expires. - fake_clock_.AdvanceTimeMilliseconds( - RtpPacketHistory::kPacketCullingDelayFactor * - RtpPacketHistory::kMinPacketDurationMs); + fake_clock_.AdvanceTime(RtpPacketHistory::kPacketCullingDelayFactor * + RtpPacketHistory::kMinPacketDuration); // Add one more packet and verify no state left from packet before reset. hist_.PutRtpPacket(CreateRtpPacket(To16u(kStartSeqNum + 2)), - fake_clock_.TimeInMilliseconds()); + /*send_time=*/fake_clock_.CurrentTime()); EXPECT_FALSE(hist_.GetPacketState(kStartSeqNum)); EXPECT_TRUE(hist_.GetPacketState(To16u(kStartSeqNum + 1))); EXPECT_TRUE(hist_.GetPacketState(To16u(kStartSeqNum + 2))); @@ -104,7 +103,8 @@ TEST_P(RtpPacketHistoryTest, StartSeqResetAfterReset) { TEST_P(RtpPacketHistoryTest, NoStoreStatus) { EXPECT_EQ(StorageMode::kDisabled, hist_.GetStorageMode()); std::unique_ptr packet = CreateRtpPacket(kStartSeqNum); - hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMilliseconds()); + hist_.PutRtpPacket(std::move(packet), + /*send_time=*/fake_clock_.CurrentTime()); // Packet should not be stored. EXPECT_FALSE(hist_.GetPacketState(kStartSeqNum)); } @@ -119,7 +119,8 @@ TEST_P(RtpPacketHistoryTest, PutRtpPacket) { std::unique_ptr packet = CreateRtpPacket(kStartSeqNum); EXPECT_FALSE(hist_.GetPacketState(kStartSeqNum)); - hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMilliseconds()); + hist_.PutRtpPacket(std::move(packet), + /*send_time=*/fake_clock_.CurrentTime()); EXPECT_TRUE(hist_.GetPacketState(kStartSeqNum)); } @@ -129,7 +130,8 @@ TEST_P(RtpPacketHistoryTest, GetRtpPacket) { std::unique_ptr packet = CreateRtpPacket(kStartSeqNum); packet->set_capture_time(capture_time); rtc::CopyOnWriteBuffer buffer = packet->Buffer(); - hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMilliseconds()); + hist_.PutRtpPacket(std::move(packet), + /*send_time=*/fake_clock_.CurrentTime()); std::unique_ptr packet_out = hist_.GetPacketAndMarkAsPending(kStartSeqNum); @@ -139,14 +141,14 @@ TEST_P(RtpPacketHistoryTest, GetRtpPacket) { } TEST_P(RtpPacketHistoryTest, MinResendTime) { - static const int64_t kMinRetransmitIntervalMs = 100; + static const TimeDelta kMinRetransmitInterval = TimeDelta::Millis(100); hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 10); - hist_.SetRtt(kMinRetransmitIntervalMs); + hist_.SetRtt(kMinRetransmitInterval); Timestamp capture_time = fake_clock_.CurrentTime(); std::unique_ptr packet = CreateRtpPacket(kStartSeqNum); size_t len = packet->size(); - hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMilliseconds()); + hist_.PutRtpPacket(std::move(packet), fake_clock_.CurrentTime()); // First retransmission - allow early retransmission. fake_clock_.AdvanceTimeMilliseconds(1); @@ -157,7 +159,7 @@ TEST_P(RtpPacketHistoryTest, MinResendTime) { hist_.MarkPacketAsSent(kStartSeqNum); // Second retransmission - advance time to just before retransmission OK. - fake_clock_.AdvanceTimeMilliseconds(kMinRetransmitIntervalMs - 1); + fake_clock_.AdvanceTime(kMinRetransmitInterval - TimeDelta::Millis(1)); EXPECT_FALSE(hist_.GetPacketAndMarkAsPending(kStartSeqNum)); // Advance time to just after retransmission OK. @@ -169,18 +171,18 @@ TEST_P(RtpPacketHistoryTest, RemovesOldestSentPacketWhenAtMaxSize) { const size_t kMaxNumPackets = 10; hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, kMaxNumPackets); - // History does not allow removing packets within kMinPacketDurationMs, + // History does not allow removing packets within kMinPacketDuration, // so in order to test capacity, make sure insertion spans this time. - const int64_t kPacketIntervalMs = - RtpPacketHistory::kMinPacketDurationMs / kMaxNumPackets; + const TimeDelta kPacketInterval = + RtpPacketHistory::kMinPacketDuration / kMaxNumPackets; // Add packets until the buffer is full. for (size_t i = 0; i < kMaxNumPackets; ++i) { std::unique_ptr packet = CreateRtpPacket(To16u(kStartSeqNum + i)); // Immediate mark packet as sent. - hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMilliseconds()); - fake_clock_.AdvanceTimeMilliseconds(kPacketIntervalMs); + hist_.PutRtpPacket(std::move(packet), fake_clock_.CurrentTime()); + fake_clock_.AdvanceTime(kPacketInterval); } // First packet should still be there. @@ -189,7 +191,7 @@ TEST_P(RtpPacketHistoryTest, RemovesOldestSentPacketWhenAtMaxSize) { // History is full, oldest one should be overwritten. std::unique_ptr packet = CreateRtpPacket(To16u(kStartSeqNum + kMaxNumPackets)); - hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMilliseconds()); + hist_.PutRtpPacket(std::move(packet), fake_clock_.CurrentTime()); // Oldest packet should be gone, but packet after than one still present. EXPECT_FALSE(hist_.GetPacketState(kStartSeqNum)); @@ -207,7 +209,8 @@ TEST_P(RtpPacketHistoryTest, RemovesOldestPacketWhenAtMaxCapacity) { for (size_t i = 0; i < kMaxNumPackets; ++i) { std::unique_ptr packet = CreateRtpPacket(To16u(kStartSeqNum + i)); - hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMilliseconds()); + hist_.PutRtpPacket(std::move(packet), + /*send_time=*/fake_clock_.CurrentTime()); // Mark packets as pending, preventing it from being removed. hist_.GetPacketAndMarkAsPending(To16u(kStartSeqNum + i)); } @@ -218,7 +221,7 @@ TEST_P(RtpPacketHistoryTest, RemovesOldestPacketWhenAtMaxCapacity) { // History is full, oldest one should be overwritten. std::unique_ptr packet = CreateRtpPacket(To16u(kStartSeqNum + kMaxNumPackets)); - hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMilliseconds()); + hist_.PutRtpPacket(std::move(packet), fake_clock_.CurrentTime()); // Oldest packet should be gone, but packet after than one still present. EXPECT_FALSE(hist_.GetPacketState(kStartSeqNum)); @@ -235,14 +238,14 @@ TEST_P(RtpPacketHistoryTest, RemovesLowestPrioPaddingWhenAtMaxCapacity) { // set of potential padding packets. const size_t kMaxNumPackets = RtpPacketHistory::kMaxPaddingHistory; hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, kMaxNumPackets * 2); - hist_.SetRtt(1); + hist_.SetRtt(TimeDelta::Millis(1)); // Add packets until the max is reached, and then yet another one. for (size_t i = 0; i < kMaxNumPackets + 1; ++i) { std::unique_ptr packet = CreateRtpPacket(To16u(kStartSeqNum + i)); // Don't mark packets as sent, preventing them from being removed. - hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMilliseconds()); + hist_.PutRtpPacket(std::move(packet), fake_clock_.CurrentTime()); } // Advance time to allow retransmission/padding. @@ -267,50 +270,48 @@ TEST_P(RtpPacketHistoryTest, DontRemoveTooRecentlyTransmittedPackets) { hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 1); // Add a packet, marked as send, and advance time to just before removal time. - hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), - fake_clock_.TimeInMilliseconds()); - fake_clock_.AdvanceTimeMilliseconds(RtpPacketHistory::kMinPacketDurationMs - - 1); + hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), fake_clock_.CurrentTime()); + fake_clock_.AdvanceTime(RtpPacketHistory::kMinPacketDuration - + TimeDelta::Millis(1)); // Add a new packet to trigger culling. hist_.PutRtpPacket(CreateRtpPacket(To16u(kStartSeqNum + 1)), - fake_clock_.TimeInMilliseconds()); + fake_clock_.CurrentTime()); // First packet should still be there. EXPECT_TRUE(hist_.GetPacketState(kStartSeqNum)); // Advance time to where packet will be eligible for removal and try again. fake_clock_.AdvanceTimeMilliseconds(1); hist_.PutRtpPacket(CreateRtpPacket(To16u(kStartSeqNum + 2)), - fake_clock_.TimeInMilliseconds()); + fake_clock_.CurrentTime()); // First packet should no be gone, but next one still there. EXPECT_FALSE(hist_.GetPacketState(kStartSeqNum)); EXPECT_TRUE(hist_.GetPacketState(To16u(kStartSeqNum + 1))); } TEST_P(RtpPacketHistoryTest, DontRemoveTooRecentlyTransmittedPacketsHighRtt) { - const int64_t kRttMs = RtpPacketHistory::kMinPacketDurationMs * 2; - const int64_t kPacketTimeoutMs = - kRttMs * RtpPacketHistory::kMinPacketDurationRtt; + const TimeDelta kRtt = RtpPacketHistory::kMinPacketDuration * 2; + const TimeDelta kPacketTimeout = + kRtt * RtpPacketHistory::kMinPacketDurationRtt; // Set size to remove old packets as soon as possible. hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 1); - hist_.SetRtt(kRttMs); + hist_.SetRtt(kRtt); // Add a packet, marked as send, and advance time to just before removal time. - hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), - fake_clock_.TimeInMilliseconds()); - fake_clock_.AdvanceTimeMilliseconds(kPacketTimeoutMs - 1); + hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), fake_clock_.CurrentTime()); + fake_clock_.AdvanceTime(kPacketTimeout - TimeDelta::Millis(1)); // Add a new packet to trigger culling. hist_.PutRtpPacket(CreateRtpPacket(To16u(kStartSeqNum + 1)), - fake_clock_.TimeInMilliseconds()); + fake_clock_.CurrentTime()); // First packet should still be there. EXPECT_TRUE(hist_.GetPacketState(kStartSeqNum)); // Advance time to where packet will be eligible for removal and try again. fake_clock_.AdvanceTimeMilliseconds(1); hist_.PutRtpPacket(CreateRtpPacket(To16u(kStartSeqNum + 2)), - fake_clock_.TimeInMilliseconds()); + fake_clock_.CurrentTime()); // First packet should no be gone, but next one still there. EXPECT_FALSE(hist_.GetPacketState(kStartSeqNum)); EXPECT_TRUE(hist_.GetPacketState(To16u(kStartSeqNum + 1))); @@ -321,12 +322,11 @@ TEST_P(RtpPacketHistoryTest, RemovesOldWithCulling) { // Enable culling. Even without feedback, this can trigger early removal. hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, kMaxNumPackets); - hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), - fake_clock_.TimeInMilliseconds()); + hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), fake_clock_.CurrentTime()); - int64_t kMaxPacketDurationMs = RtpPacketHistory::kMinPacketDurationMs * + TimeDelta kMaxPacketDuration = RtpPacketHistory::kMinPacketDuration * RtpPacketHistory::kPacketCullingDelayFactor; - fake_clock_.AdvanceTimeMilliseconds(kMaxPacketDurationMs - 1); + fake_clock_.AdvanceTime(kMaxPacketDuration - TimeDelta::Millis(1)); // First packet should still be there. EXPECT_TRUE(hist_.GetPacketState(kStartSeqNum)); @@ -334,25 +334,24 @@ TEST_P(RtpPacketHistoryTest, RemovesOldWithCulling) { // Advance to where packet can be culled, even if buffer is not full. fake_clock_.AdvanceTimeMilliseconds(1); hist_.PutRtpPacket(CreateRtpPacket(To16u(kStartSeqNum + 1)), - fake_clock_.TimeInMilliseconds()); + fake_clock_.CurrentTime()); EXPECT_FALSE(hist_.GetPacketState(kStartSeqNum)); } TEST_P(RtpPacketHistoryTest, RemovesOldWithCullingHighRtt) { const size_t kMaxNumPackets = 10; - const int64_t kRttMs = RtpPacketHistory::kMinPacketDurationMs * 2; + const TimeDelta kRtt = RtpPacketHistory::kMinPacketDuration * 2; // Enable culling. Even without feedback, this can trigger early removal. hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, kMaxNumPackets); - hist_.SetRtt(kRttMs); + hist_.SetRtt(kRtt); - hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), - fake_clock_.TimeInMilliseconds()); + hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), fake_clock_.CurrentTime()); - int64_t kMaxPacketDurationMs = kRttMs * + TimeDelta kMaxPacketDuration = kRtt * RtpPacketHistory::kMinPacketDurationRtt * RtpPacketHistory::kPacketCullingDelayFactor; - fake_clock_.AdvanceTimeMilliseconds(kMaxPacketDurationMs - 1); + fake_clock_.AdvanceTime(kMaxPacketDuration - TimeDelta::Millis(1)); // First packet should still be there. EXPECT_TRUE(hist_.GetPacketState(kStartSeqNum)); @@ -360,30 +359,33 @@ TEST_P(RtpPacketHistoryTest, RemovesOldWithCullingHighRtt) { // Advance to where packet can be culled, even if buffer is not full. fake_clock_.AdvanceTimeMilliseconds(1); hist_.PutRtpPacket(CreateRtpPacket(To16u(kStartSeqNum + 1)), - fake_clock_.TimeInMilliseconds()); + fake_clock_.CurrentTime()); EXPECT_FALSE(hist_.GetPacketState(kStartSeqNum)); } TEST_P(RtpPacketHistoryTest, CullWithAcks) { - const int64_t kPacketLifetime = RtpPacketHistory::kMinPacketDurationMs * - RtpPacketHistory::kPacketCullingDelayFactor; + const TimeDelta kPacketLifetime = RtpPacketHistory::kMinPacketDuration * + RtpPacketHistory::kPacketCullingDelayFactor; - const int64_t start_time = fake_clock_.TimeInMilliseconds(); + const Timestamp start_time = fake_clock_.CurrentTime(); hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 10); // Insert three packets 33ms apart, immediately mark them as sent. std::unique_ptr packet = CreateRtpPacket(kStartSeqNum); packet->SetPayloadSize(50); - hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMilliseconds()); + hist_.PutRtpPacket(std::move(packet), + /*send_time=*/fake_clock_.CurrentTime()); fake_clock_.AdvanceTimeMilliseconds(33); packet = CreateRtpPacket(To16u(kStartSeqNum + 1)); packet->SetPayloadSize(50); - hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMilliseconds()); + hist_.PutRtpPacket(std::move(packet), + /*send_time=*/fake_clock_.CurrentTime()); fake_clock_.AdvanceTimeMilliseconds(33); packet = CreateRtpPacket(To16u(kStartSeqNum + 2)); packet->SetPayloadSize(50); - hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMilliseconds()); + hist_.PutRtpPacket(std::move(packet), + /*send_time=*/fake_clock_.CurrentTime()); EXPECT_TRUE(hist_.GetPacketState(kStartSeqNum)); EXPECT_TRUE(hist_.GetPacketState(To16u(kStartSeqNum + 1))); @@ -399,38 +401,38 @@ TEST_P(RtpPacketHistoryTest, CullWithAcks) { // Advance time to where second packet would have expired, verify first packet // is removed. - int64_t second_packet_expiry_time = start_time + kPacketLifetime + 33 + 1; - fake_clock_.AdvanceTimeMilliseconds(second_packet_expiry_time - - fake_clock_.TimeInMilliseconds()); - hist_.SetRtt(1); // Trigger culling of old packets. + Timestamp second_packet_expiry_time = + start_time + kPacketLifetime + TimeDelta::Millis(33 + 1); + fake_clock_.AdvanceTime(second_packet_expiry_time - + fake_clock_.CurrentTime()); + hist_.SetRtt(TimeDelta::Millis(1)); // Trigger culling of old packets. EXPECT_FALSE(hist_.GetPacketState(kStartSeqNum)); EXPECT_FALSE(hist_.GetPacketState(To16u(kStartSeqNum + 1))); EXPECT_TRUE(hist_.GetPacketState(To16u(kStartSeqNum + 2))); // Advance to where last packet expires, verify all gone. fake_clock_.AdvanceTimeMilliseconds(33); - hist_.SetRtt(1); // Trigger culling of old packets. + hist_.SetRtt(TimeDelta::Millis(1)); // Trigger culling of old packets. EXPECT_FALSE(hist_.GetPacketState(kStartSeqNum)); EXPECT_FALSE(hist_.GetPacketState(To16u(kStartSeqNum + 1))); EXPECT_FALSE(hist_.GetPacketState(To16u(kStartSeqNum + 2))); } TEST_P(RtpPacketHistoryTest, GetPacketAndSetSent) { - const int64_t kRttMs = RtpPacketHistory::kMinPacketDurationMs * 2; - hist_.SetRtt(kRttMs); + const TimeDelta kRtt = RtpPacketHistory::kMinPacketDuration * 2; + hist_.SetRtt(kRtt); // Set size to remove old packets as soon as possible. hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 1); // Add a sent packet to the history. - hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), - fake_clock_.TimeInMicroseconds()); + hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), fake_clock_.CurrentTime()); // Retransmission request, first retransmission is allowed immediately. EXPECT_TRUE(hist_.GetPacketAndMarkAsPending(kStartSeqNum)); // Packet not yet sent, new retransmission not allowed. - fake_clock_.AdvanceTimeMilliseconds(kRttMs); + fake_clock_.AdvanceTime(kRtt); EXPECT_FALSE(hist_.GetPacketAndMarkAsPending(kStartSeqNum)); // Mark as sent, but too early for retransmission. @@ -438,14 +440,14 @@ TEST_P(RtpPacketHistoryTest, GetPacketAndSetSent) { EXPECT_FALSE(hist_.GetPacketAndMarkAsPending(kStartSeqNum)); // Enough time has passed, retransmission is allowed again. - fake_clock_.AdvanceTimeMilliseconds(kRttMs); + fake_clock_.AdvanceTime(kRtt); EXPECT_TRUE(hist_.GetPacketAndMarkAsPending(kStartSeqNum)); } TEST_P(RtpPacketHistoryTest, GetPacketWithEncapsulation) { const uint32_t kSsrc = 92384762; - const int64_t kRttMs = RtpPacketHistory::kMinPacketDurationMs * 2; - hist_.SetRtt(kRttMs); + const TimeDelta kRtt = RtpPacketHistory::kMinPacketDuration * 2; + hist_.SetRtt(kRtt); // Set size to remove old packets as soon as possible. hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 1); @@ -453,7 +455,7 @@ TEST_P(RtpPacketHistoryTest, GetPacketWithEncapsulation) { // Add a sent packet to the history, with a set SSRC. std::unique_ptr packet = CreateRtpPacket(kStartSeqNum); packet->SetSsrc(kSsrc); - hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMicroseconds()); + hist_.PutRtpPacket(std::move(packet), fake_clock_.CurrentTime()); // Retransmission request, simulate an RTX-like encapsulation, were the packet // is sent on a different SSRC. @@ -472,8 +474,7 @@ TEST_P(RtpPacketHistoryTest, GetPacketWithEncapsulation) { TEST_P(RtpPacketHistoryTest, GetPacketWithEncapsulationAbortOnNullptr) { hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 1); - hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), - fake_clock_.TimeInMicroseconds()); + hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), fake_clock_.CurrentTime()); // Retransmission request, but the encapsulator determines that this packet is // not suitable for retransmission (bandwidth exhausted?) so the retransmit is @@ -487,20 +488,19 @@ TEST_P(RtpPacketHistoryTest, GetPacketWithEncapsulationAbortOnNullptr) { } TEST_P(RtpPacketHistoryTest, DontRemovePendingTransmissions) { - const int64_t kRttMs = RtpPacketHistory::kMinPacketDurationMs * 2; - const int64_t kPacketTimeoutMs = - kRttMs * RtpPacketHistory::kMinPacketDurationRtt; + const TimeDelta kRtt = RtpPacketHistory::kMinPacketDuration * 2; + const TimeDelta kPacketTimeout = + kRtt * RtpPacketHistory::kMinPacketDurationRtt; // Set size to remove old packets as soon as possible. hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 1); - hist_.SetRtt(kRttMs); + hist_.SetRtt(kRtt); // Add a sent packet. - hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), - fake_clock_.TimeInMilliseconds()); + hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), fake_clock_.CurrentTime()); // Advance clock to just before packet timeout. - fake_clock_.AdvanceTimeMilliseconds(kPacketTimeoutMs - 1); + fake_clock_.AdvanceTime(kPacketTimeout - TimeDelta::Millis(1)); // Mark as enqueued in pacer. EXPECT_TRUE(hist_.GetPacketAndMarkAsPending(kStartSeqNum)); @@ -511,7 +511,7 @@ TEST_P(RtpPacketHistoryTest, DontRemovePendingTransmissions) { // Packet sent. Now it can be removed. hist_.MarkPacketAsSent(kStartSeqNum); - hist_.SetRtt(kRttMs); // Force culling of old packets. + hist_.SetRtt(kRtt); // Force culling of old packets. EXPECT_FALSE(hist_.GetPacketState(kStartSeqNum)); } @@ -524,12 +524,11 @@ TEST_P(RtpPacketHistoryTest, PrioritizedPayloadPadding) { hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 1); // Add two sent packets, one millisecond apart. - hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), - fake_clock_.TimeInMilliseconds()); + hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), fake_clock_.CurrentTime()); fake_clock_.AdvanceTimeMilliseconds(1); hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum + 1), - fake_clock_.TimeInMilliseconds()); + fake_clock_.CurrentTime()); fake_clock_.AdvanceTimeMilliseconds(1); // Latest packet given equal retransmission count. @@ -560,8 +559,7 @@ TEST_P(RtpPacketHistoryTest, PrioritizedPayloadPadding) { TEST_P(RtpPacketHistoryTest, NoPendingPacketAsPadding) { hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 1); - hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), - fake_clock_.TimeInMilliseconds()); + hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), fake_clock_.CurrentTime()); fake_clock_.AdvanceTimeMilliseconds(1); EXPECT_EQ(hist_.GetPayloadPaddingPacket()->SequenceNumber(), kStartSeqNum); @@ -578,8 +576,7 @@ TEST_P(RtpPacketHistoryTest, NoPendingPacketAsPadding) { TEST_P(RtpPacketHistoryTest, PayloadPaddingWithEncapsulation) { hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 1); - hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), - fake_clock_.TimeInMilliseconds()); + hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), fake_clock_.CurrentTime()); fake_clock_.AdvanceTimeMilliseconds(1); // Aborted padding. @@ -600,10 +597,9 @@ TEST_P(RtpPacketHistoryTest, PayloadPaddingWithEncapsulation) { TEST_P(RtpPacketHistoryTest, NackAfterAckIsNoop) { hist_.SetStorePacketsStatus(StorageMode::kStoreAndCull, 2); // Add two sent packets. - hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), - fake_clock_.TimeInMilliseconds()); + hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum), fake_clock_.CurrentTime()); hist_.PutRtpPacket(CreateRtpPacket(kStartSeqNum + 1), - fake_clock_.TimeInMilliseconds()); + fake_clock_.CurrentTime()); // Remove newest one. hist_.CullAcknowledgedPackets(std::vector{kStartSeqNum + 1}); // Retransmission request for already acked packet, should be noop. @@ -622,7 +618,7 @@ TEST_P(RtpPacketHistoryTest, OutOfOrderInsertRemoval) { uint16_t seq_no = To16u(kStartSeqNum + offset); std::unique_ptr packet = CreateRtpPacket(seq_no); packet->SetPayloadSize(50); - hist_.PutRtpPacket(std::move(packet), fake_clock_.TimeInMilliseconds()); + hist_.PutRtpPacket(std::move(packet), fake_clock_.CurrentTime()); fake_clock_.AdvanceTimeMilliseconds(33); } @@ -649,7 +645,7 @@ TEST_P(RtpPacketHistoryTest, UsesLastPacketAsPaddingWithPrioOff) { for (size_t i = 0; i < kHistorySize; ++i) { hist_.PutRtpPacket(CreateRtpPacket(To16u(kStartSeqNum + i)), - fake_clock_.TimeInMilliseconds()); + fake_clock_.CurrentTime()); hist_.MarkPacketAsSent(To16u(kStartSeqNum + i)); fake_clock_.AdvanceTimeMilliseconds(1); diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc index 367785846b..a98dab3972 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc @@ -787,7 +787,7 @@ void ModuleRtpRtcpImpl::set_rtt_ms(int64_t rtt_ms) { rtt_ms_ = rtt_ms; } if (rtp_sender_) { - rtp_sender_->packet_history.SetRtt(rtt_ms); + rtp_sender_->packet_history.SetRtt(TimeDelta::Millis(rtt_ms)); } } diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc index 6f39c5ce53..06fbbe01b5 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc @@ -745,7 +745,7 @@ void ModuleRtpRtcpImpl2::set_rtt_ms(int64_t rtt_ms) { rtt_ms_ = rtt_ms; } if (rtp_sender_) { - rtp_sender_->packet_history.SetRtt(rtt_ms); + rtp_sender_->packet_history.SetRtt(TimeDelta::Millis(rtt_ms)); } } diff --git a/modules/rtp_rtcp/source/rtp_sender.cc b/modules/rtp_rtcp/source/rtp_sender.cc index f644c7d64a..d5c6c16978 100644 --- a/modules/rtp_rtcp/source/rtp_sender.cc +++ b/modules/rtp_rtcp/source/rtp_sender.cc @@ -354,7 +354,7 @@ void RTPSender::OnReceivedAckOnRtxSsrc( void RTPSender::OnReceivedNack( const std::vector& nack_sequence_numbers, int64_t avg_rtt) { - packet_history_->SetRtt(5 + avg_rtt); + packet_history_->SetRtt(TimeDelta::Millis(5 + avg_rtt)); for (uint16_t seq_no : nack_sequence_numbers) { const int32_t bytes_sent = ReSendPacket(seq_no); if (bytes_sent < 0) { diff --git a/modules/rtp_rtcp/source/rtp_sender_egress.cc b/modules/rtp_rtcp/source/rtp_sender_egress.cc index b34b54c1fa..e5c2e536f6 100644 --- a/modules/rtp_rtcp/source/rtp_sender_egress.cc +++ b/modules/rtp_rtcp/source/rtp_sender_egress.cc @@ -276,7 +276,7 @@ void RtpSenderEgress::SendPacket(RtpPacketToSend* packet, // actual sending fails. if (is_media && packet->allow_retransmission()) { packet_history_->PutRtpPacket(std::make_unique(*packet), - now_ms); + Timestamp::Millis(now_ms)); } else if (packet->retransmitted_sequence_number()) { packet_history_->MarkPacketAsSent(*packet->retransmitted_sequence_number()); } diff --git a/modules/rtp_rtcp/source/rtp_sender_unittest.cc b/modules/rtp_rtcp/source/rtp_sender_unittest.cc index 0582d71453..d77d566c17 100644 --- a/modules/rtp_rtcp/source/rtp_sender_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_sender_unittest.cc @@ -371,7 +371,7 @@ TEST_F(RtpSenderTest, ReSendPacketForwardsPacketsToPacer) { auto packet = BuildRtpPacket(kPayload, kMarkerBit, kTimestamp, now_ms); packet->SetSequenceNumber(kSeqNum); packet->set_allow_retransmission(true); - packet_history_->PutRtpPacket(std::move(packet), now_ms); + packet_history_->PutRtpPacket(std::move(packet), Timestamp::Millis(now_ms)); EXPECT_CALL(mock_paced_sender_, EnqueuePackets(ElementsAre(AllOf( @@ -571,7 +571,8 @@ TEST_F(RtpSenderTest, KeepsTimestampsOnPayloadPadding) { Timestamp::Millis(start_time))))))); std::unique_ptr media_packet = SendPacket(start_time, kPayloadSize); - packet_history_->PutRtpPacket(std::move(media_packet), start_time); + packet_history_->PutRtpPacket(std::move(media_packet), + Timestamp::Millis(start_time)); // Advance time before sending padding. const TimeDelta kTimeDiff = TimeDelta::Millis(17); @@ -626,7 +627,7 @@ TEST_F(RtpSenderTest, RidIncludedOnRtxSentPackets) { .WillOnce([&](std::vector> packets) { sequencer_->Sequence(*packets[0]); packet_history_->PutRtpPacket(std::move(packets[0]), - clock_->TimeInMilliseconds()); + clock_->CurrentTime()); }); SendGenericPacket(); @@ -705,7 +706,7 @@ TEST_F(RtpSenderTest, MidAndRidIncludedOnFirstRtxPacket) { EXPECT_CALL(mock_paced_sender_, EnqueuePackets(SizeIs(1))) .WillOnce([&](std::vector> packets) { packet_history_->PutRtpPacket(std::move(packets[0]), - clock_->TimeInMilliseconds()); + clock_->CurrentTime()); }); auto second_built_packet = SendGenericPacket(); @@ -734,7 +735,7 @@ TEST_F(RtpSenderTest, MidAndRidNotIncludedOnRtxPacketsAfterAck) { sequencer_->Sequence(*first_built_packet); packet_history_->PutRtpPacket( std::make_unique(*first_built_packet), - /*send_time=*/clock_->TimeInMilliseconds()); + /*send_time=*/clock_->CurrentTime()); rtp_sender_->OnReceivedAckOnSsrc(first_built_packet->SequenceNumber()); // The second packet will include neither since an ack was received. @@ -742,7 +743,7 @@ TEST_F(RtpSenderTest, MidAndRidNotIncludedOnRtxPacketsAfterAck) { sequencer_->Sequence(*second_built_packet); packet_history_->PutRtpPacket( std::make_unique(*second_built_packet), - /*send_time=*/clock_->TimeInMilliseconds()); + /*send_time=*/clock_->CurrentTime()); // The first RTX packet will include MID and RRID. EXPECT_CALL(mock_paced_sender_, EnqueuePackets(SizeIs(1))) @@ -782,7 +783,7 @@ TEST_F(RtpSenderTest, MidAndRidAlwaysIncludedOnRtxPacketsWhenConfigured) { .WillRepeatedly( [&](std::vector> packets) { packet_history_->PutRtpPacket(std::move(packets[0]), - clock_->TimeInMilliseconds()); + clock_->CurrentTime()); }); auto media_packet1 = SendGenericPacket(); rtp_sender_->OnReceivedAckOnSsrc(media_packet1->SequenceNumber()); @@ -850,7 +851,7 @@ TEST_F(RtpSenderTest, MidAndRridNotIncludedOnRtxPacketsAfterRtpStateRestored) { EXPECT_CALL(mock_paced_sender_, EnqueuePackets(SizeIs(1))) .WillOnce([&](std::vector> packets) { packet_history_->PutRtpPacket(std::move(packets[0]), - clock_->TimeInMilliseconds()); + clock_->CurrentTime()); }); auto built_packet = SendGenericPacket(); @@ -877,7 +878,7 @@ TEST_F(RtpSenderTest, RespectsNackBitrateLimit) { sequencer_->Sequence(*packet); sequence_numbers.push_back(packet->SequenceNumber()); packet_history_->PutRtpPacket(std::move(packet), - /*send_time=*/clock_->TimeInMilliseconds()); + /*send_time=*/clock_->CurrentTime()); time_controller_.AdvanceTime(TimeDelta::Millis(1)); } @@ -994,8 +995,7 @@ TEST_F(RtpSenderTest, SendPacketHandlesRetransmissionHistory) { BuildRtpPacket(kPayload, true, 0, clock_->TimeInMilliseconds()); const uint16_t media_sequence_number = packet->SequenceNumber(); packet->set_allow_retransmission(true); - packet_history_->PutRtpPacket(std::move(packet), - clock_->TimeInMilliseconds()); + packet_history_->PutRtpPacket(std::move(packet), clock_->CurrentTime()); // Simulate successful retransmission request. time_controller_.AdvanceTime(TimeDelta::Millis(30)); @@ -1022,8 +1022,7 @@ TEST_F(RtpSenderTest, MarksRetransmittedPackets) { BuildRtpPacket(kPayload, true, 0, clock_->TimeInMilliseconds()); const uint16_t media_sequence_number = packet->SequenceNumber(); packet->set_allow_retransmission(true); - packet_history_->PutRtpPacket(std::move(packet), - clock_->TimeInMilliseconds()); + packet_history_->PutRtpPacket(std::move(packet), clock_->CurrentTime()); // Expect a retransmission packet marked with which packet it is a // retransmit of. @@ -1055,8 +1054,7 @@ TEST_F(RtpSenderTest, GeneratedPaddingHasBweExtensions) { packet->set_allow_retransmission(true); packet->SetPayloadSize(kMinPaddingSize); packet->set_packet_type(RtpPacketMediaType::kVideo); - packet_history_->PutRtpPacket(std::move(packet), - clock_->TimeInMilliseconds()); + packet_history_->PutRtpPacket(std::move(packet), clock_->CurrentTime()); // Generate a plain padding packet, check that extensions are registered. std::vector> generated_packets = @@ -1098,8 +1096,7 @@ TEST_F(RtpSenderTest, GeneratePaddingResendsOldPacketsWithRtx) { packet->set_allow_retransmission(true); packet->SetPayloadSize(kPayloadPacketSize); packet->set_packet_type(RtpPacketMediaType::kVideo); - packet_history_->PutRtpPacket(std::move(packet), - clock_->TimeInMilliseconds()); + packet_history_->PutRtpPacket(std::move(packet), clock_->CurrentTime()); // Generated padding has large enough budget that the video packet should be // retransmitted as padding. @@ -1149,8 +1146,7 @@ TEST_F(RtpSenderTest, LimitsPayloadPaddingSize) { packet->set_allow_retransmission(true); packet->SetPayloadSize(kPayloadPacketSize); packet->set_packet_type(RtpPacketMediaType::kVideo); - packet_history_->PutRtpPacket(std::move(packet), - clock_->TimeInMilliseconds()); + packet_history_->PutRtpPacket(std::move(packet), clock_->CurrentTime()); // Smallest target size that will result in the sent packet being returned as // padding. @@ -1191,8 +1187,7 @@ TEST_F(RtpSenderTest, GeneratePaddingCreatesPurePaddingWithoutRtx) { packet->SetPayloadSize(kPayloadPacketSize); packet->set_packet_type(RtpPacketMediaType::kVideo); sequencer_->Sequence(*packet); - packet_history_->PutRtpPacket(std::move(packet), - clock_->TimeInMilliseconds()); + packet_history_->PutRtpPacket(std::move(packet), clock_->CurrentTime()); // Payload padding not available without RTX, only generate plain padding on // the media SSRC. @@ -1269,7 +1264,8 @@ TEST_F(RtpSenderTest, SetsCaptureTimeOnRtxRetransmissions) { /*capture_time_ms=*/start_time_ms); packet->set_allow_retransmission(true); sequencer_->Sequence(*packet); - packet_history_->PutRtpPacket(std::move(packet), start_time_ms); + packet_history_->PutRtpPacket(std::move(packet), + Timestamp::Millis(start_time_ms)); // Advance time, request an RTX retransmission. Capture timestamp should be // preserved. @@ -1283,7 +1279,7 @@ TEST_F(RtpSenderTest, SetsCaptureTimeOnRtxRetransmissions) { } TEST_F(RtpSenderTest, IgnoresNackAfterDisablingMedia) { - const int64_t kRtt = 10; + const TimeDelta kRtt = TimeDelta::Millis(10); EnableRtx(); packet_history_->SetRtt(kRtt); @@ -1295,18 +1291,19 @@ TEST_F(RtpSenderTest, IgnoresNackAfterDisablingMedia) { /*capture_time_ms=*/start_time_ms); packet->set_allow_retransmission(true); sequencer_->Sequence(*packet); - packet_history_->PutRtpPacket(std::move(packet), start_time_ms); + packet_history_->PutRtpPacket(std::move(packet), + Timestamp::Millis(start_time_ms)); // Disable media sending and try to retransmit the packet, it should fail. rtp_sender_->SetSendingMediaStatus(false); - time_controller_.AdvanceTime(TimeDelta::Millis(kRtt)); + time_controller_.AdvanceTime(kRtt); EXPECT_LT(rtp_sender_->ReSendPacket(kSeqNum), 0); } TEST_F(RtpSenderTest, DoesntFecProtectRetransmissions) { // Set up retranmission without RTX, so that a plain copy of the old packet is // re-sent instead. - const int64_t kRtt = 10; + const TimeDelta kRtt = TimeDelta::Millis(10); rtp_sender_->SetSendingMediaStatus(true); rtp_sender_->SetRtxStatus(kRtxOff); packet_history_->SetStorePacketsStatus( @@ -1321,7 +1318,8 @@ TEST_F(RtpSenderTest, DoesntFecProtectRetransmissions) { packet->set_allow_retransmission(true); packet->set_fec_protect_packet(true); sequencer_->Sequence(*packet); - packet_history_->PutRtpPacket(std::move(packet), start_time_ms); + packet_history_->PutRtpPacket(std::move(packet), + Timestamp::Millis(start_time_ms)); // Re-send packet, the retransmitted packet should not have the FEC protection // flag set. @@ -1329,7 +1327,7 @@ TEST_F(RtpSenderTest, DoesntFecProtectRetransmissions) { EnqueuePackets(ElementsAre(Pointee( Property(&RtpPacketToSend::fec_protect_packet, false))))); - time_controller_.AdvanceTime(TimeDelta::Millis(kRtt)); + time_controller_.AdvanceTime(kRtt); EXPECT_GT(rtp_sender_->ReSendPacket(kSeqNum), 0); } From 80260c226d45ecc35250ee8788daf3130d9bfd44 Mon Sep 17 00:00:00 2001 From: Evan Shrubsole Date: Fri, 4 Mar 2022 15:22:08 +0100 Subject: [PATCH 107/847] Switch VCMRttFilter to use TimeDelta MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Moved into its own GN target * Switched the internal buffer types to absl::InlinedVector as arrays are tricky to use with types that do not have default constructors. * Update fields arnd variables to use style guide. * Use constexpr for formerly const fields. * Adds unit tests. Change-Id: I476ae8491f0f9878c176e7b87a5133942c3d79f7 Bug: webrtc:13756 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253120 Reviewed-by: Erik Språng Reviewed-by: Stefan Holmer Commit-Queue: Evan Shrubsole Cr-Commit-Position: refs/heads/main@{#36133} --- modules/video_coding/BUILD.gn | 17 +- modules/video_coding/jitter_estimator.cc | 8 +- modules/video_coding/rtt_filter.cc | 171 +++++++++++--------- modules/video_coding/rtt_filter.h | 43 ++--- modules/video_coding/rtt_filter_unittest.cc | 105 ++++++++++++ 5 files changed, 238 insertions(+), 106 deletions(-) create mode 100644 modules/video_coding/rtt_filter_unittest.cc diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn index 3ac8751776..830701144c 100644 --- a/modules/video_coding/BUILD.gn +++ b/modules/video_coding/BUILD.gn @@ -202,6 +202,18 @@ rtc_library("timing") { absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } +rtc_library("rtt_filter") { + sources = [ + "rtt_filter.cc", + "rtt_filter.h", + ] + deps = [ "../../api/units:time_delta" ] + absl_deps = [ + "//third_party/abseil-cpp/absl/algorithm:container", + "//third_party/abseil-cpp/absl/container:inlined_vector", + ] +} + rtc_library("video_coding") { visibility = [ "*" ] sources = [ @@ -242,8 +254,6 @@ rtc_library("video_coding") { "rtp_vp8_ref_finder.h", "rtp_vp9_ref_finder.cc", "rtp_vp9_ref_finder.h", - "rtt_filter.cc", - "rtt_filter.h", "timestamp_map.cc", "timestamp_map.h", "unique_timestamp_counter.cc", @@ -259,6 +269,7 @@ rtc_library("video_coding") { ":frame_buffer", ":frame_helpers", ":packet_buffer", + ":rtt_filter", ":timing", ":video_codec_interface", ":video_coding_utility", @@ -1084,6 +1095,7 @@ if (rtc_include_tests) { "rtp_frame_reference_finder_unittest.cc", "rtp_vp8_ref_finder_unittest.cc", "rtp_vp9_ref_finder_unittest.cc", + "rtt_filter_unittest.cc", "session_info_unittest.cc", "test/stream_generator.cc", "test/stream_generator.h", @@ -1119,6 +1131,7 @@ if (rtc_include_tests) { ":h264_packet_buffer", ":nack_requester", ":packet_buffer", + ":rtt_filter", ":simulcast_test_fixture_impl", ":timing", ":video_codec_interface", diff --git a/modules/video_coding/jitter_estimator.cc b/modules/video_coding/jitter_estimator.cc index 38ce35b61e..cf57232d0f 100644 --- a/modules/video_coding/jitter_estimator.cc +++ b/modules/video_coding/jitter_estimator.cc @@ -346,7 +346,7 @@ void VCMJitterEstimator::PostProcessEstimate() { } void VCMJitterEstimator::UpdateRtt(int64_t rttMs) { - _rttFilter.Update(rttMs); + _rttFilter.Update(TimeDelta::Millis(rttMs)); } // Returns the current filtered estimate if available, @@ -364,10 +364,10 @@ int VCMJitterEstimator::GetJitterEstimate( jitterMS = _filterJitterEstimate; if (_nackCount >= _nackLimit) { if (rttMultAddCapMs.has_value()) { - jitterMS += - std::min(_rttFilter.RttMs() * rttMultiplier, rttMultAddCapMs.value()); + jitterMS += std::min(_rttFilter.Rtt().ms() * rttMultiplier, + rttMultAddCapMs.value()); } else { - jitterMS += _rttFilter.RttMs() * rttMultiplier; + jitterMS += _rttFilter.Rtt().ms() * rttMultiplier; } } diff --git a/modules/video_coding/rtt_filter.cc b/modules/video_coding/rtt_filter.cc index 773ff6867e..eaf3b2b301 100644 --- a/modules/video_coding/rtt_filter.cc +++ b/modules/video_coding/rtt_filter.cc @@ -14,137 +14,148 @@ #include #include -#include "modules/video_coding/internal_defines.h" +#include + +#include "absl/algorithm/container.h" +#include "absl/container/inlined_vector.h" +#include "api/units/time_delta.h" namespace webrtc { +namespace { + +constexpr TimeDelta kMaxRtt = TimeDelta::Seconds(3); +constexpr uint32_t kFilterFactorMax = 35; +constexpr double kJumpStddev = 2.5; +constexpr double kDriftStdDev = 3.5; + +} // namespace + VCMRttFilter::VCMRttFilter() - : _filtFactMax(35), - _jumpStdDevs(2.5), - _driftStdDevs(3.5), - _detectThreshold(kMaxDriftJumpCount) { + : avg_rtt_(TimeDelta::Zero()), + var_rtt_(0), + max_rtt_(TimeDelta::Zero()), + jump_buf_(kMaxDriftJumpCount, TimeDelta::Zero()), + drift_buf_(kMaxDriftJumpCount, TimeDelta::Zero()) { Reset(); } void VCMRttFilter::Reset() { - _gotNonZeroUpdate = false; - _avgRtt = 0; - _varRtt = 0; - _maxRtt = 0; - _filtFactCount = 1; - _jumpCount = 0; - _driftCount = 0; - memset(_jumpBuf, 0, sizeof(_jumpBuf)); - memset(_driftBuf, 0, sizeof(_driftBuf)); + got_non_zero_update_ = false; + avg_rtt_ = TimeDelta::Zero(); + var_rtt_ = 0; + max_rtt_ = TimeDelta::Zero(); + filt_fact_count_ = 1; + absl::c_fill(jump_buf_, TimeDelta::Zero()); + absl::c_fill(drift_buf_, TimeDelta::Zero()); } -void VCMRttFilter::Update(int64_t rttMs) { - if (!_gotNonZeroUpdate) { - if (rttMs == 0) { +void VCMRttFilter::Update(TimeDelta rtt) { + if (!got_non_zero_update_) { + if (rtt.IsZero()) { return; } - _gotNonZeroUpdate = true; + got_non_zero_update_ = true; } // Sanity check - if (rttMs > 3000) { - rttMs = 3000; + if (rtt > kMaxRtt) { + rtt = kMaxRtt; } - double filtFactor = 0; - if (_filtFactCount > 1) { - filtFactor = static_cast(_filtFactCount - 1) / _filtFactCount; + double filt_factor = 0; + if (filt_fact_count_ > 1) { + filt_factor = static_cast(filt_fact_count_ - 1) / filt_fact_count_; } - _filtFactCount++; - if (_filtFactCount > _filtFactMax) { - // This prevents filtFactor from going above - // (_filtFactMax - 1) / _filtFactMax, - // e.g., _filtFactMax = 50 => filtFactor = 49/50 = 0.98 - _filtFactCount = _filtFactMax; + filt_fact_count_++; + if (filt_fact_count_ > kFilterFactorMax) { + // This prevents filt_factor from going above + // (_filt_fact_max - 1) / filt_fact_max_, + // e.g., filt_fact_max_ = 50 => filt_factor = 49/50 = 0.98 + filt_fact_count_ = kFilterFactorMax; } - double oldAvg = _avgRtt; - double oldVar = _varRtt; - _avgRtt = filtFactor * _avgRtt + (1 - filtFactor) * rttMs; - _varRtt = filtFactor * _varRtt + - (1 - filtFactor) * (rttMs - _avgRtt) * (rttMs - _avgRtt); - _maxRtt = VCM_MAX(rttMs, _maxRtt); - if (!JumpDetection(rttMs) || !DriftDetection(rttMs)) { + TimeDelta old_avg = avg_rtt_; + int64_t old_var = var_rtt_; + avg_rtt_ = filt_factor * avg_rtt_ + (1 - filt_factor) * rtt; + int64_t delta_ms = (rtt - avg_rtt_).ms(); + var_rtt_ = filt_factor * var_rtt_ + (1 - filt_factor) * (delta_ms * delta_ms); + max_rtt_ = std::max(rtt, max_rtt_); + if (!JumpDetection(rtt) || !DriftDetection(rtt)) { // In some cases we don't want to update the statistics - _avgRtt = oldAvg; - _varRtt = oldVar; + avg_rtt_ = old_avg; + var_rtt_ = old_var; } } -bool VCMRttFilter::JumpDetection(int64_t rttMs) { - double diffFromAvg = _avgRtt - rttMs; - if (fabs(diffFromAvg) > _jumpStdDevs * sqrt(_varRtt)) { - int diffSign = (diffFromAvg >= 0) ? 1 : -1; - int jumpCountSign = (_jumpCount >= 0) ? 1 : -1; - if (diffSign != jumpCountSign) { +bool VCMRttFilter::JumpDetection(TimeDelta rtt) { + TimeDelta diff_from_avg = avg_rtt_ - rtt; + // Unit of var_rtt_ is ms^2. + TimeDelta jump_threshold = TimeDelta::Millis(kJumpStddev * sqrt(var_rtt_)); + if (diff_from_avg.Abs() > jump_threshold) { + bool positive_diff = diff_from_avg >= TimeDelta::Zero(); + if (!jump_buf_.empty() && positive_diff != last_jump_positive_) { // Since the signs differ the samples currently // in the buffer is useless as they represent a // jump in a different direction. - _jumpCount = 0; + jump_buf_.clear(); } - if (abs(_jumpCount) < kMaxDriftJumpCount) { - // Update the buffer used for the short time - // statistics. + if (jump_buf_.size() < kMaxDriftJumpCount) { + // Update the buffer used for the short time statistics. // The sign of the diff is used for updating the counter since // we want to use the same buffer for keeping track of when // the RTT jumps down and up. - _jumpBuf[abs(_jumpCount)] = rttMs; - _jumpCount += diffSign; + jump_buf_.push_back(rtt); + last_jump_positive_ = positive_diff; } - if (abs(_jumpCount) >= _detectThreshold) { + if (jump_buf_.size() >= kMaxDriftJumpCount) { // Detected an RTT jump - ShortRttFilter(_jumpBuf, abs(_jumpCount)); - _filtFactCount = _detectThreshold + 1; - _jumpCount = 0; + ShortRttFilter(jump_buf_); + filt_fact_count_ = kMaxDriftJumpCount + 1; + jump_buf_.clear(); } else { return false; } } else { - _jumpCount = 0; + jump_buf_.clear(); } return true; } -bool VCMRttFilter::DriftDetection(int64_t rttMs) { - if (_maxRtt - _avgRtt > _driftStdDevs * sqrt(_varRtt)) { - if (_driftCount < kMaxDriftJumpCount) { - // Update the buffer used for the short time - // statistics. - _driftBuf[_driftCount] = rttMs; - _driftCount++; +bool VCMRttFilter::DriftDetection(TimeDelta rtt) { + // Unit of sqrt of var_rtt_ is ms. + TimeDelta drift_threshold = TimeDelta::Millis(kDriftStdDev * sqrt(var_rtt_)); + if (max_rtt_ - avg_rtt_ > drift_threshold) { + if (drift_buf_.size() < kMaxDriftJumpCount) { + // Update the buffer used for the short time statistics. + drift_buf_.push_back(rtt); } - if (_driftCount >= _detectThreshold) { + if (drift_buf_.size() >= kMaxDriftJumpCount) { // Detected an RTT drift - ShortRttFilter(_driftBuf, _driftCount); - _filtFactCount = _detectThreshold + 1; - _driftCount = 0; + ShortRttFilter(drift_buf_); + filt_fact_count_ = kMaxDriftJumpCount + 1; + drift_buf_.clear(); } } else { - _driftCount = 0; + drift_buf_.clear(); } return true; } -void VCMRttFilter::ShortRttFilter(int64_t* buf, uint32_t length) { - if (length == 0) { - return; - } - _maxRtt = 0; - _avgRtt = 0; - for (uint32_t i = 0; i < length; i++) { - if (buf[i] > _maxRtt) { - _maxRtt = buf[i]; +void VCMRttFilter::ShortRttFilter(const BufferList& buf) { + RTC_DCHECK_EQ(buf.size(), kMaxDriftJumpCount); + max_rtt_ = TimeDelta::Zero(); + avg_rtt_ = TimeDelta::Zero(); + for (const TimeDelta& rtt : buf) { + if (rtt > max_rtt_) { + max_rtt_ = rtt; } - _avgRtt += buf[i]; + avg_rtt_ += rtt; } - _avgRtt = _avgRtt / static_cast(length); + avg_rtt_ = avg_rtt_ / static_cast(buf.size()); } -int64_t VCMRttFilter::RttMs() const { - return static_cast(_maxRtt + 0.5); +TimeDelta VCMRttFilter::Rtt() const { + return max_rtt_; } + } // namespace webrtc diff --git a/modules/video_coding/rtt_filter.h b/modules/video_coding/rtt_filter.h index bc4f56d2b9..a611aafcb8 100644 --- a/modules/video_coding/rtt_filter.h +++ b/modules/video_coding/rtt_filter.h @@ -13,6 +13,9 @@ #include +#include "absl/container/inlined_vector.h" +#include "api/units/time_delta.h" + namespace webrtc { class VCMRttFilter { @@ -24,41 +27,41 @@ class VCMRttFilter { // Resets the filter. void Reset(); // Updates the filter with a new sample. - void Update(int64_t rttMs); - // A getter function for the current RTT level in ms. - int64_t RttMs() const; + void Update(TimeDelta rtt); + // A getter function for the current RTT level. + TimeDelta Rtt() const; private: // The size of the drift and jump memory buffers // and thus also the detection threshold for these // detectors in number of samples. - enum { kMaxDriftJumpCount = 5 }; + static constexpr int kMaxDriftJumpCount = 5; + using BufferList = absl::InlinedVector; + // Detects RTT jumps by comparing the difference between // samples and average to the standard deviation. // Returns true if the long time statistics should be updated // and false otherwise - bool JumpDetection(int64_t rttMs); + bool JumpDetection(TimeDelta rtt); + // Detects RTT drifts by comparing the difference between // max and average to the standard deviation. // Returns true if the long time statistics should be updated // and false otherwise - bool DriftDetection(int64_t rttMs); + bool DriftDetection(TimeDelta rtt); + // Computes the short time average and maximum of the vector buf. - void ShortRttFilter(int64_t* buf, uint32_t length); + void ShortRttFilter(const BufferList& buf); - bool _gotNonZeroUpdate; - double _avgRtt; - double _varRtt; - int64_t _maxRtt; - uint32_t _filtFactCount; - const uint32_t _filtFactMax; - const double _jumpStdDevs; - const double _driftStdDevs; - int32_t _jumpCount; - int32_t _driftCount; - const int32_t _detectThreshold; - int64_t _jumpBuf[kMaxDriftJumpCount]; - int64_t _driftBuf[kMaxDriftJumpCount]; + bool got_non_zero_update_; + TimeDelta avg_rtt_; + // Variance units are TimeDelta^2. Store as ms^2. + int64_t var_rtt_; + TimeDelta max_rtt_; + uint32_t filt_fact_count_; + bool last_jump_positive_ = false; + BufferList jump_buf_; + BufferList drift_buf_; }; } // namespace webrtc diff --git a/modules/video_coding/rtt_filter_unittest.cc b/modules/video_coding/rtt_filter_unittest.cc new file mode 100644 index 0000000000..15d7d66b83 --- /dev/null +++ b/modules/video_coding/rtt_filter_unittest.cc @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2022 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/video_coding/rtt_filter.h" + +#include "api/units/time_delta.h" +#include "test/gmock.h" +#include "test/gtest.h" + +namespace webrtc { + +TEST(RttFilterTest, RttIsCapped) { + VCMRttFilter rtt_filter; + rtt_filter.Update(TimeDelta::Seconds(500)); + + EXPECT_EQ(rtt_filter.Rtt(), TimeDelta::Seconds(3)); +} + +// If the difference between samples is more than away 2.5 stddev from the mean +// then this is considered a jump. After more than 5 data points at the new +// level, the RTT is reset to the new level. +TEST(RttFilterTest, PositiveJumpDetection) { + VCMRttFilter rtt_filter; + + rtt_filter.Update(TimeDelta::Millis(200)); + rtt_filter.Update(TimeDelta::Millis(200)); + rtt_filter.Update(TimeDelta::Millis(200)); + + // Trigger 5 jumps. + rtt_filter.Update(TimeDelta::Millis(1400)); + rtt_filter.Update(TimeDelta::Millis(1500)); + rtt_filter.Update(TimeDelta::Millis(1600)); + rtt_filter.Update(TimeDelta::Millis(1600)); + + EXPECT_EQ(rtt_filter.Rtt(), TimeDelta::Millis(1600)); + + rtt_filter.Update(TimeDelta::Millis(1600)); + EXPECT_EQ(rtt_filter.Rtt(), TimeDelta::Millis(1600)); +} + +TEST(RttFilterTest, NegativeJumpDetection) { + VCMRttFilter rtt_filter; + + for (int i = 0; i < 10; ++i) + rtt_filter.Update(TimeDelta::Millis(1500)); + + // Trigger 5 negative data points that jump rtt down. + rtt_filter.Update(TimeDelta::Millis(200)); + rtt_filter.Update(TimeDelta::Millis(200)); + rtt_filter.Update(TimeDelta::Millis(200)); + rtt_filter.Update(TimeDelta::Millis(200)); + // Before 5 data points at the new level, max RTT is still 1500. + EXPECT_EQ(rtt_filter.Rtt(), TimeDelta::Millis(1500)); + + rtt_filter.Update(TimeDelta::Millis(300)); + EXPECT_EQ(rtt_filter.Rtt(), TimeDelta::Millis(300)); +} + +TEST(RttFilterTest, JumpsResetByDirectionShift) { + VCMRttFilter rtt_filter; + for (int i = 0; i < 10; ++i) + rtt_filter.Update(TimeDelta::Millis(1500)); + + // Trigger 4 negative jumps, then a positive one. This resets the jump + // detection. + rtt_filter.Update(TimeDelta::Millis(200)); + rtt_filter.Update(TimeDelta::Millis(200)); + rtt_filter.Update(TimeDelta::Millis(200)); + rtt_filter.Update(TimeDelta::Millis(200)); + rtt_filter.Update(TimeDelta::Millis(2000)); + EXPECT_EQ(rtt_filter.Rtt(), TimeDelta::Millis(2000)); + + rtt_filter.Update(TimeDelta::Millis(300)); + EXPECT_EQ(rtt_filter.Rtt(), TimeDelta::Millis(2000)); +} + +// If the difference between the max and average is more than 3.5 stddevs away +// then a drift is detected, and a short filter is applied to find a new max +// rtt. +TEST(RttFilterTest, DriftDetection) { + VCMRttFilter rtt_filter; + + // Descend RTT by 30ms and settle at 700ms RTT. A drift is detected after rtt + // of 700ms is reported around 50 times for these targets. + constexpr TimeDelta kStartRtt = TimeDelta::Millis(1000); + constexpr TimeDelta kDriftTarget = TimeDelta::Millis(700); + constexpr TimeDelta kDelta = TimeDelta::Millis(30); + for (TimeDelta rtt = kStartRtt; rtt >= kDriftTarget; rtt -= kDelta) + rtt_filter.Update(rtt); + + EXPECT_EQ(rtt_filter.Rtt(), kStartRtt); + + for (int i = 0; i < 50; ++i) + rtt_filter.Update(kDriftTarget); + EXPECT_EQ(rtt_filter.Rtt(), kDriftTarget); +} + +} // namespace webrtc From c41d639a0b6cd033192b5e811fe30ac418ab6269 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Fri, 4 Mar 2022 10:02:11 -0800 Subject: [PATCH 108/847] Roll chromium_revision a85d99a8b9..7c62ca054f (977584:977721) Change log: https://chromium.googlesource.com/chromium/src/+log/a85d99a8b9..7c62ca054f Full diff: https://chromium.googlesource.com/chromium/src/+/a85d99a8b9..7c62ca054f Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/0eacf31b03..00a0b1aaa5 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/fbd9d68e74..ab05046d45 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/5298d5dbf1..5436c24ee3 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/34da09f87f..7dccadc8d1 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/780d067922..e5f5727660 * src/third_party/freetype/src: https://chromium.googlesource.com/chromium/src/third_party/freetype2.git/+log/034e5dbf92..335224beee * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/9d1b2dd686..e98f7485e7 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/146011e098..a4f7771c3c DEPS diff: https://chromium.googlesource.com/chromium/src/+/a85d99a8b9..7c62ca054f/DEPS No update to Clang. BUG=None Change-Id: Id61daf21c2e0edd31d2a1016eff051497fa21e2e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253660 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36134} --- DEPS | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/DEPS b/DEPS index e3a1628d8b..19dfa7ebb3 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': 'a85d99a8b918ce933b4626fb114368084e78f6af', + 'chromium_revision': '7c62ca054f04b694b3270632780f05a212e92828', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@0eacf31b03f7240b7bf2f771404959885dc1a264', + 'https://chromium.googlesource.com/chromium/src/base@00a0b1aaa5b1ec7244ce8e8eb2bcd0b86ff94bc7', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@fbd9d68e74e48207ee56e3e7eb03f67ada32018b', + 'https://chromium.googlesource.com/chromium/src/build@ab05046d453d6fea1dd10053c4af4843bc60ca92', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@113dd1badbcbffea108a8c95ac7c89c22bfd25f3', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@5298d5dbf1d22694ff6e7a1118dd7d5fd5177b60', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@5436c24ee3b3d955014a744677b281e8e426e7cc', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@34da09f87f2f25e97b463eb1ac550297d8f588d2', + 'https://chromium.googlesource.com/chromium/src/testing@7dccadc8d1fd7829bc1ae099c8ea1e2b3fff1702', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@780d067922d63686a8e0aa92164906ace2112ce6', + 'https://chromium.googlesource.com/chromium/src/third_party@e5f5727660dca299555c87f5143e9d7eb10b0707', 'src/buildtools/linux64': { 'packages': [ @@ -162,7 +162,7 @@ deps = { 'condition': 'checkout_linux', }, 'src/third_party/freetype/src': - 'https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@034e5dbf92ea3a7ea7c9322e47a3a50ff23f7b55', + 'https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@335224beee2e72caab4ae56b76d6eb72001c3753', 'src/third_party/harfbuzz-ng/src': 'https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git@0acf466c44143de2e9b9cc0375cb25ec67cb132f', 'src/third_party/google_benchmark/src': { @@ -228,7 +228,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@9d1b2dd68697e0b5d912c18674cadd1c16ef5790', + 'https://android.googlesource.com/platform/external/perfetto.git@e98f7485e72d619259589260c004588b8437fc7c', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@146011e09857794de599e17d4cd2ad84f4e0c8de', + 'https://chromium.googlesource.com/chromium/src/tools@a4f7771c3cdf2793aff3b4c1b731115672a3d787', 'src/third_party/accessibility_test_framework': { 'packages': [ From 0bb4d864c94b9af836c3d3dff77d35fad90aa786 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Fri, 4 Mar 2022 14:02:11 -0800 Subject: [PATCH 109/847] Roll chromium_revision 7c62ca054f..506c2577bc (977721:977835) Change log: https://chromium.googlesource.com/chromium/src/+log/7c62ca054f..506c2577bc Full diff: https://chromium.googlesource.com/chromium/src/+/7c62ca054f..506c2577bc Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/00a0b1aaa5..bcd37851f4 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/ab05046d45..bba692af19 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/5436c24ee3..cabf0cba2c * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/7dccadc8d1..b5ba3855c4 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/e5f5727660..ad0b57e097 * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/10d8471fc7..e87767edb2 * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/df1a3c0bb8..ca3aae0014 * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/e98f7485e7..1badc020b3 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/a4f7771c3c..c65b31ce64 DEPS diff: https://chromium.googlesource.com/chromium/src/+/7c62ca054f..506c2577bc/DEPS No update to Clang. BUG=None Change-Id: I15ca798d3f235a78fa56ba6e5e10e4b8a4a2062e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253681 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36135} --- DEPS | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/DEPS b/DEPS index 19dfa7ebb3..d1d476a68f 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': '7c62ca054f04b694b3270632780f05a212e92828', + 'chromium_revision': '506c2577bc5967f3ce93b3ee84fd3baea04f206e', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@00a0b1aaa5b1ec7244ce8e8eb2bcd0b86ff94bc7', + 'https://chromium.googlesource.com/chromium/src/base@bcd37851f49b509310bd078a547dbd68167cff5e', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@ab05046d453d6fea1dd10053c4af4843bc60ca92', + 'https://chromium.googlesource.com/chromium/src/build@bba692af19c293ffd1f7c1764d30ccd424d79f8d', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@113dd1badbcbffea108a8c95ac7c89c22bfd25f3', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@5436c24ee3b3d955014a744677b281e8e426e7cc', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@cabf0cba2c6ef3436c901a8a5c8cbd7dd4930de5', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@7dccadc8d1fd7829bc1ae099c8ea1e2b3fff1702', + 'https://chromium.googlesource.com/chromium/src/testing@b5ba3855c471aee0a4a61fb284dfa7a607cc5dd4', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@e5f5727660dca299555c87f5143e9d7eb10b0707', + 'https://chromium.googlesource.com/chromium/src/third_party@ad0b57e097c03ca324d0bccded62fa087cc17275', 'src/buildtools/linux64': { 'packages': [ @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@10d8471fc78e1b76fac51b2cc07f5086fe92a2f2', + 'https://chromium.googlesource.com/catapult.git@e87767edb21947a28ae24105709c32ad628e1345', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@df1a3c0bb803ef47515f26a65d7dfba924f7853e', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@ca3aae0014011dad4c60ed0a39defa00d0189114', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -228,7 +228,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@e98f7485e72d619259589260c004588b8437fc7c', + 'https://android.googlesource.com/platform/external/perfetto.git@1badc020b35ebe45f738c1ddb21e79bb87e56273', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@a4f7771c3cdf2793aff3b4c1b731115672a3d787', + 'https://chromium.googlesource.com/chromium/src/tools@c65b31ce646ed2ff478ba42b4dcafb90466f53f8', 'src/third_party/accessibility_test_framework': { 'packages': [ From bd56fcbf79d2884aafb838ce084022e3afdd77a2 Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Fri, 4 Mar 2022 20:03:17 -0800 Subject: [PATCH 110/847] Update WebRTC code version (2022-03-05T04:03:15). Bug: None Change-Id: I2b1ab55010e744c483c706d4a2a796a926099015 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253684 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36136} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index 041c62b042..2ca69e307b 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 2022-03-04T04:05:35"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-03-05T04:03:15"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From ce414e23d7d9b435be5982b0c1d1642e14de3933 Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Sat, 5 Mar 2022 20:05:26 -0800 Subject: [PATCH 111/847] Update WebRTC code version (2022-03-06T04:05:24). Bug: None Change-Id: Iaf722f40911fe0e64a9b426f518eff2c9b68a18d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253730 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36137} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index 2ca69e307b..e7ef788038 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 2022-03-05T04:03:15"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-03-06T04:05:24"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From 4abffda39fe98a625cd467340903bca520824ba5 Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Sun, 6 Mar 2022 20:04:34 -0800 Subject: [PATCH 112/847] Update WebRTC code version (2022-03-07T04:04:33). Bug: None Change-Id: Id479c4344bcd5d480df73ffce039f7877249de86 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253761 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36138} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index e7ef788038..e5f326b777 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 2022-03-06T04:05:24"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-03-07T04:04:33"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From 7befe8e5e450f750b076f969f6ac56d17cd315db Mon Sep 17 00:00:00 2001 From: Jeremy Leconte Date: Mon, 7 Mar 2022 08:55:52 +0100 Subject: [PATCH 113/847] Remove reference to an old branch. Bug: webrtc:13788 Change-Id: I628b27f3b26aaaf77824cdadca0089e43f0e976b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253781 Reviewed-by: Mirko Bonadei Commit-Queue: Jeremy Leconte Cr-Commit-Position: refs/heads/main@{#36139} --- tools_webrtc/version_updater/update_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools_webrtc/version_updater/update_version.py b/tools_webrtc/version_updater/update_version.py index 83e7ce8061..2a693cd630 100644 --- a/tools_webrtc/version_updater/update_version.py +++ b/tools_webrtc/version_updater/update_version.py @@ -36,7 +36,7 @@ def FindSrcDirPath(): def _RemovePreviousUpdateBranch(): active_branch, branches = _GetBranches() if active_branch == UPDATE_BRANCH_NAME: - active_branch = 'master' + active_branch = 'main' if UPDATE_BRANCH_NAME in branches: logging.info('Removing previous update branch (%s)', UPDATE_BRANCH_NAME) subprocess.check_call(['git', 'checkout', active_branch]) From 0f50cc284949f225f663408e7d467f39d549d3dc Mon Sep 17 00:00:00 2001 From: Xavier Lepaul Date: Mon, 7 Mar 2022 10:23:23 +0100 Subject: [PATCH 114/847] Remove checks for SDK <= 21 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit WebRTC’s minSdk is 21, so all those checks are dead code. Change-Id: I26497fd92259b66d9e5ac6afbb393adf4d904c77 Bug: webrtc:13780 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253124 Reviewed-by: Henrik Andreassson Reviewed-by: Linus Nilsson Commit-Queue: Xavier Lepaul‎ Cr-Commit-Position: refs/heads/main@{#36140} --- .../appspot/apprtc/AppRTCProximitySensor.java | 14 ++--- .../src/org/appspot/apprtc/CallActivity.java | 11 +--- .../src/org/appspot/apprtc/CpuMonitor.java | 4 +- .../apprtc/test/PeerConnectionClientTest.java | 20 ------ .../voiceengine/WebRtcAudioEffects.java | 11 ---- .../voiceengine/WebRtcAudioManager.java | 8 +-- .../webrtc/voiceengine/WebRtcAudioTrack.java | 61 ++++--------------- .../webrtc/voiceengine/WebRtcAudioUtils.java | 9 +-- .../api/org/webrtc/Camera2Capturer.java | 2 - .../api/org/webrtc/Camera2Enumerator.java | 6 -- sdk/android/api/org/webrtc/EglBase.java | 6 +- .../webrtc/HardwareVideoEncoderFactory.java | 35 +++-------- .../api/org/webrtc/ScreenCapturerAndroid.java | 4 -- .../api/org/webrtc/SurfaceTextureHelper.java | 16 +---- .../src/org/webrtc/Camera2CapturerTest.java | 2 - .../org/webrtc/HardwareVideoEncoderTest.java | 2 - .../src/org/webrtc/NetworkMonitorTest.java | 12 ++-- .../src/java/org/webrtc/Camera2Session.java | 2 - .../src/java/org/webrtc/EglBase14Impl.java | 18 +----- .../java/org/webrtc/HardwareVideoEncoder.java | 5 -- .../src/java/org/webrtc/MediaCodecUtils.java | 11 +--- .../webrtc/MediaCodecVideoDecoderFactory.java | 9 +-- .../webrtc/MediaCodecWrapperFactoryImpl.java | 3 - .../org/webrtc/audio/WebRtcAudioEffects.java | 7 --- .../org/webrtc/audio/WebRtcAudioManager.java | 8 +-- .../org/webrtc/audio/WebRtcAudioTrack.java | 53 +++------------- .../org/webrtc/audio/WebRtcAudioUtils.java | 9 +-- 27 files changed, 54 insertions(+), 294 deletions(-) diff --git a/examples/androidapp/src/org/appspot/apprtc/AppRTCProximitySensor.java b/examples/androidapp/src/org/appspot/apprtc/AppRTCProximitySensor.java index 5c73b4395c..604e2863d9 100644 --- a/examples/androidapp/src/org/appspot/apprtc/AppRTCProximitySensor.java +++ b/examples/androidapp/src/org/appspot/apprtc/AppRTCProximitySensor.java @@ -149,16 +149,10 @@ private void logProximitySensorInfo() { info.append(", resolution: ").append(proximitySensor.getResolution()); info.append(", max range: ").append(proximitySensor.getMaximumRange()); info.append(", min delay: ").append(proximitySensor.getMinDelay()); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { - // Added in API level 20. - info.append(", type: ").append(proximitySensor.getStringType()); - } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - // Added in API level 21. - info.append(", max delay: ").append(proximitySensor.getMaxDelay()); - info.append(", reporting mode: ").append(proximitySensor.getReportingMode()); - info.append(", isWakeUpSensor: ").append(proximitySensor.isWakeUpSensor()); - } + info.append(", type: ").append(proximitySensor.getStringType()); + info.append(", max delay: ").append(proximitySensor.getMaxDelay()); + info.append(", reporting mode: ").append(proximitySensor.getReportingMode()); + info.append(", isWakeUpSensor: ").append(proximitySensor.isWakeUpSensor()); Log.d(TAG, info.toString()); } } diff --git a/examples/androidapp/src/org/appspot/apprtc/CallActivity.java b/examples/androidapp/src/org/appspot/apprtc/CallActivity.java index 2da2073e2b..eb5ee8289e 100644 --- a/examples/androidapp/src/org/appspot/apprtc/CallActivity.java +++ b/examples/androidapp/src/org/appspot/apprtc/CallActivity.java @@ -384,7 +384,6 @@ public void run() { } } - @TargetApi(17) private DisplayMetrics getDisplayMetrics() { DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager windowManager = @@ -393,16 +392,11 @@ private DisplayMetrics getDisplayMetrics() { return displayMetrics; } - @TargetApi(19) private static int getSystemUiVisibility() { - int flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - flags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; - } - return flags; + return View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; } - @TargetApi(21) private void startScreenCapture() { MediaProjectionManager mediaProjectionManager = (MediaProjectionManager) getApplication().getSystemService( @@ -460,7 +454,6 @@ private boolean captureToTexture() { return null; } - @TargetApi(21) private @Nullable VideoCapturer createScreenCapturer() { if (mediaProjectionPermissionResultCode != Activity.RESULT_OK) { reportError("User didn't give permission to capture the screen."); diff --git a/examples/androidapp/src/org/appspot/apprtc/CpuMonitor.java b/examples/androidapp/src/org/appspot/apprtc/CpuMonitor.java index dd51ab2561..1c64621864 100644 --- a/examples/androidapp/src/org/appspot/apprtc/CpuMonitor.java +++ b/examples/androidapp/src/org/appspot/apprtc/CpuMonitor.java @@ -73,7 +73,6 @@ * correct value, and then returns to back to correct reading. Both when * jumping up and back down we might create faulty CPU load readings. */ -@TargetApi(Build.VERSION_CODES.KITKAT) class CpuMonitor { private static final String TAG = "CpuMonitor"; private static final int MOVING_AVERAGE_SAMPLES = 5; @@ -159,8 +158,7 @@ public double getAverage() { } public static boolean isSupported() { - return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT - && Build.VERSION.SDK_INT < Build.VERSION_CODES.N; + return Build.VERSION.SDK_INT < Build.VERSION_CODES.N; } public CpuMonitor(Context context) { diff --git a/examples/androidtests/src/org/appspot/apprtc/test/PeerConnectionClientTest.java b/examples/androidtests/src/org/appspot/apprtc/test/PeerConnectionClientTest.java index ac3fb23a6e..051d7379bd 100644 --- a/examples/androidtests/src/org/appspot/apprtc/test/PeerConnectionClientTest.java +++ b/examples/androidtests/src/org/appspot/apprtc/test/PeerConnectionClientTest.java @@ -453,10 +453,6 @@ public void testLoopbackH264() throws InterruptedException { @Test @SmallTest public void testLoopbackVp8DecodeToTexture() throws InterruptedException { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - Log.i(TAG, "Decode to textures is not supported, requires SDK version 19."); - return; - } doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_VP8), createCameraCapturer(false /* captureToTexture */), true /* decodeToTexture */); } @@ -464,10 +460,6 @@ public void testLoopbackVp8DecodeToTexture() throws InterruptedException { @Test @SmallTest public void testLoopbackVp9DecodeToTexture() throws InterruptedException { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - Log.i(TAG, "Decode to textures is not supported, requires SDK version 19."); - return; - } doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_VP9), createCameraCapturer(false /* captureToTexture */), true /* decodeToTexture */); } @@ -475,10 +467,6 @@ public void testLoopbackVp9DecodeToTexture() throws InterruptedException { @Test @SmallTest public void testLoopbackH264DecodeToTexture() throws InterruptedException { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - Log.i(TAG, "Decode to textures is not supported, requires SDK version 19."); - return; - } doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_H264), createCameraCapturer(false /* captureToTexture */), true /* decodeToTexture */); } @@ -486,10 +474,6 @@ public void testLoopbackH264DecodeToTexture() throws InterruptedException { @Test @SmallTest public void testLoopbackVp8CaptureToTexture() throws InterruptedException { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - Log.i(TAG, "Encode to textures is not supported. Requires SDK version 19"); - return; - } doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_VP8), createCameraCapturer(true /* captureToTexture */), true /* decodeToTexture */); } @@ -497,10 +481,6 @@ public void testLoopbackVp8CaptureToTexture() throws InterruptedException { @Test @SmallTest public void testLoopbackH264CaptureToTexture() throws InterruptedException { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - Log.i(TAG, "Encode to textures is not supported. Requires KITKAT"); - return; - } doLoopbackTest(createParametersForVideoCall(VIDEO_CODEC_H264), createCameraCapturer(true /* captureToTexture */), true /* decodeToTexture */); } diff --git a/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioEffects.java b/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioEffects.java index 11ed669c3e..92f1c93524 100644 --- a/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioEffects.java +++ b/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioEffects.java @@ -95,8 +95,6 @@ public static boolean isNoiseSuppressorBlacklisted() { // Returns true if the platform AEC should be excluded based on its UUID. // AudioEffect.queryEffects() can throw IllegalStateException. private static boolean isAcousticEchoCancelerExcludedByUUID() { - if (Build.VERSION.SDK_INT < 18) - return false; for (Descriptor d : getAvailableEffects()) { if (d.type.equals(AudioEffect.EFFECT_TYPE_AEC) && d.uuid.equals(AOSP_ACOUSTIC_ECHO_CANCELER)) { @@ -109,8 +107,6 @@ private static boolean isAcousticEchoCancelerExcludedByUUID() { // Returns true if the platform NS should be excluded based on its UUID. // AudioEffect.queryEffects() can throw IllegalStateException. private static boolean isNoiseSuppressorExcludedByUUID() { - if (Build.VERSION.SDK_INT < 18) - return false; for (Descriptor d : getAvailableEffects()) { if (d.type.equals(AudioEffect.EFFECT_TYPE_NS) && d.uuid.equals(AOSP_NOISE_SUPPRESSOR)) { return true; @@ -121,15 +117,11 @@ private static boolean isNoiseSuppressorExcludedByUUID() { // Returns true if the device supports Acoustic Echo Cancellation (AEC). private static boolean isAcousticEchoCancelerEffectAvailable() { - if (Build.VERSION.SDK_INT < 18) - return false; return isEffectTypeAvailable(AudioEffect.EFFECT_TYPE_AEC); } // Returns true if the device supports Noise Suppression (NS). private static boolean isNoiseSuppressorEffectAvailable() { - if (Build.VERSION.SDK_INT < 18) - return false; return isEffectTypeAvailable(AudioEffect.EFFECT_TYPE_NS); } @@ -277,9 +269,6 @@ public void release() { // As an example: Samsung Galaxy S6 includes an AGC in the descriptor but // AutomaticGainControl.isAvailable() returns false. private boolean effectTypeIsVoIP(UUID type) { - if (Build.VERSION.SDK_INT < 18) - return false; - return (AudioEffect.EFFECT_TYPE_AEC.equals(type) && isAcousticEchoCancelerSupported()) || (AudioEffect.EFFECT_TYPE_NS.equals(type) && isNoiseSuppressorSupported()); } diff --git a/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java b/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java index b057c3a454..43c416f5b1 100644 --- a/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java +++ b/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java @@ -258,7 +258,7 @@ public boolean isLowLatencyInputSupported() { // as well. The NDK doc states that: "As of API level 21, lower latency // audio input is supported on select devices. To take advantage of this // feature, first confirm that lower latency output is available". - return Build.VERSION.SDK_INT >= 21 && isLowLatencyOutputSupported(); + return isLowLatencyOutputSupported(); } // Returns true if the device has professional audio level of functionality @@ -301,9 +301,6 @@ private int getNativeOutputSampleRate() { } private int getSampleRateForApiLevel() { - if (Build.VERSION.SDK_INT < 17) { - return WebRtcAudioUtils.getDefaultSampleRateHz(); - } String sampleRateString = audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE); return (sampleRateString == null) ? WebRtcAudioUtils.getDefaultSampleRateHz() : Integer.parseInt(sampleRateString); @@ -312,9 +309,6 @@ private int getSampleRateForApiLevel() { // Returns the native output buffer size for low-latency output streams. private int getLowLatencyOutputFramesPerBuffer() { assertTrue(isLowLatencyOutputSupported()); - if (Build.VERSION.SDK_INT < 17) { - return DEFAULT_FRAME_PER_BUFFER; - } String framesPerBuffer = audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER); return framesPerBuffer == null ? DEFAULT_FRAME_PER_BUFFER : Integer.parseInt(framesPerBuffer); diff --git a/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java b/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java index e3988e1a36..3e1875c3d6 100644 --- a/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java +++ b/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java @@ -10,7 +10,6 @@ package org.webrtc.voiceengine; -import android.annotation.TargetApi; import android.content.Context; import android.media.AudioAttributes; import android.media.AudioFormat; @@ -46,7 +45,7 @@ public class WebRtcAudioTrack { // By default, WebRTC creates audio tracks with a usage attribute // corresponding to voice communications, such as telephony or VoIP. - private static final int DEFAULT_USAGE = getDefaultUsageAttribute(); + private static final int DEFAULT_USAGE = AudioAttributes.USAGE_VOICE_COMMUNICATION; private static int usageAttribute = DEFAULT_USAGE; // This method overrides the default usage attribute and allows the user @@ -60,15 +59,6 @@ public static synchronized void setAudioTrackUsageAttribute(int usage) { usageAttribute = usage; } - private static int getDefaultUsageAttribute() { - if (Build.VERSION.SDK_INT >= 21) { - return AudioAttributes.USAGE_VOICE_COMMUNICATION; - } else { - // Not used on SDKs lower than 21. - return 0; - } - } - private final long nativeAudioTrack; private final AudioManager audioManager; private final ThreadUtils.ThreadChecker threadChecker = new ThreadUtils.ThreadChecker(); @@ -154,7 +144,7 @@ public void run() { byteBuffer.put(emptyBytes); byteBuffer.position(0); } - int bytesWritten = writeBytes(audioTrack, byteBuffer, sizeInBytes); + int bytesWritten = audioTrack.write(byteBuffer, sizeInBytes, AudioTrack.WRITE_BLOCKING); if (bytesWritten != sizeInBytes) { Logging.e(TAG, "AudioTrack.write played invalid number of bytes: " + bytesWritten); // If a write() returns a negative value, an error has occurred. @@ -188,14 +178,6 @@ public void run() { } } - private int writeBytes(AudioTrack audioTrack, ByteBuffer byteBuffer, int sizeInBytes) { - if (Build.VERSION.SDK_INT >= 21) { - return audioTrack.write(byteBuffer, sizeInBytes, AudioTrack.WRITE_BLOCKING); - } else { - return audioTrack.write(byteBuffer.array(), byteBuffer.arrayOffset(), sizeInBytes); - } - } - // Stops the inner thread loop which results in calling AudioTrack.stop(). // Does not block the calling thread. public void stopThread() { @@ -257,19 +239,12 @@ private int initPlayout(int sampleRate, int channels, double bufferSizeFactor) { // Create an AudioTrack object and initialize its associated audio buffer. // The size of this buffer determines how long an AudioTrack can play // before running out of data. - if (Build.VERSION.SDK_INT >= 21) { - // If we are on API level 21 or higher, it is possible to use a special AudioTrack - // constructor that uses AudioAttributes and AudioFormat as input. It allows us to - // supersede the notion of stream types for defining the behavior of audio playback, - // and to allow certain platforms or routing policies to use this information for more - // refined volume or routing decisions. - audioTrack = createAudioTrackOnLollipopOrHigher( - sampleRate, channelConfig, minBufferSizeInBytes); - } else { - // Use default constructor for API levels below 21. - audioTrack = - createAudioTrackOnLowerThanLollipop(sampleRate, channelConfig, minBufferSizeInBytes); - } + // As we are on API level 21 or higher, it is possible to use a special AudioTrack + // constructor that uses AudioAttributes and AudioFormat as input. It allows us to + // supersede the notion of stream types for defining the behavior of audio playback, + // and to allow certain platforms or routing policies to use this information for more + // refined volume or routing decisions. + audioTrack = createAudioTrack(sampleRate, channelConfig, minBufferSizeInBytes); } catch (IllegalArgumentException e) { reportWebRtcAudioTrackInitError(e.getMessage()); releaseAudioResources(); @@ -353,7 +328,7 @@ private boolean setStreamVolume(int volume) { threadChecker.checkIsOnValidThread(); Logging.d(TAG, "setStreamVolume(" + volume + ")"); assertTrue(audioManager != null); - if (isVolumeFixed()) { + if (audioManager.isVolumeFixed()) { Logging.e(TAG, "The device implements a fixed volume policy."); return false; } @@ -361,12 +336,6 @@ private boolean setStreamVolume(int volume) { return true; } - private boolean isVolumeFixed() { - if (Build.VERSION.SDK_INT < 21) - return false; - return audioManager.isVolumeFixed(); - } - /** Get current volume level for a phone call audio stream. */ private int getStreamVolume() { threadChecker.checkIsOnValidThread(); @@ -387,10 +356,9 @@ private void logMainParameters() { // Creates and AudioTrack instance using AudioAttributes and AudioFormat as input. // It allows certain platforms or routing policies to use this information for more // refined volume or routing decisions. - @TargetApi(21) - private static AudioTrack createAudioTrackOnLollipopOrHigher( + private static AudioTrack createAudioTrack( int sampleRateInHz, int channelConfig, int bufferSizeInBytes) { - Logging.d(TAG, "createAudioTrackOnLollipopOrHigher"); + Logging.d(TAG, "createAudioTrack"); // TODO(henrika): use setPerformanceMode(int) with PERFORMANCE_MODE_LOW_LATENCY to control // performance when Android O is supported. Add some logging in the mean time. final int nativeOutputSampleRate = @@ -418,13 +386,6 @@ private static AudioTrack createAudioTrackOnLollipopOrHigher( AudioManager.AUDIO_SESSION_ID_GENERATE); } - @SuppressWarnings("deprecation") // Deprecated in API level 25. - private static AudioTrack createAudioTrackOnLowerThanLollipop( - int sampleRateInHz, int channelConfig, int bufferSizeInBytes) { - return new AudioTrack(AudioManager.STREAM_VOICE_CALL, sampleRateInHz, channelConfig, - AudioFormat.ENCODING_PCM_16BIT, bufferSizeInBytes, AudioTrack.MODE_STREAM); - } - private void logBufferSizeInFrames() { if (Build.VERSION.SDK_INT >= 23) { Logging.d(TAG, "AudioTrack: " diff --git a/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioUtils.java b/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioUtils.java index 61cab58f07..0472114297 100644 --- a/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioUtils.java +++ b/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioUtils.java @@ -214,13 +214,6 @@ private static void logAudioStateBasic(String tag, AudioManager audioManager) { + "BT SCO: " + audioManager.isBluetoothScoOn()); } - private static boolean isVolumeFixed(AudioManager audioManager) { - if (Build.VERSION.SDK_INT < 21) { - return false; - } - return audioManager.isVolumeFixed(); - } - // Adds volume information for all possible stream types. private static void logAudioStateVolume(String tag, AudioManager audioManager) { final int[] streams = { @@ -233,7 +226,7 @@ private static void logAudioStateVolume(String tag, AudioManager audioManager) { }; Logging.d(tag, "Audio State: "); // Some devices may not have volume controls and might use a fixed volume. - boolean fixedVolume = isVolumeFixed(audioManager); + boolean fixedVolume = audioManager.isVolumeFixed(); Logging.d(tag, " fixed volume=" + fixedVolume); if (!fixedVolume) { for (int stream : streams) { diff --git a/sdk/android/api/org/webrtc/Camera2Capturer.java b/sdk/android/api/org/webrtc/Camera2Capturer.java index 3c1d477c3a..c4becf4819 100644 --- a/sdk/android/api/org/webrtc/Camera2Capturer.java +++ b/sdk/android/api/org/webrtc/Camera2Capturer.java @@ -10,12 +10,10 @@ package org.webrtc; -import android.annotation.TargetApi; import android.content.Context; import android.hardware.camera2.CameraManager; import androidx.annotation.Nullable; -@TargetApi(21) public class Camera2Capturer extends CameraCapturer { private final Context context; @Nullable private final CameraManager cameraManager; diff --git a/sdk/android/api/org/webrtc/Camera2Enumerator.java b/sdk/android/api/org/webrtc/Camera2Enumerator.java index 961ab753aa..8a0ce4a7bc 100644 --- a/sdk/android/api/org/webrtc/Camera2Enumerator.java +++ b/sdk/android/api/org/webrtc/Camera2Enumerator.java @@ -10,7 +10,6 @@ package org.webrtc; -import android.annotation.TargetApi; import android.content.Context; import android.graphics.Rect; import android.graphics.SurfaceTexture; @@ -30,7 +29,6 @@ import java.util.Map; import org.webrtc.CameraEnumerationAndroid.CaptureFormat; -@TargetApi(21) public class Camera2Enumerator implements CameraEnumerator { private final static String TAG = "Camera2Enumerator"; private final static double NANO_SECONDS_PER_SECOND = 1.0e9; @@ -107,10 +105,6 @@ public CameraVideoCapturer createCapturer( * Checks if API is supported and all cameras have better than legacy support. */ public static boolean isSupported(Context context) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - return false; - } - CameraManager cameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE); try { String[] cameraIds = cameraManager.getCameraIdList(); diff --git a/sdk/android/api/org/webrtc/EglBase.java b/sdk/android/api/org/webrtc/EglBase.java index 763f4e5a72..64771d004a 100644 --- a/sdk/android/api/org/webrtc/EglBase.java +++ b/sdk/android/api/org/webrtc/EglBase.java @@ -147,13 +147,11 @@ static int getOpenGlesVersionFromConfig(int[] configAttributes) { /** * Create a new context with the specified config attributes, sharing data with `sharedContext`. - * If `sharedContext` is null, a root context is created. This function will try to create an EGL - * 1.4 context if possible, and an EGL 1.0 context otherwise. + * If `sharedContext` is null, a root EGL 1.4 context is created. */ public static EglBase create(@Nullable Context sharedContext, int[] configAttributes) { if (sharedContext == null) { - return EglBase14Impl.isEGL14Supported() ? createEgl14(configAttributes) - : createEgl10(configAttributes); + return createEgl14(configAttributes); } else if (sharedContext instanceof EglBase14.Context) { return createEgl14((EglBase14.Context) sharedContext, configAttributes); } else if (sharedContext instanceof EglBase10.Context) { diff --git a/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java b/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java index 2454182923..b48a39aaa6 100644 --- a/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java +++ b/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java @@ -94,11 +94,6 @@ public HardwareVideoEncoderFactory(boolean enableIntelVp8Encoder, boolean enable @Nullable @Override public VideoEncoder createEncoder(VideoCodecInfo input) { - // HW encoding is not supported below Android Kitkat. - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - return null; - } - VideoCodecMimeType type = VideoCodecMimeType.valueOf(input.getName()); MediaCodecInfo info = findCodecForType(type); @@ -135,11 +130,6 @@ public VideoEncoder createEncoder(VideoCodecInfo input) { @Override public VideoCodecInfo[] getSupportedCodecs() { - // HW encoding is not supported below Android Kitkat. - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - return new VideoCodecInfo[0]; - } - List supportedCodecInfos = new ArrayList(); // Generate a list of supported codecs in order of preference: // VP8, VP9, H264 (high profile), H264 (baseline profile) and AV1. @@ -219,13 +209,12 @@ private boolean isHardwareSupportedInCurrentSdk(MediaCodecInfo info, VideoCodecM private boolean isHardwareSupportedInCurrentSdkVp8(MediaCodecInfo info) { String name = info.getName(); - // QCOM Vp8 encoder is supported in KITKAT or later. - return (name.startsWith(QCOM_PREFIX) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) + // QCOM Vp8 encoder is always supported. + return name.startsWith(QCOM_PREFIX) // Exynos VP8 encoder is supported in M or later. || (name.startsWith(EXYNOS_PREFIX) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) - // Intel Vp8 encoder is supported in LOLLIPOP or later, with the intel encoder enabled. - || (name.startsWith(INTEL_PREFIX) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP - && enableIntelVp8Encoder); + // Intel Vp8 encoder is always supported, with the intel encoder enabled. + || (name.startsWith(INTEL_PREFIX) && enableIntelVp8Encoder); } private boolean isHardwareSupportedInCurrentSdkVp9(MediaCodecInfo info) { @@ -241,11 +230,8 @@ private boolean isHardwareSupportedInCurrentSdkH264(MediaCodecInfo info) { return false; } String name = info.getName(); - // QCOM H264 encoder is supported in KITKAT or later. - return (name.startsWith(QCOM_PREFIX) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) - // Exynos H264 encoder is supported in LOLLIPOP or later. - || (name.startsWith(EXYNOS_PREFIX) - && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP); + // QCOM and Exynos H264 encoders are always supported. + return name.startsWith(QCOM_PREFIX) || name.startsWith(EXYNOS_PREFIX); } private boolean isMediaCodecAllowed(MediaCodecInfo info) { @@ -257,14 +243,13 @@ private boolean isMediaCodecAllowed(MediaCodecInfo info) { private int getForcedKeyFrameIntervalMs(VideoCodecMimeType type, String codecName) { if (type == VideoCodecMimeType.VP8 && codecName.startsWith(QCOM_PREFIX)) { - if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP - || Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP_MR1) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { return QCOM_VP8_KEY_FRAME_INTERVAL_ANDROID_L_MS; - } else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) { + } + if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) { return QCOM_VP8_KEY_FRAME_INTERVAL_ANDROID_M_MS; - } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) { - return QCOM_VP8_KEY_FRAME_INTERVAL_ANDROID_N_MS; } + return QCOM_VP8_KEY_FRAME_INTERVAL_ANDROID_N_MS; } // Other codecs don't need key frame forcing. return 0; diff --git a/sdk/android/api/org/webrtc/ScreenCapturerAndroid.java b/sdk/android/api/org/webrtc/ScreenCapturerAndroid.java index adcb1149d9..231d507155 100644 --- a/sdk/android/api/org/webrtc/ScreenCapturerAndroid.java +++ b/sdk/android/api/org/webrtc/ScreenCapturerAndroid.java @@ -10,7 +10,6 @@ package org.webrtc; -import android.annotation.TargetApi; import android.app.Activity; import android.content.Context; import android.content.Intent; @@ -31,10 +30,7 @@ * place on the HandlerThread of the given {@code SurfaceTextureHelper}. When done with each frame, * the native code returns the buffer to the {@code SurfaceTextureHelper} to be used for new * frames. At any time, at most one frame is being processed. - * - * @note This class is only supported on Android Lollipop and above. */ -@TargetApi(21) public class ScreenCapturerAndroid implements VideoCapturer, VideoSink { private static final int DISPLAY_FLAGS = DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC | DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION; diff --git a/sdk/android/api/org/webrtc/SurfaceTextureHelper.java b/sdk/android/api/org/webrtc/SurfaceTextureHelper.java index e186f9a3c1..3ea22736ea 100644 --- a/sdk/android/api/org/webrtc/SurfaceTextureHelper.java +++ b/sdk/android/api/org/webrtc/SurfaceTextureHelper.java @@ -198,7 +198,7 @@ private SurfaceTextureHelper(Context sharedContext, Handler handler, boolean ali oesTextureId = GlUtil.generateTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES); surfaceTexture = new SurfaceTexture(oesTextureId); - setOnFrameAvailableListener(surfaceTexture, (SurfaceTexture st) -> { + surfaceTexture.setOnFrameAvailableListener(st -> { if (hasPendingTexture) { Logging.d(TAG, "A frame is already pending, dropping frame."); } @@ -208,20 +208,6 @@ private SurfaceTextureHelper(Context sharedContext, Handler handler, boolean ali }, handler); } - @TargetApi(21) - private static void setOnFrameAvailableListener(SurfaceTexture surfaceTexture, - SurfaceTexture.OnFrameAvailableListener listener, Handler handler) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - surfaceTexture.setOnFrameAvailableListener(listener, handler); - } else { - // The documentation states that the listener will be called on an arbitrary thread, but in - // pratice, it is always the thread on which the SurfaceTexture was constructed. There are - // assertions in place in case this ever changes. For API >= 21, we use the new API to - // explicitly specify the handler. - surfaceTexture.setOnFrameAvailableListener(listener); - } - } - /** * Start to stream textures to the given `listener`. If you need to change listener, you need to * call stopListening() first. diff --git a/sdk/android/instrumentationtests/src/org/webrtc/Camera2CapturerTest.java b/sdk/android/instrumentationtests/src/org/webrtc/Camera2CapturerTest.java index 5a09795c20..ae84df0fde 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/Camera2CapturerTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/Camera2CapturerTest.java @@ -12,7 +12,6 @@ import static org.junit.Assert.fail; -import android.annotation.TargetApi; import android.content.Context; import android.hardware.camera2.CameraAccessException; import android.hardware.camera2.CameraDevice; @@ -31,7 +30,6 @@ import org.junit.Test; import org.junit.runner.RunWith; -@TargetApi(21) @RunWith(BaseJUnit4ClassRunner.class) public class Camera2CapturerTest { static final String TAG = "Camera2CapturerTest"; diff --git a/sdk/android/instrumentationtests/src/org/webrtc/HardwareVideoEncoderTest.java b/sdk/android/instrumentationtests/src/org/webrtc/HardwareVideoEncoderTest.java index 3a61b6edc2..fa1e46a9be 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/HardwareVideoEncoderTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/HardwareVideoEncoderTest.java @@ -16,7 +16,6 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import android.annotation.TargetApi; import android.graphics.Matrix; import android.opengl.GLES11Ext; import android.util.Log; @@ -38,7 +37,6 @@ import org.junit.Test; import org.junit.runner.RunWith; -@TargetApi(16) @RunWith(ParameterizedRunner.class) @UseRunnerDelegate(BaseJUnit4RunnerDelegate.class) public class HardwareVideoEncoderTest { diff --git a/sdk/android/instrumentationtests/src/org/webrtc/NetworkMonitorTest.java b/sdk/android/instrumentationtests/src/org/webrtc/NetworkMonitorTest.java index a80cd952c8..e045285efc 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/NetworkMonitorTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/NetworkMonitorTest.java @@ -296,14 +296,12 @@ public void testConnectivityManagerDelegateDoesNotCrash() { ConnectivityManagerDelegate delegate = new ConnectivityManagerDelegate( InstrumentationRegistry.getTargetContext(), new HashSet<>()); delegate.getNetworkState(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - Network[] networks = delegate.getAllNetworks(); - if (networks.length >= 1) { - delegate.getNetworkState(networks[0]); - delegate.hasInternetCapability(networks[0]); - } - delegate.getDefaultNetId(); + Network[] networks = delegate.getAllNetworks(); + if (networks.length >= 1) { + delegate.getNetworkState(networks[0]); + delegate.hasInternetCapability(networks[0]); } + delegate.getDefaultNetId(); } /** Tests that ConnectivityManagerDelegate preferentially reads from the cache */ diff --git a/sdk/android/src/java/org/webrtc/Camera2Session.java b/sdk/android/src/java/org/webrtc/Camera2Session.java index d0f92be19d..e0b898f506 100644 --- a/sdk/android/src/java/org/webrtc/Camera2Session.java +++ b/sdk/android/src/java/org/webrtc/Camera2Session.java @@ -10,7 +10,6 @@ package org.webrtc; -import android.annotation.TargetApi; import android.content.Context; import android.hardware.camera2.CameraAccessException; import android.hardware.camera2.CameraCaptureSession; @@ -29,7 +28,6 @@ import java.util.concurrent.TimeUnit; import org.webrtc.CameraEnumerationAndroid.CaptureFormat; -@TargetApi(21) class Camera2Session implements CameraSession { private static final String TAG = "Camera2Session"; diff --git a/sdk/android/src/java/org/webrtc/EglBase14Impl.java b/sdk/android/src/java/org/webrtc/EglBase14Impl.java index aa27cf81e2..e53dda6e4c 100644 --- a/sdk/android/src/java/org/webrtc/EglBase14Impl.java +++ b/sdk/android/src/java/org/webrtc/EglBase14Impl.java @@ -10,7 +10,6 @@ package org.webrtc; -import android.annotation.TargetApi; import android.graphics.SurfaceTexture; import android.opengl.EGL14; import android.opengl.EGLConfig; @@ -29,25 +28,13 @@ * and an EGLSurface. */ @SuppressWarnings("ReferenceEquality") // We want to compare to EGL14 constants. -@TargetApi(18) class EglBase14Impl implements EglBase14 { private static final String TAG = "EglBase14Impl"; - private static final int EGLExt_SDK_VERSION = Build.VERSION_CODES.JELLY_BEAN_MR2; - private static final int CURRENT_SDK_VERSION = Build.VERSION.SDK_INT; private EGLContext eglContext; @Nullable private EGLConfig eglConfig; private EGLDisplay eglDisplay; private EGLSurface eglSurface = EGL14.EGL_NO_SURFACE; - // EGL 1.4 is supported from API 17. But EGLExt that is used for setting presentation - // time stamp on a surface is supported from 18 so we require 18. - public static boolean isEGL14Supported() { - Logging.d(TAG, - "SDK version: " + CURRENT_SDK_VERSION - + ". isEGL14Supported: " + (CURRENT_SDK_VERSION >= EGLExt_SDK_VERSION)); - return (CURRENT_SDK_VERSION >= EGLExt_SDK_VERSION); - } - public static class Context implements EglBase14.Context { private final EGLContext egl14Context; @@ -57,11 +44,8 @@ public EGLContext getRawContext() { } @Override - @SuppressWarnings("deprecation") - @TargetApi(Build.VERSION_CODES.LOLLIPOP) public long getNativeEglContext() { - return CURRENT_SDK_VERSION >= Build.VERSION_CODES.LOLLIPOP ? egl14Context.getNativeHandle() - : egl14Context.getHandle(); + return egl14Context.getNativeHandle(); } public Context(android.opengl.EGLContext eglContext) { diff --git a/sdk/android/src/java/org/webrtc/HardwareVideoEncoder.java b/sdk/android/src/java/org/webrtc/HardwareVideoEncoder.java index 0825c1e742..743edb0b85 100644 --- a/sdk/android/src/java/org/webrtc/HardwareVideoEncoder.java +++ b/sdk/android/src/java/org/webrtc/HardwareVideoEncoder.java @@ -10,7 +10,6 @@ package org.webrtc; -import android.annotation.TargetApi; import android.media.MediaCodec; import android.media.MediaCodecInfo; import android.media.MediaFormat; @@ -29,11 +28,7 @@ /** * Android hardware video encoder. - * - * @note This class is only supported on Android Kitkat and above. */ -@TargetApi(19) -@SuppressWarnings("deprecation") // Cannot support API level 19 without using deprecated methods. class HardwareVideoEncoder implements VideoEncoder { private static final String TAG = "HardwareVideoEncoder"; diff --git a/sdk/android/src/java/org/webrtc/MediaCodecUtils.java b/sdk/android/src/java/org/webrtc/MediaCodecUtils.java index 5d83014dc3..d5ccae9688 100644 --- a/sdk/android/src/java/org/webrtc/MediaCodecUtils.java +++ b/sdk/android/src/java/org/webrtc/MediaCodecUtils.java @@ -56,15 +56,8 @@ class MediaCodecUtils { MediaCodecUtils.COLOR_QCOM_FORMATYUV420PackedSemiPlanar32m}; // Color formats supported by texture mode encoding - in order of preference. - static final int[] TEXTURE_COLOR_FORMATS = getTextureColorFormats(); - - private static int[] getTextureColorFormats() { - if (Build.VERSION.SDK_INT >= 18) { - return new int[] {MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface}; - } else { - return new int[] {}; - } - } + static final int[] TEXTURE_COLOR_FORMATS = + new int[] {MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface}; static @Nullable Integer selectColorFormat( int[] supportedColorFormats, CodecCapabilities capabilities) { diff --git a/sdk/android/src/java/org/webrtc/MediaCodecVideoDecoderFactory.java b/sdk/android/src/java/org/webrtc/MediaCodecVideoDecoderFactory.java index 4ee8b1aad1..bf591dda26 100644 --- a/sdk/android/src/java/org/webrtc/MediaCodecVideoDecoderFactory.java +++ b/sdk/android/src/java/org/webrtc/MediaCodecVideoDecoderFactory.java @@ -83,11 +83,6 @@ public VideoCodecInfo[] getSupportedCodecs() { } private @Nullable MediaCodecInfo findCodecForType(VideoCodecMimeType type) { - // HW decoding is not supported on builds before KITKAT. - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - return null; - } - for (int i = 0; i < MediaCodecList.getCodecCount(); ++i) { MediaCodecInfo info = null; try { @@ -131,8 +126,8 @@ private boolean isCodecAllowed(MediaCodecInfo info) { private boolean isH264HighProfileSupported(MediaCodecInfo info) { String name = info.getName(); - // Support H.264 HP decoding on QCOM chips for Android L and above. - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && name.startsWith(QCOM_PREFIX)) { + // Support H.264 HP decoding on QCOM chips. + if (name.startsWith(QCOM_PREFIX)) { return true; } // Support H.264 HP decoding on Exynos chips for Android M and above. diff --git a/sdk/android/src/java/org/webrtc/MediaCodecWrapperFactoryImpl.java b/sdk/android/src/java/org/webrtc/MediaCodecWrapperFactoryImpl.java index 29edf6ef0c..3b4647bcb6 100644 --- a/sdk/android/src/java/org/webrtc/MediaCodecWrapperFactoryImpl.java +++ b/sdk/android/src/java/org/webrtc/MediaCodecWrapperFactoryImpl.java @@ -10,7 +10,6 @@ package org.webrtc; -import android.annotation.TargetApi; import android.media.MediaCodec; import android.media.MediaCodec.BufferInfo; import android.media.MediaCrypto; @@ -99,13 +98,11 @@ public ByteBuffer[] getOutputBuffers() { } @Override - @TargetApi(18) public Surface createInputSurface() { return mediaCodec.createInputSurface(); } @Override - @TargetApi(19) public void setParameters(Bundle params) { mediaCodec.setParameters(params); } diff --git a/sdk/android/src/java/org/webrtc/audio/WebRtcAudioEffects.java b/sdk/android/src/java/org/webrtc/audio/WebRtcAudioEffects.java index fb132c6049..a9ff1011b6 100644 --- a/sdk/android/src/java/org/webrtc/audio/WebRtcAudioEffects.java +++ b/sdk/android/src/java/org/webrtc/audio/WebRtcAudioEffects.java @@ -54,15 +54,11 @@ class WebRtcAudioEffects { // Returns true if all conditions for supporting HW Acoustic Echo Cancellation (AEC) are // fulfilled. public static boolean isAcousticEchoCancelerSupported() { - if (Build.VERSION.SDK_INT < 18) - return false; return isEffectTypeAvailable(AudioEffect.EFFECT_TYPE_AEC, AOSP_ACOUSTIC_ECHO_CANCELER); } // Returns true if all conditions for supporting HW Noise Suppression (NS) are fulfilled. public static boolean isNoiseSuppressorSupported() { - if (Build.VERSION.SDK_INT < 18) - return false; return isEffectTypeAvailable(AudioEffect.EFFECT_TYPE_NS, AOSP_NOISE_SUPPRESSOR); } @@ -188,9 +184,6 @@ public void release() { // As an example: Samsung Galaxy S6 includes an AGC in the descriptor but // AutomaticGainControl.isAvailable() returns false. private boolean effectTypeIsVoIP(UUID type) { - if (Build.VERSION.SDK_INT < 18) - return false; - return (AudioEffect.EFFECT_TYPE_AEC.equals(type) && isAcousticEchoCancelerSupported()) || (AudioEffect.EFFECT_TYPE_NS.equals(type) && isNoiseSuppressorSupported()); } diff --git a/sdk/android/src/java/org/webrtc/audio/WebRtcAudioManager.java b/sdk/android/src/java/org/webrtc/audio/WebRtcAudioManager.java index f016dad502..f398602a28 100644 --- a/sdk/android/src/java/org/webrtc/audio/WebRtcAudioManager.java +++ b/sdk/android/src/java/org/webrtc/audio/WebRtcAudioManager.java @@ -64,7 +64,7 @@ private static boolean isLowLatencyInputSupported(Context context) { // as well. The NDK doc states that: "As of API level 21, lower latency // audio input is supported on select devices. To take advantage of this // feature, first confirm that lower latency output is available". - return Build.VERSION.SDK_INT >= 21 && isLowLatencyOutputSupported(context); + return isLowLatencyOutputSupported(context); } /** @@ -85,18 +85,12 @@ static int getSampleRate(AudioManager audioManager) { } private static int getSampleRateForApiLevel(AudioManager audioManager) { - if (Build.VERSION.SDK_INT < 17) { - return DEFAULT_SAMPLE_RATE_HZ; - } String sampleRateString = audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE); return (sampleRateString == null) ? DEFAULT_SAMPLE_RATE_HZ : Integer.parseInt(sampleRateString); } // Returns the native output buffer size for low-latency output streams. private static int getLowLatencyFramesPerBuffer(AudioManager audioManager) { - if (Build.VERSION.SDK_INT < 17) { - return DEFAULT_FRAME_PER_BUFFER; - } String framesPerBuffer = audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER); return framesPerBuffer == null ? DEFAULT_FRAME_PER_BUFFER : Integer.parseInt(framesPerBuffer); diff --git a/sdk/android/src/java/org/webrtc/audio/WebRtcAudioTrack.java b/sdk/android/src/java/org/webrtc/audio/WebRtcAudioTrack.java index 885df55479..f0cfd73caf 100644 --- a/sdk/android/src/java/org/webrtc/audio/WebRtcAudioTrack.java +++ b/sdk/android/src/java/org/webrtc/audio/WebRtcAudioTrack.java @@ -47,16 +47,7 @@ class WebRtcAudioTrack { // By default, WebRTC creates audio tracks with a usage attribute // corresponding to voice communications, such as telephony or VoIP. - private static final int DEFAULT_USAGE = getDefaultUsageAttribute(); - - private static int getDefaultUsageAttribute() { - if (Build.VERSION.SDK_INT >= 21) { - return AudioAttributes.USAGE_VOICE_COMMUNICATION; - } else { - // Not used on SDKs lower than L. - return 0; - } - } + private static final int DEFAULT_USAGE = AudioAttributes.USAGE_VOICE_COMMUNICATION; // Indicates the AudioTrack has started playing audio. private static final int AUDIO_TRACK_START = 0; @@ -128,7 +119,7 @@ public void run() { byteBuffer.put(emptyBytes); byteBuffer.position(0); } - int bytesWritten = writeBytes(audioTrack, byteBuffer, sizeInBytes); + int bytesWritten = audioTrack.write(byteBuffer, sizeInBytes, AudioTrack.WRITE_BLOCKING); if (bytesWritten != sizeInBytes) { Logging.e(TAG, "AudioTrack.write played invalid number of bytes: " + bytesWritten); // If a write() returns a negative value, an error has occurred. @@ -152,14 +143,6 @@ public void run() { } } - private int writeBytes(AudioTrack audioTrack, ByteBuffer byteBuffer, int sizeInBytes) { - if (Build.VERSION.SDK_INT >= 21) { - return audioTrack.write(byteBuffer, sizeInBytes, AudioTrack.WRITE_BLOCKING); - } else { - return audioTrack.write(byteBuffer.array(), byteBuffer.arrayOffset(), sizeInBytes); - } - } - // Stops the inner thread loop which results in calling AudioTrack.stop(). // Does not block the calling thread. public void stopThread() { @@ -247,18 +230,14 @@ private int initPlayout(int sampleRate, int channels, double bufferSizeFactor) { // On API level 26 or higher, we can use a low latency mode. audioTrack = createAudioTrackOnOreoOrHigher( sampleRate, channelConfig, minBufferSizeInBytes, audioAttributes); - } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - // If we are on API level 21 or higher, it is possible to use a special AudioTrack + } else { + // As we are on API level 21 or higher, it is possible to use a special AudioTrack // constructor that uses AudioAttributes and AudioFormat as input. It allows us to // supersede the notion of stream types for defining the behavior of audio playback, // and to allow certain platforms or routing policies to use this information for more // refined volume or routing decisions. - audioTrack = createAudioTrackOnLollipopOrHigher( + audioTrack = createAudioTrackBeforeOreo( sampleRate, channelConfig, minBufferSizeInBytes, audioAttributes); - } else { - // Use default constructor for API levels below 21. - audioTrack = - createAudioTrackOnLowerThanLollipop(sampleRate, channelConfig, minBufferSizeInBytes); } } catch (IllegalArgumentException e) { reportWebRtcAudioTrackInitError(e.getMessage()); @@ -360,7 +339,7 @@ private int getStreamMaxVolume() { private boolean setStreamVolume(int volume) { threadChecker.checkIsOnValidThread(); Logging.d(TAG, "setStreamVolume(" + volume + ")"); - if (isVolumeFixed()) { + if (audioManager.isVolumeFixed()) { Logging.e(TAG, "The device implements a fixed volume policy."); return false; } @@ -368,12 +347,6 @@ private boolean setStreamVolume(int volume) { return true; } - private boolean isVolumeFixed() { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) - return false; - return audioManager.isVolumeFixed(); - } - /** Get current volume level for a phone call audio stream. */ @CalledByNative private int getStreamVolume() { @@ -441,10 +414,9 @@ private static AudioAttributes getAudioAttributes(@Nullable AudioAttributes over // Creates and AudioTrack instance using AudioAttributes and AudioFormat as input. // It allows certain platforms or routing policies to use this information for more // refined volume or routing decisions. - @TargetApi(Build.VERSION_CODES.LOLLIPOP) - private static AudioTrack createAudioTrackOnLollipopOrHigher(int sampleRateInHz, - int channelConfig, int bufferSizeInBytes, @Nullable AudioAttributes overrideAttributes) { - Logging.d(TAG, "createAudioTrackOnLollipopOrHigher"); + private static AudioTrack createAudioTrackBeforeOreo(int sampleRateInHz, int channelConfig, + int bufferSizeInBytes, @Nullable AudioAttributes overrideAttributes) { + Logging.d(TAG, "createAudioTrackBeforeOreo"); logNativeOutputSampleRate(sampleRateInHz); // Create an audio track where the audio usage is for VoIP and the content type is speech. @@ -489,13 +461,6 @@ private static AudioAttributes.Builder applyAttributesOnQOrHigher( return builder.setAllowedCapturePolicy(overrideAttributes.getAllowedCapturePolicy()); } - @SuppressWarnings("deprecation") // Deprecated in API level 25. - private static AudioTrack createAudioTrackOnLowerThanLollipop( - int sampleRateInHz, int channelConfig, int bufferSizeInBytes) { - return new AudioTrack(AudioManager.STREAM_VOICE_CALL, sampleRateInHz, channelConfig, - AudioFormat.ENCODING_PCM_16BIT, bufferSizeInBytes, AudioTrack.MODE_STREAM); - } - private void logBufferSizeInFrames() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { Logging.d(TAG, diff --git a/sdk/android/src/java/org/webrtc/audio/WebRtcAudioUtils.java b/sdk/android/src/java/org/webrtc/audio/WebRtcAudioUtils.java index 591fc9e013..7894659926 100644 --- a/sdk/android/src/java/org/webrtc/audio/WebRtcAudioUtils.java +++ b/sdk/android/src/java/org/webrtc/audio/WebRtcAudioUtils.java @@ -201,13 +201,6 @@ private static void logAudioStateBasic(String tag, Context context, AudioManager + "BT SCO: " + audioManager.isBluetoothScoOn()); } - private static boolean isVolumeFixed(AudioManager audioManager) { - if (Build.VERSION.SDK_INT < 21) { - return false; - } - return audioManager.isVolumeFixed(); - } - // Adds volume information for all possible stream types. private static void logAudioStateVolume(String tag, AudioManager audioManager) { final int[] streams = {AudioManager.STREAM_VOICE_CALL, AudioManager.STREAM_MUSIC, @@ -215,7 +208,7 @@ private static void logAudioStateVolume(String tag, AudioManager audioManager) { AudioManager.STREAM_SYSTEM}; Logging.d(tag, "Audio State: "); // Some devices may not have volume controls and might use a fixed volume. - boolean fixedVolume = isVolumeFixed(audioManager); + boolean fixedVolume = audioManager.isVolumeFixed(); Logging.d(tag, " fixed volume=" + fixedVolume); if (!fixedVolume) { for (int stream : streams) { From eee0e336a2f3de58c286e308e0705265f9a8ba0c Mon Sep 17 00:00:00 2001 From: Victor Boivie Date: Fri, 4 Mar 2022 20:11:44 +0100 Subject: [PATCH 115/847] dcsctp: Convert socket tests not to use fixtures Following https://abseil.io/tips/122 to make tests easier to understand and adds a bit of flexibility to create sockets with custom parameters. This also simplifies handover tests. Additionally, AdvanceTime will now also run timers, as that was easily forgotten previously. Bug: None Change-Id: Ieb5eece7aca51c98a7634ed1c61646383ad1712d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253782 Reviewed-by: Sergey Sukhanov Commit-Queue: Victor Boivie Cr-Commit-Position: refs/heads/main@{#36141} --- net/dcsctp/socket/dcsctp_socket_test.cc | 1660 +++++++++-------- .../socket/mock_dcsctp_socket_callbacks.h | 6 - net/dcsctp/timer/fake_timeout.h | 2 - 3 files changed, 882 insertions(+), 786 deletions(-) diff --git a/net/dcsctp/socket/dcsctp_socket_test.cc b/net/dcsctp/socket/dcsctp_socket_test.cc index 66876e4e25..f45773baba 100644 --- a/net/dcsctp/socket/dcsctp_socket_test.cc +++ b/net/dcsctp/socket/dcsctp_socket_test.cc @@ -233,13 +233,12 @@ TSN AddTo(TSN tsn, int delta) { return TSN(*tsn + delta); } -DcSctpOptions MakeOptionsForTest(bool enable_message_interleaving) { - DcSctpOptions options; +DcSctpOptions FixupOptions(DcSctpOptions options = {}) { + DcSctpOptions fixup = options; // To make the interval more predictable in tests. - options.heartbeat_interval_include_rtt = false; - options.enable_message_interleaving = enable_message_interleaving; - options.max_burst = kMaxBurstPackets; - return options; + fixup.heartbeat_interval_include_rtt = false; + fixup.max_burst = kMaxBurstPackets; + return fixup; } std::unique_ptr GetPacketObserver(absl::string_view name) { @@ -249,102 +248,89 @@ std::unique_ptr GetPacketObserver(absl::string_view name) { return nullptr; } -class DcSctpSocketTest : public testing::Test { - protected: - explicit DcSctpSocketTest(bool enable_message_interleaving = false) - : options_(MakeOptionsForTest(enable_message_interleaving)), - cb_a_("A"), - cb_z_("Z"), - sock_a_(std::make_unique("A", - cb_a_, - GetPacketObserver("A"), - options_)), - sock_z_(std::make_unique("Z", - cb_z_, - GetPacketObserver("Z"), - options_)) {} - - void AdvanceTime(DurationMs duration) { - cb_a_.AdvanceTime(duration); - cb_z_.AdvanceTime(duration); - } +struct SocketUnderTest { + explicit SocketUnderTest(absl::string_view name, + const DcSctpOptions& opts = {}) + : options(FixupOptions(opts)), + cb(name), + socket(name, cb, GetPacketObserver(name), options) {} - static void ExchangeMessages(DcSctpSocket& sock_a, - MockDcSctpSocketCallbacks& cb_a, - DcSctpSocket& sock_z, - MockDcSctpSocketCallbacks& cb_z) { - bool delivered_packet = false; - do { - delivered_packet = false; - std::vector packet_from_a = cb_a.ConsumeSentPacket(); - if (!packet_from_a.empty()) { - delivered_packet = true; - sock_z.ReceivePacket(std::move(packet_from_a)); - } - std::vector packet_from_z = cb_z.ConsumeSentPacket(); - if (!packet_from_z.empty()) { - delivered_packet = true; - sock_a.ReceivePacket(std::move(packet_from_z)); - } - } while (delivered_packet); - } + const DcSctpOptions options; + testing::NiceMock cb; + DcSctpSocket socket; +}; - void RunTimers(MockDcSctpSocketCallbacks& cb, DcSctpSocket& socket) { - for (;;) { - absl::optional timeout_id = cb.GetNextExpiredTimeout(); - if (!timeout_id.has_value()) { - break; - } - socket.HandleTimeout(*timeout_id); +void ExchangeMessages(SocketUnderTest& a, SocketUnderTest& z) { + bool delivered_packet = false; + do { + delivered_packet = false; + std::vector packet_from_a = a.cb.ConsumeSentPacket(); + if (!packet_from_a.empty()) { + delivered_packet = true; + z.socket.ReceivePacket(std::move(packet_from_a)); } - } + std::vector packet_from_z = z.cb.ConsumeSentPacket(); + if (!packet_from_z.empty()) { + delivered_packet = true; + a.socket.ReceivePacket(std::move(packet_from_z)); + } + } while (delivered_packet); +} - void RunTimers() { - RunTimers(cb_a_, *sock_a_); - RunTimers(cb_z_, *sock_z_); +void RunTimers(SocketUnderTest& s) { + for (;;) { + absl::optional timeout_id = s.cb.GetNextExpiredTimeout(); + if (!timeout_id.has_value()) { + break; + } + s.socket.HandleTimeout(*timeout_id); } +} - // Calls Connect() on `sock_a_` and make the connection established. - void ConnectSockets() { - EXPECT_CALL(cb_a_, OnConnected).Times(1); - EXPECT_CALL(cb_z_, OnConnected).Times(1); +void AdvanceTime(SocketUnderTest& a, SocketUnderTest& z, DurationMs duration) { + a.cb.AdvanceTime(duration); + z.cb.AdvanceTime(duration); - sock_a_->Connect(); - // Z reads INIT, INIT_ACK, COOKIE_ECHO, COOKIE_ACK - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + RunTimers(a); + RunTimers(z); +} - EXPECT_EQ(sock_a_->state(), SocketState::kConnected); - EXPECT_EQ(sock_z_->state(), SocketState::kConnected); - } +// Calls Connect() on `sock_a_` and make the connection established. +void ConnectSockets(SocketUnderTest& a, SocketUnderTest& z) { + EXPECT_CALL(a.cb, OnConnected).Times(1); + EXPECT_CALL(z.cb, OnConnected).Times(1); - void HandoverSocketZ() { - ASSERT_EQ(sock_z_->GetHandoverReadiness(), HandoverReadinessStatus()); - bool is_closed = sock_z_->state() == SocketState::kClosed; - if (!is_closed) { - EXPECT_CALL(cb_z_, OnClosed).Times(1); - } - absl::optional handover_state = - sock_z_->GetHandoverStateAndClose(); - EXPECT_TRUE(handover_state.has_value()); - g_handover_state_transformer_for_test(&*handover_state); - cb_z_.Reset(); - sock_z_ = std::make_unique("Z", cb_z_, GetPacketObserver("Z"), - options_); - if (!is_closed) { - EXPECT_CALL(cb_z_, OnConnected).Times(1); - } - sock_z_->RestoreFromState(*handover_state); - } + a.socket.Connect(); + // Z reads INIT, INIT_ACK, COOKIE_ECHO, COOKIE_ACK + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); + a.socket.ReceivePacket(z.cb.ConsumeSentPacket()); + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); + a.socket.ReceivePacket(z.cb.ConsumeSentPacket()); - const DcSctpOptions options_; - testing::NiceMock cb_a_; - testing::NiceMock cb_z_; - std::unique_ptr sock_a_; - std::unique_ptr sock_z_; -}; + EXPECT_EQ(a.socket.state(), SocketState::kConnected); + EXPECT_EQ(z.socket.state(), SocketState::kConnected); +} + +std::unique_ptr HandoverSocket( + std::unique_ptr sut) { + EXPECT_EQ(sut->socket.GetHandoverReadiness(), HandoverReadinessStatus()); + + bool is_closed = sut->socket.state() == SocketState::kClosed; + if (!is_closed) { + EXPECT_CALL(sut->cb, OnClosed).Times(1); + } + absl::optional handover_state = + sut->socket.GetHandoverStateAndClose(); + EXPECT_TRUE(handover_state.has_value()); + g_handover_state_transformer_for_test(&*handover_state); + + auto handover_socket = std::make_unique("H", sut->options); + if (!is_closed) { + EXPECT_CALL(handover_socket->cb, OnConnected).Times(1); + } + handover_socket->socket.RestoreFromState(*handover_state); + return handover_socket; +} // Test parameter that controls whether to perform handovers during the test. A // test can have multiple points where it conditionally hands over socket Z. @@ -355,27 +341,31 @@ enum class HandoverMode { }; class DcSctpSocketParametrizedTest - : public DcSctpSocketTest, + : public ::testing::Test, public ::testing::WithParamInterface { protected: - // Trigger handover for socket Z depending on the current test param. - void MaybeHandoverSocketZ() { + // Trigger handover for `sut` depending on the current test param. + std::unique_ptr MaybeHandoverSocket( + std::unique_ptr sut) { if (GetParam() == HandoverMode::kPerformHandovers) { - HandoverSocketZ(); + return HandoverSocket(std::move(sut)); } + return sut; } + // Trigger handover for socket Z depending on the current test param. // Then checks message passing to verify the handed over socket is functional. - void MaybeHandoverSocketZAndSendMessage() { + void MaybeHandoverSocketAndSendMessage(SocketUnderTest& a, + std::unique_ptr z) { if (GetParam() == HandoverMode::kPerformHandovers) { - HandoverSocketZ(); + z = HandoverSocket(std::move(z)); } - ExchangeMessages(*sock_a_, cb_a_, *sock_z_, cb_z_); - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), {1, 2}), kSendOptions); - ExchangeMessages(*sock_a_, cb_a_, *sock_z_, cb_z_); + ExchangeMessages(a, *z); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), {1, 2}), kSendOptions); + ExchangeMessages(a, *z); - absl::optional msg = cb_z_.ConsumeReceivedMessage(); + absl::optional msg = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg.has_value()); EXPECT_EQ(msg->stream_id(), StreamID(1)); } @@ -392,451 +382,492 @@ INSTANTIATE_TEST_SUITE_P(Handovers, : "NoHandover"; }); -TEST_F(DcSctpSocketTest, EstablishConnection) { - EXPECT_CALL(cb_a_, OnConnected).Times(1); - EXPECT_CALL(cb_z_, OnConnected).Times(1); - EXPECT_CALL(cb_a_, OnConnectionRestarted).Times(0); - EXPECT_CALL(cb_z_, OnConnectionRestarted).Times(0); +TEST(DcSctpSocketTest, EstablishConnection) { + SocketUnderTest a("A"); + SocketUnderTest z("Z"); + + EXPECT_CALL(a.cb, OnConnected).Times(1); + EXPECT_CALL(z.cb, OnConnected).Times(1); + EXPECT_CALL(a.cb, OnConnectionRestarted).Times(0); + EXPECT_CALL(z.cb, OnConnectionRestarted).Times(0); - sock_a_->Connect(); + a.socket.Connect(); // Z reads INIT, produces INIT_ACK - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); // A reads INIT_ACK, produces COOKIE_ECHO - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z.cb.ConsumeSentPacket()); // Z reads COOKIE_ECHO, produces COOKIE_ACK - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); // A reads COOKIE_ACK. - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z.cb.ConsumeSentPacket()); - EXPECT_EQ(sock_a_->state(), SocketState::kConnected); - EXPECT_EQ(sock_z_->state(), SocketState::kConnected); + EXPECT_EQ(a.socket.state(), SocketState::kConnected); + EXPECT_EQ(z.socket.state(), SocketState::kConnected); } -TEST_F(DcSctpSocketTest, EstablishConnectionWithSetupCollision) { - EXPECT_CALL(cb_a_, OnConnected).Times(1); - EXPECT_CALL(cb_z_, OnConnected).Times(1); - EXPECT_CALL(cb_a_, OnConnectionRestarted).Times(0); - EXPECT_CALL(cb_z_, OnConnectionRestarted).Times(0); - sock_a_->Connect(); - sock_z_->Connect(); +TEST(DcSctpSocketTest, EstablishConnectionWithSetupCollision) { + SocketUnderTest a("A"); + SocketUnderTest z("Z"); + + EXPECT_CALL(a.cb, OnConnected).Times(1); + EXPECT_CALL(z.cb, OnConnected).Times(1); + EXPECT_CALL(a.cb, OnConnectionRestarted).Times(0); + EXPECT_CALL(z.cb, OnConnectionRestarted).Times(0); + a.socket.Connect(); + z.socket.Connect(); - ExchangeMessages(*sock_a_, cb_a_, *sock_z_, cb_z_); + ExchangeMessages(a, z); - EXPECT_EQ(sock_a_->state(), SocketState::kConnected); - EXPECT_EQ(sock_z_->state(), SocketState::kConnected); + EXPECT_EQ(a.socket.state(), SocketState::kConnected); + EXPECT_EQ(z.socket.state(), SocketState::kConnected); } -TEST_F(DcSctpSocketTest, ShuttingDownWhileEstablishingConnection) { - EXPECT_CALL(cb_a_, OnConnected).Times(0); - EXPECT_CALL(cb_z_, OnConnected).Times(1); - sock_a_->Connect(); +TEST(DcSctpSocketTest, ShuttingDownWhileEstablishingConnection) { + SocketUnderTest a("A"); + SocketUnderTest z("Z"); + + EXPECT_CALL(a.cb, OnConnected).Times(0); + EXPECT_CALL(z.cb, OnConnected).Times(1); + a.socket.Connect(); // Z reads INIT, produces INIT_ACK - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); // A reads INIT_ACK, produces COOKIE_ECHO - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z.cb.ConsumeSentPacket()); // Z reads COOKIE_ECHO, produces COOKIE_ACK - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); // Drop COOKIE_ACK, just to more easily verify shutdown protocol. - cb_z_.ConsumeSentPacket(); + z.cb.ConsumeSentPacket(); // As Socket A has received INIT_ACK, it has a TCB and is connected, while // Socket Z needs to receive COOKIE_ECHO to get there. Socket A still has // timers running at this point. - EXPECT_EQ(sock_a_->state(), SocketState::kConnecting); - EXPECT_EQ(sock_z_->state(), SocketState::kConnected); + EXPECT_EQ(a.socket.state(), SocketState::kConnecting); + EXPECT_EQ(z.socket.state(), SocketState::kConnected); // Socket A is now shut down, which should make it stop those timers. - sock_a_->Shutdown(); + a.socket.Shutdown(); - EXPECT_CALL(cb_a_, OnClosed).Times(1); - EXPECT_CALL(cb_z_, OnClosed).Times(1); + EXPECT_CALL(a.cb, OnClosed).Times(1); + EXPECT_CALL(z.cb, OnClosed).Times(1); // Z reads SHUTDOWN, produces SHUTDOWN_ACK - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); // A reads SHUTDOWN_ACK, produces SHUTDOWN_COMPLETE - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z.cb.ConsumeSentPacket()); // Z reads SHUTDOWN_COMPLETE. - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); - EXPECT_TRUE(cb_a_.ConsumeSentPacket().empty()); - EXPECT_TRUE(cb_z_.ConsumeSentPacket().empty()); + EXPECT_TRUE(a.cb.ConsumeSentPacket().empty()); + EXPECT_TRUE(z.cb.ConsumeSentPacket().empty()); - EXPECT_EQ(sock_a_->state(), SocketState::kClosed); - EXPECT_EQ(sock_z_->state(), SocketState::kClosed); + EXPECT_EQ(a.socket.state(), SocketState::kClosed); + EXPECT_EQ(z.socket.state(), SocketState::kClosed); } -TEST_F(DcSctpSocketTest, EstablishSimultaneousConnection) { - EXPECT_CALL(cb_a_, OnConnected).Times(1); - EXPECT_CALL(cb_z_, OnConnected).Times(1); - EXPECT_CALL(cb_a_, OnConnectionRestarted).Times(0); - EXPECT_CALL(cb_z_, OnConnectionRestarted).Times(0); - sock_a_->Connect(); +TEST(DcSctpSocketTest, EstablishSimultaneousConnection) { + SocketUnderTest a("A"); + SocketUnderTest z("Z"); + + EXPECT_CALL(a.cb, OnConnected).Times(1); + EXPECT_CALL(z.cb, OnConnected).Times(1); + EXPECT_CALL(a.cb, OnConnectionRestarted).Times(0); + EXPECT_CALL(z.cb, OnConnectionRestarted).Times(0); + a.socket.Connect(); // INIT isn't received by Z, as it wasn't ready yet. - cb_a_.ConsumeSentPacket(); + a.cb.ConsumeSentPacket(); - sock_z_->Connect(); + z.socket.Connect(); // A reads INIT, produces INIT_ACK - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z.cb.ConsumeSentPacket()); // Z reads INIT_ACK, sends COOKIE_ECHO - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); // A reads COOKIE_ECHO - establishes connection. - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z.cb.ConsumeSentPacket()); - EXPECT_EQ(sock_a_->state(), SocketState::kConnected); + EXPECT_EQ(a.socket.state(), SocketState::kConnected); // Proceed with the remaining packets. - ExchangeMessages(*sock_a_, cb_a_, *sock_z_, cb_z_); + ExchangeMessages(a, z); - EXPECT_EQ(sock_a_->state(), SocketState::kConnected); - EXPECT_EQ(sock_z_->state(), SocketState::kConnected); + EXPECT_EQ(a.socket.state(), SocketState::kConnected); + EXPECT_EQ(z.socket.state(), SocketState::kConnected); } -TEST_F(DcSctpSocketTest, EstablishConnectionLostCookieAck) { - EXPECT_CALL(cb_a_, OnConnected).Times(1); - EXPECT_CALL(cb_z_, OnConnected).Times(1); - EXPECT_CALL(cb_a_, OnConnectionRestarted).Times(0); - EXPECT_CALL(cb_z_, OnConnectionRestarted).Times(0); +TEST(DcSctpSocketTest, EstablishConnectionLostCookieAck) { + SocketUnderTest a("A"); + SocketUnderTest z("Z"); + + EXPECT_CALL(a.cb, OnConnected).Times(1); + EXPECT_CALL(z.cb, OnConnected).Times(1); + EXPECT_CALL(a.cb, OnConnectionRestarted).Times(0); + EXPECT_CALL(z.cb, OnConnectionRestarted).Times(0); - sock_a_->Connect(); + a.socket.Connect(); // Z reads INIT, produces INIT_ACK - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); // A reads INIT_ACK, produces COOKIE_ECHO - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z.cb.ConsumeSentPacket()); // Z reads COOKIE_ECHO, produces COOKIE_ACK - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); // COOKIE_ACK is lost. - cb_z_.ConsumeSentPacket(); + z.cb.ConsumeSentPacket(); - EXPECT_EQ(sock_a_->state(), SocketState::kConnecting); - EXPECT_EQ(sock_z_->state(), SocketState::kConnected); + EXPECT_EQ(a.socket.state(), SocketState::kConnecting); + EXPECT_EQ(z.socket.state(), SocketState::kConnected); // This will make A re-send the COOKIE_ECHO - AdvanceTime(DurationMs(options_.t1_cookie_timeout)); - RunTimers(); + AdvanceTime(a, z, DurationMs(a.options.t1_cookie_timeout)); // Z reads COOKIE_ECHO, produces COOKIE_ACK - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); // A reads COOKIE_ACK. - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z.cb.ConsumeSentPacket()); - EXPECT_EQ(sock_a_->state(), SocketState::kConnected); - EXPECT_EQ(sock_z_->state(), SocketState::kConnected); + EXPECT_EQ(a.socket.state(), SocketState::kConnected); + EXPECT_EQ(z.socket.state(), SocketState::kConnected); } -TEST_F(DcSctpSocketTest, ResendInitAndEstablishConnection) { - sock_a_->Connect(); +TEST(DcSctpSocketTest, ResendInitAndEstablishConnection) { + SocketUnderTest a("A"); + SocketUnderTest z("Z"); + + a.socket.Connect(); // INIT is never received by Z. ASSERT_HAS_VALUE_AND_ASSIGN(SctpPacket init_packet, - SctpPacket::Parse(cb_a_.ConsumeSentPacket())); + SctpPacket::Parse(a.cb.ConsumeSentPacket())); EXPECT_EQ(init_packet.descriptors()[0].type, InitChunk::kType); - AdvanceTime(options_.t1_init_timeout); - RunTimers(); + AdvanceTime(a, z, a.options.t1_init_timeout); // Z reads INIT, produces INIT_ACK - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); // A reads INIT_ACK, produces COOKIE_ECHO - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z.cb.ConsumeSentPacket()); // Z reads COOKIE_ECHO, produces COOKIE_ACK - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); // A reads COOKIE_ACK. - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z.cb.ConsumeSentPacket()); - EXPECT_EQ(sock_a_->state(), SocketState::kConnected); - EXPECT_EQ(sock_z_->state(), SocketState::kConnected); + EXPECT_EQ(a.socket.state(), SocketState::kConnected); + EXPECT_EQ(z.socket.state(), SocketState::kConnected); } -TEST_F(DcSctpSocketTest, ResendingInitTooManyTimesAborts) { - sock_a_->Connect(); +TEST(DcSctpSocketTest, ResendingInitTooManyTimesAborts) { + SocketUnderTest a("A"); + SocketUnderTest z("Z"); + + a.socket.Connect(); // INIT is never received by Z. ASSERT_HAS_VALUE_AND_ASSIGN(SctpPacket init_packet, - SctpPacket::Parse(cb_a_.ConsumeSentPacket())); + SctpPacket::Parse(a.cb.ConsumeSentPacket())); EXPECT_EQ(init_packet.descriptors()[0].type, InitChunk::kType); - for (int i = 0; i < *options_.max_init_retransmits; ++i) { - AdvanceTime(options_.t1_init_timeout * (1 << i)); - RunTimers(); + for (int i = 0; i < *a.options.max_init_retransmits; ++i) { + AdvanceTime(a, z, a.options.t1_init_timeout * (1 << i)); // INIT is resent ASSERT_HAS_VALUE_AND_ASSIGN(SctpPacket resent_init_packet, - SctpPacket::Parse(cb_a_.ConsumeSentPacket())); + SctpPacket::Parse(a.cb.ConsumeSentPacket())); EXPECT_EQ(resent_init_packet.descriptors()[0].type, InitChunk::kType); } // Another timeout, after the max init retransmits. - AdvanceTime(options_.t1_init_timeout * (1 << *options_.max_init_retransmits)); - EXPECT_CALL(cb_a_, OnAborted).Times(1); - RunTimers(); + EXPECT_CALL(a.cb, OnAborted).Times(1); + AdvanceTime( + a, z, a.options.t1_init_timeout * (1 << *a.options.max_init_retransmits)); - EXPECT_EQ(sock_a_->state(), SocketState::kClosed); + EXPECT_EQ(a.socket.state(), SocketState::kClosed); } -TEST_F(DcSctpSocketTest, ResendCookieEchoAndEstablishConnection) { - sock_a_->Connect(); +TEST(DcSctpSocketTest, ResendCookieEchoAndEstablishConnection) { + SocketUnderTest a("A"); + SocketUnderTest z("Z"); + + a.socket.Connect(); // Z reads INIT, produces INIT_ACK - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); // A reads INIT_ACK, produces COOKIE_ECHO - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z.cb.ConsumeSentPacket()); // COOKIE_ECHO is never received by Z. ASSERT_HAS_VALUE_AND_ASSIGN(SctpPacket init_packet, - SctpPacket::Parse(cb_a_.ConsumeSentPacket())); + SctpPacket::Parse(a.cb.ConsumeSentPacket())); EXPECT_EQ(init_packet.descriptors()[0].type, CookieEchoChunk::kType); - AdvanceTime(options_.t1_init_timeout); - RunTimers(); + AdvanceTime(a, z, a.options.t1_init_timeout); // Z reads COOKIE_ECHO, produces COOKIE_ACK - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); // A reads COOKIE_ACK. - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z.cb.ConsumeSentPacket()); - EXPECT_EQ(sock_a_->state(), SocketState::kConnected); - EXPECT_EQ(sock_z_->state(), SocketState::kConnected); + EXPECT_EQ(a.socket.state(), SocketState::kConnected); + EXPECT_EQ(z.socket.state(), SocketState::kConnected); } -TEST_F(DcSctpSocketTest, ResendingCookieEchoTooManyTimesAborts) { - sock_a_->Connect(); +TEST(DcSctpSocketTest, ResendingCookieEchoTooManyTimesAborts) { + SocketUnderTest a("A"); + SocketUnderTest z("Z"); + + a.socket.Connect(); // Z reads INIT, produces INIT_ACK - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); // A reads INIT_ACK, produces COOKIE_ECHO - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z.cb.ConsumeSentPacket()); // COOKIE_ECHO is never received by Z. ASSERT_HAS_VALUE_AND_ASSIGN(SctpPacket init_packet, - SctpPacket::Parse(cb_a_.ConsumeSentPacket())); + SctpPacket::Parse(a.cb.ConsumeSentPacket())); EXPECT_EQ(init_packet.descriptors()[0].type, CookieEchoChunk::kType); - for (int i = 0; i < *options_.max_init_retransmits; ++i) { - AdvanceTime(options_.t1_cookie_timeout * (1 << i)); - RunTimers(); + for (int i = 0; i < *a.options.max_init_retransmits; ++i) { + AdvanceTime(a, z, a.options.t1_cookie_timeout * (1 << i)); // COOKIE_ECHO is resent ASSERT_HAS_VALUE_AND_ASSIGN(SctpPacket resent_init_packet, - SctpPacket::Parse(cb_a_.ConsumeSentPacket())); + SctpPacket::Parse(a.cb.ConsumeSentPacket())); EXPECT_EQ(resent_init_packet.descriptors()[0].type, CookieEchoChunk::kType); } // Another timeout, after the max init retransmits. - AdvanceTime(options_.t1_cookie_timeout * - (1 << *options_.max_init_retransmits)); - EXPECT_CALL(cb_a_, OnAborted).Times(1); - RunTimers(); + EXPECT_CALL(a.cb, OnAborted).Times(1); + AdvanceTime( + a, z, + a.options.t1_cookie_timeout * (1 << *a.options.max_init_retransmits)); - EXPECT_EQ(sock_a_->state(), SocketState::kClosed); + EXPECT_EQ(a.socket.state(), SocketState::kClosed); } -TEST_F(DcSctpSocketTest, DoesntSendMorePacketsUntilCookieAckHasBeenReceived) { - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), +TEST(DcSctpSocketTest, DoesntSendMorePacketsUntilCookieAckHasBeenReceived) { + SocketUnderTest a("A"); + SocketUnderTest z("Z"); + + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), std::vector(kLargeMessageSize)), kSendOptions); - sock_a_->Connect(); + a.socket.Connect(); // Z reads INIT, produces INIT_ACK - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); // A reads INIT_ACK, produces COOKIE_ECHO - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z.cb.ConsumeSentPacket()); // COOKIE_ECHO is never received by Z. ASSERT_HAS_VALUE_AND_ASSIGN(SctpPacket cookie_echo_packet1, - SctpPacket::Parse(cb_a_.ConsumeSentPacket())); + SctpPacket::Parse(a.cb.ConsumeSentPacket())); EXPECT_THAT(cookie_echo_packet1.descriptors(), SizeIs(2)); EXPECT_EQ(cookie_echo_packet1.descriptors()[0].type, CookieEchoChunk::kType); EXPECT_EQ(cookie_echo_packet1.descriptors()[1].type, DataChunk::kType); - EXPECT_THAT(cb_a_.ConsumeSentPacket(), IsEmpty()); + EXPECT_THAT(a.cb.ConsumeSentPacket(), IsEmpty()); // There are DATA chunks in the sent packet (that was lost), which means that // the T3-RTX timer is running, but as the socket is in kCookieEcho state, it // will be T1-COOKIE that drives retransmissions, so when the T3-RTX expires, // nothing should be retransmitted. - ASSERT_TRUE(options_.rto_initial < options_.t1_cookie_timeout); - AdvanceTime(options_.rto_initial); - RunTimers(); - EXPECT_THAT(cb_a_.ConsumeSentPacket(), IsEmpty()); + ASSERT_TRUE(a.options.rto_initial < a.options.t1_cookie_timeout); + AdvanceTime(a, z, a.options.rto_initial); + EXPECT_THAT(a.cb.ConsumeSentPacket(), IsEmpty()); // When T1-COOKIE expires, both the COOKIE-ECHO and DATA should be present. - AdvanceTime(options_.t1_cookie_timeout - options_.rto_initial); - RunTimers(); + AdvanceTime(a, z, a.options.t1_cookie_timeout - a.options.rto_initial); // And this COOKIE-ECHO and DATA is also lost - never received by Z. ASSERT_HAS_VALUE_AND_ASSIGN(SctpPacket cookie_echo_packet2, - SctpPacket::Parse(cb_a_.ConsumeSentPacket())); + SctpPacket::Parse(a.cb.ConsumeSentPacket())); EXPECT_THAT(cookie_echo_packet2.descriptors(), SizeIs(2)); EXPECT_EQ(cookie_echo_packet2.descriptors()[0].type, CookieEchoChunk::kType); EXPECT_EQ(cookie_echo_packet2.descriptors()[1].type, DataChunk::kType); - EXPECT_THAT(cb_a_.ConsumeSentPacket(), IsEmpty()); + EXPECT_THAT(a.cb.ConsumeSentPacket(), IsEmpty()); // COOKIE_ECHO has exponential backoff. - AdvanceTime(options_.t1_cookie_timeout * 2); - RunTimers(); + AdvanceTime(a, z, a.options.t1_cookie_timeout * 2); // Z reads COOKIE_ECHO, produces COOKIE_ACK - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); // A reads COOKIE_ACK. - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z.cb.ConsumeSentPacket()); - EXPECT_EQ(sock_a_->state(), SocketState::kConnected); - EXPECT_EQ(sock_z_->state(), SocketState::kConnected); + EXPECT_EQ(a.socket.state(), SocketState::kConnected); + EXPECT_EQ(z.socket.state(), SocketState::kConnected); - ExchangeMessages(*sock_a_, cb_a_, *sock_z_, cb_z_); - EXPECT_THAT(cb_z_.ConsumeReceivedMessage()->payload(), + ExchangeMessages(a, z); + EXPECT_THAT(z.cb.ConsumeReceivedMessage()->payload(), SizeIs(kLargeMessageSize)); } TEST_P(DcSctpSocketParametrizedTest, ShutdownConnection) { - ConnectSockets(); - MaybeHandoverSocketZ(); + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); RTC_LOG(LS_INFO) << "Shutting down"; - EXPECT_CALL(cb_z_, OnClosed).Times(1); - sock_a_->Shutdown(); + EXPECT_CALL(z->cb, OnClosed).Times(1); + a.socket.Shutdown(); // Z reads SHUTDOWN, produces SHUTDOWN_ACK - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z->socket.ReceivePacket(a.cb.ConsumeSentPacket()); // A reads SHUTDOWN_ACK, produces SHUTDOWN_COMPLETE - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z->cb.ConsumeSentPacket()); // Z reads SHUTDOWN_COMPLETE. - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z->socket.ReceivePacket(a.cb.ConsumeSentPacket()); - EXPECT_EQ(sock_a_->state(), SocketState::kClosed); - EXPECT_EQ(sock_z_->state(), SocketState::kClosed); + EXPECT_EQ(a.socket.state(), SocketState::kClosed); + EXPECT_EQ(z->socket.state(), SocketState::kClosed); - MaybeHandoverSocketZ(); - EXPECT_EQ(sock_z_->state(), SocketState::kClosed); + z = MaybeHandoverSocket(std::move(z)); + EXPECT_EQ(z->socket.state(), SocketState::kClosed); } -TEST_F(DcSctpSocketTest, ShutdownTimerExpiresTooManyTimeClosesConnection) { - ConnectSockets(); +TEST(DcSctpSocketTest, ShutdownTimerExpiresTooManyTimeClosesConnection) { + SocketUnderTest a("A"); + SocketUnderTest z("Z"); - sock_a_->Shutdown(); + ConnectSockets(a, z); + + a.socket.Shutdown(); // Drop first SHUTDOWN packet. - cb_a_.ConsumeSentPacket(); + a.cb.ConsumeSentPacket(); - EXPECT_EQ(sock_a_->state(), SocketState::kShuttingDown); + EXPECT_EQ(a.socket.state(), SocketState::kShuttingDown); - for (int i = 0; i < *options_.max_retransmissions; ++i) { - AdvanceTime(DurationMs(options_.rto_initial * (1 << i))); - RunTimers(); + for (int i = 0; i < *a.options.max_retransmissions; ++i) { + AdvanceTime(a, z, DurationMs(a.options.rto_initial * (1 << i))); // Dropping every shutdown chunk. ASSERT_HAS_VALUE_AND_ASSIGN(SctpPacket packet, - SctpPacket::Parse(cb_a_.ConsumeSentPacket())); + SctpPacket::Parse(a.cb.ConsumeSentPacket())); EXPECT_EQ(packet.descriptors()[0].type, ShutdownChunk::kType); - EXPECT_TRUE(cb_a_.ConsumeSentPacket().empty()); + EXPECT_TRUE(a.cb.ConsumeSentPacket().empty()); } // The last expiry, makes it abort the connection. - AdvanceTime(options_.rto_initial * (1 << *options_.max_retransmissions)); - EXPECT_CALL(cb_a_, OnAborted).Times(1); - RunTimers(); + EXPECT_CALL(a.cb, OnAborted).Times(1); + AdvanceTime(a, z, + a.options.rto_initial * (1 << *a.options.max_retransmissions)); - EXPECT_EQ(sock_a_->state(), SocketState::kClosed); + EXPECT_EQ(a.socket.state(), SocketState::kClosed); ASSERT_HAS_VALUE_AND_ASSIGN(SctpPacket packet, - SctpPacket::Parse(cb_a_.ConsumeSentPacket())); + SctpPacket::Parse(a.cb.ConsumeSentPacket())); EXPECT_EQ(packet.descriptors()[0].type, AbortChunk::kType); - EXPECT_TRUE(cb_a_.ConsumeSentPacket().empty()); + EXPECT_TRUE(a.cb.ConsumeSentPacket().empty()); } -TEST_F(DcSctpSocketTest, EstablishConnectionWhileSendingData) { - sock_a_->Connect(); +TEST(DcSctpSocketTest, EstablishConnectionWhileSendingData) { + SocketUnderTest a("A"); + SocketUnderTest z("Z"); + + a.socket.Connect(); - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), {1, 2}), kSendOptions); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), {1, 2}), kSendOptions); // Z reads INIT, produces INIT_ACK - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); // // A reads INIT_ACK, produces COOKIE_ECHO - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z.cb.ConsumeSentPacket()); // // Z reads COOKIE_ECHO, produces COOKIE_ACK - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); // // A reads COOKIE_ACK. - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z.cb.ConsumeSentPacket()); - EXPECT_EQ(sock_a_->state(), SocketState::kConnected); - EXPECT_EQ(sock_z_->state(), SocketState::kConnected); + EXPECT_EQ(a.socket.state(), SocketState::kConnected); + EXPECT_EQ(z.socket.state(), SocketState::kConnected); - absl::optional msg = cb_z_.ConsumeReceivedMessage(); + absl::optional msg = z.cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg.has_value()); EXPECT_EQ(msg->stream_id(), StreamID(1)); } -TEST_F(DcSctpSocketTest, SendMessageAfterEstablished) { - ConnectSockets(); +TEST(DcSctpSocketTest, SendMessageAfterEstablished) { + SocketUnderTest a("A"); + SocketUnderTest z("Z"); - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), {1, 2}), kSendOptions); - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + ConnectSockets(a, z); - absl::optional msg = cb_z_.ConsumeReceivedMessage(); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), {1, 2}), kSendOptions); + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); + + absl::optional msg = z.cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg.has_value()); EXPECT_EQ(msg->stream_id(), StreamID(1)); } TEST_P(DcSctpSocketParametrizedTest, TimeoutResendsPacket) { - ConnectSockets(); - MaybeHandoverSocketZ(); + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), {1, 2}), kSendOptions); - cb_a_.ConsumeSentPacket(); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), {1, 2}), kSendOptions); + a.cb.ConsumeSentPacket(); RTC_LOG(LS_INFO) << "Advancing time"; - AdvanceTime(options_.rto_initial); - RunTimers(); + AdvanceTime(a, *z, a.options.rto_initial); - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z->socket.ReceivePacket(a.cb.ConsumeSentPacket()); - absl::optional msg = cb_z_.ConsumeReceivedMessage(); + absl::optional msg = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg.has_value()); EXPECT_EQ(msg->stream_id(), StreamID(1)); - MaybeHandoverSocketZAndSendMessage(); + MaybeHandoverSocketAndSendMessage(a, std::move(z)); } TEST_P(DcSctpSocketParametrizedTest, SendALotOfBytesMissedSecondPacket) { - ConnectSockets(); - MaybeHandoverSocketZ(); + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); std::vector payload(kLargeMessageSize); - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), payload), kSendOptions); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), payload), kSendOptions); // First DATA - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z->socket.ReceivePacket(a.cb.ConsumeSentPacket()); // Second DATA (lost) - cb_a_.ConsumeSentPacket(); + a.cb.ConsumeSentPacket(); // Retransmit and handle the rest - ExchangeMessages(*sock_a_, cb_a_, *sock_z_, cb_z_); + ExchangeMessages(a, *z); - absl::optional msg = cb_z_.ConsumeReceivedMessage(); + absl::optional msg = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg.has_value()); EXPECT_EQ(msg->stream_id(), StreamID(1)); EXPECT_THAT(msg->payload(), testing::ElementsAreArray(payload)); - MaybeHandoverSocketZAndSendMessage(); + MaybeHandoverSocketAndSendMessage(a, std::move(z)); } TEST_P(DcSctpSocketParametrizedTest, SendingHeartbeatAnswersWithAck) { - ConnectSockets(); - MaybeHandoverSocketZ(); + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); // Inject a HEARTBEAT chunk - SctpPacket::Builder b(sock_a_->verification_tag(), DcSctpOptions()); + SctpPacket::Builder b(a.socket.verification_tag(), DcSctpOptions()); uint8_t info[] = {1, 2, 3, 4}; Parameters::Builder params_builder; params_builder.Add(HeartbeatInfoParameter(info)); b.Add(HeartbeatRequestChunk(params_builder.Build())); - sock_a_->ReceivePacket(b.Build()); + a.socket.ReceivePacket(b.Build()); // HEARTBEAT_ACK is sent as a reply. Capture it. ASSERT_HAS_VALUE_AND_ASSIGN(SctpPacket ack_packet, - SctpPacket::Parse(cb_a_.ConsumeSentPacket())); + SctpPacket::Parse(a.cb.ConsumeSentPacket())); ASSERT_THAT(ack_packet.descriptors(), SizeIs(1)); ASSERT_HAS_VALUE_AND_ASSIGN( HeartbeatAckChunk ack, @@ -844,19 +875,21 @@ TEST_P(DcSctpSocketParametrizedTest, SendingHeartbeatAnswersWithAck) { ASSERT_HAS_VALUE_AND_ASSIGN(HeartbeatInfoParameter info_param, ack.info()); EXPECT_THAT(info_param.info(), ElementsAre(1, 2, 3, 4)); - MaybeHandoverSocketZAndSendMessage(); + MaybeHandoverSocketAndSendMessage(a, std::move(z)); } TEST_P(DcSctpSocketParametrizedTest, ExpectHeartbeatToBeSent) { - ConnectSockets(); - MaybeHandoverSocketZ(); + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); - EXPECT_THAT(cb_a_.ConsumeSentPacket(), IsEmpty()); + EXPECT_THAT(a.cb.ConsumeSentPacket(), IsEmpty()); - AdvanceTime(options_.heartbeat_interval); - RunTimers(); + AdvanceTime(a, *z, a.options.heartbeat_interval); - std::vector hb_packet_raw = cb_a_.ConsumeSentPacket(); + std::vector hb_packet_raw = a.cb.ConsumeSentPacket(); ASSERT_HAS_VALUE_AND_ASSIGN(SctpPacket hb_packet, SctpPacket::Parse(hb_packet_raw)); ASSERT_THAT(hb_packet.descriptors(), SizeIs(1)); @@ -869,86 +902,85 @@ TEST_P(DcSctpSocketParametrizedTest, ExpectHeartbeatToBeSent) { EXPECT_THAT(hb.info()->info(), SizeIs(8)); // Feed it to Sock-z and expect a HEARTBEAT_ACK that will be propagated back. - sock_z_->ReceivePacket(hb_packet_raw); - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + z->socket.ReceivePacket(hb_packet_raw); + a.socket.ReceivePacket(z->cb.ConsumeSentPacket()); - MaybeHandoverSocketZAndSendMessage(); + MaybeHandoverSocketAndSendMessage(a, std::move(z)); } TEST_P(DcSctpSocketParametrizedTest, CloseConnectionAfterTooManyLostHeartbeats) { - ConnectSockets(); - MaybeHandoverSocketZ(); + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); - EXPECT_CALL(cb_z_, OnClosed).Times(1); - EXPECT_THAT(cb_a_.ConsumeSentPacket(), testing::IsEmpty()); + EXPECT_CALL(z->cb, OnClosed).Times(1); + EXPECT_THAT(a.cb.ConsumeSentPacket(), testing::IsEmpty()); // Force-close socket Z so that it doesn't interfere from now on. - sock_z_->Close(); + z->socket.Close(); - DurationMs time_to_next_hearbeat = options_.heartbeat_interval; + DurationMs time_to_next_hearbeat = a.options.heartbeat_interval; - for (int i = 0; i < *options_.max_retransmissions; ++i) { + for (int i = 0; i < *a.options.max_retransmissions; ++i) { RTC_LOG(LS_INFO) << "Letting HEARTBEAT interval timer expire - sending..."; - AdvanceTime(time_to_next_hearbeat); - RunTimers(); + AdvanceTime(a, *z, time_to_next_hearbeat); // Dropping every heartbeat. ASSERT_HAS_VALUE_AND_ASSIGN(SctpPacket hb_packet, - SctpPacket::Parse(cb_a_.ConsumeSentPacket())); + SctpPacket::Parse(a.cb.ConsumeSentPacket())); EXPECT_EQ(hb_packet.descriptors()[0].type, HeartbeatRequestChunk::kType); RTC_LOG(LS_INFO) << "Letting the heartbeat expire."; - AdvanceTime(DurationMs(1000)); - RunTimers(); + AdvanceTime(a, *z, DurationMs(1000)); - time_to_next_hearbeat = options_.heartbeat_interval - DurationMs(1000); + time_to_next_hearbeat = a.options.heartbeat_interval - DurationMs(1000); } RTC_LOG(LS_INFO) << "Letting HEARTBEAT interval timer expire - sending..."; - AdvanceTime(time_to_next_hearbeat); - RunTimers(); + AdvanceTime(a, *z, time_to_next_hearbeat); // Last heartbeat - EXPECT_THAT(cb_a_.ConsumeSentPacket(), Not(IsEmpty())); + EXPECT_THAT(a.cb.ConsumeSentPacket(), Not(IsEmpty())); - EXPECT_CALL(cb_a_, OnAborted).Times(1); + EXPECT_CALL(a.cb, OnAborted).Times(1); // Should suffice as exceeding RTO - AdvanceTime(DurationMs(1000)); - RunTimers(); + AdvanceTime(a, *z, DurationMs(1000)); - MaybeHandoverSocketZ(); + z = MaybeHandoverSocket(std::move(z)); } TEST_P(DcSctpSocketParametrizedTest, RecoversAfterASuccessfulAck) { - ConnectSockets(); - MaybeHandoverSocketZ(); + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); - EXPECT_THAT(cb_a_.ConsumeSentPacket(), testing::IsEmpty()); - EXPECT_CALL(cb_z_, OnClosed).Times(1); + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); + + EXPECT_THAT(a.cb.ConsumeSentPacket(), testing::IsEmpty()); + EXPECT_CALL(z->cb, OnClosed).Times(1); // Force-close socket Z so that it doesn't interfere from now on. - sock_z_->Close(); + z->socket.Close(); - DurationMs time_to_next_hearbeat = options_.heartbeat_interval; + DurationMs time_to_next_hearbeat = a.options.heartbeat_interval; - for (int i = 0; i < *options_.max_retransmissions; ++i) { - AdvanceTime(time_to_next_hearbeat); - RunTimers(); + for (int i = 0; i < *a.options.max_retransmissions; ++i) { + AdvanceTime(a, *z, time_to_next_hearbeat); // Dropping every heartbeat. - cb_a_.ConsumeSentPacket(); + a.cb.ConsumeSentPacket(); RTC_LOG(LS_INFO) << "Letting the heartbeat expire."; - AdvanceTime(DurationMs(1000)); - RunTimers(); + AdvanceTime(a, *z, DurationMs(1000)); - time_to_next_hearbeat = options_.heartbeat_interval - DurationMs(1000); + time_to_next_hearbeat = a.options.heartbeat_interval - DurationMs(1000); } RTC_LOG(LS_INFO) << "Getting the last heartbeat - and acking it"; - AdvanceTime(time_to_next_hearbeat); - RunTimers(); + AdvanceTime(a, *z, time_to_next_hearbeat); - std::vector hb_packet_raw = cb_a_.ConsumeSentPacket(); + std::vector hb_packet_raw = a.cb.ConsumeSentPacket(); ASSERT_HAS_VALUE_AND_ASSIGN(SctpPacket hb_packet, SctpPacket::Parse(hb_packet_raw)); ASSERT_THAT(hb_packet.descriptors(), SizeIs(1)); @@ -956,350 +988,363 @@ TEST_P(DcSctpSocketParametrizedTest, RecoversAfterASuccessfulAck) { HeartbeatRequestChunk hb, HeartbeatRequestChunk::Parse(hb_packet.descriptors()[0].data)); - SctpPacket::Builder b(sock_a_->verification_tag(), options_); + SctpPacket::Builder b(a.socket.verification_tag(), a.options); b.Add(HeartbeatAckChunk(std::move(hb).extract_parameters())); - sock_a_->ReceivePacket(b.Build()); + a.socket.ReceivePacket(b.Build()); // Should suffice as exceeding RTO - which will not fire. - EXPECT_CALL(cb_a_, OnAborted).Times(0); - AdvanceTime(DurationMs(1000)); - RunTimers(); - EXPECT_THAT(cb_a_.ConsumeSentPacket(), IsEmpty()); + EXPECT_CALL(a.cb, OnAborted).Times(0); + AdvanceTime(a, *z, DurationMs(1000)); + + EXPECT_THAT(a.cb.ConsumeSentPacket(), IsEmpty()); // Verify that we get new heartbeats again. RTC_LOG(LS_INFO) << "Expecting a new heartbeat"; - AdvanceTime(time_to_next_hearbeat); - RunTimers(); + AdvanceTime(a, *z, time_to_next_hearbeat); ASSERT_HAS_VALUE_AND_ASSIGN(SctpPacket another_packet, - SctpPacket::Parse(cb_a_.ConsumeSentPacket())); + SctpPacket::Parse(a.cb.ConsumeSentPacket())); EXPECT_EQ(another_packet.descriptors()[0].type, HeartbeatRequestChunk::kType); } TEST_P(DcSctpSocketParametrizedTest, ResetStream) { - ConnectSockets(); - MaybeHandoverSocketZ(); + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), {1, 2}), {}); - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), {1, 2}), {}); + z->socket.ReceivePacket(a.cb.ConsumeSentPacket()); - absl::optional msg = cb_z_.ConsumeReceivedMessage(); + absl::optional msg = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg.has_value()); EXPECT_EQ(msg->stream_id(), StreamID(1)); // Handle SACK - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z->cb.ConsumeSentPacket()); // Reset the outgoing stream. This will directly send a RE-CONFIG. - sock_a_->ResetStreams(std::vector({StreamID(1)})); + a.socket.ResetStreams(std::vector({StreamID(1)})); // Receiving the packet will trigger a callback, indicating that A has // reset its stream. It will also send a RE-CONFIG with a response. - EXPECT_CALL(cb_z_, OnIncomingStreamsReset).Times(1); - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + EXPECT_CALL(z->cb, OnIncomingStreamsReset).Times(1); + z->socket.ReceivePacket(a.cb.ConsumeSentPacket()); // Receiving a response will trigger a callback. Streams are now reset. - EXPECT_CALL(cb_a_, OnStreamsResetPerformed).Times(1); - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + EXPECT_CALL(a.cb, OnStreamsResetPerformed).Times(1); + a.socket.ReceivePacket(z->cb.ConsumeSentPacket()); - MaybeHandoverSocketZAndSendMessage(); + MaybeHandoverSocketAndSendMessage(a, std::move(z)); } TEST_P(DcSctpSocketParametrizedTest, ResetStreamWillMakeChunksStartAtZeroSsn) { - ConnectSockets(); - MaybeHandoverSocketZ(); + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); - std::vector payload(options_.mtu - 100); + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), payload), {}); - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), payload), {}); + std::vector payload(a.options.mtu - 100); - auto packet1 = cb_a_.ConsumeSentPacket(); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), payload), {}); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), payload), {}); + + auto packet1 = a.cb.ConsumeSentPacket(); EXPECT_THAT(packet1, HasDataChunkWithSsn(SSN(0))); - sock_z_->ReceivePacket(packet1); + z->socket.ReceivePacket(packet1); - auto packet2 = cb_a_.ConsumeSentPacket(); + auto packet2 = a.cb.ConsumeSentPacket(); EXPECT_THAT(packet2, HasDataChunkWithSsn(SSN(1))); - sock_z_->ReceivePacket(packet2); + z->socket.ReceivePacket(packet2); // Handle SACK - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z->cb.ConsumeSentPacket()); - absl::optional msg1 = cb_z_.ConsumeReceivedMessage(); + absl::optional msg1 = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg1.has_value()); EXPECT_EQ(msg1->stream_id(), StreamID(1)); - absl::optional msg2 = cb_z_.ConsumeReceivedMessage(); + absl::optional msg2 = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg2.has_value()); EXPECT_EQ(msg2->stream_id(), StreamID(1)); // Reset the outgoing stream. This will directly send a RE-CONFIG. - sock_a_->ResetStreams(std::vector({StreamID(1)})); + a.socket.ResetStreams(std::vector({StreamID(1)})); // RE-CONFIG, req - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z->socket.ReceivePacket(a.cb.ConsumeSentPacket()); // RE-CONFIG, resp - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z->cb.ConsumeSentPacket()); - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), payload), {}); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), payload), {}); - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), payload), {}); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), payload), {}); - auto packet3 = cb_a_.ConsumeSentPacket(); + auto packet3 = a.cb.ConsumeSentPacket(); EXPECT_THAT(packet3, HasDataChunkWithSsn(SSN(0))); - sock_z_->ReceivePacket(packet3); + z->socket.ReceivePacket(packet3); - auto packet4 = cb_a_.ConsumeSentPacket(); + auto packet4 = a.cb.ConsumeSentPacket(); EXPECT_THAT(packet4, HasDataChunkWithSsn(SSN(1))); - sock_z_->ReceivePacket(packet4); + z->socket.ReceivePacket(packet4); // Handle SACK - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z->cb.ConsumeSentPacket()); - MaybeHandoverSocketZAndSendMessage(); + MaybeHandoverSocketAndSendMessage(a, std::move(z)); } TEST_P(DcSctpSocketParametrizedTest, ResetStreamWillOnlyResetTheRequestedStreams) { - ConnectSockets(); - MaybeHandoverSocketZ(); + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); - std::vector payload(options_.mtu - 100); + std::vector payload(a.options.mtu - 100); // Send two ordered messages on SID 1 - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), payload), {}); - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), payload), {}); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), payload), {}); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), payload), {}); - auto packet1 = cb_a_.ConsumeSentPacket(); + auto packet1 = a.cb.ConsumeSentPacket(); EXPECT_THAT(packet1, HasDataChunkWithStreamId(StreamID(1))); EXPECT_THAT(packet1, HasDataChunkWithSsn(SSN(0))); - sock_z_->ReceivePacket(packet1); + z->socket.ReceivePacket(packet1); - auto packet2 = cb_a_.ConsumeSentPacket(); + auto packet2 = a.cb.ConsumeSentPacket(); EXPECT_THAT(packet1, HasDataChunkWithStreamId(StreamID(1))); EXPECT_THAT(packet2, HasDataChunkWithSsn(SSN(1))); - sock_z_->ReceivePacket(packet2); + z->socket.ReceivePacket(packet2); // Handle SACK - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z->cb.ConsumeSentPacket()); // Do the same, for SID 3 - sock_a_->Send(DcSctpMessage(StreamID(3), PPID(53), payload), {}); - sock_a_->Send(DcSctpMessage(StreamID(3), PPID(53), payload), {}); - auto packet3 = cb_a_.ConsumeSentPacket(); + a.socket.Send(DcSctpMessage(StreamID(3), PPID(53), payload), {}); + a.socket.Send(DcSctpMessage(StreamID(3), PPID(53), payload), {}); + auto packet3 = a.cb.ConsumeSentPacket(); EXPECT_THAT(packet3, HasDataChunkWithStreamId(StreamID(3))); EXPECT_THAT(packet3, HasDataChunkWithSsn(SSN(0))); - sock_z_->ReceivePacket(packet3); - auto packet4 = cb_a_.ConsumeSentPacket(); + z->socket.ReceivePacket(packet3); + auto packet4 = a.cb.ConsumeSentPacket(); EXPECT_THAT(packet4, HasDataChunkWithStreamId(StreamID(3))); EXPECT_THAT(packet4, HasDataChunkWithSsn(SSN(1))); - sock_z_->ReceivePacket(packet4); - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + z->socket.ReceivePacket(packet4); + a.socket.ReceivePacket(z->cb.ConsumeSentPacket()); // Receive all messages. - absl::optional msg1 = cb_z_.ConsumeReceivedMessage(); + absl::optional msg1 = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg1.has_value()); EXPECT_EQ(msg1->stream_id(), StreamID(1)); - absl::optional msg2 = cb_z_.ConsumeReceivedMessage(); + absl::optional msg2 = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg2.has_value()); EXPECT_EQ(msg2->stream_id(), StreamID(1)); - absl::optional msg3 = cb_z_.ConsumeReceivedMessage(); + absl::optional msg3 = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg3.has_value()); EXPECT_EQ(msg3->stream_id(), StreamID(3)); - absl::optional msg4 = cb_z_.ConsumeReceivedMessage(); + absl::optional msg4 = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg4.has_value()); EXPECT_EQ(msg4->stream_id(), StreamID(3)); // Reset SID 1. This will directly send a RE-CONFIG. - sock_a_->ResetStreams(std::vector({StreamID(3)})); + a.socket.ResetStreams(std::vector({StreamID(3)})); // RE-CONFIG, req - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z->socket.ReceivePacket(a.cb.ConsumeSentPacket()); // RE-CONFIG, resp - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z->cb.ConsumeSentPacket()); // Send a message on SID 1 and 3 - SID 1 should not be reset, but 3 should. - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), payload), {}); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), payload), {}); - sock_a_->Send(DcSctpMessage(StreamID(3), PPID(53), payload), {}); + a.socket.Send(DcSctpMessage(StreamID(3), PPID(53), payload), {}); - auto packet5 = cb_a_.ConsumeSentPacket(); + auto packet5 = a.cb.ConsumeSentPacket(); EXPECT_THAT(packet5, HasDataChunkWithStreamId(StreamID(1))); EXPECT_THAT(packet5, HasDataChunkWithSsn(SSN(2))); // Unchanged. - sock_z_->ReceivePacket(packet5); + z->socket.ReceivePacket(packet5); - auto packet6 = cb_a_.ConsumeSentPacket(); + auto packet6 = a.cb.ConsumeSentPacket(); EXPECT_THAT(packet6, HasDataChunkWithStreamId(StreamID(3))); EXPECT_THAT(packet6, HasDataChunkWithSsn(SSN(0))); // Reset. - sock_z_->ReceivePacket(packet6); + z->socket.ReceivePacket(packet6); // Handle SACK - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z->cb.ConsumeSentPacket()); - MaybeHandoverSocketZAndSendMessage(); + MaybeHandoverSocketAndSendMessage(a, std::move(z)); } TEST_P(DcSctpSocketParametrizedTest, OnePeerReconnects) { - ConnectSockets(); - MaybeHandoverSocketZ(); + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); - EXPECT_CALL(cb_a_, OnConnectionRestarted).Times(1); + EXPECT_CALL(a.cb, OnConnectionRestarted).Times(1); // Let's be evil here - reconnect while a fragmented packet was about to be // sent. The receiving side should get it in full. std::vector payload(kLargeMessageSize); - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), payload), kSendOptions); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), payload), kSendOptions); // First DATA - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z->socket.ReceivePacket(a.cb.ConsumeSentPacket()); // Create a new association, z2 - and don't use z anymore. - testing::NiceMock cb_z2("Z2"); - DcSctpSocket sock_z2("Z2", cb_z2, nullptr, options_); - - sock_z2.Connect(); + SocketUnderTest z2("Z2"); + z2.socket.Connect(); // Retransmit and handle the rest. As there will be some chunks in-flight that // have the wrong verification tag, those will yield errors. - ExchangeMessages(*sock_a_, cb_a_, sock_z2, cb_z2); + ExchangeMessages(a, z2); - absl::optional msg = cb_z2.ConsumeReceivedMessage(); + absl::optional msg = z2.cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg.has_value()); EXPECT_EQ(msg->stream_id(), StreamID(1)); EXPECT_THAT(msg->payload(), testing::ElementsAreArray(payload)); } TEST_P(DcSctpSocketParametrizedTest, SendMessageWithLimitedRtx) { - ConnectSockets(); - MaybeHandoverSocketZ(); + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); SendOptions send_options; send_options.max_retransmissions = 0; - std::vector payload(options_.mtu - 100); - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(51), payload), send_options); - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(52), payload), send_options); - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), payload), send_options); + std::vector payload(a.options.mtu - 100); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(51), payload), send_options); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(52), payload), send_options); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), payload), send_options); // First DATA - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z->socket.ReceivePacket(a.cb.ConsumeSentPacket()); // Second DATA (lost) - cb_a_.ConsumeSentPacket(); + a.cb.ConsumeSentPacket(); // Third DATA - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z->socket.ReceivePacket(a.cb.ConsumeSentPacket()); // Handle SACK for first DATA - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z->cb.ConsumeSentPacket()); // Handle delayed SACK for third DATA - AdvanceTime(options_.delayed_ack_max_timeout); - RunTimers(); + AdvanceTime(a, *z, a.options.delayed_ack_max_timeout); // Handle SACK for second DATA - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z->cb.ConsumeSentPacket()); // Now the missing data chunk will be marked as nacked, but it might still be // in-flight and the reported gap could be due to out-of-order delivery. So // the RetransmissionQueue will not mark it as "to be retransmitted" until // after the t3-rtx timer has expired. - AdvanceTime(options_.rto_initial); - RunTimers(); + AdvanceTime(a, *z, a.options.rto_initial); // The chunk will be marked as retransmitted, and then as abandoned, which // will trigger a FORWARD-TSN to be sent. // FORWARD-TSN (third) - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z->socket.ReceivePacket(a.cb.ConsumeSentPacket()); // Which will trigger a SACK - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); + a.socket.ReceivePacket(z->cb.ConsumeSentPacket()); - absl::optional msg1 = cb_z_.ConsumeReceivedMessage(); + absl::optional msg1 = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg1.has_value()); EXPECT_EQ(msg1->ppid(), PPID(51)); - absl::optional msg2 = cb_z_.ConsumeReceivedMessage(); + absl::optional msg2 = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg2.has_value()); EXPECT_EQ(msg2->ppid(), PPID(53)); - absl::optional msg3 = cb_z_.ConsumeReceivedMessage(); + absl::optional msg3 = z->cb.ConsumeReceivedMessage(); EXPECT_FALSE(msg3.has_value()); - MaybeHandoverSocketZAndSendMessage(); + MaybeHandoverSocketAndSendMessage(a, std::move(z)); } TEST_P(DcSctpSocketParametrizedTest, SendManyFragmentedMessagesWithLimitedRtx) { - ConnectSockets(); - MaybeHandoverSocketZ(); + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); SendOptions send_options; send_options.unordered = IsUnordered(true); send_options.max_retransmissions = 0; - std::vector payload(options_.mtu * 2 - 100 /* margin */); + std::vector payload(a.options.mtu * 2 - 100 /* margin */); // Sending first message - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(51), payload), send_options); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(51), payload), send_options); // Sending second message - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(52), payload), send_options); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(52), payload), send_options); // Sending third message - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), payload), send_options); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), payload), send_options); // Sending fourth message - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(54), payload), send_options); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(54), payload), send_options); // First DATA, first fragment - std::vector packet = cb_a_.ConsumeSentPacket(); + std::vector packet = a.cb.ConsumeSentPacket(); EXPECT_THAT(packet, HasDataChunkWithPPID(PPID(51))); - sock_z_->ReceivePacket(std::move(packet)); + z->socket.ReceivePacket(std::move(packet)); // First DATA, second fragment (lost) - packet = cb_a_.ConsumeSentPacket(); + packet = a.cb.ConsumeSentPacket(); EXPECT_THAT(packet, HasDataChunkWithPPID(PPID(51))); // Second DATA, first fragment - packet = cb_a_.ConsumeSentPacket(); + packet = a.cb.ConsumeSentPacket(); EXPECT_THAT(packet, HasDataChunkWithPPID(PPID(52))); - sock_z_->ReceivePacket(std::move(packet)); + z->socket.ReceivePacket(std::move(packet)); // Second DATA, second fragment (lost) - packet = cb_a_.ConsumeSentPacket(); + packet = a.cb.ConsumeSentPacket(); EXPECT_THAT(packet, HasDataChunkWithPPID(PPID(52))); EXPECT_THAT(packet, HasDataChunkWithSsn(SSN(0))); // Third DATA, first fragment - packet = cb_a_.ConsumeSentPacket(); + packet = a.cb.ConsumeSentPacket(); EXPECT_THAT(packet, HasDataChunkWithPPID(PPID(53))); EXPECT_THAT(packet, HasDataChunkWithSsn(SSN(0))); - sock_z_->ReceivePacket(std::move(packet)); + z->socket.ReceivePacket(std::move(packet)); // Third DATA, second fragment (lost) - packet = cb_a_.ConsumeSentPacket(); + packet = a.cb.ConsumeSentPacket(); EXPECT_THAT(packet, HasDataChunkWithPPID(PPID(53))); EXPECT_THAT(packet, HasDataChunkWithSsn(SSN(0))); // Fourth DATA, first fragment - packet = cb_a_.ConsumeSentPacket(); + packet = a.cb.ConsumeSentPacket(); EXPECT_THAT(packet, HasDataChunkWithPPID(PPID(54))); EXPECT_THAT(packet, HasDataChunkWithSsn(SSN(0))); - sock_z_->ReceivePacket(std::move(packet)); + z->socket.ReceivePacket(std::move(packet)); // Fourth DATA, second fragment - packet = cb_a_.ConsumeSentPacket(); + packet = a.cb.ConsumeSentPacket(); EXPECT_THAT(packet, HasDataChunkWithPPID(PPID(54))); EXPECT_THAT(packet, HasDataChunkWithSsn(SSN(0))); - sock_z_->ReceivePacket(std::move(packet)); + z->socket.ReceivePacket(std::move(packet)); - ExchangeMessages(*sock_a_, cb_a_, *sock_z_, cb_z_); + ExchangeMessages(a, *z); // Let the RTX timer expire, and exchange FORWARD-TSN/SACKs - AdvanceTime(options_.rto_initial); - RunTimers(); - ExchangeMessages(*sock_a_, cb_a_, *sock_z_, cb_z_); + AdvanceTime(a, *z, a.options.rto_initial); - absl::optional msg1 = cb_z_.ConsumeReceivedMessage(); + ExchangeMessages(a, *z); + + absl::optional msg1 = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg1.has_value()); EXPECT_EQ(msg1->ppid(), PPID(54)); - ASSERT_FALSE(cb_z_.ConsumeReceivedMessage().has_value()); + ASSERT_FALSE(z->cb.ConsumeReceivedMessage().has_value()); - MaybeHandoverSocketZAndSendMessage(); + MaybeHandoverSocketAndSendMessage(a, std::move(z)); } struct FakeChunkConfig : ChunkConfig { @@ -1322,17 +1367,20 @@ class FakeChunk : public Chunk, public TLVTrait { }; TEST_P(DcSctpSocketParametrizedTest, ReceivingUnknownChunkRespondsWithError) { - ConnectSockets(); - MaybeHandoverSocketZ(); + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); // Inject a FAKE chunk - SctpPacket::Builder b(sock_a_->verification_tag(), DcSctpOptions()); + SctpPacket::Builder b(a.socket.verification_tag(), DcSctpOptions()); b.Add(FakeChunk()); - sock_a_->ReceivePacket(b.Build()); + a.socket.ReceivePacket(b.Build()); // ERROR is sent as a reply. Capture it. ASSERT_HAS_VALUE_AND_ASSIGN(SctpPacket reply_packet, - SctpPacket::Parse(cb_a_.ConsumeSentPacket())); + SctpPacket::Parse(a.cb.ConsumeSentPacket())); ASSERT_THAT(reply_packet.descriptors(), SizeIs(1)); ASSERT_HAS_VALUE_AND_ASSIGN( ErrorChunk error, ErrorChunk::Parse(reply_packet.descriptors()[0].data)); @@ -1341,50 +1389,52 @@ TEST_P(DcSctpSocketParametrizedTest, ReceivingUnknownChunkRespondsWithError) { error.error_causes().get()); EXPECT_THAT(cause.unrecognized_chunk(), ElementsAre(0x49, 0x00, 0x00, 0x04)); - MaybeHandoverSocketZAndSendMessage(); + MaybeHandoverSocketAndSendMessage(a, std::move(z)); } TEST_P(DcSctpSocketParametrizedTest, ReceivingErrorChunkReportsAsCallback) { - ConnectSockets(); - MaybeHandoverSocketZ(); + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); // Inject a ERROR chunk - SctpPacket::Builder b(sock_a_->verification_tag(), DcSctpOptions()); + SctpPacket::Builder b(a.socket.verification_tag(), DcSctpOptions()); b.Add( ErrorChunk(Parameters::Builder() .Add(UnrecognizedChunkTypeCause({0x49, 0x00, 0x00, 0x04})) .Build())); - EXPECT_CALL(cb_a_, OnError(ErrorKind::kPeerReported, - HasSubstr("Unrecognized Chunk Type"))); - sock_a_->ReceivePacket(b.Build()); + EXPECT_CALL(a.cb, OnError(ErrorKind::kPeerReported, + HasSubstr("Unrecognized Chunk Type"))); + a.socket.ReceivePacket(b.Build()); - MaybeHandoverSocketZAndSendMessage(); + MaybeHandoverSocketAndSendMessage(a, std::move(z)); } -TEST_F(DcSctpSocketTest, PassingHighWatermarkWillOnlyAcceptCumAckTsn) { - // Create a new association, z2 - and don't use z anymore. - testing::NiceMock cb_z2("Z2"); - DcSctpOptions options = options_; +TEST(DcSctpSocketTest, PassingHighWatermarkWillOnlyAcceptCumAckTsn) { + SocketUnderTest a("A"); + constexpr size_t kReceiveWindowBufferSize = 2000; - options.max_receiver_window_buffer_size = kReceiveWindowBufferSize; - options.mtu = 3000; - DcSctpSocket sock_z2("Z2", cb_z2, nullptr, options); + SocketUnderTest z( + "Z", {.mtu = 3000, + .max_receiver_window_buffer_size = kReceiveWindowBufferSize}); - EXPECT_CALL(cb_z2, OnClosed).Times(0); - EXPECT_CALL(cb_z2, OnAborted).Times(0); + EXPECT_CALL(z.cb, OnClosed).Times(0); + EXPECT_CALL(z.cb, OnAborted).Times(0); - sock_a_->Connect(); - std::vector init_data = cb_a_.ConsumeSentPacket(); + a.socket.Connect(); + std::vector init_data = a.cb.ConsumeSentPacket(); ASSERT_HAS_VALUE_AND_ASSIGN(SctpPacket init_packet, SctpPacket::Parse(init_data)); ASSERT_HAS_VALUE_AND_ASSIGN( InitChunk init_chunk, InitChunk::Parse(init_packet.descriptors()[0].data)); - sock_z2.ReceivePacket(init_data); - sock_a_->ReceivePacket(cb_z2.ConsumeSentPacket()); - sock_z2.ReceivePacket(cb_a_.ConsumeSentPacket()); - sock_a_->ReceivePacket(cb_z2.ConsumeSentPacket()); + z.socket.ReceivePacket(init_data); + a.socket.ReceivePacket(z.cb.ConsumeSentPacket()); + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); + a.socket.ReceivePacket(z.cb.ConsumeSentPacket()); // Fill up Z2 to the high watermark limit. constexpr size_t kWatermarkLimit = @@ -1394,99 +1444,105 @@ TEST_F(DcSctpSocketTest, PassingHighWatermarkWillOnlyAcceptCumAckTsn) { TSN tsn = init_chunk.initial_tsn(); AnyDataChunk::Options opts; opts.is_beginning = Data::IsBeginning(true); - sock_z2.ReceivePacket( - SctpPacket::Builder(sock_z2.verification_tag(), options) + z.socket.ReceivePacket( + SctpPacket::Builder(z.socket.verification_tag(), z.options) .Add(DataChunk(tsn, StreamID(1), SSN(0), PPID(53), std::vector(kWatermarkLimit + 1), opts)) .Build()); // First DATA will always trigger a SACK. It's not interesting. - EXPECT_THAT(cb_z2.ConsumeSentPacket(), + EXPECT_THAT(z.cb.ConsumeSentPacket(), AllOf(HasSackWithCumAckTsn(tsn), HasSackWithNoGapAckBlocks())); // This DATA should be accepted - it's advancing cum ack tsn. - sock_z2.ReceivePacket(SctpPacket::Builder(sock_z2.verification_tag(), options) - .Add(DataChunk(AddTo(tsn, 1), StreamID(1), SSN(0), - PPID(53), std::vector(1), - /*options=*/{})) - .Build()); + z.socket.ReceivePacket( + SctpPacket::Builder(z.socket.verification_tag(), z.options) + .Add(DataChunk(AddTo(tsn, 1), StreamID(1), SSN(0), PPID(53), + std::vector(1), + /*options=*/{})) + .Build()); // The receiver might have moved into delayed ack mode. - cb_z2.AdvanceTime(options.rto_initial); - RunTimers(cb_z2, sock_z2); + AdvanceTime(a, z, z.options.rto_initial); EXPECT_THAT( - cb_z2.ConsumeSentPacket(), + z.cb.ConsumeSentPacket(), AllOf(HasSackWithCumAckTsn(AddTo(tsn, 1)), HasSackWithNoGapAckBlocks())); // This DATA will not be accepted - it's not advancing cum ack tsn. - sock_z2.ReceivePacket(SctpPacket::Builder(sock_z2.verification_tag(), options) - .Add(DataChunk(AddTo(tsn, 3), StreamID(1), SSN(0), - PPID(53), std::vector(1), - /*options=*/{})) - .Build()); + z.socket.ReceivePacket( + SctpPacket::Builder(z.socket.verification_tag(), z.options) + .Add(DataChunk(AddTo(tsn, 3), StreamID(1), SSN(0), PPID(53), + std::vector(1), + /*options=*/{})) + .Build()); // Sack will be sent in IMMEDIATE mode when this is happening. EXPECT_THAT( - cb_z2.ConsumeSentPacket(), + z.cb.ConsumeSentPacket(), AllOf(HasSackWithCumAckTsn(AddTo(tsn, 1)), HasSackWithNoGapAckBlocks())); // This DATA will not be accepted either. - sock_z2.ReceivePacket(SctpPacket::Builder(sock_z2.verification_tag(), options) - .Add(DataChunk(AddTo(tsn, 4), StreamID(1), SSN(0), - PPID(53), std::vector(1), - /*options=*/{})) - .Build()); + z.socket.ReceivePacket( + SctpPacket::Builder(z.socket.verification_tag(), z.options) + .Add(DataChunk(AddTo(tsn, 4), StreamID(1), SSN(0), PPID(53), + std::vector(1), + /*options=*/{})) + .Build()); // Sack will be sent in IMMEDIATE mode when this is happening. EXPECT_THAT( - cb_z2.ConsumeSentPacket(), + z.cb.ConsumeSentPacket(), AllOf(HasSackWithCumAckTsn(AddTo(tsn, 1)), HasSackWithNoGapAckBlocks())); // This DATA should be accepted, and it fills the reassembly queue. - sock_z2.ReceivePacket( - SctpPacket::Builder(sock_z2.verification_tag(), options) + z.socket.ReceivePacket( + SctpPacket::Builder(z.socket.verification_tag(), z.options) .Add(DataChunk(AddTo(tsn, 2), StreamID(1), SSN(0), PPID(53), std::vector(kRemainingSize), /*options=*/{})) .Build()); // The receiver might have moved into delayed ack mode. - cb_z2.AdvanceTime(options.rto_initial); - RunTimers(cb_z2, sock_z2); + AdvanceTime(a, z, z.options.rto_initial); EXPECT_THAT( - cb_z2.ConsumeSentPacket(), + z.cb.ConsumeSentPacket(), AllOf(HasSackWithCumAckTsn(AddTo(tsn, 2)), HasSackWithNoGapAckBlocks())); - EXPECT_CALL(cb_z2, OnAborted(ErrorKind::kResourceExhaustion, _)); - EXPECT_CALL(cb_z2, OnClosed).Times(0); + EXPECT_CALL(z.cb, OnAborted(ErrorKind::kResourceExhaustion, _)); + EXPECT_CALL(z.cb, OnClosed).Times(0); // This DATA will make the connection close. It's too full now. - sock_z2.ReceivePacket( - SctpPacket::Builder(sock_z2.verification_tag(), options) + z.socket.ReceivePacket( + SctpPacket::Builder(z.socket.verification_tag(), z.options) .Add(DataChunk(AddTo(tsn, 3), StreamID(1), SSN(0), PPID(53), std::vector(kSmallMessageSize), /*options=*/{})) .Build()); } -TEST_F(DcSctpSocketTest, SetMaxMessageSize) { - sock_a_->SetMaxMessageSize(42u); - EXPECT_EQ(sock_a_->options().max_message_size, 42u); +TEST(DcSctpSocketTest, SetMaxMessageSize) { + SocketUnderTest a("A"); + + a.socket.SetMaxMessageSize(42u); + EXPECT_EQ(a.socket.options().max_message_size, 42u); } TEST_P(DcSctpSocketParametrizedTest, SendsMessagesWithLowLifetime) { - ConnectSockets(); - MaybeHandoverSocketZ(); + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); // Mock that the time always goes forward. TimeMs now(0); - EXPECT_CALL(cb_a_, TimeMillis).WillRepeatedly([&]() { + EXPECT_CALL(a.cb, TimeMillis).WillRepeatedly([&]() { now += DurationMs(3); return now; }); - EXPECT_CALL(cb_z_, TimeMillis).WillRepeatedly([&]() { + EXPECT_CALL(z->cb, TimeMillis).WillRepeatedly([&]() { now += DurationMs(3); return now; }); @@ -1499,27 +1555,30 @@ TEST_P(DcSctpSocketParametrizedTest, SendsMessagesWithLowLifetime) { send_options.unordered = IsUnordered((i % 2) == 0); send_options.lifetime = DurationMs(i % 3); // 0, 1, 2 ms - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), {1, 2}), send_options); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), {1, 2}), send_options); } - ExchangeMessages(*sock_a_, cb_a_, *sock_z_, cb_z_); + ExchangeMessages(a, *z); for (int i = 0; i < kIterations; ++i) { - EXPECT_TRUE(cb_z_.ConsumeReceivedMessage().has_value()); + EXPECT_TRUE(z->cb.ConsumeReceivedMessage().has_value()); } - EXPECT_FALSE(cb_z_.ConsumeReceivedMessage().has_value()); + EXPECT_FALSE(z->cb.ConsumeReceivedMessage().has_value()); // Validate that the sockets really make the time move forward. EXPECT_GE(*now, kIterations * 2); - MaybeHandoverSocketZAndSendMessage(); + MaybeHandoverSocketAndSendMessage(a, std::move(z)); } TEST_P(DcSctpSocketParametrizedTest, DiscardsMessagesWithLowLifetimeIfMustBuffer) { - ConnectSockets(); - MaybeHandoverSocketZ(); + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); SendOptions lifetime_0; lifetime_0.unordered = IsUnordered(true); @@ -1531,93 +1590,100 @@ TEST_P(DcSctpSocketParametrizedTest, // Mock that the time always goes forward. TimeMs now(0); - EXPECT_CALL(cb_a_, TimeMillis).WillRepeatedly([&]() { + EXPECT_CALL(a.cb, TimeMillis).WillRepeatedly([&]() { now += DurationMs(3); return now; }); - EXPECT_CALL(cb_z_, TimeMillis).WillRepeatedly([&]() { + EXPECT_CALL(z->cb, TimeMillis).WillRepeatedly([&]() { now += DurationMs(3); return now; }); // Fill up the send buffer with a large message. std::vector payload(kLargeMessageSize); - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), payload), kSendOptions); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), payload), kSendOptions); // And queue a few small messages with lifetime=0 or 1 ms - can't be sent. - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), {1, 2, 3}), lifetime_0); - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), {4, 5, 6}), lifetime_1); - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), {7, 8, 9}), lifetime_0); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), {1, 2, 3}), lifetime_0); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), {4, 5, 6}), lifetime_1); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), {7, 8, 9}), lifetime_0); // Handle all that was sent until congestion window got full. for (;;) { - std::vector packet_from_a = cb_a_.ConsumeSentPacket(); + std::vector packet_from_a = a.cb.ConsumeSentPacket(); if (packet_from_a.empty()) { break; } - sock_z_->ReceivePacket(std::move(packet_from_a)); + z->socket.ReceivePacket(std::move(packet_from_a)); } // Shouldn't be enough to send that large message. - EXPECT_FALSE(cb_z_.ConsumeReceivedMessage().has_value()); + EXPECT_FALSE(z->cb.ConsumeReceivedMessage().has_value()); // Exchange the rest of the messages, with the time ever increasing. - ExchangeMessages(*sock_a_, cb_a_, *sock_z_, cb_z_); + ExchangeMessages(a, *z); // The large message should be delivered. It was sent reliably. - ASSERT_HAS_VALUE_AND_ASSIGN(DcSctpMessage m1, cb_z_.ConsumeReceivedMessage()); + ASSERT_HAS_VALUE_AND_ASSIGN(DcSctpMessage m1, z->cb.ConsumeReceivedMessage()); EXPECT_EQ(m1.stream_id(), StreamID(1)); EXPECT_THAT(m1.payload(), SizeIs(kLargeMessageSize)); // But none of the smaller messages. - EXPECT_FALSE(cb_z_.ConsumeReceivedMessage().has_value()); + EXPECT_FALSE(z->cb.ConsumeReceivedMessage().has_value()); - MaybeHandoverSocketZAndSendMessage(); + MaybeHandoverSocketAndSendMessage(a, std::move(z)); } TEST_P(DcSctpSocketParametrizedTest, HasReasonableBufferedAmountValues) { - ConnectSockets(); - MaybeHandoverSocketZ(); + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); - EXPECT_EQ(sock_a_->buffered_amount(StreamID(1)), 0u); + EXPECT_EQ(a.socket.buffered_amount(StreamID(1)), 0u); - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), std::vector(kSmallMessageSize)), kSendOptions); // Sending a small message will directly send it as a single packet, so // nothing is left in the queue. - EXPECT_EQ(sock_a_->buffered_amount(StreamID(1)), 0u); + EXPECT_EQ(a.socket.buffered_amount(StreamID(1)), 0u); - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), std::vector(kLargeMessageSize)), kSendOptions); // Sending a message will directly start sending a few packets, so the // buffered amount is not the full message size. - EXPECT_GT(sock_a_->buffered_amount(StreamID(1)), 0u); - EXPECT_LT(sock_a_->buffered_amount(StreamID(1)), kLargeMessageSize); + EXPECT_GT(a.socket.buffered_amount(StreamID(1)), 0u); + EXPECT_LT(a.socket.buffered_amount(StreamID(1)), kLargeMessageSize); - MaybeHandoverSocketZAndSendMessage(); + MaybeHandoverSocketAndSendMessage(a, std::move(z)); } -TEST_F(DcSctpSocketTest, HasDefaultOnBufferedAmountLowValueZero) { - EXPECT_EQ(sock_a_->buffered_amount_low_threshold(StreamID(1)), 0u); +TEST(DcSctpSocketTest, HasDefaultOnBufferedAmountLowValueZero) { + SocketUnderTest a("A"); + EXPECT_EQ(a.socket.buffered_amount_low_threshold(StreamID(1)), 0u); } TEST_P(DcSctpSocketParametrizedTest, TriggersOnBufferedAmountLowWithDefaultValueZero) { - EXPECT_CALL(cb_a_, OnBufferedAmountLow).Times(0); - ConnectSockets(); - MaybeHandoverSocketZ(); + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + EXPECT_CALL(a.cb, OnBufferedAmountLow).Times(0); + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); - EXPECT_CALL(cb_a_, OnBufferedAmountLow(StreamID(1))); - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), + EXPECT_CALL(a.cb, OnBufferedAmountLow(StreamID(1))); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), std::vector(kSmallMessageSize)), kSendOptions); - ExchangeMessages(*sock_a_, cb_a_, *sock_z_, cb_z_); + ExchangeMessages(a, *z); - EXPECT_CALL(cb_a_, OnBufferedAmountLow).WillRepeatedly(testing::Return()); - MaybeHandoverSocketZAndSendMessage(); + EXPECT_CALL(a.cb, OnBufferedAmountLow).WillRepeatedly(testing::Return()); + MaybeHandoverSocketAndSendMessage(a, std::move(z)); } TEST_P(DcSctpSocketParametrizedTest, @@ -1625,64 +1691,70 @@ TEST_P(DcSctpSocketParametrizedTest, static constexpr size_t kMessageSize = 1000; static constexpr size_t kBufferedAmountLowThreshold = kMessageSize * 10; - sock_a_->SetBufferedAmountLowThreshold(StreamID(1), + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + a.socket.SetBufferedAmountLowThreshold(StreamID(1), kBufferedAmountLowThreshold); - EXPECT_CALL(cb_a_, OnBufferedAmountLow).Times(0); - ConnectSockets(); - MaybeHandoverSocketZ(); + EXPECT_CALL(a.cb, OnBufferedAmountLow).Times(0); + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); - EXPECT_CALL(cb_a_, OnBufferedAmountLow(StreamID(1))).Times(0); - sock_a_->Send( + EXPECT_CALL(a.cb, OnBufferedAmountLow(StreamID(1))).Times(0); + a.socket.Send( DcSctpMessage(StreamID(1), PPID(53), std::vector(kMessageSize)), kSendOptions); - ExchangeMessages(*sock_a_, cb_a_, *sock_z_, cb_z_); + ExchangeMessages(a, *z); - sock_a_->Send( + a.socket.Send( DcSctpMessage(StreamID(1), PPID(53), std::vector(kMessageSize)), kSendOptions); - ExchangeMessages(*sock_a_, cb_a_, *sock_z_, cb_z_); + ExchangeMessages(a, *z); - MaybeHandoverSocketZAndSendMessage(); + MaybeHandoverSocketAndSendMessage(a, std::move(z)); } TEST_P(DcSctpSocketParametrizedTest, TriggersOnBufferedAmountMultipleTimes) { static constexpr size_t kMessageSize = 1000; static constexpr size_t kBufferedAmountLowThreshold = kMessageSize / 2; - sock_a_->SetBufferedAmountLowThreshold(StreamID(1), + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + a.socket.SetBufferedAmountLowThreshold(StreamID(1), kBufferedAmountLowThreshold); - EXPECT_CALL(cb_a_, OnBufferedAmountLow).Times(0); - ConnectSockets(); - MaybeHandoverSocketZ(); + EXPECT_CALL(a.cb, OnBufferedAmountLow).Times(0); + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); - EXPECT_CALL(cb_a_, OnBufferedAmountLow(StreamID(1))).Times(3); - EXPECT_CALL(cb_a_, OnBufferedAmountLow(StreamID(2))).Times(2); - sock_a_->Send( + EXPECT_CALL(a.cb, OnBufferedAmountLow(StreamID(1))).Times(3); + EXPECT_CALL(a.cb, OnBufferedAmountLow(StreamID(2))).Times(2); + a.socket.Send( DcSctpMessage(StreamID(1), PPID(53), std::vector(kMessageSize)), kSendOptions); - ExchangeMessages(*sock_a_, cb_a_, *sock_z_, cb_z_); + ExchangeMessages(a, *z); - sock_a_->Send( + a.socket.Send( DcSctpMessage(StreamID(2), PPID(53), std::vector(kMessageSize)), kSendOptions); - ExchangeMessages(*sock_a_, cb_a_, *sock_z_, cb_z_); + ExchangeMessages(a, *z); - sock_a_->Send( + a.socket.Send( DcSctpMessage(StreamID(1), PPID(53), std::vector(kMessageSize)), kSendOptions); - ExchangeMessages(*sock_a_, cb_a_, *sock_z_, cb_z_); + ExchangeMessages(a, *z); - sock_a_->Send( + a.socket.Send( DcSctpMessage(StreamID(2), PPID(53), std::vector(kMessageSize)), kSendOptions); - ExchangeMessages(*sock_a_, cb_a_, *sock_z_, cb_z_); + ExchangeMessages(a, *z); - sock_a_->Send( + a.socket.Send( DcSctpMessage(StreamID(1), PPID(53), std::vector(kMessageSize)), kSendOptions); - ExchangeMessages(*sock_a_, cb_a_, *sock_z_, cb_z_); + ExchangeMessages(a, *z); - MaybeHandoverSocketZAndSendMessage(); + MaybeHandoverSocketAndSendMessage(a, std::move(z)); } TEST_P(DcSctpSocketParametrizedTest, @@ -1690,72 +1762,83 @@ TEST_P(DcSctpSocketParametrizedTest, static constexpr size_t kMessageSize = 1000; static constexpr size_t kBufferedAmountLowThreshold = kMessageSize * 1.5; - sock_a_->SetBufferedAmountLowThreshold(StreamID(1), + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + a.socket.SetBufferedAmountLowThreshold(StreamID(1), kBufferedAmountLowThreshold); - EXPECT_CALL(cb_a_, OnBufferedAmountLow).Times(0); - ConnectSockets(); - MaybeHandoverSocketZ(); + EXPECT_CALL(a.cb, OnBufferedAmountLow).Times(0); + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); - EXPECT_CALL(cb_a_, OnBufferedAmountLow).Times(0); + EXPECT_CALL(a.cb, OnBufferedAmountLow).Times(0); // Add a few messages to fill up the congestion window. When that is full, // messages will start to be fully buffered. - while (sock_a_->buffered_amount(StreamID(1)) <= kBufferedAmountLowThreshold) { - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), + while (a.socket.buffered_amount(StreamID(1)) <= kBufferedAmountLowThreshold) { + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), std::vector(kMessageSize)), kSendOptions); } - size_t initial_buffered = sock_a_->buffered_amount(StreamID(1)); + size_t initial_buffered = a.socket.buffered_amount(StreamID(1)); ASSERT_GT(initial_buffered, kBufferedAmountLowThreshold); // Start ACKing packets, which will empty the send queue, and trigger the // callback. - EXPECT_CALL(cb_a_, OnBufferedAmountLow(StreamID(1))).Times(1); - ExchangeMessages(*sock_a_, cb_a_, *sock_z_, cb_z_); + EXPECT_CALL(a.cb, OnBufferedAmountLow(StreamID(1))).Times(1); + ExchangeMessages(a, *z); - MaybeHandoverSocketZAndSendMessage(); + MaybeHandoverSocketAndSendMessage(a, std::move(z)); } TEST_P(DcSctpSocketParametrizedTest, DoesntTriggerOnTotalBufferAmountLowWhenBelow) { - ConnectSockets(); - MaybeHandoverSocketZ(); + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); - EXPECT_CALL(cb_a_, OnTotalBufferedAmountLow).Times(0); + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), + EXPECT_CALL(a.cb, OnTotalBufferedAmountLow).Times(0); + + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), std::vector(kLargeMessageSize)), kSendOptions); - ExchangeMessages(*sock_a_, cb_a_, *sock_z_, cb_z_); + ExchangeMessages(a, *z); - MaybeHandoverSocketZAndSendMessage(); + MaybeHandoverSocketAndSendMessage(a, std::move(z)); } TEST_P(DcSctpSocketParametrizedTest, TriggersOnTotalBufferAmountLowWhenCrossingThreshold) { - ConnectSockets(); - MaybeHandoverSocketZ(); + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); - EXPECT_CALL(cb_a_, OnTotalBufferedAmountLow).Times(0); + EXPECT_CALL(a.cb, OnTotalBufferedAmountLow).Times(0); // Fill up the send queue completely. for (;;) { - if (sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), + if (a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), std::vector(kLargeMessageSize)), kSendOptions) == SendStatus::kErrorResourceExhaustion) { break; } } - EXPECT_CALL(cb_a_, OnTotalBufferedAmountLow).Times(1); - ExchangeMessages(*sock_a_, cb_a_, *sock_z_, cb_z_); + EXPECT_CALL(a.cb, OnTotalBufferedAmountLow).Times(1); + ExchangeMessages(a, *z); - MaybeHandoverSocketZAndSendMessage(); + MaybeHandoverSocketAndSendMessage(a, std::move(z)); } -TEST_F(DcSctpSocketTest, InitialMetricsAreZeroed) { - Metrics metrics = sock_a_->GetMetrics(); +TEST(DcSctpSocketTest, InitialMetricsAreZeroed) { + SocketUnderTest a("A"); + + Metrics metrics = a.socket.GetMetrics(); EXPECT_EQ(metrics.tx_packets_count, 0u); EXPECT_EQ(metrics.tx_messages_count, 0u); EXPECT_EQ(metrics.cwnd_bytes.has_value(), false); @@ -1766,85 +1849,90 @@ TEST_F(DcSctpSocketTest, InitialMetricsAreZeroed) { EXPECT_EQ(metrics.peer_rwnd_bytes.has_value(), false); } -TEST_F(DcSctpSocketTest, RxAndTxPacketMetricsIncrease) { - ConnectSockets(); +TEST(DcSctpSocketTest, RxAndTxPacketMetricsIncrease) { + SocketUnderTest a("A"); + SocketUnderTest z("Z"); - const size_t initial_a_rwnd = options_.max_receiver_window_buffer_size * + ConnectSockets(a, z); + + const size_t initial_a_rwnd = a.options.max_receiver_window_buffer_size * ReassemblyQueue::kHighWatermarkLimit; - EXPECT_EQ(sock_a_->GetMetrics().tx_packets_count, 2u); - EXPECT_EQ(sock_a_->GetMetrics().rx_packets_count, 2u); - EXPECT_EQ(sock_a_->GetMetrics().tx_messages_count, 0u); - EXPECT_EQ(*sock_a_->GetMetrics().cwnd_bytes, - options_.cwnd_mtus_initial * options_.mtu); - EXPECT_EQ(sock_a_->GetMetrics().unack_data_count, 0u); + EXPECT_EQ(a.socket.GetMetrics().tx_packets_count, 2u); + EXPECT_EQ(a.socket.GetMetrics().rx_packets_count, 2u); + EXPECT_EQ(a.socket.GetMetrics().tx_messages_count, 0u); + EXPECT_EQ(*a.socket.GetMetrics().cwnd_bytes, + a.options.cwnd_mtus_initial * a.options.mtu); + EXPECT_EQ(a.socket.GetMetrics().unack_data_count, 0u); - EXPECT_EQ(sock_z_->GetMetrics().rx_packets_count, 2u); - EXPECT_EQ(sock_z_->GetMetrics().rx_messages_count, 0u); + EXPECT_EQ(z.socket.GetMetrics().rx_packets_count, 2u); + EXPECT_EQ(z.socket.GetMetrics().rx_messages_count, 0u); - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), {1, 2}), kSendOptions); - EXPECT_EQ(sock_a_->GetMetrics().unack_data_count, 1u); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), {1, 2}), kSendOptions); + EXPECT_EQ(a.socket.GetMetrics().unack_data_count, 1u); - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); // DATA - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); // SACK - EXPECT_EQ(*sock_a_->GetMetrics().peer_rwnd_bytes, initial_a_rwnd); - EXPECT_EQ(sock_a_->GetMetrics().unack_data_count, 0u); + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); // DATA + a.socket.ReceivePacket(z.cb.ConsumeSentPacket()); // SACK + EXPECT_EQ(*a.socket.GetMetrics().peer_rwnd_bytes, initial_a_rwnd); + EXPECT_EQ(a.socket.GetMetrics().unack_data_count, 0u); - EXPECT_TRUE(cb_z_.ConsumeReceivedMessage().has_value()); + EXPECT_TRUE(z.cb.ConsumeReceivedMessage().has_value()); - EXPECT_EQ(sock_a_->GetMetrics().tx_packets_count, 3u); - EXPECT_EQ(sock_a_->GetMetrics().rx_packets_count, 3u); - EXPECT_EQ(sock_a_->GetMetrics().tx_messages_count, 1u); + EXPECT_EQ(a.socket.GetMetrics().tx_packets_count, 3u); + EXPECT_EQ(a.socket.GetMetrics().rx_packets_count, 3u); + EXPECT_EQ(a.socket.GetMetrics().tx_messages_count, 1u); - EXPECT_EQ(sock_z_->GetMetrics().rx_packets_count, 3u); - EXPECT_EQ(sock_z_->GetMetrics().rx_messages_count, 1u); + EXPECT_EQ(z.socket.GetMetrics().rx_packets_count, 3u); + EXPECT_EQ(z.socket.GetMetrics().rx_messages_count, 1u); // Send one more (large - fragmented), and receive the delayed SACK. - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), - std::vector(options_.mtu * 2 + 1)), + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), + std::vector(a.options.mtu * 2 + 1)), kSendOptions); - EXPECT_EQ(sock_a_->GetMetrics().unack_data_count, 3u); + EXPECT_EQ(a.socket.GetMetrics().unack_data_count, 3u); - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); // DATA - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); // DATA + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); // DATA + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); // DATA - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); // SACK - EXPECT_EQ(sock_a_->GetMetrics().unack_data_count, 1u); - EXPECT_GT(*sock_a_->GetMetrics().peer_rwnd_bytes, 0u); - EXPECT_LT(*sock_a_->GetMetrics().peer_rwnd_bytes, initial_a_rwnd); + a.socket.ReceivePacket(z.cb.ConsumeSentPacket()); // SACK + EXPECT_EQ(a.socket.GetMetrics().unack_data_count, 1u); + EXPECT_GT(*a.socket.GetMetrics().peer_rwnd_bytes, 0u); + EXPECT_LT(*a.socket.GetMetrics().peer_rwnd_bytes, initial_a_rwnd); - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); // DATA + z.socket.ReceivePacket(a.cb.ConsumeSentPacket()); // DATA - EXPECT_TRUE(cb_z_.ConsumeReceivedMessage().has_value()); + EXPECT_TRUE(z.cb.ConsumeReceivedMessage().has_value()); - EXPECT_EQ(sock_a_->GetMetrics().tx_packets_count, 6u); - EXPECT_EQ(sock_a_->GetMetrics().rx_packets_count, 4u); - EXPECT_EQ(sock_a_->GetMetrics().tx_messages_count, 2u); + EXPECT_EQ(a.socket.GetMetrics().tx_packets_count, 6u); + EXPECT_EQ(a.socket.GetMetrics().rx_packets_count, 4u); + EXPECT_EQ(a.socket.GetMetrics().tx_messages_count, 2u); - EXPECT_EQ(sock_z_->GetMetrics().rx_packets_count, 6u); - EXPECT_EQ(sock_z_->GetMetrics().rx_messages_count, 2u); + EXPECT_EQ(z.socket.GetMetrics().rx_packets_count, 6u); + EXPECT_EQ(z.socket.GetMetrics().rx_messages_count, 2u); // Delayed sack - AdvanceTime(options_.delayed_ack_max_timeout); - RunTimers(); + AdvanceTime(a, z, a.options.delayed_ack_max_timeout); - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); // SACK - EXPECT_EQ(sock_a_->GetMetrics().unack_data_count, 0u); - EXPECT_EQ(sock_a_->GetMetrics().rx_packets_count, 5u); - EXPECT_EQ(*sock_a_->GetMetrics().peer_rwnd_bytes, initial_a_rwnd); + a.socket.ReceivePacket(z.cb.ConsumeSentPacket()); // SACK + EXPECT_EQ(a.socket.GetMetrics().unack_data_count, 0u); + EXPECT_EQ(a.socket.GetMetrics().rx_packets_count, 5u); + EXPECT_EQ(*a.socket.GetMetrics().peer_rwnd_bytes, initial_a_rwnd); } TEST_P(DcSctpSocketParametrizedTest, UnackDataAlsoIncludesSendQueue) { - ConnectSockets(); - MaybeHandoverSocketZ(); + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), std::vector(kLargeMessageSize)), kSendOptions); size_t payload_bytes = - options_.mtu - SctpPacket::kHeaderSize - DataChunk::kHeaderSize; + a.options.mtu - SctpPacket::kHeaderSize - DataChunk::kHeaderSize; - size_t expected_sent_packets = options_.cwnd_mtus_initial; + size_t expected_sent_packets = a.options.cwnd_mtus_initial; size_t expected_queued_bytes = kLargeMessageSize - expected_sent_packets * payload_bytes; @@ -1853,42 +1941,48 @@ TEST_P(DcSctpSocketParametrizedTest, UnackDataAlsoIncludesSendQueue) { // Due to alignment, padding etc, it's hard to calculate the exact number, but // it should be in this range. - EXPECT_GE(sock_a_->GetMetrics().unack_data_count, + EXPECT_GE(a.socket.GetMetrics().unack_data_count, expected_sent_packets + expected_queued_packets); - EXPECT_LE(sock_a_->GetMetrics().unack_data_count, + EXPECT_LE(a.socket.GetMetrics().unack_data_count, expected_sent_packets + expected_queued_packets + 2); - MaybeHandoverSocketZAndSendMessage(); + MaybeHandoverSocketAndSendMessage(a, std::move(z)); } TEST_P(DcSctpSocketParametrizedTest, DoesntSendMoreThanMaxBurstPackets) { - ConnectSockets(); - MaybeHandoverSocketZ(); + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), std::vector(kLargeMessageSize)), kSendOptions); for (int i = 0; i < kMaxBurstPackets; ++i) { - std::vector packet = cb_a_.ConsumeSentPacket(); + std::vector packet = a.cb.ConsumeSentPacket(); EXPECT_THAT(packet, Not(IsEmpty())); - sock_z_->ReceivePacket(std::move(packet)); // DATA + z->socket.ReceivePacket(std::move(packet)); // DATA } - EXPECT_THAT(cb_a_.ConsumeSentPacket(), IsEmpty()); + EXPECT_THAT(a.cb.ConsumeSentPacket(), IsEmpty()); - ExchangeMessages(*sock_a_, cb_a_, *sock_z_, cb_z_); - MaybeHandoverSocketZAndSendMessage(); + ExchangeMessages(a, *z); + MaybeHandoverSocketAndSendMessage(a, std::move(z)); } TEST_P(DcSctpSocketParametrizedTest, SendsOnlyLargePackets) { - ConnectSockets(); - MaybeHandoverSocketZ(); + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); // A really large message, to ensure that the congestion window is often full. constexpr size_t kMessageSize = 100000; - sock_a_->Send( + a.socket.Send( DcSctpMessage(StreamID(1), PPID(53), std::vector(kMessageSize)), kSendOptions); @@ -1896,21 +1990,21 @@ TEST_P(DcSctpSocketParametrizedTest, SendsOnlyLargePackets) { std::vector data_packet_sizes; do { delivered_packet = false; - std::vector packet_from_a = cb_a_.ConsumeSentPacket(); + std::vector packet_from_a = a.cb.ConsumeSentPacket(); if (!packet_from_a.empty()) { data_packet_sizes.push_back(packet_from_a.size()); delivered_packet = true; - sock_z_->ReceivePacket(std::move(packet_from_a)); + z->socket.ReceivePacket(std::move(packet_from_a)); } - std::vector packet_from_z = cb_z_.ConsumeSentPacket(); + std::vector packet_from_z = z->cb.ConsumeSentPacket(); if (!packet_from_z.empty()) { delivered_packet = true; - sock_a_->ReceivePacket(std::move(packet_from_z)); + a.socket.ReceivePacket(std::move(packet_from_z)); } } while (delivered_packet); size_t packet_payload_bytes = - options_.mtu - SctpPacket::kHeaderSize - DataChunk::kHeaderSize; + a.options.mtu - SctpPacket::kHeaderSize - DataChunk::kHeaderSize; // +1 accounts for padding, and rounding up. size_t expected_packets = (kMessageSize + packet_payload_bytes - 1) / packet_payload_bytes + 1; @@ -1922,158 +2016,168 @@ TEST_P(DcSctpSocketParametrizedTest, SendsOnlyLargePackets) { for (size_t size : data_packet_sizes) { // The 4 is for padding/alignment. - EXPECT_GE(size, options_.mtu - 4); + EXPECT_GE(size, a.options.mtu - 4); } - MaybeHandoverSocketZAndSendMessage(); + MaybeHandoverSocketAndSendMessage(a, std::move(z)); } TEST_P(DcSctpSocketParametrizedTest, DoesntBundleForwardTsnWithData) { - ConnectSockets(); - MaybeHandoverSocketZ(); + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); // Force an RTT measurement using heartbeats. - AdvanceTime(options_.heartbeat_interval); - RunTimers(); + AdvanceTime(a, *z, a.options.heartbeat_interval); // HEARTBEAT - std::vector hb_req_a = cb_a_.ConsumeSentPacket(); - std::vector hb_req_z = cb_z_.ConsumeSentPacket(); + std::vector hb_req_a = a.cb.ConsumeSentPacket(); + std::vector hb_req_z = z->cb.ConsumeSentPacket(); constexpr DurationMs kRtt = DurationMs(80); - AdvanceTime(kRtt); - sock_z_->ReceivePacket(hb_req_a); - sock_a_->ReceivePacket(hb_req_z); + AdvanceTime(a, *z, kRtt); + z->socket.ReceivePacket(hb_req_a); + a.socket.ReceivePacket(hb_req_z); // HEARTBEAT_ACK - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + a.socket.ReceivePacket(z->cb.ConsumeSentPacket()); + z->socket.ReceivePacket(a.cb.ConsumeSentPacket()); SendOptions send_options; send_options.max_retransmissions = 0; - std::vector payload(options_.mtu - 100); + std::vector payload(a.options.mtu - 100); // Send an initial message that is received, but the SACK was lost - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(51), payload), send_options); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(51), payload), send_options); // DATA - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + z->socket.ReceivePacket(a.cb.ConsumeSentPacket()); // SACK (lost) - std::vector sack = cb_z_.ConsumeSentPacket(); + std::vector sack = z->cb.ConsumeSentPacket(); // Queue enough messages to fill the congestion window. do { - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(51), payload), send_options); - } while (!cb_a_.ConsumeSentPacket().empty()); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(51), payload), send_options); + } while (!a.cb.ConsumeSentPacket().empty()); // Enqueue at least one more. - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(51), payload), send_options); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(51), payload), send_options); // Let all of them expire by T3-RTX and inspect what's sent. - AdvanceTime(options_.rto_initial); - RunTimers(); + AdvanceTime(a, *z, a.options.rto_initial); - std::vector sent1 = cb_a_.ConsumeSentPacket(); + std::vector sent1 = a.cb.ConsumeSentPacket(); ASSERT_HAS_VALUE_AND_ASSIGN(SctpPacket packet1, SctpPacket::Parse(sent1)); EXPECT_THAT(packet1.descriptors(), SizeIs(1)); EXPECT_EQ(packet1.descriptors()[0].type, ForwardTsnChunk::kType); - std::vector sent2 = cb_a_.ConsumeSentPacket(); + std::vector sent2 = a.cb.ConsumeSentPacket(); ASSERT_HAS_VALUE_AND_ASSIGN(SctpPacket packet2, SctpPacket::Parse(sent2)); EXPECT_GE(packet2.descriptors().size(), 1u); EXPECT_EQ(packet2.descriptors()[0].type, DataChunk::kType); // Drop all remaining packets that A has sent. - while (!cb_a_.ConsumeSentPacket().empty()) { + while (!a.cb.ConsumeSentPacket().empty()) { } // Replay the SACK, and see if a FORWARD-TSN is sent again. - sock_a_->ReceivePacket(sack); + a.socket.ReceivePacket(sack); // It shouldn't be sent as not enough time has passed yet. Instead, more // DATA chunks are sent, that are in the queue. - std::vector sent3 = cb_a_.ConsumeSentPacket(); + std::vector sent3 = a.cb.ConsumeSentPacket(); ASSERT_HAS_VALUE_AND_ASSIGN(SctpPacket packet3, SctpPacket::Parse(sent3)); EXPECT_GE(packet2.descriptors().size(), 1u); EXPECT_EQ(packet3.descriptors()[0].type, DataChunk::kType); // Now let RTT time pass, to allow a FORWARD-TSN to be sent again. - AdvanceTime(kRtt); - sock_a_->ReceivePacket(sack); + AdvanceTime(a, *z, kRtt); + a.socket.ReceivePacket(sack); - std::vector sent4 = cb_a_.ConsumeSentPacket(); + std::vector sent4 = a.cb.ConsumeSentPacket(); ASSERT_HAS_VALUE_AND_ASSIGN(SctpPacket packet4, SctpPacket::Parse(sent4)); EXPECT_THAT(packet4.descriptors(), SizeIs(1)); EXPECT_EQ(packet4.descriptors()[0].type, ForwardTsnChunk::kType); } -TEST_F(DcSctpSocketTest, SendMessagesAfterHandover) { - ConnectSockets(); +TEST(DcSctpSocketTest, SendMessagesAfterHandover) { + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + ConnectSockets(a, *z); // Send message before handover to move socket to a not initial state - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), {1, 2}), kSendOptions); - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); - cb_z_.ConsumeReceivedMessage(); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), {1, 2}), kSendOptions); + z->socket.ReceivePacket(a.cb.ConsumeSentPacket()); + z->cb.ConsumeReceivedMessage(); - HandoverSocketZ(); + z = HandoverSocket(std::move(z)); absl::optional msg; RTC_LOG(LS_INFO) << "Sending A #1"; - sock_a_->Send(DcSctpMessage(StreamID(1), PPID(53), {3, 4}), kSendOptions); - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + a.socket.Send(DcSctpMessage(StreamID(1), PPID(53), {3, 4}), kSendOptions); + z->socket.ReceivePacket(a.cb.ConsumeSentPacket()); - msg = cb_z_.ConsumeReceivedMessage(); + msg = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg.has_value()); EXPECT_EQ(msg->stream_id(), StreamID(1)); EXPECT_THAT(msg->payload(), testing::ElementsAre(3, 4)); RTC_LOG(LS_INFO) << "Sending A #2"; - sock_a_->Send(DcSctpMessage(StreamID(2), PPID(53), {5, 6}), kSendOptions); - sock_z_->ReceivePacket(cb_a_.ConsumeSentPacket()); + a.socket.Send(DcSctpMessage(StreamID(2), PPID(53), {5, 6}), kSendOptions); + z->socket.ReceivePacket(a.cb.ConsumeSentPacket()); - msg = cb_z_.ConsumeReceivedMessage(); + msg = z->cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg.has_value()); EXPECT_EQ(msg->stream_id(), StreamID(2)); EXPECT_THAT(msg->payload(), testing::ElementsAre(5, 6)); RTC_LOG(LS_INFO) << "Sending Z #1"; - sock_z_->Send(DcSctpMessage(StreamID(1), PPID(53), {1, 2, 3}), kSendOptions); - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); // ack - sock_a_->ReceivePacket(cb_z_.ConsumeSentPacket()); // data + z->socket.Send(DcSctpMessage(StreamID(1), PPID(53), {1, 2, 3}), kSendOptions); + a.socket.ReceivePacket(z->cb.ConsumeSentPacket()); // ack + a.socket.ReceivePacket(z->cb.ConsumeSentPacket()); // data - msg = cb_a_.ConsumeReceivedMessage(); + msg = a.cb.ConsumeReceivedMessage(); ASSERT_TRUE(msg.has_value()); EXPECT_EQ(msg->stream_id(), StreamID(1)); EXPECT_THAT(msg->payload(), testing::ElementsAre(1, 2, 3)); } -TEST_F(DcSctpSocketTest, CanDetectDcsctpImplementation) { - ConnectSockets(); +TEST(DcSctpSocketTest, CanDetectDcsctpImplementation) { + SocketUnderTest a("A"); + SocketUnderTest z("Z"); - EXPECT_EQ(sock_a_->peer_implementation(), SctpImplementation::kDcsctp); + ConnectSockets(a, z); + + EXPECT_EQ(a.socket.peer_implementation(), SctpImplementation::kDcsctp); // As A initiated the connection establishment, Z will not receive enough // information to know about A's implementation - EXPECT_EQ(sock_z_->peer_implementation(), SctpImplementation::kUnknown); + EXPECT_EQ(z.socket.peer_implementation(), SctpImplementation::kUnknown); } -TEST_F(DcSctpSocketTest, BothCanDetectDcsctpImplementation) { - EXPECT_CALL(cb_a_, OnConnected).Times(1); - EXPECT_CALL(cb_z_, OnConnected).Times(1); - sock_a_->Connect(); - sock_z_->Connect(); +TEST(DcSctpSocketTest, BothCanDetectDcsctpImplementation) { + SocketUnderTest a("A"); + SocketUnderTest z("Z"); + + EXPECT_CALL(a.cb, OnConnected).Times(1); + EXPECT_CALL(z.cb, OnConnected).Times(1); + a.socket.Connect(); + z.socket.Connect(); - ExchangeMessages(*sock_a_, cb_a_, *sock_z_, cb_z_); + ExchangeMessages(a, z); - EXPECT_EQ(sock_a_->peer_implementation(), SctpImplementation::kDcsctp); - EXPECT_EQ(sock_z_->peer_implementation(), SctpImplementation::kDcsctp); + EXPECT_EQ(a.socket.peer_implementation(), SctpImplementation::kDcsctp); + EXPECT_EQ(z.socket.peer_implementation(), SctpImplementation::kDcsctp); } } // namespace } // namespace dcsctp diff --git a/net/dcsctp/socket/mock_dcsctp_socket_callbacks.h b/net/dcsctp/socket/mock_dcsctp_socket_callbacks.h index 1e30777e89..803f688a84 100644 --- a/net/dcsctp/socket/mock_dcsctp_socket_callbacks.h +++ b/net/dcsctp/socket/mock_dcsctp_socket_callbacks.h @@ -153,12 +153,6 @@ class MockDcSctpSocketCallbacks : public DcSctpSocketCallbacks { return timeout_manager_.GetNextExpiredTimeout(); } - void Reset() { - sent_packets_.clear(); - received_messages_.clear(); - timeout_manager_.Reset(); - } - private: const std::string log_prefix_; TimeMs now_ = TimeMs(0); diff --git a/net/dcsctp/timer/fake_timeout.h b/net/dcsctp/timer/fake_timeout.h index f87227577b..74ffe5af29 100644 --- a/net/dcsctp/timer/fake_timeout.h +++ b/net/dcsctp/timer/fake_timeout.h @@ -97,8 +97,6 @@ class FakeTimeoutManager { return absl::nullopt; } - void Reset() { timers_.clear(); } - private: const std::function get_time_; webrtc::flat_set timers_; From a5f3c20f2dab9bd706565144d0f9d1b60db767fe Mon Sep 17 00:00:00 2001 From: Jeremy Leconte Date: Mon, 7 Mar 2022 12:45:43 +0100 Subject: [PATCH 116/847] Fix warning 'Build argument has no effect: ios_build_chrome'. Same warning for ios_use_goma_rbe. https://logs.chromium.org/logs/webrtc/buildbucket/cr-buildbucket/8820359174215951313/+/u/generate_build_files/stdout Bug: webrtc:13556 Change-Id: I5342644d1f620d293a9a7f541ac59803dedf4d67 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253840 Reviewed-by: Mirko Bonadei Commit-Queue: Jeremy Leconte Cr-Commit-Position: refs/heads/main@{#36142} --- tools_webrtc/mb/mb_config.pyl | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/tools_webrtc/mb/mb_config.pyl b/tools_webrtc/mb/mb_config.pyl index d082ddc0cd..787bc131db 100644 --- a/tools_webrtc/mb/mb_config.pyl +++ b/tools_webrtc/mb/mb_config.pyl @@ -356,31 +356,27 @@ # iOS 'ios_debug_bot_arm64': [ - 'ios', 'debug_bot', 'arm64', 'no_ios_code_signing', 'ios_use_goma_rbe', - 'xctest', 'ios_no_chrome', + 'ios', 'debug_bot', 'arm64', 'no_ios_code_signing', + 'xctest' ], 'ios_release_bot_arm64': [ - 'ios', 'release_bot', 'arm64', 'no_ios_code_signing', 'ios_use_goma_rbe', - 'xctest', 'ios_no_chrome', + 'ios', 'release_bot', 'arm64', 'no_ios_code_signing', + 'xctest' ], 'ios_internal_debug_bot_arm64': [ - 'ios', 'debug_bot', 'arm64', 'ios_use_goma_rbe', - 'ios_code_signing_identity_description', 'xctest', - 'ios_no_chrome', + 'ios', 'debug_bot', 'arm64', + 'ios_code_signing_identity_description', 'xctest' ], 'ios_internal_release_bot_arm64': [ - 'ios', 'release_bot', 'arm64', 'ios_use_goma_rbe', - 'ios_code_signing_identity_description', 'xctest', - 'ios_no_chrome', + 'ios', 'release_bot', 'arm64', + 'ios_code_signing_identity_description', 'xctest' ], 'ios_internal_pure_release_bot_arm64': [ - 'ios', 'pure_release_bot', 'arm64', 'ios_use_goma_rbe', - 'ios_code_signing_identity_description', 'xctest', - 'ios_no_chrome', + 'ios', 'pure_release_bot', 'arm64', + 'ios_code_signing_identity_description', 'xctest' ], 'ios_debug_bot_x64': [ - 'ios', 'debug_bot', 'x64', 'ios_use_goma_rbe', 'xctest', - 'ios_no_chrome', + 'ios', 'debug_bot', 'x64', 'xctest' ], # More configs @@ -468,14 +464,6 @@ 'gn_args': 'ios_code_signing_identity_description="Apple Development"', }, - 'ios_no_chrome': { - 'gn_args': 'ios_build_chrome=false', - }, - - 'ios_use_goma_rbe': { - 'gn_args': 'ios_use_goma_rbe=true', - }, - 'ios': { 'gn_args': 'target_os="ios"', }, From 13e42a88dfbeaad26dc91f0633312f4f56ff006e Mon Sep 17 00:00:00 2001 From: Evan Shrubsole Date: Mon, 7 Mar 2022 13:21:51 +0100 Subject: [PATCH 117/847] Use TimeDelta and Timestamp in VCMJitterEstimator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Uses DataSize to represent incoming and outgoing bytes. * Puts units into doubles as they enter the Kalman filter * Moved to its own GN target. Change-Id: I1e7d5486a00a7158d418f553a6c77f9dd56bf3c2 Bug: webrtc:13756 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253121 Reviewed-by: Åsa Persson Commit-Queue: Evan Shrubsole Cr-Commit-Position: refs/heads/main@{#36143} --- modules/video_coding/BUILD.gn | 28 +- modules/video_coding/frame_buffer2.cc | 20 +- modules/video_coding/jitter_buffer.cc | 6 +- modules/video_coding/jitter_estimator.cc | 396 +++++++++--------- modules/video_coding/jitter_estimator.h | 148 +++---- .../video_coding/jitter_estimator_tests.cc | 51 ++- video/BUILD.gn | 2 + video/frame_buffer_proxy.cc | 19 +- video/video_receive_stream2.cc | 1 + 9 files changed, 364 insertions(+), 307 deletions(-) diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn index 830701144c..a1b2d07067 100644 --- a/modules/video_coding/BUILD.gn +++ b/modules/video_coding/BUILD.gn @@ -214,6 +214,26 @@ rtc_library("rtt_filter") { ] } +rtc_library("jitter_estimator") { + sources = [ + "jitter_estimator.cc", + "jitter_estimator.h", + ] + deps = [ + ":rtt_filter", + "../../api/units:data_size", + "../../api/units:frequency", + "../../api/units:time_delta", + "../../api/units:timestamp", + "../../rtc_base", + "../../rtc_base:safe_conversions", + "../../rtc_base/experiments:jitter_upper_bound_experiment", + "../../system_wrappers", + "../../system_wrappers:field_trial", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] +} + rtc_library("video_coding") { visibility = [ "*" ] sources = [ @@ -236,8 +256,6 @@ rtc_library("video_coding") { "inter_frame_delay.cc", "inter_frame_delay.h", "internal_defines.h", - "jitter_estimator.cc", - "jitter_estimator.h", "loss_notification_controller.cc", "loss_notification_controller.h", "media_opt_util.cc", @@ -268,6 +286,7 @@ rtc_library("video_coding") { ":encoded_frame", ":frame_buffer", ":frame_helpers", + ":jitter_estimator", ":packet_buffer", ":rtt_filter", ":timing", @@ -285,6 +304,8 @@ rtc_library("video_coding") { "../../api:sequence_checker", "../../api/task_queue", "../../api/units:data_rate", + "../../api/units:data_size", + "../../api/units:frequency", "../../api/units:time_delta", "../../api/units:timestamp", "../../api/video:builtin_video_bitrate_allocator_factory", @@ -381,6 +402,7 @@ rtc_library("video_coding_legacy") { deps = [ ":codec_globals_headers", ":encoded_frame", + ":jitter_estimator", ":timing", ":video_codec_interface", ":video_coding", @@ -1129,6 +1151,7 @@ if (rtc_include_tests) { ":frame_buffer", ":frame_dependencies_calculator", ":h264_packet_buffer", + ":jitter_estimator", ":nack_requester", ":packet_buffer", ":rtt_filter", @@ -1158,6 +1181,7 @@ if (rtc_include_tests) { "../../api:videocodec_test_fixture_api", "../../api/task_queue:default_task_queue_factory", "../../api/test/video:function_video_factory", + "../../api/units:data_size", "../../api/units:frequency", "../../api/units:time_delta", "../../api/units:timestamp", diff --git a/modules/video_coding/frame_buffer2.cc b/modules/video_coding/frame_buffer2.cc index b17cc944f6..d7944dbfa7 100644 --- a/modules/video_coding/frame_buffer2.cc +++ b/modules/video_coding/frame_buffer2.cc @@ -19,6 +19,8 @@ #include #include "absl/container/inlined_vector.h" +#include "api/units/data_size.h" +#include "api/units/time_delta.h" #include "api/video/encoded_image.h" #include "api/video/video_timing.h" #include "modules/video_coding/frame_helpers.h" @@ -250,7 +252,7 @@ std::unique_ptr FrameBuffer::GetNextFrame() { RTC_DCHECK(!frames_to_decode_.empty()); bool superframe_delayed_by_retransmission = false; - size_t superframe_size = 0; + DataSize superframe_size = DataSize::Zero(); const EncodedFrame& first_frame = *frames_to_decode_[0]->second.frame; absl::optional render_time = first_frame.RenderTimestamp(); int64_t receive_time_ms = first_frame.ReceivedTime(); @@ -270,7 +272,7 @@ std::unique_ptr FrameBuffer::GetNextFrame() { superframe_delayed_by_retransmission |= frame->delayed_by_retransmission(); receive_time_ms = std::max(receive_time_ms, frame->ReceivedTime()); - superframe_size += frame->size(); + superframe_size += DataSize::Bytes(frame->size()); PropagateDecodability(frame_it->second); decoded_frames_history_.InsertDecoded(frame_it->first, frame->Timestamp()); @@ -297,17 +299,19 @@ std::unique_ptr FrameBuffer::GetNextFrame() { if (inter_frame_delay_.CalculateDelay(first_frame.Timestamp(), &frame_delay, receive_time_ms)) { - jitter_estimator_.UpdateEstimate(frame_delay, superframe_size); + jitter_estimator_.UpdateEstimate(TimeDelta::Millis(frame_delay), + superframe_size); } float rtt_mult = protection_mode_ == kProtectionNackFEC ? 0.0 : 1.0; - absl::optional rtt_mult_add_cap_ms = absl::nullopt; + absl::optional rtt_mult_add_cap_ms = absl::nullopt; if (rtt_mult_settings_.has_value()) { rtt_mult = rtt_mult_settings_->rtt_mult_setting; - rtt_mult_add_cap_ms = rtt_mult_settings_->rtt_mult_add_cap_ms; + rtt_mult_add_cap_ms = + TimeDelta::Millis(rtt_mult_settings_->rtt_mult_add_cap_ms); } - timing_->SetJitterDelay(TimeDelta::Millis( - jitter_estimator_.GetJitterEstimate(rtt_mult, rtt_mult_add_cap_ms))); + timing_->SetJitterDelay( + jitter_estimator_.GetJitterEstimate(rtt_mult, rtt_mult_add_cap_ms)); timing_->UpdateCurrentDelay(*render_time, now); } else { if (RttMultExperiment::RttMultEnabled()) @@ -352,7 +356,7 @@ int FrameBuffer::Size() { void FrameBuffer::UpdateRtt(int64_t rtt_ms) { MutexLock lock(&mutex_); - jitter_estimator_.UpdateRtt(rtt_ms); + jitter_estimator_.UpdateRtt(TimeDelta::Millis(rtt_ms)); } bool FrameBuffer::ValidReferences(const EncodedFrame& frame) const { diff --git a/modules/video_coding/jitter_buffer.cc b/modules/video_coding/jitter_buffer.cc index 4c6015e027..a49ee6968c 100644 --- a/modules/video_coding/jitter_buffer.cc +++ b/modules/video_coding/jitter_buffer.cc @@ -572,7 +572,7 @@ void VCMJitterBuffer::FindAndInsertContinuousFramesWithState( uint32_t VCMJitterBuffer::EstimatedJitterMs() { MutexLock lock(&mutex_); const double rtt_mult = 1.0f; - return jitter_estimate_.GetJitterEstimate(rtt_mult, absl::nullopt); + return jitter_estimate_.GetJitterEstimate(rtt_mult, absl::nullopt).ms(); } void VCMJitterBuffer::SetNackSettings(size_t max_nack_list_size, @@ -879,7 +879,9 @@ void VCMJitterBuffer::UpdateJitterEstimate(int64_t latest_packet_time_ms, // Filter out frames which have been reordered in time by the network if (not_reordered) { // Update the jitter estimate with the new samples - jitter_estimate_.UpdateEstimate(frame_delay, frame_size, incomplete_frame); + jitter_estimate_.UpdateEstimate(TimeDelta::Millis(frame_delay), + DataSize::Bytes(frame_size), + incomplete_frame); } } diff --git a/modules/video_coding/jitter_estimator.cc b/modules/video_coding/jitter_estimator.cc index cf57232d0f..5ecd545e07 100644 --- a/modules/video_coding/jitter_estimator.cc +++ b/modules/video_coding/jitter_estimator.cc @@ -17,7 +17,10 @@ #include #include "absl/types/optional.h" -#include "modules/video_coding/internal_defines.h" +#include "api/units/data_size.h" +#include "api/units/frequency.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "modules/video_coding/rtt_filter.h" #include "rtc_base/experiments/jitter_upper_bound_experiment.h" #include "rtc_base/numerics/safe_conversions.h" @@ -28,24 +31,26 @@ namespace webrtc { namespace { static constexpr uint32_t kStartupDelaySamples = 30; static constexpr int64_t kFsAccuStartupSamples = 5; -static constexpr double kMaxFramerateEstimate = 200.0; -static constexpr int64_t kNackCountTimeoutMs = 60000; +static constexpr Frequency kMaxFramerateEstimate = Frequency::Hertz(200); +static constexpr TimeDelta kNackCountTimeout = TimeDelta::Seconds(60); static constexpr double kDefaultMaxTimestampDeviationInSigmas = 3.5; + +constexpr double kPhi = 0.97; +constexpr double kPsi = 0.9999; +constexpr uint32_t kAlphaCountMax = 400; +constexpr double kThetaLow = 0.000001; +constexpr uint32_t kNackLimit = 3; +constexpr int32_t kNumStdDevDelayOutlier = 15; +constexpr int32_t kNumStdDevFrameSizeOutlier = 3; +// ~Less than 1% chance (look up in normal distribution table)... +constexpr double kNoiseStdDevs = 2.33; +// ...of getting 30 ms freezes +constexpr double kNoiseStdDevOffset = 30.0; + } // namespace VCMJitterEstimator::VCMJitterEstimator(Clock* clock) - : _phi(0.97), - _psi(0.9999), - _alphaCountMax(400), - _thetaLow(0.000001), - _nackLimit(3), - _numStdDevDelayOutlier(15), - _numStdDevFrameSizeOutlier(3), - _noiseStdDevs(2.33), // ~Less than 1% chance - // (look up in normal distribution table)... - _noiseStdDevOffset(30.0), // ...of getting 30 ms freezes - _rttFilter(), - fps_counter_(30), // TODO(sprang): Use an estimator with limit based on + : fps_counter_(30), // TODO(sprang): Use an estimator with limit based on // time, rather than number of samples. time_deviation_upper_bound_( JitterUpperBoundExperiment::GetUpperBoundSigmas().value_or( @@ -56,133 +61,133 @@ VCMJitterEstimator::VCMJitterEstimator(Clock* clock) Reset(); } -VCMJitterEstimator::~VCMJitterEstimator() {} +VCMJitterEstimator::~VCMJitterEstimator() = default; // Resets the JitterEstimate. void VCMJitterEstimator::Reset() { - _theta[0] = 1 / (512e3 / 8); - _theta[1] = 0; - _varNoise = 4.0; - - _thetaCov[0][0] = 1e-4; - _thetaCov[1][1] = 1e2; - _thetaCov[0][1] = _thetaCov[1][0] = 0; - _Qcov[0][0] = 2.5e-10; - _Qcov[1][1] = 1e-10; - _Qcov[0][1] = _Qcov[1][0] = 0; - _avgFrameSize = 500; - _maxFrameSize = 500; - _varFrameSize = 100; - _lastUpdateT = -1; - _prevEstimate = -1.0; - _prevFrameSize = 0; - _avgNoise = 0.0; - _alphaCount = 1; - _filterJitterEstimate = 0.0; - _latestNackTimestamp = 0; - _nackCount = 0; - _latestNackTimestamp = 0; - _fsSum = 0; - _fsCount = 0; - _startupCount = 0; - _rttFilter.Reset(); + theta_[0] = 1 / (512e3 / 8); + theta_[1] = 0; + var_noise_ = 4.0; + + theta_cov_[0][0] = 1e-4; + theta_cov_[1][1] = 1e2; + theta_cov_[0][1] = theta_cov_[1][0] = 0; + q_cov_[0][0] = 2.5e-10; + q_cov_[1][1] = 1e-10; + q_cov_[0][1] = q_cov_[1][0] = 0; + avg_frame_size_ = kDefaultAvgAndMaxFrameSize; + max_frame_size_ = kDefaultAvgAndMaxFrameSize; + var_frame_size_ = 100; + last_update_time_ = absl::nullopt; + prev_estimate_ = absl::nullopt; + prev_frame_size_ = absl::nullopt; + avg_noise_ = 0.0; + alpha_count_ = 1; + filter_jitter_estimate_ = TimeDelta::Zero(); + latest_nack_ = Timestamp::Zero(); + nack_count_ = 0; + frame_size_sum_ = DataSize::Zero(); + frame_size_count_ = 0; + startup_count_ = 0; + rtt_filter_.Reset(); fps_counter_.Reset(); } // Updates the estimates with the new measurements. -void VCMJitterEstimator::UpdateEstimate(int64_t frameDelayMS, - uint32_t frameSizeBytes, - bool incompleteFrame /* = false */) { - if (frameSizeBytes == 0) { +void VCMJitterEstimator::UpdateEstimate(TimeDelta frame_delay, + DataSize frame_size, + bool incomplete_frame /* = false */) { + if (frame_size.IsZero()) { return; } - int deltaFS = frameSizeBytes - _prevFrameSize; - if (_fsCount < kFsAccuStartupSamples) { - _fsSum += frameSizeBytes; - _fsCount++; - } else if (_fsCount == kFsAccuStartupSamples) { + // Can't use DataSize since this can be negative. + double delta_frame_bytes = + frame_size.bytes() - prev_frame_size_.value_or(DataSize::Zero()).bytes(); + if (frame_size_count_ < kFsAccuStartupSamples) { + frame_size_sum_ += frame_size; + frame_size_count_++; + } else if (frame_size_count_ == kFsAccuStartupSamples) { // Give the frame size filter. - _avgFrameSize = static_cast(_fsSum) / static_cast(_fsCount); - _fsCount++; + avg_frame_size_ = frame_size_sum_ / static_cast(frame_size_count_); + frame_size_count_++; } - if (!incompleteFrame || frameSizeBytes > _avgFrameSize) { - double avgFrameSize = _phi * _avgFrameSize + (1 - _phi) * frameSizeBytes; - if (frameSizeBytes < _avgFrameSize + 2 * sqrt(_varFrameSize)) { + if (!incomplete_frame || frame_size > avg_frame_size_) { + DataSize avg_frame_size = kPhi * avg_frame_size_ + (1 - kPhi) * frame_size; + DataSize deviation_size = DataSize::Bytes(2 * sqrt(var_frame_size_)); + if (frame_size < avg_frame_size_ + deviation_size) { // Only update the average frame size if this sample wasn't a key frame. - _avgFrameSize = avgFrameSize; + avg_frame_size_ = avg_frame_size; } // Update the variance anyway since we want to capture cases where we only // get key frames. - _varFrameSize = VCM_MAX( - _phi * _varFrameSize + (1 - _phi) * (frameSizeBytes - avgFrameSize) * - (frameSizeBytes - avgFrameSize), - 1.0); + double delta_bytes = frame_size.bytes() - avg_frame_size.bytes(); + var_frame_size_ = std::max( + kPhi * var_frame_size_ + (1 - kPhi) * (delta_bytes * delta_bytes), 1.0); } - // Update max frameSize estimate. - _maxFrameSize = - VCM_MAX(_psi * _maxFrameSize, static_cast(frameSizeBytes)); + // Update max_frame_size_ estimate. + max_frame_size_ = std::max(kPsi * max_frame_size_, frame_size); - if (_prevFrameSize == 0) { - _prevFrameSize = frameSizeBytes; + if (!prev_frame_size_) { + prev_frame_size_ = frame_size; return; } - _prevFrameSize = frameSizeBytes; + prev_frame_size_ = frame_size; - // Cap frameDelayMS based on the current time deviation noise. - int64_t max_time_deviation_ms = - static_cast(time_deviation_upper_bound_ * sqrt(_varNoise) + 0.5); - frameDelayMS = std::max(std::min(frameDelayMS, max_time_deviation_ms), - -max_time_deviation_ms); + // Cap frame_delay based on the current time deviation noise. + TimeDelta max_time_deviation = + TimeDelta::Millis(time_deviation_upper_bound_ * sqrt(var_noise_) + 0.5); + frame_delay.Clamp(-max_time_deviation, max_time_deviation); // Only update the Kalman filter if the sample is not considered an extreme // outlier. Even if it is an extreme outlier from a delay point of view, if // the frame size also is large the deviation is probably due to an incorrect // line slope. - double deviation = DeviationFromExpectedDelay(frameDelayMS, deltaFS); + double deviation = DeviationFromExpectedDelay(frame_delay, delta_frame_bytes); - if (fabs(deviation) < _numStdDevDelayOutlier * sqrt(_varNoise) || - frameSizeBytes > - _avgFrameSize + _numStdDevFrameSizeOutlier * sqrt(_varFrameSize)) { + if (fabs(deviation) < kNumStdDevDelayOutlier * sqrt(var_noise_) || + frame_size.bytes() > + avg_frame_size_.bytes() + + kNumStdDevFrameSizeOutlier * sqrt(var_frame_size_)) { // Update the variance of the deviation from the line given by the Kalman // filter. - EstimateRandomJitter(deviation, incompleteFrame); + EstimateRandomJitter(deviation, incomplete_frame); // Prevent updating with frames which have been congested by a large frame, // and therefore arrives almost at the same time as that frame. // This can occur when we receive a large frame (key frame) which has been // delayed. The next frame is of normal size (delta frame), and thus deltaFS // will be << 0. This removes all frame samples which arrives after a key // frame. - if ((!incompleteFrame || deviation >= 0.0) && - static_cast(deltaFS) > -0.25 * _maxFrameSize) { + if ((!incomplete_frame || deviation >= 0) && + delta_frame_bytes > -0.25 * max_frame_size_.bytes()) { // Update the Kalman filter with the new data - KalmanEstimateChannel(frameDelayMS, deltaFS); + KalmanEstimateChannel(frame_delay, delta_frame_bytes); } } else { int nStdDev = - (deviation >= 0) ? _numStdDevDelayOutlier : -_numStdDevDelayOutlier; - EstimateRandomJitter(nStdDev * sqrt(_varNoise), incompleteFrame); + (deviation >= 0) ? kNumStdDevDelayOutlier : -kNumStdDevDelayOutlier; + EstimateRandomJitter(nStdDev * sqrt(var_noise_), incomplete_frame); } // Post process the total estimated jitter - if (_startupCount >= kStartupDelaySamples) { + if (startup_count_ >= kStartupDelaySamples) { PostProcessEstimate(); } else { - _startupCount++; + startup_count_++; } } // Updates the nack/packet ratio. void VCMJitterEstimator::FrameNacked() { - if (_nackCount < _nackLimit) { - _nackCount++; + if (nack_count_ < kNackLimit) { + nack_count_++; } - _latestNackTimestamp = clock_->TimeInMicroseconds(); + latest_nack_ = clock_->CurrentTime(); } // Updates Kalman estimate of the channel. // The caller is expected to sanity check the inputs. -void VCMJitterEstimator::KalmanEstimateChannel(int64_t frameDelayMS, - int32_t deltaFSBytes) { +void VCMJitterEstimator::KalmanEstimateChannel(TimeDelta frame_delay, + double delta_frame_size_bytes) { double Mh[2]; double hMh_sigma; double kalmanGain[2]; @@ -193,31 +198,31 @@ void VCMJitterEstimator::KalmanEstimateChannel(int64_t frameDelayMS, // Prediction // M = M + Q - _thetaCov[0][0] += _Qcov[0][0]; - _thetaCov[0][1] += _Qcov[0][1]; - _thetaCov[1][0] += _Qcov[1][0]; - _thetaCov[1][1] += _Qcov[1][1]; + theta_cov_[0][0] += q_cov_[0][0]; + theta_cov_[0][1] += q_cov_[0][1]; + theta_cov_[1][0] += q_cov_[1][0]; + theta_cov_[1][1] += q_cov_[1][1]; // Kalman gain // K = M*h'/(sigma2n + h*M*h') = M*h'/(1 + h*M*h') // h = [dFS 1] // Mh = M*h' // hMh_sigma = h*M*h' + R - Mh[0] = _thetaCov[0][0] * deltaFSBytes + _thetaCov[0][1]; - Mh[1] = _thetaCov[1][0] * deltaFSBytes + _thetaCov[1][1]; + Mh[0] = theta_cov_[0][0] * delta_frame_size_bytes + theta_cov_[0][1]; + Mh[1] = theta_cov_[1][0] * delta_frame_size_bytes + theta_cov_[1][1]; // sigma weights measurements with a small deltaFS as noisy and // measurements with large deltaFS as good - if (_maxFrameSize < 1.0) { + if (max_frame_size_ < DataSize::Bytes(1)) { return; } - double sigma = (300.0 * exp(-fabs(static_cast(deltaFSBytes)) / - (1e0 * _maxFrameSize)) + + double sigma = (300.0 * exp(-fabs(delta_frame_size_bytes) / + (1e0 * max_frame_size_.bytes())) + 1) * - sqrt(_varNoise); + sqrt(var_noise_); if (sigma < 1.0) { sigma = 1.0; } - hMh_sigma = deltaFSBytes * Mh[0] + Mh[1] + sigma; + hMh_sigma = delta_frame_size_bytes * Mh[0] + Mh[1] + sigma; if ((hMh_sigma < 1e-9 && hMh_sigma >= 0) || (hMh_sigma > -1e-9 && hMh_sigma <= 0)) { RTC_DCHECK_NOTREACHED(); @@ -228,94 +233,96 @@ void VCMJitterEstimator::KalmanEstimateChannel(int64_t frameDelayMS, // Correction // theta = theta + K*(dT - h*theta) - measureRes = frameDelayMS - (deltaFSBytes * _theta[0] + _theta[1]); - _theta[0] += kalmanGain[0] * measureRes; - _theta[1] += kalmanGain[1] * measureRes; + measureRes = + frame_delay.ms() - (delta_frame_size_bytes * theta_[0] + theta_[1]); + theta_[0] += kalmanGain[0] * measureRes; + theta_[1] += kalmanGain[1] * measureRes; - if (_theta[0] < _thetaLow) { - _theta[0] = _thetaLow; + if (theta_[0] < kThetaLow) { + theta_[0] = kThetaLow; } // M = (I - K*h)*M - t00 = _thetaCov[0][0]; - t01 = _thetaCov[0][1]; - _thetaCov[0][0] = (1 - kalmanGain[0] * deltaFSBytes) * t00 - - kalmanGain[0] * _thetaCov[1][0]; - _thetaCov[0][1] = (1 - kalmanGain[0] * deltaFSBytes) * t01 - - kalmanGain[0] * _thetaCov[1][1]; - _thetaCov[1][0] = _thetaCov[1][0] * (1 - kalmanGain[1]) - - kalmanGain[1] * deltaFSBytes * t00; - _thetaCov[1][1] = _thetaCov[1][1] * (1 - kalmanGain[1]) - - kalmanGain[1] * deltaFSBytes * t01; + t00 = theta_cov_[0][0]; + t01 = theta_cov_[0][1]; + theta_cov_[0][0] = (1 - kalmanGain[0] * delta_frame_size_bytes) * t00 - + kalmanGain[0] * theta_cov_[1][0]; + theta_cov_[0][1] = (1 - kalmanGain[0] * delta_frame_size_bytes) * t01 - + kalmanGain[0] * theta_cov_[1][1]; + theta_cov_[1][0] = theta_cov_[1][0] * (1 - kalmanGain[1]) - + kalmanGain[1] * delta_frame_size_bytes * t00; + theta_cov_[1][1] = theta_cov_[1][1] * (1 - kalmanGain[1]) - + kalmanGain[1] * delta_frame_size_bytes * t01; // Covariance matrix, must be positive semi-definite. - RTC_DCHECK(_thetaCov[0][0] + _thetaCov[1][1] >= 0 && - _thetaCov[0][0] * _thetaCov[1][1] - - _thetaCov[0][1] * _thetaCov[1][0] >= + RTC_DCHECK(theta_cov_[0][0] + theta_cov_[1][1] >= 0 && + theta_cov_[0][0] * theta_cov_[1][1] - + theta_cov_[0][1] * theta_cov_[1][0] >= 0 && - _thetaCov[0][0] >= 0); + theta_cov_[0][0] >= 0); } // Calculate difference in delay between a sample and the expected delay // estimated by the Kalman filter double VCMJitterEstimator::DeviationFromExpectedDelay( - int64_t frameDelayMS, - int32_t deltaFSBytes) const { - return frameDelayMS - (_theta[0] * deltaFSBytes + _theta[1]); + TimeDelta frame_delay, + double delta_frame_size_bytes) const { + return frame_delay.ms() - (theta_[0] * delta_frame_size_bytes + theta_[1]); } // Estimates the random jitter by calculating the variance of the sample // distance from the line given by theta. void VCMJitterEstimator::EstimateRandomJitter(double d_dT, - bool incompleteFrame) { - uint64_t now = clock_->TimeInMicroseconds(); - if (_lastUpdateT != -1) { - fps_counter_.AddSample(now - _lastUpdateT); + bool incomplete_frame) { + Timestamp now = clock_->CurrentTime(); + if (last_update_time_.has_value()) { + fps_counter_.AddSample((now - *last_update_time_).us()); } - _lastUpdateT = now; + last_update_time_ = now; - if (_alphaCount == 0) { + if (alpha_count_ == 0) { RTC_DCHECK_NOTREACHED(); return; } double alpha = - static_cast(_alphaCount - 1) / static_cast(_alphaCount); - _alphaCount++; - if (_alphaCount > _alphaCountMax) - _alphaCount = _alphaCountMax; + static_cast(alpha_count_ - 1) / static_cast(alpha_count_); + alpha_count_++; + if (alpha_count_ > kAlphaCountMax) + alpha_count_ = kAlphaCountMax; // In order to avoid a low frame rate stream to react slower to changes, // scale the alpha weight relative a 30 fps stream. - double fps = GetFrameRate(); - if (fps > 0.0) { - double rate_scale = 30.0 / fps; + Frequency fps = GetFrameRate(); + if (fps > Frequency::Zero()) { + constexpr Frequency k30Fps = Frequency::Hertz(30); + double rate_scale = k30Fps / fps; // At startup, there can be a lot of noise in the fps estimate. // Interpolate rate_scale linearly, from 1.0 at sample #1, to 30.0 / fps // at sample #kStartupDelaySamples. - if (_alphaCount < kStartupDelaySamples) { + if (alpha_count_ < kStartupDelaySamples) { rate_scale = - (_alphaCount * rate_scale + (kStartupDelaySamples - _alphaCount)) / + (alpha_count_ * rate_scale + (kStartupDelaySamples - alpha_count_)) / kStartupDelaySamples; } alpha = pow(alpha, rate_scale); } - double avgNoise = alpha * _avgNoise + (1 - alpha) * d_dT; - double varNoise = - alpha * _varNoise + (1 - alpha) * (d_dT - _avgNoise) * (d_dT - _avgNoise); - if (!incompleteFrame || varNoise > _varNoise) { - _avgNoise = avgNoise; - _varNoise = varNoise; + double avgNoise = alpha * avg_noise_ + (1 - alpha) * d_dT; + double varNoise = alpha * var_noise_ + + (1 - alpha) * (d_dT - avg_noise_) * (d_dT - avg_noise_); + if (!incomplete_frame || varNoise > var_noise_) { + avg_noise_ = avgNoise; + var_noise_ = varNoise; } - if (_varNoise < 1.0) { + if (var_noise_ < 1.0) { // The variance should never be zero, since we might get stuck and consider // all samples as outliers. - _varNoise = 1.0; + var_noise_ = 1.0; } } double VCMJitterEstimator::NoiseThreshold() const { - double noiseThreshold = _noiseStdDevs * sqrt(_varNoise) - _noiseStdDevOffset; + double noiseThreshold = kNoiseStdDevs * sqrt(var_noise_) - kNoiseStdDevOffset; if (noiseThreshold < 1.0) { noiseThreshold = 1.0; } @@ -323,88 +330,91 @@ double VCMJitterEstimator::NoiseThreshold() const { } // Calculates the current jitter estimate from the filtered estimates. -double VCMJitterEstimator::CalculateEstimate() { - double ret = _theta[0] * (_maxFrameSize - _avgFrameSize) + NoiseThreshold(); +TimeDelta VCMJitterEstimator::CalculateEstimate() { + double retMs = + theta_[0] * (max_frame_size_.bytes() - avg_frame_size_.bytes()) + + NoiseThreshold(); + TimeDelta ret = TimeDelta::Millis(retMs); + + constexpr TimeDelta kMinPrevEstimate = TimeDelta::Micros(10); + constexpr TimeDelta kMaxEstimate = TimeDelta::Seconds(10); // A very low estimate (or negative) is neglected. - if (ret < 1.0) { - if (_prevEstimate <= 0.01) { - ret = 1.0; + if (ret < TimeDelta::Millis(1)) { + if (!prev_estimate_ || prev_estimate_ <= kMinPrevEstimate) { + ret = TimeDelta::Millis(1); } else { - ret = _prevEstimate; + ret = *prev_estimate_; } } - if (ret > 10000.0) { // Sanity - ret = 10000.0; + if (ret > kMaxEstimate) { // Sanity + ret = kMaxEstimate; } - _prevEstimate = ret; + prev_estimate_ = ret; return ret; } void VCMJitterEstimator::PostProcessEstimate() { - _filterJitterEstimate = CalculateEstimate(); + filter_jitter_estimate_ = CalculateEstimate(); } -void VCMJitterEstimator::UpdateRtt(int64_t rttMs) { - _rttFilter.Update(TimeDelta::Millis(rttMs)); +void VCMJitterEstimator::UpdateRtt(TimeDelta rtt) { + rtt_filter_.Update(rtt); } // Returns the current filtered estimate if available, // otherwise tries to calculate an estimate. -int VCMJitterEstimator::GetJitterEstimate( - double rttMultiplier, - absl::optional rttMultAddCapMs) { - double jitterMS = CalculateEstimate() + OPERATING_SYSTEM_JITTER; - uint64_t now = clock_->TimeInMicroseconds(); - - if (now - _latestNackTimestamp > kNackCountTimeoutMs * 1000) - _nackCount = 0; - - if (_filterJitterEstimate > jitterMS) - jitterMS = _filterJitterEstimate; - if (_nackCount >= _nackLimit) { - if (rttMultAddCapMs.has_value()) { - jitterMS += std::min(_rttFilter.Rtt().ms() * rttMultiplier, - rttMultAddCapMs.value()); +TimeDelta VCMJitterEstimator::GetJitterEstimate( + double rtt_multiplier, + absl::optional rtt_mult_add_cap) { + TimeDelta jitter = CalculateEstimate() + OPERATING_SYSTEM_JITTER; + Timestamp now = clock_->CurrentTime(); + + if (now - latest_nack_ > kNackCountTimeout) + nack_count_ = 0; + + if (filter_jitter_estimate_ > jitter) + jitter = filter_jitter_estimate_; + if (nack_count_ >= kNackLimit) { + if (rtt_mult_add_cap.has_value()) { + jitter += std::min(rtt_filter_.Rtt() * rtt_multiplier, + rtt_mult_add_cap.value()); } else { - jitterMS += _rttFilter.Rtt().ms() * rttMultiplier; + jitter += rtt_filter_.Rtt() * rtt_multiplier; } } if (enable_reduced_delay_) { - static const double kJitterScaleLowThreshold = 5.0; - static const double kJitterScaleHighThreshold = 10.0; - double fps = GetFrameRate(); + static const Frequency kJitterScaleLowThreshold = Frequency::Hertz(5); + static const Frequency kJitterScaleHighThreshold = Frequency::Hertz(10); + Frequency fps = GetFrameRate(); // Ignore jitter for very low fps streams. if (fps < kJitterScaleLowThreshold) { - if (fps == 0.0) { - return rtc::checked_cast(std::max(0.0, jitterMS) + 0.5); + if (fps.IsZero()) { + return std::max(TimeDelta::Zero(), jitter); } - return 0; + return TimeDelta::Zero(); } // Semi-low frame rate; scale by factor linearly interpolated from 0.0 at // kJitterScaleLowThreshold to 1.0 at kJitterScaleHighThreshold. if (fps < kJitterScaleHighThreshold) { - jitterMS = - (1.0 / (kJitterScaleHighThreshold - kJitterScaleLowThreshold)) * - (fps - kJitterScaleLowThreshold) * jitterMS; + jitter = (1.0 / (kJitterScaleHighThreshold - kJitterScaleLowThreshold)) * + (fps - kJitterScaleLowThreshold) * jitter; } } - return rtc::checked_cast(std::max(0.0, jitterMS) + 0.5); + return std::max(TimeDelta::Zero(), jitter); } -double VCMJitterEstimator::GetFrameRate() const { - if (fps_counter_.ComputeMean() <= 0.0) - return 0; +Frequency VCMJitterEstimator::GetFrameRate() const { + TimeDelta mean_frame_period = TimeDelta::Micros(fps_counter_.ComputeMean()); + if (mean_frame_period <= TimeDelta::Zero()) + return Frequency::Zero(); - double fps = 1000000.0 / fps_counter_.ComputeMean(); + Frequency fps = 1 / mean_frame_period; // Sanity check. - RTC_DCHECK_GE(fps, 0.0); - if (fps > kMaxFramerateEstimate) { - fps = kMaxFramerateEstimate; - } - return fps; + RTC_DCHECK_GE(fps, Frequency::Zero()); + return std::min(fps, kMaxFramerateEstimate); } } // namespace webrtc diff --git a/modules/video_coding/jitter_estimator.h b/modules/video_coding/jitter_estimator.h index ee8f264329..026fb7e580 100644 --- a/modules/video_coding/jitter_estimator.h +++ b/modules/video_coding/jitter_estimator.h @@ -11,6 +11,11 @@ #ifndef MODULES_VIDEO_CODING_JITTER_ESTIMATOR_H_ #define MODULES_VIDEO_CODING_JITTER_ESTIMATOR_H_ +#include "absl/types/optional.h" +#include "api/units/data_size.h" +#include "api/units/frequency.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "modules/video_coding/rtt_filter.h" #include "rtc_base/rolling_accumulator.h" @@ -31,24 +36,25 @@ class VCMJitterEstimator { // Updates the jitter estimate with the new data. // // Input: - // - frameDelay : Delay-delta calculated by UTILDelayEstimate in - // milliseconds. - // - frameSize : Frame size of the current frame. - // - incompleteFrame : Flags if the frame is used to update the + // - frame_delay : Delay-delta calculated by UTILDelayEstimate. + // - frame_size : Frame size of the current frame. + // - incomplete_frame : Flags if the frame is used to update the // estimate before it was complete. // Default is false. - void UpdateEstimate(int64_t frameDelayMS, - uint32_t frameSizeBytes, - bool incompleteFrame = false); + void UpdateEstimate(TimeDelta frame_delay, + DataSize frame_size, + bool incomplete_frame = false); - // Returns the current jitter estimate in milliseconds and adds an RTT - // dependent term in cases of retransmission. + // Returns the current jitter estimate and adds an RTT dependent term in cases + // of retransmission. // Input: - // - rttMultiplier : RTT param multiplier (when applicable). + // - rtt_multiplier : RTT param multiplier (when applicable). + // - rtt_mult_add_cap : Multiplier cap from the RTTMultExperiment. // - // Return value : Jitter estimate in milliseconds. - virtual int GetJitterEstimate(double rttMultiplier, - absl::optional rttMultAddCapMs); + // Return value : Jitter estimate. + virtual TimeDelta GetJitterEstimate( + double rtt_multiplier, + absl::optional rtt_mult_add_cap); // Updates the nack counter. void FrameNacked(); @@ -56,45 +62,47 @@ class VCMJitterEstimator { // Updates the RTT filter. // // Input: - // - rttMs : RTT in ms. - void UpdateRtt(int64_t rttMs); + // - rtt : Round trip time. + void UpdateRtt(TimeDelta rtt); // A constant describing the delay from the jitter buffer to the delay on the // receiving side which is not accounted for by the jitter buffer nor the // decoding delay estimate. - static const uint32_t OPERATING_SYSTEM_JITTER = 10; + static constexpr TimeDelta OPERATING_SYSTEM_JITTER = TimeDelta::Millis(10); protected: // These are protected for better testing possibilities. - double _theta[2]; // Estimated line parameters (slope, offset) - double _varNoise; // Variance of the time-deviation from the line + double theta_[2]; // Estimated line parameters (slope, offset) + double var_noise_; // Variance of the time-deviation from the line private: // Updates the Kalman filter for the line describing the frame size dependent // jitter. // // Input: - // - frameDelayMS : Delay-delta calculated by UTILDelayEstimate in - // milliseconds. - // - deltaFSBytes : Frame size delta, i.e. frame size at time T - // : minus frame size at time T-1. - void KalmanEstimateChannel(int64_t frameDelayMS, int32_t deltaFSBytes); + // - frame_delay + // Delay-delta calculated by UTILDelayEstimate. + // - delta_frame_size_bytes + // Frame size delta, i.e. frame size at time T minus frame size + // at time T-1. + void KalmanEstimateChannel(TimeDelta frame_delay, + double delta_frame_size_bytes); // Updates the random jitter estimate, i.e. the variance of the time // deviations from the line given by the Kalman filter. // // Input: // - d_dT : The deviation from the kalman estimate. - // - incompleteFrame : True if the frame used to update the + // - incomplete_frame : True if the frame used to update the // estimate with was incomplete. - void EstimateRandomJitter(double d_dT, bool incompleteFrame); + void EstimateRandomJitter(double d_dT, bool incomplete_frame); double NoiseThreshold() const; // Calculates the current jitter estimate. // - // Return value : The current jitter estimate in milliseconds. - double CalculateEstimate(); + // Return value : The current jitter estimate. + TimeDelta CalculateEstimate(); // Post process the calculated estimate. void PostProcessEstimate(); @@ -103,52 +111,48 @@ class VCMJitterEstimator { // estimated by the Kalman filter. // // Input: - // - frameDelayMS : Delay-delta calculated by UTILDelayEstimate in - // milliseconds. - // - deltaFS : Frame size delta, i.e. frame size at time - // T minus frame size at time T-1. + // - frame_delay : Delay-delta calculated by UTILDelayEstimate. + // - delta_frame_size_bytes : Frame size delta, i.e. frame size at + // time + // T minus frame size at time T-1. // - // Return value : The difference in milliseconds. - double DeviationFromExpectedDelay(int64_t frameDelayMS, - int32_t deltaFSBytes) const; - - double GetFrameRate() const; - - // Constants, filter parameters. - const double _phi; - const double _psi; - const uint32_t _alphaCountMax; - const double _thetaLow; - const uint32_t _nackLimit; - const int32_t _numStdDevDelayOutlier; - const int32_t _numStdDevFrameSizeOutlier; - const double _noiseStdDevs; - const double _noiseStdDevOffset; - - double _thetaCov[2][2]; // Estimate covariance - double _Qcov[2][2]; // Process noise covariance - double _avgFrameSize; // Average frame size - double _varFrameSize; // Frame size variance - double _maxFrameSize; // Largest frame size received (descending - // with a factor _psi) - uint32_t _fsSum; - uint32_t _fsCount; - - int64_t _lastUpdateT; - double _prevEstimate; // The previously returned jitter estimate - uint32_t _prevFrameSize; // Frame size of the previous frame - double _avgNoise; // Average of the random jitter - uint32_t _alphaCount; - double _filterJitterEstimate; // The filtered sum of jitter estimates - - uint32_t _startupCount; - - int64_t - _latestNackTimestamp; // Timestamp in ms when the latest nack was seen - uint32_t _nackCount; // Keeps track of the number of nacks received, - // but never goes above _nackLimit - VCMRttFilter _rttFilter; - + // Return value : The delay difference in ms. + double DeviationFromExpectedDelay(TimeDelta frame_delay, + double delta_frame_size_bytes) const; + + Frequency GetFrameRate() const; + + double theta_cov_[2][2]; // Estimate covariance + double q_cov_[2][2]; // Process noise covariance + + static constexpr DataSize kDefaultAvgAndMaxFrameSize = DataSize::Bytes(500); + DataSize avg_frame_size_ = kDefaultAvgAndMaxFrameSize; // Average frame size + double var_frame_size_; // Frame size variance. Unit is bytes^2. + // Largest frame size received (descending with a factor kPsi) + DataSize max_frame_size_ = kDefaultAvgAndMaxFrameSize; + DataSize frame_size_sum_ = DataSize::Zero(); + uint32_t frame_size_count_; + + absl::optional last_update_time_; + // The previously returned jitter estimate + absl::optional prev_estimate_; + // Frame size of the previous frame + absl::optional prev_frame_size_; + // Average of the random jitter + double avg_noise_; + uint32_t alpha_count_; + // The filtered sum of jitter estimates + TimeDelta filter_jitter_estimate_ = TimeDelta::Zero(); + + uint32_t startup_count_; + // Time when the latest nack was seen + Timestamp latest_nack_ = Timestamp::Zero(); + // Keeps track of the number of nacks received, but never goes above + // kNackLimit. + uint32_t nack_count_; + VCMRttFilter rtt_filter_; + + // Tracks frame rates in microseconds. rtc::RollingAccumulator fps_counter_; const double time_deviation_upper_bound_; const bool enable_reduced_delay_; diff --git a/modules/video_coding/jitter_estimator_tests.cc b/modules/video_coding/jitter_estimator_tests.cc index 14baae7e81..f4bb7fc1ea 100644 --- a/modules/video_coding/jitter_estimator_tests.cc +++ b/modules/video_coding/jitter_estimator_tests.cc @@ -14,6 +14,9 @@ #include "absl/types/optional.h" #include "api/array_view.h" +#include "api/units/data_size.h" +#include "api/units/frequency.h" +#include "api/units/time_delta.h" #include "modules/video_coding/jitter_estimator.h" #include "rtc_base/experiments/jitter_upper_bound_experiment.h" #include "rtc_base/numerics/histogram_percentile_counter.h" @@ -33,10 +36,6 @@ class TestVCMJitterEstimator : public ::testing::Test { estimator_ = std::make_unique(&fake_clock_); } - void AdvanceClock(int64_t microseconds) { - fake_clock_.AdvanceTimeMicroseconds(microseconds); - } - SimulatedClock fake_clock_; std::unique_ptr estimator_; }; @@ -46,11 +45,16 @@ class ValueGenerator { public: explicit ValueGenerator(int32_t amplitude) : amplitude_(amplitude), counter_(0) {} - virtual ~ValueGenerator() {} - int64_t Delay() const { return ((counter_ % 11) - 5) * amplitude_; } + virtual ~ValueGenerator() = default; - uint32_t FrameSize() const { return 1000 + Delay(); } + TimeDelta Delay() const { + return TimeDelta::Millis((counter_ % 11) - 5) * amplitude_; + } + + DataSize FrameSize() const { + return DataSize::Bytes(1000 + Delay().ms() / 5); + } void Advance() { ++counter_; } @@ -62,12 +66,13 @@ class ValueGenerator { // 5 fps, disable jitter delay altogether. TEST_F(TestVCMJitterEstimator, TestLowRate) { ValueGenerator gen(10); - uint64_t time_delta_us = rtc::kNumMicrosecsPerSec / 5; + TimeDelta time_delta = 1 / Frequency::Hertz(5); for (int i = 0; i < 60; ++i) { estimator_->UpdateEstimate(gen.Delay(), gen.FrameSize()); - AdvanceClock(time_delta_us); + fake_clock_.AdvanceTime(time_delta); if (i > 2) - EXPECT_EQ(estimator_->GetJitterEstimate(0, absl::nullopt), 0); + EXPECT_EQ(estimator_->GetJitterEstimate(0, absl::nullopt), + TimeDelta::Zero()); gen.Advance(); } } @@ -78,12 +83,13 @@ TEST_F(TestVCMJitterEstimator, TestLowRateDisabled) { SetUp(); ValueGenerator gen(10); - uint64_t time_delta_us = rtc::kNumMicrosecsPerSec / 5; + TimeDelta time_delta = 1 / Frequency::Hertz(5); for (int i = 0; i < 60; ++i) { estimator_->UpdateEstimate(gen.Delay(), gen.FrameSize()); - AdvanceClock(time_delta_us); + fake_clock_.AdvanceTime(time_delta); if (i > 2) - EXPECT_GT(estimator_->GetJitterEstimate(0, absl::nullopt), 0); + EXPECT_GT(estimator_->GetJitterEstimate(0, absl::nullopt), + TimeDelta::Zero()); gen.Advance(); } } @@ -97,7 +103,7 @@ TEST_F(TestVCMJitterEstimator, TestUpperBound) { percentiles(1000) {} double upper_bound; double rtt_mult; - absl::optional rtt_mult_add_cap_ms; + absl::optional rtt_mult_add_cap_ms; rtc::HistogramPercentileCounter percentiles; }; std::vector test_cases(4); @@ -113,11 +119,11 @@ TEST_F(TestVCMJitterEstimator, TestUpperBound) { // Large upper bound, rtt_mult = 1, and large rtt_mult addition cap value. test_cases[2].upper_bound = 1000.0; test_cases[2].rtt_mult = 1.0; - test_cases[2].rtt_mult_add_cap_ms = 200.0; + test_cases[2].rtt_mult_add_cap_ms = TimeDelta::Millis(200); // Large upper bound, rtt_mult = 1, and small rtt_mult addition cap value. test_cases[3].upper_bound = 1000.0; test_cases[3].rtt_mult = 1.0; - test_cases[3].rtt_mult_add_cap_ms = 10.0; + test_cases[3].rtt_mult_add_cap_ms = TimeDelta::Millis(10); // Test jitter buffer upper_bound and rtt_mult addition cap sizes. for (TestContext& context : test_cases) { @@ -130,16 +136,17 @@ TEST_F(TestVCMJitterEstimator, TestUpperBound) { SetUp(); ValueGenerator gen(50); - uint64_t time_delta_us = rtc::kNumMicrosecsPerSec / 30; - constexpr int64_t kRttMs = 250; + TimeDelta time_delta = 1 / Frequency::Hertz(30); + constexpr TimeDelta kRtt = TimeDelta::Millis(250); for (int i = 0; i < 100; ++i) { estimator_->UpdateEstimate(gen.Delay(), gen.FrameSize()); - AdvanceClock(time_delta_us); + fake_clock_.AdvanceTime(time_delta); estimator_->FrameNacked(); // To test rtt_mult. - estimator_->UpdateRtt(kRttMs); // To test rtt_mult. + estimator_->UpdateRtt(kRtt); // To test rtt_mult. context.percentiles.Add( - static_cast(estimator_->GetJitterEstimate( - context.rtt_mult, context.rtt_mult_add_cap_ms))); + estimator_ + ->GetJitterEstimate(context.rtt_mult, context.rtt_mult_add_cap_ms) + .ms()); gen.Advance(); } } diff --git a/video/BUILD.gn b/video/BUILD.gn index e8f7417b08..e5ba48b3b2 100644 --- a/video/BUILD.gn +++ b/video/BUILD.gn @@ -100,6 +100,7 @@ rtc_library("video") { "../modules/video_coding:codec_globals_headers", "../modules/video_coding:frame_buffer", "../modules/video_coding:frame_helpers", + "../modules/video_coding:jitter_estimator", "../modules/video_coding:nack_requester", "../modules/video_coding:packet_buffer", "../modules/video_coding:timing", @@ -308,6 +309,7 @@ rtc_library("frame_buffer_proxy") { "../api:sequence_checker", "../api/metronome", "../api/task_queue", + "../api/units:data_size", "../api/video:encoded_frame", "../api/video:video_rtp_headers", "../modules/video_coding", diff --git a/video/frame_buffer_proxy.cc b/video/frame_buffer_proxy.cc index d277a368ef..c7fce7ae19 100644 --- a/video/frame_buffer_proxy.cc +++ b/video/frame_buffer_proxy.cc @@ -17,6 +17,7 @@ #include "absl/base/attributes.h" #include "absl/functional/bind_front.h" #include "api/sequence_checker.h" +#include "api/units/data_size.h" #include "api/video/encoded_frame.h" #include "api/video/video_content_type.h" #include "modules/video_coding/frame_buffer2.h" @@ -261,7 +262,7 @@ class FrameBuffer3Proxy : public FrameBufferProxy { void UpdateRtt(int64_t max_rtt_ms) override { RTC_DCHECK_RUN_ON(&worker_sequence_checker_); - jitter_estimator_.UpdateRtt(max_rtt_ms); + jitter_estimator_.UpdateRtt(TimeDelta::Millis(max_rtt_ms)); } void StartNextDecode(bool keyframe_required) override { @@ -298,7 +299,7 @@ class FrameBuffer3Proxy : public FrameBufferProxy { Timestamp now = clock_->CurrentTime(); bool superframe_delayed_by_retransmission = false; - size_t superframe_size = 0; + DataSize superframe_size = DataSize::Zero(); const EncodedFrame& first_frame = *frames.front(); int64_t receive_time_ms = first_frame.ReceivedTime(); @@ -319,7 +320,7 @@ class FrameBuffer3Proxy : public FrameBufferProxy { superframe_delayed_by_retransmission |= frame->delayed_by_retransmission(); receive_time_ms = std::max(receive_time_ms, frame->ReceivedTime()); - superframe_size += frame->size(); + superframe_size += DataSize::Bytes(frame->size()); } if (!superframe_delayed_by_retransmission) { @@ -327,17 +328,19 @@ class FrameBuffer3Proxy : public FrameBufferProxy { if (inter_frame_delay_.CalculateDelay(first_frame.Timestamp(), &frame_delay, receive_time_ms)) { - jitter_estimator_.UpdateEstimate(frame_delay, superframe_size); + jitter_estimator_.UpdateEstimate(TimeDelta::Millis(frame_delay), + superframe_size); } float rtt_mult = protection_mode_ == kProtectionNackFEC ? 0.0 : 1.0; - absl::optional rtt_mult_add_cap_ms = absl::nullopt; + absl::optional rtt_mult_add_cap_ms = absl::nullopt; if (rtt_mult_settings_.has_value()) { rtt_mult = rtt_mult_settings_->rtt_mult_setting; - rtt_mult_add_cap_ms = rtt_mult_settings_->rtt_mult_add_cap_ms; + rtt_mult_add_cap_ms = + TimeDelta::Millis(rtt_mult_settings_->rtt_mult_add_cap_ms); } - timing_->SetJitterDelay(TimeDelta::Millis( - jitter_estimator_.GetJitterEstimate(rtt_mult, rtt_mult_add_cap_ms))); + timing_->SetJitterDelay( + jitter_estimator_.GetJitterEstimate(rtt_mult, rtt_mult_add_cap_ms)); timing_->UpdateCurrentDelay(render_time, now); } else if (RttMultExperiment::RttMultEnabled()) { jitter_estimator_.FrameNacked(); diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc index 290180b8c6..c2e79460da 100644 --- a/video/video_receive_stream2.cc +++ b/video/video_receive_stream2.cc @@ -692,6 +692,7 @@ void VideoReceiveStream2::OnCompleteFrame(std::unique_ptr frame) { void VideoReceiveStream2::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { RTC_DCHECK_RUN_ON(&worker_sequence_checker_); + // TODO(bugs.webrtc.org/13757): Replace with TimeDelta. frame_buffer_->UpdateRtt(max_rtt_ms); rtp_video_stream_receiver_.UpdateRtt(max_rtt_ms); stats_proxy_.OnRttUpdate(avg_rtt_ms); From 11cc804d973ce892db7bce526c17d488c8afe758 Mon Sep 17 00:00:00 2001 From: philipel Date: Mon, 7 Mar 2022 15:33:19 +0100 Subject: [PATCH 118/847] Remove unused variable from RtpVp9RefFinder Bug: none Change-Id: Iaa1f2f8272a7e47f50a3572efb2e0765286c8a0e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253843 Reviewed-by: Danil Chapovalov Commit-Queue: Philip Eliasson Cr-Commit-Position: refs/heads/main@{#36144} --- modules/video_coding/rtp_vp9_ref_finder.cc | 3 --- modules/video_coding/rtp_vp9_ref_finder.h | 4 ---- 2 files changed, 7 deletions(-) diff --git a/modules/video_coding/rtp_vp9_ref_finder.cc b/modules/video_coding/rtp_vp9_ref_finder.cc index fd271f81f8..d4e30054ae 100644 --- a/modules/video_coding/rtp_vp9_ref_finder.cc +++ b/modules/video_coding/rtp_vp9_ref_finder.cc @@ -53,9 +53,6 @@ RtpVp9RefFinder::FrameDecision RtpVp9RefFinder::ManageFrameInternal( frame->SetSpatialIndex(codec_header.spatial_idx); frame->SetId(codec_header.picture_id & (kFrameIdLength - 1)); - if (last_picture_id_ == -1) - last_picture_id_ = frame->Id(); - if (codec_header.flexible_mode) { if (codec_header.num_ref_pics > EncodedFrame::kMaxFrameReferences) { return kDrop; diff --git a/modules/video_coding/rtp_vp9_ref_finder.h b/modules/video_coding/rtp_vp9_ref_finder.h index 436cb1c84a..00de8ca59d 100644 --- a/modules/video_coding/rtp_vp9_ref_finder.h +++ b/modules/video_coding/rtp_vp9_ref_finder.h @@ -60,10 +60,6 @@ class RtpVp9RefFinder { void FlattenFrameIdAndRefs(RtpFrameObject* frame, bool inter_layer_predicted); - // Save the last picture id in order to detect when there is a gap in frames - // that have not yet been fully received. - int last_picture_id_ = -1; - // Frames that have been fully received but didn't have all the information // needed to determine their references. std::deque> stashed_frames_; From 10ab697dcbee66c4570f6e767274d92412af67e7 Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Mon, 7 Mar 2022 11:28:08 +0100 Subject: [PATCH 119/847] Cleanup legacy functions to handle time as raw int in RtpPacketToSend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:13757 Change-Id: I28964cb7dbd6bc6363401a9658208b8f96aceb8a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253820 Auto-Submit: Danil Chapovalov Reviewed-by: Erik Språng Commit-Queue: Erik Språng Cr-Commit-Position: refs/heads/main@{#36145} --- modules/rtp_rtcp/source/rtp_packet_to_send.h | 36 -------------------- 1 file changed, 36 deletions(-) diff --git a/modules/rtp_rtcp/source/rtp_packet_to_send.h b/modules/rtp_rtcp/source/rtp_packet_to_send.h index 9b3bbf673a..8c0fc7bd5c 100644 --- a/modules/rtp_rtcp/source/rtp_packet_to_send.h +++ b/modules/rtp_rtcp/source/rtp_packet_to_send.h @@ -15,7 +15,6 @@ #include -#include "absl/base/attributes.h" #include "absl/types/optional.h" #include "api/array_view.h" #include "api/ref_counted_base.h" @@ -49,13 +48,6 @@ class RtpPacketToSend : public RtpPacket { webrtc::Timestamp capture_time() const { return capture_time_; } void set_capture_time(webrtc::Timestamp time) { capture_time_ = time; } - ABSL_DEPRECATED("Use capture_time() instead") - int64_t capture_time_ms() const { return capture_time_.ms_or(-1); } - ABSL_DEPRECATED("Use set_capture_time() instead") - void set_capture_time_ms(int64_t time) { - capture_time_ = webrtc::Timestamp::Millis(time); - } - void set_packet_type(RtpPacketMediaType type) { packet_type_ = type; } absl::optional packet_type() const { return packet_type_; @@ -109,34 +101,6 @@ class RtpPacketToSend : public RtpPacket { VideoTimingExtension::kNetwork2TimestampDeltaOffset); } - ABSL_DEPRECATED("Use set_packetization_finish_time() instead") - void set_packetization_finish_time_ms(int64_t time) { - SetExtension( - VideoSendTiming::GetDeltaCappedMs(capture_time_.ms_or(0), time), - VideoTimingExtension::kPacketizationFinishDeltaOffset); - } - - ABSL_DEPRECATED("Use set_pacer_exit_time() instead") - void set_pacer_exit_time_ms(int64_t time) { - SetExtension( - VideoSendTiming::GetDeltaCappedMs(capture_time_.ms_or(0), time), - VideoTimingExtension::kPacerExitDeltaOffset); - } - - ABSL_DEPRECATED("Use set_network_time() instead") - void set_network_time_ms(int64_t time) { - SetExtension( - VideoSendTiming::GetDeltaCappedMs(capture_time_.ms_or(0), time), - VideoTimingExtension::kNetworkTimestampDeltaOffset); - } - - ABSL_DEPRECATED("Use set_network2_time() instead") - void set_network2_time_ms(int64_t time) { - SetExtension( - VideoSendTiming::GetDeltaCappedMs(capture_time_.ms_or(0), time), - VideoTimingExtension::kNetwork2TimestampDeltaOffset); - } - // Indicates if packet is the first packet of a video frame. void set_first_packet_of_frame(bool is_first_packet) { is_first_packet_of_frame_ = is_first_packet; From 773205dfb25ff71919c14a3e2b4bc6239b8afe9a Mon Sep 17 00:00:00 2001 From: philipel Date: Mon, 7 Mar 2022 18:12:26 +0100 Subject: [PATCH 120/847] Save unwrapped `tl0_pic_idx` for inserted VP9 frames. As stashed frames are retried their `tl0_pic_idx` are again unwrapped which can lead to the `tl0_unwrapper_` to unwrap the `tl0_pic_idx` of newer frames backwards. Instead unwrap the `tl0_pid_idx` only once and save it with the frame if necessary. In this CL - Only unwrap the TL0 once in ManageFrame. - Split ManageFrameInternal into ManageFrameFlexible and ManageFrameGof. - Save the unwrapped TL0 with the stashed frame. Bug: none Change-Id: I56e6b071c0082682e010c049c537d66060635567 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253844 Reviewed-by: Danil Chapovalov Commit-Queue: Philip Eliasson Cr-Commit-Position: refs/heads/main@{#36146} --- modules/video_coding/rtp_vp9_ref_finder.cc | 101 ++++++++++-------- modules/video_coding/rtp_vp9_ref_finder.h | 13 ++- .../rtp_vp9_ref_finder_unittest.cc | 14 +++ 3 files changed, 83 insertions(+), 45 deletions(-) diff --git a/modules/video_coding/rtp_vp9_ref_finder.cc b/modules/video_coding/rtp_vp9_ref_finder.cc index d4e30054ae..7a1f946904 100644 --- a/modules/video_coding/rtp_vp9_ref_finder.cc +++ b/modules/video_coding/rtp_vp9_ref_finder.cc @@ -16,17 +16,44 @@ #include "rtc_base/logging.h" namespace webrtc { - RtpFrameReferenceFinder::ReturnVector RtpVp9RefFinder::ManageFrame( std::unique_ptr frame) { - FrameDecision decision = ManageFrameInternal(frame.get()); + const RTPVideoHeaderVP9& codec_header = absl::get( + frame->GetRtpVideoHeader().video_type_header); + + frame->SetSpatialIndex(codec_header.spatial_idx); + frame->SetId(codec_header.picture_id & (kFrameIdLength - 1)); + + FrameDecision decision; + if (codec_header.temporal_idx >= kMaxTemporalLayers || + codec_header.spatial_idx >= kMaxSpatialLayers) { + decision = kDrop; + } else if (codec_header.flexible_mode) { + decision = ManageFrameFlexible(frame.get(), codec_header); + } else { + if (codec_header.tl0_pic_idx == kNoTl0PicIdx) { + RTC_LOG(LS_WARNING) << "TL0PICIDX is expected to be present in " + "non-flexible mode."; + decision = kDrop; + } else { + int64_t unwrapped_tl0 = + tl0_unwrapper_.Unwrap(codec_header.tl0_pic_idx & 0xFF); + decision = ManageFrameGof(frame.get(), codec_header, unwrapped_tl0); + + if (decision == kStash) { + if (stashed_frames_.size() > kMaxStashedFrames) { + stashed_frames_.pop_back(); + } + + stashed_frames_.push_front( + {.unwrapped_tl0 = unwrapped_tl0, .frame = std::move(frame)}); + } + } + } RtpFrameReferenceFinder::ReturnVector res; switch (decision) { case kStash: - if (stashed_frames_.size() > kMaxStashedFrames) - stashed_frames_.pop_back(); - stashed_frames_.push_front(std::move(frame)); return res; case kHandOff: res.push_back(std::move(frame)); @@ -39,43 +66,28 @@ RtpFrameReferenceFinder::ReturnVector RtpVp9RefFinder::ManageFrame( return res; } -RtpVp9RefFinder::FrameDecision RtpVp9RefFinder::ManageFrameInternal( - RtpFrameObject* frame) { - const RTPVideoHeader& video_header = frame->GetRtpVideoHeader(); - const RTPVideoHeaderVP9& codec_header = - absl::get(video_header.video_type_header); - - // Protect against corrupted packets with arbitrary large temporal idx. - if (codec_header.temporal_idx >= kMaxTemporalLayers || - codec_header.spatial_idx >= kMaxSpatialLayers) +RtpVp9RefFinder::FrameDecision RtpVp9RefFinder::ManageFrameFlexible( + RtpFrameObject* frame, + const RTPVideoHeaderVP9& codec_header) { + if (codec_header.num_ref_pics > EncodedFrame::kMaxFrameReferences) { return kDrop; - - frame->SetSpatialIndex(codec_header.spatial_idx); - frame->SetId(codec_header.picture_id & (kFrameIdLength - 1)); - - if (codec_header.flexible_mode) { - if (codec_header.num_ref_pics > EncodedFrame::kMaxFrameReferences) { - return kDrop; - } - frame->num_references = codec_header.num_ref_pics; - for (size_t i = 0; i < frame->num_references; ++i) { - frame->references[i] = - Subtract(frame->Id(), codec_header.pid_diff[i]); - } - - FlattenFrameIdAndRefs(frame, codec_header.inter_layer_predicted); - return kHandOff; } - if (codec_header.tl0_pic_idx == kNoTl0PicIdx) { - RTC_LOG(LS_WARNING) << "TL0PICIDX is expected to be present in " - "non-flexible mode."; - return kDrop; + frame->num_references = codec_header.num_ref_pics; + for (size_t i = 0; i < frame->num_references; ++i) { + frame->references[i] = + Subtract(frame->Id(), codec_header.pid_diff[i]); } + FlattenFrameIdAndRefs(frame, codec_header.inter_layer_predicted); + return kHandOff; +} + +RtpVp9RefFinder::FrameDecision RtpVp9RefFinder::ManageFrameGof( + RtpFrameObject* frame, + const RTPVideoHeaderVP9& codec_header, + int64_t unwrapped_tl0) { GofInfo* info; - int64_t unwrapped_tl0 = - tl0_unwrapper_.Unwrap(codec_header.tl0_pic_idx & 0xFF); if (codec_header.ss_data_available) { if (codec_header.temporal_idx != 0) { RTC_LOG(LS_WARNING) << "Received scalability structure on a non base " @@ -300,20 +312,23 @@ void RtpVp9RefFinder::RetryStashedFrames( bool complete_frame = false; do { complete_frame = false; - for (auto frame_it = stashed_frames_.begin(); - frame_it != stashed_frames_.end();) { - FrameDecision decision = ManageFrameInternal(frame_it->get()); + for (auto it = stashed_frames_.begin(); it != stashed_frames_.end();) { + const RTPVideoHeaderVP9& codec_header = absl::get( + it->frame->GetRtpVideoHeader().video_type_header); + RTC_DCHECK(!codec_header.flexible_mode); + FrameDecision decision = + ManageFrameGof(it->frame.get(), codec_header, it->unwrapped_tl0); switch (decision) { case kStash: - ++frame_it; + ++it; break; case kHandOff: complete_frame = true; - res.push_back(std::move(*frame_it)); + res.push_back(std::move(it->frame)); [[fallthrough]]; case kDrop: - frame_it = stashed_frames_.erase(frame_it); + it = stashed_frames_.erase(it); } } } while (complete_frame); @@ -339,7 +354,7 @@ void RtpVp9RefFinder::FlattenFrameIdAndRefs(RtpFrameObject* frame, void RtpVp9RefFinder::ClearTo(uint16_t seq_num) { auto it = stashed_frames_.begin(); while (it != stashed_frames_.end()) { - if (AheadOf(seq_num, (*it)->first_seq_num())) { + if (AheadOf(seq_num, it->frame->first_seq_num())) { it = stashed_frames_.erase(it); } else { ++it; diff --git a/modules/video_coding/rtp_vp9_ref_finder.h b/modules/video_coding/rtp_vp9_ref_finder.h index 00de8ca59d..2971f686b1 100644 --- a/modules/video_coding/rtp_vp9_ref_finder.h +++ b/modules/video_coding/rtp_vp9_ref_finder.h @@ -48,7 +48,16 @@ class RtpVp9RefFinder { uint16_t last_picture_id; }; - FrameDecision ManageFrameInternal(RtpFrameObject* frame); + struct UnwrappedTl0Frame { + int64_t unwrapped_tl0; + std::unique_ptr frame; + }; + + FrameDecision ManageFrameFlexible(RtpFrameObject* frame, + const RTPVideoHeaderVP9& vp9_header); + FrameDecision ManageFrameGof(RtpFrameObject* frame, + const RTPVideoHeaderVP9& vp9_header, + int64_t unwrapped_tl0); void RetryStashedFrames(RtpFrameReferenceFinder::ReturnVector& res); bool MissingRequiredFrameVp9(uint16_t picture_id, const GofInfo& info); @@ -62,7 +71,7 @@ class RtpVp9RefFinder { // Frames that have been fully received but didn't have all the information // needed to determine their references. - std::deque> stashed_frames_; + std::deque stashed_frames_; // Where the current scalability structure is in the // `scalability_structures_` array. diff --git a/modules/video_coding/rtp_vp9_ref_finder_unittest.cc b/modules/video_coding/rtp_vp9_ref_finder_unittest.cc index 6de7ce106f..66b284f020 100644 --- a/modules/video_coding/rtp_vp9_ref_finder_unittest.cc +++ b/modules/video_coding/rtp_vp9_ref_finder_unittest.cc @@ -23,6 +23,7 @@ using ::testing::Matches; using ::testing::MatchResultListener; using ::testing::Pointee; using ::testing::Property; +using ::testing::SizeIs; using ::testing::UnorderedElementsAreArray; namespace webrtc { @@ -702,4 +703,17 @@ TEST_F(RtpVp9RefFinderTest, SpatialIndex) { Contains(Pointee(Property(&EncodedFrame::SpatialIndex, 2)))); } +TEST_F(RtpVp9RefFinderTest, StashedFramesDoNotWrapTl0Backwards) { + GofInfoVP9 ss; + ss.SetGofInfoVP9(kTemporalStructureMode1); + + Insert(Frame().Pid(0).SidAndTid(0, 0).Tl0(0)); + EXPECT_THAT(frames_, SizeIs(0)); + + Insert(Frame().Pid(128).SidAndTid(0, 0).Tl0(128).AsKeyFrame().Gof(&ss)); + EXPECT_THAT(frames_, SizeIs(1)); + Insert(Frame().Pid(129).SidAndTid(0, 0).Tl0(129)); + EXPECT_THAT(frames_, SizeIs(2)); +} + } // namespace webrtc From e9126c18bfc98041bec8e7e1017552565f7b5bc4 Mon Sep 17 00:00:00 2001 From: Evan Shrubsole Date: Mon, 7 Mar 2022 14:50:51 +0100 Subject: [PATCH 121/847] Migrate VCMInterFrameDelay to use Time units MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Additionally, * Moved to its own GN target. * Added unittests. * Removed unused variable `_zeroWallClock`. * Renamed variables to match style guide. * Moved fields _dTS and _wrapArounds to variables. Change-Id: I7aa8b8dec55abab49ceabe838dabf2a7e13d685d Bug: webrtc:13756 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253580 Reviewed-by: Niels Moller Reviewed-by: Erik Språng Reviewed-by: Harald Alvestrand Commit-Queue: Evan Shrubsole Cr-Commit-Position: refs/heads/main@{#36147} --- api/video/encoded_frame.cc | 6 + api/video/encoded_frame.h | 3 + modules/video_coding/BUILD.gn | 21 +- modules/video_coding/frame_buffer2.cc | 10 +- modules/video_coding/inter_frame_delay.cc | 91 ++++----- modules/video_coding/inter_frame_delay.h | 42 ++-- .../inter_frame_delay_unittest.cc | 190 ++++++++++++++++++ modules/video_coding/jitter_buffer.cc | 25 ++- video/BUILD.gn | 1 + video/frame_buffer_proxy.cc | 33 +-- 10 files changed, 299 insertions(+), 123 deletions(-) create mode 100644 modules/video_coding/inter_frame_delay_unittest.cc diff --git a/api/video/encoded_frame.cc b/api/video/encoded_frame.cc index 56d199f30f..c5e2abbbb4 100644 --- a/api/video/encoded_frame.cc +++ b/api/video/encoded_frame.cc @@ -14,6 +14,12 @@ namespace webrtc { +absl::optional EncodedFrame::ReceivedTimestamp() const { + return ReceivedTime() >= 0 + ? absl::make_optional(Timestamp::Millis(ReceivedTime())) + : absl::nullopt; +} + absl::optional EncodedFrame::RenderTimestamp() const { return RenderTimeMs() >= 0 ? absl::make_optional(Timestamp::Millis(RenderTimeMs())) diff --git a/api/video/encoded_frame.h b/api/video/encoded_frame.h index 610c988ebd..66aee227bb 100644 --- a/api/video/encoded_frame.h +++ b/api/video/encoded_frame.h @@ -34,6 +34,9 @@ class EncodedFrame : public webrtc::VCMEncodedFrame { // When this frame was received. // TODO(bugs.webrtc.org/13756): Use Timestamp instead of int. virtual int64_t ReceivedTime() const = 0; + // Returns a Timestamp from `ReceivedTime`, or nullopt if there is no receive + // time. + absl::optional ReceivedTimestamp() const; // When this frame should be rendered. // TODO(bugs.webrtc.org/13756): Use Timestamp instead of int. diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn index a1b2d07067..7d6b5da1af 100644 --- a/modules/video_coding/BUILD.gn +++ b/modules/video_coding/BUILD.gn @@ -234,6 +234,20 @@ rtc_library("jitter_estimator") { absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } +rtc_library("inter_frame_delay") { + sources = [ + "inter_frame_delay.cc", + "inter_frame_delay.h", + ] + deps = [ + "..:module_api_public", + "../../api/units:frequency", + "../../api/units:time_delta", + "../../api/units:timestamp", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] +} + rtc_library("video_coding") { visibility = [ "*" ] sources = [ @@ -253,8 +267,6 @@ rtc_library("video_coding") { "h264_sps_pps_tracker.cc", "h264_sps_pps_tracker.h", "include/video_codec_initializer.h", - "inter_frame_delay.cc", - "inter_frame_delay.h", "internal_defines.h", "loss_notification_controller.cc", "loss_notification_controller.h", @@ -286,8 +298,8 @@ rtc_library("video_coding") { ":encoded_frame", ":frame_buffer", ":frame_helpers", + ":inter_frame_delay", ":jitter_estimator", - ":packet_buffer", ":rtt_filter", ":timing", ":video_codec_interface", @@ -402,6 +414,7 @@ rtc_library("video_coding_legacy") { deps = [ ":codec_globals_headers", ":encoded_frame", + ":inter_frame_delay", ":jitter_estimator", ":timing", ":video_codec_interface", @@ -1107,6 +1120,7 @@ if (rtc_include_tests) { "h264_sprop_parameter_sets_unittest.cc", "h264_sps_pps_tracker_unittest.cc", "histogram_unittest.cc", + "inter_frame_delay_unittest.cc", "jitter_buffer_unittest.cc", "jitter_estimator_tests.cc", "loss_notification_controller_unittest.cc", @@ -1151,6 +1165,7 @@ if (rtc_include_tests) { ":frame_buffer", ":frame_dependencies_calculator", ":h264_packet_buffer", + ":inter_frame_delay", ":jitter_estimator", ":nack_requester", ":packet_buffer", diff --git a/modules/video_coding/frame_buffer2.cc b/modules/video_coding/frame_buffer2.cc index d7944dbfa7..de239817e6 100644 --- a/modules/video_coding/frame_buffer2.cc +++ b/modules/video_coding/frame_buffer2.cc @@ -64,7 +64,6 @@ FrameBuffer::FrameBuffer(Clock* clock, callback_queue_(nullptr), jitter_estimator_(clock), timing_(timing), - inter_frame_delay_(clock_->TimeInMilliseconds()), stopped_(false), protection_mode_(kProtectionNack), stats_callback_(stats_callback), @@ -295,12 +294,11 @@ std::unique_ptr FrameBuffer::GetNextFrame() { } if (!superframe_delayed_by_retransmission) { - int64_t frame_delay; + auto frame_delay = inter_frame_delay_.CalculateDelay( + first_frame.Timestamp(), Timestamp::Millis(receive_time_ms)); - if (inter_frame_delay_.CalculateDelay(first_frame.Timestamp(), &frame_delay, - receive_time_ms)) { - jitter_estimator_.UpdateEstimate(TimeDelta::Millis(frame_delay), - superframe_size); + if (frame_delay) { + jitter_estimator_.UpdateEstimate(*frame_delay, superframe_size); } float rtt_mult = protection_mode_ == kProtectionNackFEC ? 0.0 : 1.0; diff --git a/modules/video_coding/inter_frame_delay.cc b/modules/video_coding/inter_frame_delay.cc index d0c21aa771..8cdb6644ae 100644 --- a/modules/video_coding/inter_frame_delay.cc +++ b/modules/video_coding/inter_frame_delay.cc @@ -10,85 +10,62 @@ #include "modules/video_coding/inter_frame_delay.h" +#include "absl/types/optional.h" +#include "api/units/frequency.h" +#include "api/units/time_delta.h" +#include "modules/include/module_common_types_public.h" + namespace webrtc { -VCMInterFrameDelay::VCMInterFrameDelay(int64_t currentWallClock) { - Reset(currentWallClock); +namespace { +constexpr Frequency k90kHz = Frequency::KiloHertz(90); +} + +VCMInterFrameDelay::VCMInterFrameDelay() { + Reset(); } // Resets the delay estimate. -void VCMInterFrameDelay::Reset(int64_t currentWallClock) { - _zeroWallClock = currentWallClock; - _wrapArounds = 0; - _prevWallClock = 0; - _prevTimestamp = 0; - _dTS = 0; +void VCMInterFrameDelay::Reset() { + prev_wall_clock_ = absl::nullopt; + prev_rtp_timestamp_unwrapped_ = 0; } // Calculates the delay of a frame with the given timestamp. // This method is called when the frame is complete. -bool VCMInterFrameDelay::CalculateDelay(uint32_t timestamp, - int64_t* delay, - int64_t currentWallClock) { - if (_prevWallClock == 0) { +absl::optional VCMInterFrameDelay::CalculateDelay( + uint32_t rtp_timestamp, + Timestamp now) { + int64_t rtp_timestamp_unwrapped = unwrapper_.Unwrap(rtp_timestamp); + if (!prev_wall_clock_) { // First set of data, initialization, wait for next frame. - _prevWallClock = currentWallClock; - _prevTimestamp = timestamp; - *delay = 0; - return true; + prev_wall_clock_ = now; + prev_rtp_timestamp_unwrapped_ = rtp_timestamp_unwrapped; + return TimeDelta::Zero(); } - int32_t prevWrapArounds = _wrapArounds; - CheckForWrapArounds(timestamp); - - // This will be -1 for backward wrap arounds and +1 for forward wrap arounds. - int32_t wrapAroundsSincePrev = _wrapArounds - prevWrapArounds; - // Account for reordering in jitter variance estimate in the future? // Note that this also captures incomplete frames which are grabbed for // decoding after a later frame has been complete, i.e. real packet losses. - if ((wrapAroundsSincePrev == 0 && timestamp < _prevTimestamp) || - wrapAroundsSincePrev < 0) { - *delay = 0; - return false; + uint32_t cropped_last = static_cast(prev_rtp_timestamp_unwrapped_); + if (rtp_timestamp_unwrapped < prev_rtp_timestamp_unwrapped_ || + !IsNewerTimestamp(rtp_timestamp, cropped_last)) { + return absl::nullopt; } - // Compute the compensated timestamp difference and convert it to ms and round - // it to closest integer. - _dTS = static_cast( - (timestamp + wrapAroundsSincePrev * (static_cast(1) << 32) - - _prevTimestamp) / - 90.0 + - 0.5); + // Compute the compensated timestamp difference. + int64_t d_rtp_ticks = rtp_timestamp_unwrapped - prev_rtp_timestamp_unwrapped_; + TimeDelta dts = d_rtp_ticks / k90kHz; + TimeDelta dt = now - *prev_wall_clock_; // frameDelay is the difference of dT and dTS -- i.e. the difference of the // wall clock time difference and the timestamp difference between two // following frames. - *delay = static_cast(currentWallClock - _prevWallClock - _dTS); - - _prevTimestamp = timestamp; - _prevWallClock = currentWallClock; + TimeDelta delay = dt - dts; - return true; + prev_rtp_timestamp_unwrapped_ = rtp_timestamp_unwrapped; + prev_wall_clock_ = now; + return delay; } -// Investigates if the timestamp clock has overflowed since the last timestamp -// and keeps track of the number of wrap arounds since reset. -void VCMInterFrameDelay::CheckForWrapArounds(uint32_t timestamp) { - if (timestamp < _prevTimestamp) { - // This difference will probably be less than -2^31 if we have had a wrap - // around (e.g. timestamp = 1, _prevTimestamp = 2^32 - 1). Since it is cast - // to a int32_t, it should be positive. - if (static_cast(timestamp - _prevTimestamp) > 0) { - // Forward wrap around. - _wrapArounds++; - } - // This difference will probably be less than -2^31 if we have had a - // backward wrap around. Since it is cast to a int32_t, it should be - // positive. - } else if (static_cast(_prevTimestamp - timestamp) > 0) { - // Backward wrap around. - _wrapArounds--; - } -} } // namespace webrtc diff --git a/modules/video_coding/inter_frame_delay.h b/modules/video_coding/inter_frame_delay.h index f121c61498..e0fee6bfba 100644 --- a/modules/video_coding/inter_frame_delay.h +++ b/modules/video_coding/inter_frame_delay.h @@ -13,46 +13,32 @@ #include +#include "absl/types/optional.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" +#include "modules/include/module_common_types_public.h" + namespace webrtc { class VCMInterFrameDelay { public: - explicit VCMInterFrameDelay(int64_t currentWallClock); + VCMInterFrameDelay(); // Resets the estimate. Zeros are given as parameters. - void Reset(int64_t currentWallClock); + void Reset(); // Calculates the delay of a frame with the given timestamp. // This method is called when the frame is complete. - // - // Input: - // - timestamp : RTP timestamp of a received frame. - // - *delay : Pointer to memory where the result should be - // stored. - // - currentWallClock : The current time in milliseconds. - // Should be -1 for normal operation, only used - // for testing. - // Return value : true if OK, false when reordered timestamps. - bool CalculateDelay(uint32_t timestamp, - int64_t* delay, - int64_t currentWallClock); + absl::optional CalculateDelay(uint32_t rtp_timestamp, + Timestamp now); private: - // Controls if the RTP timestamp counter has had a wrap around between the - // current and the previously received frame. - // - // Input: - // - timestamp : RTP timestamp of the current frame. - void CheckForWrapArounds(uint32_t timestamp); - - int64_t _zeroWallClock; // Local timestamp of the first video packet received - int32_t _wrapArounds; // Number of wrapArounds detected - // The previous timestamp passed to the delay estimate - uint32_t _prevTimestamp; + // The previous rtp timestamp passed to the delay estimate + int64_t prev_rtp_timestamp_unwrapped_; + TimestampUnwrapper unwrapper_; + // The previous wall clock timestamp used by the delay estimate - int64_t _prevWallClock; - // Wrap-around compensated difference between incoming timestamps - int64_t _dTS; + absl::optional prev_wall_clock_; }; } // namespace webrtc diff --git a/modules/video_coding/inter_frame_delay_unittest.cc b/modules/video_coding/inter_frame_delay_unittest.cc new file mode 100644 index 0000000000..a338ba9d3b --- /dev/null +++ b/modules/video_coding/inter_frame_delay_unittest.cc @@ -0,0 +1,190 @@ +/* + * Copyright (c) 2022 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/video_coding/inter_frame_delay.h" + +#include + +#include "absl/types/optional.h" +#include "api/units/frequency.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" +#include "system_wrappers/include/clock.h" +#include "test/gmock.h" +#include "test/gtest.h" + +namespace webrtc { + +namespace { + +// Test is for frames at 30fps. At 30fps, RTP timestamps will increase by +// 90000 / 30 = 3000 ticks per frame. +constexpr Frequency k30Fps = Frequency::Hertz(30); +constexpr TimeDelta kFrameDelay = 1 / k30Fps; +constexpr uint32_t kRtpTicksPerFrame = Frequency::KiloHertz(90) / k30Fps; +constexpr Timestamp kStartTime = Timestamp::Millis(1337); + +} // namespace + +using ::testing::Eq; +using ::testing::Optional; + +TEST(InterFrameDelayTest, OldRtpTimestamp) { + VCMInterFrameDelay inter_frame_delay; + EXPECT_THAT(inter_frame_delay.CalculateDelay(180000, kStartTime), + Optional(TimeDelta::Zero())); + EXPECT_THAT(inter_frame_delay.CalculateDelay(90000, kStartTime), + Eq(absl::nullopt)); +} + +TEST(InterFrameDelayTest, NegativeWrapAroundIsSameAsOldRtpTimestamp) { + VCMInterFrameDelay inter_frame_delay; + uint32_t rtp = 1500; + EXPECT_THAT(inter_frame_delay.CalculateDelay(rtp, kStartTime), + Optional(TimeDelta::Zero())); + // RTP has wrapped around backwards. + rtp -= 3000; + EXPECT_THAT(inter_frame_delay.CalculateDelay(rtp, kStartTime), + Eq(absl::nullopt)); +} + +TEST(InterFrameDelayTest, CorrectDelayForFrames) { + VCMInterFrameDelay inter_frame_delay; + // Use a fake clock to simplify time keeping. + SimulatedClock clock(kStartTime); + + // First frame is always delay 0. + uint32_t rtp = 90000; + EXPECT_THAT(inter_frame_delay.CalculateDelay(rtp, clock.CurrentTime()), + Optional(TimeDelta::Zero())); + + // Perfectly timed frame has 0 delay. + clock.AdvanceTime(kFrameDelay); + rtp += kRtpTicksPerFrame; + EXPECT_THAT(inter_frame_delay.CalculateDelay(rtp, clock.CurrentTime()), + Optional(TimeDelta::Zero())); + + // Slightly early frame will have a negative delay. + clock.AdvanceTime(kFrameDelay - TimeDelta::Millis(3)); + rtp += kRtpTicksPerFrame; + EXPECT_THAT(inter_frame_delay.CalculateDelay(rtp, clock.CurrentTime()), + Optional(-TimeDelta::Millis(3))); + + // Slightly late frame will have positive delay. + clock.AdvanceTime(kFrameDelay + TimeDelta::Micros(5125)); + rtp += kRtpTicksPerFrame; + EXPECT_THAT(inter_frame_delay.CalculateDelay(rtp, clock.CurrentTime()), + Optional(TimeDelta::Micros(5125))); + + // Simulate faster frame RTP at the same clock delay. The frame arrives late, + // since the RTP timestamp is faster than the delay, and thus is positive. + clock.AdvanceTime(kFrameDelay); + rtp += kRtpTicksPerFrame / 2; + EXPECT_THAT(inter_frame_delay.CalculateDelay(rtp, clock.CurrentTime()), + Optional(kFrameDelay / 2.0)); + + // Simulate slower frame RTP at the same clock delay. The frame is early, + // since the RTP timestamp advanced more than the delay, and thus is negative. + clock.AdvanceTime(kFrameDelay); + rtp += 1.5 * kRtpTicksPerFrame; + EXPECT_THAT(inter_frame_delay.CalculateDelay(rtp, clock.CurrentTime()), + Optional(-kFrameDelay / 2.0)); +} + +TEST(InterFrameDelayTest, PositiveWrapAround) { + VCMInterFrameDelay inter_frame_delay; + // Use a fake clock to simplify time keeping. + SimulatedClock clock(kStartTime); + + // First frame is behind the max RTP by 1500. + uint32_t rtp = std::numeric_limits::max() - 1500; + EXPECT_THAT(inter_frame_delay.CalculateDelay(rtp, clock.CurrentTime()), + Optional(TimeDelta::Zero())); + + // Rtp wraps around, now 1499. + rtp += kRtpTicksPerFrame; + + // Frame delay should be as normal, in this case simulated as 1ms late. + clock.AdvanceTime(kFrameDelay + TimeDelta::Millis(1)); + EXPECT_THAT(inter_frame_delay.CalculateDelay(rtp, clock.CurrentTime()), + Optional(TimeDelta::Millis(1))); +} + +TEST(InterFrameDelayTest, MultipleWrapArounds) { + // Simulate a long pauses which cause wrap arounds multiple times. + constexpr Frequency k90Khz = Frequency::KiloHertz(90); + constexpr uint32_t kHalfRtp = std::numeric_limits::max() / 2; + constexpr TimeDelta kWrapAroundDelay = kHalfRtp / k90Khz; + + VCMInterFrameDelay inter_frame_delay; + // Use a fake clock to simplify time keeping. + SimulatedClock clock(kStartTime); + uint32_t rtp = 0; + EXPECT_THAT(inter_frame_delay.CalculateDelay(rtp, clock.CurrentTime()), + Optional(TimeDelta::Zero())); + + rtp += kHalfRtp; + clock.AdvanceTime(kWrapAroundDelay); + EXPECT_THAT(inter_frame_delay.CalculateDelay(rtp, clock.CurrentTime()), + Optional(TimeDelta::Zero())); + // 1st wrap around. + rtp += kHalfRtp + 1; + clock.AdvanceTime(kWrapAroundDelay + TimeDelta::Millis(1)); + EXPECT_THAT(inter_frame_delay.CalculateDelay(rtp, clock.CurrentTime()), + Optional(TimeDelta::Millis(1) - (1 / k90Khz))); + + rtp += kHalfRtp; + clock.AdvanceTime(kWrapAroundDelay); + EXPECT_THAT(inter_frame_delay.CalculateDelay(rtp, clock.CurrentTime()), + Optional(TimeDelta::Zero())); + // 2nd wrap arounds. + rtp += kHalfRtp + 1; + clock.AdvanceTime(kWrapAroundDelay - TimeDelta::Millis(1)); + EXPECT_THAT(inter_frame_delay.CalculateDelay(rtp, clock.CurrentTime()), + Optional(-TimeDelta::Millis(1) - (1 / k90Khz))); + + // Ensure short delay (large RTP delay) between wrap-arounds has correct + // jitter. + rtp += kHalfRtp; + clock.AdvanceTime(TimeDelta::Millis(10)); + EXPECT_THAT(inter_frame_delay.CalculateDelay(rtp, clock.CurrentTime()), + Optional(-(kWrapAroundDelay - TimeDelta::Millis(10)))); + // 3nd wrap arounds, this time with large RTP delay. + rtp += kHalfRtp + 1; + clock.AdvanceTime(TimeDelta::Millis(10)); + EXPECT_THAT( + inter_frame_delay.CalculateDelay(rtp, clock.CurrentTime()), + Optional(-(kWrapAroundDelay - TimeDelta::Millis(10) + (1 / k90Khz)))); +} + +TEST(InterFrameDelayTest, NegativeWrapAroundAfterPositiveWrapAround) { + VCMInterFrameDelay inter_frame_delay; + // Use a fake clock to simplify time keeping. + SimulatedClock clock(kStartTime); + uint32_t rtp = std::numeric_limits::max() - 1500; + EXPECT_THAT(inter_frame_delay.CalculateDelay(rtp, clock.CurrentTime()), + Optional(TimeDelta::Zero())); + + // Rtp wraps around, now 1499. + rtp += kRtpTicksPerFrame; + // Frame delay should be as normal, in this case simulated as 1ms late. + clock.AdvanceTime(kFrameDelay); + EXPECT_THAT(inter_frame_delay.CalculateDelay(rtp, clock.CurrentTime()), + Optional(TimeDelta::Zero())); + + // Wrap back. + rtp -= kRtpTicksPerFrame; + // Frame delay should be as normal, in this case simulated as 1ms late. + clock.AdvanceTime(kFrameDelay); + EXPECT_THAT(inter_frame_delay.CalculateDelay(rtp, clock.CurrentTime()), + Eq(absl::nullopt)); +} + +} // namespace webrtc diff --git a/modules/video_coding/jitter_buffer.cc b/modules/video_coding/jitter_buffer.cc index a49ee6968c..f51b6ec898 100644 --- a/modules/video_coding/jitter_buffer.cc +++ b/modules/video_coding/jitter_buffer.cc @@ -9,11 +9,11 @@ */ #include "modules/video_coding/jitter_buffer.h" - #include #include #include +#include "api/units/timestamp.h" #include "modules/video_coding/frame_buffer.h" #include "modules/video_coding/include/video_coding.h" #include "modules/video_coding/inter_frame_delay.h" @@ -123,7 +123,6 @@ VCMJitterBuffer::VCMJitterBuffer(Clock* clock, num_packets_(0), num_duplicated_packets_(0), jitter_estimate_(clock), - inter_frame_delay_(clock_->TimeInMilliseconds()), missing_sequence_numbers_(SequenceNumberLessThan()), latest_received_sequence_number_(0), max_nack_list_size_(0), @@ -192,7 +191,7 @@ void VCMJitterBuffer::Flush() { num_consecutive_old_packets_ = 0; // Also reset the jitter and delay estimates jitter_estimate_.Reset(); - inter_frame_delay_.Reset(clock_->TimeInMilliseconds()); + inter_frame_delay_.Reset(); waiting_for_completion_.frame_size = 0; waiting_for_completion_.timestamp = 0; waiting_for_completion_.latest_packet_time = -1; @@ -392,13 +391,13 @@ VCMFrameBufferEnum VCMJitterBuffer::InsertPacket(const VCMPacket& packet, if (error != kNoError) return error; - int64_t now_ms = clock_->TimeInMilliseconds(); + Timestamp now = clock_->CurrentTime(); // We are keeping track of the first and latest seq numbers, and // the number of wraps to be able to calculate how many packets we expect. if (first_packet_since_reset_) { // Now it's time to start estimating jitter // reset the delay estimate. - inter_frame_delay_.Reset(now_ms); + inter_frame_delay_.Reset(); } // Empty packets may bias the jitter estimate (lacking size component), @@ -408,9 +407,9 @@ VCMFrameBufferEnum VCMJitterBuffer::InsertPacket(const VCMPacket& packet, // This can get bad if we have a lot of duplicate packets, // we will then count some packet multiple times. waiting_for_completion_.frame_size += packet.sizeBytes; - waiting_for_completion_.latest_packet_time = now_ms; + waiting_for_completion_.latest_packet_time = now.ms(); } else if (waiting_for_completion_.latest_packet_time >= 0 && - waiting_for_completion_.latest_packet_time + 2000 <= now_ms) { + waiting_for_completion_.latest_packet_time + 2000 <= now.ms()) { // A packet should never be more than two seconds late UpdateJitterEstimate(waiting_for_completion_, true); waiting_for_completion_.latest_packet_time = -1; @@ -425,7 +424,7 @@ VCMFrameBufferEnum VCMJitterBuffer::InsertPacket(const VCMPacket& packet, frame_data.rtt_ms = kDefaultRtt; frame_data.rolling_average_packets_per_frame = average_packets_per_frame_; VCMFrameBufferEnum buffer_state = - frame->InsertPacket(packet, now_ms, frame_data); + frame->InsertPacket(packet, now.ms(), frame_data); if (buffer_state > 0) { if (first_packet_since_reset_) { @@ -873,14 +872,14 @@ void VCMJitterBuffer::UpdateJitterEstimate(int64_t latest_packet_time_ms, if (latest_packet_time_ms == -1) { return; } - int64_t frame_delay; - bool not_reordered = inter_frame_delay_.CalculateDelay( - timestamp, &frame_delay, latest_packet_time_ms); + auto frame_delay = inter_frame_delay_.CalculateDelay( + timestamp, Timestamp::Millis(latest_packet_time_ms)); + + bool not_reordered = frame_delay.has_value(); // Filter out frames which have been reordered in time by the network if (not_reordered) { // Update the jitter estimate with the new samples - jitter_estimate_.UpdateEstimate(TimeDelta::Millis(frame_delay), - DataSize::Bytes(frame_size), + jitter_estimate_.UpdateEstimate(*frame_delay, DataSize::Bytes(frame_size), incomplete_frame); } } diff --git a/video/BUILD.gn b/video/BUILD.gn index e5ba48b3b2..8dcef1ae68 100644 --- a/video/BUILD.gn +++ b/video/BUILD.gn @@ -100,6 +100,7 @@ rtc_library("video") { "../modules/video_coding:codec_globals_headers", "../modules/video_coding:frame_buffer", "../modules/video_coding:frame_helpers", + "../modules/video_coding:inter_frame_delay", "../modules/video_coding:jitter_estimator", "../modules/video_coding:nack_requester", "../modules/video_coding:packet_buffer", diff --git a/video/frame_buffer_proxy.cc b/video/frame_buffer_proxy.cc index c7fce7ae19..2ec3ac41c9 100644 --- a/video/frame_buffer_proxy.cc +++ b/video/frame_buffer_proxy.cc @@ -149,7 +149,7 @@ struct FrameMetadata { contentType(frame.contentType()), delayed_by_retransmission(frame.delayed_by_retransmission()), rtp_timestamp(frame.Timestamp()), - receive_time_ms(frame.ReceivedTime()) {} + receive_time(frame.ReceivedTimestamp()) {} const bool is_last_spatial_layer; const bool is_keyframe; @@ -157,9 +157,15 @@ struct FrameMetadata { const VideoContentType contentType; const bool delayed_by_retransmission; const uint32_t rtp_timestamp; - const int64_t receive_time_ms; + const absl::optional receive_time; }; +Timestamp ReceiveTime(const EncodedFrame& frame) { + absl::optional ts = frame.ReceivedTimestamp(); + RTC_DCHECK(ts.has_value()) << "Received frame must have a timestamp set!"; + return *ts; +} + // Encapsulates use of the new frame buffer for use in VideoReceiveStream. This // behaves the same as the FrameBuffer2Proxy but uses frame_buffer3 instead. // Responsibilities from frame_buffer2, like stats, jitter and frame timing @@ -186,7 +192,6 @@ class FrameBuffer3Proxy : public FrameBufferProxy { timing_(timing), frame_decode_scheduler_(std::move(frame_decode_scheduler)), jitter_estimator_(clock_), - inter_frame_delay_(clock_->TimeInMilliseconds()), buffer_(std::make_unique(kMaxFramesBuffered, kMaxFramesHistory)), decode_timing_(clock_, timing_), @@ -248,12 +253,10 @@ class FrameBuffer3Proxy : public FrameBufferProxy { if (complete_units < buffer_->GetTotalNumberOfContinuousTemporalUnits()) { stats_proxy_->OnCompleteFrame(metadata.is_keyframe, metadata.size, metadata.contentType); - RTC_DCHECK_GE(metadata.receive_time_ms, 0) - << "Frame receive time must be positive for received frames, was " - << metadata.receive_time_ms << "."; - if (!metadata.delayed_by_retransmission && metadata.receive_time_ms >= 0) + RTC_DCHECK(metadata.receive_time) << "Frame receive time must be set!"; + if (!metadata.delayed_by_retransmission && metadata.receive_time) timing_->IncomingTimestamp(metadata.rtp_timestamp, - Timestamp::Millis(metadata.receive_time_ms)); + *metadata.receive_time); MaybeScheduleFrameForRelease(); } @@ -301,7 +304,7 @@ class FrameBuffer3Proxy : public FrameBufferProxy { bool superframe_delayed_by_retransmission = false; DataSize superframe_size = DataSize::Zero(); const EncodedFrame& first_frame = *frames.front(); - int64_t receive_time_ms = first_frame.ReceivedTime(); + Timestamp receive_time = ReceiveTime(first_frame); if (first_frame.is_keyframe()) keyframe_required_ = false; @@ -319,17 +322,15 @@ class FrameBuffer3Proxy : public FrameBufferProxy { superframe_delayed_by_retransmission |= frame->delayed_by_retransmission(); - receive_time_ms = std::max(receive_time_ms, frame->ReceivedTime()); + receive_time = std::max(receive_time, ReceiveTime(*frame)); superframe_size += DataSize::Bytes(frame->size()); } if (!superframe_delayed_by_retransmission) { - int64_t frame_delay; - - if (inter_frame_delay_.CalculateDelay(first_frame.Timestamp(), - &frame_delay, receive_time_ms)) { - jitter_estimator_.UpdateEstimate(TimeDelta::Millis(frame_delay), - superframe_size); + auto frame_delay = inter_frame_delay_.CalculateDelay( + first_frame.Timestamp(), receive_time); + if (frame_delay) { + jitter_estimator_.UpdateEstimate(*frame_delay, superframe_size); } float rtt_mult = protection_mode_ == kProtectionNackFEC ? 0.0 : 1.0; From 7e04b49bb81c60a3bc5d5c6c61746f828e3eb1f9 Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Tue, 8 Mar 2022 01:26:03 +0100 Subject: [PATCH 122/847] [PCLF] Add ability to provide audio processor and mixer Bug: b/196034093 Change-Id: Ia444acfcf3f3c40e4a3affd61ed9c107470ef013 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253880 Reviewed-by: Mirko Bonadei Reviewed-by: Sam Zackrisson Commit-Queue: Artem Titov Cr-Commit-Position: refs/heads/main@{#36148} --- api/BUILD.gn | 2 ++ api/test/DEPS | 1 + .../peerconnection_quality_test_fixture.h | 6 +++++ test/pc/e2e/BUILD.gn | 4 +++ test/pc/e2e/peer_configurer.h | 12 +++++++++ .../e2e/peer_connection_quality_test_params.h | 5 ++++ test/pc/e2e/test_peer_factory.cc | 26 ++++++++++++------- 7 files changed, 46 insertions(+), 10 deletions(-) diff --git a/api/BUILD.gn b/api/BUILD.gn index 9d9bf55b8b..f8a6532866 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn @@ -445,8 +445,10 @@ rtc_source_set("peer_connection_quality_test_fixture_api") { ":track_id_stream_info_map", ":video_quality_analyzer_api", "../media:rtc_media_base", + "../modules/audio_processing:api", "../rtc_base:rtc_base", "../rtc_base:threading", + "audio:audio_mixer_api", "rtc_event_log", "task_queue", "transport:network_control", diff --git a/api/test/DEPS b/api/test/DEPS index 6c3a9ebed1..48889d528f 100644 --- a/api/test/DEPS +++ b/api/test/DEPS @@ -27,6 +27,7 @@ specific_include_rules = { "+rtc_base/ssl_certificate.h", "+rtc_base/thread.h", "+media/base/media_constants.h", + "+modules/audio_processing/include/audio_processing.h", ], "time_controller\.h": [ "+modules/utility/include/process_thread.h", diff --git a/api/test/peerconnection_quality_test_fixture.h b/api/test/peerconnection_quality_test_fixture.h index 1bd2eb2635..434a3a643f 100644 --- a/api/test/peerconnection_quality_test_fixture.h +++ b/api/test/peerconnection_quality_test_fixture.h @@ -20,6 +20,7 @@ #include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "api/async_resolver_factory.h" +#include "api/audio/audio_mixer.h" #include "api/call/call_factory_interface.h" #include "api/fec_controller.h" #include "api/function_view.h" @@ -41,6 +42,7 @@ #include "api/video_codecs/video_encoder.h" #include "api/video_codecs/video_encoder_factory.h" #include "media/base/media_constants.h" +#include "modules/audio_processing/include/audio_processing.h" #include "rtc_base/network.h" #include "rtc_base/rtc_certificate_generator.h" #include "rtc_base/ssl_certificate.h" @@ -357,6 +359,10 @@ class PeerConnectionE2EQualityTestFixture { // Set a custom NetEqFactory to be used in the call. virtual PeerConfigurer* SetNetEqFactory( std::unique_ptr neteq_factory) = 0; + virtual PeerConfigurer* SetAudioProcessing( + rtc::scoped_refptr audio_processing) = 0; + virtual PeerConfigurer* SetAudioMixer( + rtc::scoped_refptr audio_mixer) = 0; // The parameters of the following 4 methods will be passed to the // PeerConnectionInterface implementation that will be created for this diff --git a/test/pc/e2e/BUILD.gn b/test/pc/e2e/BUILD.gn index 4e4b6bfda3..37cf51b6b7 100644 --- a/test/pc/e2e/BUILD.gn +++ b/test/pc/e2e/BUILD.gn @@ -55,11 +55,13 @@ if (!build_with_chromium) { "../../../api:libjingle_peerconnection_api", "../../../api:packet_socket_factory", "../../../api:peer_connection_quality_test_fixture_api", + "../../../api/audio:audio_mixer_api", "../../../api/rtc_event_log", "../../../api/task_queue", "../../../api/transport:network_control", "../../../api/transport:webrtc_key_value_config", "../../../api/video_codecs:video_codecs_api", + "../../../modules/audio_processing:api", "../../../p2p:rtc_p2p", "../../../rtc_base", "../../../rtc_base:threading", @@ -313,10 +315,12 @@ if (!build_with_chromium) { "../../../api:fec_controller_api", "../../../api:packet_socket_factory", "../../../api:peer_connection_quality_test_fixture_api", + "../../../api/audio:audio_mixer_api", "../../../api/rtc_event_log", "../../../api/task_queue", "../../../api/transport:network_control", "../../../api/video_codecs:video_codecs_api", + "../../../modules/audio_processing:api", "../../../rtc_base", "../../../rtc_base:threading", ] diff --git a/test/pc/e2e/peer_configurer.h b/test/pc/e2e/peer_configurer.h index 33ad5ebd12..27133e494d 100644 --- a/test/pc/e2e/peer_configurer.h +++ b/test/pc/e2e/peer_configurer.h @@ -17,6 +17,7 @@ #include "absl/strings/string_view.h" #include "api/async_resolver_factory.h" +#include "api/audio/audio_mixer.h" #include "api/call/call_factory_interface.h" #include "api/fec_controller.h" #include "api/rtc_event_log/rtc_event_log_factory_interface.h" @@ -26,6 +27,7 @@ #include "api/transport/network_control.h" #include "api/video_codecs/video_decoder_factory.h" #include "api/video_codecs/video_encoder_factory.h" +#include "modules/audio_processing/include/audio_processing.h" #include "rtc_base/network.h" #include "rtc_base/rtc_certificate_generator.h" #include "rtc_base/ssl_certificate.h" @@ -165,6 +167,16 @@ class PeerConfigurerImpl final components_->pcf_dependencies->neteq_factory = std::move(neteq_factory); return this; } + PeerConfigurer* SetAudioProcessing( + rtc::scoped_refptr audio_processing) override { + components_->pcf_dependencies->audio_processing = audio_processing; + return this; + } + PeerConfigurer* SetAudioMixer( + rtc::scoped_refptr audio_mixer) override { + components_->pcf_dependencies->audio_mixer = audio_mixer; + return this; + } PeerConfigurer* SetRtcEventLogPath(std::string path) override { params_->rtc_event_log_path = std::move(path); return this; diff --git a/test/pc/e2e/peer_connection_quality_test_params.h b/test/pc/e2e/peer_connection_quality_test_params.h index 93fa8c11b9..fae231c653 100644 --- a/test/pc/e2e/peer_connection_quality_test_params.h +++ b/test/pc/e2e/peer_connection_quality_test_params.h @@ -15,6 +15,7 @@ #include #include "api/async_resolver_factory.h" +#include "api/audio/audio_mixer.h" #include "api/call/call_factory_interface.h" #include "api/fec_controller.h" #include "api/rtc_event_log/rtc_event_log_factory_interface.h" @@ -24,6 +25,7 @@ #include "api/transport/webrtc_key_value_config.h" #include "api/video_codecs/video_decoder_factory.h" #include "api/video_codecs/video_encoder_factory.h" +#include "modules/audio_processing/include/audio_processing.h" #include "p2p/base/port_allocator.h" #include "rtc_base/network.h" #include "rtc_base/rtc_certificate_generator.h" @@ -56,6 +58,9 @@ struct PeerConnectionFactoryComponents { std::unique_ptr video_decoder_factory; std::unique_ptr trials; + + rtc::scoped_refptr audio_processing; + rtc::scoped_refptr audio_mixer; }; // Contains most parts from PeerConnectionDependencies. Also all fields are diff --git a/test/pc/e2e/test_peer_factory.cc b/test/pc/e2e/test_peer_factory.cc index 119c8e114f..29a4c6a8f2 100644 --- a/test/pc/e2e/test_peer_factory.cc +++ b/test/pc/e2e/test_peer_factory.cc @@ -167,12 +167,12 @@ rtc::scoped_refptr CreateAudioDeviceModule( std::unique_ptr CreateMediaEngine( PeerConnectionFactoryComponents* pcf_dependencies, - rtc::scoped_refptr audio_device_module, - rtc::scoped_refptr audio_processing) { + rtc::scoped_refptr audio_device_module) { cricket::MediaEngineDependencies media_deps; media_deps.task_queue_factory = pcf_dependencies->task_queue_factory.get(); media_deps.adm = audio_device_module; - media_deps.audio_processing = audio_processing; + media_deps.audio_processing = pcf_dependencies->audio_processing; + media_deps.audio_mixer = pcf_dependencies->audio_mixer; media_deps.video_encoder_factory = std::move(pcf_dependencies->video_encoder_factory); media_deps.video_decoder_factory = @@ -315,11 +315,13 @@ std::unique_ptr TestPeerFactory::CreateTestPeer( params->rtc_configuration.sdp_semantics = SdpSemantics::kUnifiedPlan; // Create peer connection factory. - rtc::scoped_refptr audio_processing = - webrtc::AudioProcessingBuilder().Create(); - if (params->aec_dump_path && audio_processing) { - audio_processing->CreateAndAttachAecDump(*params->aec_dump_path, -1, - task_queue_); + if (components->pcf_dependencies->audio_processing == nullptr) { + components->pcf_dependencies->audio_processing = + webrtc::AudioProcessingBuilder().Create(); + } + if (params->aec_dump_path) { + components->pcf_dependencies->audio_processing->CreateAndAttachAecDump( + *params->aec_dump_path, -1, task_queue_); } rtc::scoped_refptr audio_device_module = CreateAudioDeviceModule( @@ -333,11 +335,15 @@ std::unique_ptr TestPeerFactory::CreateTestPeer( components->pcf_dependencies.get(), video_analyzer_helper_); std::unique_ptr media_engine = - CreateMediaEngine(components->pcf_dependencies.get(), audio_device_module, - audio_processing); + CreateMediaEngine(components->pcf_dependencies.get(), + audio_device_module); std::unique_ptr worker_thread = time_controller_.CreateThread("worker_thread"); + // Store `webrtc::AudioProcessing` into local variable before move of + // `components->pcf_dependencies` + rtc::scoped_refptr audio_processing = + components->pcf_dependencies->audio_processing; PeerConnectionFactoryDependencies pcf_deps = CreatePCFDependencies( std::move(components->pcf_dependencies), std::move(media_engine), signaling_thread_, worker_thread.get(), components->network_thread); From c7c5764eaeb975553997ac3d7e01ed5cf8eaa257 Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Tue, 8 Mar 2022 01:40:00 -0800 Subject: [PATCH 123/847] Update WebRTC code version (2022-03-08T09:39:59). Bug: None Change-Id: Id077e8be720580f6eccbe1c24488d101fd4183a3 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253920 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36149} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index e5f326b777..47148b19b3 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 2022-03-07T04:04:33"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-03-08T09:39:59"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From 775ce76b66c323ad853c867144339adaa547e535 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Tue, 8 Mar 2022 14:11:36 +0100 Subject: [PATCH 124/847] Don't swallow UnsatisfiedLinkError MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When loading the library fails, the user will be faced with this error: java.lang.UnsatisfiedLinkError: No implementation found for void org.webrtc.PeerConnectionFactory.nativeInitializeAndroidGlobals() With no context, however. Bug: webrtc:13619 Change-Id: I88565f085773ad1e8c2f5742d7fdba96fb6043d8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253960 Reviewed-by: Christoffer Jansson Reviewed-by: Xavier Lepaul‎ Commit-Queue: Xavier Lepaul‎ Cr-Commit-Position: refs/heads/main@{#36150} --- sdk/android/src/java/org/webrtc/NativeLibrary.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sdk/android/src/java/org/webrtc/NativeLibrary.java b/sdk/android/src/java/org/webrtc/NativeLibrary.java index 7fa5d6ff16..531c216302 100644 --- a/sdk/android/src/java/org/webrtc/NativeLibrary.java +++ b/sdk/android/src/java/org/webrtc/NativeLibrary.java @@ -17,12 +17,9 @@ static class DefaultLoader implements NativeLibraryLoader { @Override public boolean load(String name) { Logging.d(TAG, "Loading library: " + name); - try { - System.loadLibrary(name); - } catch (UnsatisfiedLinkError e) { - Logging.e(TAG, "Failed to load native library: " + name, e); - return false; - } + System.loadLibrary(name); + + // Not relevant, but kept for API compatibility. return true; } } From ddcfe405d3bc7a9c3c17ce6a46236fac64b54fe9 Mon Sep 17 00:00:00 2001 From: Jerome Jiang Date: Tue, 8 Mar 2022 11:58:44 -0800 Subject: [PATCH 125/847] Change PSNR threshold for av1 test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: None Change-Id: I47101a6625c2f1704599ea60ad3f2c05370da66e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254101 Reviewed-by: Erik Språng Commit-Queue: Jerome Jiang Cr-Commit-Position: refs/heads/main@{#36151} --- modules/video_coding/codecs/test/videocodec_test_av1.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/video_coding/codecs/test/videocodec_test_av1.cc b/modules/video_coding/codecs/test/videocodec_test_av1.cc index 3a7f61edc1..f53afde14b 100644 --- a/modules/video_coding/codecs/test/videocodec_test_av1.cc +++ b/modules/video_coding/codecs/test/videocodec_test_av1.cc @@ -78,7 +78,7 @@ TEST_P(VideoCodecTestAv1, VeryLowBitrate) { std::vector rc_thresholds = { {15, 8, 75, 2, 2, 2, 2, 1}}; - std::vector quality_thresholds = {{28, 24.9, 0.70, 0.55}}; + std::vector quality_thresholds = {{28, 24.8, 0.70, 0.55}}; fixture->RunTest(rate_profiles, &rc_thresholds, &quality_thresholds, nullptr); } From 41cf5fb7213ddeb782e200a89a9e3b96aab34a3b Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Tue, 8 Mar 2022 20:01:54 -0800 Subject: [PATCH 126/847] Update WebRTC code version (2022-03-09T04:01:53). Bug: None Change-Id: I92463dab13eebfa2e6b5d6fe4f41ba9b69cb7034 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254200 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36152} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index 47148b19b3..801455c5c5 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 2022-03-08T09:39:59"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-03-09T04:01:53"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From f73b524a5a0120257f38064fcd822230c7416456 Mon Sep 17 00:00:00 2001 From: Per Kjellander Date: Tue, 8 Mar 2022 17:57:11 +0100 Subject: [PATCH 127/847] Add perkj@ as owner of remote_bitrate_estimator And remove srte since they are no longer active. Bug: none Change-Id: I259898db1223d43d13b918ece6555c5f687ce23f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254060 Reviewed-by: Stefan Holmer Commit-Queue: Stefan Holmer Cr-Commit-Position: refs/heads/main@{#36153} --- modules/remote_bitrate_estimator/OWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/remote_bitrate_estimator/OWNERS b/modules/remote_bitrate_estimator/OWNERS index 9b97144ac8..97e5d51dac 100644 --- a/modules/remote_bitrate_estimator/OWNERS +++ b/modules/remote_bitrate_estimator/OWNERS @@ -3,4 +3,4 @@ terelius@webrtc.org asapersson@webrtc.org mflodman@webrtc.org philipel@webrtc.org -srte@webrtc.org +perkj@webrtc.org From 4d54260ae2ed4b0d7b4148674a7f8fb1a989215d Mon Sep 17 00:00:00 2001 From: Per Kjellander Date: Wed, 9 Mar 2022 09:29:42 +0100 Subject: [PATCH 128/847] Field trial to not clamp delay based estimate to a lowered link estimate This adds a new paramater to WebRTC-Bwe-EstimateBoundedIncrease that ensure that even if the link capacity has decreased, the delay based estimate does not immediately decrease unless an overuse has been detected. This is a follow up to https://webrtc-review.googlesource.com/c/src/+/252442/ Bug: none Change-Id: I98d77ba1e3f7856b06f2691575f2d248a500e659 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253901 Reviewed-by: Diep Bui Commit-Queue: Per Kjellander Cr-Commit-Position: refs/heads/main@{#36154} --- modules/remote_bitrate_estimator/BUILD.gn | 1 + .../aimd_rate_control.cc | 8 +- .../aimd_rate_control.h | 2 + .../aimd_rate_control_unittest.cc | 83 +++++++++++++++++++ 4 files changed, 92 insertions(+), 2 deletions(-) diff --git a/modules/remote_bitrate_estimator/BUILD.gn b/modules/remote_bitrate_estimator/BUILD.gn index 923f00a74c..fd52b2dcb9 100644 --- a/modules/remote_bitrate_estimator/BUILD.gn +++ b/modules/remote_bitrate_estimator/BUILD.gn @@ -122,6 +122,7 @@ if (rtc_include_tests) { "../../api/transport:field_trial_based_config", "../../api/transport:mock_network_control", "../../api/transport:network_control", + "../../api/units:data_rate", "../../rtc_base", "../../rtc_base:checks", "../../rtc_base:rtc_base_approved", diff --git a/modules/remote_bitrate_estimator/aimd_rate_control.cc b/modules/remote_bitrate_estimator/aimd_rate_control.cc index bf1d431879..1714dd115a 100644 --- a/modules/remote_bitrate_estimator/aimd_rate_control.cc +++ b/modules/remote_bitrate_estimator/aimd_rate_control.cc @@ -99,7 +99,8 @@ AimdRateControl::AimdRateControl(const WebRtcKeyValueConfig* key_value_config, link_capacity_fix_("link_capacity_fix") { ParseFieldTrial( {&disable_estimate_bounded_increase_, &estimate_bounded_increase_ratio_, - &ignore_throughput_limit_if_network_estimate_}, + &ignore_throughput_limit_if_network_estimate_, + &ignore_network_estimate_decrease_}, key_value_config->Lookup("WebRTC-Bwe-EstimateBoundedIncrease")); // E.g // WebRTC-BweAimdRateControlConfig/initial_backoff_interval:100ms/ @@ -380,7 +381,10 @@ DataRate AimdRateControl::ClampBitrate(DataRate new_bitrate) const { network_estimate_->link_capacity_upper.IsFinite()) { DataRate upper_bound = network_estimate_->link_capacity_upper * estimate_bounded_increase_ratio_.Get(); - new_bitrate = std::min(new_bitrate, upper_bound); + if (ignore_network_estimate_decrease_) { + upper_bound = std::max(upper_bound, current_bitrate_); + } + new_bitrate = std::min(upper_bound, new_bitrate); } new_bitrate = std::max(new_bitrate, min_configured_bitrate_); return new_bitrate; diff --git a/modules/remote_bitrate_estimator/aimd_rate_control.h b/modules/remote_bitrate_estimator/aimd_rate_control.h index 12dec32b4d..699b185c2d 100644 --- a/modules/remote_bitrate_estimator/aimd_rate_control.h +++ b/modules/remote_bitrate_estimator/aimd_rate_control.h @@ -113,6 +113,8 @@ class AimdRateControl { FieldTrialParameter estimate_bounded_increase_ratio_{"ratio", 1.0}; FieldTrialParameter ignore_throughput_limit_if_network_estimate_{ "ignore_acked", false}; + FieldTrialParameter ignore_network_estimate_decrease_{"ignore_decr", + false}; absl::optional last_decrease_; FieldTrialOptional initial_backoff_interval_; FieldTrialFlag link_capacity_fix_; diff --git a/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc b/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc index 34aafb4f91..5d9c328e06 100644 --- a/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc +++ b/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc @@ -12,6 +12,7 @@ #include #include "api/transport/field_trial_based_config.h" +#include "api/units/data_rate.h" #include "system_wrappers/include/clock.h" #include "test/field_trial.h" #include "test/gtest.h" @@ -254,6 +255,37 @@ TEST(AimdRateControlTest, SetEstimateIncreaseBweInAlr) { 2 * kInitialBitrateBps); } +TEST(AimdRateControlTest, SetEstimateClampedByNetworkEstimate) { + auto states = CreateAimdRateControlStates(/*send_side=*/true); + NetworkStateEstimate network_estimate; + network_estimate.link_capacity_upper = DataRate::KilobitsPerSec(400); + states.aimd_rate_control->SetNetworkStateEstimate(network_estimate); + SetEstimate(states, 500'000); + EXPECT_EQ(states.aimd_rate_control->LatestEstimate(), + network_estimate.link_capacity_upper); +} + +TEST(AimdRateControlTest, SetEstimateIgnoresNetworkEstimatesLowerThanCurrent) { + test::ScopedFieldTrials override_field_trials( + "WebRTC-Bwe-EstimateBoundedIncrease/" + "ratio:0.85,ignore_acked:true,ignore_decr:true/"); + auto states = CreateAimdRateControlStates(/*send_side=*/true); + states.aimd_rate_control->SetStartBitrate(DataRate::KilobitsPerSec(30)); + NetworkStateEstimate network_estimate; + network_estimate.link_capacity_upper = DataRate::KilobitsPerSec(400); + states.aimd_rate_control->SetNetworkStateEstimate(network_estimate); + SetEstimate(states, 500'000); + ASSERT_EQ(states.aimd_rate_control->LatestEstimate(), + network_estimate.link_capacity_upper * 0.85); + + NetworkStateEstimate lower_network_estimate; + lower_network_estimate.link_capacity_upper = DataRate::KilobitsPerSec(300); + states.aimd_rate_control->SetNetworkStateEstimate(lower_network_estimate); + SetEstimate(states, 500'000); + EXPECT_EQ(states.aimd_rate_control->LatestEstimate(), + network_estimate.link_capacity_upper * 0.85); +} + 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. @@ -317,6 +349,57 @@ TEST(AimdRateControlTest, EstimateLimitedByNetworkEstimateInAlrIfSet) { network_estimate.link_capacity_upper * 0.85); } +TEST(AimdRateControlTest, EstimateNotLoweredByNetworkEstimate) { + // The delay based estimator is allowed to increase up to a percentage of + // upper link capacity but does not decrease unless the delay detector + // discover an overuse. + test::ScopedFieldTrials override_field_trials( + "WebRTC-Bwe-EstimateBoundedIncrease/" + "ratio:0.85,ignore_acked:true,ignore_decr:true/" + "WebRTC-DontIncreaseDelayBasedBweInAlr/Enabled/"); + auto states = CreateAimdRateControlStates(/*send_side=*/true); + constexpr int kInitialBitrateBps = 123000; + constexpr int kEstimatedThroughputBps = 30'000; + SetEstimate(states, kInitialBitrateBps); + + NetworkStateEstimate network_estimate; + network_estimate.link_capacity_upper = DataRate::KilobitsPerSec(200); + states.aimd_rate_control->SetNetworkStateEstimate(network_estimate); + for (int i = 0; i < 100; ++i) { + UpdateRateControl(states, BandwidthUsage::kBwNormal, + kEstimatedThroughputBps, + states.simulated_clock->TimeInMilliseconds()); + states.simulated_clock->AdvanceTimeMilliseconds(100); + } + DataRate estimate_after_increase = states.aimd_rate_control->LatestEstimate(); + ASSERT_EQ(estimate_after_increase, + network_estimate.link_capacity_upper * 0.85); + + // A lower network estimate does not decrease the estimate immediately, + // but the estimate is not allowed to increase. + network_estimate.link_capacity_upper = DataRate::KilobitsPerSec(100); + network_estimate.link_capacity_lower = DataRate::KilobitsPerSec(80); + states.aimd_rate_control->SetNetworkStateEstimate(network_estimate); + for (int i = 0; i < 10; ++i) { + UpdateRateControl(states, BandwidthUsage::kBwNormal, + kEstimatedThroughputBps, + states.simulated_clock->TimeInMilliseconds()); + states.simulated_clock->AdvanceTimeMilliseconds(100); + EXPECT_EQ(states.aimd_rate_control->LatestEstimate(), + estimate_after_increase); + } + + // If the detector detects and overuse, BWE drops to a value relative the + // network estimate. + UpdateRateControl(states, BandwidthUsage::kBwOverusing, + kEstimatedThroughputBps, + states.simulated_clock->TimeInMilliseconds()); + EXPECT_LT(states.aimd_rate_control->LatestEstimate(), + network_estimate.link_capacity_lower); + EXPECT_GT(states.aimd_rate_control->LatestEstimate().bps(), + kEstimatedThroughputBps); +} + TEST(AimdRateControlTest, EstimateDoesNotIncreaseInAlrIfNetworkEstimateNotSet) { // 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 From a04b8b504393d7d36ae1e173dcb223371c2e197b Mon Sep 17 00:00:00 2001 From: Victor Boivie Date: Tue, 8 Mar 2022 09:36:55 +0100 Subject: [PATCH 129/847] dcsctp: Handle losing first DATA on ordered stream When a FORWARD-TSN is received as the first chunk on an ordered stream, it will fail to set the new "next expected SSN" that is present in the FORWARD-TSN as that stream hasn't been allocated yet. It's allocated when the first DATA is received on that stream. This is a non-issue for ordinary data channels as the first message on any stream will be the "Data Channel Establishment Protocol" messages, which are always sent reliably. But if prenegotiated channels are used, and the very first packet received on an ordered data channel is lost _and_ signaled to the receiver as lost _before_ the receiver has received any other fragments on that data channel, future messages will not be delivered on that channel. Bug: webrtc:13799 Change-Id: Ide5c656243b3a51a2ed9d76615cfc3631cfe900c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253902 Reviewed-by: Harald Alvestrand Commit-Queue: Victor Boivie Cr-Commit-Position: refs/heads/main@{#36155} --- .../rx/traditional_reassembly_streams.cc | 11 +++--- .../rx/traditional_reassembly_streams_test.cc | 21 +++++++++++ net/dcsctp/socket/dcsctp_socket_test.cc | 35 +++++++++++++++++++ 3 files changed, 61 insertions(+), 6 deletions(-) diff --git a/net/dcsctp/rx/traditional_reassembly_streams.cc b/net/dcsctp/rx/traditional_reassembly_streams.cc index 4ccc2e5278..f5dc8cacc8 100644 --- a/net/dcsctp/rx/traditional_reassembly_streams.cc +++ b/net/dcsctp/rx/traditional_reassembly_streams.cc @@ -261,11 +261,11 @@ size_t TraditionalReassemblyStreams::OrderedStream::EraseTo(SSN ssn) { int TraditionalReassemblyStreams::Add(UnwrappedTSN tsn, Data data) { if (data.is_unordered) { - auto it = unordered_streams_.emplace(data.stream_id, this).first; + auto it = unordered_streams_.try_emplace(data.stream_id, this).first; return it->second.Add(tsn, std::move(data)); } - auto it = ordered_streams_.emplace(data.stream_id, this).first; + auto it = ordered_streams_.try_emplace(data.stream_id, this).first; return it->second.Add(tsn, std::move(data)); } @@ -280,10 +280,9 @@ size_t TraditionalReassemblyStreams::HandleForwardTsn( } for (const auto& skipped_stream : skipped_streams) { - auto it = ordered_streams_.find(skipped_stream.stream_id); - if (it != ordered_streams_.end()) { - bytes_removed += it->second.EraseTo(skipped_stream.ssn); - } + auto it = + ordered_streams_.try_emplace(skipped_stream.stream_id, this).first; + bytes_removed += it->second.EraseTo(skipped_stream.ssn); } return bytes_removed; diff --git a/net/dcsctp/rx/traditional_reassembly_streams_test.cc b/net/dcsctp/rx/traditional_reassembly_streams_test.cc index 3e6f560aba..759962473d 100644 --- a/net/dcsctp/rx/traditional_reassembly_streams_test.cc +++ b/net/dcsctp/rx/traditional_reassembly_streams_test.cc @@ -25,8 +25,10 @@ namespace dcsctp { namespace { +using ::testing::ElementsAre; using ::testing::MockFunction; using ::testing::NiceMock; +using ::testing::Property; class TraditionalReassemblyStreamsTest : public testing::Test { protected: @@ -232,5 +234,24 @@ TEST_F(TraditionalReassemblyStreamsTest, EXPECT_EQ(streams2.Add(tsn(4), gen_.Unordered({7})), 1); } +TEST_F(TraditionalReassemblyStreamsTest, CanDeleteFirstOrderedMessage) { + NiceMock> on_assembled; + EXPECT_CALL(on_assembled, + Call(ElementsAre(tsn(2)), + Property(&DcSctpMessage::payload, ElementsAre(2, 3, 4)))); + + TraditionalReassemblyStreams streams("", on_assembled.AsStdFunction()); + + // Not received, SID=1. TSN=1, SSN=0 + gen_.Ordered({1}, "BE"); + // And deleted (SID=1, TSN=1, SSN=0) + ForwardTsnChunk::SkippedStream skipped[] = { + ForwardTsnChunk::SkippedStream(StreamID(1), SSN(0))}; + EXPECT_EQ(streams.HandleForwardTsn(tsn(1), skipped), 0u); + + // Receive SID=1, TSN=2, SSN=1 + EXPECT_EQ(streams.Add(tsn(2), gen_.Ordered({2, 3, 4}, "BE")), 0); +} + } // namespace } // namespace dcsctp diff --git a/net/dcsctp/socket/dcsctp_socket_test.cc b/net/dcsctp/socket/dcsctp_socket_test.cc index f45773baba..d30043d332 100644 --- a/net/dcsctp/socket/dcsctp_socket_test.cc +++ b/net/dcsctp/socket/dcsctp_socket_test.cc @@ -2179,5 +2179,40 @@ TEST(DcSctpSocketTest, BothCanDetectDcsctpImplementation) { EXPECT_EQ(a.socket.peer_implementation(), SctpImplementation::kDcsctp); EXPECT_EQ(z.socket.peer_implementation(), SctpImplementation::kDcsctp); } + +TEST_P(DcSctpSocketParametrizedTest, CanLoseFirstOrderedMessage) { + SocketUnderTest a("A"); + auto z = std::make_unique("Z"); + + ConnectSockets(a, *z); + z = MaybeHandoverSocket(std::move(z)); + + SendOptions send_options; + send_options.unordered = IsUnordered(false); + send_options.max_retransmissions = 0; + std::vector payload(a.options.mtu - 100); + + // Send a first message (SID=1, SSN=0) + a.socket.Send(DcSctpMessage(StreamID(1), PPID(51), payload), send_options); + + // First DATA is lost, and retransmission timer will delete it. + a.cb.ConsumeSentPacket(); + AdvanceTime(a, *z, a.options.rto_initial); + ExchangeMessages(a, *z); + + // Send a second message (SID=0, SSN=1). + a.socket.Send(DcSctpMessage(StreamID(1), PPID(52), payload), send_options); + ExchangeMessages(a, *z); + + // The Z socket should receive the second message, but not the first. + absl::optional msg = z->cb.ConsumeReceivedMessage(); + ASSERT_TRUE(msg.has_value()); + EXPECT_EQ(msg->ppid(), PPID(52)); + + EXPECT_FALSE(z->cb.ConsumeReceivedMessage().has_value()); + + MaybeHandoverSocketAndSendMessage(a, std::move(z)); +} + } // namespace } // namespace dcsctp From d7031692e3ba9eed78ead07f8bf34a847ca1fce6 Mon Sep 17 00:00:00 2001 From: Shuhai Peng Date: Thu, 3 Mar 2022 02:03:09 +0000 Subject: [PATCH 130/847] Reland "remove NV12 to I420 conversion in webrtc AV1 Encoder." MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 66557e1af3f95a70753e782224d13a6186ed0d2e. Reason for revert: Some downstream projects seem to have an old libaom version with no NV12 support yet. It will be updated soon. Original change's description: > Revert "remove NV12 to I420 conversion in webrtc AV1 Encoder." > > This reverts commit 9558ab41eb4de39c62cda2dd1e559f5814a3a0c7. > > Reason for revert: speculative revert: breaks downstream project > > Original change's description: > > remove NV12 to I420 conversion in webrtc AV1 Encoder. > > > > libaom supports for NV12 inputs for encoding av1 stream. It will reduce > > unnecessary conversion from NV12 to I420 format. > > (https://bugs.chromium.org/p/aomedia/issues/detail?id=3232&q=3232&can=2) > > > > Bug: webrtc:13746 > > Change-Id: I1407227d1690b3f63cb6581eef5d587e5f418892 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251920 > > Reviewed-by: Erik Språng > > Reviewed-by: Ilya Nikolaevskiy > > Commit-Queue: Shuhai Peng > > Cr-Commit-Position: refs/heads/main@{#36111} > > Bug: webrtc:13746 > Change-Id: Ie928f7f5b5992337a9d186fa70b7fdec20a33f00 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253122 > Bot-Commit: rubber-stamper@appspot.gserviceaccount.com > Reviewed-by: Mirko Bonadei > Commit-Queue: Artem Titov > Owners-Override: Artem Titov > Owners-Override: Mirko Bonadei > Cr-Commit-Position: refs/heads/main@{#36114} Bug: webrtc:13746 Change-Id: Ib26ff6204abceb863b03d55e5953797c9ca27fc2 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253215 Bot-Commit: rubber-stamper@appspot.gserviceaccount.com Reviewed-by: Erik Språng Reviewed-by: Ilya Nikolaevskiy Commit-Queue: Ilya Nikolaevskiy Cr-Commit-Position: refs/heads/main@{#36156} --- .../codecs/av1/libaom_av1_encoder.cc | 109 +++++++++++++----- video/video_stream_encoder_unittest.cc | 2 +- 2 files changed, 82 insertions(+), 29 deletions(-) diff --git a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc index 0e427be915..9f33acf24e 100644 --- a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc +++ b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc @@ -93,6 +93,8 @@ class LibaomAv1Encoder final : public VideoEncoder { // Configures the encoder which buffers next frame updates and can reference. void SetSvcRefFrameConfig( const ScalableVideoController::LayerFrameConfig& layer_frame); + // If pixel format doesn't match, then reallocate. + void MaybeRewrapImgWithFormat(const aom_img_fmt_t fmt); std::unique_ptr svc_controller_; bool inited_; @@ -216,11 +218,10 @@ int LibaomAv1Encoder::InitEncode(const VideoCodec* codec_settings, cfg_.g_pass = AOM_RC_ONE_PASS; // One-pass rate control cfg_.g_lag_in_frames = kLagInFrames; // No look ahead when lag equals 0. - // Creating a wrapper to the image - setting image data to nullptr. Actual - // pointer will be set in encode. Setting align to 1, as it is meaningless - // (actual memory is not allocated). - frame_for_encode_ = - aom_img_alloc(nullptr, AOM_IMG_FMT_I420, cfg_.g_w, cfg_.g_h, 1); + if (frame_for_encode_ != nullptr) { + aom_img_free(frame_for_encode_); + frame_for_encode_ = nullptr; + } // Flag options: AOM_CODEC_USE_PSNR and AOM_CODEC_USE_HIGHBITDEPTH aom_codec_flags_t flags = 0; @@ -578,6 +579,21 @@ int32_t LibaomAv1Encoder::Release() { return WEBRTC_VIDEO_CODEC_OK; } +void LibaomAv1Encoder::MaybeRewrapImgWithFormat(const aom_img_fmt_t fmt) { + if (!frame_for_encode_) { + frame_for_encode_ = + aom_img_wrap(nullptr, fmt, cfg_.g_w, cfg_.g_h, 1, nullptr); + + } else if (frame_for_encode_->fmt != fmt) { + RTC_LOG(LS_INFO) << "Switching AV1 encoder pixel format to " + << (fmt == AOM_IMG_FMT_NV12 ? "NV12" : "I420"); + aom_img_free(frame_for_encode_); + frame_for_encode_ = + aom_img_wrap(nullptr, fmt, cfg_.g_w, cfg_.g_h, 1, nullptr); + } + // else no-op since the image is already in the right format. +} + int32_t LibaomAv1Encoder::Encode( const VideoFrame& frame, const std::vector* frame_types) { @@ -597,38 +613,74 @@ int32_t LibaomAv1Encoder::Encode( return WEBRTC_VIDEO_CODEC_ERROR; } + rtc::scoped_refptr buffer = frame.video_frame_buffer(); + absl::InlinedVector + supported_formats = {VideoFrameBuffer::Type::kI420, + VideoFrameBuffer::Type::kNV12}; + rtc::scoped_refptr mapped_buffer; + if (buffer->type() != VideoFrameBuffer::Type::kNative) { + // `buffer` is already mapped. + mapped_buffer = buffer; + } else { + // Attempt to map to one of the supported formats. + mapped_buffer = buffer->GetMappedFrameBuffer(supported_formats); + } + // Convert input frame to I420, if needed. - VideoFrame prepped_input_frame = frame; - if (prepped_input_frame.video_frame_buffer()->type() != - VideoFrameBuffer::Type::kI420 && - prepped_input_frame.video_frame_buffer()->type() != - VideoFrameBuffer::Type::kI420A) { + if (!mapped_buffer || + (absl::c_find(supported_formats, mapped_buffer->type()) == + supported_formats.end() && + mapped_buffer->type() != VideoFrameBuffer::Type::kI420A)) { rtc::scoped_refptr converted_buffer( - prepped_input_frame.video_frame_buffer()->ToI420()); + mapped_buffer->ToI420()); if (!converted_buffer) { RTC_LOG(LS_ERROR) << "Failed to convert " << VideoFrameBufferTypeToString( - prepped_input_frame.video_frame_buffer()->type()) + frame.video_frame_buffer()->type()) << " image to I420. Can't encode frame."; return WEBRTC_VIDEO_CODEC_ENCODER_FAILURE; } RTC_CHECK(converted_buffer->type() == VideoFrameBuffer::Type::kI420 || converted_buffer->type() == VideoFrameBuffer::Type::kI420A); - prepped_input_frame = VideoFrame(converted_buffer, frame.timestamp(), - frame.render_time_ms(), frame.rotation()); - } - - // Set frame_for_encode_ data pointers and strides. - auto i420_buffer = prepped_input_frame.video_frame_buffer()->GetI420(); - frame_for_encode_->planes[AOM_PLANE_Y] = - const_cast(i420_buffer->DataY()); - frame_for_encode_->planes[AOM_PLANE_U] = - const_cast(i420_buffer->DataU()); - frame_for_encode_->planes[AOM_PLANE_V] = - const_cast(i420_buffer->DataV()); - frame_for_encode_->stride[AOM_PLANE_Y] = i420_buffer->StrideY(); - frame_for_encode_->stride[AOM_PLANE_U] = i420_buffer->StrideU(); - frame_for_encode_->stride[AOM_PLANE_V] = i420_buffer->StrideV(); + + mapped_buffer = converted_buffer; + } + + switch (mapped_buffer->type()) { + case VideoFrameBuffer::Type::kI420: + case VideoFrameBuffer::Type::kI420A: { + // Set frame_for_encode_ data pointers and strides. + MaybeRewrapImgWithFormat(AOM_IMG_FMT_I420); + auto i420_buffer = mapped_buffer->GetI420(); + RTC_DCHECK(i420_buffer); + frame_for_encode_->planes[AOM_PLANE_Y] = + const_cast(i420_buffer->DataY()); + frame_for_encode_->planes[AOM_PLANE_U] = + const_cast(i420_buffer->DataU()); + frame_for_encode_->planes[AOM_PLANE_V] = + const_cast(i420_buffer->DataV()); + frame_for_encode_->stride[AOM_PLANE_Y] = i420_buffer->StrideY(); + frame_for_encode_->stride[AOM_PLANE_U] = i420_buffer->StrideU(); + frame_for_encode_->stride[AOM_PLANE_V] = i420_buffer->StrideV(); + break; + } + case VideoFrameBuffer::Type::kNV12: { + MaybeRewrapImgWithFormat(AOM_IMG_FMT_NV12); + const NV12BufferInterface* nv12_buffer = mapped_buffer->GetNV12(); + RTC_DCHECK(nv12_buffer); + frame_for_encode_->planes[AOM_PLANE_Y] = + const_cast(nv12_buffer->DataY()); + frame_for_encode_->planes[AOM_PLANE_U] = + const_cast(nv12_buffer->DataUV()); + frame_for_encode_->planes[AOM_PLANE_V] = nullptr; + frame_for_encode_->stride[AOM_PLANE_Y] = nv12_buffer->StrideY(); + frame_for_encode_->stride[AOM_PLANE_U] = nv12_buffer->StrideUV(); + frame_for_encode_->stride[AOM_PLANE_V] = 0; + break; + } + default: + return WEBRTC_VIDEO_CODEC_ENCODER_FAILURE; + } const uint32_t duration = kRtpTicksPerSecond / static_cast(encoder_settings_.maxFramerate); @@ -828,7 +880,8 @@ VideoEncoder::EncoderInfo LibaomAv1Encoder::GetEncoderInfo() const { info.has_trusted_rate_controller = true; info.is_hardware_accelerated = false; info.scaling_settings = VideoEncoder::ScalingSettings(kMinQindex, kMaxQindex); - info.preferred_pixel_formats = {VideoFrameBuffer::Type::kI420}; + info.preferred_pixel_formats = {VideoFrameBuffer::Type::kI420, + VideoFrameBuffer::Type::kNV12}; if (SvcEnabled()) { for (int sid = 0; sid < svc_params_->number_spatial_layers; ++sid) { info.fps_allocation[sid].resize(svc_params_->number_temporal_layers); diff --git a/video/video_stream_encoder_unittest.cc b/video/video_stream_encoder_unittest.cc index aea1988df9..b1ff12ed11 100644 --- a/video/video_stream_encoder_unittest.cc +++ b/video/video_stream_encoder_unittest.cc @@ -8694,7 +8694,7 @@ constexpr std::pair kVP8DisallowConversion = constexpr std::pair kVP9DisallowConversion = std::make_pair(kVideoCodecVP9, /*allow_i420_conversion=*/false); constexpr std::pair kAV1AllowConversion = - std::make_pair(kVideoCodecAV1, /*allow_i420_conversion=*/true); + std::make_pair(kVideoCodecAV1, /*allow_i420_conversion=*/false); constexpr std::pair kMultiplexDisallowConversion = std::make_pair(kVideoCodecMultiplex, /*allow_i420_conversion=*/false); #if defined(WEBRTC_USE_H264) From 584b4df92d3332eb97fb5142e9a48c77cdb7a3b5 Mon Sep 17 00:00:00 2001 From: Victor Boivie Date: Tue, 8 Mar 2022 23:05:10 +0100 Subject: [PATCH 131/847] dcsctp: Don't deliver skipped messages If a FORWARD-TSN contains an ordered skipped stream with a large TSN but with a too small SSN, it can result in messages being assembled that should've been skipped. Typically: Receive DATA, ordered, complete, TSN=10, SID=1, SSN=0 - will be delivered. Receive DATA, ordered, complete, TSN=43, SID=1, SSN=7 - will stay in queue, due to missing SSN=1,2,3,4,5,6. Receive FORWARD-TSN, TSN=44, SSN=6 - is invalid, as the SSN should've been 7 or higher. However, as the TSN isn't used for removing messages in ordered streams, but just the SSN, the SSN=7 isn't removed but instead will be delivered as it's the next following SSN after 6. This will trigger internal consistency checks as a chunk with TSN=43 will be delivered when the current cumulative TSN is set to 44, which is greater. This was found when fuzzing, and can only be provoked by a client that is intentionally misbehaving. Before this fix, there was no harm done, but it failed consistency checks which fuzzers have enabled. When bug 13799 was fixed (in a previous commit), this allowed the fuzzers to find it faster. Bug: webrtc:13799 Change-Id: I830ef189476e227e1dbe08157d34f96ad6453e30 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254240 Reviewed-by: Harald Alvestrand Commit-Queue: Victor Boivie Cr-Commit-Position: refs/heads/main@{#36157} --- net/dcsctp/packet/chunk/forward_tsn_chunk.cc | 3 +++ .../packet/chunk/forward_tsn_chunk_test.cc | 3 ++- net/dcsctp/rx/reassembly_queue.cc | 12 ++++++++++-- net/dcsctp/rx/reassembly_queue_test.cc | 16 ++++++++++++++++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/net/dcsctp/packet/chunk/forward_tsn_chunk.cc b/net/dcsctp/packet/chunk/forward_tsn_chunk.cc index f01505094d..e432114c50 100644 --- a/net/dcsctp/packet/chunk/forward_tsn_chunk.cc +++ b/net/dcsctp/packet/chunk/forward_tsn_chunk.cc @@ -87,6 +87,9 @@ void ForwardTsnChunk::SerializeTo(std::vector& out) const { std::string ForwardTsnChunk::ToString() const { rtc::StringBuilder sb; sb << "FORWARD-TSN, new_cumulative_tsn=" << *new_cumulative_tsn(); + for (const auto& skipped : skipped_streams()) { + sb << ", skip " << skipped.stream_id.value() << ":" << *skipped.ssn; + } return sb.str(); } } // namespace dcsctp diff --git a/net/dcsctp/packet/chunk/forward_tsn_chunk_test.cc b/net/dcsctp/packet/chunk/forward_tsn_chunk_test.cc index 9420c1f2ef..51f97f2396 100644 --- a/net/dcsctp/packet/chunk/forward_tsn_chunk_test.cc +++ b/net/dcsctp/packet/chunk/forward_tsn_chunk_test.cc @@ -56,7 +56,8 @@ TEST(ForwardTsnChunkTest, SerializeAndDeserialize) { ElementsAre(ForwardTsnChunk::SkippedStream(StreamID(1), SSN(23)), ForwardTsnChunk::SkippedStream(StreamID(42), SSN(99)))); - EXPECT_EQ(deserialized.ToString(), "FORWARD-TSN, new_cumulative_tsn=123"); + EXPECT_EQ(deserialized.ToString(), + "FORWARD-TSN, new_cumulative_tsn=123, skip 1:23, skip 42:99"); } } // namespace diff --git a/net/dcsctp/rx/reassembly_queue.cc b/net/dcsctp/rx/reassembly_queue.cc index 5791d6805c..cbf198b136 100644 --- a/net/dcsctp/rx/reassembly_queue.cc +++ b/net/dcsctp/rx/reassembly_queue.cc @@ -210,8 +210,16 @@ void ReassemblyQueue::AddReassembledMessage( << ", payload=" << message.payload().size() << " bytes"; for (const UnwrappedTSN tsn : tsns) { - // Update watermark, or insert into delivered_tsns_ - if (tsn == last_assembled_tsn_watermark_.next_value()) { + if (tsn <= last_assembled_tsn_watermark_) { + // This can be provoked by a misbehaving peer by sending FORWARD-TSN with + // invalid SSNs, allowing ordered messages to stay in the queue that + // should've been discarded. + RTC_DLOG(LS_VERBOSE) + << log_prefix_ + << "Message is built from fragments already seen - skipping"; + return; + } else if (tsn == last_assembled_tsn_watermark_.next_value()) { + // Update watermark, or insert into delivered_tsns_ last_assembled_tsn_watermark_.Increment(); } else { delivered_tsns_.insert(tsn); diff --git a/net/dcsctp/rx/reassembly_queue_test.cc b/net/dcsctp/rx/reassembly_queue_test.cc index d1e3bf6413..bc1b776837 100644 --- a/net/dcsctp/rx/reassembly_queue_test.cc +++ b/net/dcsctp/rx/reassembly_queue_test.cc @@ -389,5 +389,21 @@ TEST_F(ReassemblyQueueTest, HandoverAfterHavingAssembedOneMessage) { reasm2.Add(TSN(11), gen_.Ordered({1, 2, 3, 4}, "BE")); EXPECT_THAT(reasm2.FlushMessages(), SizeIs(1)); } + +TEST_F(ReassemblyQueueTest, HandleInconsistentForwardTSN) { + // Found when fuzzing. + ReassemblyQueue reasm("log: ", TSN(10), kBufferSize); + // Add TSN=43, SSN=7. Can't be reassembled as previous SSNs aren't known. + reasm.Add(TSN(43), Data(kStreamID, SSN(7), MID(0), FSN(0), kPPID, + std::vector(10), Data::IsBeginning(true), + Data::IsEnd(true), IsUnordered(false))); + + // Invalid, as TSN=44 have to have SSN>=7, but peer says 6. + reasm.Handle(ForwardTsnChunk( + TSN(44), {ForwardTsnChunk::SkippedStream(kStreamID, SSN(6))})); + + // Don't assemble SSN=7, as that TSN is skipped. + EXPECT_FALSE(reasm.HasMessages()); +} } // namespace } // namespace dcsctp From 57869dae117d164f66c0c3cb75cb9c078e07c922 Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Wed, 9 Mar 2022 10:52:14 +0000 Subject: [PATCH 132/847] Remove obsolete comment about loglevels The nonstandard loglevel equivalents have been removed, but I forgot to update this comment. Bug: webrtc:13362 Change-Id: Ifd604cfe53b9ee312d80179cc5e1bc6734ee6c29 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254261 Reviewed-by: Mirko Bonadei Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#36158} --- rtc_base/logging.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rtc_base/logging.h b/rtc_base/logging.h index eaa84e893a..8991f6f2b4 100644 --- a/rtc_base/logging.h +++ b/rtc_base/logging.h @@ -72,9 +72,7 @@ namespace rtc { ////////////////////////////////////////////////////////////////////// - -// Note that the non-standard LoggingSeverity aliases exist because they are -// still in broad use. The meanings of the levels are: +// The meanings of the levels are: // LS_VERBOSE: This level is for data which we do not want to appear in the // normal debug log, but should appear in diagnostic logs. // LS_INFO: Chatty level used in debugging for all sorts of things, the default From fef0026f2f64a7aff21a70a30e5bb9e5a3fc2065 Mon Sep 17 00:00:00 2001 From: Andrey Logvin Date: Wed, 9 Mar 2022 11:37:17 +0000 Subject: [PATCH 133/847] Revert "Reland "remove NV12 to I420 conversion in webrtc AV1 Encoder."" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit d7031692e3ba9eed78ead07f8bf34a847ca1fce6. Reason for revert: Breaks downstream project Original change's description: > Reland "remove NV12 to I420 conversion in webrtc AV1 Encoder." > > This reverts commit 66557e1af3f95a70753e782224d13a6186ed0d2e. > > Reason for revert: Some downstream projects seem to have an old libaom version with no NV12 support yet. It will be updated soon. > > Original change's description: > > Revert "remove NV12 to I420 conversion in webrtc AV1 Encoder." > > > > This reverts commit 9558ab41eb4de39c62cda2dd1e559f5814a3a0c7. > > > > Reason for revert: speculative revert: breaks downstream project > > > > Original change's description: > > > remove NV12 to I420 conversion in webrtc AV1 Encoder. > > > > > > libaom supports for NV12 inputs for encoding av1 stream. It will reduce > > > unnecessary conversion from NV12 to I420 format. > > > (https://bugs.chromium.org/p/aomedia/issues/detail?id=3232&q=3232&can=2) > > > > > > Bug: webrtc:13746 > > > Change-Id: I1407227d1690b3f63cb6581eef5d587e5f418892 > > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251920 > > > Reviewed-by: Erik Språng > > > Reviewed-by: Ilya Nikolaevskiy > > > Commit-Queue: Shuhai Peng > > > Cr-Commit-Position: refs/heads/main@{#36111} > > > > Bug: webrtc:13746 > > Change-Id: Ie928f7f5b5992337a9d186fa70b7fdec20a33f00 > > No-Presubmit: true > > No-Tree-Checks: true > > No-Try: true > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253122 > > Bot-Commit: rubber-stamper@appspot.gserviceaccount.com > > Reviewed-by: Mirko Bonadei > > Commit-Queue: Artem Titov > > Owners-Override: Artem Titov > > Owners-Override: Mirko Bonadei > > Cr-Commit-Position: refs/heads/main@{#36114} > > Bug: webrtc:13746 > Change-Id: Ib26ff6204abceb863b03d55e5953797c9ca27fc2 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253215 > Bot-Commit: rubber-stamper@appspot.gserviceaccount.com > Reviewed-by: Erik Språng > Reviewed-by: Ilya Nikolaevskiy > Commit-Queue: Ilya Nikolaevskiy > Cr-Commit-Position: refs/heads/main@{#36156} Bug: webrtc:13746 Change-Id: Ia9f8024bf70a82f8e26cd7a80d3020ed796c1b40 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254262 Bot-Commit: rubber-stamper@appspot.gserviceaccount.com Reviewed-by: Andrey Logvin Commit-Queue: Andrey Logvin Reviewed-by: Ilya Nikolaevskiy Commit-Queue: Ilya Nikolaevskiy Cr-Commit-Position: refs/heads/main@{#36159} --- .../codecs/av1/libaom_av1_encoder.cc | 109 +++++------------- video/video_stream_encoder_unittest.cc | 2 +- 2 files changed, 29 insertions(+), 82 deletions(-) diff --git a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc index 9f33acf24e..0e427be915 100644 --- a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc +++ b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc @@ -93,8 +93,6 @@ class LibaomAv1Encoder final : public VideoEncoder { // Configures the encoder which buffers next frame updates and can reference. void SetSvcRefFrameConfig( const ScalableVideoController::LayerFrameConfig& layer_frame); - // If pixel format doesn't match, then reallocate. - void MaybeRewrapImgWithFormat(const aom_img_fmt_t fmt); std::unique_ptr svc_controller_; bool inited_; @@ -218,10 +216,11 @@ int LibaomAv1Encoder::InitEncode(const VideoCodec* codec_settings, cfg_.g_pass = AOM_RC_ONE_PASS; // One-pass rate control cfg_.g_lag_in_frames = kLagInFrames; // No look ahead when lag equals 0. - if (frame_for_encode_ != nullptr) { - aom_img_free(frame_for_encode_); - frame_for_encode_ = nullptr; - } + // Creating a wrapper to the image - setting image data to nullptr. Actual + // pointer will be set in encode. Setting align to 1, as it is meaningless + // (actual memory is not allocated). + frame_for_encode_ = + aom_img_alloc(nullptr, AOM_IMG_FMT_I420, cfg_.g_w, cfg_.g_h, 1); // Flag options: AOM_CODEC_USE_PSNR and AOM_CODEC_USE_HIGHBITDEPTH aom_codec_flags_t flags = 0; @@ -579,21 +578,6 @@ int32_t LibaomAv1Encoder::Release() { return WEBRTC_VIDEO_CODEC_OK; } -void LibaomAv1Encoder::MaybeRewrapImgWithFormat(const aom_img_fmt_t fmt) { - if (!frame_for_encode_) { - frame_for_encode_ = - aom_img_wrap(nullptr, fmt, cfg_.g_w, cfg_.g_h, 1, nullptr); - - } else if (frame_for_encode_->fmt != fmt) { - RTC_LOG(LS_INFO) << "Switching AV1 encoder pixel format to " - << (fmt == AOM_IMG_FMT_NV12 ? "NV12" : "I420"); - aom_img_free(frame_for_encode_); - frame_for_encode_ = - aom_img_wrap(nullptr, fmt, cfg_.g_w, cfg_.g_h, 1, nullptr); - } - // else no-op since the image is already in the right format. -} - int32_t LibaomAv1Encoder::Encode( const VideoFrame& frame, const std::vector* frame_types) { @@ -613,74 +597,38 @@ int32_t LibaomAv1Encoder::Encode( return WEBRTC_VIDEO_CODEC_ERROR; } - rtc::scoped_refptr buffer = frame.video_frame_buffer(); - absl::InlinedVector - supported_formats = {VideoFrameBuffer::Type::kI420, - VideoFrameBuffer::Type::kNV12}; - rtc::scoped_refptr mapped_buffer; - if (buffer->type() != VideoFrameBuffer::Type::kNative) { - // `buffer` is already mapped. - mapped_buffer = buffer; - } else { - // Attempt to map to one of the supported formats. - mapped_buffer = buffer->GetMappedFrameBuffer(supported_formats); - } - // Convert input frame to I420, if needed. - if (!mapped_buffer || - (absl::c_find(supported_formats, mapped_buffer->type()) == - supported_formats.end() && - mapped_buffer->type() != VideoFrameBuffer::Type::kI420A)) { + VideoFrame prepped_input_frame = frame; + if (prepped_input_frame.video_frame_buffer()->type() != + VideoFrameBuffer::Type::kI420 && + prepped_input_frame.video_frame_buffer()->type() != + VideoFrameBuffer::Type::kI420A) { rtc::scoped_refptr converted_buffer( - mapped_buffer->ToI420()); + prepped_input_frame.video_frame_buffer()->ToI420()); if (!converted_buffer) { RTC_LOG(LS_ERROR) << "Failed to convert " << VideoFrameBufferTypeToString( - frame.video_frame_buffer()->type()) + prepped_input_frame.video_frame_buffer()->type()) << " image to I420. Can't encode frame."; return WEBRTC_VIDEO_CODEC_ENCODER_FAILURE; } RTC_CHECK(converted_buffer->type() == VideoFrameBuffer::Type::kI420 || converted_buffer->type() == VideoFrameBuffer::Type::kI420A); - - mapped_buffer = converted_buffer; - } - - switch (mapped_buffer->type()) { - case VideoFrameBuffer::Type::kI420: - case VideoFrameBuffer::Type::kI420A: { - // Set frame_for_encode_ data pointers and strides. - MaybeRewrapImgWithFormat(AOM_IMG_FMT_I420); - auto i420_buffer = mapped_buffer->GetI420(); - RTC_DCHECK(i420_buffer); - frame_for_encode_->planes[AOM_PLANE_Y] = - const_cast(i420_buffer->DataY()); - frame_for_encode_->planes[AOM_PLANE_U] = - const_cast(i420_buffer->DataU()); - frame_for_encode_->planes[AOM_PLANE_V] = - const_cast(i420_buffer->DataV()); - frame_for_encode_->stride[AOM_PLANE_Y] = i420_buffer->StrideY(); - frame_for_encode_->stride[AOM_PLANE_U] = i420_buffer->StrideU(); - frame_for_encode_->stride[AOM_PLANE_V] = i420_buffer->StrideV(); - break; - } - case VideoFrameBuffer::Type::kNV12: { - MaybeRewrapImgWithFormat(AOM_IMG_FMT_NV12); - const NV12BufferInterface* nv12_buffer = mapped_buffer->GetNV12(); - RTC_DCHECK(nv12_buffer); - frame_for_encode_->planes[AOM_PLANE_Y] = - const_cast(nv12_buffer->DataY()); - frame_for_encode_->planes[AOM_PLANE_U] = - const_cast(nv12_buffer->DataUV()); - frame_for_encode_->planes[AOM_PLANE_V] = nullptr; - frame_for_encode_->stride[AOM_PLANE_Y] = nv12_buffer->StrideY(); - frame_for_encode_->stride[AOM_PLANE_U] = nv12_buffer->StrideUV(); - frame_for_encode_->stride[AOM_PLANE_V] = 0; - break; - } - default: - return WEBRTC_VIDEO_CODEC_ENCODER_FAILURE; - } + prepped_input_frame = VideoFrame(converted_buffer, frame.timestamp(), + frame.render_time_ms(), frame.rotation()); + } + + // Set frame_for_encode_ data pointers and strides. + auto i420_buffer = prepped_input_frame.video_frame_buffer()->GetI420(); + frame_for_encode_->planes[AOM_PLANE_Y] = + const_cast(i420_buffer->DataY()); + frame_for_encode_->planes[AOM_PLANE_U] = + const_cast(i420_buffer->DataU()); + frame_for_encode_->planes[AOM_PLANE_V] = + const_cast(i420_buffer->DataV()); + frame_for_encode_->stride[AOM_PLANE_Y] = i420_buffer->StrideY(); + frame_for_encode_->stride[AOM_PLANE_U] = i420_buffer->StrideU(); + frame_for_encode_->stride[AOM_PLANE_V] = i420_buffer->StrideV(); const uint32_t duration = kRtpTicksPerSecond / static_cast(encoder_settings_.maxFramerate); @@ -880,8 +828,7 @@ VideoEncoder::EncoderInfo LibaomAv1Encoder::GetEncoderInfo() const { info.has_trusted_rate_controller = true; info.is_hardware_accelerated = false; info.scaling_settings = VideoEncoder::ScalingSettings(kMinQindex, kMaxQindex); - info.preferred_pixel_formats = {VideoFrameBuffer::Type::kI420, - VideoFrameBuffer::Type::kNV12}; + info.preferred_pixel_formats = {VideoFrameBuffer::Type::kI420}; if (SvcEnabled()) { for (int sid = 0; sid < svc_params_->number_spatial_layers; ++sid) { info.fps_allocation[sid].resize(svc_params_->number_temporal_layers); diff --git a/video/video_stream_encoder_unittest.cc b/video/video_stream_encoder_unittest.cc index b1ff12ed11..aea1988df9 100644 --- a/video/video_stream_encoder_unittest.cc +++ b/video/video_stream_encoder_unittest.cc @@ -8694,7 +8694,7 @@ constexpr std::pair kVP8DisallowConversion = constexpr std::pair kVP9DisallowConversion = std::make_pair(kVideoCodecVP9, /*allow_i420_conversion=*/false); constexpr std::pair kAV1AllowConversion = - std::make_pair(kVideoCodecAV1, /*allow_i420_conversion=*/false); + std::make_pair(kVideoCodecAV1, /*allow_i420_conversion=*/true); constexpr std::pair kMultiplexDisallowConversion = std::make_pair(kVideoCodecMultiplex, /*allow_i420_conversion=*/false); #if defined(WEBRTC_USE_H264) From ed99dae4229e20df137a444f77bb5bdb31ac7889 Mon Sep 17 00:00:00 2001 From: Jonas Oreland Date: Wed, 9 Mar 2022 09:28:10 +0100 Subject: [PATCH 134/847] WebRTC-DeprecateGlobalFieldTrialString/Enabled/ - part 1 This cl/ 1) move WebRtcKeyValueConfig from api/transport to api/ directory. 2) add a test/ScopedKeyValueConfig (compare ScopedFieldTrials). 3) removes usage of webrtc::field_trial:: from the pc/ directory. 4) removes a few unused includes of system_wrappers/field_trial.h. Bug: webrtc:10335 Change-Id: If29c07900dbe791050b0a5ad05332bedfad035f2 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253903 Reviewed-by: Harald Alvestrand Reviewed-by: Mirko Bonadei Commit-Queue: Jonas Oreland Cr-Commit-Position: refs/heads/main@{#36160} --- api/BUILD.gn | 7 ++ api/transport/BUILD.gn | 5 +- api/transport/webrtc_key_value_config.h | 22 +--- api/webrtc_key_value_config.h | 41 +++++++ call/bitrate_allocator.cc | 1 - call/call.cc | 1 - .../rtp/transport_feedback_adapter.cc | 1 - modules/pacing/paced_sender_unittest.cc | 1 - .../remote_bitrate_estimator/bwe_defines.cc | 2 - p2p/BUILD.gn | 3 + p2p/base/port.cc | 1 - p2p/base/stun_request.cc | 1 - p2p/base/transport_description_factory.cc | 5 +- p2p/base/transport_description_factory.h | 7 +- .../transport_description_factory_unittest.cc | 4 + pc/BUILD.gn | 17 ++- pc/channel_manager_unittest.cc | 5 +- pc/channel_unittest.cc | 4 +- pc/connection_context.cc | 11 +- pc/connection_context.h | 6 +- pc/data_channel_integrationtest.cc | 3 +- pc/dtls_srtp_transport.cc | 5 +- pc/dtls_srtp_transport.h | 3 +- pc/dtls_srtp_transport_unittest.cc | 4 +- pc/jsep_transport_controller.cc | 7 +- pc/jsep_transport_controller.h | 3 + pc/jsep_transport_controller_unittest.cc | 3 + pc/jsep_transport_unittest.cc | 7 +- pc/media_session.cc | 59 ++++----- pc/media_session.h | 8 ++ pc/media_session_unittest.cc | 42 ++++--- pc/peer_connection.cc | 2 + pc/peer_connection.h | 2 + pc/peer_connection_internal.h | 2 + pc/rtp_sender_receiver_unittest.cc | 4 +- pc/sdp_offer_answer.cc | 11 +- pc/sdp_offer_answer.h | 3 +- pc/srtp_session.cc | 8 +- pc/srtp_session.h | 2 + pc/srtp_session_unittest.cc | 6 +- pc/srtp_transport.cc | 13 +- pc/srtp_transport.h | 6 +- pc/srtp_transport_unittest.cc | 8 +- pc/stats_collector.cc | 4 +- pc/stats_collector.h | 1 + pc/test/fake_peer_connection_base.h | 5 + pc/test/integration_test_helpers.h | 12 +- pc/webrtc_session_description_factory.cc | 10 +- pc/webrtc_session_description_factory.h | 3 +- test/BUILD.gn | 19 ++- test/explicit_key_value_config.cc | 3 +- test/explicit_key_value_config.h | 2 +- test/peer_scenario/BUILD.gn | 2 + test/peer_scenario/scenario_connection.cc | 1 + test/peer_scenario/scenario_connection.h | 3 + test/scoped_key_value_config.cc | 116 ++++++++++++++++++ test/scoped_key_value_config.h | 52 ++++++++ video/encoder_bitrate_adjuster.cc | 1 - 58 files changed, 450 insertions(+), 140 deletions(-) create mode 100644 api/webrtc_key_value_config.h create mode 100644 test/scoped_key_value_config.cc create mode 100644 test/scoped_key_value_config.h diff --git a/api/BUILD.gn b/api/BUILD.gn index f8a6532866..b736f93885 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn @@ -1223,3 +1223,10 @@ if (rtc_include_tests) { ] } } + +rtc_source_set("webrtc_key_value_config") { + visibility = [ "*" ] + sources = [ "webrtc_key_value_config.h" ] + deps = [ "../rtc_base/system:rtc_export" ] + absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] +} diff --git a/api/transport/BUILD.gn b/api/transport/BUILD.gn index 30955273b0..fb0fcf7a64 100644 --- a/api/transport/BUILD.gn +++ b/api/transport/BUILD.gn @@ -48,7 +48,10 @@ rtc_library("network_control") { rtc_source_set("webrtc_key_value_config") { visibility = [ "*" ] sources = [ "webrtc_key_value_config.h" ] - deps = [ "../../rtc_base/system:rtc_export" ] + deps = [ + "../../api:webrtc_key_value_config", + "../../rtc_base/system:rtc_export", + ] absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } diff --git a/api/transport/webrtc_key_value_config.h b/api/transport/webrtc_key_value_config.h index 5666a82783..f666873cfe 100644 --- a/api/transport/webrtc_key_value_config.h +++ b/api/transport/webrtc_key_value_config.h @@ -10,24 +10,8 @@ #ifndef API_TRANSPORT_WEBRTC_KEY_VALUE_CONFIG_H_ #define API_TRANSPORT_WEBRTC_KEY_VALUE_CONFIG_H_ -#include - -#include "absl/strings/string_view.h" -#include "rtc_base/system/rtc_export.h" - -namespace webrtc { - -// An interface that provides a key-value mapping for configuring internal -// details of WebRTC. Note that there's no guarantess that the meaning of a -// particular key value mapping will be preserved over time and no announcements -// will be made if they are changed. It's up to the library user to ensure that -// the behavior does not break. -class RTC_EXPORT WebRtcKeyValueConfig { - public: - virtual ~WebRtcKeyValueConfig() = default; - // The configured value for the given key. Defaults to an empty string. - virtual std::string Lookup(absl::string_view key) const = 0; -}; -} // namespace webrtc +// TODO(bugs.webrtc.org/10335): Remove once all migrated to +// "api/webrtc_key_value_config.h". +#include "api/webrtc_key_value_config.h" #endif // API_TRANSPORT_WEBRTC_KEY_VALUE_CONFIG_H_ diff --git a/api/webrtc_key_value_config.h b/api/webrtc_key_value_config.h new file mode 100644 index 0000000000..32a2e47eed --- /dev/null +++ b/api/webrtc_key_value_config.h @@ -0,0 +1,41 @@ +/* + * Copyright 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_WEBRTC_KEY_VALUE_CONFIG_H_ +#define API_WEBRTC_KEY_VALUE_CONFIG_H_ + +#include + +#include "absl/strings/string_view.h" +#include "rtc_base/system/rtc_export.h" + +namespace webrtc { + +// An interface that provides a key-value mapping for configuring internal +// details of WebRTC. Note that there's no guarantess that the meaning of a +// particular key value mapping will be preserved over time and no announcements +// will be made if they are changed. It's up to the library user to ensure that +// the behavior does not break. +class RTC_EXPORT WebRtcKeyValueConfig { + public: + virtual ~WebRtcKeyValueConfig() = default; + // The configured value for the given key. Defaults to an empty string. + virtual std::string Lookup(absl::string_view key) const = 0; + + bool IsEnabled(absl::string_view key) const { + return Lookup(key).find("Enabled") == 0; + } + + bool IsDisabled(absl::string_view key) const { + return Lookup(key).find("Disabled") == 0; + } +}; +} // namespace webrtc + +#endif // API_WEBRTC_KEY_VALUE_CONFIG_H_ diff --git a/call/bitrate_allocator.cc b/call/bitrate_allocator.cc index 1693661ef5..2684a1650e 100644 --- a/call/bitrate_allocator.cc +++ b/call/bitrate_allocator.cc @@ -23,7 +23,6 @@ #include "rtc_base/logging.h" #include "rtc_base/numerics/safe_minmax.h" #include "system_wrappers/include/clock.h" -#include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/metrics.h" namespace webrtc { diff --git a/call/call.cc b/call/call.cc index bb62365cd4..2638b22b31 100644 --- a/call/call.cc +++ b/call/call.cc @@ -61,7 +61,6 @@ #include "rtc_base/trace_event.h" #include "system_wrappers/include/clock.h" #include "system_wrappers/include/cpu_info.h" -#include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/metrics.h" #include "video/call_stats2.h" #include "video/send_delay_stats.h" diff --git a/modules/congestion_controller/rtp/transport_feedback_adapter.cc b/modules/congestion_controller/rtp/transport_feedback_adapter.cc index 87691bf263..87e917e978 100644 --- a/modules/congestion_controller/rtp/transport_feedback_adapter.cc +++ b/modules/congestion_controller/rtp/transport_feedback_adapter.cc @@ -22,7 +22,6 @@ #include "modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" -#include "system_wrappers/include/field_trial.h" namespace webrtc { diff --git a/modules/pacing/paced_sender_unittest.cc b/modules/pacing/paced_sender_unittest.cc index 53cc1c42ed..7abd532417 100644 --- a/modules/pacing/paced_sender_unittest.cc +++ b/modules/pacing/paced_sender_unittest.cc @@ -19,7 +19,6 @@ #include "modules/pacing/packet_router.h" #include "modules/utility/include/mock/mock_process_thread.h" #include "system_wrappers/include/clock.h" -#include "system_wrappers/include/field_trial.h" #include "test/field_trial.h" #include "test/gmock.h" #include "test/gtest.h" diff --git a/modules/remote_bitrate_estimator/bwe_defines.cc b/modules/remote_bitrate_estimator/bwe_defines.cc index 6afbe133e2..22c605e82d 100644 --- a/modules/remote_bitrate_estimator/bwe_defines.cc +++ b/modules/remote_bitrate_estimator/bwe_defines.cc @@ -10,8 +10,6 @@ #include "modules/remote_bitrate_estimator/include/bwe_defines.h" -#include "system_wrappers/include/field_trial.h" - namespace webrtc { const char kBweTypeHistogram[] = "WebRTC.BWE.Types"; diff --git a/p2p/BUILD.gn b/p2p/BUILD.gn index a9c059bed3..66da247ade 100644 --- a/p2p/BUILD.gn +++ b/p2p/BUILD.gn @@ -91,6 +91,7 @@ rtc_library("rtc_p2p") { "../api:rtc_error", "../api:scoped_refptr", "../api:sequence_checker", + "../api:webrtc_key_value_config", "../api:wrapping_async_dns_resolver", "../api/crypto:options", "../api/rtc_event_log", @@ -240,6 +241,7 @@ if (rtc_include_tests) { "../api:mock_async_dns_resolver", "../api:packet_socket_factory", "../api:scoped_refptr", + "../api:webrtc_key_value_config", "../api/transport:stun_types", "../api/units:time_delta", "../rtc_base", @@ -259,6 +261,7 @@ if (rtc_include_tests) { "../system_wrappers:metrics", "../test:field_trial", "../test:rtc_expect_death", + "../test:scoped_key_value_config", "../test:test_support", "//testing/gtest", ] diff --git a/p2p/base/port.cc b/p2p/base/port.cc index 5d3552b7f6..f864150969 100644 --- a/p2p/base/port.cc +++ b/p2p/base/port.cc @@ -34,7 +34,6 @@ #include "rtc_base/strings/string_builder.h" #include "rtc_base/third_party/base64/base64.h" #include "rtc_base/trace_event.h" -#include "system_wrappers/include/field_trial.h" namespace { diff --git a/p2p/base/stun_request.cc b/p2p/base/stun_request.cc index 09a7a8345e..ed94ccb5fc 100644 --- a/p2p/base/stun_request.cc +++ b/p2p/base/stun_request.cc @@ -19,7 +19,6 @@ #include "rtc_base/logging.h" #include "rtc_base/string_encode.h" #include "rtc_base/time_utils.h" // For TimeMillis -#include "system_wrappers/include/field_trial.h" namespace cricket { diff --git a/p2p/base/transport_description_factory.cc b/p2p/base/transport_description_factory.cc index e46114ed83..18c4a28c2b 100644 --- a/p2p/base/transport_description_factory.cc +++ b/p2p/base/transport_description_factory.cc @@ -21,8 +21,9 @@ namespace cricket { -TransportDescriptionFactory::TransportDescriptionFactory() - : secure_(SEC_DISABLED) {} +TransportDescriptionFactory::TransportDescriptionFactory( + const webrtc::WebRtcKeyValueConfig& field_trials) + : secure_(SEC_DISABLED), field_trials_(field_trials) {} TransportDescriptionFactory::~TransportDescriptionFactory() = default; diff --git a/p2p/base/transport_description_factory.h b/p2p/base/transport_description_factory.h index 0be7f32929..46f1c2f9fa 100644 --- a/p2p/base/transport_description_factory.h +++ b/p2p/base/transport_description_factory.h @@ -13,6 +13,7 @@ #include +#include "api/webrtc_key_value_config.h" #include "p2p/base/ice_credentials_iterator.h" #include "p2p/base/transport_description.h" #include "rtc_base/rtc_certificate.h" @@ -37,7 +38,8 @@ struct TransportOptions { class TransportDescriptionFactory { public: // Default ctor; use methods below to set configuration. - TransportDescriptionFactory(); + explicit TransportDescriptionFactory( + const webrtc::WebRtcKeyValueConfig& field_trials); ~TransportDescriptionFactory(); SecurePolicy secure() const { return secure_; } @@ -73,12 +75,15 @@ class TransportDescriptionFactory { const TransportDescription* current_description, IceCredentialsIterator* ice_credentials) const; + const webrtc::WebRtcKeyValueConfig& trials() const { return field_trials_; } + private: bool SetSecurityInfo(TransportDescription* description, ConnectionRole role) const; SecurePolicy secure_; rtc::scoped_refptr certificate_; + const webrtc::WebRtcKeyValueConfig& field_trials_; }; } // namespace cricket diff --git a/p2p/base/transport_description_factory_unittest.cc b/p2p/base/transport_description_factory_unittest.cc index 77a56eff26..75e6e8ee09 100644 --- a/p2p/base/transport_description_factory_unittest.cc +++ b/p2p/base/transport_description_factory_unittest.cc @@ -25,6 +25,7 @@ #include "rtc_base/ssl_identity.h" #include "test/gmock.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" using cricket::TransportDescription; using cricket::TransportDescriptionFactory; @@ -36,6 +37,8 @@ class TransportDescriptionFactoryTest : public ::testing::Test { public: TransportDescriptionFactoryTest() : ice_credentials_({}), + f1_(field_trials_), + f2_(field_trials_), cert1_(rtc::RTCCertificate::Create(std::unique_ptr( new rtc::FakeSSLIdentity("User1")))), cert2_(rtc::RTCCertificate::Create(std::unique_ptr( @@ -156,6 +159,7 @@ class TransportDescriptionFactoryTest : public ::testing::Test { } } + webrtc::test::ScopedKeyValueConfig field_trials_; cricket::IceCredentialsIterator ice_credentials_; TransportDescriptionFactory f1_; TransportDescriptionFactory f2_; diff --git a/pc/BUILD.gn b/pc/BUILD.gn index 32d114444f..f88226a51c 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -143,6 +143,7 @@ rtc_library("rtc_pc_base") { "../api:scoped_refptr", "../api:sequence_checker", "../api:video_track_source_constraints", + "../api:webrtc_key_value_config", "../api/crypto:options", "../api/rtc_event_log", "../api/task_queue", @@ -813,6 +814,7 @@ rtc_source_set("stats_collector") { "../api:rtp_parameters", "../api:scoped_refptr", "../api:sequence_checker", + "../api:webrtc_key_value_config", "../api/audio_codecs:audio_codecs_api", "../api/video:video_rtp_headers", "../call:call_interfaces", @@ -829,7 +831,6 @@ rtc_source_set("stats_collector") { "../rtc_base:stringutils", "../rtc_base:threading", "../rtc_base:timeutils", - "../system_wrappers:field_trial", ] absl_deps = [ "//third_party/abseil-cpp/absl/strings", @@ -906,6 +907,7 @@ rtc_source_set("webrtc_session_description_factory") { "webrtc_session_description_factory.h", ] deps = [ + ":connection_context", ":rtc_pc_base", ":sdp_state_provider", ":session_description", @@ -1581,7 +1583,8 @@ if (rtc_include_tests && !build_with_chromium) { "../rtc_base/task_utils:to_queued_task", "../rtc_base/third_party/sigslot", "../system_wrappers:metrics", - "../test:field_trial", + "../test:explicit_key_value_config", + "../test:scoped_key_value_config", "../test:test_common", "../test:test_main", "../test:test_support", @@ -1767,6 +1770,7 @@ if (rtc_include_tests && !build_with_chromium) { "../api:rtc_error", "../api:rtp_transceiver_direction", "../api:scoped_refptr", + "../api:webrtc_key_value_config", "../api/adaptation:resource_adaptation_api", "../api/audio:audio_mixer_api", "../api/crypto:frame_decryptor_interface", @@ -1817,9 +1821,10 @@ if (rtc_include_tests && !build_with_chromium) { "../rtc_base/third_party/sigslot", "../system_wrappers:field_trial", "../system_wrappers:metrics", - "../test:field_trial", + "../test:explicit_key_value_config", "../test:fileutils", "../test:rtp_test_utils", + "../test:scoped_key_value_config", "../test:test_common", "../test/pc/sctp:fake_sctp_transport", "./scenario_tests:pc_scenario_tests", @@ -1994,9 +1999,10 @@ if (rtc_include_tests && !build_with_chromium) { "../rtc_base/third_party/base64", "../rtc_base/third_party/sigslot", "../system_wrappers:metrics", - "../test:field_trial", + "../test:explicit_key_value_config", "../test:fileutils", "../test:rtp_test_utils", + "../test:scoped_key_value_config", "../test:test_support", "../test/pc/sctp:fake_sctp_transport", ] @@ -2054,10 +2060,12 @@ if (rtc_include_tests && !build_with_chromium) { "../api:rtc_stats_api", "../api:scoped_refptr", "../api:sequence_checker", + "../api:webrtc_key_value_config", "../api/audio:audio_mixer_api", "../api/audio_codecs:audio_codecs_api", "../api/task_queue", "../api/task_queue:default_task_queue_factory", + "../api/transport:webrtc_key_value_config", "../api/video:builtin_video_bitrate_allocator_factory", "../api/video:video_frame", "../api/video:video_rtp_headers", @@ -2084,6 +2092,7 @@ if (rtc_include_tests && !build_with_chromium) { "../rtc_base/synchronization:mutex", "../rtc_base/task_utils:repeating_task", "../rtc_base/third_party/sigslot", + "../test:scoped_key_value_config", "../test:test_support", "../test:video_test_common", ] diff --git a/pc/channel_manager_unittest.cc b/pc/channel_manager_unittest.cc index 9503243a09..7d7d3e475f 100644 --- a/pc/channel_manager_unittest.cc +++ b/pc/channel_manager_unittest.cc @@ -24,6 +24,7 @@ #include "rtc_base/location.h" #include "rtc_base/thread.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" namespace cricket { namespace { @@ -88,6 +89,7 @@ class ChannelManagerTest : public ::testing::Test { video_bitrate_allocator_factory_; std::unique_ptr cm_; cricket::FakeCall fake_call_; + webrtc::test::ScopedKeyValueConfig field_trials_; }; TEST_F(ChannelManagerTest, SetVideoRtxEnabled) { @@ -123,7 +125,8 @@ TEST_F(ChannelManagerTest, CreateDestroyChannels) { "fake_dtls_transport", cricket::ICE_CANDIDATE_COMPONENT_RTP, network_.get()); auto dtls_srtp_transport = std::make_unique( - /*rtcp_mux_required=*/true); + /*rtcp_mux_required=*/true, field_trials_); + network_->Invoke( RTC_FROM_HERE, [&rtp_dtls_transport, &dtls_srtp_transport] { dtls_srtp_transport->SetDtlsTransports(rtp_dtls_transport.get(), diff --git a/pc/channel_unittest.cc b/pc/channel_unittest.cc index 3bf9556403..463f60bf35 100644 --- a/pc/channel_unittest.cc +++ b/pc/channel_unittest.cc @@ -46,6 +46,7 @@ #include "rtc_base/task_utils/to_queued_task.h" #include "test/gmock.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" using cricket::DtlsTransportInternal; using cricket::FakeVoiceMediaChannel; @@ -317,7 +318,7 @@ class ChannelTest : public ::testing::Test, public sigslot::has_slots<> { cricket::DtlsTransportInternal* rtp_dtls_transport, cricket::DtlsTransportInternal* rtcp_dtls_transport) { auto dtls_srtp_transport = std::make_unique( - rtcp_dtls_transport == nullptr); + rtcp_dtls_transport == nullptr, field_trials_); network_thread_->Invoke( RTC_FROM_HERE, @@ -1441,6 +1442,7 @@ class ChannelTest : public ::testing::Test, public sigslot::has_slots<> { rtc::Buffer rtcp_packet_; cricket::CandidatePairInterface* last_selected_candidate_pair_; rtc::UniqueRandomIdGenerator ssrc_generator_; + webrtc::test::ScopedKeyValueConfig field_trials_; }; template <> diff --git a/pc/connection_context.cc b/pc/connection_context.cc index d093ee3cf5..31810bca62 100644 --- a/pc/connection_context.cc +++ b/pc/connection_context.cc @@ -73,7 +73,8 @@ rtc::Thread* MaybeWrapThread(rtc::Thread* signaling_thread, std::unique_ptr MaybeCreateSctpFactory( std::unique_ptr factory, - rtc::Thread* network_thread) { + rtc::Thread* network_thread, + const WebRtcKeyValueConfig& field_trials) { if (factory) { return factory; } @@ -102,15 +103,15 @@ ConnectionContext::ConnectionContext( owned_worker_thread_)), signaling_thread_(MaybeWrapThread(dependencies->signaling_thread, wraps_current_thread_)), + trials_(dependencies->trials ? std::move(dependencies->trials) + : std::make_unique()), network_monitor_factory_( std::move(dependencies->network_monitor_factory)), call_factory_(std::move(dependencies->call_factory)), sctp_factory_( MaybeCreateSctpFactory(std::move(dependencies->sctp_factory), - network_thread())), - trials_(dependencies->trials - ? std::move(dependencies->trials) - : std::make_unique()) { + network_thread(), + *trials_.get())) { signaling_thread_->AllowInvokesToThread(worker_thread_); signaling_thread_->AllowInvokesToThread(network_thread_); worker_thread_->AllowInvokesToThread(network_thread_); diff --git a/pc/connection_context.h b/pc/connection_context.h index 2aaa840df1..05f838fac4 100644 --- a/pc/connection_context.h +++ b/pc/connection_context.h @@ -112,6 +112,10 @@ class ConnectionContext final rtc::Thread* const network_thread_; rtc::Thread* const worker_thread_; rtc::Thread* const signaling_thread_; + + // Accessed both on signaling thread and worker thread. + std::unique_ptr const trials_; + // channel_manager is accessed both on signaling thread and worker thread. std::unique_ptr channel_manager_; std::unique_ptr const network_monitor_factory_ @@ -124,8 +128,6 @@ class ConnectionContext final std::unique_ptr default_socket_factory_ RTC_GUARDED_BY(signaling_thread_); std::unique_ptr const sctp_factory_; - // Accessed both on signaling thread and worker thread. - std::unique_ptr const trials_; }; } // namespace webrtc diff --git a/pc/data_channel_integrationtest.cc b/pc/data_channel_integrationtest.cc index c76a4d97b0..6d96251ac1 100644 --- a/pc/data_channel_integrationtest.cc +++ b/pc/data_channel_integrationtest.cc @@ -39,7 +39,6 @@ #include "rtc_base/logging.h" #include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/virtual_socket_server.h" -#include "system_wrappers/include/field_trial.h" #include "test/gmock.h" #include "test/gtest.h" @@ -845,7 +844,7 @@ TEST_P(DataChannelIntegrationTest, EXPECT_GT(202u, callee()->data_observer()->received_message_count()); EXPECT_LE(2u, callee()->data_observer()->received_message_count()); // Then, check that observed behavior (lose some messages) has not changed - if (!webrtc::field_trial::IsDisabled("WebRTC-DataChannel-Dcsctp")) { + if (!trials().IsDisabled("WebRTC-DataChannel-Dcsctp")) { // DcSctp loses all messages. This is correct. EXPECT_EQ(2u, callee()->data_observer()->received_message_count()); } else { diff --git a/pc/dtls_srtp_transport.cc b/pc/dtls_srtp_transport.cc index 9a4135bb2f..9ec14f530b 100644 --- a/pc/dtls_srtp_transport.cc +++ b/pc/dtls_srtp_transport.cc @@ -27,8 +27,9 @@ static const char kDtlsSrtpExporterLabel[] = "EXTRACTOR-dtls_srtp"; namespace webrtc { -DtlsSrtpTransport::DtlsSrtpTransport(bool rtcp_mux_enabled) - : SrtpTransport(rtcp_mux_enabled) {} +DtlsSrtpTransport::DtlsSrtpTransport(bool rtcp_mux_enabled, + const WebRtcKeyValueConfig& field_trials) + : SrtpTransport(rtcp_mux_enabled, field_trials) {} void DtlsSrtpTransport::SetDtlsTransports( cricket::DtlsTransportInternal* rtp_dtls_transport, diff --git a/pc/dtls_srtp_transport.h b/pc/dtls_srtp_transport.h index c2c51c22f2..2ee6e02e30 100644 --- a/pc/dtls_srtp_transport.h +++ b/pc/dtls_srtp_transport.h @@ -32,7 +32,8 @@ namespace webrtc { // configures the SrtpSessions in the base class. class DtlsSrtpTransport : public SrtpTransport { public: - explicit DtlsSrtpTransport(bool rtcp_mux_enabled); + DtlsSrtpTransport(bool rtcp_mux_enabled, + const WebRtcKeyValueConfig& field_trials); // Set P2P layer RTP/RTCP DtlsTransports. When using RTCP-muxing, // `rtcp_dtls_transport` is null. diff --git a/pc/dtls_srtp_transport_unittest.cc b/pc/dtls_srtp_transport_unittest.cc index 76d9c30c5e..30f09e740c 100644 --- a/pc/dtls_srtp_transport_unittest.cc +++ b/pc/dtls_srtp_transport_unittest.cc @@ -31,6 +31,7 @@ #include "rtc_base/ssl_identity.h" #include "rtc_base/third_party/sigslot/sigslot.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" using cricket::FakeDtlsTransport; using cricket::FakeIceTransport; @@ -59,7 +60,7 @@ class DtlsSrtpTransportTest : public ::testing::Test, FakeDtlsTransport* rtcp_dtls, bool rtcp_mux_enabled) { auto dtls_srtp_transport = - std::make_unique(rtcp_mux_enabled); + std::make_unique(rtcp_mux_enabled, field_trials_); dtls_srtp_transport->SetDtlsTransports(rtp_dtls, rtcp_dtls); @@ -256,6 +257,7 @@ class DtlsSrtpTransportTest : public ::testing::Test, webrtc::TransportObserver transport_observer2_; int sequence_number_ = 0; + webrtc::test::ScopedKeyValueConfig field_trials_; }; // Tests that if RTCP muxing is enabled and transports are set after RTP diff --git a/pc/jsep_transport_controller.cc b/pc/jsep_transport_controller.cc index e63742aaee..6c69130a38 100644 --- a/pc/jsep_transport_controller.cc +++ b/pc/jsep_transport_controller.cc @@ -62,6 +62,7 @@ JsepTransportController::JsepTransportController( RTC_DCHECK(config_.rtcp_handler); RTC_DCHECK(config_.ice_transport_factory); RTC_DCHECK(config_.on_dtls_handshake_error_); + RTC_DCHECK(config_.field_trials); } JsepTransportController::~JsepTransportController() { @@ -477,8 +478,8 @@ JsepTransportController::CreateSdesTransport( cricket::DtlsTransportInternal* rtp_dtls_transport, cricket::DtlsTransportInternal* rtcp_dtls_transport) { RTC_DCHECK_RUN_ON(network_thread_); - auto srtp_transport = - std::make_unique(rtcp_dtls_transport == nullptr); + auto srtp_transport = std::make_unique( + rtcp_dtls_transport == nullptr, *config_.field_trials); RTC_DCHECK(rtp_dtls_transport); srtp_transport->SetRtpPacketTransport(rtp_dtls_transport); if (rtcp_dtls_transport) { @@ -497,7 +498,7 @@ JsepTransportController::CreateDtlsSrtpTransport( cricket::DtlsTransportInternal* rtcp_dtls_transport) { RTC_DCHECK_RUN_ON(network_thread_); auto dtls_srtp_transport = std::make_unique( - rtcp_dtls_transport == nullptr); + rtcp_dtls_transport == nullptr, *config_.field_trials); if (config_.enable_external_auth) { dtls_srtp_transport->EnableExternalAuth(); } diff --git a/pc/jsep_transport_controller.h b/pc/jsep_transport_controller.h index ed4d20ba84..44d5981684 100644 --- a/pc/jsep_transport_controller.h +++ b/pc/jsep_transport_controller.h @@ -137,6 +137,9 @@ class JsepTransportController : public sigslot::has_slots<> { // Factory for SCTP transports. SctpTransportFactoryInterface* sctp_factory = nullptr; std::function on_dtls_handshake_error_; + + // Field trials. + const webrtc::WebRtcKeyValueConfig* field_trials; }; // The ICE related events are fired on the `network_thread`. diff --git a/pc/jsep_transport_controller_unittest.cc b/pc/jsep_transport_controller_unittest.cc index 622a9b90e3..ee306f093a 100644 --- a/pc/jsep_transport_controller_unittest.cc +++ b/pc/jsep_transport_controller_unittest.cc @@ -33,6 +33,7 @@ #include "rtc_base/ssl_identity.h" #include "rtc_base/thread.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" using cricket::Candidate; using cricket::Candidates; @@ -100,6 +101,7 @@ class JsepTransportControllerTest : public JsepTransportController::Observer, config.ice_transport_factory = fake_ice_transport_factory_.get(); config.dtls_transport_factory = fake_dtls_transport_factory_.get(); config.on_dtls_handshake_error_ = [](rtc::SSLHandshakeError s) {}; + config.field_trials = &field_trials_; transport_controller_ = std::make_unique( network_thread, port_allocator, nullptr /* async_resolver_factory */, config); @@ -378,6 +380,7 @@ class JsepTransportControllerTest : public JsepTransportController::Observer, // Transport controller needs to be destroyed first, because it may issue // callbacks that modify the changed_*_by_mid in the destructor. std::unique_ptr transport_controller_; + webrtc::test::ScopedKeyValueConfig field_trials_; }; TEST_F(JsepTransportControllerTest, GetRtpTransport) { diff --git a/pc/jsep_transport_unittest.cc b/pc/jsep_transport_unittest.cc index 2ec96d2af7..c63dc496db 100644 --- a/pc/jsep_transport_unittest.cc +++ b/pc/jsep_transport_unittest.cc @@ -37,6 +37,7 @@ #include "rtc_base/ssl_identity.h" #include "rtc_base/third_party/sigslot/sigslot.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" namespace cricket { namespace { @@ -89,7 +90,7 @@ class JsepTransport2Test : public ::testing::Test, public sigslot::has_slots<> { rtc::PacketTransportInternal* rtp_packet_transport, rtc::PacketTransportInternal* rtcp_packet_transport) { auto srtp_transport = std::make_unique( - rtcp_packet_transport == nullptr); + rtcp_packet_transport == nullptr, field_trials_); srtp_transport->SetRtpPacketTransport(rtp_packet_transport); if (rtcp_packet_transport) { @@ -102,7 +103,7 @@ class JsepTransport2Test : public ::testing::Test, public sigslot::has_slots<> { cricket::DtlsTransportInternal* rtp_dtls_transport, cricket::DtlsTransportInternal* rtcp_dtls_transport) { auto dtls_srtp_transport = std::make_unique( - rtcp_dtls_transport == nullptr); + rtcp_dtls_transport == nullptr, field_trials_); dtls_srtp_transport->SetDtlsTransports(rtp_dtls_transport, rtcp_dtls_transport); return dtls_srtp_transport; @@ -192,6 +193,8 @@ class JsepTransport2Test : public ::testing::Test, public sigslot::has_slots<> { // The SrtpTransport is owned by `jsep_transport_`. Keep a raw pointer here // for testing. webrtc::SrtpTransport* sdes_transport_ = nullptr; + + webrtc::test::ScopedKeyValueConfig field_trials_; }; // The parameterized tests cover both cases when RTCP mux is enable and diff --git a/pc/media_session.cc b/pc/media_session.cc index 2a3a698874..9aeae708d7 100644 --- a/pc/media_session.cc +++ b/pc/media_session.cc @@ -39,7 +39,6 @@ #include "rtc_base/string_encode.h" #include "rtc_base/third_party/base64/base64.h" #include "rtc_base/unique_id_generator.h" -#include "system_wrappers/include/field_trial.h" namespace { @@ -301,7 +300,8 @@ static StreamParams CreateStreamParamsForNewSenderWithSsrcs( const std::string& rtcp_cname, bool include_rtx_streams, bool include_flexfec_stream, - UniqueRandomIdGenerator* ssrc_generator) { + UniqueRandomIdGenerator* ssrc_generator, + const webrtc::WebRtcKeyValueConfig& field_trials) { StreamParams result; result.id = sender.track_id; @@ -313,8 +313,7 @@ static StreamParams CreateStreamParamsForNewSenderWithSsrcs( "a single media streams. This session has multiple " "media streams however, so no FlexFEC SSRC will be generated."; } - if (include_flexfec_stream && - !webrtc::field_trial::IsEnabled("WebRTC-FlexFEC-03")) { + if (include_flexfec_stream && !field_trials.IsEnabled("WebRTC-FlexFEC-03")) { include_flexfec_stream = false; RTC_LOG(LS_WARNING) << "WebRTC-FlexFEC trial is not enabled, not sending FlexFEC"; @@ -396,12 +395,12 @@ static void AddSimulcastToMediaDescription( // content_description. // `current_params` - All currently known StreamParams of any media type. template -static bool AddStreamParams( - const std::vector& sender_options, - const std::string& rtcp_cname, - UniqueRandomIdGenerator* ssrc_generator, - StreamParamsVec* current_streams, - MediaContentDescriptionImpl* content_description) { +static bool AddStreamParams(const std::vector& sender_options, + const std::string& rtcp_cname, + UniqueRandomIdGenerator* ssrc_generator, + StreamParamsVec* current_streams, + MediaContentDescriptionImpl* content_description, + const webrtc::WebRtcKeyValueConfig& field_trials) { // SCTP streams are not negotiated using SDP/ContentDescriptions. if (IsSctpProtocol(content_description->protocol())) { return true; @@ -423,7 +422,7 @@ static bool AddStreamParams( // Signal SSRCs and legacy simulcast (if requested). CreateStreamParamsForNewSenderWithSsrcs( sender, rtcp_cname, include_rtx_streams, - include_flexfec_stream, ssrc_generator) + include_flexfec_stream, ssrc_generator, field_trials) : // Signal RIDs and spec-compliant simulcast (if requested). CreateStreamParamsForNewSenderWithRids(sender, rtcp_cname); @@ -711,11 +710,12 @@ static bool CreateMediaContentOffer( const RtpHeaderExtensions& rtp_extensions, UniqueRandomIdGenerator* ssrc_generator, StreamParamsVec* current_streams, - MediaContentDescriptionImpl* offer) { + MediaContentDescriptionImpl* offer, + const webrtc::WebRtcKeyValueConfig& field_trials) { offer->AddCodecs(codecs); if (!AddStreamParams(media_description_options.sender_options, session_options.rtcp_cname, ssrc_generator, - current_streams, offer)) { + current_streams, offer, field_trials)) { return false; } @@ -1351,7 +1351,8 @@ static bool SetCodecsInAnswer( const MediaSessionOptions& session_options, UniqueRandomIdGenerator* ssrc_generator, StreamParamsVec* current_streams, - MediaContentDescriptionImpl* answer) { + MediaContentDescriptionImpl* answer, + const webrtc::WebRtcKeyValueConfig& field_trials) { std::vector negotiated_codecs; NegotiateCodecs(local_codecs, offer->codecs(), &negotiated_codecs, media_description_options.codec_preferences.empty()); @@ -1359,7 +1360,7 @@ static bool SetCodecsInAnswer( answer->set_protocol(offer->protocol()); if (!AddStreamParams(media_description_options.sender_options, session_options.rtcp_cname, ssrc_generator, - current_streams, answer)) { + current_streams, answer, field_trials)) { return false; // Something went seriously wrong. } return true; @@ -2325,11 +2326,11 @@ bool MediaSessionDescriptionFactory::AddAudioContentForOffer( std::vector crypto_suites; GetSupportedAudioSdesCryptoSuiteNames(session_options.crypto_options, &crypto_suites); - if (!CreateMediaContentOffer(media_description_options, session_options, - filtered_codecs, sdes_policy, - GetCryptos(current_content), crypto_suites, - audio_rtp_extensions, ssrc_generator_, - current_streams, audio.get())) { + if (!CreateMediaContentOffer( + media_description_options, session_options, filtered_codecs, + sdes_policy, GetCryptos(current_content), crypto_suites, + audio_rtp_extensions, ssrc_generator_, current_streams, audio.get(), + transport_desc_factory_->trials())) { return false; } @@ -2434,11 +2435,11 @@ bool MediaSessionDescriptionFactory::AddVideoContentForOffer( std::vector crypto_suites; GetSupportedVideoSdesCryptoSuiteNames(session_options.crypto_options, &crypto_suites); - if (!CreateMediaContentOffer(media_description_options, session_options, - filtered_codecs, sdes_policy, - GetCryptos(current_content), crypto_suites, - video_rtp_extensions, ssrc_generator_, - current_streams, video.get())) { + if (!CreateMediaContentOffer( + media_description_options, session_options, filtered_codecs, + sdes_policy, GetCryptos(current_content), crypto_suites, + video_rtp_extensions, ssrc_generator_, current_streams, video.get(), + transport_desc_factory_->trials())) { return false; } @@ -2622,8 +2623,8 @@ bool MediaSessionDescriptionFactory::AddAudioContentForAnswer( audio_transport->secure() ? cricket::SEC_DISABLED : secure(); if (!SetCodecsInAnswer(offer_audio_description, filtered_codecs, media_description_options, session_options, - ssrc_generator_, current_streams, - audio_answer.get())) { + ssrc_generator_, current_streams, audio_answer.get(), + transport_desc_factory_->trials())) { return false; } if (!CreateMediaContentAnswer( @@ -2748,8 +2749,8 @@ bool MediaSessionDescriptionFactory::AddVideoContentForAnswer( video_transport->secure() ? cricket::SEC_DISABLED : secure(); if (!SetCodecsInAnswer(offer_video_description, filtered_codecs, media_description_options, session_options, - ssrc_generator_, current_streams, - video_answer.get())) { + ssrc_generator_, current_streams, video_answer.get(), + transport_desc_factory_->trials())) { return false; } if (!CreateMediaContentAnswer( diff --git a/pc/media_session.h b/pc/media_session.h index aa24f015de..d6c7474fe6 100644 --- a/pc/media_session.h +++ b/pc/media_session.h @@ -22,6 +22,7 @@ #include "api/media_types.h" #include "api/rtp_parameters.h" #include "api/rtp_transceiver_direction.h" +#include "api/webrtc_key_value_config.h" #include "media/base/media_constants.h" #include "media/base/rid_description.h" #include "media/base/stream_params.h" @@ -35,6 +36,13 @@ #include "pc/simulcast_description.h" #include "rtc_base/unique_id_generator.h" +namespace webrtc { + +// Forward declaration due to circular dependecy. +class ConnectionContext; + +} // namespace webrtc + namespace cricket { class ChannelManager; diff --git a/pc/media_session_unittest.cc b/pc/media_session_unittest.cc index 6bc842d222..f06ddc7586 100644 --- a/pc/media_session_unittest.cc +++ b/pc/media_session_unittest.cc @@ -43,9 +43,9 @@ #include "rtc_base/string_encode.h" #include "rtc_base/strings/string_builder.h" #include "rtc_base/unique_id_generator.h" -#include "test/field_trial.h" #include "test/gmock.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" #define ASSERT_CRYPTO(cd, s, cs) \ ASSERT_EQ(s, cd->cryptos().size()); \ @@ -431,7 +431,10 @@ void PreferGcmCryptoParameters(CryptoParamsVec* cryptos) { class MediaSessionDescriptionFactoryTest : public ::testing::Test { public: MediaSessionDescriptionFactoryTest() - : f1_(&tdf1_, &ssrc_generator1), f2_(&tdf2_, &ssrc_generator2) { + : tdf1_(field_trials), + tdf2_(field_trials), + f1_(&tdf1_, &ssrc_generator1), + f2_(&tdf2_, &ssrc_generator2) { f1_.set_audio_codecs(MAKE_VECTOR(kAudioCodecs1), MAKE_VECTOR(kAudioCodecs1)); f1_.set_video_codecs(MAKE_VECTOR(kVideoCodecs1), @@ -791,12 +794,13 @@ class MediaSessionDescriptionFactoryTest : public ::testing::Test { } protected: + webrtc::test::ScopedKeyValueConfig field_trials; UniqueRandomIdGenerator ssrc_generator1; UniqueRandomIdGenerator ssrc_generator2; - MediaSessionDescriptionFactory f1_; - MediaSessionDescriptionFactory f2_; TransportDescriptionFactory tdf1_; TransportDescriptionFactory tdf2_; + MediaSessionDescriptionFactory f1_; + MediaSessionDescriptionFactory f2_; }; // Create a typical audio offer, and ensure it matches what we expect. @@ -3260,8 +3264,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateMultipleRtxSsrcs) { // Test that, when the FlexFEC codec is added, a FlexFEC ssrc is created // together with a FEC-FR grouping. Guarded by WebRTC-FlexFEC-03 trial. TEST_F(MediaSessionDescriptionFactoryTest, GenerateFlexfecSsrc) { - webrtc::test::ScopedFieldTrials override_field_trials( - "WebRTC-FlexFEC-03/Enabled/"); + webrtc::test::ScopedKeyValueConfig override_field_trials( + field_trials, "WebRTC-FlexFEC-03/Enabled/"); MediaSessionOptions opts; AddMediaDescriptionOptions(MEDIA_TYPE_VIDEO, "video", RtpTransceiverDirection::kSendRecv, kActive, @@ -3303,8 +3307,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, GenerateFlexfecSsrc) { // TODO(brandtr): Remove this test when we support simulcast, either through // multiple FlexfecSenders, or through multistream protection. TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateNoFlexfecSsrcs) { - webrtc::test::ScopedFieldTrials override_field_trials( - "WebRTC-FlexFEC-03/Enabled/"); + webrtc::test::ScopedKeyValueConfig override_field_trials( + field_trials, "WebRTC-FlexFEC-03/Enabled/"); MediaSessionOptions opts; AddMediaDescriptionOptions(MEDIA_TYPE_VIDEO, "video", RtpTransceiverDirection::kSendRecv, kActive, @@ -4330,7 +4334,10 @@ TEST_F(MediaSessionDescriptionFactoryTest, class MediaProtocolTest : public ::testing::TestWithParam { public: MediaProtocolTest() - : f1_(&tdf1_, &ssrc_generator1), f2_(&tdf2_, &ssrc_generator2) { + : tdf1_(field_trials_), + tdf2_(field_trials_), + f1_(&tdf1_, &ssrc_generator1), + f2_(&tdf2_, &ssrc_generator2) { f1_.set_audio_codecs(MAKE_VECTOR(kAudioCodecs1), MAKE_VECTOR(kAudioCodecs1)); f1_.set_video_codecs(MAKE_VECTOR(kVideoCodecs1), @@ -4350,10 +4357,11 @@ class MediaProtocolTest : public ::testing::TestWithParam { } protected: - MediaSessionDescriptionFactory f1_; - MediaSessionDescriptionFactory f2_; + webrtc::test::ScopedKeyValueConfig field_trials_; TransportDescriptionFactory tdf1_; TransportDescriptionFactory tdf2_; + MediaSessionDescriptionFactory f1_; + MediaSessionDescriptionFactory f2_; UniqueRandomIdGenerator ssrc_generator1; UniqueRandomIdGenerator ssrc_generator2; }; @@ -4389,7 +4397,8 @@ INSTANTIATE_TEST_SUITE_P(MediaProtocolDtlsPatternTest, ::testing::ValuesIn(kMediaProtocolsDtls)); TEST_F(MediaSessionDescriptionFactoryTest, TestSetAudioCodecs) { - TransportDescriptionFactory tdf; + webrtc::test::ScopedKeyValueConfig field_trials; + TransportDescriptionFactory tdf(field_trials); UniqueRandomIdGenerator ssrc_generator; MediaSessionDescriptionFactory sf(&tdf, &ssrc_generator); std::vector send_codecs = MAKE_VECTOR(kAudioCodecs1); @@ -4459,7 +4468,8 @@ bool CodecsMatch(const std::vector& codecs1, } void TestAudioCodecsOffer(RtpTransceiverDirection direction) { - TransportDescriptionFactory tdf; + webrtc::test::ScopedKeyValueConfig field_trials; + TransportDescriptionFactory tdf(field_trials); UniqueRandomIdGenerator ssrc_generator; MediaSessionDescriptionFactory sf(&tdf, &ssrc_generator); const std::vector send_codecs = MAKE_VECTOR(kAudioCodecs1); @@ -4556,11 +4566,13 @@ std::vector VectorFromIndices(const T* array, const int (&indices)[IDXS]) { void TestAudioCodecsAnswer(RtpTransceiverDirection offer_direction, RtpTransceiverDirection answer_direction, bool add_legacy_stream) { - TransportDescriptionFactory offer_tdf; - TransportDescriptionFactory answer_tdf; + webrtc::test::ScopedKeyValueConfig field_trials; + TransportDescriptionFactory offer_tdf(field_trials); + TransportDescriptionFactory answer_tdf(field_trials); UniqueRandomIdGenerator ssrc_generator1, ssrc_generator2; MediaSessionDescriptionFactory offer_factory(&offer_tdf, &ssrc_generator1); MediaSessionDescriptionFactory answer_factory(&answer_tdf, &ssrc_generator2); + offer_factory.set_audio_codecs( VectorFromIndices(kOfferAnswerCodecs, kOfferSendCodecs), VectorFromIndices(kOfferAnswerCodecs, kOfferRecvCodecs)); diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc index a315ac510f..ec6bef32f7 100644 --- a/pc/peer_connection.cc +++ b/pc/peer_connection.cc @@ -711,6 +711,8 @@ JsepTransportController* PeerConnection::InitializeTransportController_n( } }; + config.field_trials = &context_->trials(); + transport_controller_.reset( new JsepTransportController(network_thread(), port_allocator_.get(), async_dns_resolver_factory_.get(), config)); diff --git a/pc/peer_connection.h b/pc/peer_connection.h index cd4af9e420..a6e4510b47 100644 --- a/pc/peer_connection.h +++ b/pc/peer_connection.h @@ -451,6 +451,8 @@ class PeerConnection : public PeerConnectionInternal, } void RequestUsagePatternReportForTesting(); + const WebRtcKeyValueConfig& trials() override { return context_->trials(); } + protected: // Available for rtc::scoped_refptr creation PeerConnection(rtc::scoped_refptr context, diff --git a/pc/peer_connection_internal.h b/pc/peer_connection_internal.h index 16caade6c9..eaff20a0d3 100644 --- a/pc/peer_connection_internal.h +++ b/pc/peer_connection_internal.h @@ -178,6 +178,8 @@ class PeerConnectionInternal : public PeerConnectionInterface, virtual void NoteDataAddedEvent() {} // Handler for the "channel closed" signal virtual void OnSctpDataChannelClosed(DataChannelInterface* channel) {} + + virtual const WebRtcKeyValueConfig& trials() = 0; }; } // namespace webrtc diff --git a/pc/rtp_sender_receiver_unittest.cc b/pc/rtp_sender_receiver_unittest.cc index c0b09e39c3..a7b9c9ab68 100644 --- a/pc/rtp_sender_receiver_unittest.cc +++ b/pc/rtp_sender_receiver_unittest.cc @@ -70,6 +70,7 @@ #include "test/gmock.h" #include "test/gtest.h" #include "test/run_loop.h" +#include "test/scoped_key_value_config.h" using ::testing::_; using ::testing::ContainerEq; @@ -187,7 +188,7 @@ class RtpSenderReceiverTest std::unique_ptr CreateDtlsSrtpTransport() { auto dtls_srtp_transport = std::make_unique( - /*rtcp_mux_required=*/true); + /*rtcp_mux_required=*/true, field_trials_); dtls_srtp_transport->SetDtlsTransports(rtp_dtls_transport_.get(), /*rtcp_dtls_transport=*/nullptr); return dtls_srtp_transport; @@ -544,6 +545,7 @@ class RtpSenderReceiverTest rtc::scoped_refptr video_track_; rtc::scoped_refptr audio_track_; bool audio_sender_destroyed_signal_fired_ = false; + webrtc::test::ScopedKeyValueConfig field_trials_; }; // Test that `voice_channel_` is updated when an audio track is associated diff --git a/pc/sdp_offer_answer.cc b/pc/sdp_offer_answer.cc index 69588350ab..a9501caa5e 100644 --- a/pc/sdp_offer_answer.cc +++ b/pc/sdp_offer_answer.cc @@ -63,7 +63,6 @@ #include "rtc_base/string_encode.h" #include "rtc_base/strings/string_builder.h" #include "rtc_base/trace_event.h" -#include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/metrics.h" using cricket::ContentInfo; @@ -1186,13 +1185,14 @@ std::unique_ptr SdpOfferAnswerHandler::Create( PeerConnectionDependencies& dependencies, ConnectionContext* context) { auto handler = absl::WrapUnique(new SdpOfferAnswerHandler(pc, context)); - handler->Initialize(configuration, dependencies); + handler->Initialize(configuration, dependencies, context); return handler; } void SdpOfferAnswerHandler::Initialize( const PeerConnectionInterface::RTCConfiguration& configuration, - PeerConnectionDependencies& dependencies) { + PeerConnectionDependencies& dependencies, + ConnectionContext* context) { RTC_DCHECK_RUN_ON(signaling_thread()); video_options_.screencast_min_bitrate_kbps = configuration.screencast_min_bitrate; @@ -1222,9 +1222,8 @@ void SdpOfferAnswerHandler::Initialize( webrtc_session_desc_factory_ = std::make_unique( - signaling_thread(), channel_manager(), this, pc_->session_id(), - pc_->dtls_enabled(), std::move(dependencies.cert_generator), - certificate, + context, this, pc_->session_id(), pc_->dtls_enabled(), + std::move(dependencies.cert_generator), certificate, [this](const rtc::scoped_refptr& certificate) { RTC_DCHECK_RUN_ON(signaling_thread()); transport_controller_s()->SetLocalCertificate(certificate); diff --git a/pc/sdp_offer_answer.h b/pc/sdp_offer_answer.h index 67ead47242..a32ece930b 100644 --- a/pc/sdp_offer_answer.h +++ b/pc/sdp_offer_answer.h @@ -220,7 +220,8 @@ class SdpOfferAnswerHandler : public SdpStateProvider, // once. Modifies dependencies. void Initialize( const PeerConnectionInterface::RTCConfiguration& configuration, - PeerConnectionDependencies& dependencies); + PeerConnectionDependencies& dependencies, + ConnectionContext* context); rtc::Thread* signaling_thread() const; rtc::Thread* network_thread() const; diff --git a/pc/srtp_session.cc b/pc/srtp_session.cc index a81f2415a5..b5b244265c 100644 --- a/pc/srtp_session.cc +++ b/pc/srtp_session.cc @@ -18,6 +18,7 @@ #include "absl/base/attributes.h" #include "absl/base/const_init.h" #include "api/array_view.h" +#include "api/webrtc_key_value_config.h" #include "modules/rtp_rtcp/source/rtp_util.h" #include "pc/external_hmac.h" #include "rtc_base/byte_order.h" @@ -26,7 +27,6 @@ #include "rtc_base/ssl_stream_adapter.h" #include "rtc_base/string_encode.h" #include "rtc_base/time_utils.h" -#include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/metrics.h" #include "third_party/libsrtp/include/srtp.h" #include "third_party/libsrtp/include/srtp_priv.h" @@ -40,8 +40,10 @@ using ::webrtc::ParseRtpSequenceNumber; // in srtp.h. constexpr int kSrtpErrorCodeBoundary = 28; -SrtpSession::SrtpSession() { - dump_plain_rtp_ = webrtc::field_trial::IsEnabled("WebRTC-Debugging-RtpDump"); +SrtpSession::SrtpSession() {} + +SrtpSession::SrtpSession(const webrtc::WebRtcKeyValueConfig& field_trials) { + dump_plain_rtp_ = field_trials.IsEnabled("WebRTC-Debugging-RtpDump"); } SrtpSession::~SrtpSession() { diff --git a/pc/srtp_session.h b/pc/srtp_session.h index d88eaae319..c3979aae7a 100644 --- a/pc/srtp_session.h +++ b/pc/srtp_session.h @@ -18,6 +18,7 @@ #include "api/scoped_refptr.h" #include "api/sequence_checker.h" +#include "api/webrtc_key_value_config.h" #include "rtc_base/synchronization/mutex.h" // Forward declaration to avoid pulling in libsrtp headers here @@ -35,6 +36,7 @@ void ProhibitLibsrtpInitialization(); class SrtpSession { public: SrtpSession(); + explicit SrtpSession(const webrtc::WebRtcKeyValueConfig& field_trials); ~SrtpSession(); SrtpSession(const SrtpSession&) = delete; diff --git a/pc/srtp_session_unittest.cc b/pc/srtp_session_unittest.cc index dc08c2e908..16a840a307 100644 --- a/pc/srtp_session_unittest.cc +++ b/pc/srtp_session_unittest.cc @@ -21,6 +21,7 @@ #include "system_wrappers/include/metrics.h" #include "test/gmock.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" #include "third_party/libsrtp/include/srtp.h" using ::testing::ElementsAre; @@ -32,7 +33,9 @@ std::vector kEncryptedHeaderExtensionIds; class SrtpSessionTest : public ::testing::Test { public: - SrtpSessionTest() { webrtc::metrics::Reset(); } + SrtpSessionTest() : s1_(field_trials_), s2_(field_trials_) { + webrtc::metrics::Reset(); + } protected: virtual void SetUp() { @@ -69,6 +72,7 @@ class SrtpSessionTest : public ::testing::Test { EXPECT_EQ(expected_len, out_len); EXPECT_EQ(0, memcmp(rtcp_packet_, kRtcpReport, out_len)); } + webrtc::test::ScopedKeyValueConfig field_trials_; cricket::SrtpSession s1_; cricket::SrtpSession s2_; char rtp_packet_[sizeof(kPcmuFrame) + 10]; diff --git a/pc/srtp_transport.cc b/pc/srtp_transport.cc index 230c1a347b..b59fc1d1d2 100644 --- a/pc/srtp_transport.cc +++ b/pc/srtp_transport.cc @@ -34,8 +34,9 @@ namespace webrtc { -SrtpTransport::SrtpTransport(bool rtcp_mux_enabled) - : RtpTransport(rtcp_mux_enabled) {} +SrtpTransport::SrtpTransport(bool rtcp_mux_enabled, + const WebRtcKeyValueConfig& field_trials) + : RtpTransport(rtcp_mux_enabled), field_trials_(field_trials) {} RTCError SrtpTransport::SetSrtpSendKey(const cricket::CryptoParams& params) { if (send_params_) { @@ -324,13 +325,13 @@ bool SrtpTransport::SetRtcpParams(int send_cs, return false; } - send_rtcp_session_.reset(new cricket::SrtpSession()); + send_rtcp_session_.reset(new cricket::SrtpSession(field_trials_)); if (!send_rtcp_session_->SetSend(send_cs, send_key, send_key_len, send_extension_ids)) { return false; } - recv_rtcp_session_.reset(new cricket::SrtpSession()); + recv_rtcp_session_.reset(new cricket::SrtpSession(field_trials_)); if (!recv_rtcp_session_->SetRecv(recv_cs, recv_key, recv_key_len, recv_extension_ids)) { return false; @@ -361,8 +362,8 @@ void SrtpTransport::ResetParams() { } void SrtpTransport::CreateSrtpSessions() { - send_session_.reset(new cricket::SrtpSession()); - recv_session_.reset(new cricket::SrtpSession()); + send_session_.reset(new cricket::SrtpSession(field_trials_)); + recv_session_.reset(new cricket::SrtpSession(field_trials_)); if (external_auth_enabled_) { send_session_->EnableExternalAuth(); } diff --git a/pc/srtp_transport.h b/pc/srtp_transport.h index 4bc028d68e..2fec29eb01 100644 --- a/pc/srtp_transport.h +++ b/pc/srtp_transport.h @@ -21,6 +21,7 @@ #include "absl/types/optional.h" #include "api/crypto_params.h" #include "api/rtc_error.h" +#include "api/webrtc_key_value_config.h" #include "p2p/base/packet_transport_internal.h" #include "pc/rtp_transport.h" #include "pc/srtp_session.h" @@ -36,7 +37,8 @@ namespace webrtc { // parameters for the SrtpSession underneath. class SrtpTransport : public RtpTransport { public: - explicit SrtpTransport(bool rtcp_mux_enabled); + SrtpTransport(bool rtcp_mux_enabled, + const WebRtcKeyValueConfig& field_trials); virtual ~SrtpTransport() = default; @@ -167,6 +169,8 @@ class SrtpTransport : public RtpTransport { int rtp_abs_sendtime_extn_id_ = -1; int decryption_failure_count_ = 0; + + const WebRtcKeyValueConfig& field_trials_; }; } // namespace webrtc diff --git a/pc/srtp_transport_unittest.cc b/pc/srtp_transport_unittest.cc index 980ebca08a..4e643935a9 100644 --- a/pc/srtp_transport_unittest.cc +++ b/pc/srtp_transport_unittest.cc @@ -27,6 +27,7 @@ #include "rtc_base/ssl_stream_adapter.h" #include "rtc_base/third_party/sigslot/sigslot.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" using rtc::kSrtpAeadAes128Gcm; using rtc::kTestKey1; @@ -57,8 +58,10 @@ class SrtpTransportTest : public ::testing::Test, public sigslot::has_slots<> { rtp_packet_transport1_->SetDestination(rtp_packet_transport2_.get(), asymmetric); - srtp_transport1_ = std::make_unique(rtcp_mux_enabled); - srtp_transport2_ = std::make_unique(rtcp_mux_enabled); + srtp_transport1_ = + std::make_unique(rtcp_mux_enabled, field_trials_); + srtp_transport2_ = + std::make_unique(rtcp_mux_enabled, field_trials_); srtp_transport1_->SetRtpPacketTransport(rtp_packet_transport1_.get()); srtp_transport2_->SetRtpPacketTransport(rtp_packet_transport2_.get()); @@ -333,6 +336,7 @@ class SrtpTransportTest : public ::testing::Test, public sigslot::has_slots<> { TransportObserver rtp_sink2_; int sequence_number_ = 0; + webrtc::test::ScopedKeyValueConfig field_trials_; }; class SrtpTransportTestWithExternalAuth diff --git a/pc/stats_collector.cc b/pc/stats_collector.cc index 6b1cda3ad5..927e993203 100644 --- a/pc/stats_collector.cc +++ b/pc/stats_collector.cc @@ -31,6 +31,7 @@ #include "api/sequence_checker.h" #include "api/video/video_content_type.h" #include "api/video/video_timing.h" +#include "api/webrtc_key_value_config.h" #include "call/call.h" #include "media/base/media_channel.h" #include "modules/audio_processing/include/audio_processing_statistics.h" @@ -55,7 +56,6 @@ #include "rtc_base/thread.h" #include "rtc_base/time_utils.h" #include "rtc_base/trace_event.h" -#include "system_wrappers/include/field_trial.h" namespace webrtc { namespace { @@ -543,7 +543,7 @@ StatsCollector::StatsCollector(PeerConnectionInternal* pc) : pc_(pc), stats_gathering_started_(0), use_standard_bytes_stats_( - webrtc::field_trial::IsEnabled(kUseStandardBytesStats)) { + pc->trials().IsEnabled(kUseStandardBytesStats)) { RTC_DCHECK(pc_); } diff --git a/pc/stats_collector.h b/pc/stats_collector.h index 751a2de09c..794437e9eb 100644 --- a/pc/stats_collector.h +++ b/pc/stats_collector.h @@ -30,6 +30,7 @@ #include "api/peer_connection_interface.h" #include "api/scoped_refptr.h" #include "api/stats_types.h" +#include "api/webrtc_key_value_config.h" #include "p2p/base/connection_info.h" #include "p2p/base/port.h" #include "pc/peer_connection_internal.h" diff --git a/pc/test/fake_peer_connection_base.h b/pc/test/fake_peer_connection_base.h index 7d64ab8180..2b4dd73913 100644 --- a/pc/test/fake_peer_connection_base.h +++ b/pc/test/fake_peer_connection_base.h @@ -18,7 +18,9 @@ #include #include "api/sctp_transport_interface.h" +#include "api/webrtc_key_value_config.h" #include "pc/peer_connection_internal.h" +#include "test/scoped_key_value_config.h" namespace webrtc { @@ -358,7 +360,10 @@ class FakePeerConnectionBase : public PeerConnectionInternal { void SetSctpDataMid(const std::string& mid) override {} void ResetSctpDataMid() override {} + const WebRtcKeyValueConfig& trials() override { return field_trials_; } + protected: + webrtc::test::ScopedKeyValueConfig field_trials_; sigslot::signal1 SignalSctpDataChannelCreated_; }; diff --git a/pc/test/integration_test_helpers.h b/pc/test/integration_test_helpers.h index 99ad8af4b5..00417d96a5 100644 --- a/pc/test/integration_test_helpers.h +++ b/pc/test/integration_test_helpers.h @@ -120,8 +120,8 @@ #include "rtc_base/time_utils.h" #include "rtc_base/virtual_socket_server.h" #include "system_wrappers/include/metrics.h" -#include "test/field_trial.h" #include "test/gmock.h" +#include "test/scoped_key_value_config.h" namespace webrtc { @@ -1366,9 +1366,9 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test { fss_(new rtc::FirewallSocketServer(ss_.get())), network_thread_(new rtc::Thread(fss_.get())), worker_thread_(rtc::Thread::Create()), - field_trials_(field_trials.has_value() - ? new test::ScopedFieldTrials(*field_trials) - : nullptr) { + // TODO(bugs.webrtc.org/10335): Pass optional ScopedKeyValueConfig. + field_trials_(new test::ScopedKeyValueConfig( + field_trials.has_value() ? *field_trials : "")) { network_thread_->SetName("PCNetworkThread", this); worker_thread_->SetName("PCWorkerThread", this); RTC_CHECK(network_thread_->Start()); @@ -1855,6 +1855,8 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test { expected_cipher_suite); } + const WebRtcKeyValueConfig& trials() const { return *field_trials_.get(); } + protected: SdpSemantics sdp_semantics_; @@ -1874,7 +1876,7 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test { std::vector> turn_customizers_; std::unique_ptr caller_; std::unique_ptr callee_; - std::unique_ptr field_trials_; + std::unique_ptr field_trials_; }; } // namespace webrtc diff --git a/pc/webrtc_session_description_factory.cc b/pc/webrtc_session_description_factory.cc index 82ba849544..09f2ee2f00 100644 --- a/pc/webrtc_session_description_factory.cc +++ b/pc/webrtc_session_description_factory.cc @@ -24,6 +24,7 @@ #include "api/jsep_session_description.h" #include "api/rtc_error.h" #include "api/sequence_checker.h" +#include "pc/connection_context.h" #include "pc/sdp_state_provider.h" #include "pc/session_description.h" #include "rtc_base/checks.h" @@ -127,8 +128,7 @@ void WebRtcSessionDescriptionFactory::CopyCandidatesFromSessionDescription( } WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory( - rtc::Thread* signaling_thread, - cricket::ChannelManager* channel_manager, + ConnectionContext* context, const SdpStateProvider* sdp_info, const std::string& session_id, bool dtls_enabled, @@ -136,8 +136,10 @@ WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory( const rtc::scoped_refptr& certificate, std::function&)> on_certificate_ready) - : signaling_thread_(signaling_thread), - session_desc_factory_(channel_manager, &transport_desc_factory_), + : signaling_thread_(context->signaling_thread()), + transport_desc_factory_(context->trials()), + session_desc_factory_(context->channel_manager(), + &transport_desc_factory_), // RFC 4566 suggested a Network Time Protocol (NTP) format timestamp // as the session id and session version. To simplify, it should be fine // to just use a random number as session id and start version from diff --git a/pc/webrtc_session_description_factory.h b/pc/webrtc_session_description_factory.h index 6a6e8efa51..79171f797b 100644 --- a/pc/webrtc_session_description_factory.h +++ b/pc/webrtc_session_description_factory.h @@ -79,8 +79,7 @@ class WebRtcSessionDescriptionFactory : public rtc::MessageHandler, // asynchronously. If a certificate is given, will use that for identifying // over DTLS. If neither is specified, DTLS is disabled. WebRtcSessionDescriptionFactory( - rtc::Thread* signaling_thread, - cricket::ChannelManager* channel_manager, + ConnectionContext* context, const SdpStateProvider* sdp_info, const std::string& session_id, bool dtls_enabled, diff --git a/test/BUILD.gn b/test/BUILD.gn index f49dbd485a..82d909d1ae 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -214,7 +214,6 @@ rtc_library("rtp_test_utils") { rtc_library("field_trial") { visibility = [ "*" ] - testonly = true sources = [ "field_trial.cc", "field_trial.h", @@ -233,9 +232,23 @@ rtc_library("explicit_key_value_config") { ] deps = [ - "../api/transport:webrtc_key_value_config", + ":field_trial", + "../api:webrtc_key_value_config", + "../rtc_base:checks", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/strings:strings" ] +} + +rtc_library("scoped_key_value_config") { + sources = [ + "scoped_key_value_config.cc", + "scoped_key_value_config.h", + ] + + deps = [ + ":field_trial", + "../api:webrtc_key_value_config", "../rtc_base:checks", - "../system_wrappers:field_trial", ] absl_deps = [ "//third_party/abseil-cpp/absl/strings:strings" ] } diff --git a/test/explicit_key_value_config.cc b/test/explicit_key_value_config.cc index 69f725a9e2..6a561fa209 100644 --- a/test/explicit_key_value_config.cc +++ b/test/explicit_key_value_config.cc @@ -10,9 +10,8 @@ #include "test/explicit_key_value_config.h" -#include "api/transport/webrtc_key_value_config.h" +#include "api/webrtc_key_value_config.h" #include "rtc_base/checks.h" -#include "system_wrappers/include/field_trial.h" namespace webrtc { namespace test { diff --git a/test/explicit_key_value_config.h b/test/explicit_key_value_config.h index 9a3bc84f60..0a728ab536 100644 --- a/test/explicit_key_value_config.h +++ b/test/explicit_key_value_config.h @@ -15,7 +15,7 @@ #include #include "absl/strings/string_view.h" -#include "api/transport/webrtc_key_value_config.h" +#include "api/webrtc_key_value_config.h" namespace webrtc { namespace test { diff --git a/test/peer_scenario/BUILD.gn b/test/peer_scenario/BUILD.gn index a08b4acbeb..d3ac0da606 100644 --- a/test/peer_scenario/BUILD.gn +++ b/test/peer_scenario/BUILD.gn @@ -49,6 +49,8 @@ if (rtc_include_tests) { "../../rtc_base", "../../rtc_base:null_socket_server", "../../rtc_base:stringutils", + "../../test:explicit_key_value_config", + "../../test:scoped_key_value_config", "../logging:log_writer", "../network:emulated_network", "../scenario", diff --git a/test/peer_scenario/scenario_connection.cc b/test/peer_scenario/scenario_connection.cc index dac21d5586..07da453b8a 100644 --- a/test/peer_scenario/scenario_connection.cc +++ b/test/peer_scenario/scenario_connection.cc @@ -132,6 +132,7 @@ JsepTransportController::Config ScenarioIceConnectionImpl::CreateJsepConfig() { RTC_DCHECK_RUN_ON(network_thread_); observer_->OnPacketReceived(packet); }; + config.field_trials = &field_trials; return config; } diff --git a/test/peer_scenario/scenario_connection.h b/test/peer_scenario/scenario_connection.h index f43b3d39d4..e8cef527c5 100644 --- a/test/peer_scenario/scenario_connection.h +++ b/test/peer_scenario/scenario_connection.h @@ -19,6 +19,7 @@ #include "api/jsep.h" #include "p2p/base/transport_description.h" #include "test/network/network_emulation_manager.h" +#include "test/scoped_key_value_config.h" namespace webrtc { @@ -56,6 +57,8 @@ class ScenarioIceConnection { virtual EmulatedEndpoint* endpoint() = 0; virtual const cricket::TransportDescription& transport_description() const = 0; + + webrtc::test::ScopedKeyValueConfig field_trials; }; } // namespace webrtc diff --git a/test/scoped_key_value_config.cc b/test/scoped_key_value_config.cc new file mode 100644 index 0000000000..fe3f42635d --- /dev/null +++ b/test/scoped_key_value_config.cc @@ -0,0 +1,116 @@ +/* + * 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 "api/webrtc_key_value_config.h" +#include "rtc_base/checks.h" +#include "test/field_trial.h" + +namespace { + +// This part is copied from system_wrappers/field_trial.cc. +void InsertIntoMap(std::map& key_value_map, + const std::string& 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(const std::string& s) + : ScopedKeyValueConfig(nullptr, s) {} + +ScopedKeyValueConfig::ScopedKeyValueConfig(ScopedKeyValueConfig& parent, + const std::string& s) + : ScopedKeyValueConfig(&parent, s) {} + +ScopedKeyValueConfig::ScopedKeyValueConfig(ScopedKeyValueConfig* parent, + const std::string& s) + : parent_(parent), leaf_(nullptr) { + InsertIntoMap(key_value_map_, s); + // 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::Lookup(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(std::string(key)); + if (it != key_value_map_.end()) + return it->second; + + if (parent_) { + return parent_->LookupRecurse(key); + } + + return ""; +} + +} // namespace test +} // namespace webrtc diff --git a/test/scoped_key_value_config.h b/test/scoped_key_value_config.h new file mode 100644 index 0000000000..a00f61ac60 --- /dev/null +++ b/test/scoped_key_value_config.h @@ -0,0 +1,52 @@ +/* + * 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 "absl/strings/string_view.h" +#include "api/webrtc_key_value_config.h" +#include "test/field_trial.h" + +namespace webrtc { +namespace test { + +class ScopedKeyValueConfig : public WebRtcKeyValueConfig { + public: + virtual ~ScopedKeyValueConfig(); + ScopedKeyValueConfig(); + explicit ScopedKeyValueConfig(const std::string& s); + ScopedKeyValueConfig(ScopedKeyValueConfig& parent, const std::string& s); + + std::string Lookup(absl::string_view key) const override; + + private: + ScopedKeyValueConfig(ScopedKeyValueConfig* parent, const std::string& s); + ScopedKeyValueConfig* GetRoot(ScopedKeyValueConfig* n); + 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_; + + 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/video/encoder_bitrate_adjuster.cc b/video/encoder_bitrate_adjuster.cc index 9f4d8551c4..8ed16a7565 100644 --- a/video/encoder_bitrate_adjuster.cc +++ b/video/encoder_bitrate_adjuster.cc @@ -17,7 +17,6 @@ #include "rtc_base/experiments/rate_control_settings.h" #include "rtc_base/logging.h" #include "rtc_base/time_utils.h" -#include "system_wrappers/include/field_trial.h" namespace webrtc { namespace { From a0a3f9c5785e9770256b3aa295b2f1440b780807 Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Tue, 8 Mar 2022 18:33:17 +0100 Subject: [PATCH 135/847] Delete legacy unused RtpStreamsSynchronizer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: None Change-Id: I499b8b81b86ea007f0e00bd7e71eeddc961ddc76 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254080 Auto-Submit: Danil Chapovalov Commit-Queue: Danil Chapovalov Reviewed-by: Erik Språng Commit-Queue: Erik Språng Cr-Commit-Position: refs/heads/main@{#36161} --- video/BUILD.gn | 2 - video/rtp_streams_synchronizer.cc | 208 ------------------------------ video/rtp_streams_synchronizer.h | 67 ---------- 3 files changed, 277 deletions(-) delete mode 100644 video/rtp_streams_synchronizer.cc delete mode 100644 video/rtp_streams_synchronizer.h diff --git a/video/BUILD.gn b/video/BUILD.gn index 8dcef1ae68..81d511e76c 100644 --- a/video/BUILD.gn +++ b/video/BUILD.gn @@ -157,8 +157,6 @@ rtc_source_set("video_legacy") { "call_stats.h", "receive_statistics_proxy.cc", "receive_statistics_proxy.h", - "rtp_streams_synchronizer.cc", - "rtp_streams_synchronizer.h", "rtp_video_stream_receiver.cc", "rtp_video_stream_receiver.h", "video_quality_observer.cc", diff --git a/video/rtp_streams_synchronizer.cc b/video/rtp_streams_synchronizer.cc deleted file mode 100644 index 29ace90431..0000000000 --- a/video/rtp_streams_synchronizer.cc +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "video/rtp_streams_synchronizer.h" - -#include "absl/types/optional.h" -#include "call/syncable.h" -#include "rtc_base/checks.h" -#include "rtc_base/logging.h" -#include "rtc_base/time_utils.h" -#include "rtc_base/trace_event.h" -#include "system_wrappers/include/rtp_to_ntp_estimator.h" - -namespace webrtc { -namespace { -// Time interval for logging stats. -constexpr int64_t kStatsLogIntervalMs = 10000; - -bool UpdateMeasurements(StreamSynchronization::Measurements* stream, - const Syncable::Info& info) { - RTC_DCHECK(stream); - stream->latest_timestamp = info.latest_received_capture_timestamp; - stream->latest_receive_time_ms = info.latest_receive_time_ms; - bool new_rtcp_sr = false; - if (!stream->rtp_to_ntp.UpdateMeasurements( - info.capture_time_ntp_secs, info.capture_time_ntp_frac, - info.capture_time_source_clock, &new_rtcp_sr)) { - return false; - } - return true; -} -} // namespace - -RtpStreamsSynchronizer::RtpStreamsSynchronizer(Syncable* syncable_video) - : syncable_video_(syncable_video), - syncable_audio_(nullptr), - sync_(), - last_sync_time_(rtc::TimeNanos()), - last_stats_log_ms_(rtc::TimeMillis()) { - RTC_DCHECK(syncable_video); - process_thread_checker_.Detach(); -} - -RtpStreamsSynchronizer::~RtpStreamsSynchronizer() = default; - -void RtpStreamsSynchronizer::ConfigureSync(Syncable* syncable_audio) { - MutexLock lock(&mutex_); - if (syncable_audio == syncable_audio_) { - // This prevents expensive no-ops. - return; - } - - syncable_audio_ = syncable_audio; - sync_.reset(nullptr); - if (syncable_audio_) { - sync_.reset(new StreamSynchronization(syncable_video_->id(), - syncable_audio_->id())); - } -} - -int64_t RtpStreamsSynchronizer::TimeUntilNextProcess() { - RTC_DCHECK_RUN_ON(&process_thread_checker_); - const int64_t kSyncIntervalMs = 1000; - return kSyncIntervalMs - - (rtc::TimeNanos() - last_sync_time_) / rtc::kNumNanosecsPerMillisec; -} - -void RtpStreamsSynchronizer::Process() { - RTC_DCHECK_RUN_ON(&process_thread_checker_); - last_sync_time_ = rtc::TimeNanos(); - - MutexLock lock(&mutex_); - if (!syncable_audio_) { - return; - } - RTC_DCHECK(sync_.get()); - - bool log_stats = false; - const int64_t now_ms = rtc::TimeMillis(); - if (now_ms - last_stats_log_ms_ > kStatsLogIntervalMs) { - last_stats_log_ms_ = now_ms; - log_stats = true; - } - - int64_t last_audio_receive_time_ms = - audio_measurement_.latest_receive_time_ms; - absl::optional audio_info = syncable_audio_->GetInfo(); - if (!audio_info || !UpdateMeasurements(&audio_measurement_, *audio_info)) { - return; - } - - if (last_audio_receive_time_ms == audio_measurement_.latest_receive_time_ms) { - // No new audio packet has been received since last update. - return; - } - - int64_t last_video_receive_ms = video_measurement_.latest_receive_time_ms; - absl::optional video_info = syncable_video_->GetInfo(); - if (!video_info || !UpdateMeasurements(&video_measurement_, *video_info)) { - return; - } - - if (last_video_receive_ms == video_measurement_.latest_receive_time_ms) { - // No new video packet has been received since last update. - return; - } - - int relative_delay_ms; - // Calculate how much later or earlier the audio stream is compared to video. - if (!sync_->ComputeRelativeDelay(audio_measurement_, video_measurement_, - &relative_delay_ms)) { - return; - } - - if (log_stats) { - RTC_LOG(LS_INFO) << "Sync info stats: " << now_ms - << ", {ssrc: " << sync_->audio_stream_id() << ", " - << "cur_delay_ms: " << audio_info->current_delay_ms - << "} {ssrc: " << sync_->video_stream_id() << ", " - << "cur_delay_ms: " << video_info->current_delay_ms - << "} {relative_delay_ms: " << relative_delay_ms << "} "; - } - - TRACE_COUNTER1("webrtc", "SyncCurrentVideoDelay", - video_info->current_delay_ms); - TRACE_COUNTER1("webrtc", "SyncCurrentAudioDelay", - audio_info->current_delay_ms); - TRACE_COUNTER1("webrtc", "SyncRelativeDelay", relative_delay_ms); - - int target_audio_delay_ms = 0; - int target_video_delay_ms = video_info->current_delay_ms; - // Calculate the necessary extra audio delay and desired total video - // delay to get the streams in sync. - if (!sync_->ComputeDelays(relative_delay_ms, audio_info->current_delay_ms, - &target_audio_delay_ms, &target_video_delay_ms)) { - return; - } - - if (log_stats) { - RTC_LOG(LS_INFO) << "Sync delay stats: " << now_ms - << ", {ssrc: " << sync_->audio_stream_id() << ", " - << "target_delay_ms: " << target_audio_delay_ms - << "} {ssrc: " << sync_->video_stream_id() << ", " - << "target_delay_ms: " << target_video_delay_ms << "} "; - } - - syncable_audio_->SetMinimumPlayoutDelay(target_audio_delay_ms); - syncable_video_->SetMinimumPlayoutDelay(target_video_delay_ms); -} - -// TODO(https://bugs.webrtc.org/7065): Move RtpToNtpEstimator out of -// RtpStreamsSynchronizer and into respective receive stream to always populate -// the estimated playout timestamp. -bool RtpStreamsSynchronizer::GetStreamSyncOffsetInMs( - uint32_t rtp_timestamp, - int64_t render_time_ms, - int64_t* video_playout_ntp_ms, - int64_t* stream_offset_ms, - double* estimated_freq_khz) const { - MutexLock lock(&mutex_); - if (!syncable_audio_) { - return false; - } - - uint32_t audio_rtp_timestamp; - int64_t time_ms; - if (!syncable_audio_->GetPlayoutRtpTimestamp(&audio_rtp_timestamp, - &time_ms)) { - return false; - } - - int64_t latest_audio_ntp; - if (!audio_measurement_.rtp_to_ntp.Estimate(audio_rtp_timestamp, - &latest_audio_ntp)) { - return false; - } - - syncable_audio_->SetEstimatedPlayoutNtpTimestampMs(latest_audio_ntp, time_ms); - - int64_t latest_video_ntp; - if (!video_measurement_.rtp_to_ntp.Estimate(rtp_timestamp, - &latest_video_ntp)) { - return false; - } - - // Current audio ntp. - int64_t now_ms = rtc::TimeMillis(); - latest_audio_ntp += (now_ms - time_ms); - - // Remove video playout delay. - int64_t time_to_render_ms = render_time_ms - now_ms; - if (time_to_render_ms > 0) - latest_video_ntp -= time_to_render_ms; - - *video_playout_ntp_ms = latest_video_ntp; - *stream_offset_ms = latest_audio_ntp - latest_video_ntp; - *estimated_freq_khz = video_measurement_.rtp_to_ntp.params()->frequency_khz; - return true; -} - -} // namespace webrtc diff --git a/video/rtp_streams_synchronizer.h b/video/rtp_streams_synchronizer.h deleted file mode 100644 index b759ad1789..0000000000 --- a/video/rtp_streams_synchronizer.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// RtpStreamsSynchronizer is responsible for synchronizing audio and video for -// a given audio receive stream and video receive stream. - -#ifndef VIDEO_RTP_STREAMS_SYNCHRONIZER_H_ -#define VIDEO_RTP_STREAMS_SYNCHRONIZER_H_ - -#include - -#include "api/sequence_checker.h" -#include "modules/include/module.h" -#include "rtc_base/synchronization/mutex.h" -#include "video/stream_synchronization.h" - -namespace webrtc { - -class Syncable; - -// DEPRECATED. -class RtpStreamsSynchronizer : public Module { - public: - explicit RtpStreamsSynchronizer(Syncable* syncable_video); - ~RtpStreamsSynchronizer() override; - - void ConfigureSync(Syncable* syncable_audio); - - // Implements Module. - int64_t TimeUntilNextProcess() override; - void Process() override; - - // Gets the estimated playout NTP timestamp for the video frame with - // `rtp_timestamp` and the sync offset between the current played out audio - // frame and the video frame. Returns true on success, false otherwise. - // The `estimated_freq_khz` is the frequency used in the RTP to NTP timestamp - // conversion. - bool GetStreamSyncOffsetInMs(uint32_t rtp_timestamp, - int64_t render_time_ms, - int64_t* video_playout_ntp_ms, - int64_t* stream_offset_ms, - double* estimated_freq_khz) const; - - private: - Syncable* syncable_video_; - - mutable Mutex mutex_; - Syncable* syncable_audio_ RTC_GUARDED_BY(mutex_); - std::unique_ptr sync_ RTC_GUARDED_BY(mutex_); - StreamSynchronization::Measurements audio_measurement_ RTC_GUARDED_BY(mutex_); - StreamSynchronization::Measurements video_measurement_ RTC_GUARDED_BY(mutex_); - - SequenceChecker process_thread_checker_; - int64_t last_sync_time_ RTC_GUARDED_BY(&process_thread_checker_); - int64_t last_stats_log_ms_ RTC_GUARDED_BY(&process_thread_checker_); -}; - -} // namespace webrtc - -#endif // VIDEO_RTP_STREAMS_SYNCHRONIZER_H_ From 878c0299b3906155215712fc9646d85e355df525 Mon Sep 17 00:00:00 2001 From: Philipp Hancke Date: Wed, 9 Mar 2022 10:00:15 +0100 Subject: [PATCH 136/847] flexfec: increase verbosity of logging - add recovered sequence number and length of the recovered packet - increase level of periodic logging to LS_INFO - log for every packet on LS_VERBOSE This makes it easier to validate and debug flexfec implementations. BUG=None Change-Id: I6f9e73e72ec3dcc0531f7adc62ac7019c7899270 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254120 Reviewed-by: Harald Alvestrand Commit-Queue: Philipp Hancke Cr-Commit-Position: refs/heads/main@{#36162} --- modules/rtp_rtcp/source/flexfec_receiver.cc | 26 ++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/modules/rtp_rtcp/source/flexfec_receiver.cc b/modules/rtp_rtcp/source/flexfec_receiver.cc index e01b9205cf..b5198b53a6 100644 --- a/modules/rtp_rtcp/source/flexfec_receiver.cc +++ b/modules/rtp_rtcp/source/flexfec_receiver.cc @@ -159,18 +159,28 @@ void FlexfecReceiver::ProcessReceivedPacket( // Set this flag first, since OnRecoveredPacket may end up here // again, with the same packet. recovered_packet->returned = true; - RTC_CHECK_GT(recovered_packet->pkt->data.size(), 0); + RTC_CHECK_GE(recovered_packet->pkt->data.size(), kRtpHeaderSize); recovered_packet_receiver_->OnRecoveredPacket( recovered_packet->pkt->data.cdata(), recovered_packet->pkt->data.size()); - // Periodically log the incoming packets. + uint32_t media_ssrc = + ForwardErrorCorrection::ParseSsrc(recovered_packet->pkt->data.data()); + uint16_t media_seq_num = ForwardErrorCorrection::ParseSequenceNumber( + recovered_packet->pkt->data.data()); + // Periodically log the incoming packets at LS_INFO. int64_t now_ms = clock_->TimeInMilliseconds(); - if (now_ms - last_recovered_packet_ms_ > kPacketLogIntervalMs) { - uint32_t media_ssrc = - ForwardErrorCorrection::ParseSsrc(recovered_packet->pkt->data.data()); - RTC_LOG(LS_VERBOSE) << "Recovered media packet with SSRC: " << media_ssrc - << " from FlexFEC stream with SSRC: " << ssrc_ << "."; - last_recovered_packet_ms_ = now_ms; + bool should_log_periodically = + now_ms - last_recovered_packet_ms_ > kPacketLogIntervalMs; + if (RTC_LOG_CHECK_LEVEL(LS_VERBOSE) || should_log_periodically) { + rtc::LoggingSeverity level = + should_log_periodically ? rtc::LS_INFO : rtc::LS_VERBOSE; + RTC_LOG_V(level) << "Recovered media packet with SSRC: " << media_ssrc + << " seq " << media_seq_num << " recovered length " + << recovered_packet->pkt->data.size() + << " from FlexFEC stream with SSRC: " << ssrc_; + if (should_log_periodically) { + last_recovered_packet_ms_ = now_ms; + } } } } From a5f3018c24dd809ea9fbdba48b585bc2eb95425f Mon Sep 17 00:00:00 2001 From: Austin Orion Date: Tue, 8 Mar 2022 15:47:17 -0800 Subject: [PATCH 137/847] [DesktopCapture][WGC] Avoid artifacts when capture source is resized This CL fixes the issue where artifacts appear during capture with WGC when the capture source is resized. A video of the issue is available here: https://bugs.chromium.org/p/webrtc/issues/detail?id=9273#c44 The solution is to use CopySubresourceRegion instead of CopyResource to only copy valid data into our texture. Additionally, we moved the call to CreateMappedTexture to before the call to CopySubresourceRegion, as the latter requires both textures to be of the same size. Bug: webrtc:9273 Change-Id: I114458d95cbf58550ff653a985dd84db4741e0f8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254100 Reviewed-by: Alexander Cooper Commit-Queue: Austin Orion Cr-Commit-Position: refs/heads/main@{#36163} --- .../win/wgc_capture_session.cc | 81 +++++++++++-------- 1 file changed, 47 insertions(+), 34 deletions(-) diff --git a/modules/desktop_capture/win/wgc_capture_session.cc b/modules/desktop_capture/win/wgc_capture_session.cc index 09c336fdc5..b6b566b3ee 100644 --- a/modules/desktop_capture/win/wgc_capture_session.cc +++ b/modules/desktop_capture/win/wgc_capture_session.cc @@ -223,8 +223,8 @@ HRESULT WgcCaptureSession::GetFrame( return hr; } - // We need to get this CaptureFrame as an ID3D11Texture2D so that we can get - // the raw image data in the format required by the DesktopFrame interface. + // We need to get `capture_frame` as an `ID3D11Texture2D` so that we can get + // the raw image data in the format required by the `DesktopFrame` interface. ComPtr d3d_surface; hr = capture_frame->get_Surface(&d3d_surface); @@ -261,16 +261,6 @@ HRESULT WgcCaptureSession::GetFrame( // Otherwise it would only be readable by the GPU. ComPtr d3d_context; d3d11_device_->GetImmediateContext(&d3d_context); - d3d_context->CopyResource(mapped_texture_.Get(), texture_2D.Get()); - - D3D11_MAPPED_SUBRESOURCE map_info; - hr = d3d_context->Map(mapped_texture_.Get(), /*subresource_index=*/0, - D3D11_MAP_READ, /*D3D11_MAP_FLAG_DO_NOT_WAIT=*/0, - &map_info); - if (FAILED(hr)) { - RecordGetFrameResult(GetFrameResult::kMapFrameFailed); - return hr; - } ABI::Windows::Graphics::SizeInt32 new_size; hr = capture_frame->get_ContentSize(&new_size); @@ -279,11 +269,53 @@ HRESULT WgcCaptureSession::GetFrame( return hr; } + // If the size changed, we must resize `mapped_texture_` and `frame_pool_` to + // fit the new size. This must be done before `CopySubresourceRegion` so that + // the textures are the same size. + if (previous_size_.Height != new_size.Height || + previous_size_.Width != new_size.Width) { + hr = CreateMappedTexture(texture_2D, new_size.Width, new_size.Height); + if (FAILED(hr)) { + RecordGetFrameResult(GetFrameResult::kResizeMappedTextureFailed); + return hr; + } + + hr = frame_pool_->Recreate(direct3d_device_.Get(), kPixelFormat, + kNumBuffers, new_size); + if (FAILED(hr)) { + RecordGetFrameResult(GetFrameResult::kRecreateFramePoolFailed); + return hr; + } + } + // If the size has changed since the last capture, we must be sure to use // the smaller dimensions. Otherwise we might overrun our buffer, or // read stale data from the last frame. int image_height = std::min(previous_size_.Height, new_size.Height); int image_width = std::min(previous_size_.Width, new_size.Width); + + D3D11_BOX copy_region; + copy_region.left = 0; + copy_region.top = 0; + copy_region.right = image_width; + copy_region.bottom = image_height; + // Our textures are 2D so we just want one "slice" of the box. + copy_region.front = 0; + copy_region.back = 1; + d3d_context->CopySubresourceRegion(mapped_texture_.Get(), + /*dst_subresource_index=*/0, /*dst_x=*/0, + /*dst_y=*/0, /*dst_z=*/0, texture_2D.Get(), + /*src_subresource_index=*/0, ©_region); + + D3D11_MAPPED_SUBRESOURCE map_info; + hr = d3d_context->Map(mapped_texture_.Get(), /*subresource_index=*/0, + D3D11_MAP_READ, /*D3D11_MAP_FLAG_DO_NOT_WAIT=*/0, + &map_info); + if (FAILED(hr)) { + RecordGetFrameResult(GetFrameResult::kMapFrameFailed); + return hr; + } + int row_data_length = image_width * DesktopFrame::kBytesPerPixel; // Make a copy of the data pointed to by `map_info.pData` so we are free to @@ -298,34 +330,15 @@ HRESULT WgcCaptureSession::GetFrame( src_data += map_info.RowPitch; } + d3d_context->Unmap(mapped_texture_.Get(), 0); + // Transfer ownership of `image_data` to the output_frame. DesktopSize size(image_width, image_height); *output_frame = std::make_unique(size, row_data_length, std::move(image_data)); - d3d_context->Unmap(mapped_texture_.Get(), 0); - - // If the size changed, we must resize the texture and frame pool to fit the - // new size. - if (previous_size_.Height != new_size.Height || - previous_size_.Width != new_size.Width) { - hr = CreateMappedTexture(texture_2D, new_size.Width, new_size.Height); - if (FAILED(hr)) { - RecordGetFrameResult(GetFrameResult::kResizeMappedTextureFailed); - return hr; - } - - hr = frame_pool_->Recreate(direct3d_device_.Get(), kPixelFormat, - kNumBuffers, new_size); - if (FAILED(hr)) { - RecordGetFrameResult(GetFrameResult::kRecreateFramePoolFailed); - return hr; - } - } - - RecordGetFrameResult(GetFrameResult::kSuccess); - previous_size_ = new_size; + RecordGetFrameResult(GetFrameResult::kSuccess); return hr; } From fdaa77cd218a5190a7a0e42107d002e55f46a5e2 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Wed, 9 Mar 2022 10:04:03 -0800 Subject: [PATCH 138/847] Roll chromium_revision 506c2577bc..330454c702 (977835:979310) Change log: https://chromium.googlesource.com/chromium/src/+log/506c2577bc..330454c702 Full diff: https://chromium.googlesource.com/chromium/src/+/506c2577bc..330454c702 Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/bcd37851f4..86b036f2ce * src/build: https://chromium.googlesource.com/chromium/src/build/+log/bba692af19..6d6a1eaf7a * src/buildtools/third_party/libc++abi/trunk: https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git/+log/738dc100c6..4d411388aa * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/cabf0cba2c..f02733c9d4 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/b5ba3855c4..f596ce142c * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/ad0b57e097..a4ba4d030a * src/third_party/android_deps/libs/android_arch_core_common: version:2@1.1.1.cr0..version:2@1.1.1.cr1 * src/third_party/android_deps/libs/android_arch_core_runtime: version:2@1.1.1.cr0..version:2@1.1.1.cr1 * src/third_party/android_deps/libs/android_arch_lifecycle_common: version:2@1.1.1.cr0..version:2@1.1.1.cr1 * src/third_party/android_deps/libs/android_arch_lifecycle_common_java8: version:2@1.1.1.cr0..version:2@1.1.1.cr1 * src/third_party/android_deps/libs/android_arch_lifecycle_livedata: version:2@1.1.1.cr0..version:2@1.1.1.cr1 * src/third_party/android_deps/libs/android_arch_lifecycle_livedata_core: version:2@1.1.1.cr0..version:2@1.1.1.cr1 * src/third_party/android_deps/libs/android_arch_lifecycle_runtime: version:2@1.1.1.cr0..version:2@1.1.1.cr1 * src/third_party/android_deps/libs/android_arch_lifecycle_viewmodel: version:2@1.1.1.cr0..version:2@1.1.1.cr1 * src/third_party/android_deps/libs/com_android_support_animated_vector_drawable: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_appcompat_v7: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_asynclayoutinflater: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_cardview_v7: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_collections: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_coordinatorlayout: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_cursoradapter: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_customview: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_design: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_documentfile: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_drawerlayout: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_interpolator: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_loader: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_localbroadcastmanager: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_multidex: version:2@1.0.0.cr0..version:2@1.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_print: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_recyclerview_v7: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_slidingpanelayout: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_support_annotations: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_support_compat: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_support_core_ui: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_support_core_utils: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_support_fragment: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_support_media_compat: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_support_v4: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_support_vector_drawable: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_swiperefreshlayout: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_transition: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_versionedparcelable: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_support_viewpager: version:2@28.0.0.cr0..version:2@28.0.0.cr1 * src/third_party/android_deps/libs/com_android_tools_common: version:2@30.2.0-beta01.cr0..version:2@30.2.0-beta01.cr1 * src/third_party/android_deps/libs/com_android_tools_layoutlib_layoutlib_api: version:2@30.2.0-beta01.cr0..version:2@30.2.0-beta01.cr1 * src/third_party/android_deps/libs/com_android_tools_sdk_common: version:2@30.2.0-beta01.cr0..version:2@30.2.0-beta01.cr1 * src/third_party/android_deps/libs/com_github_ben_manes_caffeine_caffeine: version:2@2.8.8.cr0..version:2@2.8.8.cr1 * src/third_party/android_deps/libs/com_github_kevinstern_software_and_algorithms: version:2@1.0.cr0..version:2@1.0.cr1 * src/third_party/android_deps/libs/com_google_android_datatransport_transport_api: version:2@2.2.1.cr0..version:2@2.2.1.cr1 * src/third_party/android_deps/libs/com_google_android_gms_play_services_auth: version:2@17.0.0.cr0..version:2@17.0.0.cr1 * src/third_party/android_deps/libs/com_google_android_gms_play_services_auth_api_phone: version:2@17.5.0.cr0..version:2@17.5.0.cr1 * src/third_party/android_deps/libs/com_google_android_gms_play_services_auth_base: version:2@17.0.0.cr0..version:2@17.0.0.cr1 * src/third_party/android_deps/libs/com_google_android_gms_play_services_base: version:2@17.5.0.cr0..version:2@17.5.0.cr1 * src/third_party/android_deps/libs/com_google_android_gms_play_services_basement: version:2@17.5.0.cr0..version:2@17.5.0.cr1 * src/third_party/android_deps/libs/com_google_android_gms_play_services_cast: version:2@17.0.0.cr0..version:2@17.0.0.cr1 * src/third_party/android_deps/libs/com_google_android_gms_play_services_cast_framework: version:2@17.0.0.cr0..version:2@17.0.0.cr1 * src/third_party/android_deps/libs/com_google_android_gms_play_services_clearcut: version:2@17.0.0.cr0..version:2@17.0.0.cr1 * src/third_party/android_deps/libs/com_google_android_gms_play_services_cloud_messaging: version:2@16.0.0.cr0..version:2@16.0.0.cr1 * src/third_party/android_deps/libs/com_google_android_gms_play_services_fido: version:2@19.0.0-beta.cr0..version:2@19.0.0-beta.cr1 * src/third_party/android_deps/libs/com_google_android_gms_play_services_flags: version:2@17.0.0.cr0..version:2@17.0.0.cr1 * src/third_party/android_deps/libs/com_google_android_gms_play_services_gcm: version:2@17.0.0.cr0..version:2@17.0.0.cr1 * src/third_party/android_deps/libs/com_google_android_gms_play_services_iid: version:2@17.0.0.cr0..version:2@17.0.0.cr1 * src/third_party/android_deps/libs/com_google_android_gms_play_services_instantapps: version:2@17.0.0.cr0..version:2@17.0.0.cr1 * src/third_party/android_deps/libs/com_google_android_gms_play_services_location: version:2@17.0.0.cr0..version:2@17.0.0.cr1 * src/third_party/android_deps/libs/com_google_android_gms_play_services_phenotype: version:2@17.0.0.cr0..version:2@17.0.0.cr1 * src/third_party/android_deps/libs/com_google_android_gms_play_services_places_placereport: version:2@17.0.0.cr0..version:2@17.0.0.cr1 * src/third_party/android_deps/libs/com_google_android_gms_play_services_stats: version:2@17.0.0.cr0..version:2@17.0.0.cr1 * src/third_party/android_deps/libs/com_google_android_gms_play_services_tasks: version:2@17.2.0.cr0..version:2@17.2.0.cr1 * src/third_party/android_deps/libs/com_google_android_gms_play_services_vision: version:2@18.0.0.cr0..version:2@18.0.0.cr1 * src/third_party/android_deps/libs/com_google_android_gms_play_services_vision_common: version:2@18.0.0.cr0..version:2@18.0.0.cr1 * src/third_party/android_deps/libs/com_google_android_material_material: version:2@1.6.0-alpha01.cr0..version:2@1.6.0-alpha01.cr1 * src/third_party/android_deps/libs/com_google_android_play_core: version:2@1.10.0.cr0..version:2@1.10.0.cr1 * src/third_party/android_deps/libs/com_google_auto_auto_common: version:2@1.1.2.cr0..version:2@1.2.1.cr1 * src/third_party/android_deps/libs/com_google_auto_service_auto_service: version:2@1.0-rc6.cr0..version:2@1.0-rc6.cr1 * src/third_party/android_deps/libs/com_google_auto_service_auto_service_annotations: version:2@1.0-rc6.cr0..version:2@1.0-rc6.cr1 * src/third_party/android_deps/libs/com_google_auto_value_auto_value_annotations: version:2@1.7.4.cr0..version:2@1.9.cr1 * src/third_party/android_deps/libs/com_google_code_findbugs_jsr305: version:2@3.0.2.cr0..version:2@3.0.2.cr1 * src/third_party/android_deps/libs/com_google_code_gson_gson: version:2@2.8.0.cr0..version:2@2.8.0.cr1 * src/third_party/android_deps/libs/com_google_dagger_dagger: version:2@2.30.cr0..version:2@2.30.cr1 * src/third_party/android_deps/libs/com_google_dagger_dagger_compiler: version:2@2.30.cr0..version:2@2.30.cr1 * src/third_party/android_deps/libs/com_google_dagger_dagger_producers: version:2@2.30.cr0..version:2@2.30.cr1 * src/third_party/android_deps/libs/com_google_dagger_dagger_spi: version:2@2.30.cr0..version:2@2.30.cr1 * src/third_party/android_deps/libs/com_google_errorprone_error_prone_annotation: version:2@2.10.0.cr0..version:2@2.11.0.cr1 * src/third_party/android_deps/libs/com_google_errorprone_error_prone_annotations: version:2@2.9.0.cr0..version:2@2.11.0.cr1 * src/third_party/android_deps/libs/com_google_errorprone_error_prone_check_api: version:2@2.10.0.cr0..version:2@2.11.0.cr1 * src/third_party/android_deps/libs/com_google_errorprone_error_prone_core: version:2@2.10.0.cr0..version:2@2.11.0.cr1 * src/third_party/android_deps/libs/com_google_errorprone_error_prone_type_annotations: version:2@2.10.0.cr0..version:2@2.11.0.cr1 * src/third_party/android_deps/libs/com_google_errorprone_javac: version:2@9+181-r4173-1.cr0..version:2@9+181-r4173-1.cr1 * src/third_party/android_deps/libs/com_google_errorprone_javac_shaded: version:2@9-dev-r4023-3.cr0..version:2@9-dev-r4023-3.cr1 * src/third_party/android_deps/libs/com_google_firebase_firebase_annotations: version:2@16.0.0.cr0..version:2@16.0.0.cr1 * src/third_party/android_deps/libs/com_google_firebase_firebase_common: version:2@19.5.0.cr0..version:2@19.5.0.cr1 * src/third_party/android_deps/libs/com_google_firebase_firebase_components: version:2@16.1.0.cr0..version:2@16.1.0.cr1 * src/third_party/android_deps/libs/com_google_firebase_firebase_encoders: version:2@16.1.0.cr0..version:2@16.1.0.cr1 * src/third_party/android_deps/libs/com_google_firebase_firebase_encoders_json: version:2@17.1.0.cr0..version:2@17.1.0.cr1 * src/third_party/android_deps/libs/com_google_firebase_firebase_iid: version:2@21.0.1.cr0..version:2@21.0.1.cr1 * src/third_party/android_deps/libs/com_google_firebase_firebase_iid_interop: version:2@17.0.0.cr0..version:2@17.0.0.cr1 * src/third_party/android_deps/libs/com_google_firebase_firebase_installations: version:2@16.3.5.cr0..version:2@16.3.5.cr1 * src/third_party/android_deps/libs/com_google_firebase_firebase_installations_interop: version:2@16.0.1.cr0..version:2@16.0.1.cr1 * src/third_party/android_deps/libs/com_google_firebase_firebase_measurement_connector: version:2@18.0.0.cr0..version:2@18.0.0.cr1 * src/third_party/android_deps/libs/com_google_firebase_firebase_messaging: version:2@21.0.1.cr0..version:2@21.0.1.cr1 * src/third_party/android_deps/libs/com_google_flatbuffers_flatbuffers_java: version:2@2.0.3.cr0..version:2@2.0.3.cr1 * src/third_party/android_deps/libs/com_google_googlejavaformat_google_java_format: version:2@1.5.cr0..version:2@1.5.cr1 * src/third_party/android_deps/libs/com_google_guava_failureaccess: version:2@1.0.1.cr0..version:2@1.0.1.cr1 * src/third_party/android_deps/libs/com_google_guava_guava: version:2@31.0-jre.cr0..version:2@31.0.1-jre.cr1 * src/third_party/android_deps/libs/com_google_guava_guava_android: version:2@31.0-android.cr0..version:2@31.0-android.cr1 * src/third_party/android_deps/libs/com_google_guava_listenablefuture: version:2@1.0.cr0..version:2@1.0.cr1 * src/third_party/android_deps/libs/com_google_j2objc_j2objc_annotations: version:2@1.3.cr0..version:2@1.3.cr1 * src/third_party/android_deps/libs/com_google_protobuf_protobuf_java: version:2@3.4.0.cr0..version:2@3.19.2.cr1 * src/third_party/android_deps/libs/com_google_protobuf_protobuf_javalite: version:2@3.19.3.cr0..version:2@3.19.3.cr1 * src/third_party/android_deps/libs/com_googlecode_java_diff_utils_diffutils: version:2@1.3.0.cr0..version:2@1.3.0.cr1 * src/third_party/android_deps/libs/com_squareup_javapoet: version:2@1.13.0.cr0..version:2@1.13.0.cr1 * src/third_party/android_deps/libs/com_squareup_javawriter: version:2@2.1.1.cr0..version:2@2.1.1.cr1 * src/third_party/android_deps/libs/io_github_java_diff_utils_java_diff_utils: version:2@4.0.cr0..version:2@4.0.cr1 * src/third_party/android_deps/libs/javax_annotation_javax_annotation_api: version:2@1.3.2.cr0..version:2@1.3.2.cr1 * src/third_party/android_deps/libs/javax_annotation_jsr250_api: version:2@1.0.cr0..version:2@1.0.cr1 * src/third_party/android_deps/libs/javax_inject_javax_inject: version:2@1.cr0..version:2@1.cr1 * src/third_party/android_deps/libs/net_ltgt_gradle_incap_incap: version:2@0.2.cr0..version:2@0.2.cr1 * src/third_party/android_deps/libs/net_sf_kxml_kxml2: version:2@2.3.0.cr0..version:2@2.3.0.cr1 * src/third_party/android_deps/libs/org_ccil_cowan_tagsoup_tagsoup: version:2@1.2.1.cr0..version:2@1.2.1.cr1 * src/third_party/android_deps/libs/org_checkerframework_checker_compat_qual: version:2@2.5.5.cr0..version:2@2.5.5.cr1 * src/third_party/android_deps/libs/org_checkerframework_checker_qual: version:2@3.12.0.cr0..version:2@3.12.0.cr1 * src/third_party/android_deps/libs/org_checkerframework_dataflow_errorprone: version:2@3.15.0.cr0..version:2@3.15.0.cr1 * src/third_party/android_deps/libs/org_codehaus_mojo_animal_sniffer_annotations: version:2@1.17.cr0..version:2@1.17.cr1 * src/third_party/android_deps/libs/org_eclipse_jgit_org_eclipse_jgit: version:2@4.4.1.201607150455-r.cr0..version:2@4.4.1.201607150455-r.cr1 * src/third_party/android_deps/libs/org_jetbrains_annotations: version:2@13.0.cr0..version:2@13.0.cr1 * src/third_party/android_deps/libs/org_jetbrains_kotlin_kotlin_stdlib: version:2@1.6.10.cr0..version:2@1.6.10.cr1 * src/third_party/android_deps/libs/org_jetbrains_kotlin_kotlin_stdlib_common: version:2@1.6.10.cr0..version:2@1.6.10.cr1 * src/third_party/android_deps/libs/org_jetbrains_kotlin_kotlin_stdlib_jdk7: version:2@1.5.0.cr0..version:2@1.5.0.cr1 * src/third_party/android_deps/libs/org_jetbrains_kotlin_kotlin_stdlib_jdk8: version:2@1.5.0.cr0..version:2@1.5.0.cr1 * src/third_party/android_deps/libs/org_jetbrains_kotlinx_kotlinx_coroutines_android: version:2@1.5.0.cr0..version:2@1.5.0.cr1 * src/third_party/android_deps/libs/org_jetbrains_kotlinx_kotlinx_coroutines_core_jvm: version:2@1.5.0.cr0..version:2@1.5.0.cr1 * src/third_party/android_deps/libs/org_jetbrains_kotlinx_kotlinx_metadata_jvm: version:2@0.1.0.cr0..version:2@0.1.0.cr1 * src/third_party/android_deps/libs/org_pcollections_pcollections: version:2@2.1.2.cr0..version:2@3.1.4.cr1 * src/third_party/android_deps/libs/org_robolectric_nativeruntime: version:2@4.7.3.cr0..version:2@4.7.3.cr1 * src/third_party/androidx: F8k604AvABforYzuHHVPAKR63JI50fyxFmcXAgoRluEC..3VkiRTe5qdPdzmIzC63lc6LJPSEUMNjCHwQM4OBH_pgC * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/e87767edb2..5b79b29052 * src/third_party/dav1d/libdav1d: https://chromium.googlesource.com/external/github.com/videolan/dav1d.git/+log/3262e3d0c8..493ffb12f7 * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/ca3aae0014..8edc960e9a * src/third_party/freetype/src: https://chromium.googlesource.com/chromium/src/third_party/freetype2.git/+log/335224beee..1e2eb65048 * src/third_party/googletest/src: https://chromium.googlesource.com/external/github.com/google/googletest.git/+log/c9461a9b55..ae1b7ad430 * src/third_party/libjpeg_turbo: https://chromium.googlesource.com/chromium/deps/libjpeg_turbo.git/+log/02959c3ee1..22f1a22c99 * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/1badc020b3..6eb2732376 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/c65b31ce64..63cb382ead Removed dependency * src/third_party/android_deps/libs/com_google_code_findbugs_jformatstring DEPS diff: https://chromium.googlesource.com/chromium/src/+/506c2577bc..330454c702/DEPS Clang version changed llvmorg-15-init-1995-g5bec1ea7:llvmorg-15-init-3540-g85c53c70 Details: https://chromium.googlesource.com/chromium/src/+/506c2577bc..330454c702/tools/clang/scripts/update.py BUG=None Change-Id: Ib9c61f72c0a858f92620815af00614d02ddb5403 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254360 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36164} --- DEPS | 301 ++++++++++++++++++++++++++++------------------------------- 1 file changed, 145 insertions(+), 156 deletions(-) diff --git a/DEPS b/DEPS index d1d476a68f..0870f67788 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': '506c2577bc5967f3ce93b3ee84fd3baea04f206e', + 'chromium_revision': '330454c702f9e43b585625a0d9974087d135a739', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@bcd37851f49b509310bd078a547dbd68167cff5e', + 'https://chromium.googlesource.com/chromium/src/base@86b036f2ce633df9cd8b01934a9d332c41b0b23a', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@bba692af19c293ffd1f7c1764d30ccd424d79f8d', + 'https://chromium.googlesource.com/chromium/src/build@6d6a1eaf7aedcd420a33e9dbb88d4d8ad8574093', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@113dd1badbcbffea108a8c95ac7c89c22bfd25f3', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@cabf0cba2c6ef3436c901a8a5c8cbd7dd4930de5', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@f02733c9d4d4095fda307d1fc87dbb72b0ee83f7', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@b5ba3855c471aee0a4a61fb284dfa7a607cc5dd4', + 'https://chromium.googlesource.com/chromium/src/testing@f596ce142c4db1f6b860a28f214f24384bab700b', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@ad0b57e097c03ca324d0bccded62fa087cc17275', + 'https://chromium.googlesource.com/chromium/src/third_party@a4ba4d030afa7c02d103682927829bb1ce352d30', 'src/buildtools/linux64': { 'packages': [ @@ -78,7 +78,7 @@ deps = { 'src/buildtools/third_party/libc++/trunk': 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxx.git@79a2e924d96e2fc1e4b937c42efd08898fa472d7', 'src/buildtools/third_party/libc++abi/trunk': - 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git@738dc100c61890744f9e78cac27c71d0a2190781', + 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git@4d411388aacc2b7d0072aaacb80cb736d75ad51e', 'src/buildtools/third_party/libunwind/trunk': 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git@d1c7f92b8b0bff8d9f710ca40e44563a63db376e', @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@e87767edb21947a28ae24105709c32ad628e1345', + 'https://chromium.googlesource.com/catapult.git@5b79b290529ea30ab66a47ef758ecf2ef8825d66', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@ca3aae0014011dad4c60ed0a39defa00d0189114', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@8edc960e9acbaedbff28e323e77a4129817266b3', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -162,7 +162,7 @@ deps = { 'condition': 'checkout_linux', }, 'src/third_party/freetype/src': - 'https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@335224beee2e72caab4ae56b76d6eb72001c3753', + 'https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@1e2eb65048f75c64b68708efed6ce904c31f3b2f', 'src/third_party/harfbuzz-ng/src': 'https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git@0acf466c44143de2e9b9cc0375cb25ec67cb132f', 'src/third_party/google_benchmark/src': { @@ -182,7 +182,7 @@ deps = { 'dep_type': 'cipd', }, 'src/third_party/googletest/src': - 'https://chromium.googlesource.com/external/github.com/google/googletest.git@c9461a9b55ba954df0489bab6420eb297bed846b', + 'https://chromium.googlesource.com/external/github.com/google/googletest.git@ae1b7ad4308249bfa928e65d1a33be117fc0992c', 'src/third_party/icu': { 'url': 'https://chromium.googlesource.com/chromium/deps/icu.git@1fa4e3959ec6637182b7318ac1d382799454806d', }, @@ -216,11 +216,11 @@ deps = { 'src/third_party/libFuzzer/src': 'https://chromium.googlesource.com/chromium/llvm-project/compiler-rt/lib/fuzzer.git@debe7d2d1982e540fbd6bd78604bf001753f9e74', 'src/third_party/libjpeg_turbo': - 'https://chromium.googlesource.com/chromium/deps/libjpeg_turbo.git@02959c3ee17abacfd1339ec22ea93301292ffd56', + 'https://chromium.googlesource.com/chromium/deps/libjpeg_turbo.git@22f1a22c99e9dde8cd3c72ead333f425c5a7aa77', 'src/third_party/libsrtp': 'https://chromium.googlesource.com/chromium/deps/libsrtp.git@5b7c744eb8310250ccc534f3f86a2015b3887a0a', 'src/third_party/dav1d/libdav1d': - 'https://chromium.googlesource.com/external/github.com/videolan/dav1d.git@3262e3d0c89c83389e5bec32d7d81564077e2687', + 'https://chromium.googlesource.com/external/github.com/videolan/dav1d.git@493ffb12f77df791f7dcde991b92d64bf873fefd', 'src/third_party/libaom/source/libaom': 'https://aomedia.googlesource.com/aom.git@a08d3f6c329a25744712578a70715e5cfd749759', 'src/third_party/libunwindstack': { @@ -228,7 +228,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@1badc020b35ebe45f738c1ddb21e79bb87e56273', + 'https://android.googlesource.com/platform/external/perfetto.git@6eb273237653c5c8d417fd1b556c6d361eb6a79d', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@c65b31ce646ed2ff478ba42b4dcafb90466f53f8', + 'https://chromium.googlesource.com/chromium/src/tools@63cb382ead5cd71516bc9c210f9854becacfab6c', 'src/third_party/accessibility_test_framework': { 'packages': [ @@ -384,7 +384,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/androidx', - 'version': 'F8k604AvABforYzuHHVPAKR63JI50fyxFmcXAgoRluEC', + 'version': '3VkiRTe5qdPdzmIzC63lc6LJPSEUMNjCHwQM4OBH_pgC', }, ], 'condition': 'checkout_android', @@ -506,7 +506,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/android_arch_core_common', - 'version': 'version:2@1.1.1.cr0', + 'version': 'version:2@1.1.1.cr1', }, ], 'condition': 'checkout_android', @@ -517,7 +517,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/android_arch_core_runtime', - 'version': 'version:2@1.1.1.cr0', + 'version': 'version:2@1.1.1.cr1', }, ], 'condition': 'checkout_android', @@ -528,7 +528,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/android_arch_lifecycle_common', - 'version': 'version:2@1.1.1.cr0', + 'version': 'version:2@1.1.1.cr1', }, ], 'condition': 'checkout_android', @@ -539,7 +539,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/android_arch_lifecycle_common_java8', - 'version': 'version:2@1.1.1.cr0', + 'version': 'version:2@1.1.1.cr1', }, ], 'condition': 'checkout_android', @@ -550,7 +550,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/android_arch_lifecycle_livedata', - 'version': 'version:2@1.1.1.cr0', + 'version': 'version:2@1.1.1.cr1', }, ], 'condition': 'checkout_android', @@ -561,7 +561,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/android_arch_lifecycle_livedata_core', - 'version': 'version:2@1.1.1.cr0', + 'version': 'version:2@1.1.1.cr1', }, ], 'condition': 'checkout_android', @@ -572,7 +572,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/android_arch_lifecycle_runtime', - 'version': 'version:2@1.1.1.cr0', + 'version': 'version:2@1.1.1.cr1', }, ], 'condition': 'checkout_android', @@ -583,7 +583,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/android_arch_lifecycle_viewmodel', - 'version': 'version:2@1.1.1.cr0', + 'version': 'version:2@1.1.1.cr1', }, ], 'condition': 'checkout_android', @@ -594,7 +594,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_animated_vector_drawable', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -605,7 +605,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_appcompat_v7', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -616,7 +616,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_asynclayoutinflater', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -627,7 +627,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_cardview_v7', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -638,7 +638,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_collections', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -649,7 +649,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_coordinatorlayout', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -660,7 +660,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_cursoradapter', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -671,7 +671,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_customview', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -682,7 +682,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_design', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -693,7 +693,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_documentfile', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -704,7 +704,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_drawerlayout', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -715,7 +715,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_interpolator', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -726,7 +726,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_loader', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -737,7 +737,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_localbroadcastmanager', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -748,7 +748,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_multidex', - 'version': 'version:2@1.0.0.cr0', + 'version': 'version:2@1.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -759,7 +759,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_print', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -770,7 +770,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_recyclerview_v7', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -781,7 +781,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_slidingpanelayout', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -792,7 +792,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_support_annotations', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -803,7 +803,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_support_compat', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -814,7 +814,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_support_core_ui', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -825,7 +825,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_support_core_utils', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -836,7 +836,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_support_fragment', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -847,7 +847,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_support_media_compat', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -858,7 +858,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_support_v4', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -869,7 +869,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_support_vector_drawable', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -880,7 +880,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_swiperefreshlayout', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -891,7 +891,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_transition', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -902,7 +902,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_versionedparcelable', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -913,7 +913,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_support_viewpager', - 'version': 'version:2@28.0.0.cr0', + 'version': 'version:2@28.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -924,7 +924,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_tools_common', - 'version': 'version:2@30.2.0-beta01.cr0', + 'version': 'version:2@30.2.0-beta01.cr1', }, ], 'condition': 'checkout_android', @@ -957,7 +957,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_tools_layoutlib_layoutlib_api', - 'version': 'version:2@30.2.0-beta01.cr0', + 'version': 'version:2@30.2.0-beta01.cr1', }, ], 'condition': 'checkout_android', @@ -968,7 +968,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_android_tools_sdk_common', - 'version': 'version:2@30.2.0-beta01.cr0', + 'version': 'version:2@30.2.0-beta01.cr1', }, ], 'condition': 'checkout_android', @@ -979,7 +979,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_github_ben_manes_caffeine_caffeine', - 'version': 'version:2@2.8.8.cr0', + 'version': 'version:2@2.8.8.cr1', }, ], 'condition': 'checkout_android', @@ -990,7 +990,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_github_kevinstern_software_and_algorithms', - 'version': 'version:2@1.0.cr0', + 'version': 'version:2@1.0.cr1', }, ], 'condition': 'checkout_android', @@ -1001,7 +1001,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_android_datatransport_transport_api', - 'version': 'version:2@2.2.1.cr0', + 'version': 'version:2@2.2.1.cr1', }, ], 'condition': 'checkout_android', @@ -1012,7 +1012,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_auth', - 'version': 'version:2@17.0.0.cr0', + 'version': 'version:2@17.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -1023,7 +1023,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_auth_api_phone', - 'version': 'version:2@17.5.0.cr0', + 'version': 'version:2@17.5.0.cr1', }, ], 'condition': 'checkout_android', @@ -1034,7 +1034,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_auth_base', - 'version': 'version:2@17.0.0.cr0', + 'version': 'version:2@17.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -1045,7 +1045,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_base', - 'version': 'version:2@17.5.0.cr0', + 'version': 'version:2@17.5.0.cr1', }, ], 'condition': 'checkout_android', @@ -1056,7 +1056,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_basement', - 'version': 'version:2@17.5.0.cr0', + 'version': 'version:2@17.5.0.cr1', }, ], 'condition': 'checkout_android', @@ -1067,7 +1067,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_cast', - 'version': 'version:2@17.0.0.cr0', + 'version': 'version:2@17.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -1078,7 +1078,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_cast_framework', - 'version': 'version:2@17.0.0.cr0', + 'version': 'version:2@17.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -1089,7 +1089,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_clearcut', - 'version': 'version:2@17.0.0.cr0', + 'version': 'version:2@17.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -1100,7 +1100,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_cloud_messaging', - 'version': 'version:2@16.0.0.cr0', + 'version': 'version:2@16.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -1111,7 +1111,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_fido', - 'version': 'version:2@19.0.0-beta.cr0', + 'version': 'version:2@19.0.0-beta.cr1', }, ], 'condition': 'checkout_android', @@ -1122,7 +1122,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_flags', - 'version': 'version:2@17.0.0.cr0', + 'version': 'version:2@17.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -1133,7 +1133,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_gcm', - 'version': 'version:2@17.0.0.cr0', + 'version': 'version:2@17.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -1144,7 +1144,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_iid', - 'version': 'version:2@17.0.0.cr0', + 'version': 'version:2@17.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -1155,7 +1155,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_instantapps', - 'version': 'version:2@17.0.0.cr0', + 'version': 'version:2@17.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -1166,7 +1166,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_location', - 'version': 'version:2@17.0.0.cr0', + 'version': 'version:2@17.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -1177,7 +1177,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_phenotype', - 'version': 'version:2@17.0.0.cr0', + 'version': 'version:2@17.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -1188,7 +1188,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_places_placereport', - 'version': 'version:2@17.0.0.cr0', + 'version': 'version:2@17.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -1199,7 +1199,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_stats', - 'version': 'version:2@17.0.0.cr0', + 'version': 'version:2@17.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -1210,7 +1210,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_tasks', - 'version': 'version:2@17.2.0.cr0', + 'version': 'version:2@17.2.0.cr1', }, ], 'condition': 'checkout_android', @@ -1221,7 +1221,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_vision', - 'version': 'version:2@18.0.0.cr0', + 'version': 'version:2@18.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -1232,7 +1232,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_android_gms_play_services_vision_common', - 'version': 'version:2@18.0.0.cr0', + 'version': 'version:2@18.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -1243,7 +1243,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_android_material_material', - 'version': 'version:2@1.6.0-alpha01.cr0', + 'version': 'version:2@1.6.0-alpha01.cr1', }, ], 'condition': 'checkout_android', @@ -1254,7 +1254,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_android_play_core', - 'version': 'version:2@1.10.0.cr0', + 'version': 'version:2@1.10.0.cr1', }, ], 'condition': 'checkout_android', @@ -1265,7 +1265,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_auto_auto_common', - 'version': 'version:2@1.1.2.cr0', + 'version': 'version:2@1.2.1.cr1', }, ], 'condition': 'checkout_android', @@ -1276,7 +1276,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_auto_service_auto_service', - 'version': 'version:2@1.0-rc6.cr0', + 'version': 'version:2@1.0-rc6.cr1', }, ], 'condition': 'checkout_android', @@ -1287,7 +1287,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_auto_service_auto_service_annotations', - 'version': 'version:2@1.0-rc6.cr0', + 'version': 'version:2@1.0-rc6.cr1', }, ], 'condition': 'checkout_android', @@ -1298,18 +1298,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_auto_value_auto_value_annotations', - 'version': 'version:2@1.7.4.cr0', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - - 'src/third_party/android_deps/libs/com_google_code_findbugs_jformatstring': { - 'packages': [ - { - 'package': 'chromium/third_party/android_deps/libs/com_google_code_findbugs_jformatstring', - 'version': 'version:2@3.0.0.cr0', + 'version': 'version:2@1.9.cr1', }, ], 'condition': 'checkout_android', @@ -1320,7 +1309,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_code_findbugs_jsr305', - 'version': 'version:2@3.0.2.cr0', + 'version': 'version:2@3.0.2.cr1', }, ], 'condition': 'checkout_android', @@ -1331,7 +1320,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_code_gson_gson', - 'version': 'version:2@2.8.0.cr0', + 'version': 'version:2@2.8.0.cr1', }, ], 'condition': 'checkout_android', @@ -1342,7 +1331,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_dagger_dagger', - 'version': 'version:2@2.30.cr0', + 'version': 'version:2@2.30.cr1', }, ], 'condition': 'checkout_android', @@ -1353,7 +1342,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_dagger_dagger_compiler', - 'version': 'version:2@2.30.cr0', + 'version': 'version:2@2.30.cr1', }, ], 'condition': 'checkout_android', @@ -1364,7 +1353,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_dagger_dagger_producers', - 'version': 'version:2@2.30.cr0', + 'version': 'version:2@2.30.cr1', }, ], 'condition': 'checkout_android', @@ -1375,7 +1364,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_dagger_dagger_spi', - 'version': 'version:2@2.30.cr0', + 'version': 'version:2@2.30.cr1', }, ], 'condition': 'checkout_android', @@ -1386,7 +1375,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_errorprone_error_prone_annotation', - 'version': 'version:2@2.10.0.cr0', + 'version': 'version:2@2.11.0.cr1', }, ], 'condition': 'checkout_android', @@ -1397,7 +1386,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_errorprone_error_prone_annotations', - 'version': 'version:2@2.9.0.cr0', + 'version': 'version:2@2.11.0.cr1', }, ], 'condition': 'checkout_android', @@ -1408,7 +1397,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_errorprone_error_prone_check_api', - 'version': 'version:2@2.10.0.cr0', + 'version': 'version:2@2.11.0.cr1', }, ], 'condition': 'checkout_android', @@ -1419,7 +1408,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_errorprone_error_prone_core', - 'version': 'version:2@2.10.0.cr0', + 'version': 'version:2@2.11.0.cr1', }, ], 'condition': 'checkout_android', @@ -1430,7 +1419,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_errorprone_error_prone_type_annotations', - 'version': 'version:2@2.10.0.cr0', + 'version': 'version:2@2.11.0.cr1', }, ], 'condition': 'checkout_android', @@ -1441,7 +1430,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_errorprone_javac', - 'version': 'version:2@9+181-r4173-1.cr0', + 'version': 'version:2@9+181-r4173-1.cr1', }, ], 'condition': 'checkout_android', @@ -1452,7 +1441,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_errorprone_javac_shaded', - 'version': 'version:2@9-dev-r4023-3.cr0', + 'version': 'version:2@9-dev-r4023-3.cr1', }, ], 'condition': 'checkout_android', @@ -1463,7 +1452,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_firebase_firebase_annotations', - 'version': 'version:2@16.0.0.cr0', + 'version': 'version:2@16.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -1474,7 +1463,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_firebase_firebase_common', - 'version': 'version:2@19.5.0.cr0', + 'version': 'version:2@19.5.0.cr1', }, ], 'condition': 'checkout_android', @@ -1485,7 +1474,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_firebase_firebase_components', - 'version': 'version:2@16.1.0.cr0', + 'version': 'version:2@16.1.0.cr1', }, ], 'condition': 'checkout_android', @@ -1496,7 +1485,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_firebase_firebase_encoders', - 'version': 'version:2@16.1.0.cr0', + 'version': 'version:2@16.1.0.cr1', }, ], 'condition': 'checkout_android', @@ -1507,7 +1496,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_firebase_firebase_encoders_json', - 'version': 'version:2@17.1.0.cr0', + 'version': 'version:2@17.1.0.cr1', }, ], 'condition': 'checkout_android', @@ -1518,7 +1507,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_firebase_firebase_iid', - 'version': 'version:2@21.0.1.cr0', + 'version': 'version:2@21.0.1.cr1', }, ], 'condition': 'checkout_android', @@ -1529,7 +1518,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_firebase_firebase_iid_interop', - 'version': 'version:2@17.0.0.cr0', + 'version': 'version:2@17.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -1540,7 +1529,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_firebase_firebase_installations', - 'version': 'version:2@16.3.5.cr0', + 'version': 'version:2@16.3.5.cr1', }, ], 'condition': 'checkout_android', @@ -1551,7 +1540,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_firebase_firebase_installations_interop', - 'version': 'version:2@16.0.1.cr0', + 'version': 'version:2@16.0.1.cr1', }, ], 'condition': 'checkout_android', @@ -1562,7 +1551,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_firebase_firebase_measurement_connector', - 'version': 'version:2@18.0.0.cr0', + 'version': 'version:2@18.0.0.cr1', }, ], 'condition': 'checkout_android', @@ -1573,7 +1562,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_firebase_firebase_messaging', - 'version': 'version:2@21.0.1.cr0', + 'version': 'version:2@21.0.1.cr1', }, ], 'condition': 'checkout_android', @@ -1584,7 +1573,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_flatbuffers_flatbuffers_java', - 'version': 'version:2@2.0.3.cr0', + 'version': 'version:2@2.0.3.cr1', }, ], 'condition': 'checkout_android', @@ -1595,7 +1584,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_googlejavaformat_google_java_format', - 'version': 'version:2@1.5.cr0', + 'version': 'version:2@1.5.cr1', }, ], 'condition': 'checkout_android', @@ -1606,7 +1595,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_guava_failureaccess', - 'version': 'version:2@1.0.1.cr0', + 'version': 'version:2@1.0.1.cr1', }, ], 'condition': 'checkout_android', @@ -1617,7 +1606,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_guava_guava', - 'version': 'version:2@31.0-jre.cr0', + 'version': 'version:2@31.0.1-jre.cr1', }, ], 'condition': 'checkout_android', @@ -1628,7 +1617,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_guava_guava_android', - 'version': 'version:2@31.0-android.cr0', + 'version': 'version:2@31.0-android.cr1', }, ], 'condition': 'checkout_android', @@ -1639,7 +1628,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_guava_listenablefuture', - 'version': 'version:2@1.0.cr0', + 'version': 'version:2@1.0.cr1', }, ], 'condition': 'checkout_android', @@ -1650,7 +1639,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_j2objc_j2objc_annotations', - 'version': 'version:2@1.3.cr0', + 'version': 'version:2@1.3.cr1', }, ], 'condition': 'checkout_android', @@ -1661,7 +1650,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_protobuf_protobuf_java', - 'version': 'version:2@3.4.0.cr0', + 'version': 'version:2@3.19.2.cr1', }, ], 'condition': 'checkout_android', @@ -1672,7 +1661,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_google_protobuf_protobuf_javalite', - 'version': 'version:2@3.19.3.cr0', + 'version': 'version:2@3.19.3.cr1', }, ], 'condition': 'checkout_android', @@ -1683,7 +1672,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_googlecode_java_diff_utils_diffutils', - 'version': 'version:2@1.3.0.cr0', + 'version': 'version:2@1.3.0.cr1', }, ], 'condition': 'checkout_android', @@ -1694,7 +1683,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_squareup_javapoet', - 'version': 'version:2@1.13.0.cr0', + 'version': 'version:2@1.13.0.cr1', }, ], 'condition': 'checkout_android', @@ -1705,7 +1694,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/com_squareup_javawriter', - 'version': 'version:2@2.1.1.cr0', + 'version': 'version:2@2.1.1.cr1', }, ], 'condition': 'checkout_android', @@ -1716,7 +1705,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/io_github_java_diff_utils_java_diff_utils', - 'version': 'version:2@4.0.cr0', + 'version': 'version:2@4.0.cr1', }, ], 'condition': 'checkout_android', @@ -1727,7 +1716,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/javax_annotation_javax_annotation_api', - 'version': 'version:2@1.3.2.cr0', + 'version': 'version:2@1.3.2.cr1', }, ], 'condition': 'checkout_android', @@ -1738,7 +1727,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/javax_annotation_jsr250_api', - 'version': 'version:2@1.0.cr0', + 'version': 'version:2@1.0.cr1', }, ], 'condition': 'checkout_android', @@ -1749,7 +1738,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/javax_inject_javax_inject', - 'version': 'version:2@1.cr0', + 'version': 'version:2@1.cr1', }, ], 'condition': 'checkout_android', @@ -1760,7 +1749,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/net_ltgt_gradle_incap_incap', - 'version': 'version:2@0.2.cr0', + 'version': 'version:2@0.2.cr1', }, ], 'condition': 'checkout_android', @@ -1771,7 +1760,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/net_sf_kxml_kxml2', - 'version': 'version:2@2.3.0.cr0', + 'version': 'version:2@2.3.0.cr1', }, ], 'condition': 'checkout_android', @@ -1782,7 +1771,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_ccil_cowan_tagsoup_tagsoup', - 'version': 'version:2@1.2.1.cr0', + 'version': 'version:2@1.2.1.cr1', }, ], 'condition': 'checkout_android', @@ -1793,7 +1782,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_checkerframework_checker_compat_qual', - 'version': 'version:2@2.5.5.cr0', + 'version': 'version:2@2.5.5.cr1', }, ], 'condition': 'checkout_android', @@ -1804,7 +1793,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_checkerframework_checker_qual', - 'version': 'version:2@3.12.0.cr0', + 'version': 'version:2@3.12.0.cr1', }, ], 'condition': 'checkout_android', @@ -1815,7 +1804,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_checkerframework_dataflow_errorprone', - 'version': 'version:2@3.15.0.cr0', + 'version': 'version:2@3.15.0.cr1', }, ], 'condition': 'checkout_android', @@ -1826,7 +1815,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_codehaus_mojo_animal_sniffer_annotations', - 'version': 'version:2@1.17.cr0', + 'version': 'version:2@1.17.cr1', }, ], 'condition': 'checkout_android', @@ -1837,7 +1826,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_eclipse_jgit_org_eclipse_jgit', - 'version': 'version:2@4.4.1.201607150455-r.cr0', + 'version': 'version:2@4.4.1.201607150455-r.cr1', }, ], 'condition': 'checkout_android', @@ -1848,7 +1837,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_jetbrains_annotations', - 'version': 'version:2@13.0.cr0', + 'version': 'version:2@13.0.cr1', }, ], 'condition': 'checkout_android', @@ -1859,7 +1848,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_jetbrains_kotlin_kotlin_stdlib', - 'version': 'version:2@1.6.10.cr0', + 'version': 'version:2@1.6.10.cr1', }, ], 'condition': 'checkout_android', @@ -1870,7 +1859,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_jetbrains_kotlin_kotlin_stdlib_common', - 'version': 'version:2@1.6.10.cr0', + 'version': 'version:2@1.6.10.cr1', }, ], 'condition': 'checkout_android', @@ -1881,7 +1870,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_jetbrains_kotlin_kotlin_stdlib_jdk7', - 'version': 'version:2@1.5.0.cr0', + 'version': 'version:2@1.5.0.cr1', }, ], 'condition': 'checkout_android', @@ -1892,7 +1881,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_jetbrains_kotlin_kotlin_stdlib_jdk8', - 'version': 'version:2@1.5.0.cr0', + 'version': 'version:2@1.5.0.cr1', }, ], 'condition': 'checkout_android', @@ -1903,7 +1892,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_jetbrains_kotlinx_kotlinx_coroutines_android', - 'version': 'version:2@1.5.0.cr0', + 'version': 'version:2@1.5.0.cr1', }, ], 'condition': 'checkout_android', @@ -1914,7 +1903,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_jetbrains_kotlinx_kotlinx_coroutines_core_jvm', - 'version': 'version:2@1.5.0.cr0', + 'version': 'version:2@1.5.0.cr1', }, ], 'condition': 'checkout_android', @@ -1925,7 +1914,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_jetbrains_kotlinx_kotlinx_metadata_jvm', - 'version': 'version:2@0.1.0.cr0', + 'version': 'version:2@0.1.0.cr1', }, ], 'condition': 'checkout_android', @@ -1991,7 +1980,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_pcollections_pcollections', - 'version': 'version:2@2.1.2.cr0', + 'version': 'version:2@3.1.4.cr1', }, ], 'condition': 'checkout_android', @@ -2024,7 +2013,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_deps/libs/org_robolectric_nativeruntime', - 'version': 'version:2@4.7.3.cr0', + 'version': 'version:2@4.7.3.cr1', }, ], 'condition': 'checkout_android', From c7f691a71a0ee3b717e30d1c5f43fdc2c8314769 Mon Sep 17 00:00:00 2001 From: Jonas Oreland Date: Wed, 9 Mar 2022 15:12:07 +0100 Subject: [PATCH 139/847] WebRTC-DeprecateGlobalFieldTrialString/Enabled/ - part 2 convert call/ (and the collaterals) Bug: webrtc:10335 Change-Id: I8f6bc13c032713aa2a947724b464f6f35454d39a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254320 Reviewed-by: Mirko Bonadei Reviewed-by: Harald Alvestrand Commit-Queue: Jonas Oreland Cr-Commit-Position: refs/heads/main@{#36165} --- call/BUILD.gn | 4 +- call/adaptation/BUILD.gn | 2 + .../resource_adaptation_processor_unittest.cc | 5 +- call/adaptation/video_stream_adapter.cc | 4 +- call/adaptation/video_stream_adapter.h | 4 +- .../video_stream_adapter_unittest.cc | 16 +- call/call.cc | 6 +- call/rampup_tests.cc | 1 - call/receive_time_calculator.cc | 20 +-- call/receive_time_calculator.h | 9 +- call/receive_time_calculator_unittest.cc | 4 +- call/rtp_payload_params.h | 2 +- call/rtp_payload_params_unittest.cc | 7 +- call/rtp_transport_controller_send.cc | 6 +- call/rtp_transport_controller_send.h | 2 + call/rtp_video_sender.cc | 6 +- call/rtp_video_sender.h | 7 +- call/rtp_video_sender_unittest.cc | 32 ++-- rtc_base/experiments/BUILD.gn | 2 + .../balanced_degradation_settings.cc | 6 +- .../balanced_degradation_settings.h | 3 +- .../balanced_degradation_settings_unittest.cc | 150 +++++++++--------- video/BUILD.gn | 3 + video/adaptation/BUILD.gn | 1 + video/adaptation/balanced_constraint.cc | 4 +- video/adaptation/balanced_constraint.h | 6 +- .../video_stream_encoder_resource_manager.cc | 9 +- .../video_stream_encoder_resource_manager.h | 4 +- video/video_send_stream.cc | 11 +- video/video_send_stream.h | 4 +- video/video_stream_encoder.cc | 10 +- video/video_stream_encoder.h | 4 +- video/video_stream_encoder_unittest.cc | 77 +++++---- 33 files changed, 257 insertions(+), 174 deletions(-) diff --git a/call/BUILD.gn b/call/BUILD.gn index b2b56b273c..1bba3d7410 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -178,11 +178,11 @@ rtc_library("rtp_sender") { "../api:rtp_parameters", "../api:sequence_checker", "../api:transport_api", + "../api:webrtc_key_value_config", "../api/rtc_event_log", "../api/transport:field_trial_based_config", "../api/transport:goog_cc", "../api/transport:network_control", - "../api/transport:webrtc_key_value_config", "../api/units:data_rate", "../api/units:time_delta", "../api/units:timestamp", @@ -291,6 +291,7 @@ rtc_library("call") { "../api:sequence_checker", "../api:simulated_network_api", "../api:transport_api", + "../api:webrtc_key_value_config", "../api/rtc_event_log", "../api/transport:network_control", "../api/units:time_delta", @@ -491,6 +492,7 @@ if (rtc_include_tests) { "../test:field_trial", "../test:mock_frame_transformer", "../test:mock_transport", + "../test:scoped_key_value_config", "../test:test_common", "../test:test_support", "../test:video_test_common", diff --git a/call/adaptation/BUILD.gn b/call/adaptation/BUILD.gn index 10a46a3d43..4661c3e2f6 100644 --- a/call/adaptation/BUILD.gn +++ b/call/adaptation/BUILD.gn @@ -35,6 +35,7 @@ rtc_library("resource_adaptation") { "../../api:rtp_parameters", "../../api:scoped_refptr", "../../api:sequence_checker", + "../../api:webrtc_key_value_config", "../../api/adaptation:resource_adaptation_api", "../../api/task_queue:task_queue", "../../api/video:video_adaptation", @@ -86,6 +87,7 @@ if (rtc_include_tests) { "../../rtc_base/synchronization:mutex", "../../test:field_trial", "../../test:rtc_expect_death", + "../../test:scoped_key_value_config", "../../test:test_support", ] absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] diff --git a/call/adaptation/resource_adaptation_processor_unittest.cc b/call/adaptation/resource_adaptation_processor_unittest.cc index 705223ab71..da2bc947b9 100644 --- a/call/adaptation/resource_adaptation_processor_unittest.cc +++ b/call/adaptation/resource_adaptation_processor_unittest.cc @@ -23,6 +23,7 @@ #include "rtc_base/synchronization/mutex.h" #include "rtc_base/task_queue_for_test.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" namespace webrtc { @@ -90,7 +91,8 @@ class ResourceAdaptationProcessorTest : public ::testing::Test { other_resource_(FakeResource::Create("OtherFakeResource")), video_stream_adapter_( std::make_unique(&input_state_provider_, - &frame_rate_provider_)), + &frame_rate_provider_, + field_trials_)), processor_(std::make_unique( video_stream_adapter_.get())) { video_stream_adapter_->AddRestrictionsListener(&restrictions_listener_); @@ -133,6 +135,7 @@ class ResourceAdaptationProcessorTest : public ::testing::Test { } protected: + webrtc::test::ScopedKeyValueConfig field_trials_; FakeFrameRateProvider frame_rate_provider_; VideoStreamInputStateProvider input_state_provider_; rtc::scoped_refptr resource_; diff --git a/call/adaptation/video_stream_adapter.cc b/call/adaptation/video_stream_adapter.cc index ce1c300a72..313bcc33de 100644 --- a/call/adaptation/video_stream_adapter.cc +++ b/call/adaptation/video_stream_adapter.cc @@ -203,9 +203,11 @@ const VideoAdaptationCounters& Adaptation::counters() const { VideoStreamAdapter::VideoStreamAdapter( VideoStreamInputStateProvider* input_state_provider, - VideoStreamEncoderObserver* encoder_stats_observer) + VideoStreamEncoderObserver* encoder_stats_observer, + const WebRtcKeyValueConfig& field_trials) : input_state_provider_(input_state_provider), encoder_stats_observer_(encoder_stats_observer), + balanced_settings_(field_trials), adaptation_validation_id_(0), degradation_preference_(DegradationPreference::DISABLED), awaiting_frame_size_change_(absl::nullopt) { diff --git a/call/adaptation/video_stream_adapter.h b/call/adaptation/video_stream_adapter.h index 7bf424a17e..a4a52f400a 100644 --- a/call/adaptation/video_stream_adapter.h +++ b/call/adaptation/video_stream_adapter.h @@ -21,6 +21,7 @@ #include "api/rtp_parameters.h" #include "api/video/video_adaptation_counters.h" #include "api/video/video_stream_encoder_observer.h" +#include "api/webrtc_key_value_config.h" #include "call/adaptation/adaptation_constraint.h" #include "call/adaptation/degradation_preference_provider.h" #include "call/adaptation/video_source_restrictions.h" @@ -123,7 +124,8 @@ class Adaptation final { class VideoStreamAdapter { public: VideoStreamAdapter(VideoStreamInputStateProvider* input_state_provider, - VideoStreamEncoderObserver* encoder_stats_observer); + VideoStreamEncoderObserver* encoder_stats_observer, + const WebRtcKeyValueConfig& field_trials); ~VideoStreamAdapter(); VideoSourceRestrictions source_restrictions() const; diff --git a/call/adaptation/video_stream_adapter_unittest.cc b/call/adaptation/video_stream_adapter_unittest.cc index aba9cf1f29..8f29194254 100644 --- a/call/adaptation/video_stream_adapter_unittest.cc +++ b/call/adaptation/video_stream_adapter_unittest.cc @@ -27,9 +27,9 @@ #include "call/adaptation/video_source_restrictions.h" #include "call/adaptation/video_stream_input_state.h" #include "rtc_base/string_encode.h" -#include "test/field_trial.h" #include "test/gmock.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" #include "test/testsupport/rtc_expect_death.h" namespace webrtc { @@ -153,10 +153,12 @@ class VideoStreamAdapterTest : public ::testing::Test { VideoStreamAdapterTest() : field_trials_(BalancedFieldTrialConfig()), resource_(FakeResource::Create("FakeResource")), - adapter_(&input_state_provider_, &encoder_stats_observer_) {} + adapter_(&input_state_provider_, + &encoder_stats_observer_, + field_trials_) {} protected: - webrtc::test::ScopedFieldTrials field_trials_; + webrtc::test::ScopedKeyValueConfig field_trials_; FakeVideoStreamInputStateProvider input_state_provider_; rtc::scoped_refptr resource_; testing::StrictMock encoder_stats_observer_; @@ -919,9 +921,11 @@ TEST_F(VideoStreamAdapterTest, AdaptationConstraintDisallowsAdaptationsUp) { TEST(VideoStreamAdapterDeathTest, SetDegradationPreferenceInvalidatesAdaptations) { + webrtc::test::ScopedKeyValueConfig field_trials; FakeVideoStreamInputStateProvider input_state_provider; testing::StrictMock encoder_stats_observer_; - VideoStreamAdapter adapter(&input_state_provider, &encoder_stats_observer_); + VideoStreamAdapter adapter(&input_state_provider, &encoder_stats_observer_, + field_trials); adapter.SetDegradationPreference(DegradationPreference::MAINTAIN_FRAMERATE); input_state_provider.SetInputState(1280 * 720, 30, kDefaultMinPixelsPerFrame); Adaptation adaptation = adapter.GetAdaptationDown(); @@ -930,9 +934,11 @@ TEST(VideoStreamAdapterDeathTest, } TEST(VideoStreamAdapterDeathTest, AdaptDownInvalidatesAdaptations) { + webrtc::test::ScopedKeyValueConfig field_trials; FakeVideoStreamInputStateProvider input_state_provider; testing::StrictMock encoder_stats_observer_; - VideoStreamAdapter adapter(&input_state_provider, &encoder_stats_observer_); + VideoStreamAdapter adapter(&input_state_provider, &encoder_stats_observer_, + field_trials); adapter.SetDegradationPreference(DegradationPreference::MAINTAIN_RESOLUTION); input_state_provider.SetInputState(1280 * 720, 30, kDefaultMinPixelsPerFrame); Adaptation adaptation = adapter.GetAdaptationDown(); diff --git a/call/call.cc b/call/call.cc index 2638b22b31..16f7b9058f 100644 --- a/call/call.cc +++ b/call/call.cc @@ -823,7 +823,8 @@ Call::Call(Clock* clock, absl::bind_front(&PacketRouter::SendRemb, transport_send->packet_router()), /*network_state_estimator=*/nullptr), - receive_time_calculator_(ReceiveTimeCalculator::CreateFromFieldTrial()), + receive_time_calculator_( + ReceiveTimeCalculator::CreateFromFieldTrial(*config.trials)), video_send_delay_stats_(new SendDelayStats(clock_)), start_of_call_(clock_->CurrentTime()), transport_send_ptr_(transport_send.get()), @@ -1055,7 +1056,8 @@ webrtc::VideoSendStream* Call::CreateVideoSendStream( call_stats_->AsRtcpRttStats(), transport_send_.get(), bitrate_allocator_.get(), video_send_delay_stats_.get(), event_log_, std::move(config), std::move(encoder_config), suspended_video_send_ssrcs_, - suspended_video_payload_states_, std::move(fec_controller)); + suspended_video_payload_states_, std::move(fec_controller), + *config_.trials); for (uint32_t ssrc : ssrcs) { RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); diff --git a/call/rampup_tests.cc b/call/rampup_tests.cc index abd0f1f348..999bb50815 100644 --- a/call/rampup_tests.cc +++ b/call/rampup_tests.cc @@ -26,7 +26,6 @@ #include "rtc_base/task_queue_for_test.h" #include "rtc_base/time_utils.h" #include "test/encoder_settings.h" -#include "test/field_trial.h" #include "test/gtest.h" #include "test/testsupport/perf_test.h" diff --git a/call/receive_time_calculator.cc b/call/receive_time_calculator.cc index 94d1fd18cc..d6ffd39d6d 100644 --- a/call/receive_time_calculator.cc +++ b/call/receive_time_calculator.cc @@ -16,22 +16,20 @@ #include "rtc_base/experiments/field_trial_parser.h" #include "rtc_base/numerics/safe_minmax.h" -#include "system_wrappers/include/field_trial.h" namespace webrtc { namespace { -using ::webrtc::field_trial::IsEnabled; const char kBweReceiveTimeCorrection[] = "WebRTC-Bwe-ReceiveTimeFix"; } // namespace -ReceiveTimeCalculatorConfig::ReceiveTimeCalculatorConfig() +ReceiveTimeCalculatorConfig::ReceiveTimeCalculatorConfig( + const WebRtcKeyValueConfig& field_trials) : max_packet_time_repair("maxrep", TimeDelta::Millis(2000)), stall_threshold("stall", TimeDelta::Millis(5)), tolerance("tol", TimeDelta::Millis(1)), max_stall("maxstall", TimeDelta::Seconds(5)) { - std::string trial_string = - field_trial::FindFullName(kBweReceiveTimeCorrection); + std::string trial_string = field_trials.Lookup(kBweReceiveTimeCorrection); ParseFieldTrial( {&max_packet_time_repair, &stall_threshold, &tolerance, &max_stall}, trial_string); @@ -40,14 +38,16 @@ ReceiveTimeCalculatorConfig::ReceiveTimeCalculatorConfig( const ReceiveTimeCalculatorConfig&) = default; ReceiveTimeCalculatorConfig::~ReceiveTimeCalculatorConfig() = default; -ReceiveTimeCalculator::ReceiveTimeCalculator() - : config_(ReceiveTimeCalculatorConfig()) {} +ReceiveTimeCalculator::ReceiveTimeCalculator( + const WebRtcKeyValueConfig& field_trials) + : config_(field_trials) {} std::unique_ptr -ReceiveTimeCalculator::CreateFromFieldTrial() { - if (!IsEnabled(kBweReceiveTimeCorrection)) +ReceiveTimeCalculator::CreateFromFieldTrial( + const WebRtcKeyValueConfig& field_trials) { + if (!field_trials.IsEnabled(kBweReceiveTimeCorrection)) return nullptr; - return std::make_unique(); + return std::make_unique(field_trials); } int64_t ReceiveTimeCalculator::ReconcileReceiveTimes(int64_t packet_time_us, diff --git a/call/receive_time_calculator.h b/call/receive_time_calculator.h index 0bd3a82afc..276ddda720 100644 --- a/call/receive_time_calculator.h +++ b/call/receive_time_calculator.h @@ -15,12 +15,14 @@ #include #include "api/units/time_delta.h" +#include "api/webrtc_key_value_config.h" #include "rtc_base/experiments/field_trial_parser.h" namespace webrtc { struct ReceiveTimeCalculatorConfig { - ReceiveTimeCalculatorConfig(); + explicit ReceiveTimeCalculatorConfig( + const WebRtcKeyValueConfig& field_trials); ReceiveTimeCalculatorConfig(const ReceiveTimeCalculatorConfig&); ReceiveTimeCalculatorConfig& operator=(const ReceiveTimeCalculatorConfig&) = default; @@ -41,8 +43,9 @@ struct ReceiveTimeCalculatorConfig { // is received. class ReceiveTimeCalculator { public: - static std::unique_ptr CreateFromFieldTrial(); - ReceiveTimeCalculator(); + static std::unique_ptr CreateFromFieldTrial( + const WebRtcKeyValueConfig& field_trials); + explicit ReceiveTimeCalculator(const WebRtcKeyValueConfig& field_trials); int64_t ReconcileReceiveTimes(int64_t packet_time_us_, int64_t system_time_us_, int64_t safe_time_us_); diff --git a/call/receive_time_calculator_unittest.cc b/call/receive_time_calculator_unittest.cc index d18fb1be8b..f2e3d54f0c 100644 --- a/call/receive_time_calculator_unittest.cc +++ b/call/receive_time_calculator_unittest.cc @@ -21,6 +21,7 @@ #include "rtc_base/random.h" #include "rtc_base/time_utils.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" namespace webrtc { namespace test { @@ -168,6 +169,7 @@ class EmulatedNonMonotoneousClock : public EmulatedClock { }; TEST(ClockRepair, NoClockDrift) { + webrtc::test::ScopedKeyValueConfig field_trials; const int kSeeds = 10; const int kFirstSeed = 1; const int64_t kRuntimeUs = 10 * rtc::kNumMicrosecsPerSec; @@ -177,7 +179,7 @@ TEST(ClockRepair, NoClockDrift) { EmulatedMonotoneousClock monotone_clock(seed); EmulatedNonMonotoneousClock non_monotone_clock( seed + 1, kRuntimeUs + rtc::kNumMicrosecsPerSec, kDrift); - ReceiveTimeCalculator reception_time_tracker; + ReceiveTimeCalculator reception_time_tracker(field_trials); int64_t corrected_clock_0 = 0; int64_t reset_during_stall_tol_us = 0; bool initial_clock_stall = true; diff --git a/call/rtp_payload_params.h b/call/rtp_payload_params.h index 1f03fab6da..b1680a9ac0 100644 --- a/call/rtp_payload_params.h +++ b/call/rtp_payload_params.h @@ -15,8 +15,8 @@ #include #include "absl/types/optional.h" -#include "api/transport/webrtc_key_value_config.h" #include "api/video_codecs/video_encoder.h" +#include "api/webrtc_key_value_config.h" #include "call/rtp_config.h" #include "modules/rtp_rtcp/source/rtp_generic_frame_descriptor.h" #include "modules/rtp_rtcp/source/rtp_video_header.h" diff --git a/call/rtp_payload_params_unittest.cc b/call/rtp_payload_params_unittest.cc index 8b22716f43..b155c4c204 100644 --- a/call/rtp_payload_params_unittest.cc +++ b/call/rtp_payload_params_unittest.cc @@ -27,9 +27,9 @@ #include "modules/video_coding/codecs/vp9/include/vp9_globals.h" #include "modules/video_coding/include/video_codec_interface.h" #include "test/explicit_key_value_config.h" -#include "test/field_trial.h" #include "test/gmock.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" using ::testing::Each; using ::testing::ElementsAre; @@ -275,8 +275,7 @@ TEST(RtpPayloadParamsTest, Tl0PicIdxUpdatedForVp9) { } TEST(RtpPayloadParamsTest, PictureIdForOldGenericFormat) { - test::ScopedFieldTrials generic_picture_id( - "WebRTC-GenericPictureId/Enabled/"); + test::ScopedKeyValueConfig field_trials("WebRTC-GenericPictureId/Enabled/"); RtpPayloadState state{}; EncodedImage encoded_image; @@ -284,7 +283,7 @@ TEST(RtpPayloadParamsTest, PictureIdForOldGenericFormat) { codec_info.codecType = kVideoCodecGeneric; encoded_image._frameType = VideoFrameType::kVideoFrameKey; - RtpPayloadParams params(kSsrc1, &state, FieldTrialBasedConfig()); + RtpPayloadParams params(kSsrc1, &state, field_trials); RTPVideoHeader header = params.GetRtpVideoHeader(encoded_image, &codec_info, 10); diff --git a/call/rtp_transport_controller_send.cc b/call/rtp_transport_controller_send.cc index 230b048ce4..f1a6201ce7 100644 --- a/call/rtp_transport_controller_send.cc +++ b/call/rtp_transport_controller_send.cc @@ -134,7 +134,8 @@ RtpTransportControllerSend::RtpTransportControllerSend( retransmission_rate_limiter_(clock, kRetransmitWindowSizeMs), task_queue_(task_queue_factory->CreateTaskQueue( "rtp_send_controller", - TaskQueueFactory::Priority::NORMAL)) { + TaskQueueFactory::Priority::NORMAL)), + field_trials_(*trials) { ParseFieldTrial({&relay_bandwidth_cap_}, trials->Lookup("WebRTC-Bwe-NetworkRouteConstraints")); initial_config_.constraints = ConvertConstraints(bitrate_config, clock_); @@ -174,7 +175,8 @@ RtpVideoSenderInterface* RtpTransportControllerSend::CreateRtpVideoSender( // the parts of RtpTransportControllerSendInterface that are really used. this, event_log, &retransmission_rate_limiter_, std::move(fec_controller), frame_encryption_config.frame_encryptor, - frame_encryption_config.crypto_options, std::move(frame_transformer))); + frame_encryption_config.crypto_options, std::move(frame_transformer), + field_trials_)); return video_rtp_senders_.back().get(); } diff --git a/call/rtp_transport_controller_send.h b/call/rtp_transport_controller_send.h index e5ff162687..e45ab21cda 100644 --- a/call/rtp_transport_controller_send.h +++ b/call/rtp_transport_controller_send.h @@ -218,6 +218,8 @@ class RtpTransportControllerSend final // `task_queue_` is defined last to ensure all pending tasks are cancelled // and deleted before any other members. rtc::TaskQueue task_queue_; + + const WebRtcKeyValueConfig& field_trials_; }; } // namespace webrtc diff --git a/call/rtp_video_sender.cc b/call/rtp_video_sender.cc index 35e6beeb7c..c5de3a72d9 100644 --- a/call/rtp_video_sender.cc +++ b/call/rtp_video_sender.cc @@ -358,8 +358,10 @@ RtpVideoSender::RtpVideoSender( std::unique_ptr fec_controller, FrameEncryptorInterface* frame_encryptor, const CryptoOptions& crypto_options, - rtc::scoped_refptr frame_transformer) - : send_side_bwe_with_overhead_(!absl::StartsWith( + rtc::scoped_refptr frame_transformer, + const WebRtcKeyValueConfig& field_trials) + : field_trials_(field_trials), + send_side_bwe_with_overhead_(!absl::StartsWith( field_trials_.Lookup("WebRTC-SendSideBwe-WithOverhead"), "Disabled")), use_frame_rate_for_overhead_(absl::StartsWith( diff --git a/call/rtp_video_sender.h b/call/rtp_video_sender.h index 7023804506..1fa9a8bd1e 100644 --- a/call/rtp_video_sender.h +++ b/call/rtp_video_sender.h @@ -23,8 +23,8 @@ #include "api/fec_controller_override.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/sequence_checker.h" -#include "api/transport/field_trial_based_config.h" #include "api/video_codecs/video_encoder.h" +#include "api/webrtc_key_value_config.h" #include "call/rtp_config.h" #include "call/rtp_payload_params.h" #include "call/rtp_transport_controller_send_interface.h" @@ -85,7 +85,8 @@ class RtpVideoSender : public RtpVideoSenderInterface, std::unique_ptr fec_controller, FrameEncryptorInterface* frame_encryptor, const CryptoOptions& crypto_options, // move inside RtpTransport - rtc::scoped_refptr frame_transformer); + rtc::scoped_refptr frame_transformer, + const WebRtcKeyValueConfig& field_trials); ~RtpVideoSender() override; RtpVideoSender(const RtpVideoSender&) = delete; @@ -166,7 +167,7 @@ class RtpVideoSender : public RtpVideoSenderInterface, DataSize overhead_per_packet, Frequency framerate) const; - const FieldTrialBasedConfig field_trials_; + const WebRtcKeyValueConfig& field_trials_; const bool send_side_bwe_with_overhead_; const bool use_frame_rate_for_overhead_; const bool has_packet_feedback_; diff --git a/call/rtp_video_sender_unittest.cc b/call/rtp_video_sender_unittest.cc index c47717da7f..2f2ffb0446 100644 --- a/call/rtp_video_sender_unittest.cc +++ b/call/rtp_video_sender_unittest.cc @@ -24,12 +24,12 @@ #include "modules/video_coding/fec_controller_default.h" #include "modules/video_coding/include/video_codec_interface.h" #include "rtc_base/rate_limiter.h" -#include "test/field_trial.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/mock_frame_transformer.h" #include "test/mock_transport.h" #include "test/scenario/scenario.h" +#include "test/scoped_key_value_config.h" #include "test/time_controller/simulated_time_controller.h" #include "video/send_delay_stats.h" #include "video/send_statistics_proxy.h" @@ -118,7 +118,8 @@ class RtpVideoSenderTestFixture { int payload_type, const std::map& suspended_payload_states, FrameCountObserver* frame_count_observer, - rtc::scoped_refptr frame_transformer) + rtc::scoped_refptr frame_transformer, + const WebRtcKeyValueConfig* field_trials = nullptr) : time_controller_(Timestamp::Millis(1000000)), config_(CreateVideoSendStreamConfig(&transport_, ssrcs, @@ -134,7 +135,7 @@ class RtpVideoSenderTestFixture { bitrate_config_, time_controller_.CreateProcessThread("PacerThread"), time_controller_.GetTaskQueueFactory(), - &field_trials_), + field_trials ? field_trials : &field_trials_), stats_proxy_(time_controller_.GetClock(), config_, VideoEncoderConfig::ContentType::kRealtimeVideo), @@ -150,7 +151,8 @@ class RtpVideoSenderTestFixture { &stats_proxy_, &stats_proxy_, &send_delay_stats_), &transport_controller_, &event_log_, &retransmission_rate_limiter_, std::make_unique(time_controller_.GetClock()), - nullptr, CryptoOptions{}, frame_transformer); + nullptr, CryptoOptions{}, frame_transformer, + field_trials ? *field_trials : field_trials_); } RtpVideoSenderTestFixture( @@ -158,25 +160,29 @@ class RtpVideoSenderTestFixture { const std::vector& rtx_ssrcs, int payload_type, const std::map& suspended_payload_states, - FrameCountObserver* frame_count_observer) + FrameCountObserver* frame_count_observer, + const WebRtcKeyValueConfig* field_trials = nullptr) : RtpVideoSenderTestFixture(ssrcs, rtx_ssrcs, payload_type, suspended_payload_states, frame_count_observer, - /*frame_transformer=*/nullptr) {} + /*frame_transformer=*/nullptr, + field_trials) {} RtpVideoSenderTestFixture( const std::vector& ssrcs, const std::vector& rtx_ssrcs, int payload_type, - const std::map& suspended_payload_states) + const std::map& suspended_payload_states, + const WebRtcKeyValueConfig* field_trials = nullptr) : RtpVideoSenderTestFixture(ssrcs, rtx_ssrcs, payload_type, suspended_payload_states, /*frame_count_observer=*/nullptr, - /*frame_transformer=*/nullptr) {} + /*frame_transformer=*/nullptr, + field_trials) {} ~RtpVideoSenderTestFixture() { SetActive(false); } @@ -206,6 +212,7 @@ class RtpVideoSenderTestFixture { } private: + test::ScopedKeyValueConfig field_trials_; NiceMock transport_; NiceMock encoder_feedback_; GlobalSimulatedTimeController time_controller_; @@ -213,7 +220,6 @@ class RtpVideoSenderTestFixture { VideoSendStream::Config config_; SendDelayStats send_delay_stats_; BitrateConstraints bitrate_config_; - const FieldTrialBasedConfig field_trials_; RtpTransportControllerSend transport_controller_; SendStatisticsProxy stats_proxy_; RateLimiter retransmission_rate_limiter_; @@ -849,9 +855,9 @@ TEST(RtpVideoSenderTest, } TEST(RtpVideoSenderTest, GenerateDependecyDescriptorForGenericCodecs) { - test::ScopedFieldTrials field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-GenericCodecDependencyDescriptor/Enabled/"); - RtpVideoSenderTestFixture test({kSsrc1}, {}, kPayloadType, {}); + RtpVideoSenderTestFixture test({kSsrc1}, {}, kPayloadType, {}, &field_trials); test.SetActive(true); RtpHeaderExtensionMap extensions; @@ -1031,7 +1037,7 @@ TEST(RtpVideoSenderTest, SimulcastSenderRegistersFrameTransformers) { } TEST(RtpVideoSenderTest, OverheadIsSubtractedFromTargetBitrate) { - test::ScopedFieldTrials field_trials( + test::ScopedKeyValueConfig field_trials( "WebRTC-Video-UseFrameRateForOverhead/Enabled/"); // TODO(jakobi): RTP header size should not be hard coded. @@ -1039,7 +1045,7 @@ TEST(RtpVideoSenderTest, OverheadIsSubtractedFromTargetBitrate) { constexpr uint32_t kTransportPacketOverheadBytes = 40; constexpr uint32_t kOverheadPerPacketBytes = kRtpHeaderSizeBytes + kTransportPacketOverheadBytes; - RtpVideoSenderTestFixture test({kSsrc1}, {}, kPayloadType, {}); + RtpVideoSenderTestFixture test({kSsrc1}, {}, kPayloadType, {}, &field_trials); test.router()->OnTransportOverheadChanged(kTransportPacketOverheadBytes); test.SetActive(true); diff --git a/rtc_base/experiments/BUILD.gn b/rtc_base/experiments/BUILD.gn index 56d5000869..b9d24ca6cc 100644 --- a/rtc_base/experiments/BUILD.gn +++ b/rtc_base/experiments/BUILD.gn @@ -126,6 +126,7 @@ rtc_library("balanced_degradation_settings") { deps = [ ":field_trial_parser", "../:rtc_base_approved", + "../../api:webrtc_key_value_config", "../../api/video_codecs:video_codecs_api", "../../system_wrappers:field_trial", ] @@ -291,6 +292,7 @@ if (rtc_include_tests && !build_with_chromium) { "../../api/video_codecs:video_codecs_api", "../../system_wrappers:field_trial", "../../test:field_trial", + "../../test:scoped_key_value_config", "../../test:test_main", "../../test:test_support", ] diff --git a/rtc_base/experiments/balanced_degradation_settings.cc b/rtc_base/experiments/balanced_degradation_settings.cc index 90d44efb10..7cd1a675d4 100644 --- a/rtc_base/experiments/balanced_degradation_settings.cc +++ b/rtc_base/experiments/balanced_degradation_settings.cc @@ -15,7 +15,6 @@ #include "rtc_base/experiments/field_trial_list.h" #include "rtc_base/experiments/field_trial_parser.h" #include "rtc_base/logging.h" -#include "system_wrappers/include/field_trial.h" namespace webrtc { namespace { @@ -332,7 +331,8 @@ BalancedDegradationSettings::Config::Config(int pixels, av1(av1), generic(generic) {} -BalancedDegradationSettings::BalancedDegradationSettings() { +BalancedDegradationSettings::BalancedDegradationSettings( + const WebRtcKeyValueConfig& field_trials) { FieldTrialStructList configs( {FieldTrialStructMember("pixels", [](Config* c) { return &c->pixels; }), FieldTrialStructMember("fps", [](Config* c) { return &c->fps; }), @@ -390,7 +390,7 @@ BalancedDegradationSettings::BalancedDegradationSettings() { [](Config* c) { return &c->generic.kbps_res; })}, {}); - ParseFieldTrial({&configs}, field_trial::FindFullName(kFieldTrial)); + ParseFieldTrial({&configs}, field_trials.Lookup(kFieldTrial)); configs_ = GetValidOrDefault(configs.Get()); RTC_DCHECK_GT(configs_.size(), 1); diff --git a/rtc_base/experiments/balanced_degradation_settings.h b/rtc_base/experiments/balanced_degradation_settings.h index 0b2f2f5993..8255547cd0 100644 --- a/rtc_base/experiments/balanced_degradation_settings.h +++ b/rtc_base/experiments/balanced_degradation_settings.h @@ -15,6 +15,7 @@ #include "absl/types/optional.h" #include "api/video_codecs/video_encoder.h" +#include "api/webrtc_key_value_config.h" namespace webrtc { @@ -22,7 +23,7 @@ class BalancedDegradationSettings { public: static constexpr int kNoFpsDiff = -100; - BalancedDegradationSettings(); + BalancedDegradationSettings(const WebRtcKeyValueConfig& field_trials); ~BalancedDegradationSettings(); struct CodecTypeSpecific { diff --git a/rtc_base/experiments/balanced_degradation_settings_unittest.cc b/rtc_base/experiments/balanced_degradation_settings_unittest.cc index 92833ee98c..a32dbb4aaa 100644 --- a/rtc_base/experiments/balanced_degradation_settings_unittest.cc +++ b/rtc_base/experiments/balanced_degradation_settings_unittest.cc @@ -13,8 +13,8 @@ #include #include "rtc_base/gunit.h" -#include "test/field_trial.h" #include "test/gmock.h" +#include "test/scoped_key_value_config.h" namespace webrtc { namespace { @@ -59,8 +59,8 @@ void VerifyIsDefault( } // namespace TEST(BalancedDegradationSettings, GetsDefaultConfigIfNoList) { - webrtc::test::ScopedFieldTrials field_trials(""); - BalancedDegradationSettings settings; + webrtc::test::ScopedKeyValueConfig field_trials(""); + BalancedDegradationSettings settings(field_trials); VerifyIsDefault(settings.GetConfigs()); EXPECT_TRUE(settings.CanAdaptUp(kVideoCodecVP8, 1, /*bitrate_bps*/ 1)); EXPECT_TRUE( @@ -75,10 +75,10 @@ TEST(BalancedDegradationSettings, GetsDefaultConfigIfNoList) { } TEST(BalancedDegradationSettings, GetsConfig) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:11|22|33,fps:5|15|25,other:4|5|6/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); EXPECT_THAT(settings.GetConfigs(), ::testing::ElementsAre( BalancedDegradationSettings::Config{ @@ -117,35 +117,35 @@ TEST(BalancedDegradationSettings, GetsConfig) { } TEST(BalancedDegradationSettings, GetsDefaultConfigForZeroFpsValue) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:0|15|25/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); VerifyIsDefault(settings.GetConfigs()); } TEST(BalancedDegradationSettings, GetsDefaultConfigIfPixelsDecreases) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|999|3000,fps:5|15|25/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); VerifyIsDefault(settings.GetConfigs()); } TEST(BalancedDegradationSettings, GetsDefaultConfigIfFramerateDecreases) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|4|25/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); VerifyIsDefault(settings.GetConfigs()); } TEST(BalancedDegradationSettings, GetsConfigWithSpecificFps) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25,vp8_fps:7|8|9,vp9_fps:9|10|11," "h264_fps:11|12|13,av1_fps:1|2|3,generic_fps:13|14|15/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); EXPECT_THAT(settings.GetConfigs(), ::testing::ElementsAre( BalancedDegradationSettings::Config{ @@ -184,34 +184,34 @@ TEST(BalancedDegradationSettings, GetsConfigWithSpecificFps) { } TEST(BalancedDegradationSettings, GetsDefaultConfigForZeroVp8FpsValue) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:7|15|25,vp8_fps:0|15|25/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); VerifyIsDefault(settings.GetConfigs()); } TEST(BalancedDegradationSettings, GetsDefaultConfigForInvalidFpsValue) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:7|15|25,vp8_fps:10|15|2000/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); VerifyIsDefault(settings.GetConfigs()); } TEST(BalancedDegradationSettings, GetsDefaultConfigIfVp8FramerateDecreases) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:4|5|25,vp8_fps:5|4|25/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); VerifyIsDefault(settings.GetConfigs()); } TEST(BalancedDegradationSettings, GetsMinFps) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); EXPECT_EQ(5, settings.MinFps(kVideoCodecVP8, 1)); EXPECT_EQ(5, settings.MinFps(kVideoCodecVP8, 1000)); EXPECT_EQ(15, settings.MinFps(kVideoCodecVP8, 1001)); @@ -223,10 +223,10 @@ TEST(BalancedDegradationSettings, GetsMinFps) { } TEST(BalancedDegradationSettings, GetsVp8MinFps) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25,vp8_fps:7|10|12/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); EXPECT_EQ(7, settings.MinFps(kVideoCodecVP8, 1)); EXPECT_EQ(7, settings.MinFps(kVideoCodecVP8, 1000)); EXPECT_EQ(10, settings.MinFps(kVideoCodecVP8, 1001)); @@ -238,10 +238,10 @@ TEST(BalancedDegradationSettings, GetsVp8MinFps) { } TEST(BalancedDegradationSettings, GetsMaxFps) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); EXPECT_EQ(15, settings.MaxFps(kVideoCodecVP8, 1)); EXPECT_EQ(15, settings.MaxFps(kVideoCodecVP8, 1000)); EXPECT_EQ(25, settings.MaxFps(kVideoCodecVP8, 1001)); @@ -251,10 +251,10 @@ TEST(BalancedDegradationSettings, GetsMaxFps) { } TEST(BalancedDegradationSettings, GetsVp8MaxFps) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25,vp8_fps:7|10|12/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); EXPECT_EQ(10, settings.MaxFps(kVideoCodecVP8, 1)); EXPECT_EQ(10, settings.MaxFps(kVideoCodecVP8, 1000)); EXPECT_EQ(12, settings.MaxFps(kVideoCodecVP8, 1001)); @@ -264,39 +264,39 @@ TEST(BalancedDegradationSettings, GetsVp8MaxFps) { } TEST(BalancedDegradationSettings, GetsVp9Fps) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25,vp9_fps:7|10|12/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); EXPECT_EQ(7, settings.MinFps(kVideoCodecVP9, 1000)); EXPECT_EQ(10, settings.MaxFps(kVideoCodecVP9, 1000)); } TEST(BalancedDegradationSettings, GetsH264Fps) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25,h264_fps:8|11|13/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); EXPECT_EQ(11, settings.MinFps(kVideoCodecH264, 2000)); EXPECT_EQ(13, settings.MaxFps(kVideoCodecH264, 2000)); } TEST(BalancedDegradationSettings, GetsGenericFps) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25,generic_fps:9|12|14/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); EXPECT_EQ(14, settings.MinFps(kVideoCodecGeneric, 3000)); EXPECT_EQ(std::numeric_limits::max(), settings.MaxFps(kVideoCodecGeneric, 3000)); } TEST(BalancedDegradationSettings, GetsUnlimitedForMaxValidFps) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|100,vp8_fps:30|100|100/"); const int kUnlimitedFps = std::numeric_limits::max(); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); EXPECT_EQ(15, settings.MinFps(kVideoCodecH264, 2000)); EXPECT_EQ(kUnlimitedFps, settings.MinFps(kVideoCodecH264, 2001)); EXPECT_EQ(30, settings.MinFps(kVideoCodecVP8, 1000)); @@ -304,7 +304,7 @@ TEST(BalancedDegradationSettings, GetsUnlimitedForMaxValidFps) { } TEST(BalancedDegradationSettings, GetsConfigWithBitrate) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:11|22|33,fps:5|15|25,kbps:44|88|99,kbps_res:55|111|222," "vp8_kbps:11|12|13,vp8_kbps_res:14|15|16," @@ -312,7 +312,7 @@ TEST(BalancedDegradationSettings, GetsConfigWithBitrate) { "h264_kbps:31|32|33,h264_kbps_res:34|35|36," "av1_kbps:41|42|43,av1_kbps_res:44|45|46," "generic_kbps:51|52|53,generic_kbps_res:54|55|56/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); EXPECT_THAT(settings.GetConfigs(), ::testing::ElementsAre( BalancedDegradationSettings::Config{ @@ -351,29 +351,29 @@ TEST(BalancedDegradationSettings, GetsConfigWithBitrate) { } TEST(BalancedDegradationSettings, GetsDefaultConfigIfBitrateDecreases) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:11|22|33,fps:5|15|25,kbps:44|43|99/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); VerifyIsDefault(settings.GetConfigs()); } TEST(BalancedDegradationSettings, GetsDefaultConfigIfBitrateDecreasesWithUnsetValue) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:11|22|33,fps:5|15|25,kbps:44|0|43/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); VerifyIsDefault(settings.GetConfigs()); } TEST(BalancedDegradationSettings, CanAdaptUp) { VideoCodecType vp8 = kVideoCodecVP8; - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000|4000,fps:5|15|25|30,kbps:0|80|0|90," "vp9_kbps:40|50|60|70/"); - BalancedDegradationSettings s; + BalancedDegradationSettings s(field_trials); EXPECT_TRUE(s.CanAdaptUp(vp8, 1000, 0)); // No bitrate provided. EXPECT_FALSE(s.CanAdaptUp(vp8, 1000, 79000)); EXPECT_TRUE(s.CanAdaptUp(vp8, 1000, 80000)); @@ -384,12 +384,12 @@ TEST(BalancedDegradationSettings, CanAdaptUp) { } TEST(BalancedDegradationSettings, CanAdaptUpWithCodecType) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000|4000,fps:5|15|25|30,vp8_kbps:0|30|40|50," "vp9_kbps:0|60|70|80,h264_kbps:0|55|65|75,av1_kbps:0|77|88|99," "generic_kbps:0|25|35|45/"); - BalancedDegradationSettings s; + BalancedDegradationSettings s(field_trials); EXPECT_FALSE(s.CanAdaptUp(kVideoCodecVP8, 1000, 29000)); EXPECT_TRUE(s.CanAdaptUp(kVideoCodecVP8, 1000, 30000)); EXPECT_FALSE(s.CanAdaptUp(kVideoCodecVP9, 1000, 59000)); @@ -405,11 +405,11 @@ TEST(BalancedDegradationSettings, CanAdaptUpWithCodecType) { TEST(BalancedDegradationSettings, CanAdaptUpResolution) { VideoCodecType vp8 = kVideoCodecVP8; - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000|4000,fps:5|15|25|30,kbps_res:0|80|0|90," "vp9_kbps_res:40|50|60|70/"); - BalancedDegradationSettings s; + BalancedDegradationSettings s(field_trials); EXPECT_TRUE(s.CanAdaptUpResolution(vp8, 1000, 0)); // No bitrate provided. EXPECT_FALSE(s.CanAdaptUpResolution(vp8, 1000, 79000)); EXPECT_TRUE(s.CanAdaptUpResolution(vp8, 1000, 80000)); @@ -420,12 +420,12 @@ TEST(BalancedDegradationSettings, CanAdaptUpResolution) { } TEST(BalancedDegradationSettings, CanAdaptUpResolutionWithCodecType) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000|4000,fps:5|15|25|30,vp8_kbps_res:0|30|40|50," "vp9_kbps_res:0|60|70|80,h264_kbps_res:0|55|65|75," "av1_kbps_res:0|77|88|99,generic_kbps_res:0|25|35|45/"); - BalancedDegradationSettings s; + BalancedDegradationSettings s(field_trials); EXPECT_FALSE(s.CanAdaptUpResolution(kVideoCodecVP8, 1000, 29000)); EXPECT_TRUE(s.CanAdaptUpResolution(kVideoCodecVP8, 1000, 30000)); EXPECT_FALSE(s.CanAdaptUpResolution(kVideoCodecVP9, 1000, 59000)); @@ -441,10 +441,10 @@ TEST(BalancedDegradationSettings, CanAdaptUpResolutionWithCodecType) { } TEST(BalancedDegradationSettings, GetsFpsDiff) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25,fps_diff:0|-2|3/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); EXPECT_EQ(0, settings.MinFpsDiff(1)); EXPECT_EQ(0, settings.MinFpsDiff(1000)); EXPECT_EQ(-2, settings.MinFpsDiff(1001)); @@ -455,21 +455,21 @@ TEST(BalancedDegradationSettings, GetsFpsDiff) { } TEST(BalancedDegradationSettings, GetsNoFpsDiffIfValueBelowMinSetting) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25,fps_diff:-100|-99|-101/"); // Min valid fps_diff setting: -99. - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); EXPECT_FALSE(settings.MinFpsDiff(1000)); EXPECT_EQ(-99, settings.MinFpsDiff(2000)); EXPECT_FALSE(settings.MinFpsDiff(3000)); } TEST(BalancedDegradationSettings, QpThresholdsNotSetByDefault) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); EXPECT_FALSE(settings.GetQpThresholds(kVideoCodecVP8, 1)); EXPECT_FALSE(settings.GetQpThresholds(kVideoCodecVP9, 1)); EXPECT_FALSE(settings.GetQpThresholds(kVideoCodecH264, 1)); @@ -478,13 +478,13 @@ TEST(BalancedDegradationSettings, QpThresholdsNotSetByDefault) { } TEST(BalancedDegradationSettings, GetsConfigWithQpThresholds) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25,vp8_qp_low:89|90|88," "vp8_qp_high:90|91|92,vp9_qp_low:27|28|29,vp9_qp_high:120|130|140," "h264_qp_low:12|13|14,h264_qp_high:20|30|40,av1_qp_low:2|3|4," "av1_qp_high:11|33|44,generic_qp_low:7|6|5,generic_qp_high:22|23|24/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); EXPECT_THAT(settings.GetConfigs(), ::testing::ElementsAre( BalancedDegradationSettings::Config{ @@ -523,54 +523,54 @@ TEST(BalancedDegradationSettings, GetsConfigWithQpThresholds) { } TEST(BalancedDegradationSettings, GetsDefaultConfigIfOnlyHasLowThreshold) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25,vp8_qp_low:89|90|88/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); VerifyIsDefault(settings.GetConfigs()); } TEST(BalancedDegradationSettings, GetsDefaultConfigIfOnlyHasHighThreshold) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25,vp8_qp_high:90|91|92/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); VerifyIsDefault(settings.GetConfigs()); } TEST(BalancedDegradationSettings, GetsDefaultConfigIfLowEqualsHigh) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25," "vp8_qp_low:89|90|88,vp8_qp_high:90|91|88/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); VerifyIsDefault(settings.GetConfigs()); } TEST(BalancedDegradationSettings, GetsDefaultConfigIfLowGreaterThanHigh) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25," "vp8_qp_low:89|90|88,vp8_qp_high:90|91|87/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); VerifyIsDefault(settings.GetConfigs()); } TEST(BalancedDegradationSettings, GetsDefaultConfigForZeroQpValue) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25," "vp8_qp_low:89|0|88,vp8_qp_high:90|91|92/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); VerifyIsDefault(settings.GetConfigs()); } TEST(BalancedDegradationSettings, GetsVp8QpThresholds) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25," "vp8_qp_low:89|90|88,vp8_qp_high:90|91|92/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); EXPECT_EQ(89, settings.GetQpThresholds(kVideoCodecVP8, 1)->low); EXPECT_EQ(90, settings.GetQpThresholds(kVideoCodecVP8, 1)->high); EXPECT_EQ(90, settings.GetQpThresholds(kVideoCodecVP8, 1000)->high); @@ -582,11 +582,11 @@ TEST(BalancedDegradationSettings, GetsVp8QpThresholds) { } TEST(BalancedDegradationSettings, GetsVp9QpThresholds) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25," "vp9_qp_low:55|56|57,vp9_qp_high:155|156|157/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); const auto thresholds = settings.GetQpThresholds(kVideoCodecVP9, 1000); EXPECT_TRUE(thresholds); EXPECT_EQ(55, thresholds->low); @@ -594,11 +594,11 @@ TEST(BalancedDegradationSettings, GetsVp9QpThresholds) { } TEST(BalancedDegradationSettings, GetsH264QpThresholds) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25," "h264_qp_low:21|22|23,h264_qp_high:41|43|42/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); const auto thresholds = settings.GetQpThresholds(kVideoCodecH264, 2000); EXPECT_TRUE(thresholds); EXPECT_EQ(22, thresholds->low); @@ -606,11 +606,11 @@ TEST(BalancedDegradationSettings, GetsH264QpThresholds) { } TEST(BalancedDegradationSettings, GetsGenericQpThresholds) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-Video-BalancedDegradationSettings/" "pixels:1000|2000|3000,fps:5|15|25," "generic_qp_low:2|3|4,generic_qp_high:22|23|24/"); - BalancedDegradationSettings settings; + BalancedDegradationSettings settings(field_trials); const auto thresholds = settings.GetQpThresholds(kVideoCodecGeneric, 3000); EXPECT_TRUE(thresholds); EXPECT_EQ(4, thresholds->low); diff --git a/video/BUILD.gn b/video/BUILD.gn index 81d511e76c..7e016af4c5 100644 --- a/video/BUILD.gn +++ b/video/BUILD.gn @@ -67,6 +67,7 @@ rtc_library("video") { "../api:scoped_refptr", "../api:sequence_checker", "../api:transport_api", + "../api:webrtc_key_value_config", "../api/crypto:frame_decryptor_interface", "../api/crypto:options", "../api/rtc_event_log", @@ -429,6 +430,7 @@ rtc_library("video_stream_encoder_impl") { ":frame_cadence_adapter", "../api:rtp_parameters", "../api:sequence_checker", + "../api:webrtc_key_value_config", "../api/adaptation:resource_adaptation_api", "../api/task_queue:task_queue", "../api/units:data_rate", @@ -902,6 +904,7 @@ if (rtc_include_tests) { "../test:null_transport", "../test:perf_test", "../test:rtp_test_utils", + "../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 11962c04e3..84e6a3250f 100644 --- a/video/adaptation/BUILD.gn +++ b/video/adaptation/BUILD.gn @@ -36,6 +36,7 @@ rtc_library("video_adaptation") { "../../api:rtp_parameters", "../../api:scoped_refptr", "../../api:sequence_checker", + "../../api:webrtc_key_value_config", "../../api/adaptation:resource_adaptation_api", "../../api/task_queue:task_queue", "../../api/units:data_rate", diff --git a/video/adaptation/balanced_constraint.cc b/video/adaptation/balanced_constraint.cc index ec0b8e41d5..2a5484084e 100644 --- a/video/adaptation/balanced_constraint.cc +++ b/video/adaptation/balanced_constraint.cc @@ -19,8 +19,10 @@ namespace webrtc { BalancedConstraint::BalancedConstraint( - DegradationPreferenceProvider* degradation_preference_provider) + DegradationPreferenceProvider* degradation_preference_provider, + const WebRtcKeyValueConfig& field_trials) : encoder_target_bitrate_bps_(absl::nullopt), + balanced_settings_(field_trials), degradation_preference_provider_(degradation_preference_provider) { RTC_DCHECK(degradation_preference_provider_); sequence_checker_.Detach(); diff --git a/video/adaptation/balanced_constraint.h b/video/adaptation/balanced_constraint.h index 0bbd670408..ba465ab699 100644 --- a/video/adaptation/balanced_constraint.h +++ b/video/adaptation/balanced_constraint.h @@ -15,6 +15,7 @@ #include "absl/types/optional.h" #include "api/sequence_checker.h" +#include "api/webrtc_key_value_config.h" #include "call/adaptation/adaptation_constraint.h" #include "call/adaptation/degradation_preference_provider.h" #include "rtc_base/experiments/balanced_degradation_settings.h" @@ -24,8 +25,9 @@ namespace webrtc { class BalancedConstraint : public AdaptationConstraint { public: - explicit BalancedConstraint( - DegradationPreferenceProvider* degradation_preference_provider); + BalancedConstraint( + DegradationPreferenceProvider* degradation_preference_provider, + const WebRtcKeyValueConfig& field_trials); ~BalancedConstraint() override = default; void OnEncoderTargetBitrateUpdated( diff --git a/video/adaptation/video_stream_encoder_resource_manager.cc b/video/adaptation/video_stream_encoder_resource_manager.cc index 2847cdbb83..cb2ab144ed 100644 --- a/video/adaptation/video_stream_encoder_resource_manager.cc +++ b/video/adaptation/video_stream_encoder_resource_manager.cc @@ -266,11 +266,13 @@ VideoStreamEncoderResourceManager::VideoStreamEncoderResourceManager( Clock* clock, bool experiment_cpu_load_estimator, std::unique_ptr overuse_detector, - DegradationPreferenceProvider* degradation_preference_provider) + DegradationPreferenceProvider* degradation_preference_provider, + const WebRtcKeyValueConfig& field_trials) : degradation_preference_provider_(degradation_preference_provider), bitrate_constraint_(std::make_unique()), - balanced_constraint_(std::make_unique( - degradation_preference_provider_)), + balanced_constraint_( + std::make_unique(degradation_preference_provider_, + field_trials)), encode_usage_resource_( EncodeUsageResource::Create(std::move(overuse_detector))), quality_scaler_resource_(QualityScalerResource::Create()), @@ -283,6 +285,7 @@ VideoStreamEncoderResourceManager::VideoStreamEncoderResourceManager( encoder_stats_observer_(encoder_stats_observer), degradation_preference_(DegradationPreference::DISABLED), video_source_restrictions_(), + balanced_settings_(field_trials), clock_(clock), experiment_cpu_load_estimator_(experiment_cpu_load_estimator), initial_frame_dropper_( diff --git a/video/adaptation/video_stream_encoder_resource_manager.h b/video/adaptation/video_stream_encoder_resource_manager.h index 26b8db3ffa..223af4e801 100644 --- a/video/adaptation/video_stream_encoder_resource_manager.h +++ b/video/adaptation/video_stream_encoder_resource_manager.h @@ -32,6 +32,7 @@ #include "api/video_codecs/video_codec.h" #include "api/video_codecs/video_encoder.h" #include "api/video_codecs/video_encoder_config.h" +#include "api/webrtc_key_value_config.h" #include "call/adaptation/resource_adaptation_processor_interface.h" #include "call/adaptation/video_stream_adapter.h" #include "call/adaptation/video_stream_input_state_provider.h" @@ -79,7 +80,8 @@ class VideoStreamEncoderResourceManager Clock* clock, bool experiment_cpu_load_estimator, std::unique_ptr overuse_detector, - DegradationPreferenceProvider* degradation_preference_provider); + DegradationPreferenceProvider* degradation_preference_provider, + const WebRtcKeyValueConfig& field_trials); ~VideoStreamEncoderResourceManager() override; void Initialize(rtc::TaskQueue* encoder_queue); diff --git a/video/video_send_stream.cc b/video/video_send_stream.cc index e78211be36..8ab33dea68 100644 --- a/video/video_send_stream.cc +++ b/video/video_send_stream.cc @@ -114,7 +114,8 @@ std::unique_ptr CreateVideoStreamEncoder( SendStatisticsProxy* stats_proxy, const VideoStreamEncoderSettings& encoder_settings, VideoStreamEncoder::BitrateAllocationCallbackType - bitrate_allocation_callback_type) { + bitrate_allocation_callback_type, + const WebRtcKeyValueConfig& field_trials) { std::unique_ptr encoder_queue = task_queue_factory->CreateTaskQueue("EncoderQueue", TaskQueueFactory::Priority::NORMAL); @@ -123,7 +124,7 @@ std::unique_ptr CreateVideoStreamEncoder( clock, num_cpu_cores, stats_proxy, encoder_settings, std::make_unique(stats_proxy), FrameCadenceAdapterInterface::Create(clock, encoder_queue_ptr), - std::move(encoder_queue), bitrate_allocation_callback_type); + std::move(encoder_queue), bitrate_allocation_callback_type, field_trials); } } // namespace @@ -144,7 +145,8 @@ VideoSendStream::VideoSendStream( VideoEncoderConfig encoder_config, const std::map& suspended_ssrcs, const std::map& suspended_payload_states, - std::unique_ptr fec_controller) + std::unique_ptr fec_controller, + const WebRtcKeyValueConfig& field_trials) : rtp_transport_queue_(transport->GetWorkerQueue()), transport_(transport), stats_proxy_(clock, config, encoder_config.content_type), @@ -156,7 +158,8 @@ VideoSendStream::VideoSendStream( task_queue_factory, &stats_proxy_, config_.encoder_settings, - GetBitrateAllocationCallbackType(config_))), + GetBitrateAllocationCallbackType(config_), + field_trials)), encoder_feedback_( clock, config_.rtp.ssrcs, diff --git a/video/video_send_stream.h b/video/video_send_stream.h index d1afefa786..048de3d108 100644 --- a/video/video_send_stream.h +++ b/video/video_send_stream.h @@ -18,6 +18,7 @@ #include "api/fec_controller.h" #include "api/sequence_checker.h" #include "api/video/video_stream_encoder_interface.h" +#include "api/webrtc_key_value_config.h" #include "call/bitrate_allocator.h" #include "call/video_receive_stream.h" #include "call/video_send_stream.h" @@ -68,7 +69,8 @@ class VideoSendStream : public webrtc::VideoSendStream { VideoEncoderConfig encoder_config, const std::map& suspended_ssrcs, const std::map& suspended_payload_states, - std::unique_ptr fec_controller); + std::unique_ptr fec_controller, + const WebRtcKeyValueConfig& field_trials); ~VideoSendStream() override; diff --git a/video/video_stream_encoder.cc b/video/video_stream_encoder.cc index 147e0110bd..4c5975945b 100644 --- a/video/video_stream_encoder.cc +++ b/video/video_stream_encoder.cc @@ -30,6 +30,7 @@ #include "api/video/video_layers_allocation.h" #include "api/video_codecs/sdp_video_format.h" #include "api/video_codecs/video_encoder.h" +#include "api/webrtc_key_value_config.h" #include "call/adaptation/resource_adaptation_processor.h" #include "call/adaptation/video_stream_adapter.h" #include "modules/video_coding/include/video_codec_initializer.h" @@ -597,7 +598,8 @@ VideoStreamEncoder::VideoStreamEncoder( std::unique_ptr frame_cadence_adapter, std::unique_ptr encoder_queue, - BitrateAllocationCallbackType allocation_cb_type) + BitrateAllocationCallbackType allocation_cb_type, + const WebRtcKeyValueConfig& field_trials) : worker_queue_(TaskQueueBase::Current()), number_of_cores_(number_of_cores), sink_(nullptr), @@ -645,7 +647,8 @@ VideoStreamEncoder::VideoStreamEncoder( input_state_provider_(encoder_stats_observer), video_stream_adapter_( std::make_unique(&input_state_provider_, - encoder_stats_observer)), + encoder_stats_observer, + field_trials)), degradation_preference_manager_( std::make_unique( video_stream_adapter_.get())), @@ -655,7 +658,8 @@ VideoStreamEncoder::VideoStreamEncoder( clock_, settings_.experiment_cpu_load_estimator, std::move(overuse_detector), - degradation_preference_manager_.get()), + degradation_preference_manager_.get(), + field_trials), video_source_sink_controller_(/*sink=*/frame_cadence_adapter_.get(), /*source=*/nullptr), default_limits_allowed_( diff --git a/video/video_stream_encoder.h b/video/video_stream_encoder.h index c667f049f8..e89ba4a31c 100644 --- a/video/video_stream_encoder.h +++ b/video/video_stream_encoder.h @@ -28,6 +28,7 @@ #include "api/video/video_stream_encoder_settings.h" #include "api/video_codecs/video_codec.h" #include "api/video_codecs/video_encoder.h" +#include "api/webrtc_key_value_config.h" #include "call/adaptation/adaptation_constraint.h" #include "call/adaptation/resource_adaptation_processor.h" #include "call/adaptation/resource_adaptation_processor_interface.h" @@ -79,7 +80,8 @@ class VideoStreamEncoder : public VideoStreamEncoderInterface, std::unique_ptr frame_cadence_adapter, std::unique_ptr encoder_queue, - BitrateAllocationCallbackType allocation_cb_type); + BitrateAllocationCallbackType allocation_cb_type, + const WebRtcKeyValueConfig& field_trials); ~VideoStreamEncoder() override; VideoStreamEncoder(const VideoStreamEncoder&) = delete; diff --git a/video/video_stream_encoder_unittest.cc b/video/video_stream_encoder_unittest.cc index aea1988df9..03ee684cd8 100644 --- a/video/video_stream_encoder_unittest.cc +++ b/video/video_stream_encoder_unittest.cc @@ -55,15 +55,14 @@ #include "rtc_base/logging.h" #include "rtc_base/ref_counted_object.h" #include "rtc_base/synchronization/mutex.h" -#include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/metrics.h" #include "test/encoder_settings.h" #include "test/fake_encoder.h" -#include "test/field_trial.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_proxy_factory.h" #include "video/frame_cadence_adapter.h" @@ -375,7 +374,8 @@ class VideoStreamEncoderUnderTest : public VideoStreamEncoder { SendStatisticsProxy* stats_proxy, const VideoStreamEncoderSettings& settings, VideoStreamEncoder::BitrateAllocationCallbackType - allocation_callback_type) + allocation_callback_type, + const WebRtcKeyValueConfig& field_trials) : VideoStreamEncoder(time_controller->GetClock(), 1 /* number_of_cores */, stats_proxy, @@ -385,7 +385,8 @@ class VideoStreamEncoderUnderTest : public VideoStreamEncoder { new CpuOveruseDetectorProxy(stats_proxy)), std::move(cadence_adapter), std::move(encoder_queue), - allocation_callback_type), + allocation_callback_type, + field_trials), time_controller_(time_controller), fake_cpu_resource_(FakeResource::Create("FakeResource[CPU]")), fake_quality_resource_(FakeResource::Create("FakeResource[QP]")), @@ -678,7 +679,8 @@ class SimpleVideoStreamEncoderFactory { std::unique_ptr CreateWithEncoderQueue( std::unique_ptr zero_hertz_adapter, - std::unique_ptr encoder_queue) { + std::unique_ptr encoder_queue, + const WebRtcKeyValueConfig* field_trials = nullptr) { auto result = std::make_unique( time_controller_.GetClock(), /*number_of_cores=*/1, @@ -686,7 +688,8 @@ class SimpleVideoStreamEncoderFactory { std::make_unique(/*stats_proxy=*/nullptr), std::move(zero_hertz_adapter), std::move(encoder_queue), VideoStreamEncoder::BitrateAllocationCallbackType:: - kVideoBitrateAllocation); + kVideoBitrateAllocation, + field_trials ? *field_trials : field_trials_); result->SetSink(&sink_, /*rotation_applied=*/false); return result; } @@ -730,6 +733,7 @@ class SimpleVideoStreamEncoderFactory { } }; + test::ScopedKeyValueConfig field_trials_; GlobalSimulatedTimeController time_controller_{Timestamp::Millis(0)}; std::unique_ptr task_queue_factory_{ time_controller_.CreateTaskQueueFactory()}; @@ -852,7 +856,7 @@ class VideoStreamEncoderTest : public ::testing::Test { video_stream_encoder_ = std::make_unique( &time_controller_, std::move(cadence_adapter), std::move(encoder_queue), stats_proxy_.get(), video_send_config_.encoder_settings, - allocation_callback_type); + allocation_callback_type, field_trials_); video_stream_encoder_->SetSink(&sink_, /*rotation_applied=*/false); video_stream_encoder_->SetSource( &video_source_, webrtc::DegradationPreference::MAINTAIN_FRAMERATE); @@ -1568,6 +1572,7 @@ class VideoStreamEncoderTest : public ::testing::Test { return time_controller_.GetTaskQueueFactory(); } + test::ScopedKeyValueConfig field_trials_; GlobalSimulatedTimeController time_controller_{Timestamp::Micros(1234)}; VideoSendStream::Config video_send_config_; VideoEncoderConfig video_encoder_config_; @@ -4119,7 +4124,8 @@ class BalancedDegradationTest : public VideoStreamEncoderTest { }; TEST_F(BalancedDegradationTest, AdaptDownTwiceIfMinFpsDiffLtThreshold) { - test::ScopedFieldTrials field_trials( + test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-Video-BalancedDegradationSettings/" "pixels:57600|129600|230400,fps:7|10|24,fps_diff:1|1|1/"); SetupTest(); @@ -4143,7 +4149,8 @@ TEST_F(BalancedDegradationTest, AdaptDownTwiceIfMinFpsDiffLtThreshold) { } TEST_F(BalancedDegradationTest, AdaptDownOnceIfFpsDiffGeThreshold) { - test::ScopedFieldTrials field_trials( + test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-Video-BalancedDegradationSettings/" "pixels:57600|129600|230400,fps:7|10|24,fps_diff:1|1|1/"); SetupTest(); @@ -4166,7 +4173,8 @@ TEST_F(BalancedDegradationTest, AdaptDownOnceIfFpsDiffGeThreshold) { } TEST_F(BalancedDegradationTest, AdaptDownUsesCodecSpecificFps) { - test::ScopedFieldTrials field_trials( + test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-Video-BalancedDegradationSettings/" "pixels:57600|129600|230400,fps:7|10|24,vp8_fps:8|11|22/"); SetupTest(); @@ -4184,7 +4192,8 @@ TEST_F(BalancedDegradationTest, AdaptDownUsesCodecSpecificFps) { } TEST_F(BalancedDegradationTest, NoAdaptUpIfBwEstimateIsLessThanMinBitrate) { - test::ScopedFieldTrials field_trials( + test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-Video-BalancedDegradationSettings/" "pixels:57600|129600|230400,fps:7|10|14,kbps:0|0|425/"); SetupTest(); @@ -4233,7 +4242,8 @@ TEST_F(BalancedDegradationTest, NoAdaptUpIfBwEstimateIsLessThanMinBitrate) { TEST_F(BalancedDegradationTest, InitialFrameDropAdaptsFpsAndResolutionInOneStep) { - test::ScopedFieldTrials field_trials( + test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-Video-BalancedDegradationSettings/" "pixels:57600|129600|230400,fps:7|24|24/"); SetupTest(); @@ -4264,7 +4274,8 @@ TEST_F(BalancedDegradationTest, TEST_F(BalancedDegradationTest, NoAdaptUpInResolutionIfBwEstimateIsLessThanMinBitrate) { - test::ScopedFieldTrials field_trials( + test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-Video-BalancedDegradationSettings/" "pixels:57600|129600|230400,fps:7|10|14,kbps_res:0|0|435/"); SetupTest(); @@ -4318,7 +4329,8 @@ TEST_F(BalancedDegradationTest, TEST_F(BalancedDegradationTest, NoAdaptUpInFpsAndResolutionIfBwEstimateIsLessThanMinBitrate) { - test::ScopedFieldTrials field_trials( + 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/"); SetupTest(); @@ -5199,7 +5211,8 @@ TEST_F(VideoStreamEncoderTest, TemporalLayersDisabledIfNotSupported) { } TEST_F(VideoStreamEncoderTest, VerifyBitrateAllocationForTwoStreams) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-Video-QualityScalerSettings/" "initial_bitrate_interval_ms:1000,initial_bitrate_factor:0.2/"); // Reset encoder for field trials to take effect. @@ -5502,7 +5515,8 @@ TEST_F(VideoStreamEncoderTest, InitialFrameDropOffWhenEncoderDisabledScaling) { } TEST_F(VideoStreamEncoderTest, InitialFrameDropActivatesWhenBweDrops) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-Video-QualityScalerSettings/" "initial_bitrate_interval_ms:1000,initial_bitrate_factor:0.2/"); // Reset encoder for field trials to take effect. @@ -5542,7 +5556,8 @@ TEST_F(VideoStreamEncoderTest, InitialFrameDropActivatesWhenBweDrops) { TEST_F(VideoStreamEncoderTest, InitialFrameDropNotReactivatedWhenBweDropsWhenScalingDisabled) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-Video-QualityScalerSettings/" "initial_bitrate_interval_ms:1000,initial_bitrate_factor:0.2/"); fake_encoder_.SetQualityScaling(false); @@ -5833,8 +5848,8 @@ TEST_F(VideoStreamEncoderTest, } TEST_F(VideoStreamEncoderTest, DefaultMaxAndMinBitratesNotUsedIfDisabled) { - webrtc::test::ScopedFieldTrials field_trials( - "WebRTC-DefaultBitrateLimitsKillSwitch/Enabled/"); + webrtc::test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-DefaultBitrateLimitsKillSwitch/Enabled/"); VideoEncoderConfig video_encoder_config; test::FillEncoderConfiguration(PayloadStringToCodecType("VP9"), 1, &video_encoder_config); @@ -6088,7 +6103,8 @@ TEST_F(VideoStreamEncoderTest, } TEST_F(VideoStreamEncoderTest, RampsUpInQualityWhenBwIsHigh) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-Video-QualityRampupSettings/" "min_pixels:921600,min_duration_ms:2000/"); @@ -6164,8 +6180,8 @@ TEST_F(VideoStreamEncoderTest, RampsUpInQualityWhenBwIsHigh) { TEST_F(VideoStreamEncoderTest, QualityScalerAdaptationsRemovedWhenQualityScalingDisabled) { - webrtc::test::ScopedFieldTrials field_trials( - "WebRTC-Video-QualityScaling/Disabled/"); + webrtc::test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-Video-QualityScaling/Disabled/"); AdaptingFrameForwarder source(&time_controller_); source.set_adaptation_enabled(true); video_stream_encoder_->SetSource(&source, @@ -7743,7 +7759,8 @@ TEST_F(VideoStreamEncoderTest, } TEST_F(VideoStreamEncoderTest, AutomaticAnimationDetection) { - test::ScopedFieldTrials field_trials( + test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-AutomaticAnimationDetectionScreenshare/" "enabled:true,min_fps:20,min_duration_ms:1000,min_area_ratio:0.8/"); const int kFramerateFps = 30; @@ -8058,8 +8075,8 @@ TEST_F(VideoStreamEncoderTest, QpAbsent_QpParsed) { } TEST_F(VideoStreamEncoderTest, QpAbsentParsingDisabled_QpAbsent) { - webrtc::test::ScopedFieldTrials field_trials( - "WebRTC-QpParsingKillSwitch/Enabled/"); + webrtc::test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-QpParsingKillSwitch/Enabled/"); ResetEncoder("VP8", 1, 1, 1, false); @@ -8904,6 +8921,8 @@ TEST(VideoStreamEncoderSimpleTest, CreateDestroy) { std::unique_ptr encoder_queue(new SuperLazyTaskQueue()); + test::ScopedKeyValueConfig field_trials; + // Construct a VideoStreamEncoder instance and let it go out of scope without // doing anything else (including calling Stop()). This should be fine since // the posted init task will simply be deleted. @@ -8912,7 +8931,8 @@ TEST(VideoStreamEncoderSimpleTest, CreateDestroy) { std::make_unique(stats_proxy.get()), std::move(adapter), std::move(encoder_queue), VideoStreamEncoder::BitrateAllocationCallbackType:: - kVideoBitrateAllocation); + kVideoBitrateAllocation, + field_trials); } TEST(VideoStreamEncoderFrameCadenceTest, ActivatesFrameCadenceOnContentType) { @@ -9177,14 +9197,15 @@ TEST(VideoStreamEncoderFrameCadenceTest, "EncoderQueue", TaskQueueFactory::Priority::NORMAL); // Enables zero-hertz mode. - test::ScopedFieldTrials field_trials("WebRTC-ZeroHertzScreenshare/Enabled/"); + test::ScopedKeyValueConfig field_trials( + "WebRTC-ZeroHertzScreenshare/Enabled/"); auto adapter = FrameCadenceAdapterInterface::Create( factory.GetTimeController()->GetClock(), encoder_queue.get()); FrameCadenceAdapterInterface* adapter_ptr = adapter.get(); MockVideoSourceInterface mock_source; auto video_stream_encoder = factory.CreateWithEncoderQueue( - std::move(adapter), std::move(encoder_queue)); + std::move(adapter), std::move(encoder_queue), &field_trials); video_stream_encoder->SetSource( &mock_source, webrtc::DegradationPreference::MAINTAIN_FRAMERATE); From e9c9a519416af8b0b6dfa74bc3fa2e0cbe4b133b Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Wed, 9 Mar 2022 14:02:01 -0800 Subject: [PATCH 140/847] Roll chromium_revision 330454c702..3f2e509065 (979310:979444) Change log: https://chromium.googlesource.com/chromium/src/+log/330454c702..3f2e509065 Full diff: https://chromium.googlesource.com/chromium/src/+/330454c702..3f2e509065 Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/86b036f2ce..897d5d8856 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/6d6a1eaf7a..7327550c04 * src/buildtools/linux64: git_revision:d7c2209cebcfe37f46dba7be4e1a7000ffc342fb..git_revision:46f94b5a7f5527b5d7ef57271d3e9447a65e22ac * src/buildtools/mac: git_revision:d7c2209cebcfe37f46dba7be4e1a7000ffc342fb..git_revision:46f94b5a7f5527b5d7ef57271d3e9447a65e22ac * src/buildtools/win: git_revision:d7c2209cebcfe37f46dba7be4e1a7000ffc342fb..git_revision:46f94b5a7f5527b5d7ef57271d3e9447a65e22ac * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/f02733c9d4..0d784cd6f8 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/f596ce142c..f6968388f8 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/a4ba4d030a..67e0f1a49a * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/8edc960e9a..1b4881c930 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/63cb382ead..9a09a4b76e DEPS diff: https://chromium.googlesource.com/chromium/src/+/330454c702..3f2e509065/DEPS No update to Clang. BUG=None Change-Id: I006cd2e07b2439848cf4c4c9fd4ee0cfe8ea3ccb Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254400 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36166} --- DEPS | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/DEPS b/DEPS index 0870f67788..6ca6981307 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': '330454c702f9e43b585625a0d9974087d135a739', + 'chromium_revision': '3f2e509065ab06dd5eb5c10cdbedf24e9e1ac643', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@86b036f2ce633df9cd8b01934a9d332c41b0b23a', + 'https://chromium.googlesource.com/chromium/src/base@897d5d8856f6e81f9f0485686ca17ee57cfb266f', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@6d6a1eaf7aedcd420a33e9dbb88d4d8ad8574093', + 'https://chromium.googlesource.com/chromium/src/build@7327550c04d15b08b63ca56113a323f4809cdbad', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@113dd1badbcbffea108a8c95ac7c89c22bfd25f3', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,19 +34,19 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@f02733c9d4d4095fda307d1fc87dbb72b0ee83f7', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@0d784cd6f8988694b5979fe9b9ee01b95e9a68df', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@f596ce142c4db1f6b860a28f214f24384bab700b', + 'https://chromium.googlesource.com/chromium/src/testing@f6968388f87ca25207622cd2a991d4d6d8038ef7', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@a4ba4d030afa7c02d103682927829bb1ce352d30', + 'https://chromium.googlesource.com/chromium/src/third_party@67e0f1a49a80fb5e22af539901a7e6473901c622', 'src/buildtools/linux64': { 'packages': [ { 'package': 'gn/gn/linux-amd64', - 'version': 'git_revision:d7c2209cebcfe37f46dba7be4e1a7000ffc342fb', + 'version': 'git_revision:46f94b5a7f5527b5d7ef57271d3e9447a65e22ac', } ], 'dep_type': 'cipd', @@ -56,7 +56,7 @@ deps = { 'packages': [ { 'package': 'gn/gn/mac-${{arch}}', - 'version': 'git_revision:d7c2209cebcfe37f46dba7be4e1a7000ffc342fb', + 'version': 'git_revision:46f94b5a7f5527b5d7ef57271d3e9447a65e22ac', } ], 'dep_type': 'cipd', @@ -66,7 +66,7 @@ deps = { 'packages': [ { 'package': 'gn/gn/windows-amd64', - 'version': 'git_revision:d7c2209cebcfe37f46dba7be4e1a7000ffc342fb', + 'version': 'git_revision:46f94b5a7f5527b5d7ef57271d3e9447a65e22ac', } ], 'dep_type': 'cipd', @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@8edc960e9acbaedbff28e323e77a4129817266b3', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@1b4881c9300a81bac80eace84caa2c10c2e41fa5', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@63cb382ead5cd71516bc9c210f9854becacfab6c', + 'https://chromium.googlesource.com/chromium/src/tools@9a09a4b76e72d6fab91496e808be0dbc7c0fbed4', 'src/third_party/accessibility_test_framework': { 'packages': [ From e39955ede6523aacd772edbc9807a89811e65bdd Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Wed, 9 Mar 2022 20:03:09 -0800 Subject: [PATCH 141/847] Update WebRTC code version (2022-03-10T04:03:07). Bug: None Change-Id: I89f313c9330a0ae03ccb5acfb10c37ac12b47097 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254440 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36167} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index 801455c5c5..7e90720e65 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 2022-03-09T04:01:53"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-03-10T04:03:07"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From 03fad386d528822209d084982f58e4fef2519a8b Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Thu, 10 Mar 2022 07:30:31 +0000 Subject: [PATCH 142/847] Add empty build targets for breakup of rtc_pc_base This is an initial step, defining targets so that external users can add dependencies. Bug: webrtc:13805 Change-Id: I5d2caf2fd746d459f747c390eb783bb4d6f179ef Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254480 Reviewed-by: Mirko Bonadei Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#36168} --- pc/BUILD.gn | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/pc/BUILD.gn b/pc/BUILD.gn index f88226a51c..4ea04610f5 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -121,10 +121,40 @@ rtc_library("rtc_pc_base") { ] deps = [ + ":channel", + ":channel_interface", + ":channel_manager", + ":dtls_srtp_transport", + ":dtls_transport", + ":external_hmac", + ":ice_transport", + ":jsep_transport", + ":jsep_transport_collection", + ":jsep_transport_controller", ":media_protocol_names", + ":media_session", + ":media_stream_proxy", + ":media_stream_track_proxy", + ":peer_connection_factory_proxy", + ":peer_connection_proxy", ":proxy", + ":rtcp_mux_filter", + ":rtp_media_utils", + ":rtp_receiver_proxy", + ":rtp_sender_proxy", + ":rtp_transport", + ":rtp_transport_internal", + ":sctp_data_channel_transport", + ":sctp_transport", + ":sctp_utils", ":session_description", ":simulcast_description", + ":srtp_filter", + ":srtp_session", + ":srtp_transport", + ":transport_stats", + ":used_ids", + ":video_track_source_proxy", "../api:array_view", "../api:async_dns_resolver", "../api:audio_options_api", @@ -208,6 +238,98 @@ rtc_library("rtc_pc_base") { public_configs = [ ":rtc_pc_config" ] } +# Targets in preparation for breaking up rtc_pc_base target +rtc_source_set("channel") { + visibility = [ ":*" ] +} +rtc_source_set("channel_interface") { + visibility = [ ":*" ] +} +rtc_source_set("channel_manager") { + visibility = [ ":*" ] +} +rtc_source_set("dtls_srtp_transport") { + visibility = [ ":*" ] +} +rtc_source_set("dtls_transport") { + visibility = [ ":*" ] +} +rtc_source_set("external_hmac") { + visibility = [ ":*" ] +} +rtc_source_set("ice_transport") { + visibility = [ ":*" ] +} +rtc_source_set("jsep_transport") { + visibility = [ ":*" ] +} +rtc_source_set("jsep_transport_collection") { + visibility = [ ":*" ] +} +rtc_source_set("jsep_transport_controller") { + visibility = [ ":*" ] +} +rtc_source_set("media_session") { + visibility = [ ":*" ] +} +rtc_source_set("media_stream_proxy") { + visibility = [ ":*" ] +} +rtc_source_set("media_stream_track_proxy") { + visibility = [ ":*" ] +} +rtc_source_set("peer_connection_factory_proxy") { + visibility = [ ":*" ] +} +rtc_source_set("peer_connection_proxy") { + visibility = [ ":*" ] +} +rtc_source_set("rtcp_mux_filter") { + visibility = [ ":*" ] +} +rtc_source_set("rtp_media_utils") { + visibility = [ ":*" ] +} +rtc_source_set("rtp_receiver_proxy") { + visibility = [ ":*" ] +} +rtc_source_set("rtp_sender_proxy") { + visibility = [ ":*" ] +} +rtc_source_set("rtp_transport") { + visibility = [ ":*" ] +} +rtc_source_set("rtp_transport_internal") { + visibility = [ ":*" ] +} +rtc_source_set("sctp_data_channel_transport") { + visibility = [ ":*" ] +} +rtc_source_set("sctp_transport") { + visibility = [ ":*" ] +} +rtc_source_set("sctp_utils") { + visibility = [ ":*" ] +} +rtc_source_set("srtp_filter") { + visibility = [ ":*" ] +} +rtc_source_set("srtp_session") { + visibility = [ ":*" ] +} +rtc_source_set("srtp_transport") { + visibility = [ ":*" ] +} +rtc_source_set("transport_stats") { + visibility = [ ":*" ] +} +rtc_source_set("used_ids") { + visibility = [ ":*" ] +} +rtc_source_set("video_track_source_proxy") { + visibility = [ ":*" ] +} + rtc_source_set("session_description") { # TODO(bugs.webrtc.org/13661): Reduce visibility if possible visibility = [ "*" ] # Used by Chrome and others From d9f684675795d3c63a1b59e1b36e306abb943fcd Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Thu, 10 Mar 2022 10:09:51 +0000 Subject: [PATCH 143/847] Break out -proxy targets from rtc_pc_base Bug: webrtc:13805 Change-Id: Ib9a126c1a12ee8f4a8ba7f888224a862643cabcc Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254580 Reviewed-by: Mirko Bonadei Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#36169} --- pc/BUILD.gn | 59 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/pc/BUILD.gn b/pc/BUILD.gn index 4ea04610f5..bc8234af42 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -88,16 +88,10 @@ rtc_library("rtc_pc_base") { "jsep_transport_controller.h", "media_session.cc", "media_session.h", - "media_stream_proxy.h", - "media_stream_track_proxy.h", - "peer_connection_factory_proxy.h", - "peer_connection_proxy.h", "rtcp_mux_filter.cc", "rtcp_mux_filter.h", "rtp_media_utils.cc", "rtp_media_utils.h", - "rtp_receiver_proxy.h", - "rtp_sender_proxy.h", "rtp_transport.cc", "rtp_transport.h", "rtp_transport_internal.h", @@ -274,15 +268,35 @@ rtc_source_set("media_session") { } rtc_source_set("media_stream_proxy") { visibility = [ ":*" ] + sources = [ "media_stream_proxy.h" ] + deps = [ + ":proxy", + "../api:media_stream_interface", + ] } rtc_source_set("media_stream_track_proxy") { visibility = [ ":*" ] + sources = [ "media_stream_track_proxy.h" ] + deps = [ + ":proxy", + "../api:media_stream_interface", + ] } rtc_source_set("peer_connection_factory_proxy") { visibility = [ ":*" ] + sources = [ "peer_connection_factory_proxy.h" ] + deps = [ + ":proxy", + "../api:libjingle_peerconnection_api", + ] } rtc_source_set("peer_connection_proxy") { visibility = [ ":*" ] + sources = [ "peer_connection_proxy.h" ] + deps = [ + ":proxy", + "../api:libjingle_peerconnection_api", + ] } rtc_source_set("rtcp_mux_filter") { visibility = [ ":*" ] @@ -292,9 +306,19 @@ rtc_source_set("rtp_media_utils") { } rtc_source_set("rtp_receiver_proxy") { visibility = [ ":*" ] + sources = [ "rtp_receiver_proxy.h" ] + deps = [ + ":proxy", + "../api:libjingle_peerconnection_api", + ] } rtc_source_set("rtp_sender_proxy") { visibility = [ ":*" ] + sources = [ "rtp_sender_proxy.h" ] + deps = [ + ":proxy", + "../api:libjingle_peerconnection_api", + ] } rtc_source_set("rtp_transport") { visibility = [ ":*" ] @@ -666,7 +690,9 @@ rtc_source_set("rtc_stats_collector") { ":rtc_pc_base", ":rtc_stats_traversal", ":rtp_receiver", + ":rtp_receiver_proxy", ":rtp_sender", + ":rtp_sender_proxy", ":rtp_transceiver", ":sctp_data_channel", ":track_media_info_map", @@ -733,12 +759,15 @@ rtc_source_set("sdp_offer_answer") { ":ice_server_parsing", ":media_stream", ":media_stream_observer", + ":media_stream_proxy", ":peer_connection_internal", ":peer_connection_message_handler", ":rtc_pc_base", ":rtc_stats_collector", ":rtp_receiver", + ":rtp_receiver_proxy", ":rtp_sender", + ":rtp_sender_proxy", ":rtp_transceiver", ":rtp_transmission_manager", ":sdp_state_provider", @@ -821,7 +850,9 @@ rtc_source_set("peer_connection") { ":rtc_pc_base", ":rtc_stats_collector", ":rtp_receiver", + ":rtp_receiver_proxy", ":rtp_sender", + ":rtp_sender_proxy", ":rtp_transceiver", ":rtp_transmission_manager", ":sctp_data_channel", @@ -929,6 +960,8 @@ rtc_source_set("stats_collector") { ":peer_connection_internal", ":rtc_pc_base", ":rtp_receiver", + ":rtp_receiver_proxy", + ":rtp_sender_proxy", ":rtp_transceiver", ":stats_collector_interface", "../api:libjingle_peerconnection_api", @@ -1094,7 +1127,11 @@ rtc_source_set("peer_connection_factory") { ] deps = [ ":local_audio_source", + ":media_stream_proxy", + ":media_stream_track_proxy", ":peer_connection", + ":peer_connection_factory_proxy", + ":peer_connection_proxy", "../api:audio_options_api", "../api:callfactory_api", "../api:fec_controller_api", @@ -1184,7 +1221,9 @@ rtc_library("rtp_transceiver") { ":rtc_pc_base", ":rtp_parameters_conversion", ":rtp_receiver", + ":rtp_receiver_proxy", ":rtp_sender", + ":rtp_sender_proxy", ":session_description", "../api:array_view", "../api:libjingle_peerconnection_api", @@ -1222,7 +1261,9 @@ rtc_library("rtp_transmission_manager") { ":audio_rtp_receiver", ":rtc_pc_base", ":rtp_receiver", + ":rtp_receiver_proxy", ":rtp_sender", + ":rtp_sender_proxy", ":rtp_transceiver", ":stats_collector_interface", ":transceiver_list", @@ -1277,6 +1318,7 @@ rtc_library("rtp_receiver") { ] deps = [ ":media_stream", + ":media_stream_proxy", ":rtc_pc_base", ":video_track_source", "../api:libjingle_peerconnection_api", @@ -1309,6 +1351,7 @@ rtc_library("audio_rtp_receiver") { ":audio_track", ":jitter_buffer_delay", ":media_stream", + ":media_stream_track_proxy", ":remote_audio_source", ":rtc_pc_base", ":rtp_receiver", @@ -1345,6 +1388,7 @@ rtc_library("video_rtp_receiver") { deps = [ ":jitter_buffer_delay", ":media_stream", + ":media_stream_track_proxy", ":rtc_pc_base", ":rtp_receiver", ":video_rtp_track_source", @@ -1852,6 +1896,7 @@ if (rtc_include_tests && !build_with_chromium) { ":peer_connection", ":peer_connection_factory", ":peer_connection_factory", + ":peer_connection_proxy", ":peerconnection", ":proxy", ":remote_audio_source", @@ -1861,6 +1906,7 @@ if (rtc_include_tests && !build_with_chromium) { ":rtp_parameters_conversion", ":rtp_receiver", ":rtp_sender", + ":rtp_sender_proxy", ":rtp_transceiver", ":sctp_data_channel", ":sdp_serializer", @@ -2042,6 +2088,7 @@ if (rtc_include_tests && !build_with_chromium) { ":pc_test_utils", ":peer_connection", ":peer_connection_factory", + ":peer_connection_proxy", ":peerconnection", ":remote_audio_source", ":rtc_pc_base", From c2a2bef4f7e11d52c56829ed3a9132e6d526203a Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Thu, 10 Mar 2022 11:28:38 +0000 Subject: [PATCH 144/847] Add a header-reduction argument to IWYU This allows to delete non-needed headers from .h files. Ran this on peer_connection.cc to demonstrate. Bug: none Change-Id: I69ce48be25a9778297e521282898c6ac31e7ea6c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254600 Reviewed-by: Mirko Bonadei Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#36170} --- pc/BUILD.gn | 2 +- pc/peer_connection.cc | 2 -- pc/peer_connection.h | 16 +--------------- tools_webrtc/iwyu/apply-iwyu | 20 +++++++++++++++++--- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/pc/BUILD.gn b/pc/BUILD.gn index bc8234af42..da78a25158 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -865,7 +865,6 @@ rtc_source_set("peer_connection") { ":usage_pattern", ":webrtc_session_description_factory", "../api:async_dns_resolver", - "../api:audio_options_api", "../api:libjingle_logging_api", "../api:libjingle_peerconnection_api", "../api:media_stream_interface", @@ -876,6 +875,7 @@ rtc_source_set("peer_connection") { "../api:rtp_transceiver_direction", "../api:scoped_refptr", "../api:sequence_checker", + "../api:webrtc_key_value_config", "../api/adaptation:resource_adaptation_api", "../api/crypto:options", "../api/rtc_event_log:rtc_event_log", diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc index ec6bef32f7..fb1f86c007 100644 --- a/pc/peer_connection.cc +++ b/pc/peer_connection.cc @@ -17,7 +17,6 @@ #include #include #include -#include #include #include "absl/algorithm/container.h" @@ -26,7 +25,6 @@ #include "api/jsep_ice_candidate.h" #include "api/rtp_parameters.h" #include "api/rtp_transceiver_direction.h" -#include "api/transport/webrtc_key_value_config.h" #include "api/uma_metrics.h" #include "api/video/video_codec_constants.h" #include "call/audio_state.h" diff --git a/pc/peer_connection.h b/pc/peer_connection.h index a6e4510b47..95bdfba3b7 100644 --- a/pc/peer_connection.h +++ b/pc/peer_connection.h @@ -18,14 +18,11 @@ #include #include #include -#include #include #include "absl/types/optional.h" #include "api/adaptation/resource.h" #include "api/async_dns_resolver.h" -#include "api/async_resolver_factory.h" -#include "api/audio_options.h" #include "api/candidate.h" #include "api/crypto/crypto_options.h" #include "api/data_channel_interface.h" @@ -34,12 +31,10 @@ #include "api/jsep.h" #include "api/media_stream_interface.h" #include "api/media_types.h" -#include "api/packet_socket_factory.h" #include "api/peer_connection_interface.h" #include "api/rtc_error.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/rtc_event_log_output.h" -#include "api/rtp_parameters.h" #include "api/rtp_receiver_interface.h" #include "api/rtp_sender_interface.h" #include "api/rtp_transceiver_interface.h" @@ -53,15 +48,12 @@ #include "api/transport/data_channel_transport_interface.h" #include "api/transport/enums.h" #include "api/turn_customizer.h" -#include "api/video/video_bitrate_allocator_factory.h" +#include "api/webrtc_key_value_config.h" #include "call/call.h" -#include "media/base/media_channel.h" -#include "media/base/media_engine.h" #include "p2p/base/ice_transport_internal.h" #include "p2p/base/port.h" #include "p2p/base/port_allocator.h" #include "p2p/base/transport_description.h" -#include "pc/channel.h" #include "pc/channel_interface.h" #include "pc/channel_manager.h" #include "pc/connection_context.h" @@ -72,23 +64,18 @@ #include "pc/peer_connection_internal.h" #include "pc/peer_connection_message_handler.h" #include "pc/rtc_stats_collector.h" -#include "pc/rtp_receiver.h" -#include "pc/rtp_sender.h" #include "pc/rtp_transceiver.h" #include "pc/rtp_transmission_manager.h" #include "pc/rtp_transport_internal.h" #include "pc/sctp_data_channel.h" -#include "pc/sctp_transport.h" #include "pc/sdp_offer_answer.h" #include "pc/session_description.h" #include "pc/stats_collector.h" -#include "pc/stream_collection.h" #include "pc/transceiver_list.h" #include "pc/transport_stats.h" #include "pc/usage_pattern.h" #include "rtc_base/checks.h" #include "rtc_base/copy_on_write_buffer.h" -#include "rtc_base/network/sent_packet.h" #include "rtc_base/rtc_certificate.h" #include "rtc_base/ssl_certificate.h" #include "rtc_base/ssl_stream_adapter.h" @@ -96,7 +83,6 @@ #include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread.h" #include "rtc_base/thread_annotations.h" -#include "rtc_base/unique_id_generator.h" #include "rtc_base/weak_ptr.h" namespace webrtc { diff --git a/tools_webrtc/iwyu/apply-iwyu b/tools_webrtc/iwyu/apply-iwyu index 7f2809b769..794756ba47 100755 --- a/tools_webrtc/iwyu/apply-iwyu +++ b/tools_webrtc/iwyu/apply-iwyu @@ -17,7 +17,7 @@ # Set this to 1 to get more debug information. # Set this to 2 to also get a dump of the iwyu tool output. -DEBUG=2 +DEBUG=0 set -e if [ $DEBUG -gt 0 ]; then @@ -26,6 +26,7 @@ fi IWYU_TOOL="${IWYU_TOOL:-/usr/bin/iwyu_tool}" FIX_INCLUDE="${FIX_INCLUDE:-/usr/bin/fix_include}" +FIX_INCLUDE_ARGS='' IWYU_TOOL_DIR="${IWYU_TOOL_DIR:-tools_webrtc/iwyu}" COMPILE_COMMANDS='' @@ -34,9 +35,22 @@ error() { exit 1 } -while getopts 'c:r' opts; do +usage() { + echo "Usage: $0 [ -c compile-commands-file.json ] [-r] file.cc" + echo "Runs the IWYU and fix-include on a CC file and its associated .h file" + echo "Arguments:" + echo " -c compile-commands: Compiler command file" + echo " -r : Remove non-required includes from .h file" + echo " -h : Print this help message" + echo "(default command file: out/Default/compile_commands.json - this" + echo "will be generated if not present" +} + +while getopts 'c:rh' opts; do case "${opts}" in c) COMPILE_COMMANDS="${OPTARG}" ;; + r) FIX_INCLUDE_ARGS="${FIX_INCLUDE_ARGS} --nosafe_headers" ;; + h) usage; exit 1 ;; *) error "Unexpected option ${opts}" ;; esac done @@ -84,7 +98,7 @@ else # In compile_commands.json, the file name is recorded # as a relative path to the build directory. pushd "$(dirname "$COMPILE_COMMANDS")" || error "pushd failed" - "$FIX_INCLUDE" < /tmp/includefixes$$ || echo "Some files modified" + "$FIX_INCLUDE" $FIX_INCLUDE_ARGS < /tmp/includefixes$$ || echo "Some files modified" popd rm /tmp/includefixes$$ fi From 09d488b352915fe1c28f140d59ad44abb60423be Mon Sep 17 00:00:00 2001 From: philipel Date: Thu, 10 Mar 2022 10:51:49 +0100 Subject: [PATCH 145/847] Rename corresponding `libaom_av1_encoder_if_supported` java buildtargets. This is in preparation to introduce new java buildtargets that will use the `libaom_av1_encoder` buildtarget instead. bug: webrtc:13573 Change-Id: I23e80653943ede576657acc17bcc5602cb0a4d5d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254540 Reviewed-by: Sergey Silkin Commit-Queue: Philip Eliasson Cr-Commit-Position: refs/heads/main@{#36171} --- sdk/android/BUILD.gn | 12 ++++++------ ...Encoder.java => LibaomAv1EncoderIfSupported.java} | 2 +- .../api/org/webrtc/SoftwareVideoEncoderFactory.java | 6 +++--- sdk/android/src/jni/libaom_av1_codec.cc | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) rename sdk/android/api/org/webrtc/{LibaomAv1Encoder.java => LibaomAv1EncoderIfSupported.java} (90%) diff --git a/sdk/android/BUILD.gn b/sdk/android/BUILD.gn index e0b8b0c81c..88a7d12d16 100644 --- a/sdk/android/BUILD.gn +++ b/sdk/android/BUILD.gn @@ -503,7 +503,7 @@ if (is_android) { visibility = [ "*" ] sources = [ "api/org/webrtc/LibaomAv1Decoder.java", - "api/org/webrtc/LibaomAv1Encoder.java", + "api/org/webrtc/LibaomAv1EncoderIfSupported.java", ] deps = [ ":base_java", @@ -848,13 +848,13 @@ if (current_os == "linux" || is_android) { ] } - rtc_library("libaom_av1_jni") { + rtc_library("libaom_av1_jni_if_supported") { visibility = [ "*" ] allow_poison = [ "software_video_codecs" ] sources = [ "src/jni/libaom_av1_codec.cc" ] deps = [ ":base_jni", - ":generated_libaom_av1_jni", + ":generated_libaom_av1_jni_if_supported", ":video_jni", "../../modules/video_coding/codecs/av1:libaom_av1_decoder", "../../modules/video_coding/codecs/av1:libaom_av1_encoder_if_supported", @@ -877,7 +877,7 @@ if (current_os == "linux" || is_android) { visibility = [ "*" ] allow_poison = [ "software_video_codecs" ] deps = [ - ":libaom_av1_jni", + ":libaom_av1_jni_if_supported", ":libvpx_vp8_jni", ":libvpx_vp9_jni", ] @@ -1313,10 +1313,10 @@ if (current_os == "linux" || is_android) { jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h" } - generate_jni("generated_libaom_av1_jni") { + generate_jni("generated_libaom_av1_jni_if_supported") { sources = [ "api/org/webrtc/LibaomAv1Decoder.java", - "api/org/webrtc/LibaomAv1Encoder.java", + "api/org/webrtc/LibaomAv1EncoderIfSupported.java", ] namespace = "webrtc::jni" diff --git a/sdk/android/api/org/webrtc/LibaomAv1Encoder.java b/sdk/android/api/org/webrtc/LibaomAv1EncoderIfSupported.java similarity index 90% rename from sdk/android/api/org/webrtc/LibaomAv1Encoder.java rename to sdk/android/api/org/webrtc/LibaomAv1EncoderIfSupported.java index 26648c589e..2d5cff79ae 100644 --- a/sdk/android/api/org/webrtc/LibaomAv1Encoder.java +++ b/sdk/android/api/org/webrtc/LibaomAv1EncoderIfSupported.java @@ -10,7 +10,7 @@ package org.webrtc; -public class LibaomAv1Encoder extends WrappedNativeVideoEncoder { +public class LibaomAv1EncoderIfSupported extends WrappedNativeVideoEncoder { @Override public long createNativeVideoEncoder() { return nativeCreateEncoder(); diff --git a/sdk/android/api/org/webrtc/SoftwareVideoEncoderFactory.java b/sdk/android/api/org/webrtc/SoftwareVideoEncoderFactory.java index 1e3e181b3e..1c0b216a27 100644 --- a/sdk/android/api/org/webrtc/SoftwareVideoEncoderFactory.java +++ b/sdk/android/api/org/webrtc/SoftwareVideoEncoderFactory.java @@ -29,8 +29,8 @@ public VideoEncoder createEncoder(VideoCodecInfo codecInfo) { return new LibvpxVp9Encoder(); } if (codecName.equalsIgnoreCase(VideoCodecMimeType.AV1.name()) - && LibaomAv1Encoder.nativeIsSupported()) { - return new LibaomAv1Encoder(); + && LibaomAv1EncoderIfSupported.nativeIsSupported()) { + return new LibaomAv1EncoderIfSupported(); } return null; @@ -48,7 +48,7 @@ static VideoCodecInfo[] supportedCodecs() { if (LibvpxVp9Encoder.nativeIsSupported()) { codecs.add(new VideoCodecInfo(VideoCodecMimeType.VP9.name(), new HashMap<>())); } - if (LibaomAv1Encoder.nativeIsSupported()) { + if (LibaomAv1EncoderIfSupported.nativeIsSupported()) { codecs.add(new VideoCodecInfo(VideoCodecMimeType.AV1.name(), new HashMap<>())); } diff --git a/sdk/android/src/jni/libaom_av1_codec.cc b/sdk/android/src/jni/libaom_av1_codec.cc index e4332a6512..220443a32f 100644 --- a/sdk/android/src/jni/libaom_av1_codec.cc +++ b/sdk/android/src/jni/libaom_av1_codec.cc @@ -12,19 +12,19 @@ #include "modules/video_coding/codecs/av1/libaom_av1_decoder.h" #include "modules/video_coding/codecs/av1/libaom_av1_encoder_supported.h" -#include "sdk/android/generated_libaom_av1_jni/LibaomAv1Decoder_jni.h" -#include "sdk/android/generated_libaom_av1_jni/LibaomAv1Encoder_jni.h" +#include "sdk/android/generated_libaom_av1_jni_if_supported/LibaomAv1Decoder_jni.h" +#include "sdk/android/generated_libaom_av1_jni_if_supported/LibaomAv1EncoderIfSupported_jni.h" #include "sdk/android/src/jni/jni_helpers.h" namespace webrtc { namespace jni { -static jlong JNI_LibaomAv1Encoder_CreateEncoder(JNIEnv* jni) { +static jlong JNI_LibaomAv1EncoderIfSupported_CreateEncoder(JNIEnv* jni) { return jlongFromPointer( webrtc::CreateLibaomAv1EncoderIfSupported().release()); } -static jboolean JNI_LibaomAv1Encoder_IsSupported(JNIEnv* jni) { +static jboolean JNI_LibaomAv1EncoderIfSupported_IsSupported(JNIEnv* jni) { return webrtc::kIsLibaomAv1EncoderSupported; } From 870ffe74431fb7807453b487011ffd9b6041c739 Mon Sep 17 00:00:00 2001 From: philipel Date: Thu, 10 Mar 2022 11:18:21 +0100 Subject: [PATCH 146/847] Add libaom AV1 encoder java buildtargets. Bug: webrtc:13573 Change-Id: Iec5d52a0e095e8b69427239ff7ff7b1a5b56db35 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254581 Reviewed-by: Sergey Silkin Commit-Queue: Philip Eliasson Cr-Commit-Position: refs/heads/main@{#36172} --- sdk/android/BUILD.gn | 30 +++++++++++++++++++ .../api/org/webrtc/LibaomAv1Encoder.java | 25 ++++++++++++++++ sdk/android/src/jni/libaom_av1_encoder.cc | 25 ++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 sdk/android/api/org/webrtc/LibaomAv1Encoder.java create mode 100644 sdk/android/src/jni/libaom_av1_encoder.cc diff --git a/sdk/android/BUILD.gn b/sdk/android/BUILD.gn index 88a7d12d16..7bc30509c4 100644 --- a/sdk/android/BUILD.gn +++ b/sdk/android/BUILD.gn @@ -499,6 +499,17 @@ if (is_android) { ] } + rtc_android_library("libaom_av1_encoder_java") { + visibility = [ "*" ] + sources = [ "api/org/webrtc/LibaomAv1Encoder.java" ] + deps = [ + ":base_java", + ":video_api_java", + ":video_java", + "//rtc_base:base_java", + ] + } + rtc_android_library("libaom_av1_java") { visibility = [ "*" ] sources = [ @@ -848,6 +859,18 @@ if (current_os == "linux" || is_android) { ] } + rtc_library("libaom_av1_encoder_jni") { + visibility = [ "*" ] + allow_poison = [ "software_video_codecs" ] + sources = [ "src/jni/libaom_av1_encoder.cc" ] + deps = [ + ":base_jni", + ":generated_libaom_av1_encoder_jni", + ":video_jni", + "../../modules/video_coding/codecs/av1:libaom_av1_encoder", + ] + } + rtc_library("libaom_av1_jni_if_supported") { visibility = [ "*" ] allow_poison = [ "software_video_codecs" ] @@ -1313,6 +1336,13 @@ if (current_os == "linux" || is_android) { 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_libaom_av1_jni_if_supported") { sources = [ "api/org/webrtc/LibaomAv1Decoder.java", diff --git a/sdk/android/api/org/webrtc/LibaomAv1Encoder.java b/sdk/android/api/org/webrtc/LibaomAv1Encoder.java new file mode 100644 index 0000000000..569a719f44 --- /dev/null +++ b/sdk/android/api/org/webrtc/LibaomAv1Encoder.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2021 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +package org.webrtc; + +public class LibaomAv1Encoder extends WrappedNativeVideoEncoder { + @Override + public long createNativeVideoEncoder() { + return nativeCreateEncoder(); + } + + static native long nativeCreateEncoder(); + + @Override + public boolean isHardwareEncoder() { + return false; + } +} diff --git a/sdk/android/src/jni/libaom_av1_encoder.cc b/sdk/android/src/jni/libaom_av1_encoder.cc new file mode 100644 index 0000000000..400c3124fe --- /dev/null +++ b/sdk/android/src/jni/libaom_av1_encoder.cc @@ -0,0 +1,25 @@ +/* + * Copyright 2021 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include + +#include "modules/video_coding/codecs/av1/libaom_av1_encoder.h" +#include "sdk/android/generated_libaom_av1_encoder_jni/LibaomAv1Encoder_jni.h" +#include "sdk/android/src/jni/jni_helpers.h" + +namespace webrtc { +namespace jni { + +static jlong JNI_LibaomAv1Encoder_CreateEncoder(JNIEnv* jni) { + return jlongFromPointer(webrtc::CreateLibaomAv1Encoder().release()); +} + +} // namespace jni +} // namespace webrtc From 6016b2ef8a6aa5890faa3ba333980aa29674af0a Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Thu, 10 Mar 2022 06:02:18 -0800 Subject: [PATCH 147/847] Roll chromium_revision 3f2e509065..0f8ad7c774 (979444:979747) Change log: https://chromium.googlesource.com/chromium/src/+log/3f2e509065..0f8ad7c774 Full diff: https://chromium.googlesource.com/chromium/src/+/3f2e509065..0f8ad7c774 Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/897d5d8856..95865a0784 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/7327550c04..c9b821033b * src/buildtools/linux64: git_revision:46f94b5a7f5527b5d7ef57271d3e9447a65e22ac..git_revision:4ffb87ad613d822e47ca1e21f9d832055ef95891 * src/buildtools/mac: git_revision:46f94b5a7f5527b5d7ef57271d3e9447a65e22ac..git_revision:4ffb87ad613d822e47ca1e21f9d832055ef95891 * src/buildtools/third_party/libc++abi/trunk: https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git/+log/4d411388aa..289d52ce75 * src/buildtools/win: git_revision:46f94b5a7f5527b5d7ef57271d3e9447a65e22ac..git_revision:4ffb87ad613d822e47ca1e21f9d832055ef95891 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/0d784cd6f8..e6d4f35f5e * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/f6968388f8..502276e7aa * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/67e0f1a49a..0cada2e9da * src/third_party/android_build_tools/bundletool: 2ZcLVDxyRwp8FzpeYLtLT0TfSRweZxvwh1-Kx1jZ_FoC..LoldiQDpZ0uTdAm5EPgZ8hBJ3La2KlTWLuaRxE7eDigC * src/third_party/androidx: 3VkiRTe5qdPdzmIzC63lc6LJPSEUMNjCHwQM4OBH_pgC..Au8GY56lt8eqtp-di9ooOGsOQprr7zRtGIq2kozVfMcC * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/1b4881c930..4ca9e1c783 * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/6eb2732376..e26fd0a8a5 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/9a09a4b76e..0ce8be83de DEPS diff: https://chromium.googlesource.com/chromium/src/+/3f2e509065..0f8ad7c774/DEPS No update to Clang. BUG=None Change-Id: Ibbb2ca98c3c763d219c8426613fe6d5e0a17d3ae Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254700 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36173} --- DEPS | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/DEPS b/DEPS index 6ca6981307..e47d151a20 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': '3f2e509065ab06dd5eb5c10cdbedf24e9e1ac643', + 'chromium_revision': '0f8ad7c774c8d16fe38041ef2545496d0f30005b', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@897d5d8856f6e81f9f0485686ca17ee57cfb266f', + 'https://chromium.googlesource.com/chromium/src/base@95865a0784ea1a20e4f40923c5173cd65870568e', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@7327550c04d15b08b63ca56113a323f4809cdbad', + 'https://chromium.googlesource.com/chromium/src/build@c9b821033b5c8f0af4bf6007cac35f9d62e50dde', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@113dd1badbcbffea108a8c95ac7c89c22bfd25f3', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,19 +34,19 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@0d784cd6f8988694b5979fe9b9ee01b95e9a68df', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@e6d4f35f5e32783d9d23f277c9be9848269c1600', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@f6968388f87ca25207622cd2a991d4d6d8038ef7', + 'https://chromium.googlesource.com/chromium/src/testing@502276e7aa37a4fc86ab2a44d57f14ed6317d535', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@67e0f1a49a80fb5e22af539901a7e6473901c622', + 'https://chromium.googlesource.com/chromium/src/third_party@0cada2e9da291ec90172cdfc9d127aab98f4a9d0', 'src/buildtools/linux64': { 'packages': [ { 'package': 'gn/gn/linux-amd64', - 'version': 'git_revision:46f94b5a7f5527b5d7ef57271d3e9447a65e22ac', + 'version': 'git_revision:4ffb87ad613d822e47ca1e21f9d832055ef95891', } ], 'dep_type': 'cipd', @@ -56,7 +56,7 @@ deps = { 'packages': [ { 'package': 'gn/gn/mac-${{arch}}', - 'version': 'git_revision:46f94b5a7f5527b5d7ef57271d3e9447a65e22ac', + 'version': 'git_revision:4ffb87ad613d822e47ca1e21f9d832055ef95891', } ], 'dep_type': 'cipd', @@ -66,7 +66,7 @@ deps = { 'packages': [ { 'package': 'gn/gn/windows-amd64', - 'version': 'git_revision:46f94b5a7f5527b5d7ef57271d3e9447a65e22ac', + 'version': 'git_revision:4ffb87ad613d822e47ca1e21f9d832055ef95891', } ], 'dep_type': 'cipd', @@ -78,7 +78,7 @@ deps = { 'src/buildtools/third_party/libc++/trunk': 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxx.git@79a2e924d96e2fc1e4b937c42efd08898fa472d7', 'src/buildtools/third_party/libc++abi/trunk': - 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git@4d411388aacc2b7d0072aaacb80cb736d75ad51e', + 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git@289d52ce75d6091a79e90ae6aead38c5c701d786', 'src/buildtools/third_party/libunwind/trunk': 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git@d1c7f92b8b0bff8d9f710ca40e44563a63db376e', @@ -128,7 +128,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_build_tools/bundletool', - 'version': '2ZcLVDxyRwp8FzpeYLtLT0TfSRweZxvwh1-Kx1jZ_FoC', + 'version': 'LoldiQDpZ0uTdAm5EPgZ8hBJ3La2KlTWLuaRxE7eDigC', }, ], 'condition': 'checkout_android', @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@1b4881c9300a81bac80eace84caa2c10c2e41fa5', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@4ca9e1c783b8fa9c8ca39edfcded3028dc7f3e1b', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -228,7 +228,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@6eb273237653c5c8d417fd1b556c6d361eb6a79d', + 'https://android.googlesource.com/platform/external/perfetto.git@e26fd0a8a5e96b82f71b3c86240d8c8c0429245e', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@9a09a4b76e72d6fab91496e808be0dbc7c0fbed4', + 'https://chromium.googlesource.com/chromium/src/tools@0ce8be83de5cb668bcd642b2b5b50c3d0d8ab2ad', 'src/third_party/accessibility_test_framework': { 'packages': [ @@ -384,7 +384,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/androidx', - 'version': '3VkiRTe5qdPdzmIzC63lc6LJPSEUMNjCHwQM4OBH_pgC', + 'version': 'Au8GY56lt8eqtp-di9ooOGsOQprr7zRtGIq2kozVfMcC', }, ], 'condition': 'checkout_android', From 7ee138e8fcafee1ba892895e543675fc82e6b14b Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Thu, 10 Mar 2022 13:21:28 +0000 Subject: [PATCH 148/847] Break out a few more targets from rtc_pc_base Also use apply-iwyu -r to clean out some not-needed includes. Bug: webrtc:13805 Change-Id: Id12b6a0e340f686fdfbb9df6fedac324bdcc4b2c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254680 Reviewed-by: Mirko Bonadei Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#36174} --- pc/BUILD.gn | 51 ++++++++++++++++++++++++++++++++++++-------- pc/external_hmac.h | 1 - pc/ice_transport.h | 1 - pc/rtp_media_utils.h | 1 - 4 files changed, 42 insertions(+), 12 deletions(-) diff --git a/pc/BUILD.gn b/pc/BUILD.gn index da78a25158..cc2bc1937a 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -76,10 +76,6 @@ rtc_library("rtc_pc_base") { "dtls_srtp_transport.h", "dtls_transport.cc", "dtls_transport.h", - "external_hmac.cc", - "external_hmac.h", - "ice_transport.cc", - "ice_transport.h", "jsep_transport.cc", "jsep_transport.h", "jsep_transport_collection.cc", @@ -88,10 +84,6 @@ rtc_library("rtc_pc_base") { "jsep_transport_controller.h", "media_session.cc", "media_session.h", - "rtcp_mux_filter.cc", - "rtcp_mux_filter.h", - "rtp_media_utils.cc", - "rtp_media_utils.h", "rtp_transport.cc", "rtp_transport.h", "rtp_transport_internal.h", @@ -224,7 +216,6 @@ rtc_library("rtc_pc_base") { "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] - if (rtc_build_libsrtp) { deps += [ "//third_party/libsrtp" ] } @@ -250,9 +241,28 @@ rtc_source_set("dtls_transport") { } rtc_source_set("external_hmac") { visibility = [ ":*" ] + sources = [ + "external_hmac.cc", + "external_hmac.h", + ] + deps = [ "../rtc_base:rtc_base_approved" ] + if (rtc_build_libsrtp) { + deps += [ "//third_party/libsrtp" ] + } } rtc_source_set("ice_transport") { visibility = [ ":*" ] + sources = [ + "ice_transport.cc", + "ice_transport.h", + ] + deps = [ + "../api:libjingle_peerconnection_api", + "../api:sequence_checker", + "../rtc_base:checks", + "../rtc_base:macromagic", + "../rtc_base:threading", + ] } rtc_source_set("jsep_transport") { visibility = [ ":*" ] @@ -300,9 +310,25 @@ rtc_source_set("peer_connection_proxy") { } rtc_source_set("rtcp_mux_filter") { visibility = [ ":*" ] + sources = [ + "rtcp_mux_filter.cc", + "rtcp_mux_filter.h", + ] + deps = [ + ":session_description", + "../rtc_base:logging", + ] } rtc_source_set("rtp_media_utils") { visibility = [ ":*" ] + sources = [ + "rtp_media_utils.cc", + "rtp_media_utils.h", + ] + deps = [ + "../api:rtp_transceiver_direction", + "../rtc_base:checks", + ] } rtc_source_set("rtp_receiver_proxy") { visibility = [ ":*" ] @@ -764,6 +790,7 @@ rtc_source_set("sdp_offer_answer") { ":peer_connection_message_handler", ":rtc_pc_base", ":rtc_stats_collector", + ":rtp_media_utils", ":rtp_receiver", ":rtp_receiver_proxy", ":rtp_sender", @@ -1219,6 +1246,7 @@ rtc_library("rtp_transceiver") { deps = [ ":proxy", ":rtc_pc_base", + ":rtp_media_utils", ":rtp_parameters_conversion", ":rtp_receiver", ":rtp_receiver_proxy", @@ -1705,12 +1733,15 @@ if (rtc_include_tests && !build_with_chromium) { deps = [ ":audio_rtp_receiver", + ":ice_transport", ":libjingle_peerconnection", ":media_protocol_names", ":pc_test_utils", ":peerconnection", ":rtc_pc", ":rtc_pc_base", + ":rtcp_mux_filter", + ":rtp_media_utils", ":session_description", ":video_rtp_receiver", "../api:array_view", @@ -1903,6 +1934,7 @@ if (rtc_include_tests && !build_with_chromium) { ":rtc_pc_base", ":rtc_stats_collector", ":rtc_stats_traversal", + ":rtp_media_utils", ":rtp_parameters_conversion", ":rtp_receiver", ":rtp_sender", @@ -2092,6 +2124,7 @@ if (rtc_include_tests && !build_with_chromium) { ":peerconnection", ":remote_audio_source", ":rtc_pc_base", + ":rtp_media_utils", ":rtp_parameters_conversion", ":rtp_receiver", ":rtp_sender", diff --git a/pc/external_hmac.h b/pc/external_hmac.h index 3c2936c685..c5071fc192 100644 --- a/pc/external_hmac.h +++ b/pc/external_hmac.h @@ -30,7 +30,6 @@ #include -#include "third_party/libsrtp/crypto/include/auth.h" #include "third_party/libsrtp/crypto/include/crypto_types.h" #include "third_party/libsrtp/include/srtp.h" #include "third_party/libsrtp/include/srtp_priv.h" diff --git a/pc/ice_transport.h b/pc/ice_transport.h index 11f3de5d27..e31ec546b2 100644 --- a/pc/ice_transport.h +++ b/pc/ice_transport.h @@ -12,7 +12,6 @@ #define PC_ICE_TRANSPORT_H_ #include "api/ice_transport_interface.h" -#include "api/sequence_checker.h" #include "rtc_base/checks.h" #include "rtc_base/thread.h" #include "rtc_base/thread_annotations.h" diff --git a/pc/rtp_media_utils.h b/pc/rtp_media_utils.h index 5c61f5b1d6..240274fe05 100644 --- a/pc/rtp_media_utils.h +++ b/pc/rtp_media_utils.h @@ -14,7 +14,6 @@ #include // no-presubmit-check TODO(webrtc:8982) #include "api/rtp_transceiver_direction.h" -#include "api/rtp_transceiver_interface.h" namespace webrtc { From 52a955607ae7e21c92e2a3d7c4be3f5542abe4b2 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Thu, 10 Mar 2022 12:01:54 -0800 Subject: [PATCH 149/847] Roll chromium_revision 0f8ad7c774..a57058ece1 (979747:979913) Change log: https://chromium.googlesource.com/chromium/src/+log/0f8ad7c774..a57058ece1 Full diff: https://chromium.googlesource.com/chromium/src/+/0f8ad7c774..a57058ece1 Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/95865a0784..3995e4dea1 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/c9b821033b..8ac9bfbfd3 * src/buildtools/linux64: git_revision:4ffb87ad613d822e47ca1e21f9d832055ef95891..git_revision:f27bae882b2178ccc3c24f314c88db9a34118992 * src/buildtools/mac: git_revision:4ffb87ad613d822e47ca1e21f9d832055ef95891..git_revision:f27bae882b2178ccc3c24f314c88db9a34118992 * src/buildtools/win: git_revision:4ffb87ad613d822e47ca1e21f9d832055ef95891..git_revision:f27bae882b2178ccc3c24f314c88db9a34118992 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/e6d4f35f5e..d4803736c6 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/502276e7aa..db21f42dd9 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/0cada2e9da..62b5a5537d * src/third_party/androidx: Au8GY56lt8eqtp-di9ooOGsOQprr7zRtGIq2kozVfMcC..EggJgyI0ja1HtThYH24KsjyfGghSO9o623ONeM4pynIC * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/4ca9e1c783..1909696991 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/0ce8be83de..a680c6e739 DEPS diff: https://chromium.googlesource.com/chromium/src/+/0f8ad7c774..a57058ece1/DEPS Clang version changed llvmorg-15-init-3540-g85c53c70:llvmorg-15-init-3677-g8133778d Details: https://chromium.googlesource.com/chromium/src/+/0f8ad7c774..a57058ece1/tools/clang/scripts/update.py BUG=None Change-Id: Icf9debf60a0c43a37c203ad9d01164b5a79ea6db Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254840 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36175} --- DEPS | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/DEPS b/DEPS index e47d151a20..d74a41c949 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': '0f8ad7c774c8d16fe38041ef2545496d0f30005b', + 'chromium_revision': 'a57058ece1144672b4024e18ab3741068cb7ff54', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@95865a0784ea1a20e4f40923c5173cd65870568e', + 'https://chromium.googlesource.com/chromium/src/base@3995e4dea1b2ab0c99079100f4a5391c8a661602', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@c9b821033b5c8f0af4bf6007cac35f9d62e50dde', + 'https://chromium.googlesource.com/chromium/src/build@8ac9bfbfd302afe2d99527f5fb46e6b3a27a9bb7', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@113dd1badbcbffea108a8c95ac7c89c22bfd25f3', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,19 +34,19 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@e6d4f35f5e32783d9d23f277c9be9848269c1600', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@d4803736c617a684b3234f3b9e0f3b019b550aec', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@502276e7aa37a4fc86ab2a44d57f14ed6317d535', + 'https://chromium.googlesource.com/chromium/src/testing@db21f42dd95304af10d7eba3a3680c5018f193f0', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@0cada2e9da291ec90172cdfc9d127aab98f4a9d0', + 'https://chromium.googlesource.com/chromium/src/third_party@62b5a5537d15c876ae732ce3f9adad51cbc978b1', 'src/buildtools/linux64': { 'packages': [ { 'package': 'gn/gn/linux-amd64', - 'version': 'git_revision:4ffb87ad613d822e47ca1e21f9d832055ef95891', + 'version': 'git_revision:f27bae882b2178ccc3c24f314c88db9a34118992', } ], 'dep_type': 'cipd', @@ -56,7 +56,7 @@ deps = { 'packages': [ { 'package': 'gn/gn/mac-${{arch}}', - 'version': 'git_revision:4ffb87ad613d822e47ca1e21f9d832055ef95891', + 'version': 'git_revision:f27bae882b2178ccc3c24f314c88db9a34118992', } ], 'dep_type': 'cipd', @@ -66,7 +66,7 @@ deps = { 'packages': [ { 'package': 'gn/gn/windows-amd64', - 'version': 'git_revision:4ffb87ad613d822e47ca1e21f9d832055ef95891', + 'version': 'git_revision:f27bae882b2178ccc3c24f314c88db9a34118992', } ], 'dep_type': 'cipd', @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@4ca9e1c783b8fa9c8ca39edfcded3028dc7f3e1b', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@1909696991d3e1e689d6d8815bb44fb327527d52', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@0ce8be83de5cb668bcd642b2b5b50c3d0d8ab2ad', + 'https://chromium.googlesource.com/chromium/src/tools@a680c6e739309497959ef94e00889b337339165a', 'src/third_party/accessibility_test_framework': { 'packages': [ @@ -384,7 +384,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/androidx', - 'version': 'Au8GY56lt8eqtp-di9ooOGsOQprr7zRtGIq2kozVfMcC', + 'version': 'EggJgyI0ja1HtThYH24KsjyfGghSO9o623ONeM4pynIC', }, ], 'condition': 'checkout_android', From 041c08377a0dd4afbd928ef40e3789b08118313c Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Thu, 10 Mar 2022 20:02:49 -0800 Subject: [PATCH 150/847] Update WebRTC code version (2022-03-11T04:02:47). Bug: None Change-Id: I17d0ee0403d10aa44d8db604f4498a3c5da7d9bb Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254900 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36176} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index 7e90720e65..11b61d9f97 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 2022-03-10T04:03:07"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-03-11T04:02:47"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From 4476b82b35a567e9bacf27212f04dfd1a151ef02 Mon Sep 17 00:00:00 2001 From: Jonas Oreland Date: Thu, 10 Mar 2022 15:21:28 +0100 Subject: [PATCH 151/847] WebRTC-DeprecateGlobalFieldTrialString/Enabled/ - part 3/inf convert much of media/ (and the collateral) Bug: webrtc:10335 Change-Id: I04489dfe9622efe7f89e04aba3be6b3f60e77c91 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254520 Reviewed-by: Mirko Bonadei Reviewed-by: Harald Alvestrand Commit-Queue: Jonas Oreland Cr-Commit-Position: refs/heads/main@{#36177} --- media/BUILD.gn | 4 +- media/base/codec.cc | 20 +- media/base/codec.h | 13 +- media/base/media_engine.h | 2 +- media/base/test_utils.h | 6 +- media/engine/webrtc_media_engine_unittest.cc | 35 ++-- media/engine/webrtc_video_engine_unittest.cc | 85 +++----- media/engine/webrtc_voice_engine.cc | 7 +- media/engine/webrtc_voice_engine_unittest.cc | 28 +-- media/sctp/sctp_transport_factory.cc | 10 +- media/sctp/sctp_transport_factory.h | 5 +- pc/channel_manager_unittest.cc | 12 +- pc/channel_unittest.cc | 24 ++- pc/connection_context.cc | 3 +- pc/media_session.cc | 197 +++++++++++-------- pc/media_session_unittest.cc | 14 +- test/BUILD.gn | 3 + 17 files changed, 254 insertions(+), 214 deletions(-) diff --git a/media/BUILD.gn b/media/BUILD.gn index 493b883949..8729168da5 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -57,6 +57,7 @@ rtc_library("rtc_media_base") { "../api:rtp_parameters", "../api:scoped_refptr", "../api:sequence_checker", + "../api:webrtc_key_value_config", "../api/audio:audio_frame_processor", "../api/audio_codecs:audio_codecs_api", "../api/crypto:frame_decryptor_interface", @@ -64,7 +65,6 @@ rtc_library("rtc_media_base") { "../api/crypto:options", "../api/transport:datagram_transport_interface", "../api/transport:stun_types", - "../api/transport:webrtc_key_value_config", "../api/transport/rtp:rtp_source", "../api/units:time_delta", "../api/video:video_bitrate_allocation", @@ -453,6 +453,7 @@ rtc_library("rtc_data_sctp_transport_factory") { ] deps = [ ":rtc_data_sctp_transport_internal", + "../api:webrtc_key_value_config", "../api/transport:sctp_transport_factory_interface", "../rtc_base:threading", "../rtc_base/experiments:field_trial_parser", @@ -641,6 +642,7 @@ if (rtc_include_tests) { "../test:fake_video_codecs", "../test:field_trial", "../test:rtp_test_utils", + "../test:scoped_key_value_config", "../test:test_main", "../test:test_support", "../test:video_test_common", diff --git a/media/base/codec.cc b/media/base/codec.cc index 9b09f5e73b..a01914dff5 100644 --- a/media/base/codec.cc +++ b/media/base/codec.cc @@ -18,7 +18,6 @@ #include "rtc_base/logging.h" #include "rtc_base/string_encode.h" #include "rtc_base/strings/string_builder.h" -#include "system_wrappers/include/field_trial.h" namespace cricket { namespace { @@ -129,13 +128,14 @@ bool Codec::operator==(const Codec& c) const { feedback_params == c.feedback_params; } -bool Codec::Matches(const Codec& codec) const { +bool Codec::Matches(const Codec& codec, + const webrtc::WebRtcKeyValueConfig* field_trials) const { // Match the codec id/name based on the typical static/dynamic name rules. // Matching is case-insensitive. // Legacy behaviour with killswitch. - if (webrtc::field_trial::IsDisabled( - "WebRTC-PayloadTypes-Lower-Dynamic-Range")) { + if (field_trials && + field_trials->IsDisabled("WebRTC-PayloadTypes-Lower-Dynamic-Range")) { const int kMaxStaticPayloadId = 95; return (id <= kMaxStaticPayloadId || codec.id <= kMaxStaticPayloadId) ? (id == codec.id) @@ -238,7 +238,9 @@ bool AudioCodec::operator==(const AudioCodec& c) const { return bitrate == c.bitrate && channels == c.channels && Codec::operator==(c); } -bool AudioCodec::Matches(const AudioCodec& codec) const { +bool AudioCodec::Matches( + const AudioCodec& codec, + const webrtc::WebRtcKeyValueConfig* field_trials) const { // If a nonzero clockrate is specified, it must match the actual clockrate. // If a nonzero bitrate is specified, it must match the actual bitrate, // unless the codec is VBR (0), where we just force the supplied value. @@ -248,7 +250,7 @@ bool AudioCodec::Matches(const AudioCodec& codec) const { // omitted if the number of channels is one." // Preference is ignored. // TODO(juberti): Treat a zero clockrate as 8000Hz, the RTP default clockrate. - return Codec::Matches(codec) && + return Codec::Matches(codec, field_trials) && ((codec.clockrate == 0 /*&& clockrate == 8000*/) || clockrate == codec.clockrate) && (codec.bitrate == 0 || bitrate <= 0 || bitrate == codec.bitrate) && @@ -324,8 +326,10 @@ bool VideoCodec::operator==(const VideoCodec& c) const { return Codec::operator==(c) && packetization == c.packetization; } -bool VideoCodec::Matches(const VideoCodec& other) const { - return Codec::Matches(other) && +bool VideoCodec::Matches( + const VideoCodec& other, + const webrtc::WebRtcKeyValueConfig* field_trials) const { + return Codec::Matches(other, field_trials) && IsSameCodecSpecific(name, params, other.name, other.params); } diff --git a/media/base/codec.h b/media/base/codec.h index cfc31aed1f..70ecfd326d 100644 --- a/media/base/codec.h +++ b/media/base/codec.h @@ -19,6 +19,7 @@ #include "absl/types/optional.h" #include "api/rtp_parameters.h" #include "api/video_codecs/sdp_video_format.h" +#include "api/webrtc_key_value_config.h" #include "media/base/media_constants.h" #include "rtc_base/system/rtc_export.h" @@ -75,7 +76,9 @@ struct RTC_EXPORT Codec { virtual ~Codec(); // Indicates if this codec is compatible with the specified codec. - bool Matches(const Codec& codec) const; + bool Matches( + const Codec& codec, + const webrtc::WebRtcKeyValueConfig* field_trials = nullptr) const; bool MatchesCapability(const webrtc::RtpCodecCapability& capability) const; // Find the parameter for `name` and write the value to `out`. @@ -132,7 +135,9 @@ struct AudioCodec : public Codec { ~AudioCodec() override = default; // Indicates if this codec is compatible with the specified codec. - bool Matches(const AudioCodec& codec) const; + bool Matches( + const AudioCodec& codec, + const webrtc::WebRtcKeyValueConfig* field_trials = nullptr) const; std::string ToString() const; @@ -163,7 +168,9 @@ struct RTC_EXPORT VideoCodec : public Codec { // Indicates if this video codec is the same as the other video codec, e.g. if // they are both VP8 or VP9, or if they are both H264 with the same H264 // profile. H264 levels however are not compared. - bool Matches(const VideoCodec& codec) const; + bool Matches( + const VideoCodec& codec, + const webrtc::WebRtcKeyValueConfig* field_trials = nullptr) const; std::string ToString() const; diff --git a/media/base/media_engine.h b/media/base/media_engine.h index 1778104a30..7b4dbe4364 100644 --- a/media/base/media_engine.h +++ b/media/base/media_engine.h @@ -19,8 +19,8 @@ #include "api/audio_codecs/audio_encoder_factory.h" #include "api/crypto/crypto_options.h" #include "api/rtp_parameters.h" -#include "api/transport/webrtc_key_value_config.h" #include "api/video/video_bitrate_allocator_factory.h" +#include "api/webrtc_key_value_config.h" #include "call/audio_state.h" #include "media/base/codec.h" #include "media/base/media_channel.h" diff --git a/media/base/test_utils.h b/media/base/test_utils.h index 22bda4f12a..fbd9f35184 100644 --- a/media/base/test_utils.h +++ b/media/base/test_utils.h @@ -37,10 +37,12 @@ inline std::vector MakeVector(const T a[], size_t s) { // Checks whether `codecs` contains `codec`; checks using Codec::Matches(). template -bool ContainsMatchingCodec(const std::vector& codecs, const C& codec) { +bool ContainsMatchingCodec(const std::vector& codecs, + const C& codec, + const webrtc::WebRtcKeyValueConfig* field_trials) { typename std::vector::const_iterator it; for (it = codecs.begin(); it != codecs.end(); ++it) { - if (it->Matches(codec)) { + if (it->Matches(codec, field_trials)) { return true; } } diff --git a/media/engine/webrtc_media_engine_unittest.cc b/media/engine/webrtc_media_engine_unittest.cc index 81982fae2b..79efea4e9c 100644 --- a/media/engine/webrtc_media_engine_unittest.cc +++ b/media/engine/webrtc_media_engine_unittest.cc @@ -13,10 +13,9 @@ #include #include -#include "api/transport/field_trial_based_config.h" #include "media/engine/webrtc_media_engine_defaults.h" -#include "test/field_trial.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" using webrtc::RtpExtension; @@ -129,7 +128,7 @@ TEST(WebRtcMediaEngineTest, ValidateRtpExtensionsChangeIdForUrl) { TEST(WebRtcMediaEngineTest, FilterRtpExtensionsEmptyList) { std::vector extensions; - webrtc::FieldTrialBasedConfig trials; + webrtc::test::ScopedKeyValueConfig trials; std::vector filtered = FilterRtpExtensions(extensions, SupportedExtensions1, true, trials); EXPECT_EQ(0u, filtered.size()); @@ -137,7 +136,7 @@ TEST(WebRtcMediaEngineTest, FilterRtpExtensionsEmptyList) { TEST(WebRtcMediaEngineTest, FilterRtpExtensionsIncludeOnlySupported) { std::vector extensions = MakeUniqueExtensions(); - webrtc::FieldTrialBasedConfig trials; + webrtc::test::ScopedKeyValueConfig trials; std::vector filtered = FilterRtpExtensions(extensions, SupportedExtensions1, false, trials); EXPECT_EQ(2u, filtered.size()); @@ -147,7 +146,7 @@ TEST(WebRtcMediaEngineTest, FilterRtpExtensionsIncludeOnlySupported) { TEST(WebRtcMediaEngineTest, FilterRtpExtensionsSortedByName1) { std::vector extensions = MakeUniqueExtensions(); - webrtc::FieldTrialBasedConfig trials; + webrtc::test::ScopedKeyValueConfig trials; std::vector filtered = FilterRtpExtensions(extensions, SupportedExtensions2, false, trials); EXPECT_EQ(12u, filtered.size()); @@ -156,7 +155,7 @@ TEST(WebRtcMediaEngineTest, FilterRtpExtensionsSortedByName1) { TEST(WebRtcMediaEngineTest, FilterRtpExtensionsSortedByName2) { std::vector extensions = MakeUniqueExtensions(); - webrtc::FieldTrialBasedConfig trials; + webrtc::test::ScopedKeyValueConfig trials; std::vector filtered = FilterRtpExtensions(extensions, SupportedExtensions2, true, trials); EXPECT_EQ(12u, filtered.size()); @@ -165,7 +164,7 @@ TEST(WebRtcMediaEngineTest, FilterRtpExtensionsSortedByName2) { TEST(WebRtcMediaEngineTest, FilterRtpExtensionsDontRemoveRedundant) { std::vector extensions = MakeRedundantExtensions(); - webrtc::FieldTrialBasedConfig trials; + webrtc::test::ScopedKeyValueConfig trials; std::vector filtered = FilterRtpExtensions(extensions, SupportedExtensions2, false, trials); EXPECT_EQ(12u, filtered.size()); @@ -175,7 +174,7 @@ TEST(WebRtcMediaEngineTest, FilterRtpExtensionsDontRemoveRedundant) { TEST(WebRtcMediaEngineTest, FilterRtpExtensionsRemoveRedundant) { std::vector extensions = MakeRedundantExtensions(); - webrtc::FieldTrialBasedConfig trials; + webrtc::test::ScopedKeyValueConfig trials; std::vector filtered = FilterRtpExtensions(extensions, SupportedExtensions2, true, trials); EXPECT_EQ(6u, filtered.size()); @@ -189,7 +188,7 @@ TEST(WebRtcMediaEngineTest, FilterRtpExtensionsRemoveRedundantEncrypted1) { extensions.push_back(webrtc::RtpExtension("b", 2, true)); extensions.push_back(webrtc::RtpExtension("c", 3)); extensions.push_back(webrtc::RtpExtension("b", 4)); - webrtc::FieldTrialBasedConfig trials; + webrtc::test::ScopedKeyValueConfig trials; std::vector filtered = FilterRtpExtensions(extensions, SupportedExtensions2, true, trials); EXPECT_EQ(3u, filtered.size()); @@ -206,7 +205,7 @@ TEST(WebRtcMediaEngineTest, FilterRtpExtensionsRemoveRedundantEncrypted2) { extensions.push_back(webrtc::RtpExtension("b", 2)); extensions.push_back(webrtc::RtpExtension("c", 3)); extensions.push_back(webrtc::RtpExtension("b", 4)); - webrtc::FieldTrialBasedConfig trials; + webrtc::test::ScopedKeyValueConfig trials; std::vector filtered = FilterRtpExtensions(extensions, SupportedExtensions2, true, trials); EXPECT_EQ(3u, filtered.size()); @@ -218,9 +217,8 @@ TEST(WebRtcMediaEngineTest, FilterRtpExtensionsRemoveRedundantEncrypted2) { } TEST(WebRtcMediaEngineTest, FilterRtpExtensionsRemoveRedundantBwe1) { - webrtc::test::ScopedFieldTrials override_field_trials_( + webrtc::test::ScopedKeyValueConfig trials( "WebRTC-FilterAbsSendTimeExtension/Enabled/"); - webrtc::FieldTrialBasedConfig trials; std::vector extensions; extensions.push_back( RtpExtension(RtpExtension::kTransportSequenceNumberUri, 3)); @@ -245,7 +243,7 @@ TEST(WebRtcMediaEngineTest, extensions.push_back( RtpExtension(RtpExtension::kTransportSequenceNumberUri, 1)); extensions.push_back(RtpExtension(RtpExtension::kTimestampOffsetUri, 14)); - webrtc::FieldTrialBasedConfig trials; + webrtc::test::ScopedKeyValueConfig trials; std::vector filtered = FilterRtpExtensions(extensions, SupportedExtensions2, true, trials); EXPECT_EQ(2u, filtered.size()); @@ -254,9 +252,8 @@ TEST(WebRtcMediaEngineTest, } TEST(WebRtcMediaEngineTest, FilterRtpExtensionsRemoveRedundantBweEncrypted1) { - webrtc::test::ScopedFieldTrials override_field_trials_( + webrtc::test::ScopedKeyValueConfig trials( "WebRTC-FilterAbsSendTimeExtension/Enabled/"); - webrtc::FieldTrialBasedConfig trials; std::vector extensions; extensions.push_back( RtpExtension(RtpExtension::kTransportSequenceNumberUri, 3)); @@ -291,7 +288,7 @@ TEST(WebRtcMediaEngineTest, extensions.push_back( RtpExtension(RtpExtension::kTransportSequenceNumberUri, 2, true)); extensions.push_back(RtpExtension(RtpExtension::kTimestampOffsetUri, 14)); - webrtc::FieldTrialBasedConfig trials; + webrtc::test::ScopedKeyValueConfig trials; std::vector filtered = FilterRtpExtensions(extensions, SupportedExtensions2, true, trials); EXPECT_EQ(3u, filtered.size()); @@ -306,7 +303,7 @@ TEST(WebRtcMediaEngineTest, FilterRtpExtensionsRemoveRedundantBwe2) { extensions.push_back(RtpExtension(RtpExtension::kTimestampOffsetUri, 1)); extensions.push_back(RtpExtension(RtpExtension::kAbsSendTimeUri, 14)); extensions.push_back(RtpExtension(RtpExtension::kTimestampOffsetUri, 7)); - webrtc::FieldTrialBasedConfig trials; + webrtc::test::ScopedKeyValueConfig trials; std::vector filtered = FilterRtpExtensions(extensions, SupportedExtensions2, true, trials); EXPECT_EQ(1u, filtered.size()); @@ -317,7 +314,7 @@ TEST(WebRtcMediaEngineTest, FilterRtpExtensionsRemoveRedundantBwe3) { std::vector extensions; extensions.push_back(RtpExtension(RtpExtension::kTimestampOffsetUri, 2)); extensions.push_back(RtpExtension(RtpExtension::kTimestampOffsetUri, 14)); - webrtc::FieldTrialBasedConfig trials; + webrtc::test::ScopedKeyValueConfig trials; std::vector filtered = FilterRtpExtensions(extensions, SupportedExtensions2, true, trials); EXPECT_EQ(1u, filtered.size()); @@ -327,7 +324,7 @@ TEST(WebRtcMediaEngineTest, FilterRtpExtensionsRemoveRedundantBwe3) { TEST(WebRtcMediaEngineTest, Create) { MediaEngineDependencies deps; webrtc::SetMediaEngineDefaults(&deps); - webrtc::FieldTrialBasedConfig trials; + webrtc::test::ScopedKeyValueConfig trials; deps.trials = &trials; std::unique_ptr engine = diff --git a/media/engine/webrtc_video_engine_unittest.cc b/media/engine/webrtc_video_engine_unittest.cc index a1aa88de7b..ab9ad1aab6 100644 --- a/media/engine/webrtc_video_engine_unittest.cc +++ b/media/engine/webrtc_video_engine_unittest.cc @@ -60,11 +60,10 @@ #include "rtc_base/gunit.h" #include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/time_utils.h" -#include "system_wrappers/include/field_trial.h" #include "test/fake_decoder.h" -#include "test/field_trial.h" #include "test/frame_forwarder.h" #include "test/gmock.h" +#include "test/scoped_key_value_config.h" #include "test/time_controller/simulated_time_controller.h" using ::testing::_; @@ -244,12 +243,8 @@ class WebRtcVideoEngineTest : public ::testing::Test { public: WebRtcVideoEngineTest() : WebRtcVideoEngineTest("") {} explicit WebRtcVideoEngineTest(const std::string& field_trials) - : time_controller_(webrtc::Timestamp::Millis(4711)), - override_field_trials_( - field_trials.empty() - ? nullptr - : std::make_unique( - field_trials)), + : field_trials_(field_trials), + time_controller_(webrtc::Timestamp::Millis(4711)), task_queue_factory_(time_controller_.CreateTaskQueueFactory()), call_(webrtc::Call::Create([&] { webrtc::Call::Config call_config(&event_log_); @@ -286,9 +281,8 @@ class WebRtcVideoEngineTest : public ::testing::Test { void ExpectRtpCapabilitySupport(const char* uri, bool supported) const; + webrtc::test::ScopedKeyValueConfig field_trials_; webrtc::GlobalSimulatedTimeController time_controller_; - std::unique_ptr override_field_trials_; - webrtc::FieldTrialBasedConfig field_trials_; webrtc::RtcEventLogNull event_log_; std::unique_ptr task_queue_factory_; // Used in WebRtcVideoEngineVoiceTest, but defined here so it's properly @@ -936,9 +930,8 @@ TEST_F(WebRtcVideoEngineTest, } TEST_F(WebRtcVideoEngineTest, SimulcastEnabledForH264BehindFieldTrial) { - RTC_DCHECK(!override_field_trials_); - override_field_trials_ = std::make_unique( - "WebRTC-H264Simulcast/Enabled/"); + webrtc::test::ScopedKeyValueConfig override_field_trials( + field_trials_, "WebRTC-H264Simulcast/Enabled/"); AddSupportedVideoCodecType("H264"); std::unique_ptr channel(engine_.CreateMediaChannel( @@ -978,9 +971,8 @@ TEST_F(WebRtcVideoEngineTest, Flexfec03SendCodecEnablesWithFieldTrial) { EXPECT_THAT(engine_.send_codecs(), Not(Contains(flexfec))); - RTC_DCHECK(!override_field_trials_); - override_field_trials_ = std::make_unique( - "WebRTC-FlexFEC-03-Advertised/Enabled/"); + webrtc::test::ScopedKeyValueConfig override_field_trials( + field_trials_, "WebRTC-FlexFEC-03-Advertised/Enabled/"); EXPECT_THAT(engine_.send_codecs(), Contains(flexfec)); } @@ -993,9 +985,8 @@ TEST_F(WebRtcVideoEngineTest, Flexfec03ReceiveCodecDisablesWithFieldTrial) { EXPECT_THAT(engine_.recv_codecs(), Contains(flexfec)); - RTC_DCHECK(!override_field_trials_); - override_field_trials_ = std::make_unique( - "WebRTC-FlexFEC-03-Advertised/Disabled/"); + webrtc::test::ScopedKeyValueConfig override_field_trials( + field_trials_, "WebRTC-FlexFEC-03-Advertised/Disabled/"); EXPECT_THAT(engine_.recv_codecs(), Not(Contains(flexfec))); } @@ -1006,9 +997,8 @@ TEST_F(WebRtcVideoEngineTest, Flexfec03LowerPayloadTypeRange) { auto flexfec = Field("name", &VideoCodec::name, "flexfec-03"); // FlexFEC is active with field trial. - RTC_DCHECK(!override_field_trials_); - override_field_trials_ = std::make_unique( - "WebRTC-FlexFEC-03-Advertised/Enabled/"); + webrtc::test::ScopedKeyValueConfig override_field_trials( + field_trials_, "WebRTC-FlexFEC-03-Advertised/Enabled/"); auto send_codecs = engine_.send_codecs(); auto it = std::find_if(send_codecs.begin(), send_codecs.end(), [](const cricket::VideoCodec& codec) { @@ -1452,7 +1442,7 @@ class WebRtcVideoChannelEncodedFrameCallbackTest : public ::testing::Test { } static const std::vector kSdpVideoFormats; - webrtc::FieldTrialBasedConfig field_trials_; + webrtc::test::ScopedKeyValueConfig field_trials_; webrtc::RtcEventLogNull event_log_; std::unique_ptr task_queue_factory_; std::unique_ptr call_; @@ -1740,8 +1730,7 @@ class WebRtcVideoChannelBaseTest : public ::testing::Test { } webrtc::RtcEventLogNull event_log_; - webrtc::FieldTrialBasedConfig field_trials_; - std::unique_ptr override_field_trials_; + webrtc::test::ScopedKeyValueConfig field_trials_; std::unique_ptr task_queue_factory_; std::unique_ptr call_; std::unique_ptr @@ -1796,9 +1785,8 @@ TEST_F(WebRtcVideoChannelBaseTest, OverridesRecvBufferSize) { // Set field trial to override the default recv buffer size, and then re-run // setup where the interface is created and configured. const int kCustomRecvBufferSize = 123456; - RTC_DCHECK(!override_field_trials_); - override_field_trials_ = std::make_unique( - "WebRTC-IncreasedReceivebuffers/123456/"); + webrtc::test::ScopedKeyValueConfig override_field_trials( + field_trials_, "WebRTC-IncreasedReceivebuffers/123456/"); ResetTest(); @@ -1814,9 +1802,8 @@ TEST_F(WebRtcVideoChannelBaseTest, OverridesRecvBufferSizeWithSuffix) { // Set field trial to override the default recv buffer size, and then re-run // setup where the interface is created and configured. const int kCustomRecvBufferSize = 123456; - RTC_DCHECK(!override_field_trials_); - override_field_trials_ = std::make_unique( - "WebRTC-IncreasedReceivebuffers/123456_Dogfood/"); + webrtc::test::ScopedKeyValueConfig override_field_trials( + field_trials_, "WebRTC-IncreasedReceivebuffers/123456_Dogfood/"); ResetTest(); EXPECT_TRUE(SetOneCodec(DefaultCodec())); @@ -1832,8 +1819,6 @@ TEST_F(WebRtcVideoChannelBaseTest, InvalidRecvBufferSize) { // then re-run setup where the interface is created and configured. The // default value should still be used. - const char* prev_field_trials = webrtc::field_trial::GetFieldTrialString(); - std::string field_trial_string; for (std::string group : {" ", "NotANumber", "-1", "0"}) { std::string trial_string = "WebRTC-IncreasedReceivebuffers/"; @@ -1858,8 +1843,8 @@ TEST_F(WebRtcVideoChannelBaseTest, InvalidRecvBufferSize) { }); waiting.Wait(rtc::Event::kForever); - field_trial_string = std::move(trial_string); - webrtc::field_trial::InitFieldTrialsFromString(field_trial_string.c_str()); + webrtc::test::ScopedKeyValueConfig field_trial_override(field_trials_, + trial_string); SetUp(); resume.Set(); @@ -1873,8 +1858,6 @@ TEST_F(WebRtcVideoChannelBaseTest, InvalidRecvBufferSize) { EXPECT_EQ(64 * 1024, network_interface_.sendbuf_size()); EXPECT_EQ(256 * 1024, network_interface_.recvbuf_size()); } - - webrtc::field_trial::InitFieldTrialsFromString(prev_field_trials); } // Test that stats work properly for a 1-1 call. @@ -3177,17 +3160,15 @@ TEST_F(WebRtcVideoChannelTest, LossNotificationIsDisabledByDefault) { } TEST_F(WebRtcVideoChannelTest, LossNotificationIsEnabledByFieldTrial) { - RTC_DCHECK(!override_field_trials_); - override_field_trials_ = std::make_unique( - "WebRTC-RtcpLossNotification/Enabled/"); + webrtc::test::ScopedKeyValueConfig override_field_trials( + field_trials_, "WebRTC-RtcpLossNotification/Enabled/"); ResetTest(); TestLossNotificationState(true); } TEST_F(WebRtcVideoChannelTest, LossNotificationCanBeEnabledAndDisabled) { - RTC_DCHECK(!override_field_trials_); - override_field_trials_ = std::make_unique( - "WebRTC-RtcpLossNotification/Enabled/"); + webrtc::test::ScopedKeyValueConfig override_field_trials( + field_trials_, "WebRTC-RtcpLossNotification/Enabled/"); ResetTest(); AssignDefaultCodec(); @@ -3788,8 +3769,8 @@ TEST_F(WebRtcVideoChannelTest, VerifyMinBitrate) { } TEST_F(WebRtcVideoChannelTest, VerifyMinBitrateWithForcedFallbackFieldTrial) { - RTC_DCHECK(!override_field_trials_); - override_field_trials_ = std::make_unique( + webrtc::test::ScopedKeyValueConfig override_field_trials( + field_trials_, "WebRTC-VP8-Forced-Fallback-Encoder-v2/Enabled-1,2,34567/"); std::vector streams = AddSendStream()->GetVideoStreams(); ASSERT_EQ(1u, streams.size()); @@ -3798,9 +3779,8 @@ TEST_F(WebRtcVideoChannelTest, VerifyMinBitrateWithForcedFallbackFieldTrial) { TEST_F(WebRtcVideoChannelTest, BalancedDegradationPreferenceNotSupportedWithoutFieldtrial) { - RTC_DCHECK(!override_field_trials_); - override_field_trials_ = std::make_unique( - "WebRTC-Video-BalancedDegradation/Disabled/"); + webrtc::test::ScopedKeyValueConfig override_field_trials( + field_trials_, "WebRTC-Video-BalancedDegradation/Disabled/"); const bool kResolutionScalingEnabled = true; const bool kFpsScalingEnabled = false; TestDegradationPreference(kResolutionScalingEnabled, kFpsScalingEnabled); @@ -3808,9 +3788,8 @@ TEST_F(WebRtcVideoChannelTest, TEST_F(WebRtcVideoChannelTest, BalancedDegradationPreferenceSupportedBehindFieldtrial) { - RTC_DCHECK(!override_field_trials_); - override_field_trials_ = std::make_unique( - "WebRTC-Video-BalancedDegradation/Enabled/"); + webrtc::test::ScopedKeyValueConfig override_field_trials( + field_trials_, "WebRTC-Video-BalancedDegradation/Enabled/"); const bool kResolutionScalingEnabled = true; const bool kFpsScalingEnabled = true; TestDegradationPreference(kResolutionScalingEnabled, kFpsScalingEnabled); @@ -4000,7 +3979,7 @@ TEST_F(WebRtcVideoChannelTest, SetDefaultSendCodecs) { VideoCodec codec; EXPECT_TRUE(channel_->GetSendCodec(&codec)); - EXPECT_TRUE(codec.Matches(engine_.send_codecs()[0])); + EXPECT_TRUE(codec.Matches(engine_.send_codecs()[0], &field_trials_)); // Using a RTX setup to verify that the default RTX payload type is good. const std::vector ssrcs = MAKE_VECTOR(kSsrcs1); @@ -8857,7 +8836,7 @@ class WebRtcVideoChannelSimulcastTest : public ::testing::Test { cricket::FakeWebRtcVideoDecoderFactory* decoder_factory_; std::unique_ptr mock_rate_allocator_factory_; - webrtc::FieldTrialBasedConfig field_trials_; + webrtc::test::ScopedKeyValueConfig field_trials_; WebRtcVideoEngine engine_; std::unique_ptr channel_; uint32_t last_ssrc_; diff --git a/media/engine/webrtc_voice_engine.cc b/media/engine/webrtc_voice_engine.cc index 7f01b95642..a229658493 100644 --- a/media/engine/webrtc_voice_engine.cc +++ b/media/engine/webrtc_voice_engine.cc @@ -125,9 +125,10 @@ bool IsCodec(const AudioCodec& codec, const char* ref_name) { bool FindCodec(const std::vector& codecs, const AudioCodec& codec, - AudioCodec* found_codec) { + AudioCodec* found_codec, + const webrtc::WebRtcKeyValueConfig* field_trials) { for (const AudioCodec& c : codecs) { - if (c.Matches(codec)) { + if (c.Matches(codec, field_trials)) { if (found_codec != NULL) { *found_codec = c; } @@ -1557,7 +1558,7 @@ bool WebRtcVoiceMediaChannel::SetRecvCodecs( // Log a warning if a codec's payload type is changing. This used to be // treated as an error. It's abnormal, but not really illegal. AudioCodec old_codec; - if (FindCodec(recv_codecs_, codec, &old_codec) && + if (FindCodec(recv_codecs_, codec, &old_codec, &call_->trials()) && old_codec.id != codec.id) { RTC_LOG(LS_WARNING) << codec.name << " mapped to a second payload type (" << codec.id << ", was already mapped to " diff --git a/media/engine/webrtc_voice_engine_unittest.cc b/media/engine/webrtc_voice_engine_unittest.cc index a9f4f22cdc..9ff91f4ff6 100644 --- a/media/engine/webrtc_voice_engine_unittest.cc +++ b/media/engine/webrtc_voice_engine_unittest.cc @@ -33,10 +33,10 @@ #include "rtc_base/arraysize.h" #include "rtc_base/byte_order.h" #include "rtc_base/numerics/safe_conversions.h" -#include "test/field_trial.h" #include "test/gtest.h" #include "test/mock_audio_decoder_factory.h" #include "test/mock_audio_encoder_factory.h" +#include "test/scoped_key_value_config.h" using ::testing::_; using ::testing::ContainerEq; @@ -180,9 +180,7 @@ class FakeAudioSource : public cricket::AudioSource { class WebRtcVoiceEngineTestFake : public ::testing::TestWithParam { public: - WebRtcVoiceEngineTestFake() : WebRtcVoiceEngineTestFake("") {} - - explicit WebRtcVoiceEngineTestFake(const char* field_trials) + WebRtcVoiceEngineTestFake() : use_null_apm_(GetParam()), task_queue_factory_(webrtc::CreateDefaultTaskQueueFactory()), adm_(webrtc::test::MockAudioDeviceModule::CreateStrict()), @@ -190,8 +188,7 @@ class WebRtcVoiceEngineTestFake : public ::testing::TestWithParam { ? nullptr : rtc::make_ref_counted< StrictMock>()), - call_(), - override_field_trials_(field_trials) { + call_() { // AudioDeviceModule. AdmSetupExpectations(adm_); @@ -212,7 +209,7 @@ class WebRtcVoiceEngineTestFake : public ::testing::TestWithParam { auto decoder_factory = webrtc::CreateBuiltinAudioDecoderFactory(); engine_.reset(new cricket::WebRtcVoiceEngine( task_queue_factory_.get(), adm_, encoder_factory, decoder_factory, - nullptr, apm_, nullptr, trials_config_)); + nullptr, apm_, nullptr, field_trials_)); engine_->Init(); send_parameters_.codecs.push_back(kPcmuCodec); recv_parameters_.codecs.push_back(kPcmuCodec); @@ -800,10 +797,7 @@ class WebRtcVoiceEngineTestFake : public ::testing::TestWithParam { cricket::AudioRecvParameters recv_parameters_; FakeAudioSource fake_source_; webrtc::AudioProcessing::Config apm_config_; - - private: - webrtc::test::ScopedFieldTrials override_field_trials_; - webrtc::FieldTrialBasedConfig trials_config_; + webrtc::test::ScopedKeyValueConfig field_trials_; }; INSTANTIATE_TEST_SUITE_P(TestBothWithAndWithoutNullApm, @@ -1232,8 +1226,8 @@ TEST_P(WebRtcVoiceEngineTestFake, } TEST_P(WebRtcVoiceEngineTestFake, AdaptivePtimeFieldTrial) { - webrtc::test::ScopedFieldTrials override_field_trials( - "WebRTC-Audio-AdaptivePtime/enabled:true/"); + webrtc::test::ScopedKeyValueConfig override_field_trials( + field_trials_, "WebRTC-Audio-AdaptivePtime/enabled:true/"); EXPECT_TRUE(SetupSendStream()); EXPECT_TRUE(GetAudioNetworkAdaptorConfig(kSsrcX)); } @@ -2503,14 +2497,6 @@ TEST_P(WebRtcVoiceEngineTestFake, AudioNetworkAdaptorNotGetOverridden) { GetAudioNetworkAdaptorConfig(kSsrcX)); } -class WebRtcVoiceEngineWithSendSideBweWithOverheadTest - : public WebRtcVoiceEngineTestFake { - public: - WebRtcVoiceEngineWithSendSideBweWithOverheadTest() - : WebRtcVoiceEngineTestFake( - "WebRTC-Audio-Allocation/min:6000bps,max:32000bps/") {} -}; - // Test that we can set the outgoing SSRC properly. // SSRC is set in SetupSendStream() by calling AddSendStream. TEST_P(WebRtcVoiceEngineTestFake, SetSendSsrc) { diff --git a/media/sctp/sctp_transport_factory.cc b/media/sctp/sctp_transport_factory.cc index 071d7fdb23..21b5b026eb 100644 --- a/media/sctp/sctp_transport_factory.cc +++ b/media/sctp/sctp_transport_factory.cc @@ -10,12 +10,12 @@ #include "media/sctp/sctp_transport_factory.h" +#include "api/webrtc_key_value_config.h" #include "rtc_base/system/unused.h" #ifdef WEBRTC_HAVE_DCSCTP #include "media/sctp/dcsctp_transport.h" // nogncheck #include "system_wrappers/include/clock.h" // nogncheck -#include "system_wrappers/include/field_trial.h" // nogncheck #endif #ifdef WEBRTC_HAVE_USRSCTP @@ -24,12 +24,14 @@ namespace cricket { -SctpTransportFactory::SctpTransportFactory(rtc::Thread* network_thread) +SctpTransportFactory::SctpTransportFactory( + rtc::Thread* network_thread, + const webrtc::WebRtcKeyValueConfig& field_trials) : network_thread_(network_thread), use_usrsctp_("Disabled", false) { RTC_UNUSED(network_thread_); #ifdef WEBRTC_HAVE_DCSCTP - webrtc::ParseFieldTrial({&use_usrsctp_}, webrtc::field_trial::FindFullName( - "WebRTC-DataChannel-Dcsctp")); + webrtc::ParseFieldTrial({&use_usrsctp_}, + field_trials.Lookup("WebRTC-DataChannel-Dcsctp")); #endif } diff --git a/media/sctp/sctp_transport_factory.h b/media/sctp/sctp_transport_factory.h index 9ae246a6a6..4fcec8e0e0 100644 --- a/media/sctp/sctp_transport_factory.h +++ b/media/sctp/sctp_transport_factory.h @@ -14,6 +14,7 @@ #include #include "api/transport/sctp_transport_factory_interface.h" +#include "api/webrtc_key_value_config.h" #include "media/sctp/sctp_transport_internal.h" #include "rtc_base/experiments/field_trial_parser.h" #include "rtc_base/thread.h" @@ -22,7 +23,9 @@ namespace cricket { class SctpTransportFactory : public webrtc::SctpTransportFactoryInterface { public: - explicit SctpTransportFactory(rtc::Thread* network_thread); + explicit SctpTransportFactory( + rtc::Thread* network_thread, + const webrtc::WebRtcKeyValueConfig& field_trials); std::unique_ptr CreateSctpTransport( rtc::PacketTransportInternal* transport) override; diff --git a/pc/channel_manager_unittest.cc b/pc/channel_manager_unittest.cc index 7d7d3e475f..7b0146c976 100644 --- a/pc/channel_manager_unittest.cc +++ b/pc/channel_manager_unittest.cc @@ -99,25 +99,25 @@ TEST_F(ChannelManagerTest, SetVideoRtxEnabled) { // By default RTX is disabled. cm_->GetSupportedVideoSendCodecs(&send_codecs); - EXPECT_FALSE(ContainsMatchingCodec(send_codecs, rtx_codec)); + EXPECT_FALSE(ContainsMatchingCodec(send_codecs, rtx_codec, &field_trials_)); cm_->GetSupportedVideoSendCodecs(&recv_codecs); - EXPECT_FALSE(ContainsMatchingCodec(recv_codecs, rtx_codec)); + EXPECT_FALSE(ContainsMatchingCodec(recv_codecs, rtx_codec, &field_trials_)); // Enable and check. cm_ = cricket::ChannelManager::Create(CreateFakeMediaEngine(), true, worker_, network_.get()); cm_->GetSupportedVideoSendCodecs(&send_codecs); - EXPECT_TRUE(ContainsMatchingCodec(send_codecs, rtx_codec)); + EXPECT_TRUE(ContainsMatchingCodec(send_codecs, rtx_codec, &field_trials_)); cm_->GetSupportedVideoSendCodecs(&recv_codecs); - EXPECT_TRUE(ContainsMatchingCodec(recv_codecs, rtx_codec)); + EXPECT_TRUE(ContainsMatchingCodec(recv_codecs, rtx_codec, &field_trials_)); // Disable and check. cm_ = cricket::ChannelManager::Create(CreateFakeMediaEngine(), false, worker_, network_.get()); cm_->GetSupportedVideoSendCodecs(&send_codecs); - EXPECT_FALSE(ContainsMatchingCodec(send_codecs, rtx_codec)); + EXPECT_FALSE(ContainsMatchingCodec(send_codecs, rtx_codec, &field_trials_)); cm_->GetSupportedVideoSendCodecs(&recv_codecs); - EXPECT_FALSE(ContainsMatchingCodec(recv_codecs, rtx_codec)); + EXPECT_FALSE(ContainsMatchingCodec(recv_codecs, rtx_codec, &field_trials_)); } TEST_F(ChannelManagerTest, CreateDestroyChannels) { diff --git a/pc/channel_unittest.cc b/pc/channel_unittest.cc index 463f60bf35..725ee34918 100644 --- a/pc/channel_unittest.cc +++ b/pc/channel_unittest.cc @@ -2020,9 +2020,11 @@ TEST_F(VideoChannelSingleThreadTest, TestSetLocalOfferWithPacketization) { EXPECT_TRUE(channel1_->SetLocalContent(&video, SdpType::kOffer, err)); EXPECT_THAT(media_channel1()->send_codecs(), testing::IsEmpty()); ASSERT_THAT(media_channel1()->recv_codecs(), testing::SizeIs(2)); - EXPECT_TRUE(media_channel1()->recv_codecs()[0].Matches(kVp8Codec)); + EXPECT_TRUE( + media_channel1()->recv_codecs()[0].Matches(kVp8Codec, &field_trials_)); EXPECT_EQ(media_channel1()->recv_codecs()[0].packetization, absl::nullopt); - EXPECT_TRUE(media_channel1()->recv_codecs()[1].Matches(vp9_codec)); + EXPECT_TRUE( + media_channel1()->recv_codecs()[1].Matches(vp9_codec, &field_trials_)); EXPECT_EQ(media_channel1()->recv_codecs()[1].packetization, cricket::kPacketizationParamRaw); } @@ -2041,9 +2043,11 @@ TEST_F(VideoChannelSingleThreadTest, TestSetRemoteOfferWithPacketization) { EXPECT_TRUE(err.empty()); EXPECT_THAT(media_channel1()->recv_codecs(), testing::IsEmpty()); ASSERT_THAT(media_channel1()->send_codecs(), testing::SizeIs(2)); - EXPECT_TRUE(media_channel1()->send_codecs()[0].Matches(kVp8Codec)); + EXPECT_TRUE( + media_channel1()->send_codecs()[0].Matches(kVp8Codec, &field_trials_)); EXPECT_EQ(media_channel1()->send_codecs()[0].packetization, absl::nullopt); - EXPECT_TRUE(media_channel1()->send_codecs()[1].Matches(vp9_codec)); + EXPECT_TRUE( + media_channel1()->send_codecs()[1].Matches(vp9_codec, &field_trials_)); EXPECT_EQ(media_channel1()->send_codecs()[1].packetization, cricket::kPacketizationParamRaw); } @@ -2063,15 +2067,19 @@ TEST_F(VideoChannelSingleThreadTest, TestSetAnswerWithPacketization) { EXPECT_TRUE(channel1_->SetRemoteContent(&video, SdpType::kAnswer, err)); EXPECT_TRUE(err.empty()); ASSERT_THAT(media_channel1()->recv_codecs(), testing::SizeIs(2)); - EXPECT_TRUE(media_channel1()->recv_codecs()[0].Matches(kVp8Codec)); + EXPECT_TRUE( + media_channel1()->recv_codecs()[0].Matches(kVp8Codec, &field_trials_)); EXPECT_EQ(media_channel1()->recv_codecs()[0].packetization, absl::nullopt); - EXPECT_TRUE(media_channel1()->recv_codecs()[1].Matches(vp9_codec)); + EXPECT_TRUE( + media_channel1()->recv_codecs()[1].Matches(vp9_codec, &field_trials_)); EXPECT_EQ(media_channel1()->recv_codecs()[1].packetization, cricket::kPacketizationParamRaw); EXPECT_THAT(media_channel1()->send_codecs(), testing::SizeIs(2)); - EXPECT_TRUE(media_channel1()->send_codecs()[0].Matches(kVp8Codec)); + EXPECT_TRUE( + media_channel1()->send_codecs()[0].Matches(kVp8Codec, &field_trials_)); EXPECT_EQ(media_channel1()->send_codecs()[0].packetization, absl::nullopt); - EXPECT_TRUE(media_channel1()->send_codecs()[1].Matches(vp9_codec)); + EXPECT_TRUE( + media_channel1()->send_codecs()[1].Matches(vp9_codec, &field_trials_)); EXPECT_EQ(media_channel1()->send_codecs()[1].packetization, cricket::kPacketizationParamRaw); } diff --git a/pc/connection_context.cc b/pc/connection_context.cc index 31810bca62..8583e7ba04 100644 --- a/pc/connection_context.cc +++ b/pc/connection_context.cc @@ -79,7 +79,8 @@ std::unique_ptr MaybeCreateSctpFactory( return factory; } #ifdef WEBRTC_HAVE_SCTP - return std::make_unique(network_thread); + return std::make_unique(network_thread, + field_trials); #else return nullptr; #endif diff --git a/pc/media_session.cc b/pc/media_session.cc index 9aeae708d7..2ab661cd69 100644 --- a/pc/media_session.cc +++ b/pc/media_session.cc @@ -726,13 +726,16 @@ static bool CreateMediaContentOffer( } template -static bool ReferencedCodecsMatch(const std::vector& codecs1, - const int codec1_id, - const std::vector& codecs2, - const int codec2_id) { +static bool ReferencedCodecsMatch( + const std::vector& codecs1, + const int codec1_id, + const std::vector& codecs2, + const int codec2_id, + const webrtc::WebRtcKeyValueConfig* field_trials) { const C* codec1 = FindCodecById(codecs1, codec1_id); const C* codec2 = FindCodecById(codecs2, codec2_id); - return codec1 != nullptr && codec2 != nullptr && codec1->Matches(*codec2); + return codec1 != nullptr && codec2 != nullptr && + codec1->Matches(*codec2, field_trials); } template @@ -752,12 +755,14 @@ template static void NegotiateCodecs(const std::vector& local_codecs, const std::vector& offered_codecs, std::vector* negotiated_codecs, - bool keep_offer_order) { + bool keep_offer_order, + const webrtc::WebRtcKeyValueConfig* field_trials) { for (const C& ours : local_codecs) { C theirs; // Note that we intentionally only find one matching codec for each of our // local codecs, in case the remote offer contains duplicate codecs. - if (FindMatchingCodec(local_codecs, offered_codecs, ours, &theirs)) { + if (FindMatchingCodec(local_codecs, offered_codecs, ours, &theirs, + field_trials)) { C negotiated = ours; NegotiatePacketization(ours, theirs, &negotiated); negotiated.IntersectFeedbackParams(theirs); @@ -810,10 +815,12 @@ static void NegotiateCodecs(const std::vector& local_codecs, // a member of `codecs1`. If `codec_to_match` is an RED or RTX codec, both // the codecs themselves and their associated codecs must match. template -static bool FindMatchingCodec(const std::vector& codecs1, - const std::vector& codecs2, - const C& codec_to_match, - C* found_codec) { +static bool FindMatchingCodec( + const std::vector& codecs1, + const std::vector& codecs2, + const C& codec_to_match, + C* found_codec, + const webrtc::WebRtcKeyValueConfig* field_trials) { // `codec_to_match` should be a member of `codecs1`, in order to look up // RED/RTX codecs' associated codecs correctly. If not, that's a programming // error. @@ -821,7 +828,7 @@ static bool FindMatchingCodec(const std::vector& codecs1, return &codec == &codec_to_match; })); for (const C& potential_match : codecs2) { - if (potential_match.Matches(codec_to_match)) { + if (potential_match.Matches(codec_to_match, field_trials)) { if (IsRtxCodec(codec_to_match)) { int apt_value_1 = 0; int apt_value_2 = 0; @@ -832,8 +839,8 @@ static bool FindMatchingCodec(const std::vector& codecs1, RTC_LOG(LS_WARNING) << "RTX missing associated payload type."; continue; } - if (!ReferencedCodecsMatch(codecs1, apt_value_1, codecs2, - apt_value_2)) { + if (!ReferencedCodecsMatch(codecs1, apt_value_1, codecs2, apt_value_2, + field_trials)) { continue; } } else if (IsRedCodec(codec_to_match)) { @@ -876,7 +883,7 @@ static bool FindMatchingCodec(const std::vector& codecs1, if (rtc::FromString(redundant_payloads_1[0], &red_value_1) && rtc::FromString(redundant_payloads_2[0], &red_value_2)) { if (!ReferencedCodecsMatch(codecs1, red_value_1, codecs2, - red_value_2)) { + red_value_2, field_trials)) { continue; } } @@ -967,14 +974,15 @@ static const C* GetAssociatedCodecForRed(const std::vector& codec_list, template static void MergeCodecs(const std::vector& reference_codecs, std::vector* offered_codecs, - UsedPayloadTypes* used_pltypes) { + UsedPayloadTypes* used_pltypes, + const webrtc::WebRtcKeyValueConfig* field_trials) { // Add all new codecs that are not RTX/RED codecs. // The two-pass splitting of the loops means preferring payload types // of actual codecs with respect to collisions. for (const C& reference_codec : reference_codecs) { if (!IsRtxCodec(reference_codec) && !IsRedCodec(reference_codec) && !FindMatchingCodec(reference_codecs, *offered_codecs, - reference_codec, nullptr)) { + reference_codec, nullptr, field_trials)) { C codec = reference_codec; used_pltypes->FindAndSetIdUsed(&codec); offered_codecs->push_back(codec); @@ -985,7 +993,7 @@ static void MergeCodecs(const std::vector& reference_codecs, for (const C& reference_codec : reference_codecs) { if (IsRtxCodec(reference_codec) && !FindMatchingCodec(reference_codecs, *offered_codecs, - reference_codec, nullptr)) { + reference_codec, nullptr, field_trials)) { C rtx_codec = reference_codec; const C* associated_codec = GetAssociatedCodecForRtx(reference_codecs, rtx_codec); @@ -996,7 +1004,8 @@ static void MergeCodecs(const std::vector& reference_codecs, // Its payload type may be different than the reference codec. C matching_codec; if (!FindMatchingCodec(reference_codecs, *offered_codecs, - *associated_codec, &matching_codec)) { + *associated_codec, &matching_codec, + field_trials)) { RTC_LOG(LS_WARNING) << "Couldn't find matching " << associated_codec->name << " codec."; continue; @@ -1008,14 +1017,15 @@ static void MergeCodecs(const std::vector& reference_codecs, offered_codecs->push_back(rtx_codec); } else if (IsRedCodec(reference_codec) && !FindMatchingCodec(reference_codecs, *offered_codecs, - reference_codec, nullptr)) { + reference_codec, nullptr, field_trials)) { C red_codec = reference_codec; const C* associated_codec = GetAssociatedCodecForRed(reference_codecs, red_codec); if (associated_codec) { C matching_codec; if (!FindMatchingCodec(reference_codecs, *offered_codecs, - *associated_codec, &matching_codec)) { + *associated_codec, &matching_codec, + field_trials)) { RTC_LOG(LS_WARNING) << "Couldn't find matching " << associated_codec->name << " codec."; continue; @@ -1039,7 +1049,8 @@ template static Codecs MatchCodecPreference( const std::vector& codec_preferences, const Codecs& codecs, - const Codecs& supported_codecs) { + const Codecs& supported_codecs, + const webrtc::WebRtcKeyValueConfig* field_trials) { Codecs filtered_codecs; bool want_rtx = false; bool want_red = false; @@ -1068,7 +1079,7 @@ static Codecs MatchCodecPreference( if (found_codec != supported_codecs.end()) { typename Codecs::value_type found_codec_with_correct_pt; if (FindMatchingCodec(supported_codecs, codecs, *found_codec, - &found_codec_with_correct_pt)) { + &found_codec_with_correct_pt, field_trials)) { filtered_codecs.push_back(found_codec_with_correct_pt); std::string id = rtc::ToString(found_codec_with_correct_pt.id); // Search for the matching rtx or red codec. @@ -1111,8 +1122,10 @@ static Codecs MatchCodecPreference( // Compute the union of `codecs1` and `codecs2`. template -std::vector ComputeCodecsUnion(const std::vector& codecs1, - const std::vector& codecs2) { +std::vector ComputeCodecsUnion( + const std::vector& codecs1, + const std::vector& codecs2, + const webrtc::WebRtcKeyValueConfig* field_trials) { std::vector all_codecs; UsedPayloadTypes used_payload_types; for (const C& codec : codecs1) { @@ -1123,7 +1136,7 @@ std::vector ComputeCodecsUnion(const std::vector& codecs1, // Use MergeCodecs to merge the second half of our list as it already checks // and fixes problems with duplicate payload types. - MergeCodecs(codecs2, &all_codecs, &used_payload_types); + MergeCodecs(codecs2, &all_codecs, &used_payload_types, field_trials); return all_codecs; } @@ -1355,7 +1368,8 @@ static bool SetCodecsInAnswer( const webrtc::WebRtcKeyValueConfig& field_trials) { std::vector negotiated_codecs; NegotiateCodecs(local_codecs, offer->codecs(), &negotiated_codecs, - media_description_options.codec_preferences.empty()); + media_description_options.codec_preferences.empty(), + &field_trials); answer->AddCodecs(negotiated_codecs); answer->set_protocol(offer->protocol()); if (!AddStreamParams(media_description_options.sender_options, @@ -2039,16 +2053,19 @@ void MergeCodecsFromDescription( const std::vector& current_active_contents, AudioCodecs* audio_codecs, VideoCodecs* video_codecs, - UsedPayloadTypes* used_pltypes) { + UsedPayloadTypes* used_pltypes, + const webrtc::WebRtcKeyValueConfig* field_trials) { for (const ContentInfo* content : current_active_contents) { if (IsMediaContentOfType(content, MEDIA_TYPE_AUDIO)) { const AudioContentDescription* audio = content->media_description()->as_audio(); - MergeCodecs(audio->codecs(), audio_codecs, used_pltypes); + MergeCodecs(audio->codecs(), audio_codecs, used_pltypes, + field_trials); } else if (IsMediaContentOfType(content, MEDIA_TYPE_VIDEO)) { const VideoContentDescription* video = content->media_description()->as_video(); - MergeCodecs(video->codecs(), video_codecs, used_pltypes); + MergeCodecs(video->codecs(), video_codecs, used_pltypes, + field_trials); } } } @@ -2063,16 +2080,20 @@ void MediaSessionDescriptionFactory::GetCodecsForOffer( const std::vector& current_active_contents, AudioCodecs* audio_codecs, VideoCodecs* video_codecs) const { + const webrtc::WebRtcKeyValueConfig* field_trials = + &transport_desc_factory_->trials(); // First - get all codecs from the current description if the media type // is used. Add them to `used_pltypes` so the payload type is not reused if a // new media type is added. UsedPayloadTypes used_pltypes; MergeCodecsFromDescription(current_active_contents, audio_codecs, - video_codecs, &used_pltypes); + video_codecs, &used_pltypes, field_trials); // Add our codecs that are not in the current description. - MergeCodecs(all_audio_codecs_, audio_codecs, &used_pltypes); - MergeCodecs(all_video_codecs_, video_codecs, &used_pltypes); + MergeCodecs(all_audio_codecs_, audio_codecs, &used_pltypes, + field_trials); + MergeCodecs(all_video_codecs_, video_codecs, &used_pltypes, + field_trials); } // Getting codecs for an answer involves these steps: @@ -2087,12 +2108,14 @@ void MediaSessionDescriptionFactory::GetCodecsForAnswer( const SessionDescription& remote_offer, AudioCodecs* audio_codecs, VideoCodecs* video_codecs) const { + const webrtc::WebRtcKeyValueConfig* field_trials = + &transport_desc_factory_->trials(); // First - get all codecs from the current description if the media type // is used. Add them to `used_pltypes` so the payload type is not reused if a // new media type is added. UsedPayloadTypes used_pltypes; MergeCodecsFromDescription(current_active_contents, audio_codecs, - video_codecs, &used_pltypes); + video_codecs, &used_pltypes, field_trials); // Second - filter out codecs that we don't support at all and should ignore. AudioCodecs filtered_offered_audio_codecs; @@ -2102,11 +2125,12 @@ void MediaSessionDescriptionFactory::GetCodecsForAnswer( const AudioContentDescription* audio = content.media_description()->as_audio(); for (const AudioCodec& offered_audio_codec : audio->codecs()) { - if (!FindMatchingCodec(audio->codecs(), - filtered_offered_audio_codecs, - offered_audio_codec, nullptr) && + if (!FindMatchingCodec( + audio->codecs(), filtered_offered_audio_codecs, + offered_audio_codec, nullptr, field_trials) && FindMatchingCodec(audio->codecs(), all_audio_codecs_, - offered_audio_codec, nullptr)) { + offered_audio_codec, nullptr, + field_trials)) { filtered_offered_audio_codecs.push_back(offered_audio_codec); } } @@ -2114,11 +2138,12 @@ void MediaSessionDescriptionFactory::GetCodecsForAnswer( const VideoContentDescription* video = content.media_description()->as_video(); for (const VideoCodec& offered_video_codec : video->codecs()) { - if (!FindMatchingCodec(video->codecs(), - filtered_offered_video_codecs, - offered_video_codec, nullptr) && + if (!FindMatchingCodec( + video->codecs(), filtered_offered_video_codecs, + offered_video_codec, nullptr, field_trials) && FindMatchingCodec(video->codecs(), all_video_codecs_, - offered_video_codec, nullptr)) { + offered_video_codec, nullptr, + field_trials)) { filtered_offered_video_codecs.push_back(offered_video_codec); } } @@ -2128,9 +2153,9 @@ void MediaSessionDescriptionFactory::GetCodecsForAnswer( // Add codecs that are not in the current description but were in // `remote_offer`. MergeCodecs(filtered_offered_audio_codecs, audio_codecs, - &used_pltypes); + &used_pltypes, field_trials); MergeCodecs(filtered_offered_video_codecs, video_codecs, - &used_pltypes); + &used_pltypes, field_trials); } MediaSessionDescriptionFactory::AudioVideoRtpHeaderExtensions @@ -2272,6 +2297,8 @@ bool MediaSessionDescriptionFactory::AddAudioContentForOffer( StreamParamsVec* current_streams, SessionDescription* desc, IceCredentialsIterator* ice_credentials) const { + const webrtc::WebRtcKeyValueConfig* field_trials = + &transport_desc_factory_->trials(); // Filter audio_codecs (which includes all codecs, with correctly remapped // payload types) based on transceiver direction. const AudioCodecs& supported_audio_codecs = @@ -2282,9 +2309,9 @@ bool MediaSessionDescriptionFactory::AddAudioContentForOffer( if (!media_description_options.codec_preferences.empty()) { // Add the codecs from the current transceiver's codec preferences. // They override any existing codecs from previous negotiations. - filtered_codecs = - MatchCodecPreference(media_description_options.codec_preferences, - audio_codecs, supported_audio_codecs); + filtered_codecs = MatchCodecPreference( + media_description_options.codec_preferences, audio_codecs, + supported_audio_codecs, field_trials); } else { // Add the codecs from current content if it exists and is not rejected nor // recycled. @@ -2295,7 +2322,7 @@ bool MediaSessionDescriptionFactory::AddAudioContentForOffer( current_content->media_description()->as_audio(); for (const AudioCodec& codec : acd->codecs()) { if (FindMatchingCodec(acd->codecs(), audio_codecs, codec, - nullptr)) { + nullptr, field_trials)) { filtered_codecs.push_back(codec); } } @@ -2304,9 +2331,10 @@ bool MediaSessionDescriptionFactory::AddAudioContentForOffer( AudioCodec found_codec; for (const AudioCodec& codec : supported_audio_codecs) { if (FindMatchingCodec(supported_audio_codecs, audio_codecs, - codec, &found_codec) && + codec, &found_codec, field_trials) && !FindMatchingCodec(supported_audio_codecs, - filtered_codecs, codec, nullptr)) { + filtered_codecs, codec, nullptr, + field_trials)) { // Use the `found_codec` from `audio_codecs` because it has the // correctly mapped payload type. filtered_codecs.push_back(found_codec); @@ -2362,6 +2390,8 @@ bool MediaSessionDescriptionFactory::AddVideoContentForOffer( StreamParamsVec* current_streams, SessionDescription* desc, IceCredentialsIterator* ice_credentials) const { + const webrtc::WebRtcKeyValueConfig* field_trials = + &transport_desc_factory_->trials(); // Filter video_codecs (which includes all codecs, with correctly remapped // payload types) based on transceiver direction. const VideoCodecs& supported_video_codecs = @@ -2372,9 +2402,9 @@ bool MediaSessionDescriptionFactory::AddVideoContentForOffer( if (!media_description_options.codec_preferences.empty()) { // Add the codecs from the current transceiver's codec preferences. // They override any existing codecs from previous negotiations. - filtered_codecs = - MatchCodecPreference(media_description_options.codec_preferences, - video_codecs, supported_video_codecs); + filtered_codecs = MatchCodecPreference( + media_description_options.codec_preferences, video_codecs, + supported_video_codecs, field_trials); } else { // Add the codecs from current content if it exists and is not rejected nor // recycled. @@ -2385,7 +2415,7 @@ bool MediaSessionDescriptionFactory::AddVideoContentForOffer( current_content->media_description()->as_video(); for (const VideoCodec& codec : vcd->codecs()) { if (FindMatchingCodec(vcd->codecs(), video_codecs, codec, - nullptr)) { + nullptr, field_trials)) { filtered_codecs.push_back(codec); } } @@ -2394,9 +2424,10 @@ bool MediaSessionDescriptionFactory::AddVideoContentForOffer( VideoCodec found_codec; for (const VideoCodec& codec : supported_video_codecs) { if (FindMatchingCodec(supported_video_codecs, video_codecs, - codec, &found_codec) && + codec, &found_codec, field_trials) && !FindMatchingCodec(supported_video_codecs, - filtered_codecs, codec, nullptr)) { + filtered_codecs, codec, nullptr, + field_trials)) { // Use the `found_codec` from `video_codecs` because it has the // correctly mapped payload type. if (IsRtxCodec(codec)) { @@ -2408,9 +2439,9 @@ bool MediaSessionDescriptionFactory::AddVideoContentForOffer( // Find the codec we should be referencing and point to it. VideoCodec changed_referenced_codec; - if (FindMatchingCodec(supported_video_codecs, - filtered_codecs, *referenced_codec, - &changed_referenced_codec)) { + if (FindMatchingCodec( + supported_video_codecs, filtered_codecs, *referenced_codec, + &changed_referenced_codec, field_trials)) { found_codec.SetParam(kCodecParamAssociatedPayloadType, changed_referenced_codec.id); } @@ -2556,6 +2587,8 @@ bool MediaSessionDescriptionFactory::AddAudioContentForAnswer( StreamParamsVec* current_streams, SessionDescription* answer, IceCredentialsIterator* ice_credentials) const { + const webrtc::WebRtcKeyValueConfig* field_trials = + &transport_desc_factory_->trials(); RTC_CHECK(IsMediaContentOfType(offer_content, MEDIA_TYPE_AUDIO)); const AudioContentDescription* offer_audio_description = offer_content->media_description()->as_audio(); @@ -2580,9 +2613,9 @@ bool MediaSessionDescriptionFactory::AddAudioContentForAnswer( AudioCodecs filtered_codecs; if (!media_description_options.codec_preferences.empty()) { - filtered_codecs = - MatchCodecPreference(media_description_options.codec_preferences, - audio_codecs, supported_audio_codecs); + filtered_codecs = MatchCodecPreference( + media_description_options.codec_preferences, audio_codecs, + supported_audio_codecs, field_trials); } else { // Add the codecs from current content if it exists and is not rejected nor // recycled. @@ -2593,7 +2626,7 @@ bool MediaSessionDescriptionFactory::AddAudioContentForAnswer( current_content->media_description()->as_audio(); for (const AudioCodec& codec : acd->codecs()) { if (FindMatchingCodec(acd->codecs(), audio_codecs, codec, - nullptr)) { + nullptr, field_trials)) { filtered_codecs.push_back(codec); } } @@ -2601,9 +2634,10 @@ bool MediaSessionDescriptionFactory::AddAudioContentForAnswer( // Add other supported audio codecs. for (const AudioCodec& codec : supported_audio_codecs) { if (FindMatchingCodec(supported_audio_codecs, audio_codecs, - codec, nullptr) && + codec, nullptr, field_trials) && !FindMatchingCodec(supported_audio_codecs, - filtered_codecs, codec, nullptr)) { + filtered_codecs, codec, nullptr, + field_trials)) { // We should use the local codec with local parameters and the codec id // would be correctly mapped in `NegotiateCodecs`. filtered_codecs.push_back(codec); @@ -2672,6 +2706,8 @@ bool MediaSessionDescriptionFactory::AddVideoContentForAnswer( StreamParamsVec* current_streams, SessionDescription* answer, IceCredentialsIterator* ice_credentials) const { + const webrtc::WebRtcKeyValueConfig* field_trials = + &transport_desc_factory_->trials(); RTC_CHECK(IsMediaContentOfType(offer_content, MEDIA_TYPE_VIDEO)); const VideoContentDescription* offer_video_description = offer_content->media_description()->as_video(); @@ -2696,9 +2732,9 @@ bool MediaSessionDescriptionFactory::AddVideoContentForAnswer( VideoCodecs filtered_codecs; if (!media_description_options.codec_preferences.empty()) { - filtered_codecs = - MatchCodecPreference(media_description_options.codec_preferences, - video_codecs, supported_video_codecs); + filtered_codecs = MatchCodecPreference( + media_description_options.codec_preferences, video_codecs, + supported_video_codecs, field_trials); } else { // Add the codecs from current content if it exists and is not rejected nor // recycled. @@ -2709,7 +2745,7 @@ bool MediaSessionDescriptionFactory::AddVideoContentForAnswer( current_content->media_description()->as_video(); for (const VideoCodec& codec : vcd->codecs()) { if (FindMatchingCodec(vcd->codecs(), video_codecs, codec, - nullptr)) { + nullptr, field_trials)) { filtered_codecs.push_back(codec); } } @@ -2719,9 +2755,10 @@ bool MediaSessionDescriptionFactory::AddVideoContentForAnswer( VideoCodecs other_video_codecs; for (const VideoCodec& codec : supported_video_codecs) { if (FindMatchingCodec(supported_video_codecs, video_codecs, - codec, nullptr) && + codec, nullptr, field_trials) && !FindMatchingCodec(supported_video_codecs, - filtered_codecs, codec, nullptr)) { + filtered_codecs, codec, nullptr, + field_trials)) { // We should use the local codec with local parameters and the codec id // would be correctly mapped in `NegotiateCodecs`. other_video_codecs.push_back(codec); @@ -2729,8 +2766,8 @@ bool MediaSessionDescriptionFactory::AddVideoContentForAnswer( } // Use ComputeCodecsUnion to avoid having duplicate payload IDs - filtered_codecs = - ComputeCodecsUnion(filtered_codecs, other_video_codecs); + filtered_codecs = ComputeCodecsUnion( + filtered_codecs, other_video_codecs, field_trials); } if (session_options.raw_packetization_for_video) { @@ -2895,13 +2932,15 @@ bool MediaSessionDescriptionFactory::AddUnsupportedContentForAnswer( } void MediaSessionDescriptionFactory::ComputeAudioCodecsIntersectionAndUnion() { + const webrtc::WebRtcKeyValueConfig* field_trials = + &transport_desc_factory_->trials(); audio_sendrecv_codecs_.clear(); all_audio_codecs_.clear(); // Compute the audio codecs union. for (const AudioCodec& send : audio_send_codecs_) { all_audio_codecs_.push_back(send); if (!FindMatchingCodec(audio_send_codecs_, audio_recv_codecs_, - send, nullptr)) { + send, nullptr, field_trials)) { // It doesn't make sense to have an RTX codec we support sending but not // receiving. RTC_DCHECK(!IsRtxCodec(send)); @@ -2909,7 +2948,7 @@ void MediaSessionDescriptionFactory::ComputeAudioCodecsIntersectionAndUnion() { } for (const AudioCodec& recv : audio_recv_codecs_) { if (!FindMatchingCodec(audio_recv_codecs_, audio_send_codecs_, - recv, nullptr)) { + recv, nullptr, field_trials)) { all_audio_codecs_.push_back(recv); } } @@ -2919,15 +2958,17 @@ void MediaSessionDescriptionFactory::ComputeAudioCodecsIntersectionAndUnion() { // expensive than decoding, and prioritizing a codec in the send list probably // means it's a codec we can handle efficiently. NegotiateCodecs(audio_recv_codecs_, audio_send_codecs_, - &audio_sendrecv_codecs_, true); + &audio_sendrecv_codecs_, true, field_trials); } void MediaSessionDescriptionFactory::ComputeVideoCodecsIntersectionAndUnion() { + const webrtc::WebRtcKeyValueConfig* field_trials = + &transport_desc_factory_->trials(); video_sendrecv_codecs_.clear(); // Use ComputeCodecsUnion to avoid having duplicate payload IDs all_video_codecs_ = - ComputeCodecsUnion(video_recv_codecs_, video_send_codecs_); + ComputeCodecsUnion(video_recv_codecs_, video_send_codecs_, field_trials); // Use NegotiateCodecs to merge our codec lists, since the operation is // essentially the same. Put send_codecs as the offered_codecs, which is the @@ -2935,7 +2976,7 @@ void MediaSessionDescriptionFactory::ComputeVideoCodecsIntersectionAndUnion() { // expensive than decoding, and prioritizing a codec in the send list probably // means it's a codec we can handle efficiently. NegotiateCodecs(video_recv_codecs_, video_send_codecs_, - &video_sendrecv_codecs_, true); + &video_sendrecv_codecs_, true, field_trials); } bool IsMediaContent(const ContentInfo* content) { diff --git a/pc/media_session_unittest.cc b/pc/media_session_unittest.cc index f06ddc7586..ee71c6ba7d 100644 --- a/pc/media_session_unittest.cc +++ b/pc/media_session_unittest.cc @@ -4454,13 +4454,14 @@ namespace { // Compare the two vectors of codecs ignoring the payload type. template bool CodecsMatch(const std::vector& codecs1, - const std::vector& codecs2) { + const std::vector& codecs2, + const webrtc::WebRtcKeyValueConfig* field_trials) { if (codecs1.size() != codecs2.size()) { return false; } for (size_t i = 0; i < codecs1.size(); ++i) { - if (!codecs1[i].Matches(codecs2[i])) { + if (!codecs1[i].Matches(codecs2[i], field_trials)) { return false; } } @@ -4503,11 +4504,14 @@ void TestAudioCodecsOffer(RtpTransceiverDirection direction) { // might eventually be used anything, but we don't know more at this // moment. if (acd->direction() == RtpTransceiverDirection::kSendOnly) { - EXPECT_TRUE(CodecsMatch(send_codecs, acd->codecs())); + EXPECT_TRUE( + CodecsMatch(send_codecs, acd->codecs(), &field_trials)); } else if (acd->direction() == RtpTransceiverDirection::kRecvOnly) { - EXPECT_TRUE(CodecsMatch(recv_codecs, acd->codecs())); + EXPECT_TRUE( + CodecsMatch(recv_codecs, acd->codecs(), &field_trials)); } else { - EXPECT_TRUE(CodecsMatch(sendrecv_codecs, acd->codecs())); + EXPECT_TRUE(CodecsMatch(sendrecv_codecs, acd->codecs(), + &field_trials)); } } } diff --git a/test/BUILD.gn b/test/BUILD.gn index 82d909d1ae..a791878baa 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -110,6 +110,7 @@ rtc_library("video_test_common") { deps = [ ":fileutils", ":frame_utils", + ":scoped_key_value_config", "../api:array_view", "../api:create_frame_generator", "../api:frame_generator_api", @@ -178,6 +179,7 @@ if (!build_with_chromium) { "vcm_capturer.h", ] deps += [ + ":scoped_key_value_config", "../api:scoped_refptr", "../modules/video_capture:video_capture_module", "../rtc_base:checks", @@ -524,6 +526,7 @@ if (rtc_include_tests && !build_with_chromium) { ":perf_test", ":rtc_expect_death", ":rtp_test_utils", + ":scoped_key_value_config", ":test_common", ":test_main", ":test_support", From b7ba6027659913883af3d64ec0fdfcba96176816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Wed, 2 Mar 2022 15:21:45 +0100 Subject: [PATCH 152/847] Avoid using lld when compiling iin iOS with bitcode The resulting framework's LLVM __bundle segment is empty otherwise. Bug: webrtc:13774 Change-Id: I235a3005f8e0d68168f29108be0f7c5b7914182b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253140 Reviewed-by: Mirko Bonadei Commit-Queue: Mirko Bonadei Cr-Commit-Position: refs/heads/main@{#36178} --- tools_webrtc/ios/build_ios_libs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools_webrtc/ios/build_ios_libs.py b/tools_webrtc/ios/build_ios_libs.py index 15a912e4ba..9a4c3e32ad 100755 --- a/tools_webrtc/ios/build_ios_libs.py +++ b/tools_webrtc/ios/build_ios_libs.py @@ -180,6 +180,7 @@ def BuildWebRTC(output_dir, target_environment, target_arch, flavor, ('true' if libvpx_build_vp9 else 'false')) gn_args.append('enable_ios_bitcode=' + ('true' if use_bitcode else 'false')) + gn_args.append('use_lld=' + ('false' if use_bitcode else 'true')) gn_args.append('use_goma=' + ('true' if use_goma else 'false')) gn_args.append('rtc_enable_objc_symbol_export=true') From 37195cf2e577cc09ad1362d046b5c8a9b65d4f99 Mon Sep 17 00:00:00 2001 From: Jianhui Dai Date: Mon, 7 Mar 2022 20:21:06 +0800 Subject: [PATCH 153/847] Pacer: Reduce TQ wake up and improve packet size estimation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The TQ Pacer schedules delayed task according to target time of PacingController. It drains all valid ProcessPackets() in single loop, denies retired scheduled tasks, and round up the timeout to 1ms. This CL also improves packet size estimation in TQ Pacer by removing zero initialization, and introduces `include_overhead_` configuration. Tests: 1. webrtc_perf_tests: MaybeProcessPackets() calls 2075147 -> 2007995 2. module_unittests: MaybeProcessPackets() calls 203393 -> 183563 3. peerconnection_unittests: MaybeProcessPackets() calls 66713-> 64333 Bug: webrtc:13417, webrtc:13437 Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 Reviewed-by: Erik Språng Reviewed-by: Henrik Boström Commit-Queue: Erik Språng Cr-Commit-Position: refs/heads/main@{#36179} --- call/rtp_transport_controller_send.cc | 3 +- modules/pacing/pacing_controller.cc | 298 ++++++++---------- modules/pacing/pacing_controller.h | 13 +- modules/pacing/task_queue_paced_sender.cc | 120 +++---- modules/pacing/task_queue_paced_sender.h | 8 +- .../task_queue_paced_sender_unittest.cc | 48 +-- 6 files changed, 231 insertions(+), 259 deletions(-) diff --git a/call/rtp_transport_controller_send.cc b/call/rtp_transport_controller_send.cc index f1a6201ce7..8ee347b74a 100644 --- a/call/rtp_transport_controller_send.cc +++ b/call/rtp_transport_controller_send.cc @@ -79,7 +79,8 @@ RtpTransportControllerSend::PacerSettings::PacerSettings( const WebRtcKeyValueConfig* trials) : tq_disabled("Disabled"), holdback_window("holdback_window", PacingController::kMinSleepTime), - holdback_packets("holdback_packets", -1) { + holdback_packets("holdback_packets", + TaskQueuePacedSender::kNoPacketHoldback) { ParseFieldTrial({&tq_disabled, &holdback_window, &holdback_packets}, trials->Lookup("WebRTC-TaskQueuePacer")); } diff --git a/modules/pacing/pacing_controller.cc b/modules/pacing/pacing_controller.cc index 9215462239..4fb33ff072 100644 --- a/modules/pacing/pacing_controller.cc +++ b/modules/pacing/pacing_controller.cc @@ -38,11 +38,6 @@ constexpr TimeDelta kMaxElapsedTime = TimeDelta::Seconds(2); // time. Applies only to periodic mode. constexpr TimeDelta kMaxProcessingInterval = TimeDelta::Millis(30); -// Allow probes to be processed slightly ahead of inteded send time. Currently -// set to 1ms as this is intended to allow times be rounded down to the nearest -// millisecond. -constexpr TimeDelta kMaxEarlyProbeProcessing = TimeDelta::Millis(1); - constexpr int kFirstPriority = 0; bool IsDisabled(const WebRtcKeyValueConfig& field_trials, @@ -94,6 +89,8 @@ const float PacingController::kDefaultPaceMultiplier = 2.5f; const TimeDelta PacingController::kPausedProcessInterval = kCongestedPacketInterval; const TimeDelta PacingController::kMinSleepTime = TimeDelta::Millis(1); +const TimeDelta PacingController::kMaxEarlyProbeProcessing = + TimeDelta::Millis(1); PacingController::PacingController(Clock* clock, PacketSender* packet_sender, @@ -133,7 +130,7 @@ PacingController::PacingController(Clock* clock, packet_counter_(0), congestion_window_size_(DataSize::PlusInfinity()), outstanding_data_(DataSize::Zero()), - queue_time_limit(kMaxExpectedQueueLength), + queue_time_limit_(kMaxExpectedQueueLength), account_for_audio_(false), include_overhead_(false) { if (!drain_large_queues_) { @@ -224,6 +221,7 @@ void PacingController::SetPacingRates(DataRate pacing_rate, media_rate_ = pacing_rate; padding_rate_ = padding_rate; pacing_bitrate_ = pacing_rate; + media_budget_.set_target_rate_kbps(pacing_rate.kbps()); padding_budget_.set_target_rate_kbps(padding_rate.kbps()); RTC_LOG(LS_VERBOSE) << "bwe:pacer_updated pacing_kbps=" @@ -302,10 +300,7 @@ void PacingController::EnqueuePacketInternal( // Use that as last process time only if it's prior to now. target_process_time = std::min(now, next_send_time); } - - TimeDelta elapsed_time = UpdateTimeAndGetElapsed(target_process_time); - UpdateBudgetWithElapsedTime(elapsed_time); - last_process_time_ = target_process_time; + UpdateBudgetWithElapsedTime(UpdateTimeAndGetElapsed(target_process_time)); } packet_queue_.Push(priority, now, packet_counter_++, std::move(packet)); } @@ -316,7 +311,6 @@ TimeDelta PacingController::UpdateTimeAndGetElapsed(Timestamp now) { if (last_process_time_.IsMinusInfinity() || now < last_process_time_) { return TimeDelta::Zero(); } - RTC_DCHECK_GE(now, last_process_time_); TimeDelta elapsed_time = now - last_process_time_; last_process_time_ = now; if (elapsed_time > kMaxElapsedTime) { @@ -333,8 +327,7 @@ bool PacingController::ShouldSendKeepalive(Timestamp now) const { packet_counter_ == 0) { // We send a padding packet every 500 ms to ensure we won't get stuck in // congested state due to no feedback being received. - TimeDelta elapsed_since_last_send = now - last_send_time_; - if (elapsed_since_last_send >= kCongestedPacketInterval) { + if (now - last_send_time_ >= kCongestedPacketInterval) { return true; } } @@ -343,17 +336,17 @@ bool PacingController::ShouldSendKeepalive(Timestamp now) const { Timestamp PacingController::NextSendTime() const { const Timestamp now = CurrentTime(); + Timestamp next_send_time = Timestamp::PlusInfinity(); if (paused_) { return last_send_time_ + kPausedProcessInterval; } // If probing is active, that always takes priority. - if (prober_.is_probing()) { + if (prober_.is_probing() && !probing_send_failure_) { Timestamp probe_time = prober_.NextProbeTime(now); - // `probe_time` == PlusInfinity indicates no probe scheduled. - if (probe_time != Timestamp::PlusInfinity() && !probing_send_failure_) { - return probe_time; + if (!probe_time.IsPlusInfinity()) { + return probe_time.IsMinusInfinity() ? now : probe_time; } } @@ -365,86 +358,53 @@ Timestamp PacingController::NextSendTime() const { // In dynamic mode, figure out when the next packet should be sent, // given the current conditions. - if (!pace_audio_) { - // Not pacing audio, if leading packet is audio its target send - // time is the time at which it was enqueued. - absl::optional audio_enqueue_time = - packet_queue_.LeadingAudioPacketEnqueueTime(); - if (audio_enqueue_time.has_value()) { - return *audio_enqueue_time; - } + // Not pacing audio, if leading packet is audio its target send + // time is the time at which it was enqueued. + absl::optional unpaced_audio_time = + pace_audio_ ? absl::nullopt + : packet_queue_.LeadingAudioPacketEnqueueTime(); + if (unpaced_audio_time) { + return *unpaced_audio_time; } + // We need to at least send keep-alive packets with some interval. if (Congested() || packet_counter_ == 0) { - // We need to at least send keep-alive packets with some interval. return last_send_time_ + kCongestedPacketInterval; } - // Check how long until we can send the next media packet. if (media_rate_ > DataRate::Zero() && !packet_queue_.Empty()) { - return std::min(last_send_time_ + kPausedProcessInterval, - last_process_time_ + media_debt_ / media_rate_); - } - - // If we _don't_ have pending packets, check how long until we have - // bandwidth for padding packets. Both media and padding debts must - // have been drained to do this. - if (padding_rate_ > DataRate::Zero() && packet_queue_.Empty()) { + // Check how long until we can send the next media packet. + next_send_time = last_process_time_ + media_debt_ / media_rate_; + } else if (padding_rate_ > DataRate::Zero() && packet_queue_.Empty()) { + // If we _don't_ have pending packets, check how long until we have + // bandwidth for padding packets. Both media and padding debts must + // have been drained to do this. + RTC_DCHECK_GT(media_rate_, DataRate::Zero()); TimeDelta drain_time = std::max(media_debt_ / media_rate_, padding_debt_ / padding_rate_); - return std::min(last_send_time_ + kPausedProcessInterval, - last_process_time_ + drain_time); + next_send_time = last_process_time_ + drain_time; + } else { + // Nothing to do. + next_send_time = last_process_time_ + kPausedProcessInterval; } if (send_padding_if_silent_) { - return last_send_time_ + kPausedProcessInterval; + next_send_time = + std::min(next_send_time, last_send_time_ + kPausedProcessInterval); } - return last_process_time_ + kPausedProcessInterval; + + return next_send_time; } void PacingController::ProcessPackets() { Timestamp now = CurrentTime(); Timestamp target_send_time = now; - if (mode_ == ProcessMode::kDynamic) { - target_send_time = NextSendTime(); - TimeDelta early_execute_margin = - prober_.is_probing() ? kMaxEarlyProbeProcessing : TimeDelta::Zero(); - if (target_send_time.IsMinusInfinity()) { - target_send_time = now; - } else if (now < target_send_time - early_execute_margin) { - // We are too early, but if queue is empty still allow draining some debt. - // Probing is allowed to be sent up to kMinSleepTime early. - TimeDelta elapsed_time = UpdateTimeAndGetElapsed(now); - UpdateBudgetWithElapsedTime(elapsed_time); - return; - } - - if (target_send_time < last_process_time_) { - // After the last process call, at time X, the target send time - // shifted to be earlier than X. This should normally not happen - // but we want to make sure rounding errors or erratic behavior - // of NextSendTime() does not cause issue. In particular, if the - // buffer reduction of - // rate * (target_send_time - previous_process_time) - // in the main loop doesn't clean up the existing debt we may not - // be able to send again. We don't want to check this reordering - // there as it is the normal exit condtion when the buffer is - // exhausted and there are packets in the queue. - UpdateBudgetWithElapsedTime(last_process_time_ - target_send_time); - target_send_time = last_process_time_; - } - } - - Timestamp previous_process_time = last_process_time_; - TimeDelta elapsed_time = UpdateTimeAndGetElapsed(now); if (ShouldSendKeepalive(now)) { + DataSize keepalive_data_sent = DataSize::Zero(); // We can not send padding unless a normal packet has first been sent. If // we do, timestamps get messed up. - if (packet_counter_ == 0) { - last_send_time_ = now; - } else { - DataSize keepalive_data_sent = DataSize::Zero(); + if (packet_counter_ > 0) { std::vector> keepalive_packets = packet_sender_->GeneratePadding(DataSize::Bytes(1)); for (auto& packet : keepalive_packets) { @@ -455,14 +415,29 @@ void PacingController::ProcessPackets() { EnqueuePacket(std::move(packet)); } } - OnPaddingSent(keepalive_data_sent); } + OnPacketSent(RtpPacketMediaType::kPadding, keepalive_data_sent, now); } if (paused_) { return; } + if (mode_ == ProcessMode::kDynamic) { + TimeDelta early_execute_margin = + prober_.is_probing() ? kMaxEarlyProbeProcessing : TimeDelta::Zero(); + + target_send_time = NextSendTime(); + if (now + early_execute_margin < target_send_time) { + // We are too early, but if queue is empty still allow draining some debt. + // Probing is allowed to be sent up to kMinSleepTime early. + UpdateBudgetWithElapsedTime(UpdateTimeAndGetElapsed(now)); + return; + } + } + + TimeDelta elapsed_time = UpdateTimeAndGetElapsed(target_send_time); + if (elapsed_time > TimeDelta::Zero()) { DataRate target_rate = pacing_bitrate_; DataSize queue_size_data = packet_queue_.Size(); @@ -474,7 +449,7 @@ void PacingController::ProcessPackets() { if (drain_large_queues_) { TimeDelta avg_time_left = std::max(TimeDelta::Millis(1), - queue_time_limit - packet_queue_.AverageQueueTime()); + queue_time_limit_ - packet_queue_.AverageQueueTime()); DataRate min_rate_needed = queue_size_data / avg_time_left; if (min_rate_needed > target_rate) { target_rate = min_rate_needed; @@ -489,13 +464,12 @@ void PacingController::ProcessPackets() { // up to (process interval duration) * (target rate), so we only need to // update it once before the packet sending loop. media_budget_.set_target_rate_kbps(target_rate.kbps()); - UpdateBudgetWithElapsedTime(elapsed_time); } else { media_rate_ = target_rate; } + UpdateBudgetWithElapsedTime(elapsed_time); } - bool first_packet_in_probe = false; PacedPacketInfo pacing_info; DataSize recommended_probe_size = DataSize::Zero(); bool is_probing = prober_.is_probing(); @@ -504,9 +478,23 @@ void PacingController::ProcessPackets() { // use actual send time rather than target. pacing_info = prober_.CurrentCluster(now).value_or(PacedPacketInfo()); if (pacing_info.probe_cluster_id != PacedPacketInfo::kNotAProbe) { - first_packet_in_probe = pacing_info.probe_cluster_bytes_sent == 0; recommended_probe_size = prober_.RecommendedMinProbeSize(); RTC_DCHECK_GT(recommended_probe_size, DataSize::Zero()); + + // If first packet in probe, insert a small padding packet so we have a + // more reliable start window for the rate estimation. + if (pacing_info.probe_cluster_bytes_sent == 0) { + auto padding = packet_sender_->GeneratePadding(DataSize::Bytes(1)); + // If no RTP modules sending media are registered, we may not get a + // padding packet back. + if (!padding.empty()) { + // Insert with high priority so larger media packets don't preempt it. + EnqueuePacketInternal(std::move(padding[0]), kFirstPriority); + // We should never get more than one padding packets with a requested + // size of 1 byte. + RTC_DCHECK_EQ(padding.size(), 1u); + } + } } else { // No valid probe cluster returned, probe might have timed out. is_probing = false; @@ -514,102 +502,74 @@ void PacingController::ProcessPackets() { } DataSize data_sent = DataSize::Zero(); - - // The paused state is checked in the loop since it leaves the critical - // section allowing the paused state to be changed from other code. - while (!paused_) { - if (first_packet_in_probe) { - // If first packet in probe, insert a small padding packet so we have a - // more reliable start window for the rate estimation. - auto padding = packet_sender_->GeneratePadding(DataSize::Bytes(1)); - // If no RTP modules sending media are registered, we may not get a - // padding packet back. - if (!padding.empty()) { - // Insert with high priority so larger media packets don't preempt it. - EnqueuePacketInternal(std::move(padding[0]), kFirstPriority); - // We should never get more than one padding packets with a requested - // size of 1 byte. - RTC_DCHECK_EQ(padding.size(), 1u); - } - first_packet_in_probe = false; - } - - if (mode_ == ProcessMode::kDynamic && - previous_process_time < target_send_time) { - // Reduce buffer levels with amount corresponding to time between last - // process and target send time for the next packet. - // If the process call is late, that may be the time between the optimal - // send times for two packets we should already have sent. - UpdateBudgetWithElapsedTime(target_send_time - previous_process_time); - previous_process_time = target_send_time; - } - - // Fetch the next packet, so long as queue is not empty or budget is not + while (true) { + // Fetch packet, so long as queue is not empty or budget is not // exhausted. std::unique_ptr rtp_packet = GetPendingPacket(pacing_info, target_send_time, now); - if (rtp_packet == nullptr) { // No packet available to send, check if we should send padding. DataSize padding_to_add = PaddingToAdd(recommended_probe_size, data_sent); if (padding_to_add > DataSize::Zero()) { std::vector> padding_packets = packet_sender_->GeneratePadding(padding_to_add); - if (padding_packets.empty()) { - // No padding packets were generated, quite send loop. - break; - } - for (auto& packet : padding_packets) { - EnqueuePacket(std::move(packet)); + if (!padding_packets.empty()) { + for (auto& packet : padding_packets) { + EnqueuePacket(std::move(packet)); + } + // Continue loop to send the padding that was just added. + continue; + } else { + // Can't generate padding, still update padding budget for next send + // time. + UpdatePaddingBudgetWithSentData(padding_to_add); } - // Continue loop to send the padding that was just added. - continue; } - // Can't fetch new packet and no padding to send, exit send loop. break; - } - - RTC_DCHECK(rtp_packet); - RTC_DCHECK(rtp_packet->packet_type().has_value()); - const RtpPacketMediaType packet_type = *rtp_packet->packet_type(); - DataSize packet_size = DataSize::Bytes(rtp_packet->payload_size() + - rtp_packet->padding_size()); - - if (include_overhead_) { - packet_size += DataSize::Bytes(rtp_packet->headers_size()) + - transport_overhead_per_packet_; - } + } else { + RTC_DCHECK(rtp_packet); + RTC_DCHECK(rtp_packet->packet_type().has_value()); + const RtpPacketMediaType packet_type = *rtp_packet->packet_type(); + DataSize packet_size = DataSize::Bytes(rtp_packet->payload_size() + + rtp_packet->padding_size()); + + if (include_overhead_) { + packet_size += DataSize::Bytes(rtp_packet->headers_size()) + + transport_overhead_per_packet_; + } - packet_sender_->SendPacket(std::move(rtp_packet), pacing_info); - for (auto& packet : packet_sender_->FetchFec()) { - EnqueuePacket(std::move(packet)); - } - data_sent += packet_size; + packet_sender_->SendPacket(std::move(rtp_packet), pacing_info); + for (auto& packet : packet_sender_->FetchFec()) { + EnqueuePacket(std::move(packet)); + } + data_sent += packet_size; - // Send done, update send/process time to the target send time. - OnPacketSent(packet_type, packet_size, target_send_time); + // Send done, update send time. + OnPacketSent(packet_type, packet_size, now); - // If we are currently probing, we need to stop the send loop when we have - // reached the send target. - if (is_probing && data_sent >= recommended_probe_size) { - break; - } + // If we are currently probing, we need to stop the send loop when we + // have reached the send target. + if (is_probing && data_sent >= recommended_probe_size) { + break; + } - if (mode_ == ProcessMode::kDynamic) { // Update target send time in case that are more packets that we are late // in processing. - Timestamp next_send_time = NextSendTime(); - if (next_send_time.IsMinusInfinity()) { - target_send_time = now; - } else { - target_send_time = std::min(now, next_send_time); + if (mode_ == ProcessMode::kDynamic) { + target_send_time = NextSendTime(); + if (target_send_time > now) { + // Exit loop if not probing. + if (!is_probing) { + break; + } + target_send_time = now; + } + UpdateBudgetWithElapsedTime(UpdateTimeAndGetElapsed(target_send_time)); } } } - last_process_time_ = std::max(last_process_time_, previous_process_time); - if (is_probing) { probing_send_failure_ = data_sent == DataSize::Zero(); if (!probing_send_failure_) { @@ -631,8 +591,8 @@ DataSize PacingController::PaddingToAdd(DataSize recommended_probe_size, } if (packet_counter_ == 0) { - // We can not send padding unless a normal packet has first been sent. If we - // do, timestamps get messed up. + // We can not send padding unless a normal packet has first been sent. If + // we do, timestamps get messed up. return DataSize::Zero(); } @@ -697,25 +657,16 @@ std::unique_ptr PacingController::GetPendingPacket( void PacingController::OnPacketSent(RtpPacketMediaType packet_type, DataSize packet_size, Timestamp send_time) { - if (!first_sent_packet_time_) { + if (!first_sent_packet_time_ && packet_type != RtpPacketMediaType::kPadding) { first_sent_packet_time_ = send_time; } + bool audio_packet = packet_type == RtpPacketMediaType::kAudio; - if (!audio_packet || account_for_audio_) { - // Update media bytes sent. + if ((!audio_packet || account_for_audio_) && packet_size > DataSize::Zero()) { UpdateBudgetWithSentData(packet_size); } - last_send_time_ = send_time; - last_process_time_ = send_time; -} -void PacingController::OnPaddingSent(DataSize data_sent) { - if (data_sent > DataSize::Zero()) { - UpdateBudgetWithSentData(data_sent); - } - Timestamp now = CurrentTime(); - last_send_time_ = now; - last_process_time_ = now; + last_send_time_ = send_time; } void PacingController::UpdateBudgetWithElapsedTime(TimeDelta delta) { @@ -733,17 +684,24 @@ void PacingController::UpdateBudgetWithSentData(DataSize size) { outstanding_data_ += size; if (mode_ == ProcessMode::kPeriodic) { media_budget_.UseBudget(size.bytes()); - padding_budget_.UseBudget(size.bytes()); } else { media_debt_ += size; media_debt_ = std::min(media_debt_, media_rate_ * kMaxDebtInTime); + } + UpdatePaddingBudgetWithSentData(size); +} + +void PacingController::UpdatePaddingBudgetWithSentData(DataSize size) { + if (mode_ == ProcessMode::kPeriodic) { + padding_budget_.UseBudget(size.bytes()); + } else { padding_debt_ += size; padding_debt_ = std::min(padding_debt_, padding_rate_ * kMaxDebtInTime); } } void PacingController::SetQueueTimeLimit(TimeDelta limit) { - queue_time_limit = limit; + queue_time_limit_ = limit; } } // namespace webrtc diff --git a/modules/pacing/pacing_controller.h b/modules/pacing/pacing_controller.h index 5d6d26b917..e7ef201a77 100644 --- a/modules/pacing/pacing_controller.h +++ b/modules/pacing/pacing_controller.h @@ -79,6 +79,11 @@ class PacingController { static const TimeDelta kMinSleepTime; + // Allow probes to be processed slightly ahead of inteded send time. Currently + // set to 1ms as this is intended to allow times be rounded down to the + // nearest millisecond. + static const TimeDelta kMaxEarlyProbeProcessing; + PacingController(Clock* clock, PacketSender* packet_sender, RtcEventLog* event_log, @@ -158,6 +163,7 @@ class PacingController { // Updates the number of bytes that can be sent for the next time interval. void UpdateBudgetWithElapsedTime(TimeDelta delta); void UpdateBudgetWithSentData(DataSize size); + void UpdatePaddingBudgetWithSentData(DataSize size); DataSize PaddingToAdd(DataSize recommended_probe_size, DataSize data_sent) const; @@ -169,7 +175,6 @@ class PacingController { void OnPacketSent(RtpPacketMediaType packet_type, DataSize packet_size, Timestamp send_time); - void OnPaddingSent(DataSize padding_sent); Timestamp CurrentTime() const; @@ -196,9 +201,9 @@ class PacingController { mutable Timestamp last_timestamp_; bool paused_; - // In dynamic mode, `media_budget_` and `padding_budget_` will be used to + // In periodic mode, `media_budget_` and `padding_budget_` will be used to // track when packets can be sent. - // In periodic mode, `media_debt_` and `padding_debt_` will be used together + // In dynamic mode, `media_debt_` and `padding_debt_` will be used together // with the target rates. // This is the media budget, keeping track of how many bits of media @@ -229,7 +234,7 @@ class PacingController { DataSize congestion_window_size_; DataSize outstanding_data_; - TimeDelta queue_time_limit; + TimeDelta queue_time_limit_; bool account_for_audio_; bool include_overhead_; }; diff --git a/modules/pacing/task_queue_paced_sender.cc b/modules/pacing/task_queue_paced_sender.cc index c392a88720..18e53d1ad7 100644 --- a/modules/pacing/task_queue_paced_sender.cc +++ b/modules/pacing/task_queue_paced_sender.cc @@ -12,15 +12,14 @@ #include #include -#include "absl/memory/memory.h" + #include "rtc_base/checks.h" -#include "rtc_base/event.h" -#include "rtc_base/logging.h" -#include "rtc_base/task_utils/to_queued_task.h" #include "rtc_base/trace_event.h" namespace webrtc { +const int TaskQueuePacedSender::kNoPacketHoldback = -1; + TaskQueuePacedSender::TaskQueuePacedSender( Clock* clock, PacingController::PacketSender* packet_sender, @@ -41,10 +40,11 @@ TaskQueuePacedSender::TaskQueuePacedSender( is_started_(false), is_shutdown_(false), packet_size_(/*alpha=*/0.95), + include_overhead_(false), task_queue_(task_queue_factory->CreateTaskQueue( "TaskQueuePacedSender", TaskQueueFactory::Priority::NORMAL)) { - packet_size_.Apply(1, 0); + RTC_DCHECK_GE(max_hold_back_window_, PacingController::kMinSleepTime); } TaskQueuePacedSender::~TaskQueuePacedSender() { @@ -140,7 +140,11 @@ void TaskQueuePacedSender::EnqueuePackets( task_queue_.PostTask([this, packets_ = std::move(packets)]() mutable { RTC_DCHECK_RUN_ON(&task_queue_); for (auto& packet : packets_) { - packet_size_.Apply(1, packet->size()); + size_t packet_size = packet->payload_size() + packet->padding_size(); + if (include_overhead_) { + packet_size += packet->headers_size(); + } + packet_size_.Apply(1, packet_size); RTC_DCHECK_GE(packet->capture_time(), Timestamp::Zero()); pacing_controller_.EnqueuePacket(std::move(packet)); } @@ -159,6 +163,7 @@ void TaskQueuePacedSender::SetAccountForAudioPackets(bool account_for_audio) { void TaskQueuePacedSender::SetIncludeOverhead() { task_queue_.PostTask([this]() { RTC_DCHECK_RUN_ON(&task_queue_); + include_overhead_ = true; pacing_controller_.SetIncludeOverhead(); MaybeProcessPackets(Timestamp::MinusInfinity()); }); @@ -194,13 +199,16 @@ absl::optional TaskQueuePacedSender::FirstSentPacketTime() const { TimeDelta TaskQueuePacedSender::OldestPacketWaitTime() const { Timestamp oldest_packet = GetStats().oldest_packet_enqueue_time; - if (oldest_packet.IsInfinite()) + if (oldest_packet.IsInfinite()) { return TimeDelta::Zero(); + } // (webrtc:9716): The clock is not always monotonic. Timestamp current = clock_->CurrentTime(); - if (current < oldest_packet) + if (current < oldest_packet) { return TimeDelta::Zero(); + } + return current - oldest_packet; } @@ -213,70 +221,70 @@ void TaskQueuePacedSender::MaybeProcessPackets( Timestamp scheduled_process_time) { RTC_DCHECK_RUN_ON(&task_queue_); +#if RTC_TRACE_EVENTS_ENABLED + TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("webrtc"), + "TaskQueuePacedSender::MaybeProcessPackets"); +#endif + if (is_shutdown_ || !is_started_) { return; } - // Normally, run ProcessPackets() only if this is the scheduled task. - // If it is not but it is already time to process and there either is - // no scheduled task or the schedule has shifted forward in time, run - // anyway and clear any schedule. - Timestamp next_process_time = pacing_controller_.NextSendTime(); + Timestamp next_send_time = pacing_controller_.NextSendTime(); + RTC_DCHECK(next_send_time.IsFinite()); const Timestamp now = clock_->CurrentTime(); - const bool is_scheduled_call = next_process_time_ == scheduled_process_time; - if (is_scheduled_call) { - // Indicate no pending scheduled call. - next_process_time_ = Timestamp::MinusInfinity(); - } - if (is_scheduled_call || - (now >= next_process_time && (next_process_time_.IsInfinite() || - next_process_time < next_process_time_))) { + + TimeDelta early_execute_margin = + pacing_controller_.IsProbing() + ? PacingController::kMaxEarlyProbeProcessing + : TimeDelta::Zero(); + + // Process packets and update stats. + while (next_send_time <= now + early_execute_margin) { pacing_controller_.ProcessPackets(); - next_process_time = pacing_controller_.NextSendTime(); + next_send_time = pacing_controller_.NextSendTime(); + RTC_DCHECK(next_send_time.IsFinite()); } + UpdateStats(); - TimeDelta hold_back_window = max_hold_back_window_; - DataRate pacing_rate = pacing_controller_.pacing_rate(); - DataSize avg_packet_size = DataSize::Bytes(packet_size_.filtered()); - if (max_hold_back_window_in_packets_ > 0 && !pacing_rate.IsZero() && - !avg_packet_size.IsZero()) { - TimeDelta avg_packet_send_time = avg_packet_size / pacing_rate; - hold_back_window = - std::min(hold_back_window, - avg_packet_send_time * max_hold_back_window_in_packets_); + // Ignore retired scheduled task, otherwise reset `next_process_time_`. + if (scheduled_process_time.IsFinite()) { + if (scheduled_process_time != next_process_time_) { + return; + } + next_process_time_ = Timestamp::MinusInfinity(); } - absl::optional time_to_next_process; - if (pacing_controller_.IsProbing() && - next_process_time != next_process_time_) { - // If we're probing and there isn't already a wakeup scheduled for the next - // process time, always post a task and just round sleep time down to - // nearest millisecond. - if (next_process_time.IsMinusInfinity()) { - time_to_next_process = TimeDelta::Zero(); - } else { - time_to_next_process = - std::max(TimeDelta::Zero(), - (next_process_time - now).RoundDownTo(TimeDelta::Millis(1))); + // Do not hold back in probing. + TimeDelta hold_back_window = TimeDelta::Zero(); + if (!pacing_controller_.IsProbing()) { + hold_back_window = max_hold_back_window_; + DataRate pacing_rate = pacing_controller_.pacing_rate(); + if (max_hold_back_window_in_packets_ != kNoPacketHoldback && + !pacing_rate.IsZero() && + packet_size_.filtered() != rtc::ExpFilter::kValueUndefined) { + TimeDelta avg_packet_send_time = + DataSize::Bytes(packet_size_.filtered()) / pacing_rate; + hold_back_window = + std::min(hold_back_window, + avg_packet_send_time * max_hold_back_window_in_packets_); } - } else if (next_process_time_.IsMinusInfinity() || - next_process_time <= next_process_time_ - hold_back_window) { - // Schedule a new task since there is none currently scheduled - // (`next_process_time_` is infinite), or the new process time is at least - // one holdback window earlier than whatever is currently scheduled. - time_to_next_process = std::max(next_process_time - now, hold_back_window); } - if (time_to_next_process) { - // Set a new scheduled process time and post a delayed task. - next_process_time_ = next_process_time; + // Calculate next process time. + TimeDelta time_to_next_process = + std::max(hold_back_window, next_send_time - now - early_execute_margin); + next_send_time = now + time_to_next_process; + // If no in flight task or in flight task is later than `next_send_time`, + // schedule a new one. Previous in flight task will be retired. + if (next_process_time_.IsMinusInfinity() || + next_process_time_ > next_send_time) { task_queue_.PostDelayedHighPrecisionTask( - [this, next_process_time]() { MaybeProcessPackets(next_process_time); }, - time_to_next_process->ms()); + [this, next_send_time]() { MaybeProcessPackets(next_send_time); }, + time_to_next_process.RoundUpTo(TimeDelta::Millis(1)).ms()); + next_process_time_ = next_send_time; } - - UpdateStats(); } void TaskQueuePacedSender::UpdateStats() { diff --git a/modules/pacing/task_queue_paced_sender.h b/modules/pacing/task_queue_paced_sender.h index 353f137963..bf17de52f9 100644 --- a/modules/pacing/task_queue_paced_sender.h +++ b/modules/pacing/task_queue_paced_sender.h @@ -14,9 +14,7 @@ #include #include -#include #include -#include #include #include "absl/types/optional.h" @@ -29,7 +27,6 @@ #include "modules/pacing/rtp_packet_pacer.h" #include "modules/rtp_rtcp/source/rtp_packet_to_send.h" #include "rtc_base/numerics/exp_filter.h" -#include "rtc_base/synchronization/mutex.h" #include "rtc_base/task_queue.h" #include "rtc_base/thread_annotations.h" @@ -39,6 +36,8 @@ class RtcEventLog; class TaskQueuePacedSender : public RtpPacketPacer, public RtpPacketSender { public: + static const int kNoPacketHoldback; + // The `hold_back_window` parameter sets a lower bound on time to sleep if // there is currently a pacer queue and packets can't immediately be // processed. Increasing this reduces thread wakeups at the expense of higher @@ -51,7 +50,7 @@ class TaskQueuePacedSender : public RtpPacketPacer, public RtpPacketSender { const WebRtcKeyValueConfig* field_trials, TaskQueueFactory* task_queue_factory, TimeDelta max_hold_back_window = PacingController::kMinSleepTime, - int max_hold_back_window_in_packets = -1); + int max_hold_back_window_in_packets = kNoPacketHoldback); ~TaskQueuePacedSender() override; @@ -156,6 +155,7 @@ class TaskQueuePacedSender : public RtpPacketPacer, public RtpPacketSender { // Filtered size of enqueued packets, in bytes. rtc::ExpFilter packet_size_ RTC_GUARDED_BY(task_queue_); + bool include_overhead_ RTC_GUARDED_BY(task_queue_); mutable Mutex stats_mutex_; Stats current_stats_ RTC_GUARDED_BY(stats_mutex_); diff --git a/modules/pacing/task_queue_paced_sender_unittest.cc b/modules/pacing/task_queue_paced_sender_unittest.cc index d78365d499..c2d1fbd095 100644 --- a/modules/pacing/task_queue_paced_sender_unittest.cc +++ b/modules/pacing/task_queue_paced_sender_unittest.cc @@ -37,7 +37,6 @@ constexpr uint32_t kVideoSsrc = 234565; constexpr uint32_t kVideoRtxSsrc = 34567; constexpr uint32_t kFlexFecSsrc = 45678; constexpr size_t kDefaultPacketSize = 1234; -constexpr int kNoPacketHoldback = -1; class MockPacketRouter : public PacketRouter { public: @@ -120,7 +119,7 @@ TEST(TaskQueuePacedSenderTest, PacesPackets) { time_controller.GetClock(), &packet_router, /*event_log=*/nullptr, /*field_trials=*/nullptr, time_controller.GetTaskQueueFactory(), - PacingController::kMinSleepTime, kNoPacketHoldback); + PacingController::kMinSleepTime, TaskQueuePacedSender::kNoPacketHoldback); // Insert a number of packets, covering one second. static constexpr size_t kPacketsToSend = 42; @@ -160,7 +159,7 @@ TEST(TaskQueuePacedSenderTest, ReschedulesProcessOnRateChange) { time_controller.GetClock(), &packet_router, /*event_log=*/nullptr, /*field_trials=*/nullptr, time_controller.GetTaskQueueFactory(), - PacingController::kMinSleepTime, kNoPacketHoldback); + PacingController::kMinSleepTime, TaskQueuePacedSender::kNoPacketHoldback); // Insert a number of packets to be sent 200ms apart. const size_t kPacketsPerSecond = 5; @@ -212,7 +211,7 @@ TEST(TaskQueuePacedSenderTest, SendsAudioImmediately) { time_controller.GetClock(), &packet_router, /*event_log=*/nullptr, /*field_trials=*/nullptr, time_controller.GetTaskQueueFactory(), - PacingController::kMinSleepTime, kNoPacketHoldback); + PacingController::kMinSleepTime, TaskQueuePacedSender::kNoPacketHoldback); const DataRate kPacingDataRate = DataRate::KilobitsPerSec(125); const DataSize kPacketSize = DataSize::Bytes(kDefaultPacketSize); @@ -241,11 +240,11 @@ TEST(TaskQueuePacedSenderTest, SleepsDuringCoalscingWindow) { const TimeDelta kCoalescingWindow = TimeDelta::Millis(5); GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); MockPacketRouter packet_router; - TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, - /*event_log=*/nullptr, - /*field_trials=*/nullptr, - time_controller.GetTaskQueueFactory(), - kCoalescingWindow, kNoPacketHoldback); + TaskQueuePacedSender pacer( + time_controller.GetClock(), &packet_router, + /*event_log=*/nullptr, + /*field_trials=*/nullptr, time_controller.GetTaskQueueFactory(), + kCoalescingWindow, TaskQueuePacedSender::kNoPacketHoldback); // Set rates so one packet adds one ms of buffer level. const DataSize kPacketSize = DataSize::Bytes(kDefaultPacketSize); @@ -278,11 +277,11 @@ TEST(TaskQueuePacedSenderTest, ProbingOverridesCoalescingWindow) { const TimeDelta kCoalescingWindow = TimeDelta::Millis(5); GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); MockPacketRouter packet_router; - TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, - /*event_log=*/nullptr, - /*field_trials=*/nullptr, - time_controller.GetTaskQueueFactory(), - kCoalescingWindow, kNoPacketHoldback); + TaskQueuePacedSender pacer( + time_controller.GetClock(), &packet_router, + /*event_log=*/nullptr, + /*field_trials=*/nullptr, time_controller.GetTaskQueueFactory(), + kCoalescingWindow, TaskQueuePacedSender::kNoPacketHoldback); // Set rates so one packet adds one ms of buffer level. const DataSize kPacketSize = DataSize::Bytes(kDefaultPacketSize); @@ -306,7 +305,7 @@ TEST(TaskQueuePacedSenderTest, ProbingOverridesCoalescingWindow) { time_controller.AdvanceTime(kCoalescingWindow - TimeDelta::Millis(1)); } -TEST(TaskQueuePacedSenderTest, SchedulesProbeAtSetTime) { +TEST(TaskQueuePacedSenderTest, SchedulesProbeAtSentTime) { ScopedFieldTrials trials("WebRTC-Bwe-ProbingBehavior/min_probe_delta:1ms/"); GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); MockPacketRouter packet_router; @@ -314,7 +313,7 @@ TEST(TaskQueuePacedSenderTest, SchedulesProbeAtSetTime) { time_controller.GetClock(), &packet_router, /*event_log=*/nullptr, /*field_trials=*/nullptr, time_controller.GetTaskQueueFactory(), - PacingController::kMinSleepTime, kNoPacketHoldback); + PacingController::kMinSleepTime, TaskQueuePacedSender::kNoPacketHoldback); // Set rates so one packet adds 4ms of buffer level. const DataSize kPacketSize = DataSize::Bytes(kDefaultPacketSize); @@ -339,15 +338,16 @@ TEST(TaskQueuePacedSenderTest, SchedulesProbeAtSetTime) { // Advance to less than 3ms before next packet send time. time_controller.AdvanceTime(TimeDelta::Micros(1001)); - // Trigger a probe at 4x the current pacing rate and insert the number of + // Trigger a probe at 2x the current pacing rate and insert the number of // packets the probe needs. const DataRate kProbeRate = 2 * kPacingDataRate; const int kProbeClusterId = 1; pacer.CreateProbeCluster(kProbeRate, kProbeClusterId); - // Expected size for each probe in a cluster is twice the expected bits - // sent during min_probe_delta. - // Expect one additional call since probe always starts with a small + // Expected size for each probe in a cluster is twice the expected bits sent + // during min_probe_delta. + // Expect one additional call since probe always starts with a small (1 byte) + // padding packet that's not counted into the probe rate here. const TimeDelta kProbeTimeDelta = TimeDelta::Millis(2); const DataSize kProbeSize = kProbeRate * kProbeTimeDelta; const size_t kNumPacketsInProbe = @@ -381,7 +381,7 @@ TEST(TaskQueuePacedSenderTest, NoMinSleepTimeWhenProbing) { time_controller.GetClock(), &packet_router, /*event_log=*/nullptr, /*field_trials=*/nullptr, time_controller.GetTaskQueueFactory(), - PacingController::kMinSleepTime, kNoPacketHoldback); + PacingController::kMinSleepTime, TaskQueuePacedSender::kNoPacketHoldback); // Set rates so one packet adds 4ms of buffer level. const DataSize kPacketSize = DataSize::Bytes(kDefaultPacketSize); @@ -423,8 +423,8 @@ TEST(TaskQueuePacedSenderTest, NoMinSleepTimeWhenProbing) { // Verify the amount of probing data sent. // Probe always starts with a small (1 byte) padding packet that's not // counted into the probe rate here. - EXPECT_EQ(data_sent, - kProbingRate * TimeDelta::Millis(1) + DataSize::Bytes(1)); + const DataSize kMinProbeSize = 2 * kMinProbeDelta * kProbingRate; + EXPECT_EQ(data_sent, DataSize::Bytes(1) + kPacketSize + 4 * kMinProbeSize); } TEST(TaskQueuePacedSenderTest, PacketBasedCoalescing) { @@ -534,7 +534,7 @@ TEST(TaskQueuePacedSenderTest, Stats) { time_controller.GetClock(), &packet_router, /*event_log=*/nullptr, /*field_trials=*/nullptr, time_controller.GetTaskQueueFactory(), - PacingController::kMinSleepTime, kNoPacketHoldback); + PacingController::kMinSleepTime, TaskQueuePacedSender::kNoPacketHoldback); // Simulate ~2mbps video stream, covering one second. static constexpr size_t kPacketsToSend = 200; From aaf9d051c7760f285005a2b24bc710a29b630364 Mon Sep 17 00:00:00 2001 From: Jerome Jiang Date: Fri, 11 Mar 2022 08:34:32 -0800 Subject: [PATCH 154/847] Lower hd av1 quality threshold MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: None Change-Id: I2b7bfbd8f5a2be13ede11df30272e5b001471453 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255021 Reviewed-by: Erik Språng Commit-Queue: Erik Språng Cr-Commit-Position: refs/heads/main@{#36180} --- modules/video_coding/codecs/test/videocodec_test_av1.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/video_coding/codecs/test/videocodec_test_av1.cc b/modules/video_coding/codecs/test/videocodec_test_av1.cc index f53afde14b..30472915a9 100644 --- a/modules/video_coding/codecs/test/videocodec_test_av1.cc +++ b/modules/video_coding/codecs/test/videocodec_test_av1.cc @@ -100,7 +100,7 @@ TEST_P(VideoCodecTestAv1, Hd) { {13, 3, 0, 1, 0.3, 0.1, 0, 1}}; std::vector quality_thresholds = { - {36, 31.55, 0.925, 0.865}}; + {35.9, 31.55, 0.925, 0.865}}; fixture->RunTest(rate_profiles, &rc_thresholds, &quality_thresholds, nullptr); } From 0e7536de03257f62ec8f7656643fb4114c35da2d Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Fri, 11 Mar 2022 14:01:33 -0800 Subject: [PATCH 155/847] Roll chromium_revision a57058ece1..12c232c43c (979913:980233) Change log: https://chromium.googlesource.com/chromium/src/+log/a57058ece1..12c232c43c Full diff: https://chromium.googlesource.com/chromium/src/+/a57058ece1..12c232c43c Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/3995e4dea1..3da6de3d00 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/8ac9bfbfd3..525877587b * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/d4803736c6..3b07d3ead2 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/db21f42dd9..f308ae6b5a * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/62b5a5537d..bb65cc1299 * src/third_party/androidx: EggJgyI0ja1HtThYH24KsjyfGghSO9o623ONeM4pynIC..s4aBuB5ULb4MMqBp4Xevo2Tf9qk_S5FxWr2xxansx68C * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/5b79b29052..271796d312 * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/1909696991..c848a4ed33 * src/third_party/libaom/source/libaom: https://aomedia.googlesource.com/aom.git/+log/a08d3f6c32..ee1ed1ccf2 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/a680c6e739..ed445842ba DEPS diff: https://chromium.googlesource.com/chromium/src/+/a57058ece1..12c232c43c/DEPS No update to Clang. BUG=None Change-Id: I85eddd6a18c41a6a1154c0131e3d7286d4d8e010 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255080 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36181} --- DEPS | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/DEPS b/DEPS index d74a41c949..c8eb3ae1cc 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': 'a57058ece1144672b4024e18ab3741068cb7ff54', + 'chromium_revision': '12c232c43ce7324d308afab5349b38b7707d8226', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@3995e4dea1b2ab0c99079100f4a5391c8a661602', + 'https://chromium.googlesource.com/chromium/src/base@3da6de3d00316c4563c2aa8e113c9c8b32a67bc6', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@8ac9bfbfd302afe2d99527f5fb46e6b3a27a9bb7', + 'https://chromium.googlesource.com/chromium/src/build@525877587b3e153035256c724ce94d31980f28d1', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@113dd1badbcbffea108a8c95ac7c89c22bfd25f3', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@d4803736c617a684b3234f3b9e0f3b019b550aec', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@3b07d3ead212da6cc923987210919ce54624db4c', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@db21f42dd95304af10d7eba3a3680c5018f193f0', + 'https://chromium.googlesource.com/chromium/src/testing@f308ae6b5aed3e4c2a90c63d846b57178c0bea08', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@62b5a5537d15c876ae732ce3f9adad51cbc978b1', + 'https://chromium.googlesource.com/chromium/src/third_party@bb65cc1299701b95d851268bee413d3353af45d9', 'src/buildtools/linux64': { 'packages': [ @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@5b79b290529ea30ab66a47ef758ecf2ef8825d66', + 'https://chromium.googlesource.com/catapult.git@271796d312a4a2e751bd84da89e19aae3de1af20', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@1909696991d3e1e689d6d8815bb44fb327527d52', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@c848a4ed332e79a654cb4ee7ef29acd796f7147d', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -222,7 +222,7 @@ deps = { 'src/third_party/dav1d/libdav1d': 'https://chromium.googlesource.com/external/github.com/videolan/dav1d.git@493ffb12f77df791f7dcde991b92d64bf873fefd', 'src/third_party/libaom/source/libaom': - 'https://aomedia.googlesource.com/aom.git@a08d3f6c329a25744712578a70715e5cfd749759', + 'https://aomedia.googlesource.com/aom.git@ee1ed1ccf2b9ecedd6aee438eafc7cc61c23342d', 'src/third_party/libunwindstack': { 'url': 'https://chromium.googlesource.com/chromium/src/third_party/libunwindstack.git@6868358481bb1e5e20d155c1084dc436c88b5e6b', 'condition': 'checkout_android', @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@a680c6e739309497959ef94e00889b337339165a', + 'https://chromium.googlesource.com/chromium/src/tools@ed445842ba89ff12dd92148c3282a6a45e66c3bc', 'src/third_party/accessibility_test_framework': { 'packages': [ @@ -384,7 +384,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/androidx', - 'version': 'EggJgyI0ja1HtThYH24KsjyfGghSO9o623ONeM4pynIC', + 'version': 's4aBuB5ULb4MMqBp4Xevo2Tf9qk_S5FxWr2xxansx68C', }, ], 'condition': 'checkout_android', From 2ea4d376cc1c61164e195461b7a41b615ce3e67c Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Thu, 10 Mar 2022 22:15:42 +0000 Subject: [PATCH 156/847] Break out remaining level-1 targets from rtc_pc_base Bug: webrtc:13805 Change-Id: I39a28489ff121de57a8476da10d297db823db091 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254822 Reviewed-by: Mirko Bonadei Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#36182} --- pc/BUILD.gn | 90 ++++++++++++++++++++++++++++++++----- test/fuzzers/BUILD.gn | 1 + test/peer_scenario/BUILD.gn | 1 + 3 files changed, 81 insertions(+), 11 deletions(-) diff --git a/pc/BUILD.gn b/pc/BUILD.gn index cc2bc1937a..b03eb8e7b5 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -86,21 +86,12 @@ rtc_library("rtc_pc_base") { "media_session.h", "rtp_transport.cc", "rtp_transport.h", - "rtp_transport_internal.h", - "sctp_data_channel_transport.cc", - "sctp_data_channel_transport.h", "sctp_transport.cc", "sctp_transport.h", - "sctp_utils.cc", - "sctp_utils.h", - "srtp_filter.cc", - "srtp_filter.h", "srtp_session.cc", "srtp_session.h", "srtp_transport.cc", "srtp_transport.h", - "transport_stats.cc", - "transport_stats.h", "used_ids.h", "video_track_source_proxy.cc", "video_track_source_proxy.h", @@ -350,19 +341,75 @@ rtc_source_set("rtp_transport") { visibility = [ ":*" ] } rtc_source_set("rtp_transport_internal") { - visibility = [ ":*" ] + visibility = [ + ":*", + "../test/peer_scenario", + ] + sources = [ "rtp_transport_internal.h" ] + deps = [ + ":session_description", + "../call:rtp_receiver", + "../p2p:rtc_p2p", + "../rtc_base", + "../rtc_base/third_party/sigslot", + ] } rtc_source_set("sctp_data_channel_transport") { visibility = [ ":*" ] + sources = [ + "sctp_data_channel_transport.cc", + "sctp_data_channel_transport.h", + ] + deps = [ + "../api:rtc_error", + "../api/transport:datagram_transport_interface", + "../media:rtc_data_sctp_transport_internal", + "../media:rtc_media_base", + "../rtc_base:rtc_base_approved", + "../rtc_base/third_party/sigslot", + ] } rtc_source_set("sctp_transport") { visibility = [ ":*" ] } rtc_source_set("sctp_utils") { - visibility = [ ":*" ] + visibility = [ + ":*", + "../test/fuzzers:sctp_utils_fuzzer", + ] + sources = [ + "sctp_utils.cc", + "sctp_utils.h", + ] + deps = [ + "../api:libjingle_peerconnection_api", + "../api:priority", + "../api/transport:datagram_transport_interface", + "../media:rtc_media_base", + "../rtc_base:rtc_base_approved", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } rtc_source_set("srtp_filter") { visibility = [ ":*" ] + sources = [ + "srtp_filter.cc", + "srtp_filter.h", + ] + deps = [ + ":session_description", + "../api:array_view", + "../api:libjingle_peerconnection_api", + "../api:sequence_checker", + "../rtc_base", + "../rtc_base:logging", + "../rtc_base:rtc_base_approved", + "../rtc_base/third_party/base64", + ] + absl_deps = [ + "//third_party/abseil-cpp/absl/strings", + "//third_party/abseil-cpp/absl/types:optional", + ] } rtc_source_set("srtp_session") { visibility = [ ":*" ] @@ -372,6 +419,15 @@ rtc_source_set("srtp_transport") { } rtc_source_set("transport_stats") { visibility = [ ":*" ] + sources = [ + "transport_stats.cc", + "transport_stats.h", + ] + deps = [ + "../api:libjingle_peerconnection_api", + "../p2p:rtc_p2p", + "../rtc_base", + ] } rtc_source_set("used_ids") { visibility = [ ":*" ] @@ -590,6 +646,7 @@ rtc_library("sctp_data_channel") { ":data_channel_utils", ":proxy", ":rtc_pc_base", + ":sctp_utils", "../api:libjingle_peerconnection_api", "../api:priority", "../api:rtc_error", @@ -669,6 +726,7 @@ rtc_source_set("data_channel_controller") { ":peer_connection_internal", ":rtc_pc_base", ":sctp_data_channel", + ":sctp_utils", "../api:libjingle_peerconnection_api", "../api:rtc_error", "../api:scoped_refptr", @@ -722,6 +780,7 @@ rtc_source_set("rtc_stats_collector") { ":rtp_transceiver", ":sctp_data_channel", ":track_media_info_map", + ":transport_stats", ":webrtc_sdp", "../api:array_view", "../api:libjingle_peerconnection_api", @@ -882,6 +941,7 @@ rtc_source_set("peer_connection") { ":rtp_sender_proxy", ":rtp_transceiver", ":rtp_transmission_manager", + ":rtp_transport_internal", ":sctp_data_channel", ":sdp_offer_answer", ":session_description", @@ -889,6 +949,7 @@ rtc_source_set("peer_connection") { ":stats_collector", ":stream_collection", ":transceiver_list", + ":transport_stats", ":usage_pattern", ":webrtc_session_description_factory", "../api:async_dns_resolver", @@ -991,6 +1052,7 @@ rtc_source_set("stats_collector") { ":rtp_sender_proxy", ":rtp_transceiver", ":stats_collector_interface", + ":transport_stats", "../api:libjingle_peerconnection_api", "../api:media_stream_interface", "../api:rtp_parameters", @@ -1252,6 +1314,7 @@ rtc_library("rtp_transceiver") { ":rtp_receiver_proxy", ":rtp_sender", ":rtp_sender_proxy", + ":rtp_transport_internal", ":session_description", "../api:array_view", "../api:libjingle_peerconnection_api", @@ -1742,7 +1805,9 @@ if (rtc_include_tests && !build_with_chromium) { ":rtc_pc_base", ":rtcp_mux_filter", ":rtp_media_utils", + ":rtp_transport_internal", ":session_description", + ":srtp_filter", ":video_rtp_receiver", "../api:array_view", "../api:audio_options_api", @@ -1940,7 +2005,9 @@ if (rtc_include_tests && !build_with_chromium) { ":rtp_sender", ":rtp_sender_proxy", ":rtp_transceiver", + ":rtp_transport_internal", ":sctp_data_channel", + ":sctp_utils", ":sdp_serializer", ":sdp_utils", ":session_description", @@ -1948,6 +2015,7 @@ if (rtc_include_tests && !build_with_chromium) { ":stats_collector", ":stream_collection", ":track_media_info_map", + ":transport_stats", ":usage_pattern", ":video_rtp_receiver", ":video_rtp_track_source", diff --git a/test/fuzzers/BUILD.gn b/test/fuzzers/BUILD.gn index c71231453c..1e19dba776 100644 --- a/test/fuzzers/BUILD.gn +++ b/test/fuzzers/BUILD.gn @@ -646,6 +646,7 @@ webrtc_fuzzer_test("sctp_utils_fuzzer") { "../../api:libjingle_peerconnection_api", "../../pc:libjingle_peerconnection", "../../pc:rtc_pc_base", + "../../pc:sctp_utils", "../../rtc_base:rtc_base_approved", ] } diff --git a/test/peer_scenario/BUILD.gn b/test/peer_scenario/BUILD.gn index d3ac0da606..b339494d7f 100644 --- a/test/peer_scenario/BUILD.gn +++ b/test/peer_scenario/BUILD.gn @@ -45,6 +45,7 @@ if (rtc_include_tests) { "../../p2p:rtc_p2p", "../../pc:pc_test_utils", "../../pc:rtc_pc_base", + "../../pc:rtp_transport_internal", "../../pc:session_description", "../../rtc_base", "../../rtc_base:null_socket_server", From 2c64c6f50e12bf34b410cc8c81114301694e9e7c Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Sun, 13 Mar 2022 21:04:50 -0700 Subject: [PATCH 157/847] Update WebRTC code version (2022-03-14T04:04:50). Bug: None Change-Id: I946168ceee261e801cb2da71c78394c6b2c642ba Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255281 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36183} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index 11b61d9f97..2de64f2e66 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 2022-03-11T04:02:47"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-03-14T04:04:50"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From f2970c8b37c7e55d708417d14e893d479850e37e Mon Sep 17 00:00:00 2001 From: Jeremy Leconte Date: Thu, 10 Mar 2022 18:43:44 +0100 Subject: [PATCH 158/847] Copy infra/config in the main branch. Bug: chromium:1159728 Change-Id: I611d60749f2a7055c67e6db758fa2f17f433c1a8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254720 Reviewed-by: Mirko Bonadei Reviewed-by: Harald Alvestrand Commit-Queue: Jeremy Leconte Cr-Commit-Position: refs/heads/main@{#36184} --- infra/config/OWNERS | 6 + infra/config/PRESUBMIT.py | 20 + infra/config/README.md | 52 + infra/config/codereview.settings | 6 + infra/config/commit-queue.cfg | 365 + infra/config/config.star | 856 +++ infra/config/console-header.textpb | 59 + infra/config/cr-buildbucket.cfg | 5864 +++++++++++++++++ infra/config/luci-logdog.cfg | 9 + infra/config/luci-milo.cfg | 606 ++ infra/config/luci-notify.cfg | 2179 ++++++ .../email-templates/build_failure.template | 24 + .../luci-notify/email-templates/cron.template | 33 + .../email-templates/infra_failure.template | 24 + infra/config/luci-scheduler.cfg | 715 ++ infra/config/project.cfg | 15 + infra/config/realms.cfg | 179 + 17 files changed, 11012 insertions(+) create mode 100644 infra/config/OWNERS create mode 100644 infra/config/PRESUBMIT.py create mode 100644 infra/config/README.md create mode 100644 infra/config/codereview.settings create mode 100644 infra/config/commit-queue.cfg create mode 100755 infra/config/config.star create mode 100644 infra/config/console-header.textpb create mode 100644 infra/config/cr-buildbucket.cfg create mode 100644 infra/config/luci-logdog.cfg create mode 100644 infra/config/luci-milo.cfg create mode 100644 infra/config/luci-notify.cfg create mode 100644 infra/config/luci-notify/email-templates/build_failure.template create mode 100644 infra/config/luci-notify/email-templates/cron.template create mode 100644 infra/config/luci-notify/email-templates/infra_failure.template create mode 100644 infra/config/luci-scheduler.cfg create mode 100644 infra/config/project.cfg create mode 100644 infra/config/realms.cfg diff --git a/infra/config/OWNERS b/infra/config/OWNERS new file mode 100644 index 0000000000..eae8171db5 --- /dev/null +++ b/infra/config/OWNERS @@ -0,0 +1,6 @@ +mbonadei@webrtc.org +jleconte@webrtc.org +titovartem@webrtc.org +jansson@webrtc.org +terelius@webrtc.org +landrey@webrtc.org diff --git a/infra/config/PRESUBMIT.py b/infra/config/PRESUBMIT.py new file mode 100644 index 0000000000..6aa75c7df5 --- /dev/null +++ b/infra/config/PRESUBMIT.py @@ -0,0 +1,20 @@ +# 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. + + +def CheckChangeOnUpload(input_api, output_api): + return input_api.RunTests( + input_api.canned_checks.CheckLucicfgGenOutput( + input_api, output_api, + 'config.star')) + input_api.canned_checks.CheckChangedLUCIConfigs( + input_api, output_api) + return res + + +def CheckChangeOnCommit(input_api, output_api): + return CheckChangeOnUpload(input_api, output_api) diff --git a/infra/config/README.md b/infra/config/README.md new file mode 100644 index 0000000000..ef60c763db --- /dev/null +++ b/infra/config/README.md @@ -0,0 +1,52 @@ +# infra/config folder + +This folder contains WebRTC project-wide configurations for Chrome infra +services, mainly the CI system ([console][]). + +`*.cfg` files are the actual configuration that [LUCI][luci-config] looks at. +They are in *protocol buffer text format*. For example, +[cr-buildbucket.cfg](cr-buildbucket.cfg) defines builders. + +However, they are all automatically generated from the [Starlark][] script +[config.star](config.star) that defines a unified config using **[lucicfg][]**. +The main body of the config is at the bottom of the file, following all the +helper definitions. + +`lucicfg` should be available as part of depot_tools. After editing +[config.star](config.star) you should run `lucicfg generate config.star` to +re-generate `*.cfg` files. Check the diffs in generated files to confirm that +your change worked as expected. Both the code change and the generated changes +need to be committed together. + +## Uploading changes + +It is recommended to have a separate checkout for this branch, so switching +to/from it does not populate/delete all files in the master branch. + +Initial setup: + +```bash +git clone https://webrtc.googlesource.com/src/ +``` + +Now you can create a new branch to make changes: + +```bash +git new-branch add-new-builder +# edit/generate files +git commit -a +git cl upload +``` + +Changes can be reviewed on Gerrit and submitted with commit queue as usual. + +### Activating the changes + +Any changes to this directory go live soon after landing, without any additional +steps. You can see the status or force a refresh of the config at +[luci-config][]. + +[console]: https://ci.chromium.org/p/webrtc/g/ci/console +[luci-config]: https://luci-config.appspot.com/#/projects/webrtc +[starlark]: https://github.com/google/starlark-go +[lucicfg]: https://chromium.googlesource.com/infra/luci/luci-go/+/master/lucicfg/doc/ diff --git a/infra/config/codereview.settings b/infra/config/codereview.settings new file mode 100644 index 0000000000..df15400f01 --- /dev/null +++ b/infra/config/codereview.settings @@ -0,0 +1,6 @@ +# This file is used by git-cl to get repository specific information. +CODE_REVIEW_SERVER: codereview.webrtc.org +CC_LIST: webrtc-reviews@webrtc.org +GERRIT_HOST: True +PROJECT: webrtc +VIEW_VC: https://webrtc.googlesource.com/src/+/ diff --git a/infra/config/commit-queue.cfg b/infra/config/commit-queue.cfg new file mode 100644 index 0000000000..ac8c474e27 --- /dev/null +++ b/infra/config/commit-queue.cfg @@ -0,0 +1,365 @@ +# Auto-generated by lucicfg. +# Do not modify manually. +# +# For the schema of this file, see Config message: +# https://luci-config.appspot.com/schemas/projects:commit-queue.cfg + +cq_status_host: "chromium-cq-status.appspot.com" +submit_options { + max_burst: 1 + burst_delay { + seconds: 60 + } +} +config_groups { + name: "cq" + gerrit { + url: "https://webrtc-review.googlesource.com" + projects { + name: "src" + ref_regexp: "refs/heads/master" + ref_regexp: "refs/heads/main" + } + } + verifiers { + gerrit_cq_ability { + committer_list: "project-webrtc-committers" + dry_run_access_list: "project-webrtc-tryjob-access" + } + tree_status { + url: "https://webrtc-status.appspot.com" + } + tryjob { + builders { + name: "webrtc-internal/g3.webrtc-internal.try/internal_compile_lite" + owner_whitelist_group: "project-webrtc-internal-tryjob-access" + } + builders { + name: "webrtc/try/android_arm64_rel" + } + builders { + name: "webrtc/try/android_arm_dbg" + } + builders { + name: "webrtc/try/android_arm_more_configs" + } + builders { + name: "webrtc/try/android_arm_rel" + } + builders { + name: "webrtc/try/android_chromium_compile" + } + builders { + name: "webrtc/try/android_compile_arm64_rel" + } + builders { + name: "webrtc/try/android_compile_arm_rel" + } + builders { + name: "webrtc/try/android_compile_x64_dbg" + } + builders { + name: "webrtc/try/android_compile_x86_dbg" + } + builders { + name: "webrtc/try/android_compile_x86_rel" + } + builders { + name: "webrtc/try/ios_api_framework" + } + builders { + name: "webrtc/try/ios_compile_arm64_dbg" + } + builders { + name: "webrtc/try/ios_compile_arm64_rel" + } + builders { + name: "webrtc/try/ios_sim_x64_dbg_ios12" + } + builders { + name: "webrtc/try/ios_sim_x64_dbg_ios13" + } + builders { + name: "webrtc/try/ios_sim_x64_dbg_ios14" + } + builders { + name: "webrtc/try/linux_asan" + } + builders { + name: "webrtc/try/linux_chromium_compile" + } + builders { + name: "webrtc/try/linux_chromium_compile_dbg" + } + builders { + name: "webrtc/try/linux_compile_arm64_dbg" + } + builders { + name: "webrtc/try/linux_compile_arm64_rel" + } + builders { + name: "webrtc/try/linux_compile_arm_dbg" + } + builders { + name: "webrtc/try/linux_compile_arm_rel" + } + builders { + name: "webrtc/try/linux_compile_dbg" + } + builders { + name: "webrtc/try/linux_compile_rel" + } + builders { + name: "webrtc/try/linux_libfuzzer_rel" + } + builders { + name: "webrtc/try/linux_more_configs" + } + builders { + name: "webrtc/try/linux_msan" + } + builders { + name: "webrtc/try/linux_rel" + } + builders { + name: "webrtc/try/linux_tsan2" + } + builders { + name: "webrtc/try/linux_ubsan" + } + builders { + name: "webrtc/try/linux_ubsan_vptr" + } + builders { + name: "webrtc/try/linux_x86_dbg" + } + builders { + name: "webrtc/try/linux_x86_rel" + } + builders { + name: "webrtc/try/mac_asan" + } + builders { + name: "webrtc/try/mac_chromium_compile" + } + builders { + name: "webrtc/try/mac_compile_dbg" + } + builders { + name: "webrtc/try/mac_rel" + } + builders { + name: "webrtc/try/presubmit" + disable_reuse: true + } + builders { + name: "webrtc/try/win_asan" + } + builders { + name: "webrtc/try/win_chromium_compile" + } + builders { + name: "webrtc/try/win_chromium_compile_dbg" + } + builders { + name: "webrtc/try/win_compile_x64_clang_dbg" + } + builders { + name: "webrtc/try/win_compile_x64_clang_rel" + } + builders { + name: "webrtc/try/win_compile_x86_clang_dbg" + } + builders { + name: "webrtc/try/win_x86_clang_rel" + } + builders { + name: "webrtc/try/win_x86_more_configs" + } + retry_config { + single_quota: 1 + global_quota: 2 + failure_weight: 1 + transient_failure_weight: 1 + timeout_weight: 2 + } + } + } +} +config_groups { + name: "cq_branch" + gerrit { + url: "https://webrtc-review.googlesource.com" + projects { + name: "src" + ref_regexp: "refs/branch-heads/.+" + } + } + verifiers { + gerrit_cq_ability { + committer_list: "project-webrtc-committers" + dry_run_access_list: "project-webrtc-tryjob-access" + } + tryjob { + builders { + name: "webrtc/try/android_arm64_rel" + } + builders { + name: "webrtc/try/android_arm_dbg" + } + builders { + name: "webrtc/try/android_arm_more_configs" + } + builders { + name: "webrtc/try/android_arm_rel" + } + builders { + name: "webrtc/try/android_compile_arm64_rel" + } + builders { + name: "webrtc/try/android_compile_arm_rel" + } + builders { + name: "webrtc/try/android_compile_x64_dbg" + } + builders { + name: "webrtc/try/android_compile_x86_dbg" + } + builders { + name: "webrtc/try/android_compile_x86_rel" + } + builders { + name: "webrtc/try/ios_api_framework" + } + builders { + name: "webrtc/try/ios_compile_arm64_dbg" + } + builders { + name: "webrtc/try/ios_compile_arm64_rel" + } + builders { + name: "webrtc/try/ios_sim_x64_dbg_ios12" + } + builders { + name: "webrtc/try/ios_sim_x64_dbg_ios13" + } + builders { + name: "webrtc/try/ios_sim_x64_dbg_ios14" + } + builders { + name: "webrtc/try/linux_asan" + } + builders { + name: "webrtc/try/linux_compile_arm64_dbg" + } + builders { + name: "webrtc/try/linux_compile_arm64_rel" + } + builders { + name: "webrtc/try/linux_compile_arm_dbg" + } + builders { + name: "webrtc/try/linux_compile_arm_rel" + } + builders { + name: "webrtc/try/linux_compile_dbg" + } + builders { + name: "webrtc/try/linux_compile_rel" + } + builders { + name: "webrtc/try/linux_libfuzzer_rel" + } + builders { + name: "webrtc/try/linux_more_configs" + } + builders { + name: "webrtc/try/linux_msan" + } + builders { + name: "webrtc/try/linux_rel" + } + builders { + name: "webrtc/try/linux_tsan2" + } + builders { + name: "webrtc/try/linux_ubsan" + } + builders { + name: "webrtc/try/linux_ubsan_vptr" + } + builders { + name: "webrtc/try/linux_x86_dbg" + } + builders { + name: "webrtc/try/linux_x86_rel" + } + builders { + name: "webrtc/try/mac_asan" + } + builders { + name: "webrtc/try/mac_compile_dbg" + } + builders { + name: "webrtc/try/mac_rel" + } + builders { + name: "webrtc/try/presubmit" + disable_reuse: true + } + builders { + name: "webrtc/try/win_asan" + } + builders { + name: "webrtc/try/win_compile_x64_clang_dbg" + } + builders { + name: "webrtc/try/win_compile_x64_clang_rel" + } + builders { + name: "webrtc/try/win_compile_x86_clang_dbg" + } + builders { + name: "webrtc/try/win_x86_clang_rel" + } + builders { + name: "webrtc/try/win_x86_more_configs" + } + retry_config { + single_quota: 1 + global_quota: 2 + failure_weight: 1 + transient_failure_weight: 1 + timeout_weight: 2 + } + } + } +} +config_groups { + name: "cq_infra" + gerrit { + url: "https://webrtc-review.googlesource.com" + projects { + name: "src" + ref_regexp: "refs/heads/infra/config" + } + } + verifiers { + gerrit_cq_ability { + committer_list: "project-webrtc-admins" + dry_run_access_list: "project-webrtc-tryjob-access" + } + tryjob { + builders { + name: "webrtc/try/presubmit" + } + retry_config { + single_quota: 1 + global_quota: 2 + failure_weight: 1 + transient_failure_weight: 1 + timeout_weight: 2 + } + } + } +} diff --git a/infra/config/config.star b/infra/config/config.star new file mode 100755 index 0000000000..f089c656ba --- /dev/null +++ b/infra/config/config.star @@ -0,0 +1,856 @@ +#!/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. + +# https://chromium.googlesource.com/infra/luci/luci-go/+/main/lucicfg/doc/ + +"""LUCI project configuration for WebRTC CQ and CI.""" + +lucicfg.check_version("1.30.9") + +WEBRTC_GIT = "https://webrtc.googlesource.com/src" +WEBRTC_GERRIT = "https://webrtc-review.googlesource.com/src" +WEBRTC_TROOPER_EMAIL = "webrtc-troopers-robots@google.com" +WEBRTC_IOS_XCODE_VERSION = "12a7209" +WEBRTC_XCODE13 = "13a233" +DEFAULT_CPU = "x86-64" + +# Helpers: + +def make_goma_properties(enable_ats = True, jobs = None): + """Makes a default goma property with the specified argument. + + Args: + enable_ats: True if the ATS should be enabled. + jobs: Number of jobs to be used by the builder. + Returns: + A dictonary with the goma properties. + """ + goma_properties = { + "server_host": "goma.chromium.org", + "use_luci_auth": True, + } + if not enable_ats: + goma_properties["enable_ats"] = enable_ats + if jobs: + goma_properties["jobs"] = jobs + return {"$build/goma": goma_properties} + +# Add names of builders to remove from LKGR finder to this list. This is +# useful when a failure can be safely ignored while fixing it without +# blocking the LKGR finder on it. +skipped_lkgr_bots = [ +] + +# Use LUCI Scheduler BBv2 names and add Scheduler realms configs. +lucicfg.enable_experiment("crbug.com/1182002") + +luci.builder.defaults.experiments.set( + { + "luci.recipes.use_python3": 100, + }, +) +luci.builder.defaults.test_presentation.set( + resultdb.test_presentation(grouping_keys = ["status", "v.test_suite"]), +) + +lucicfg.config( + config_dir = ".", + tracked_files = [ + "commit-queue.cfg", + "cr-buildbucket.cfg", + "luci-logdog.cfg", + "luci-milo.cfg", + "luci-notify.cfg", + "luci-notify/**/*", + "luci-scheduler.cfg", + "project.cfg", + "realms.cfg", + ], + lint_checks = ["default"], +) + +luci.project( + name = "webrtc", + buildbucket = "cr-buildbucket.appspot.com", + logdog = "luci-logdog.appspot.com", + milo = "luci-milo.appspot.com", + notify = "luci-notify.appspot.com", + scheduler = "luci-scheduler.appspot.com", + swarming = "chromium-swarm.appspot.com", + acls = [ + acl.entry( + [acl.BUILDBUCKET_READER, acl.LOGDOG_READER, acl.PROJECT_CONFIGS_READER, acl.SCHEDULER_READER], + groups = ["all"], + ), + acl.entry(acl.LOGDOG_WRITER, groups = ["luci-logdog-chromium-writers"]), + acl.entry(acl.SCHEDULER_OWNER, groups = ["project-webrtc-admins"]), + ], + bindings = [ + luci.binding( + roles = "role/configs.validator", + users = [ + "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com", + ], + ), + luci.binding( + roles = "role/swarming.poolOwner", + groups = "project-webrtc-admins", + ), + luci.binding( + roles = "role/swarming.poolViewer", + groups = "all", + ), + # Allow any WebRTC build to trigger a test ran under chromium-tester@ + # task service account. + luci.binding( + roles = "role/swarming.taskServiceAccount", + users = [ + "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", + ], + ), + ], +) + +luci.logdog( + gs_bucket = "chromium-luci-logdog", +) + +luci.milo( + logo = "https://storage.googleapis.com/chrome-infra/webrtc-logo-vert-retro-255x305.png", +) + +luci.notify(tree_closing_enabled = True) + +luci.cq( + status_host = "chromium-cq-status.appspot.com", + submit_max_burst = 1, + submit_burst_delay = 1 * time.minute, +) + +luci.gitiles_poller( + name = "webrtc-gitiles-trigger-main", + bucket = "ci", + repo = WEBRTC_GIT, + refs = ["refs/heads/main"], +) + +# Swarming permissions: + +luci.realm(name = "pools/cron", bindings = [ + # Unlike WebRTC's own builders, other projects need an explicit grant to use this pool. + luci.binding( + roles = "role/swarming.poolUser", + projects = "libyuv", + ), +]) + +luci.realm(name = "pools/ci") +luci.realm(name = "pools/ci-tests", bindings = [ + # Allow task service accounts of .ci pool/bucket to trigger tasks here. + luci.binding( + roles = "role/swarming.poolUser", + groups = "project-webrtc-ci-task-accounts", + ), + # Allow tasks here to use .ci task service accounts. + luci.binding( + roles = "role/swarming.taskServiceAccount", + groups = "project-webrtc-ci-task-accounts", + ), +]) +luci.realm(name = "ci", bindings = [ + # Allow CI builders to create invocations in their own builds. + luci.binding( + roles = "role/resultdb.invocationCreator", + groups = "project-webrtc-ci-task-accounts", + ), +]) + +luci.realm(name = "pools/try", bindings = [ + # Allow to use LED & Swarming "Debug" feature to a larger group but only on try bots / builders. + luci.binding( + roles = "role/swarming.poolUser", + groups = "project-webrtc-led-users", + ), +]) +luci.realm(name = "pools/try-tests", bindings = [ + # Allow task service accounts of .try pool/bucket to trigger tasks here. + luci.binding( + roles = "role/swarming.poolUser", + groups = "project-webrtc-try-task-accounts", + ), + # Allow tasks here to use .try task service accounts. + luci.binding( + roles = "role/swarming.taskServiceAccount", + groups = "project-webrtc-try-task-accounts", + ), +]) +luci.realm(name = "try", bindings = [ + luci.binding( + roles = "role/swarming.taskTriggerer", + groups = "project-webrtc-led-users", + ), + # Allow try builders to create invocations in their own builds. + luci.binding( + roles = "role/resultdb.invocationCreator", + groups = "project-webrtc-try-task-accounts", + ), +]) + +luci.realm(name = "pools/perf", bindings = [ + # Allow to use LED & Swarming "Debug" feature to a larger group but only on perf bots / builders. + luci.binding( + roles = "role/swarming.poolUser", + groups = "project-webrtc-led-users", + ), +]) +luci.realm(name = "perf", bindings = [ + luci.binding( + roles = "role/swarming.taskTriggerer", + groups = "project-webrtc-led-users", + ), +]) + +luci.realm(name = "@root", bindings = [ + # Allow admins to use LED & Swarming "Debug" feature on all WebRTC bots. + luci.binding( + roles = "role/swarming.poolUser", + groups = "project-webrtc-admins", + ), + luci.binding( + roles = "role/swarming.taskTriggerer", + groups = "project-webrtc-admins", + ), +]) + +# Bucket definitions: + +luci.bucket( + name = "try", + acls = [ + acl.entry(acl.BUILDBUCKET_TRIGGERER, groups = [ + "service-account-cq", + "project-webrtc-tryjob-access", + ]), + ], +) + +luci.bucket( + name = "ci", + acls = [ + acl.entry(acl.BUILDBUCKET_TRIGGERER, groups = [ + "project-webrtc-ci-schedulers", + ]), + acl.entry(acl.BUILDBUCKET_TRIGGERER, groups = [ + # Allow Pinpoint to trigger builds for bisection + "service-account-chromeperf", + ]), + ], +) + +luci.bucket( + name = "perf", + acls = [ + acl.entry(acl.BUILDBUCKET_TRIGGERER, users = [ + "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com", + ]), + ], +) + +luci.bucket( + name = "cron", +) + +# Commit queue definitions: + +luci.cq_group( + name = "cq", + tree_status_host = "webrtc-status.appspot.com", + watch = [cq.refset(repo = WEBRTC_GERRIT, refs = ["refs/heads/master", "refs/heads/main"])], + acls = [ + acl.entry(acl.CQ_COMMITTER, groups = ["project-webrtc-committers"]), + acl.entry(acl.CQ_DRY_RUNNER, groups = ["project-webrtc-tryjob-access"]), + ], + retry_config = cq.RETRY_ALL_FAILURES, + cancel_stale_tryjobs = True, +) + +luci.cq_group( + name = "cq_branch", + watch = [cq.refset(repo = WEBRTC_GERRIT, refs = ["refs/branch-heads/.+"])], + acls = [ + acl.entry(acl.CQ_COMMITTER, groups = ["project-webrtc-committers"]), + acl.entry(acl.CQ_DRY_RUNNER, groups = ["project-webrtc-tryjob-access"]), + ], + retry_config = cq.RETRY_ALL_FAILURES, + cancel_stale_tryjobs = True, +) + +luci.cq_group( + name = "cq_infra", + watch = [cq.refset(repo = WEBRTC_GERRIT, refs = ["refs/heads/infra/config"])], + acls = [ + acl.entry(acl.CQ_COMMITTER, groups = ["project-webrtc-admins"]), + acl.entry(acl.CQ_DRY_RUNNER, groups = ["project-webrtc-tryjob-access"]), + ], + retry_config = cq.RETRY_ALL_FAILURES, + cancel_stale_tryjobs = True, +) + +luci.cq_tryjob_verifier( + builder = "presubmit", + cq_group = "cq_infra", +) + +luci.cq_tryjob_verifier( + builder = "webrtc-internal:g3.webrtc-internal.try/internal_compile_lite", + owner_whitelist = ["project-webrtc-internal-tryjob-access"], + cq_group = "cq", +) + +# Notifier definitions: + +luci.notifier( + name = "post_submit_failure_notifier", + on_new_status = ["FAILURE"], + notify_emails = [WEBRTC_TROOPER_EMAIL], + notify_blamelist = True, + template = luci.notifier_template( + name = "build_failure", + body = io.read_file("luci-notify/email-templates/build_failure.template"), + ), +) + +luci.notifier( + name = "cron_notifier", + on_new_status = ["FAILURE", "INFRA_FAILURE"], + notify_emails = [WEBRTC_TROOPER_EMAIL], + template = luci.notifier_template( + name = "cron", + body = io.read_file("luci-notify/email-templates/cron.template"), + ), +) + +luci.notifier( + name = "infra_failure_notifier", + on_new_status = ["INFRA_FAILURE"], + notify_emails = [WEBRTC_TROOPER_EMAIL], + template = luci.notifier_template( + name = "infra_failure", + body = io.read_file("luci-notify/email-templates/infra_failure.template"), + ), +) + +# Tree closer definitions: + +luci.tree_closer( + name = "webrtc_tree_closer", + tree_status_host = "webrtc-status.appspot.com", + # TODO: These step filters are copied verbatim from Gatekeeper, for testing + # that LUCI-Notify would take the exact same actions. Once we've switched + # over, this should be updated - several of these steps don't exist in + # WebRTC recipes. + failed_step_regexp = [ + "bot_update", + "compile", + "gclient runhooks", + "runhooks", + "update", + "extract build", + "cleanup_temp", + "taskkill", + "compile", + "gn", + ], + failed_step_regexp_exclude = ".*\\(experimental\\).*", +) + +# Recipe definitions: + +def recipe(recipe, pkg = "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"): + return luci.recipe( + name = recipe.split("/")[-1], + cipd_package = pkg, + cipd_version = "refs/heads/main", + recipe = recipe, + use_python3 = True, + ) + +recipe("chromium_trybot") +recipe("run_presubmit") +recipe("webrtc/auto_roll_webrtc_deps") +recipe("webrtc/ios_api_framework") +recipe("webrtc/libfuzzer") +recipe("webrtc/standalone") +recipe("webrtc/update_webrtc_binary_version") +recipe("lkgr_finder", pkg = "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build") + +# Console definitions: + +luci.console_view(name = "ci", title = "Main", repo = WEBRTC_GIT, header = "console-header.textpb", refs = ["refs/heads/master", "refs/heads/main"]) +luci.console_view(name = "perf", title = "Perf", repo = WEBRTC_GIT, header = "console-header.textpb", refs = ["refs/heads/master", "refs/heads/main"]) +luci.list_view(name = "cron", title = "Cron") +luci.list_view(name = "try", title = "Tryserver") + +def add_milo(builder, views): + """Add Milo console entries for the builder. + + Args: + builder: builder name (str). + views: dict where keys are names of consoles and values are either a + category for the console (str, pipe-separated) or True, which means + adding to a list view rather than a console. + """ + for view_name, category in views.items(): + if category == None: + continue + elif type(category) == "string": + category, _, short_name = category.rpartition("|") + luci.console_view_entry( + console_view = view_name, + builder = builder, + category = category or None, + short_name = short_name or None, + ) + elif category == True: + luci.list_view_entry( + list_view = view_name, + builder = builder, + ) + else: + fail("Unexpected value for category: %r" % category) + +lkgr_builders = [] + +# Builder-defining functions: + +def webrtc_builder( + name, + bucket, + dimensions, + properties = None, + recipe = "standalone", + priority = 30, + execution_timeout = 2 * time.hour, + **kwargs): + """WebRTC specific wrapper around luci.builder. + + Args: + name: builder name (str). + bucket: The name of the bucket the builder belongs to. + dimensions: dict of Swarming dimensions (strings) to search machines by. + properties: dict of properties to pass to the recipe (on top of the default ones). + recipe: string with the name of the recipe to run. + priority: int [1-255] or None, indicating swarming task priority, lower is + more important. If None, defer the decision to Buildbucket service. + execution_timeout: int or None, how long to wait for a running build to finish before + forcefully aborting it and marking the build as timed out. If None, + defer the decision to Buildbucket service. + **kwargs: Pass on to webrtc_builder / luci.builder. + Returns: + A luci.builder. + """ + properties = properties or {} + properties["$recipe_engine/isolated"] = { + "server": "https://isolateserver.appspot.com", + } + resultdb_bq_table = "webrtc-ci.resultdb." + bucket + "_test_results" + return luci.builder( + name = name, + bucket = bucket, + executable = recipe, + dimensions = dimensions, + properties = properties, + execution_timeout = execution_timeout, + priority = priority, + build_numbers = True, + swarming_tags = ["vpython:native-python-wrapper"], + resultdb_settings = resultdb.settings( + enable = True, + bq_exports = [ + resultdb.export_test_results(bq_table = resultdb_bq_table), + ], + ), + **kwargs + ) + +def ci_builder( + name, + ci_cat, + dimensions, + properties = None, + perf_cat = None, + prioritized = False, + enabled = True, + **kwargs): + """Add a post-submit builder. + + Args: + name: builder name (str). + ci_cat: the category + name for the /ci/ console, or None to omit from the console. + dimensions: dict of Swarming dimensions (strings) to search machines by. + properties: dict of properties to pass to the recipe (on top of the default ones). + perf_cat: the category + name for the /perf/ console, or None to omit from the console. + prioritized: True to make this builder have a higher priority and never batch builds. + enabled: False to exclude this builder from consoles and failure notifications. + **kwargs: Pass on to webrtc_builder / luci.builder. + Returns: + A luci.builder. + + Notifications are also disabled if a builder is not on either of /ci/ or /perf/ consoles. + """ + if prioritized: + kwargs["triggering_policy"] = scheduler.greedy_batching( + max_batch_size = 1, + max_concurrent_invocations = 3, + ) + kwargs["priority"] = 29 + + if enabled: + add_milo(name, {"ci": ci_cat, "perf": perf_cat}) + if ci_cat: + lkgr_builders.append(name) + dimensions.update({"pool": "luci.webrtc.ci", "cpu": kwargs.pop("cpu", DEFAULT_CPU)}) + properties = properties or {} + properties["builder_group"] = "client.webrtc" + properties.update(make_goma_properties()) + notifies = ["post_submit_failure_notifier", "infra_failure_notifier"] + notifies += ["webrtc_tree_closer"] if name not in skipped_lkgr_bots else [] + return webrtc_builder( + name = name, + dimensions = dimensions, + properties = properties, + bucket = "ci", + service_account = "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com", + triggered_by = ["webrtc-gitiles-trigger-main"] if enabled else None, + repo = WEBRTC_GIT, + notifies = notifies if enabled else None, + **kwargs + ) + +def try_builder( + name, + dimensions, + properties = None, + try_cat = True, + cq = {}, + branch_cq = True, + goma_enable_ats = True, + goma_jobs = None, + **kwargs): + """Add a pre-submit builder. + + Args: + name: builder name (str). + dimensions: dict of Swarming dimensions (strings) to search machines by. + properties: dict of properties to pass to the recipe (on top of the default ones). + try_cat: boolean, whether to include this builder in the /try/ console. See also: `add_milo`. + cq: None to exclude this from all commit queues, or a dict of kwargs for cq_tryjob_verifier. + branch_cq: False to exclude this builder just from the release-branch CQ. + goma_enable_ats: True if the ATS should be enabled by the builder. + goma_jobs: Number of jobs to be used by the builder. + **kwargs: Pass on to webrtc_builder / luci.builder. + Returns: + A luci.builder. + """ + add_milo(name, {"try": try_cat}) + dimensions.update({"pool": "luci.webrtc.try", "cpu": DEFAULT_CPU}) + properties = properties or {} + properties["builder_group"] = "tryserver.webrtc" + properties.update(make_goma_properties(enable_ats = goma_enable_ats, jobs = goma_jobs)) + if cq != None: + luci.cq_tryjob_verifier(name, cq_group = "cq", **cq) + if branch_cq: + luci.cq_tryjob_verifier(name, cq_group = "cq_branch", **cq) + + return webrtc_builder( + name = name, + dimensions = dimensions, + properties = properties, + bucket = "try", + service_account = "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com", + notifies = ["infra_failure_notifier"], + **kwargs + ) + +def perf_builder(name, perf_cat, **kwargs): + add_milo(name, {"perf": perf_cat}) + properties = make_goma_properties() + properties["builder_group"] = "client.webrtc.perf" + return webrtc_builder( + name = name, + dimensions = {"pool": "luci.webrtc.perf", "os": "Linux"}, + properties = properties, + bucket = "perf", + service_account = "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com", + # log_base of 1.7 means: + # when there are P pending builds, LUCI will batch the first B builds. + # P: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ... + # B: 1 1 2 2 3 3 3 3 4 4 4 4 4 4 5 ... + triggering_policy = scheduler.logarithmic_batching(log_base = 1.7), + repo = WEBRTC_GIT, + execution_timeout = 3 * time.hour, + notifies = ["post_submit_failure_notifier", "infra_failure_notifier"], + **kwargs + ) + +def cron_builder(name, service_account = None, **kwargs): + if service_account == None: + service_account = "chromium-webrtc-autoroll@webrtc-ci.iam.gserviceaccount.com" + add_milo(name, {"cron": True}) + return webrtc_builder( + name = name, + dimensions = {"pool": "luci.webrtc.cron", "os": "Linux", "cpu": DEFAULT_CPU}, + bucket = "cron", + service_account = service_account, + notifies = ["cron_notifier"], + **kwargs + ) + +def normal_builder_factory(**common_kwargs): + def builder(*args, **kwargs): + kwargs.update(common_kwargs) + return ci_builder(*args, **kwargs) + + def try_job(name, **kwargs): + kwargs.update(common_kwargs) + return try_builder(name, **kwargs) + + return builder, try_job + +# Mixins: + +linux_builder, linux_try_job = normal_builder_factory( + dimensions = {"os": "Linux", "inside_docker": "0"}, +) + +android_builder, android_try_job = normal_builder_factory( + dimensions = {"os": "Linux"}, +) + +win_builder = normal_builder_factory( + dimensions = {"os": "Windows"}, +)[0] + +win_try_job = normal_builder_factory( + dimensions = {"os": "Windows"}, + goma_enable_ats = False, +)[1] + +mac_builder, mac_try_job = normal_builder_factory( + dimensions = {"os": "Mac"}, +) + +ios_builder, ios_try_job = normal_builder_factory( + dimensions = {"os": "Mac-10.15"}, + properties = {"xcode_build_version": WEBRTC_IOS_XCODE_VERSION}, + caches = [swarming.cache( + name = "xcode_ios_" + WEBRTC_IOS_XCODE_VERSION, + path = "xcode_ios_" + WEBRTC_IOS_XCODE_VERSION + ".app", + )], +) + +ios_builder_macos11, ios_try_job_macos11 = normal_builder_factory( + dimensions = {"os": "Mac-11"}, + properties = {"xcode_build_version": WEBRTC_XCODE13}, + caches = [swarming.cache( + name = "xcode_ios_" + WEBRTC_XCODE13, + path = "xcode_ios_" + WEBRTC_XCODE13 + ".app", + )], +) + +# Actual builder configuration: + +android_builder("Android32 (M Nexus5X)(dbg)", "Android|arm|dbg") +android_try_job("android_compile_arm_dbg", cq = None) +android_try_job("android_arm_dbg") +android_builder("Android32 (M Nexus5X)", "Android|arm|rel") +android_try_job("android_arm_rel") +android_builder("Android32 Builder arm", "Android|arm|size", perf_cat = "Android|arm|Builder|", prioritized = True) +android_try_job("android_compile_arm_rel") +perf_builder("Perf Android32 (M Nexus5)", "Android|arm|Tester|M Nexus5", triggered_by = ["Android32 Builder arm"]) +perf_builder("Perf Android32 (M AOSP Nexus6)", "Android|arm|Tester|M AOSP Nexus6", triggered_by = ["Android32 Builder arm"]) +android_try_job("android_compile_arm64_dbg", cq = None) +android_try_job("android_arm64_dbg", cq = None) +android_builder("Android64 (M Nexus5X)", "Android|arm64|rel") +android_try_job("android_arm64_rel") +android_builder("Android64 Builder arm64", "Android|arm64|size", perf_cat = "Android|arm64|Builder|", prioritized = True) +perf_builder("Perf Android64 (M Nexus5X)", "Android|arm64|Tester|M Nexus5X", triggered_by = ["Android64 Builder arm64"]) +perf_builder("Perf Android64 (O Pixel2)", "Android|arm64|Tester|O Pixel2", triggered_by = ["Android64 Builder arm64"]) +android_try_job("android_compile_arm64_rel") +android_builder("Android64 Builder x64 (dbg)", "Android|x64|dbg") +android_try_job("android_compile_x64_dbg") +android_try_job("android_compile_x64_rel", cq = None) +android_builder("Android32 Builder x86 (dbg)", "Android|x86|dbg") +android_try_job("android_compile_x86_dbg") +android_builder("Android32 Builder x86", "Android|x86|rel") +android_try_job("android_compile_x86_rel") +android_builder("Android32 (more configs)", "Android|arm|more") +android_try_job("android_arm_more_configs") +android_try_job("android_chromium_compile", recipe = "chromium_trybot", branch_cq = False) + +ios_builder("iOS64 Debug", "iOS|arm64|dbg") +ios_try_job("ios_compile_arm64_dbg") +ios_builder("iOS64 Release", "iOS|arm64|rel") +ios_try_job("ios_compile_arm64_rel") +ios_builder("iOS64 Sim Debug (iOS 14.0)", "iOS|x64|14") +ios_try_job("ios_sim_x64_dbg_ios14") +ios_builder("iOS64 Sim Debug (iOS 13)", "iOS|x64|13") +ios_try_job("ios_sim_x64_dbg_ios13") +ios_builder("iOS64 Sim Debug (iOS 12)", "iOS|x64|12") +ios_try_job("ios_sim_x64_dbg_ios12") +ios_builder_macos11("iOS API Framework Builder", "iOS|fat|size", recipe = "ios_api_framework", prioritized = True) +ios_try_job_macos11("ios_api_framework", recipe = "ios_api_framework") + +linux_builder("Linux32 Debug", "Linux|x86|dbg") +linux_try_job("linux_x86_dbg") +linux_builder("Linux32 Release", "Linux|x86|rel") +linux_try_job("linux_x86_rel") +linux_builder("Linux64 Debug", "Linux|x64|dbg") +linux_try_job("linux_dbg", cq = None) +linux_try_job("linux_compile_dbg") +linux_builder("Linux64 Release", "Linux|x64|rel") +linux_try_job("linux_rel") +linux_builder("Linux64 Builder", "Linux|x64|size", perf_cat = "Linux|x64|Builder|", prioritized = True) +linux_try_job("linux_compile_rel") +perf_builder("Perf Linux Trusty", "Linux|x64|Tester|Trusty", triggered_by = ["Linux64 Builder"]) +perf_builder("Perf Linux Bionic", "Linux|x64|Tester|Bionic", triggered_by = ["Linux64 Builder"]) +linux_builder("Linux32 Debug (ARM)", "Linux|arm|dbg") +linux_try_job("linux_compile_arm_dbg") +linux_builder("Linux32 Release (ARM)", "Linux|arm|rel") +linux_try_job("linux_compile_arm_rel") +linux_builder("Linux64 Debug (ARM)", "Linux|arm64|dbg") +linux_try_job("linux_compile_arm64_dbg") +linux_builder("Linux64 Release (ARM)", "Linux|arm64|rel") +linux_try_job("linux_compile_arm64_rel") +linux_builder("Linux Asan", "Linux|x64|asan") +linux_try_job("linux_asan") +linux_builder("Linux MSan", "Linux|x64|msan") +linux_try_job("linux_msan") +linux_builder("Linux Tsan v2", "Linux|x64|tsan") +linux_try_job("linux_tsan2") +linux_builder("Linux UBSan", "Linux|x64|ubsan") +linux_try_job("linux_ubsan") +linux_builder("Linux UBSan vptr", "Linux|x64|ubsan") +linux_try_job("linux_ubsan_vptr") +linux_builder("Linux64 Release (Libfuzzer)", "Linux|x64|fuzz", recipe = "libfuzzer") +linux_try_job("linux_libfuzzer_rel", recipe = "libfuzzer") +linux_builder("Linux (more configs)", "Linux|x64|more") +linux_try_job("linux_more_configs") +linux_try_job("linux_chromium_compile", recipe = "chromium_trybot", branch_cq = False) +linux_try_job("linux_chromium_compile_dbg", recipe = "chromium_trybot", branch_cq = False) + +mac_builder("Mac64 Debug", "Mac|x64|dbg") +mac_try_job("mac_dbg", cq = None) +mac_try_job("mac_compile_dbg") +mac_builder("Mac64 Release", "Mac|x64|rel") +mac_try_job("mac_rel") +mac_try_job("mac_compile_rel", cq = None) +mac_builder("Mac64 Builder", ci_cat = None, perf_cat = "Mac|x64|Builder|") +perf_builder("Perf Mac 10.11", "Mac|x64|Tester|10.11", triggered_by = ["Mac64 Builder"]) +mac_builder("Mac Asan", "Mac|x64|asan") +mac_try_job("mac_asan") +mac_try_job("mac_chromium_compile", recipe = "chromium_trybot", branch_cq = False) +mac_builder("MacARM64 M1 Release", "Mac|arm64M1|rel", cpu = "arm64-64-Apple_M1") +mac_try_job("mac_rel_m1", try_cat = None, cq = None) +mac_try_job("mac_dbg_m1", try_cat = None, cq = None) + +win_builder("Win32 Debug (Clang)", "Win Clang|x86|dbg") +win_try_job("win_x86_clang_dbg", cq = None) +win_try_job("win_compile_x86_clang_dbg") +win_builder("Win32 Release (Clang)", "Win Clang|x86|rel") +win_try_job("win_x86_clang_rel") +win_try_job("win_compile_x86_clang_rel", cq = None) +win_builder("Win32 Builder (Clang)", ci_cat = None, perf_cat = "Win|x86|Builder|") +perf_builder("Perf Win7", "Win|x86|Tester|7", triggered_by = ["Win32 Builder (Clang)"]) +win_builder("Win64 Debug (Clang)", "Win Clang|x64|dbg") +win_try_job("win_x64_clang_dbg", cq = None) +win_try_job("win_x64_clang_dbg_win10", cq = None) +win_try_job("win_compile_x64_clang_dbg") +win_builder("Win64 Release (Clang)", "Win Clang|x64|rel") +win_try_job("win_x64_clang_rel", cq = None) +win_try_job("win_compile_x64_clang_rel") +win_builder("Win64 ASan", "Win Clang|x64|asan") +win_try_job("win_asan") +win_builder("Win (more configs)", "Win Clang|x86|more") +win_try_job("win_x86_more_configs") +win_try_job("win_chromium_compile", recipe = "chromium_trybot", branch_cq = False, goma_jobs = 150) +win_try_job("win_chromium_compile_dbg", recipe = "chromium_trybot", branch_cq = False, goma_jobs = 150) + +linux_try_job( + "presubmit", + recipe = "run_presubmit", + properties = {"repo_name": "webrtc", "runhooks": True}, + priority = 28, + cq = {"disable_reuse": True}, +) + +cron_builder( + "Auto-roll - WebRTC DEPS", + recipe = "auto_roll_webrtc_deps", + schedule = "0 */2 * * *", # Every 2 hours. +) + +cron_builder( + "WebRTC version update", + recipe = "update_webrtc_binary_version", + schedule = "0 4 * * *", # Every day at 4am. + service_account = "webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com", +) + +lkgr_config = { + "project": "webrtc", + "source_url": WEBRTC_GIT, + "status_url": "https://webrtc-status.appspot.com", + "allowed_lag": 150, # hours + "allowed_gap": 4, # commits behind + "error_recipients": WEBRTC_TROOPER_EMAIL, + "buckets": { + "webrtc/ci": { + # bucket alias: luci.webrtc.ci + "builders": [ + b + for b in sorted(lkgr_builders) + if b not in skipped_lkgr_bots + ], + }, + "chromium/webrtc.fyi": { + # 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) (M Nexus5X)", + "WebRTC Chromium FYI Android Tests (dbg) (N Nexus5X)", + "WebRTC Chromium FYI Linux Builder (dbg)", + "WebRTC Chromium FYI Linux Builder", + "WebRTC Chromium FYI Linux Tester", + "WebRTC Chromium FYI Mac Builder (dbg)", + "WebRTC Chromium FYI Mac Builder", + "WebRTC Chromium FYI Mac Tester", + "WebRTC Chromium FYI Win Builder (dbg)", + "WebRTC Chromium FYI Win Builder", + "WebRTC Chromium FYI Win10 Tester", + "WebRTC Chromium FYI Win7 Tester", + "WebRTC Chromium FYI ios-device", + "WebRTC Chromium FYI ios-simulator", + ], + }, + }, +} + +cron_builder( + "WebRTC lkgr finder", + recipe = "lkgr_finder", + properties = { + "project": "webrtc", + "repo": WEBRTC_GIT, + "ref": "refs/heads/lkgr", + "src_ref": "refs/heads/main", + "lkgr_status_gs_path": "chromium-webrtc/lkgr-status", + "config": lkgr_config, + }, + schedule = "*/10 * * * *", # Every 10 minutes. +) diff --git a/infra/config/console-header.textpb b/infra/config/console-header.textpb new file mode 100644 index 0000000000..79e5d2bf21 --- /dev/null +++ b/infra/config/console-header.textpb @@ -0,0 +1,59 @@ +tree_status_host: "webrtc-status.appspot.com" +links { + name: "Consoles" + links { + text: "WebRTC" + url: "/p/webrtc/g/ci" + alt: "WebRTC Main CI Console" + } + links { + text: "WebRTC Cron" + url: "/p/webrtc/g/cron" + alt: "WebRTC Cron Console" + } + links { + text: "WebRTC Perf" + url: "/p/webrtc/g/perf" + alt: "WebRTC Perf Console" + } + links { + text: "Chromium" + url: "/p/chromium/g/chromium.webrtc" + alt: "Chromium WebRTC Console" + } + links { + text: "Chromium FYI" + url: "/p/chromium/g/chromium.webrtc.fyi" + alt: "Chromium WebRTC FYI Console" + } + links { + text: "Try WebRTC" + url: "/p/webrtc/g/try" + alt: "WebRTC Try Builders" + } +} +links { + name: "Links" + links { + text: "Source" + url: "https://webrtc.googlesource.com/src/+/main/" + } + links { + text: "Reviews" + url: "https://webrtc-review.googlesource.com/" + } + links { + text: "Bugs" + url: "https://bugs.webrtc.org/" + } + links { + text: "LKGR status" + url: "https://storage.cloud.google.com/chromium-webrtc/lkgr-status/webrtc-lkgr-status.html" + } +} +console_groups { + console_ids: "webrtc/ci" + console_ids: "webrtc/perf" + console_ids: "chromium/chromium.webrtc" + console_ids: "chromium/chromium.webrtc.fyi" +} diff --git a/infra/config/cr-buildbucket.cfg b/infra/config/cr-buildbucket.cfg new file mode 100644 index 0000000000..55aeece8db --- /dev/null +++ b/infra/config/cr-buildbucket.cfg @@ -0,0 +1,5864 @@ +# Auto-generated by lucicfg. +# Do not modify manually. +# +# For the schema of this file, see BuildbucketCfg message: +# https://luci-config.appspot.com/schemas/projects:buildbucket.cfg + +buckets { + name: "ci" + acls { + group: "all" + } + acls { + role: SCHEDULER + group: "project-webrtc-ci-schedulers" + } + acls { + role: SCHEDULER + group: "service-account-chromeperf" + } + swarming { + builders { + name: "Android32 (M Nexus5X)" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Android32 (M Nexus5X)(dbg)" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Android32 (more configs)" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Android32 Builder arm" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 29 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Android32 Builder x86" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Android32 Builder x86 (dbg)" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Android64 (M Nexus5X)" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Android64 Builder arm64" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 29 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Android64 Builder x64 (dbg)" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Linux (more configs)" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Linux Asan" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Linux MSan" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Linux Tsan v2" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Linux UBSan" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Linux UBSan vptr" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Linux32 Debug" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Linux32 Debug (ARM)" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Linux32 Release" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Linux32 Release (ARM)" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Linux64 Builder" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 29 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Linux64 Debug" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Linux64 Debug (ARM)" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Linux64 Release" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Linux64 Release (ARM)" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Linux64 Release (Libfuzzer)" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/libfuzzer"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Mac Asan" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Mac" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Mac64 Builder" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Mac" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Mac64 Debug" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Mac" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Mac64 Release" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Mac" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "MacARM64 M1 Release" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:arm64-64-Apple_M1" + dimensions: "os:Mac" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Win (more configs)" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Windows" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Win32 Builder (Clang)" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Windows" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Win32 Debug (Clang)" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Windows" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Win32 Release (Clang)" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Windows" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Win64 ASan" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Windows" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Win64 Debug (Clang)" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Windows" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "Win64 Release (Clang)" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Windows" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "iOS API Framework Builder" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Mac-11" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/ios_api_framework",' + ' "xcode_build_version": "13a233"' + '}' + priority: 29 + execution_timeout_secs: 7200 + caches { + name: "xcode_ios_13a233" + path: "xcode_ios_13a233.app" + } + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "iOS64 Debug" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Mac-10.15" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone",' + ' "xcode_build_version": "12a7209"' + '}' + priority: 30 + execution_timeout_secs: 7200 + caches { + name: "xcode_ios_12a7209" + path: "xcode_ios_12a7209.app" + } + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "iOS64 Release" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Mac-10.15" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone",' + ' "xcode_build_version": "12a7209"' + '}' + priority: 30 + execution_timeout_secs: 7200 + caches { + name: "xcode_ios_12a7209" + path: "xcode_ios_12a7209.app" + } + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "iOS64 Sim Debug (iOS 12)" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Mac-10.15" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone",' + ' "xcode_build_version": "12a7209"' + '}' + priority: 30 + execution_timeout_secs: 7200 + caches { + name: "xcode_ios_12a7209" + path: "xcode_ios_12a7209.app" + } + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "iOS64 Sim Debug (iOS 13)" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Mac-10.15" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone",' + ' "xcode_build_version": "12a7209"' + '}' + priority: 30 + execution_timeout_secs: 7200 + caches { + name: "xcode_ios_12a7209" + path: "xcode_ios_12a7209.app" + } + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + builders { + name: "iOS64 Sim Debug (iOS 14.0)" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Mac-10.15" + dimensions: "pool:luci.webrtc.ci" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc",' + ' "recipe": "webrtc/standalone",' + ' "xcode_build_version": "12a7209"' + '}' + priority: 30 + execution_timeout_secs: 7200 + caches { + name: "xcode_ios_12a7209" + path: "xcode_ios_12a7209.app" + } + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "ci_test_results" + test_results {} + } + } + } + } +} +buckets { + name: "cron" + acls { + group: "all" + } + swarming { + builders { + name: "Auto-roll - WebRTC DEPS" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.cron" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "recipe": "webrtc/auto_roll_webrtc_deps"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "chromium-webrtc-autoroll@webrtc-ci.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "cron_test_results" + test_results {} + } + } + } + builders { + name: "WebRTC lkgr finder" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.cron" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "config": {' + ' "allowed_gap": 4,' + ' "allowed_lag": 150,' + ' "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) (M Nexus5X)",' + ' "WebRTC Chromium FYI Android Tests (dbg) (N Nexus5X)",' + ' "WebRTC Chromium FYI Linux Builder (dbg)",' + ' "WebRTC Chromium FYI Linux Builder",' + ' "WebRTC Chromium FYI Linux Tester",' + ' "WebRTC Chromium FYI Mac Builder (dbg)",' + ' "WebRTC Chromium FYI Mac Builder",' + ' "WebRTC Chromium FYI Mac Tester",' + ' "WebRTC Chromium FYI Win Builder (dbg)",' + ' "WebRTC Chromium FYI Win Builder",' + ' "WebRTC Chromium FYI Win10 Tester",' + ' "WebRTC Chromium FYI Win7 Tester",' + ' "WebRTC Chromium FYI ios-device",' + ' "WebRTC Chromium FYI ios-simulator"' + ' ]' + ' },' + ' "webrtc/ci": {' + ' "builders": [' + ' "Android32 (M Nexus5X)",' + ' "Android32 (M Nexus5X)(dbg)",' + ' "Android32 (more configs)",' + ' "Android32 Builder arm",' + ' "Android32 Builder x86",' + ' "Android32 Builder x86 (dbg)",' + ' "Android64 (M Nexus5X)",' + ' "Android64 Builder arm64",' + ' "Android64 Builder x64 (dbg)",' + ' "Linux (more configs)",' + ' "Linux Asan",' + ' "Linux MSan",' + ' "Linux Tsan v2",' + ' "Linux UBSan",' + ' "Linux UBSan vptr",' + ' "Linux32 Debug",' + ' "Linux32 Debug (ARM)",' + ' "Linux32 Release",' + ' "Linux32 Release (ARM)",' + ' "Linux64 Builder",' + ' "Linux64 Debug",' + ' "Linux64 Debug (ARM)",' + ' "Linux64 Release",' + ' "Linux64 Release (ARM)",' + ' "Linux64 Release (Libfuzzer)",' + ' "Mac Asan",' + ' "Mac64 Debug",' + ' "Mac64 Release",' + ' "MacARM64 M1 Release",' + ' "Win (more configs)",' + ' "Win32 Debug (Clang)",' + ' "Win32 Release (Clang)",' + ' "Win64 ASan",' + ' "Win64 Debug (Clang)",' + ' "Win64 Release (Clang)",' + ' "iOS API Framework Builder",' + ' "iOS64 Debug",' + ' "iOS64 Release",' + ' "iOS64 Sim Debug (iOS 12)",' + ' "iOS64 Sim Debug (iOS 13)",' + ' "iOS64 Sim Debug (iOS 14.0)"' + ' ]' + ' }' + ' },' + ' "error_recipients": "webrtc-troopers-robots@google.com",' + ' "project": "webrtc",' + ' "source_url": "https://webrtc.googlesource.com/src",' + ' "status_url": "https://webrtc-status.appspot.com"' + ' },' + ' "lkgr_status_gs_path": "chromium-webrtc/lkgr-status",' + ' "project": "webrtc",' + ' "recipe": "lkgr_finder",' + ' "ref": "refs/heads/lkgr",' + ' "repo": "https://webrtc.googlesource.com/src",' + ' "src_ref": "refs/heads/main"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "chromium-webrtc-autoroll@webrtc-ci.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "cron_test_results" + test_results {} + } + } + } + builders { + name: "WebRTC version update" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.cron" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "recipe": "webrtc/update_webrtc_binary_version"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "cron_test_results" + test_results {} + } + } + } + } +} +buckets { + name: "perf" + acls { + group: "all" + } + acls { + role: SCHEDULER + identity: "user:webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + swarming { + builders { + name: "Perf Android32 (M AOSP Nexus6)" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.perf" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc.perf",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 10800 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "perf_test_results" + test_results {} + } + } + } + builders { + name: "Perf Android32 (M Nexus5)" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.perf" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc.perf",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 10800 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "perf_test_results" + test_results {} + } + } + } + builders { + name: "Perf Android64 (M Nexus5X)" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.perf" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc.perf",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 10800 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "perf_test_results" + test_results {} + } + } + } + builders { + name: "Perf Android64 (O Pixel2)" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.perf" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc.perf",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 10800 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "perf_test_results" + test_results {} + } + } + } + builders { + name: "Perf Linux Bionic" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.perf" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc.perf",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 10800 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "perf_test_results" + test_results {} + } + } + } + builders { + name: "Perf Linux Trusty" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.perf" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc.perf",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 10800 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "perf_test_results" + test_results {} + } + } + } + builders { + name: "Perf Mac 10.11" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.perf" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc.perf",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 10800 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "perf_test_results" + test_results {} + } + } + } + builders { + name: "Perf Win7" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.perf" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "client.webrtc.perf",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 10800 + build_numbers: YES + service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "perf_test_results" + test_results {} + } + } + } + } +} +buckets { + name: "try" + acls { + group: "all" + } + acls { + role: SCHEDULER + group: "project-webrtc-tryjob-access" + } + acls { + role: SCHEDULER + group: "service-account-cq" + } + swarming { + builders { + name: "android_arm64_dbg" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "android_arm64_rel" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "android_arm_dbg" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "android_arm_more_configs" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "android_arm_rel" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "android_chromium_compile" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "chromium_trybot"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "android_compile_arm64_dbg" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "android_compile_arm64_rel" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "android_compile_arm_dbg" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "android_compile_arm_rel" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "android_compile_x64_dbg" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "android_compile_x64_rel" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "android_compile_x86_dbg" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "android_compile_x86_rel" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "ios_api_framework" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Mac-11" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/ios_api_framework",' + ' "xcode_build_version": "13a233"' + '}' + priority: 30 + execution_timeout_secs: 7200 + caches { + name: "xcode_ios_13a233" + path: "xcode_ios_13a233.app" + } + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "ios_compile_arm64_dbg" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Mac-10.15" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone",' + ' "xcode_build_version": "12a7209"' + '}' + priority: 30 + execution_timeout_secs: 7200 + caches { + name: "xcode_ios_12a7209" + path: "xcode_ios_12a7209.app" + } + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "ios_compile_arm64_rel" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Mac-10.15" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone",' + ' "xcode_build_version": "12a7209"' + '}' + priority: 30 + execution_timeout_secs: 7200 + caches { + name: "xcode_ios_12a7209" + path: "xcode_ios_12a7209.app" + } + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "ios_sim_x64_dbg_ios12" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Mac-10.15" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone",' + ' "xcode_build_version": "12a7209"' + '}' + priority: 30 + execution_timeout_secs: 7200 + caches { + name: "xcode_ios_12a7209" + path: "xcode_ios_12a7209.app" + } + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "ios_sim_x64_dbg_ios13" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Mac-10.15" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone",' + ' "xcode_build_version": "12a7209"' + '}' + priority: 30 + execution_timeout_secs: 7200 + caches { + name: "xcode_ios_12a7209" + path: "xcode_ios_12a7209.app" + } + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "ios_sim_x64_dbg_ios14" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Mac-10.15" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone",' + ' "xcode_build_version": "12a7209"' + '}' + priority: 30 + execution_timeout_secs: 7200 + caches { + name: "xcode_ios_12a7209" + path: "xcode_ios_12a7209.app" + } + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "linux_asan" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "linux_chromium_compile" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "chromium_trybot"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "linux_chromium_compile_dbg" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "chromium_trybot"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "linux_compile_arm64_dbg" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "linux_compile_arm64_rel" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "linux_compile_arm_dbg" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "linux_compile_arm_rel" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "linux_compile_dbg" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "linux_compile_rel" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "linux_dbg" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "linux_libfuzzer_rel" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/libfuzzer"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "linux_more_configs" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "linux_msan" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "linux_rel" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "linux_tsan2" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "linux_ubsan" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "linux_ubsan_vptr" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "linux_x86_dbg" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "linux_x86_rel" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "mac_asan" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Mac" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "mac_chromium_compile" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Mac" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "chromium_trybot"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "mac_compile_dbg" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Mac" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "mac_compile_rel" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Mac" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "mac_dbg" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Mac" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "mac_dbg_m1" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Mac" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "mac_rel" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Mac" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "mac_rel_m1" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Mac" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "presubmit" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "inside_docker:0" + dimensions: "os:Linux" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "run_presubmit",' + ' "repo_name": "webrtc",' + ' "runhooks": true' + '}' + priority: 28 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "win_asan" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Windows" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "enable_ats": false,' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "win_chromium_compile" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Windows" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "enable_ats": false,' + ' "jobs": 150,' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "chromium_trybot"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "win_chromium_compile_dbg" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Windows" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "enable_ats": false,' + ' "jobs": 150,' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "chromium_trybot"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "win_compile_x64_clang_dbg" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Windows" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "enable_ats": false,' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "win_compile_x64_clang_rel" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Windows" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "enable_ats": false,' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "win_compile_x86_clang_dbg" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Windows" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "enable_ats": false,' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "win_compile_x86_clang_rel" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Windows" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "enable_ats": false,' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "win_x64_clang_dbg" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Windows" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "enable_ats": false,' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "win_x64_clang_dbg_win10" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Windows" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "enable_ats": false,' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "win_x64_clang_rel" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Windows" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "enable_ats": false,' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "win_x86_clang_dbg" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Windows" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "enable_ats": false,' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "win_x86_clang_rel" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Windows" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "enable_ats": false,' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + builders { + name: "win_x86_more_configs" + swarming_host: "chromium-swarm.appspot.com" + swarming_tags: "vpython:native-python-wrapper" + dimensions: "cpu:x86-64" + dimensions: "os:Windows" + dimensions: "pool:luci.webrtc.try" + exe { + cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" + cipd_version: "refs/heads/main" + cmd: "luciexe" + } + properties: + '{' + ' "$build/goma": {' + ' "enable_ats": false,' + ' "server_host": "goma.chromium.org",' + ' "use_luci_auth": true' + ' },' + ' "$recipe_engine/isolated": {' + ' "server": "https://isolateserver.appspot.com"' + ' },' + ' "$recipe_engine/resultdb/test_presentation": {' + ' "column_keys": [],' + ' "grouping_keys": [' + ' "status",' + ' "v.test_suite"' + ' ]' + ' },' + ' "builder_group": "tryserver.webrtc",' + ' "recipe": "webrtc/standalone"' + '}' + priority: 30 + execution_timeout_secs: 7200 + build_numbers: YES + service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + experiments { + key: "luci.recipes.use_python3" + value: 100 + } + resultdb { + enable: true + bq_exports { + project: "webrtc-ci" + dataset: "resultdb" + table: "try_test_results" + test_results {} + } + } + } + } +} diff --git a/infra/config/luci-logdog.cfg b/infra/config/luci-logdog.cfg new file mode 100644 index 0000000000..adc75bef49 --- /dev/null +++ b/infra/config/luci-logdog.cfg @@ -0,0 +1,9 @@ +# Auto-generated by lucicfg. +# Do not modify manually. +# +# For the schema of this file, see ProjectConfig message: +# https://luci-config.appspot.com/schemas/projects:luci-logdog.cfg + +reader_auth_groups: "all" +writer_auth_groups: "luci-logdog-chromium-writers" +archive_gs_bucket: "chromium-luci-logdog" diff --git a/infra/config/luci-milo.cfg b/infra/config/luci-milo.cfg new file mode 100644 index 0000000000..c598665644 --- /dev/null +++ b/infra/config/luci-milo.cfg @@ -0,0 +1,606 @@ +# Auto-generated by lucicfg. +# Do not modify manually. +# +# For the schema of this file, see Project message: +# https://luci-config.appspot.com/schemas/projects:luci-milo.cfg + +consoles { + id: "ci" + name: "Main" + repo_url: "https://webrtc.googlesource.com/src" + refs: "regexp:refs/heads/master" + refs: "regexp:refs/heads/main" + manifest_name: "REVISION" + builders { + name: "buildbucket/luci.webrtc.ci/Android32 (M Nexus5X)(dbg)" + category: "Android|arm" + short_name: "dbg" + } + builders { + name: "buildbucket/luci.webrtc.ci/Android32 (M Nexus5X)" + category: "Android|arm" + short_name: "rel" + } + builders { + name: "buildbucket/luci.webrtc.ci/Android32 Builder arm" + category: "Android|arm" + short_name: "size" + } + builders { + name: "buildbucket/luci.webrtc.ci/Android64 (M Nexus5X)" + category: "Android|arm64" + short_name: "rel" + } + builders { + name: "buildbucket/luci.webrtc.ci/Android64 Builder arm64" + category: "Android|arm64" + short_name: "size" + } + builders { + name: "buildbucket/luci.webrtc.ci/Android64 Builder x64 (dbg)" + category: "Android|x64" + short_name: "dbg" + } + builders { + name: "buildbucket/luci.webrtc.ci/Android32 Builder x86 (dbg)" + category: "Android|x86" + short_name: "dbg" + } + builders { + name: "buildbucket/luci.webrtc.ci/Android32 Builder x86" + category: "Android|x86" + short_name: "rel" + } + builders { + name: "buildbucket/luci.webrtc.ci/Android32 (more configs)" + category: "Android|arm" + short_name: "more" + } + builders { + name: "buildbucket/luci.webrtc.ci/iOS64 Debug" + category: "iOS|arm64" + short_name: "dbg" + } + builders { + name: "buildbucket/luci.webrtc.ci/iOS64 Release" + category: "iOS|arm64" + short_name: "rel" + } + builders { + name: "buildbucket/luci.webrtc.ci/iOS64 Sim Debug (iOS 14.0)" + category: "iOS|x64" + short_name: "14" + } + builders { + name: "buildbucket/luci.webrtc.ci/iOS64 Sim Debug (iOS 13)" + category: "iOS|x64" + short_name: "13" + } + builders { + name: "buildbucket/luci.webrtc.ci/iOS64 Sim Debug (iOS 12)" + category: "iOS|x64" + short_name: "12" + } + builders { + name: "buildbucket/luci.webrtc.ci/iOS API Framework Builder" + category: "iOS|fat" + short_name: "size" + } + builders { + name: "buildbucket/luci.webrtc.ci/Linux32 Debug" + category: "Linux|x86" + short_name: "dbg" + } + builders { + name: "buildbucket/luci.webrtc.ci/Linux32 Release" + category: "Linux|x86" + short_name: "rel" + } + builders { + name: "buildbucket/luci.webrtc.ci/Linux64 Debug" + category: "Linux|x64" + short_name: "dbg" + } + builders { + name: "buildbucket/luci.webrtc.ci/Linux64 Release" + category: "Linux|x64" + short_name: "rel" + } + builders { + name: "buildbucket/luci.webrtc.ci/Linux64 Builder" + category: "Linux|x64" + short_name: "size" + } + builders { + name: "buildbucket/luci.webrtc.ci/Linux32 Debug (ARM)" + category: "Linux|arm" + short_name: "dbg" + } + builders { + name: "buildbucket/luci.webrtc.ci/Linux32 Release (ARM)" + category: "Linux|arm" + short_name: "rel" + } + builders { + name: "buildbucket/luci.webrtc.ci/Linux64 Debug (ARM)" + category: "Linux|arm64" + short_name: "dbg" + } + builders { + name: "buildbucket/luci.webrtc.ci/Linux64 Release (ARM)" + category: "Linux|arm64" + short_name: "rel" + } + builders { + name: "buildbucket/luci.webrtc.ci/Linux Asan" + category: "Linux|x64" + short_name: "asan" + } + builders { + name: "buildbucket/luci.webrtc.ci/Linux MSan" + category: "Linux|x64" + short_name: "msan" + } + builders { + name: "buildbucket/luci.webrtc.ci/Linux Tsan v2" + category: "Linux|x64" + short_name: "tsan" + } + builders { + name: "buildbucket/luci.webrtc.ci/Linux UBSan" + category: "Linux|x64" + short_name: "ubsan" + } + builders { + name: "buildbucket/luci.webrtc.ci/Linux UBSan vptr" + category: "Linux|x64" + short_name: "ubsan" + } + builders { + name: "buildbucket/luci.webrtc.ci/Linux64 Release (Libfuzzer)" + category: "Linux|x64" + short_name: "fuzz" + } + builders { + name: "buildbucket/luci.webrtc.ci/Linux (more configs)" + category: "Linux|x64" + short_name: "more" + } + builders { + name: "buildbucket/luci.webrtc.ci/Mac64 Debug" + category: "Mac|x64" + short_name: "dbg" + } + builders { + name: "buildbucket/luci.webrtc.ci/Mac64 Release" + category: "Mac|x64" + short_name: "rel" + } + builders { + name: "buildbucket/luci.webrtc.ci/Mac Asan" + category: "Mac|x64" + short_name: "asan" + } + builders { + name: "buildbucket/luci.webrtc.ci/MacARM64 M1 Release" + category: "Mac|arm64M1" + short_name: "rel" + } + builders { + name: "buildbucket/luci.webrtc.ci/Win32 Debug (Clang)" + category: "Win Clang|x86" + short_name: "dbg" + } + builders { + name: "buildbucket/luci.webrtc.ci/Win32 Release (Clang)" + category: "Win Clang|x86" + short_name: "rel" + } + builders { + name: "buildbucket/luci.webrtc.ci/Win64 Debug (Clang)" + category: "Win Clang|x64" + short_name: "dbg" + } + builders { + name: "buildbucket/luci.webrtc.ci/Win64 Release (Clang)" + category: "Win Clang|x64" + short_name: "rel" + } + builders { + name: "buildbucket/luci.webrtc.ci/Win64 ASan" + category: "Win Clang|x64" + short_name: "asan" + } + builders { + name: "buildbucket/luci.webrtc.ci/Win (more configs)" + category: "Win Clang|x86" + short_name: "more" + } + header { + links { + name: "Consoles" + links { + text: "WebRTC" + url: "/p/webrtc/g/ci" + alt: "WebRTC Main CI Console" + } + links { + text: "WebRTC Cron" + url: "/p/webrtc/g/cron" + alt: "WebRTC Cron Console" + } + links { + text: "WebRTC Perf" + url: "/p/webrtc/g/perf" + alt: "WebRTC Perf Console" + } + links { + text: "Chromium" + url: "/p/chromium/g/chromium.webrtc" + alt: "Chromium WebRTC Console" + } + links { + text: "Chromium FYI" + url: "/p/chromium/g/chromium.webrtc.fyi" + alt: "Chromium WebRTC FYI Console" + } + links { + text: "Try WebRTC" + url: "/p/webrtc/g/try" + alt: "WebRTC Try Builders" + } + } + links { + name: "Links" + links { + text: "Source" + url: "https://webrtc.googlesource.com/src/+/main/" + } + links { + text: "Reviews" + url: "https://webrtc-review.googlesource.com/" + } + links { + text: "Bugs" + url: "https://bugs.webrtc.org/" + } + links { + text: "LKGR status" + url: "https://storage.cloud.google.com/chromium-webrtc/lkgr-status/webrtc-lkgr-status.html" + } + } + console_groups { + console_ids: "webrtc/ci" + console_ids: "webrtc/perf" + console_ids: "chromium/chromium.webrtc" + console_ids: "chromium/chromium.webrtc.fyi" + } + tree_status_host: "webrtc-status.appspot.com" + } +} +consoles { + id: "perf" + name: "Perf" + repo_url: "https://webrtc.googlesource.com/src" + refs: "regexp:refs/heads/master" + refs: "regexp:refs/heads/main" + manifest_name: "REVISION" + builders { + name: "buildbucket/luci.webrtc.ci/Android32 Builder arm" + category: "Android|arm|Builder" + } + builders { + name: "buildbucket/luci.webrtc.perf/Perf Android32 (M Nexus5)" + category: "Android|arm|Tester" + short_name: "M Nexus5" + } + builders { + name: "buildbucket/luci.webrtc.perf/Perf Android32 (M AOSP Nexus6)" + category: "Android|arm|Tester" + short_name: "M AOSP Nexus6" + } + builders { + name: "buildbucket/luci.webrtc.ci/Android64 Builder arm64" + category: "Android|arm64|Builder" + } + builders { + name: "buildbucket/luci.webrtc.perf/Perf Android64 (M Nexus5X)" + category: "Android|arm64|Tester" + short_name: "M Nexus5X" + } + builders { + name: "buildbucket/luci.webrtc.perf/Perf Android64 (O Pixel2)" + category: "Android|arm64|Tester" + short_name: "O Pixel2" + } + builders { + name: "buildbucket/luci.webrtc.ci/Linux64 Builder" + category: "Linux|x64|Builder" + } + builders { + name: "buildbucket/luci.webrtc.perf/Perf Linux Trusty" + category: "Linux|x64|Tester" + short_name: "Trusty" + } + builders { + name: "buildbucket/luci.webrtc.perf/Perf Linux Bionic" + category: "Linux|x64|Tester" + short_name: "Bionic" + } + builders { + name: "buildbucket/luci.webrtc.ci/Mac64 Builder" + category: "Mac|x64|Builder" + } + builders { + name: "buildbucket/luci.webrtc.perf/Perf Mac 10.11" + category: "Mac|x64|Tester" + short_name: "10.11" + } + builders { + name: "buildbucket/luci.webrtc.ci/Win32 Builder (Clang)" + category: "Win|x86|Builder" + } + builders { + name: "buildbucket/luci.webrtc.perf/Perf Win7" + category: "Win|x86|Tester" + short_name: "7" + } + header { + links { + name: "Consoles" + links { + text: "WebRTC" + url: "/p/webrtc/g/ci" + alt: "WebRTC Main CI Console" + } + links { + text: "WebRTC Cron" + url: "/p/webrtc/g/cron" + alt: "WebRTC Cron Console" + } + links { + text: "WebRTC Perf" + url: "/p/webrtc/g/perf" + alt: "WebRTC Perf Console" + } + links { + text: "Chromium" + url: "/p/chromium/g/chromium.webrtc" + alt: "Chromium WebRTC Console" + } + links { + text: "Chromium FYI" + url: "/p/chromium/g/chromium.webrtc.fyi" + alt: "Chromium WebRTC FYI Console" + } + links { + text: "Try WebRTC" + url: "/p/webrtc/g/try" + alt: "WebRTC Try Builders" + } + } + links { + name: "Links" + links { + text: "Source" + url: "https://webrtc.googlesource.com/src/+/main/" + } + links { + text: "Reviews" + url: "https://webrtc-review.googlesource.com/" + } + links { + text: "Bugs" + url: "https://bugs.webrtc.org/" + } + links { + text: "LKGR status" + url: "https://storage.cloud.google.com/chromium-webrtc/lkgr-status/webrtc-lkgr-status.html" + } + } + console_groups { + console_ids: "webrtc/ci" + console_ids: "webrtc/perf" + console_ids: "chromium/chromium.webrtc" + console_ids: "chromium/chromium.webrtc.fyi" + } + tree_status_host: "webrtc-status.appspot.com" + } +} +consoles { + id: "cron" + name: "Cron" + builders { + name: "buildbucket/luci.webrtc.cron/Auto-roll - WebRTC DEPS" + } + builders { + name: "buildbucket/luci.webrtc.cron/WebRTC version update" + } + builders { + name: "buildbucket/luci.webrtc.cron/WebRTC lkgr finder" + } + builder_view_only: true +} +consoles { + id: "try" + name: "Tryserver" + builders { + name: "buildbucket/luci.webrtc.try/android_compile_arm_dbg" + } + builders { + name: "buildbucket/luci.webrtc.try/android_arm_dbg" + } + builders { + name: "buildbucket/luci.webrtc.try/android_arm_rel" + } + builders { + name: "buildbucket/luci.webrtc.try/android_compile_arm_rel" + } + builders { + name: "buildbucket/luci.webrtc.try/android_compile_arm64_dbg" + } + builders { + name: "buildbucket/luci.webrtc.try/android_arm64_dbg" + } + builders { + name: "buildbucket/luci.webrtc.try/android_arm64_rel" + } + builders { + name: "buildbucket/luci.webrtc.try/android_compile_arm64_rel" + } + builders { + name: "buildbucket/luci.webrtc.try/android_compile_x64_dbg" + } + builders { + name: "buildbucket/luci.webrtc.try/android_compile_x64_rel" + } + builders { + name: "buildbucket/luci.webrtc.try/android_compile_x86_dbg" + } + builders { + name: "buildbucket/luci.webrtc.try/android_compile_x86_rel" + } + builders { + name: "buildbucket/luci.webrtc.try/android_arm_more_configs" + } + builders { + name: "buildbucket/luci.webrtc.try/android_chromium_compile" + } + builders { + name: "buildbucket/luci.webrtc.try/ios_compile_arm64_dbg" + } + builders { + name: "buildbucket/luci.webrtc.try/ios_compile_arm64_rel" + } + builders { + name: "buildbucket/luci.webrtc.try/ios_sim_x64_dbg_ios14" + } + builders { + name: "buildbucket/luci.webrtc.try/ios_sim_x64_dbg_ios13" + } + builders { + name: "buildbucket/luci.webrtc.try/ios_sim_x64_dbg_ios12" + } + builders { + name: "buildbucket/luci.webrtc.try/ios_api_framework" + } + builders { + name: "buildbucket/luci.webrtc.try/linux_x86_dbg" + } + builders { + name: "buildbucket/luci.webrtc.try/linux_x86_rel" + } + builders { + name: "buildbucket/luci.webrtc.try/linux_dbg" + } + builders { + name: "buildbucket/luci.webrtc.try/linux_compile_dbg" + } + builders { + name: "buildbucket/luci.webrtc.try/linux_rel" + } + builders { + name: "buildbucket/luci.webrtc.try/linux_compile_rel" + } + builders { + name: "buildbucket/luci.webrtc.try/linux_compile_arm_dbg" + } + builders { + name: "buildbucket/luci.webrtc.try/linux_compile_arm_rel" + } + builders { + name: "buildbucket/luci.webrtc.try/linux_compile_arm64_dbg" + } + builders { + name: "buildbucket/luci.webrtc.try/linux_compile_arm64_rel" + } + builders { + name: "buildbucket/luci.webrtc.try/linux_asan" + } + builders { + name: "buildbucket/luci.webrtc.try/linux_msan" + } + builders { + name: "buildbucket/luci.webrtc.try/linux_tsan2" + } + builders { + name: "buildbucket/luci.webrtc.try/linux_ubsan" + } + builders { + name: "buildbucket/luci.webrtc.try/linux_ubsan_vptr" + } + builders { + name: "buildbucket/luci.webrtc.try/linux_libfuzzer_rel" + } + builders { + name: "buildbucket/luci.webrtc.try/linux_more_configs" + } + builders { + name: "buildbucket/luci.webrtc.try/linux_chromium_compile" + } + builders { + name: "buildbucket/luci.webrtc.try/linux_chromium_compile_dbg" + } + builders { + name: "buildbucket/luci.webrtc.try/mac_dbg" + } + builders { + name: "buildbucket/luci.webrtc.try/mac_compile_dbg" + } + builders { + name: "buildbucket/luci.webrtc.try/mac_rel" + } + builders { + name: "buildbucket/luci.webrtc.try/mac_compile_rel" + } + builders { + name: "buildbucket/luci.webrtc.try/mac_asan" + } + builders { + name: "buildbucket/luci.webrtc.try/mac_chromium_compile" + } + builders { + name: "buildbucket/luci.webrtc.try/win_x86_clang_dbg" + } + builders { + name: "buildbucket/luci.webrtc.try/win_compile_x86_clang_dbg" + } + builders { + name: "buildbucket/luci.webrtc.try/win_x86_clang_rel" + } + builders { + name: "buildbucket/luci.webrtc.try/win_compile_x86_clang_rel" + } + builders { + name: "buildbucket/luci.webrtc.try/win_x64_clang_dbg" + } + builders { + name: "buildbucket/luci.webrtc.try/win_x64_clang_dbg_win10" + } + builders { + name: "buildbucket/luci.webrtc.try/win_compile_x64_clang_dbg" + } + builders { + name: "buildbucket/luci.webrtc.try/win_x64_clang_rel" + } + builders { + name: "buildbucket/luci.webrtc.try/win_compile_x64_clang_rel" + } + builders { + name: "buildbucket/luci.webrtc.try/win_asan" + } + builders { + name: "buildbucket/luci.webrtc.try/win_x86_more_configs" + } + builders { + name: "buildbucket/luci.webrtc.try/win_chromium_compile" + } + builders { + name: "buildbucket/luci.webrtc.try/win_chromium_compile_dbg" + } + builders { + name: "buildbucket/luci.webrtc.try/presubmit" + } + builder_view_only: true +} +logo_url: "https://storage.googleapis.com/chrome-infra/webrtc-logo-vert-retro-255x305.png" diff --git a/infra/config/luci-notify.cfg b/infra/config/luci-notify.cfg new file mode 100644 index 0000000000..4d20b9fd3a --- /dev/null +++ b/infra/config/luci-notify.cfg @@ -0,0 +1,2179 @@ +# Auto-generated by lucicfg. +# Do not modify manually. +# +# For the schema of this file, see ProjectConfig message: +# https://luci-config.appspot.com/schemas/projects:luci-notify.cfg + +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Android32 (M Nexus5X)" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Android32 (M Nexus5X)(dbg)" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Android32 (more configs)" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Android32 Builder arm" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Android32 Builder x86" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Android32 Builder x86 (dbg)" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Android64 (M Nexus5X)" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Android64 Builder arm64" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Android64 Builder x64 (dbg)" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Linux (more configs)" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Linux Asan" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Linux MSan" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Linux Tsan v2" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Linux UBSan" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Linux UBSan vptr" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Linux32 Debug" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Linux32 Debug (ARM)" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Linux32 Release" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Linux32 Release (ARM)" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Linux64 Builder" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Linux64 Debug" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Linux64 Debug (ARM)" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Linux64 Release" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Linux64 Release (ARM)" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Linux64 Release (Libfuzzer)" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Mac Asan" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Mac64 Builder" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Mac64 Debug" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Mac64 Release" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "MacARM64 M1 Release" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Win (more configs)" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Win32 Builder (Clang)" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Win32 Debug (Clang)" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Win32 Release (Clang)" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Win64 ASan" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Win64 Debug (Clang)" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "Win64 Release (Clang)" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "iOS API Framework Builder" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "iOS64 Debug" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "iOS64 Release" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "iOS64 Sim Debug (iOS 12)" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "iOS64 Sim Debug (iOS 13)" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "ci" + name: "iOS64 Sim Debug (iOS 14.0)" + repository: "https://webrtc.googlesource.com/src" + } + tree_closers { + tree_status_host: "webrtc-status.appspot.com" + failed_step_regexp: "bot_update|compile|gclient runhooks|runhooks|update|extract build|cleanup_temp|taskkill|compile|gn" + failed_step_regexp_exclude: ".*\\(experimental\\).*" + } +} +notifiers { + notifications { + on_new_status: FAILURE + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "cron" + } + builders { + bucket: "cron" + name: "Auto-roll - WebRTC DEPS" + } +} +notifiers { + notifications { + on_new_status: FAILURE + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "cron" + } + builders { + bucket: "cron" + name: "WebRTC lkgr finder" + } +} +notifiers { + notifications { + on_new_status: FAILURE + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "cron" + } + builders { + bucket: "cron" + name: "WebRTC version update" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "perf" + name: "Perf Android32 (M AOSP Nexus6)" + repository: "https://webrtc.googlesource.com/src" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "perf" + name: "Perf Android32 (M Nexus5)" + repository: "https://webrtc.googlesource.com/src" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "perf" + name: "Perf Android64 (M Nexus5X)" + repository: "https://webrtc.googlesource.com/src" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "perf" + name: "Perf Android64 (O Pixel2)" + repository: "https://webrtc.googlesource.com/src" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "perf" + name: "Perf Linux Bionic" + repository: "https://webrtc.googlesource.com/src" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "perf" + name: "Perf Linux Trusty" + repository: "https://webrtc.googlesource.com/src" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "perf" + name: "Perf Mac 10.11" + repository: "https://webrtc.googlesource.com/src" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + notifications { + on_new_status: FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "build_failure" + notify_blamelist {} + } + builders { + bucket: "perf" + name: "Perf Win7" + repository: "https://webrtc.googlesource.com/src" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "android_arm64_dbg" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "android_arm64_rel" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "android_arm_dbg" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "android_arm_more_configs" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "android_arm_rel" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "android_chromium_compile" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "android_compile_arm64_dbg" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "android_compile_arm64_rel" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "android_compile_arm_dbg" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "android_compile_arm_rel" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "android_compile_x64_dbg" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "android_compile_x64_rel" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "android_compile_x86_dbg" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "android_compile_x86_rel" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "ios_api_framework" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "ios_compile_arm64_dbg" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "ios_compile_arm64_rel" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "ios_sim_x64_dbg_ios12" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "ios_sim_x64_dbg_ios13" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "ios_sim_x64_dbg_ios14" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "linux_asan" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "linux_chromium_compile" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "linux_chromium_compile_dbg" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "linux_compile_arm64_dbg" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "linux_compile_arm64_rel" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "linux_compile_arm_dbg" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "linux_compile_arm_rel" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "linux_compile_dbg" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "linux_compile_rel" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "linux_dbg" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "linux_libfuzzer_rel" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "linux_more_configs" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "linux_msan" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "linux_rel" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "linux_tsan2" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "linux_ubsan" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "linux_ubsan_vptr" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "linux_x86_dbg" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "linux_x86_rel" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "mac_asan" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "mac_chromium_compile" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "mac_compile_dbg" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "mac_compile_rel" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "mac_dbg" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "mac_dbg_m1" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "mac_rel" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "mac_rel_m1" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "presubmit" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "win_asan" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "win_chromium_compile" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "win_chromium_compile_dbg" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "win_compile_x64_clang_dbg" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "win_compile_x64_clang_rel" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "win_compile_x86_clang_dbg" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "win_compile_x86_clang_rel" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "win_x64_clang_dbg" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "win_x64_clang_dbg_win10" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "win_x64_clang_rel" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "win_x86_clang_dbg" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "win_x86_clang_rel" + } +} +notifiers { + notifications { + on_new_status: INFRA_FAILURE + email { + recipients: "webrtc-troopers-robots@google.com" + } + template: "infra_failure" + } + builders { + bucket: "try" + name: "win_x86_more_configs" + } +} +tree_closing_enabled: true diff --git a/infra/config/luci-notify/email-templates/build_failure.template b/infra/config/luci-notify/email-templates/build_failure.template new file mode 100644 index 0000000000..dc321cbc1f --- /dev/null +++ b/infra/config/luci-notify/email-templates/build_failure.template @@ -0,0 +1,24 @@ +Test failure in WebRTC on {{ .Build.Builder.Builder }} + +

There was a failure on builder "{{ .Build.Builder.Builder }}".

+ +

Full details are available here.

+ + + + + + + + + + + + + + + + + + +
New status:{{ .Build.Status }}
Previous status:{{ .OldStatus }}
Created at:{{ .Build.CreateTime | time }}
Finished at:{{ .Build.EndTime | time }}
diff --git a/infra/config/luci-notify/email-templates/cron.template b/infra/config/luci-notify/email-templates/cron.template new file mode 100644 index 0000000000..580b7414ad --- /dev/null +++ b/infra/config/luci-notify/email-templates/cron.template @@ -0,0 +1,33 @@ +{{ .Build.Builder.Builder }} failed to run + +

There was a failure on builder "{{ .Build.Builder.Builder }}".

+ +

Full details are available here.

+ + + + + + + + + + + + + + + + + + + + + + +
Builder: + + {{ .Build.Builder.Builder }} + + (Console) +
New status:{{ .Build.Status }}
Previous status:{{ .OldStatus }}
Created at:{{ .Build.CreateTime | time }}
Finished at:{{ .Build.EndTime | time }}
diff --git a/infra/config/luci-notify/email-templates/infra_failure.template b/infra/config/luci-notify/email-templates/infra_failure.template new file mode 100644 index 0000000000..5bedf6111a --- /dev/null +++ b/infra/config/luci-notify/email-templates/infra_failure.template @@ -0,0 +1,24 @@ +Infra failure in WebRTC on {{ .Build.Builder.Builder }} + +

There was a failure on builder "{{ .Build.Builder.Builder }}".

+ +

Full details are available here.

+ + + + + + + + + + + + + + + + + + +
New status:{{ .Build.Status }}
Previous status:{{ .OldStatus }}
Created at:{{ .Build.CreateTime | time }}
Finished at:{{ .Build.EndTime | time }}
diff --git a/infra/config/luci-scheduler.cfg b/infra/config/luci-scheduler.cfg new file mode 100644 index 0000000000..019db39aea --- /dev/null +++ b/infra/config/luci-scheduler.cfg @@ -0,0 +1,715 @@ +# Auto-generated by lucicfg. +# Do not modify manually. +# +# For the schema of this file, see ProjectConfig message: +# https://luci-config.appspot.com/schemas/projects:luci-scheduler.cfg + +job { + id: "Android32 (M Nexus5X)" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Android32 (M Nexus5X)" + } +} +job { + id: "Android32 (M Nexus5X)(dbg)" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Android32 (M Nexus5X)(dbg)" + } +} +job { + id: "Android32 (more configs)" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Android32 (more configs)" + } +} +job { + id: "Android32 Builder arm" + realm: "ci" + acl_sets: "ci" + triggering_policy { + kind: GREEDY_BATCHING + max_concurrent_invocations: 3 + max_batch_size: 1 + } + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Android32 Builder arm" + } +} +job { + id: "Android32 Builder x86" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Android32 Builder x86" + } +} +job { + id: "Android32 Builder x86 (dbg)" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Android32 Builder x86 (dbg)" + } +} +job { + id: "Android64 (M Nexus5X)" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Android64 (M Nexus5X)" + } +} +job { + id: "Android64 Builder arm64" + realm: "ci" + acl_sets: "ci" + triggering_policy { + kind: GREEDY_BATCHING + max_concurrent_invocations: 3 + max_batch_size: 1 + } + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Android64 Builder arm64" + } +} +job { + id: "Android64 Builder x64 (dbg)" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Android64 Builder x64 (dbg)" + } +} +job { + id: "Auto-roll - WebRTC DEPS" + realm: "cron" + schedule: "0 */2 * * *" + acl_sets: "cron" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "cron" + builder: "Auto-roll - WebRTC DEPS" + } +} +job { + id: "Linux (more configs)" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Linux (more configs)" + } +} +job { + id: "Linux Asan" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Linux Asan" + } +} +job { + id: "Linux MSan" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Linux MSan" + } +} +job { + id: "Linux Tsan v2" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Linux Tsan v2" + } +} +job { + id: "Linux UBSan" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Linux UBSan" + } +} +job { + id: "Linux UBSan vptr" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Linux UBSan vptr" + } +} +job { + id: "Linux32 Debug" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Linux32 Debug" + } +} +job { + id: "Linux32 Debug (ARM)" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Linux32 Debug (ARM)" + } +} +job { + id: "Linux32 Release" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Linux32 Release" + } +} +job { + id: "Linux32 Release (ARM)" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Linux32 Release (ARM)" + } +} +job { + id: "Linux64 Builder" + realm: "ci" + acl_sets: "ci" + triggering_policy { + kind: GREEDY_BATCHING + max_concurrent_invocations: 3 + max_batch_size: 1 + } + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Linux64 Builder" + } +} +job { + id: "Linux64 Debug" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Linux64 Debug" + } +} +job { + id: "Linux64 Debug (ARM)" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Linux64 Debug (ARM)" + } +} +job { + id: "Linux64 Release" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Linux64 Release" + } +} +job { + id: "Linux64 Release (ARM)" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Linux64 Release (ARM)" + } +} +job { + id: "Linux64 Release (Libfuzzer)" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Linux64 Release (Libfuzzer)" + } +} +job { + id: "Mac Asan" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Mac Asan" + } +} +job { + id: "Mac64 Builder" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Mac64 Builder" + } +} +job { + id: "Mac64 Debug" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Mac64 Debug" + } +} +job { + id: "Mac64 Release" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Mac64 Release" + } +} +job { + id: "MacARM64 M1 Release" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "MacARM64 M1 Release" + } +} +job { + id: "Perf Android32 (M AOSP Nexus6)" + realm: "perf" + acls { + role: TRIGGERER + granted_to: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + acl_sets: "perf" + triggering_policy { + kind: LOGARITHMIC_BATCHING + log_base: 1.7 + } + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "perf" + builder: "Perf Android32 (M AOSP Nexus6)" + } +} +job { + id: "Perf Android32 (M Nexus5)" + realm: "perf" + acls { + role: TRIGGERER + granted_to: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + acl_sets: "perf" + triggering_policy { + kind: LOGARITHMIC_BATCHING + log_base: 1.7 + } + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "perf" + builder: "Perf Android32 (M Nexus5)" + } +} +job { + id: "Perf Android64 (M Nexus5X)" + realm: "perf" + acls { + role: TRIGGERER + granted_to: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + acl_sets: "perf" + triggering_policy { + kind: LOGARITHMIC_BATCHING + log_base: 1.7 + } + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "perf" + builder: "Perf Android64 (M Nexus5X)" + } +} +job { + id: "Perf Android64 (O Pixel2)" + realm: "perf" + acls { + role: TRIGGERER + granted_to: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + acl_sets: "perf" + triggering_policy { + kind: LOGARITHMIC_BATCHING + log_base: 1.7 + } + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "perf" + builder: "Perf Android64 (O Pixel2)" + } +} +job { + id: "Perf Linux Bionic" + realm: "perf" + acls { + role: TRIGGERER + granted_to: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + acl_sets: "perf" + triggering_policy { + kind: LOGARITHMIC_BATCHING + log_base: 1.7 + } + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "perf" + builder: "Perf Linux Bionic" + } +} +job { + id: "Perf Linux Trusty" + realm: "perf" + acls { + role: TRIGGERER + granted_to: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + acl_sets: "perf" + triggering_policy { + kind: LOGARITHMIC_BATCHING + log_base: 1.7 + } + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "perf" + builder: "Perf Linux Trusty" + } +} +job { + id: "Perf Mac 10.11" + realm: "perf" + acls { + role: TRIGGERER + granted_to: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + acl_sets: "perf" + triggering_policy { + kind: LOGARITHMIC_BATCHING + log_base: 1.7 + } + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "perf" + builder: "Perf Mac 10.11" + } +} +job { + id: "Perf Win7" + realm: "perf" + acls { + role: TRIGGERER + granted_to: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + acl_sets: "perf" + triggering_policy { + kind: LOGARITHMIC_BATCHING + log_base: 1.7 + } + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "perf" + builder: "Perf Win7" + } +} +job { + id: "WebRTC lkgr finder" + realm: "cron" + schedule: "*/10 * * * *" + acl_sets: "cron" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "cron" + builder: "WebRTC lkgr finder" + } +} +job { + id: "WebRTC version update" + realm: "cron" + schedule: "0 4 * * *" + acl_sets: "cron" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "cron" + builder: "WebRTC version update" + } +} +job { + id: "Win (more configs)" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Win (more configs)" + } +} +job { + id: "Win32 Builder (Clang)" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Win32 Builder (Clang)" + } +} +job { + id: "Win32 Debug (Clang)" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Win32 Debug (Clang)" + } +} +job { + id: "Win32 Release (Clang)" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Win32 Release (Clang)" + } +} +job { + id: "Win64 ASan" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Win64 ASan" + } +} +job { + id: "Win64 Debug (Clang)" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Win64 Debug (Clang)" + } +} +job { + id: "Win64 Release (Clang)" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "Win64 Release (Clang)" + } +} +job { + id: "iOS API Framework Builder" + realm: "ci" + acl_sets: "ci" + triggering_policy { + kind: GREEDY_BATCHING + max_concurrent_invocations: 3 + max_batch_size: 1 + } + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "iOS API Framework Builder" + } +} +job { + id: "iOS64 Debug" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "iOS64 Debug" + } +} +job { + id: "iOS64 Release" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "iOS64 Release" + } +} +job { + id: "iOS64 Sim Debug (iOS 12)" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "iOS64 Sim Debug (iOS 12)" + } +} +job { + id: "iOS64 Sim Debug (iOS 13)" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "iOS64 Sim Debug (iOS 13)" + } +} +job { + id: "iOS64 Sim Debug (iOS 14.0)" + realm: "ci" + acl_sets: "ci" + buildbucket { + server: "cr-buildbucket.appspot.com" + bucket: "ci" + builder: "iOS64 Sim Debug (iOS 14.0)" + } +} +trigger { + id: "webrtc-gitiles-trigger-main" + realm: "ci" + acl_sets: "ci" + triggers: "Android32 (M Nexus5X)" + triggers: "Android32 (M Nexus5X)(dbg)" + triggers: "Android32 (more configs)" + triggers: "Android32 Builder arm" + triggers: "Android32 Builder x86" + triggers: "Android32 Builder x86 (dbg)" + triggers: "Android64 (M Nexus5X)" + triggers: "Android64 Builder arm64" + triggers: "Android64 Builder x64 (dbg)" + triggers: "Linux (more configs)" + triggers: "Linux Asan" + triggers: "Linux MSan" + triggers: "Linux Tsan v2" + triggers: "Linux UBSan" + triggers: "Linux UBSan vptr" + triggers: "Linux32 Debug" + triggers: "Linux32 Debug (ARM)" + triggers: "Linux32 Release" + triggers: "Linux32 Release (ARM)" + triggers: "Linux64 Builder" + triggers: "Linux64 Debug" + triggers: "Linux64 Debug (ARM)" + triggers: "Linux64 Release" + triggers: "Linux64 Release (ARM)" + triggers: "Linux64 Release (Libfuzzer)" + triggers: "Mac Asan" + triggers: "Mac64 Builder" + triggers: "Mac64 Debug" + triggers: "Mac64 Release" + triggers: "MacARM64 M1 Release" + triggers: "Win (more configs)" + triggers: "Win32 Builder (Clang)" + triggers: "Win32 Debug (Clang)" + triggers: "Win32 Release (Clang)" + triggers: "Win64 ASan" + triggers: "Win64 Debug (Clang)" + triggers: "Win64 Release (Clang)" + triggers: "iOS API Framework Builder" + triggers: "iOS64 Debug" + triggers: "iOS64 Release" + triggers: "iOS64 Sim Debug (iOS 12)" + triggers: "iOS64 Sim Debug (iOS 13)" + triggers: "iOS64 Sim Debug (iOS 14.0)" + gitiles { + repo: "https://webrtc.googlesource.com/src" + refs: "regexp:refs/heads/main" + } +} +acl_sets { + name: "ci" + acls { + role: OWNER + granted_to: "group:project-webrtc-admins" + } + acls { + granted_to: "group:all" + } +} +acl_sets { + name: "cron" + acls { + role: OWNER + granted_to: "group:project-webrtc-admins" + } + acls { + granted_to: "group:all" + } +} +acl_sets { + name: "perf" + acls { + role: OWNER + granted_to: "group:project-webrtc-admins" + } + acls { + granted_to: "group:all" + } +} diff --git a/infra/config/project.cfg b/infra/config/project.cfg new file mode 100644 index 0000000000..8f83365d86 --- /dev/null +++ b/infra/config/project.cfg @@ -0,0 +1,15 @@ +# Auto-generated by lucicfg. +# Do not modify manually. +# +# For the schema of this file, see ProjectCfg message: +# https://luci-config.appspot.com/schemas/projects:project.cfg + +name: "webrtc" +access: "group:all" +lucicfg { + version: "1.30.9" + package_dir: "." + config_dir: "." + entry_point: "config.star" + experiments: "crbug.com/1182002" +} diff --git a/infra/config/realms.cfg b/infra/config/realms.cfg new file mode 100644 index 0000000000..36f32e4d2b --- /dev/null +++ b/infra/config/realms.cfg @@ -0,0 +1,179 @@ +# Auto-generated by lucicfg. +# Do not modify manually. +# +# For the schema of this file, see RealmsCfg message: +# https://luci-config.appspot.com/schemas/projects:realms.cfg + +realms { + name: "@root" + bindings { + role: "role/buildbucket.reader" + principals: "group:all" + } + bindings { + role: "role/configs.reader" + principals: "group:all" + } + bindings { + role: "role/configs.validator" + principals: "user:webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + } + bindings { + role: "role/logdog.reader" + principals: "group:all" + } + bindings { + role: "role/logdog.writer" + principals: "group:luci-logdog-chromium-writers" + } + bindings { + role: "role/scheduler.owner" + principals: "group:project-webrtc-admins" + } + bindings { + role: "role/scheduler.reader" + principals: "group:all" + } + bindings { + role: "role/swarming.poolOwner" + principals: "group:project-webrtc-admins" + } + bindings { + role: "role/swarming.poolUser" + principals: "group:project-webrtc-admins" + } + bindings { + role: "role/swarming.poolViewer" + principals: "group:all" + } + bindings { + role: "role/swarming.taskServiceAccount" + principals: "user:chromium-tester@chops-service-accounts.iam.gserviceaccount.com" + } + bindings { + role: "role/swarming.taskTriggerer" + principals: "group:project-webrtc-admins" + } +} +realms { + name: "ci" + bindings { + role: "role/buildbucket.builderServiceAccount" + principals: "user:webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + bindings { + role: "role/buildbucket.triggerer" + principals: "group:project-webrtc-ci-schedulers" + principals: "group:service-account-chromeperf" + } + bindings { + role: "role/resultdb.invocationCreator" + principals: "group:project-webrtc-ci-task-accounts" + } +} +realms { + name: "cron" + bindings { + role: "role/buildbucket.builderServiceAccount" + principals: "user:chromium-webrtc-autoroll@webrtc-ci.iam.gserviceaccount.com" + principals: "user:webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com" + } +} +realms { + name: "perf" + bindings { + role: "role/buildbucket.builderServiceAccount" + principals: "user:webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + bindings { + role: "role/buildbucket.triggerer" + principals: "user:webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + } + bindings { + role: "role/swarming.taskTriggerer" + principals: "group:project-webrtc-led-users" + } + bindings { + role: "role/scheduler.triggerer" + principals: "user:webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" + conditions { + restrict { + attribute: "scheduler.job.name" + values: "Perf Android32 (M AOSP Nexus6)" + values: "Perf Android32 (M Nexus5)" + values: "Perf Android64 (M Nexus5X)" + values: "Perf Android64 (O Pixel2)" + values: "Perf Linux Bionic" + values: "Perf Linux Trusty" + values: "Perf Mac 10.11" + values: "Perf Win7" + } + } + } +} +realms { + name: "pools/ci" +} +realms { + name: "pools/ci-tests" + bindings { + role: "role/swarming.poolUser" + principals: "group:project-webrtc-ci-task-accounts" + } + bindings { + role: "role/swarming.taskServiceAccount" + principals: "group:project-webrtc-ci-task-accounts" + } +} +realms { + name: "pools/cron" + bindings { + role: "role/swarming.poolUser" + principals: "project:libyuv" + } +} +realms { + name: "pools/perf" + bindings { + role: "role/swarming.poolUser" + principals: "group:project-webrtc-led-users" + } +} +realms { + name: "pools/try" + bindings { + role: "role/swarming.poolUser" + principals: "group:project-webrtc-led-users" + } +} +realms { + name: "pools/try-tests" + bindings { + role: "role/swarming.poolUser" + principals: "group:project-webrtc-try-task-accounts" + } + bindings { + role: "role/swarming.taskServiceAccount" + principals: "group:project-webrtc-try-task-accounts" + } +} +realms { + name: "try" + bindings { + role: "role/buildbucket.builderServiceAccount" + principals: "user:webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" + } + bindings { + role: "role/buildbucket.triggerer" + principals: "group:project-webrtc-tryjob-access" + principals: "group:service-account-cq" + } + bindings { + role: "role/resultdb.invocationCreator" + principals: "group:project-webrtc-try-task-accounts" + } + bindings { + role: "role/swarming.taskTriggerer" + principals: "group:project-webrtc-led-users" + } +} From d8543dedf23aaf2c9bdf60e5d6a1937322aa8044 Mon Sep 17 00:00:00 2001 From: Mirko Bonadei Date: Mon, 14 Mar 2022 09:13:41 +0000 Subject: [PATCH 159/847] Revert "Pacer: Reduce TQ wake up and improve packet size estimation" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 37195cf2e577cc09ad1362d046b5c8a9b65d4f99. Reason for revert: Breaks downstream tests (more investigations and testing is necessary). Original change's description: > Pacer: Reduce TQ wake up and improve packet size estimation > > The TQ Pacer schedules delayed task according to target time of > PacingController. It drains all valid ProcessPackets() in single loop, > denies retired scheduled tasks, and round up the timeout to 1ms. > > This CL also improves packet size estimation in TQ Pacer by removing > zero initialization, and introduces `include_overhead_` configuration. > > Tests: > 1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > > 2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > > 3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > > Bug: webrtc:13417, webrtc:13437 > Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 > Reviewed-by: Erik Språng > Reviewed-by: Henrik Boström > Commit-Queue: Erik Språng > Cr-Commit-Position: refs/heads/main@{#36179} No-Try: True Bug: webrtc:13417, webrtc:13437 Change-Id: I5418d26d3978f21765ef38acfb002398e671e036 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255301 Reviewed-by: Henrik Boström Owners-Override: Mirko Bonadei Commit-Queue: Mirko Bonadei Bot-Commit: rubber-stamper@appspot.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36185} --- call/rtp_transport_controller_send.cc | 3 +- modules/pacing/pacing_controller.cc | 298 ++++++++++-------- modules/pacing/pacing_controller.h | 13 +- modules/pacing/task_queue_paced_sender.cc | 120 ++++--- modules/pacing/task_queue_paced_sender.h | 8 +- .../task_queue_paced_sender_unittest.cc | 48 +-- 6 files changed, 259 insertions(+), 231 deletions(-) diff --git a/call/rtp_transport_controller_send.cc b/call/rtp_transport_controller_send.cc index 8ee347b74a..f1a6201ce7 100644 --- a/call/rtp_transport_controller_send.cc +++ b/call/rtp_transport_controller_send.cc @@ -79,8 +79,7 @@ RtpTransportControllerSend::PacerSettings::PacerSettings( const WebRtcKeyValueConfig* trials) : tq_disabled("Disabled"), holdback_window("holdback_window", PacingController::kMinSleepTime), - holdback_packets("holdback_packets", - TaskQueuePacedSender::kNoPacketHoldback) { + holdback_packets("holdback_packets", -1) { ParseFieldTrial({&tq_disabled, &holdback_window, &holdback_packets}, trials->Lookup("WebRTC-TaskQueuePacer")); } diff --git a/modules/pacing/pacing_controller.cc b/modules/pacing/pacing_controller.cc index 4fb33ff072..9215462239 100644 --- a/modules/pacing/pacing_controller.cc +++ b/modules/pacing/pacing_controller.cc @@ -38,6 +38,11 @@ constexpr TimeDelta kMaxElapsedTime = TimeDelta::Seconds(2); // time. Applies only to periodic mode. constexpr TimeDelta kMaxProcessingInterval = TimeDelta::Millis(30); +// Allow probes to be processed slightly ahead of inteded send time. Currently +// set to 1ms as this is intended to allow times be rounded down to the nearest +// millisecond. +constexpr TimeDelta kMaxEarlyProbeProcessing = TimeDelta::Millis(1); + constexpr int kFirstPriority = 0; bool IsDisabled(const WebRtcKeyValueConfig& field_trials, @@ -89,8 +94,6 @@ const float PacingController::kDefaultPaceMultiplier = 2.5f; const TimeDelta PacingController::kPausedProcessInterval = kCongestedPacketInterval; const TimeDelta PacingController::kMinSleepTime = TimeDelta::Millis(1); -const TimeDelta PacingController::kMaxEarlyProbeProcessing = - TimeDelta::Millis(1); PacingController::PacingController(Clock* clock, PacketSender* packet_sender, @@ -130,7 +133,7 @@ PacingController::PacingController(Clock* clock, packet_counter_(0), congestion_window_size_(DataSize::PlusInfinity()), outstanding_data_(DataSize::Zero()), - queue_time_limit_(kMaxExpectedQueueLength), + queue_time_limit(kMaxExpectedQueueLength), account_for_audio_(false), include_overhead_(false) { if (!drain_large_queues_) { @@ -221,7 +224,6 @@ void PacingController::SetPacingRates(DataRate pacing_rate, media_rate_ = pacing_rate; padding_rate_ = padding_rate; pacing_bitrate_ = pacing_rate; - media_budget_.set_target_rate_kbps(pacing_rate.kbps()); padding_budget_.set_target_rate_kbps(padding_rate.kbps()); RTC_LOG(LS_VERBOSE) << "bwe:pacer_updated pacing_kbps=" @@ -300,7 +302,10 @@ void PacingController::EnqueuePacketInternal( // Use that as last process time only if it's prior to now. target_process_time = std::min(now, next_send_time); } - UpdateBudgetWithElapsedTime(UpdateTimeAndGetElapsed(target_process_time)); + + TimeDelta elapsed_time = UpdateTimeAndGetElapsed(target_process_time); + UpdateBudgetWithElapsedTime(elapsed_time); + last_process_time_ = target_process_time; } packet_queue_.Push(priority, now, packet_counter_++, std::move(packet)); } @@ -311,6 +316,7 @@ TimeDelta PacingController::UpdateTimeAndGetElapsed(Timestamp now) { if (last_process_time_.IsMinusInfinity() || now < last_process_time_) { return TimeDelta::Zero(); } + RTC_DCHECK_GE(now, last_process_time_); TimeDelta elapsed_time = now - last_process_time_; last_process_time_ = now; if (elapsed_time > kMaxElapsedTime) { @@ -327,7 +333,8 @@ bool PacingController::ShouldSendKeepalive(Timestamp now) const { packet_counter_ == 0) { // We send a padding packet every 500 ms to ensure we won't get stuck in // congested state due to no feedback being received. - if (now - last_send_time_ >= kCongestedPacketInterval) { + TimeDelta elapsed_since_last_send = now - last_send_time_; + if (elapsed_since_last_send >= kCongestedPacketInterval) { return true; } } @@ -336,17 +343,17 @@ bool PacingController::ShouldSendKeepalive(Timestamp now) const { Timestamp PacingController::NextSendTime() const { const Timestamp now = CurrentTime(); - Timestamp next_send_time = Timestamp::PlusInfinity(); if (paused_) { return last_send_time_ + kPausedProcessInterval; } // If probing is active, that always takes priority. - if (prober_.is_probing() && !probing_send_failure_) { + if (prober_.is_probing()) { Timestamp probe_time = prober_.NextProbeTime(now); - if (!probe_time.IsPlusInfinity()) { - return probe_time.IsMinusInfinity() ? now : probe_time; + // `probe_time` == PlusInfinity indicates no probe scheduled. + if (probe_time != Timestamp::PlusInfinity() && !probing_send_failure_) { + return probe_time; } } @@ -358,53 +365,86 @@ Timestamp PacingController::NextSendTime() const { // In dynamic mode, figure out when the next packet should be sent, // given the current conditions. - // Not pacing audio, if leading packet is audio its target send - // time is the time at which it was enqueued. - absl::optional unpaced_audio_time = - pace_audio_ ? absl::nullopt - : packet_queue_.LeadingAudioPacketEnqueueTime(); - if (unpaced_audio_time) { - return *unpaced_audio_time; + if (!pace_audio_) { + // Not pacing audio, if leading packet is audio its target send + // time is the time at which it was enqueued. + absl::optional audio_enqueue_time = + packet_queue_.LeadingAudioPacketEnqueueTime(); + if (audio_enqueue_time.has_value()) { + return *audio_enqueue_time; + } } - // We need to at least send keep-alive packets with some interval. if (Congested() || packet_counter_ == 0) { + // We need to at least send keep-alive packets with some interval. return last_send_time_ + kCongestedPacketInterval; } + // Check how long until we can send the next media packet. if (media_rate_ > DataRate::Zero() && !packet_queue_.Empty()) { - // Check how long until we can send the next media packet. - next_send_time = last_process_time_ + media_debt_ / media_rate_; - } else if (padding_rate_ > DataRate::Zero() && packet_queue_.Empty()) { - // If we _don't_ have pending packets, check how long until we have - // bandwidth for padding packets. Both media and padding debts must - // have been drained to do this. - RTC_DCHECK_GT(media_rate_, DataRate::Zero()); + return std::min(last_send_time_ + kPausedProcessInterval, + last_process_time_ + media_debt_ / media_rate_); + } + + // If we _don't_ have pending packets, check how long until we have + // bandwidth for padding packets. Both media and padding debts must + // have been drained to do this. + if (padding_rate_ > DataRate::Zero() && packet_queue_.Empty()) { TimeDelta drain_time = std::max(media_debt_ / media_rate_, padding_debt_ / padding_rate_); - next_send_time = last_process_time_ + drain_time; - } else { - // Nothing to do. - next_send_time = last_process_time_ + kPausedProcessInterval; + return std::min(last_send_time_ + kPausedProcessInterval, + last_process_time_ + drain_time); } if (send_padding_if_silent_) { - next_send_time = - std::min(next_send_time, last_send_time_ + kPausedProcessInterval); + return last_send_time_ + kPausedProcessInterval; } - - return next_send_time; + return last_process_time_ + kPausedProcessInterval; } void PacingController::ProcessPackets() { Timestamp now = CurrentTime(); Timestamp target_send_time = now; + if (mode_ == ProcessMode::kDynamic) { + target_send_time = NextSendTime(); + TimeDelta early_execute_margin = + prober_.is_probing() ? kMaxEarlyProbeProcessing : TimeDelta::Zero(); + if (target_send_time.IsMinusInfinity()) { + target_send_time = now; + } else if (now < target_send_time - early_execute_margin) { + // We are too early, but if queue is empty still allow draining some debt. + // Probing is allowed to be sent up to kMinSleepTime early. + TimeDelta elapsed_time = UpdateTimeAndGetElapsed(now); + UpdateBudgetWithElapsedTime(elapsed_time); + return; + } + + if (target_send_time < last_process_time_) { + // After the last process call, at time X, the target send time + // shifted to be earlier than X. This should normally not happen + // but we want to make sure rounding errors or erratic behavior + // of NextSendTime() does not cause issue. In particular, if the + // buffer reduction of + // rate * (target_send_time - previous_process_time) + // in the main loop doesn't clean up the existing debt we may not + // be able to send again. We don't want to check this reordering + // there as it is the normal exit condtion when the buffer is + // exhausted and there are packets in the queue. + UpdateBudgetWithElapsedTime(last_process_time_ - target_send_time); + target_send_time = last_process_time_; + } + } + + Timestamp previous_process_time = last_process_time_; + TimeDelta elapsed_time = UpdateTimeAndGetElapsed(now); if (ShouldSendKeepalive(now)) { - DataSize keepalive_data_sent = DataSize::Zero(); // We can not send padding unless a normal packet has first been sent. If // we do, timestamps get messed up. - if (packet_counter_ > 0) { + if (packet_counter_ == 0) { + last_send_time_ = now; + } else { + DataSize keepalive_data_sent = DataSize::Zero(); std::vector> keepalive_packets = packet_sender_->GeneratePadding(DataSize::Bytes(1)); for (auto& packet : keepalive_packets) { @@ -415,29 +455,14 @@ void PacingController::ProcessPackets() { EnqueuePacket(std::move(packet)); } } + OnPaddingSent(keepalive_data_sent); } - OnPacketSent(RtpPacketMediaType::kPadding, keepalive_data_sent, now); } if (paused_) { return; } - if (mode_ == ProcessMode::kDynamic) { - TimeDelta early_execute_margin = - prober_.is_probing() ? kMaxEarlyProbeProcessing : TimeDelta::Zero(); - - target_send_time = NextSendTime(); - if (now + early_execute_margin < target_send_time) { - // We are too early, but if queue is empty still allow draining some debt. - // Probing is allowed to be sent up to kMinSleepTime early. - UpdateBudgetWithElapsedTime(UpdateTimeAndGetElapsed(now)); - return; - } - } - - TimeDelta elapsed_time = UpdateTimeAndGetElapsed(target_send_time); - if (elapsed_time > TimeDelta::Zero()) { DataRate target_rate = pacing_bitrate_; DataSize queue_size_data = packet_queue_.Size(); @@ -449,7 +474,7 @@ void PacingController::ProcessPackets() { if (drain_large_queues_) { TimeDelta avg_time_left = std::max(TimeDelta::Millis(1), - queue_time_limit_ - packet_queue_.AverageQueueTime()); + queue_time_limit - packet_queue_.AverageQueueTime()); DataRate min_rate_needed = queue_size_data / avg_time_left; if (min_rate_needed > target_rate) { target_rate = min_rate_needed; @@ -464,12 +489,13 @@ void PacingController::ProcessPackets() { // up to (process interval duration) * (target rate), so we only need to // update it once before the packet sending loop. media_budget_.set_target_rate_kbps(target_rate.kbps()); + UpdateBudgetWithElapsedTime(elapsed_time); } else { media_rate_ = target_rate; } - UpdateBudgetWithElapsedTime(elapsed_time); } + bool first_packet_in_probe = false; PacedPacketInfo pacing_info; DataSize recommended_probe_size = DataSize::Zero(); bool is_probing = prober_.is_probing(); @@ -478,23 +504,9 @@ void PacingController::ProcessPackets() { // use actual send time rather than target. pacing_info = prober_.CurrentCluster(now).value_or(PacedPacketInfo()); if (pacing_info.probe_cluster_id != PacedPacketInfo::kNotAProbe) { + first_packet_in_probe = pacing_info.probe_cluster_bytes_sent == 0; recommended_probe_size = prober_.RecommendedMinProbeSize(); RTC_DCHECK_GT(recommended_probe_size, DataSize::Zero()); - - // If first packet in probe, insert a small padding packet so we have a - // more reliable start window for the rate estimation. - if (pacing_info.probe_cluster_bytes_sent == 0) { - auto padding = packet_sender_->GeneratePadding(DataSize::Bytes(1)); - // If no RTP modules sending media are registered, we may not get a - // padding packet back. - if (!padding.empty()) { - // Insert with high priority so larger media packets don't preempt it. - EnqueuePacketInternal(std::move(padding[0]), kFirstPriority); - // We should never get more than one padding packets with a requested - // size of 1 byte. - RTC_DCHECK_EQ(padding.size(), 1u); - } - } } else { // No valid probe cluster returned, probe might have timed out. is_probing = false; @@ -502,74 +514,102 @@ void PacingController::ProcessPackets() { } DataSize data_sent = DataSize::Zero(); - while (true) { - // Fetch packet, so long as queue is not empty or budget is not + + // The paused state is checked in the loop since it leaves the critical + // section allowing the paused state to be changed from other code. + while (!paused_) { + if (first_packet_in_probe) { + // If first packet in probe, insert a small padding packet so we have a + // more reliable start window for the rate estimation. + auto padding = packet_sender_->GeneratePadding(DataSize::Bytes(1)); + // If no RTP modules sending media are registered, we may not get a + // padding packet back. + if (!padding.empty()) { + // Insert with high priority so larger media packets don't preempt it. + EnqueuePacketInternal(std::move(padding[0]), kFirstPriority); + // We should never get more than one padding packets with a requested + // size of 1 byte. + RTC_DCHECK_EQ(padding.size(), 1u); + } + first_packet_in_probe = false; + } + + if (mode_ == ProcessMode::kDynamic && + previous_process_time < target_send_time) { + // Reduce buffer levels with amount corresponding to time between last + // process and target send time for the next packet. + // If the process call is late, that may be the time between the optimal + // send times for two packets we should already have sent. + UpdateBudgetWithElapsedTime(target_send_time - previous_process_time); + previous_process_time = target_send_time; + } + + // Fetch the next packet, so long as queue is not empty or budget is not // exhausted. std::unique_ptr rtp_packet = GetPendingPacket(pacing_info, target_send_time, now); + if (rtp_packet == nullptr) { // No packet available to send, check if we should send padding. DataSize padding_to_add = PaddingToAdd(recommended_probe_size, data_sent); if (padding_to_add > DataSize::Zero()) { std::vector> padding_packets = packet_sender_->GeneratePadding(padding_to_add); - if (!padding_packets.empty()) { - for (auto& packet : padding_packets) { - EnqueuePacket(std::move(packet)); - } - // Continue loop to send the padding that was just added. - continue; - } else { - // Can't generate padding, still update padding budget for next send - // time. - UpdatePaddingBudgetWithSentData(padding_to_add); + if (padding_packets.empty()) { + // No padding packets were generated, quite send loop. + break; + } + for (auto& packet : padding_packets) { + EnqueuePacket(std::move(packet)); } + // Continue loop to send the padding that was just added. + continue; } + // Can't fetch new packet and no padding to send, exit send loop. break; - } else { - RTC_DCHECK(rtp_packet); - RTC_DCHECK(rtp_packet->packet_type().has_value()); - const RtpPacketMediaType packet_type = *rtp_packet->packet_type(); - DataSize packet_size = DataSize::Bytes(rtp_packet->payload_size() + - rtp_packet->padding_size()); - - if (include_overhead_) { - packet_size += DataSize::Bytes(rtp_packet->headers_size()) + - transport_overhead_per_packet_; - } + } - packet_sender_->SendPacket(std::move(rtp_packet), pacing_info); - for (auto& packet : packet_sender_->FetchFec()) { - EnqueuePacket(std::move(packet)); - } - data_sent += packet_size; + RTC_DCHECK(rtp_packet); + RTC_DCHECK(rtp_packet->packet_type().has_value()); + const RtpPacketMediaType packet_type = *rtp_packet->packet_type(); + DataSize packet_size = DataSize::Bytes(rtp_packet->payload_size() + + rtp_packet->padding_size()); - // Send done, update send time. - OnPacketSent(packet_type, packet_size, now); + if (include_overhead_) { + packet_size += DataSize::Bytes(rtp_packet->headers_size()) + + transport_overhead_per_packet_; + } - // If we are currently probing, we need to stop the send loop when we - // have reached the send target. - if (is_probing && data_sent >= recommended_probe_size) { - break; - } + packet_sender_->SendPacket(std::move(rtp_packet), pacing_info); + for (auto& packet : packet_sender_->FetchFec()) { + EnqueuePacket(std::move(packet)); + } + data_sent += packet_size; + + // Send done, update send/process time to the target send time. + OnPacketSent(packet_type, packet_size, target_send_time); + + // If we are currently probing, we need to stop the send loop when we have + // reached the send target. + if (is_probing && data_sent >= recommended_probe_size) { + break; + } + if (mode_ == ProcessMode::kDynamic) { // Update target send time in case that are more packets that we are late // in processing. - if (mode_ == ProcessMode::kDynamic) { - target_send_time = NextSendTime(); - if (target_send_time > now) { - // Exit loop if not probing. - if (!is_probing) { - break; - } - target_send_time = now; - } - UpdateBudgetWithElapsedTime(UpdateTimeAndGetElapsed(target_send_time)); + Timestamp next_send_time = NextSendTime(); + if (next_send_time.IsMinusInfinity()) { + target_send_time = now; + } else { + target_send_time = std::min(now, next_send_time); } } } + last_process_time_ = std::max(last_process_time_, previous_process_time); + if (is_probing) { probing_send_failure_ = data_sent == DataSize::Zero(); if (!probing_send_failure_) { @@ -591,8 +631,8 @@ DataSize PacingController::PaddingToAdd(DataSize recommended_probe_size, } if (packet_counter_ == 0) { - // We can not send padding unless a normal packet has first been sent. If - // we do, timestamps get messed up. + // We can not send padding unless a normal packet has first been sent. If we + // do, timestamps get messed up. return DataSize::Zero(); } @@ -657,16 +697,25 @@ std::unique_ptr PacingController::GetPendingPacket( void PacingController::OnPacketSent(RtpPacketMediaType packet_type, DataSize packet_size, Timestamp send_time) { - if (!first_sent_packet_time_ && packet_type != RtpPacketMediaType::kPadding) { + if (!first_sent_packet_time_) { first_sent_packet_time_ = send_time; } - bool audio_packet = packet_type == RtpPacketMediaType::kAudio; - if ((!audio_packet || account_for_audio_) && packet_size > DataSize::Zero()) { + if (!audio_packet || account_for_audio_) { + // Update media bytes sent. UpdateBudgetWithSentData(packet_size); } - last_send_time_ = send_time; + last_process_time_ = send_time; +} + +void PacingController::OnPaddingSent(DataSize data_sent) { + if (data_sent > DataSize::Zero()) { + UpdateBudgetWithSentData(data_sent); + } + Timestamp now = CurrentTime(); + last_send_time_ = now; + last_process_time_ = now; } void PacingController::UpdateBudgetWithElapsedTime(TimeDelta delta) { @@ -684,24 +733,17 @@ void PacingController::UpdateBudgetWithSentData(DataSize size) { outstanding_data_ += size; if (mode_ == ProcessMode::kPeriodic) { media_budget_.UseBudget(size.bytes()); + padding_budget_.UseBudget(size.bytes()); } else { media_debt_ += size; media_debt_ = std::min(media_debt_, media_rate_ * kMaxDebtInTime); - } - UpdatePaddingBudgetWithSentData(size); -} - -void PacingController::UpdatePaddingBudgetWithSentData(DataSize size) { - if (mode_ == ProcessMode::kPeriodic) { - padding_budget_.UseBudget(size.bytes()); - } else { padding_debt_ += size; padding_debt_ = std::min(padding_debt_, padding_rate_ * kMaxDebtInTime); } } void PacingController::SetQueueTimeLimit(TimeDelta limit) { - queue_time_limit_ = limit; + queue_time_limit = limit; } } // namespace webrtc diff --git a/modules/pacing/pacing_controller.h b/modules/pacing/pacing_controller.h index e7ef201a77..5d6d26b917 100644 --- a/modules/pacing/pacing_controller.h +++ b/modules/pacing/pacing_controller.h @@ -79,11 +79,6 @@ class PacingController { static const TimeDelta kMinSleepTime; - // Allow probes to be processed slightly ahead of inteded send time. Currently - // set to 1ms as this is intended to allow times be rounded down to the - // nearest millisecond. - static const TimeDelta kMaxEarlyProbeProcessing; - PacingController(Clock* clock, PacketSender* packet_sender, RtcEventLog* event_log, @@ -163,7 +158,6 @@ class PacingController { // Updates the number of bytes that can be sent for the next time interval. void UpdateBudgetWithElapsedTime(TimeDelta delta); void UpdateBudgetWithSentData(DataSize size); - void UpdatePaddingBudgetWithSentData(DataSize size); DataSize PaddingToAdd(DataSize recommended_probe_size, DataSize data_sent) const; @@ -175,6 +169,7 @@ class PacingController { void OnPacketSent(RtpPacketMediaType packet_type, DataSize packet_size, Timestamp send_time); + void OnPaddingSent(DataSize padding_sent); Timestamp CurrentTime() const; @@ -201,9 +196,9 @@ class PacingController { mutable Timestamp last_timestamp_; bool paused_; - // In periodic mode, `media_budget_` and `padding_budget_` will be used to + // In dynamic mode, `media_budget_` and `padding_budget_` will be used to // track when packets can be sent. - // In dynamic mode, `media_debt_` and `padding_debt_` will be used together + // In periodic mode, `media_debt_` and `padding_debt_` will be used together // with the target rates. // This is the media budget, keeping track of how many bits of media @@ -234,7 +229,7 @@ class PacingController { DataSize congestion_window_size_; DataSize outstanding_data_; - TimeDelta queue_time_limit_; + TimeDelta queue_time_limit; bool account_for_audio_; bool include_overhead_; }; diff --git a/modules/pacing/task_queue_paced_sender.cc b/modules/pacing/task_queue_paced_sender.cc index 18e53d1ad7..c392a88720 100644 --- a/modules/pacing/task_queue_paced_sender.cc +++ b/modules/pacing/task_queue_paced_sender.cc @@ -12,14 +12,15 @@ #include #include - +#include "absl/memory/memory.h" #include "rtc_base/checks.h" +#include "rtc_base/event.h" +#include "rtc_base/logging.h" +#include "rtc_base/task_utils/to_queued_task.h" #include "rtc_base/trace_event.h" namespace webrtc { -const int TaskQueuePacedSender::kNoPacketHoldback = -1; - TaskQueuePacedSender::TaskQueuePacedSender( Clock* clock, PacingController::PacketSender* packet_sender, @@ -40,11 +41,10 @@ TaskQueuePacedSender::TaskQueuePacedSender( is_started_(false), is_shutdown_(false), packet_size_(/*alpha=*/0.95), - include_overhead_(false), task_queue_(task_queue_factory->CreateTaskQueue( "TaskQueuePacedSender", TaskQueueFactory::Priority::NORMAL)) { - RTC_DCHECK_GE(max_hold_back_window_, PacingController::kMinSleepTime); + packet_size_.Apply(1, 0); } TaskQueuePacedSender::~TaskQueuePacedSender() { @@ -140,11 +140,7 @@ void TaskQueuePacedSender::EnqueuePackets( task_queue_.PostTask([this, packets_ = std::move(packets)]() mutable { RTC_DCHECK_RUN_ON(&task_queue_); for (auto& packet : packets_) { - size_t packet_size = packet->payload_size() + packet->padding_size(); - if (include_overhead_) { - packet_size += packet->headers_size(); - } - packet_size_.Apply(1, packet_size); + packet_size_.Apply(1, packet->size()); RTC_DCHECK_GE(packet->capture_time(), Timestamp::Zero()); pacing_controller_.EnqueuePacket(std::move(packet)); } @@ -163,7 +159,6 @@ void TaskQueuePacedSender::SetAccountForAudioPackets(bool account_for_audio) { void TaskQueuePacedSender::SetIncludeOverhead() { task_queue_.PostTask([this]() { RTC_DCHECK_RUN_ON(&task_queue_); - include_overhead_ = true; pacing_controller_.SetIncludeOverhead(); MaybeProcessPackets(Timestamp::MinusInfinity()); }); @@ -199,16 +194,13 @@ absl::optional TaskQueuePacedSender::FirstSentPacketTime() const { TimeDelta TaskQueuePacedSender::OldestPacketWaitTime() const { Timestamp oldest_packet = GetStats().oldest_packet_enqueue_time; - if (oldest_packet.IsInfinite()) { + if (oldest_packet.IsInfinite()) return TimeDelta::Zero(); - } // (webrtc:9716): The clock is not always monotonic. Timestamp current = clock_->CurrentTime(); - if (current < oldest_packet) { + if (current < oldest_packet) return TimeDelta::Zero(); - } - return current - oldest_packet; } @@ -221,70 +213,70 @@ void TaskQueuePacedSender::MaybeProcessPackets( Timestamp scheduled_process_time) { RTC_DCHECK_RUN_ON(&task_queue_); -#if RTC_TRACE_EVENTS_ENABLED - TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("webrtc"), - "TaskQueuePacedSender::MaybeProcessPackets"); -#endif - if (is_shutdown_ || !is_started_) { return; } - Timestamp next_send_time = pacing_controller_.NextSendTime(); - RTC_DCHECK(next_send_time.IsFinite()); + // Normally, run ProcessPackets() only if this is the scheduled task. + // If it is not but it is already time to process and there either is + // no scheduled task or the schedule has shifted forward in time, run + // anyway and clear any schedule. + Timestamp next_process_time = pacing_controller_.NextSendTime(); const Timestamp now = clock_->CurrentTime(); - - TimeDelta early_execute_margin = - pacing_controller_.IsProbing() - ? PacingController::kMaxEarlyProbeProcessing - : TimeDelta::Zero(); - - // Process packets and update stats. - while (next_send_time <= now + early_execute_margin) { + const bool is_scheduled_call = next_process_time_ == scheduled_process_time; + if (is_scheduled_call) { + // Indicate no pending scheduled call. + next_process_time_ = Timestamp::MinusInfinity(); + } + if (is_scheduled_call || + (now >= next_process_time && (next_process_time_.IsInfinite() || + next_process_time < next_process_time_))) { pacing_controller_.ProcessPackets(); - next_send_time = pacing_controller_.NextSendTime(); - RTC_DCHECK(next_send_time.IsFinite()); + next_process_time = pacing_controller_.NextSendTime(); } - UpdateStats(); - // Ignore retired scheduled task, otherwise reset `next_process_time_`. - if (scheduled_process_time.IsFinite()) { - if (scheduled_process_time != next_process_time_) { - return; - } - next_process_time_ = Timestamp::MinusInfinity(); + TimeDelta hold_back_window = max_hold_back_window_; + DataRate pacing_rate = pacing_controller_.pacing_rate(); + DataSize avg_packet_size = DataSize::Bytes(packet_size_.filtered()); + if (max_hold_back_window_in_packets_ > 0 && !pacing_rate.IsZero() && + !avg_packet_size.IsZero()) { + TimeDelta avg_packet_send_time = avg_packet_size / pacing_rate; + hold_back_window = + std::min(hold_back_window, + avg_packet_send_time * max_hold_back_window_in_packets_); } - // Do not hold back in probing. - TimeDelta hold_back_window = TimeDelta::Zero(); - if (!pacing_controller_.IsProbing()) { - hold_back_window = max_hold_back_window_; - DataRate pacing_rate = pacing_controller_.pacing_rate(); - if (max_hold_back_window_in_packets_ != kNoPacketHoldback && - !pacing_rate.IsZero() && - packet_size_.filtered() != rtc::ExpFilter::kValueUndefined) { - TimeDelta avg_packet_send_time = - DataSize::Bytes(packet_size_.filtered()) / pacing_rate; - hold_back_window = - std::min(hold_back_window, - avg_packet_send_time * max_hold_back_window_in_packets_); + absl::optional time_to_next_process; + if (pacing_controller_.IsProbing() && + next_process_time != next_process_time_) { + // If we're probing and there isn't already a wakeup scheduled for the next + // process time, always post a task and just round sleep time down to + // nearest millisecond. + if (next_process_time.IsMinusInfinity()) { + time_to_next_process = TimeDelta::Zero(); + } else { + time_to_next_process = + std::max(TimeDelta::Zero(), + (next_process_time - now).RoundDownTo(TimeDelta::Millis(1))); } + } else if (next_process_time_.IsMinusInfinity() || + next_process_time <= next_process_time_ - hold_back_window) { + // Schedule a new task since there is none currently scheduled + // (`next_process_time_` is infinite), or the new process time is at least + // one holdback window earlier than whatever is currently scheduled. + time_to_next_process = std::max(next_process_time - now, hold_back_window); } - // Calculate next process time. - TimeDelta time_to_next_process = - std::max(hold_back_window, next_send_time - now - early_execute_margin); - next_send_time = now + time_to_next_process; + if (time_to_next_process) { + // Set a new scheduled process time and post a delayed task. + next_process_time_ = next_process_time; - // If no in flight task or in flight task is later than `next_send_time`, - // schedule a new one. Previous in flight task will be retired. - if (next_process_time_.IsMinusInfinity() || - next_process_time_ > next_send_time) { task_queue_.PostDelayedHighPrecisionTask( - [this, next_send_time]() { MaybeProcessPackets(next_send_time); }, - time_to_next_process.RoundUpTo(TimeDelta::Millis(1)).ms()); - next_process_time_ = next_send_time; + [this, next_process_time]() { MaybeProcessPackets(next_process_time); }, + time_to_next_process->ms()); } + + UpdateStats(); } void TaskQueuePacedSender::UpdateStats() { diff --git a/modules/pacing/task_queue_paced_sender.h b/modules/pacing/task_queue_paced_sender.h index bf17de52f9..353f137963 100644 --- a/modules/pacing/task_queue_paced_sender.h +++ b/modules/pacing/task_queue_paced_sender.h @@ -14,7 +14,9 @@ #include #include +#include #include +#include #include #include "absl/types/optional.h" @@ -27,6 +29,7 @@ #include "modules/pacing/rtp_packet_pacer.h" #include "modules/rtp_rtcp/source/rtp_packet_to_send.h" #include "rtc_base/numerics/exp_filter.h" +#include "rtc_base/synchronization/mutex.h" #include "rtc_base/task_queue.h" #include "rtc_base/thread_annotations.h" @@ -36,8 +39,6 @@ class RtcEventLog; class TaskQueuePacedSender : public RtpPacketPacer, public RtpPacketSender { public: - static const int kNoPacketHoldback; - // The `hold_back_window` parameter sets a lower bound on time to sleep if // there is currently a pacer queue and packets can't immediately be // processed. Increasing this reduces thread wakeups at the expense of higher @@ -50,7 +51,7 @@ class TaskQueuePacedSender : public RtpPacketPacer, public RtpPacketSender { const WebRtcKeyValueConfig* field_trials, TaskQueueFactory* task_queue_factory, TimeDelta max_hold_back_window = PacingController::kMinSleepTime, - int max_hold_back_window_in_packets = kNoPacketHoldback); + int max_hold_back_window_in_packets = -1); ~TaskQueuePacedSender() override; @@ -155,7 +156,6 @@ class TaskQueuePacedSender : public RtpPacketPacer, public RtpPacketSender { // Filtered size of enqueued packets, in bytes. rtc::ExpFilter packet_size_ RTC_GUARDED_BY(task_queue_); - bool include_overhead_ RTC_GUARDED_BY(task_queue_); mutable Mutex stats_mutex_; Stats current_stats_ RTC_GUARDED_BY(stats_mutex_); diff --git a/modules/pacing/task_queue_paced_sender_unittest.cc b/modules/pacing/task_queue_paced_sender_unittest.cc index c2d1fbd095..d78365d499 100644 --- a/modules/pacing/task_queue_paced_sender_unittest.cc +++ b/modules/pacing/task_queue_paced_sender_unittest.cc @@ -37,6 +37,7 @@ constexpr uint32_t kVideoSsrc = 234565; constexpr uint32_t kVideoRtxSsrc = 34567; constexpr uint32_t kFlexFecSsrc = 45678; constexpr size_t kDefaultPacketSize = 1234; +constexpr int kNoPacketHoldback = -1; class MockPacketRouter : public PacketRouter { public: @@ -119,7 +120,7 @@ TEST(TaskQueuePacedSenderTest, PacesPackets) { time_controller.GetClock(), &packet_router, /*event_log=*/nullptr, /*field_trials=*/nullptr, time_controller.GetTaskQueueFactory(), - PacingController::kMinSleepTime, TaskQueuePacedSender::kNoPacketHoldback); + PacingController::kMinSleepTime, kNoPacketHoldback); // Insert a number of packets, covering one second. static constexpr size_t kPacketsToSend = 42; @@ -159,7 +160,7 @@ TEST(TaskQueuePacedSenderTest, ReschedulesProcessOnRateChange) { time_controller.GetClock(), &packet_router, /*event_log=*/nullptr, /*field_trials=*/nullptr, time_controller.GetTaskQueueFactory(), - PacingController::kMinSleepTime, TaskQueuePacedSender::kNoPacketHoldback); + PacingController::kMinSleepTime, kNoPacketHoldback); // Insert a number of packets to be sent 200ms apart. const size_t kPacketsPerSecond = 5; @@ -211,7 +212,7 @@ TEST(TaskQueuePacedSenderTest, SendsAudioImmediately) { time_controller.GetClock(), &packet_router, /*event_log=*/nullptr, /*field_trials=*/nullptr, time_controller.GetTaskQueueFactory(), - PacingController::kMinSleepTime, TaskQueuePacedSender::kNoPacketHoldback); + PacingController::kMinSleepTime, kNoPacketHoldback); const DataRate kPacingDataRate = DataRate::KilobitsPerSec(125); const DataSize kPacketSize = DataSize::Bytes(kDefaultPacketSize); @@ -240,11 +241,11 @@ TEST(TaskQueuePacedSenderTest, SleepsDuringCoalscingWindow) { const TimeDelta kCoalescingWindow = TimeDelta::Millis(5); GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); MockPacketRouter packet_router; - TaskQueuePacedSender pacer( - time_controller.GetClock(), &packet_router, - /*event_log=*/nullptr, - /*field_trials=*/nullptr, time_controller.GetTaskQueueFactory(), - kCoalescingWindow, TaskQueuePacedSender::kNoPacketHoldback); + TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, + /*event_log=*/nullptr, + /*field_trials=*/nullptr, + time_controller.GetTaskQueueFactory(), + kCoalescingWindow, kNoPacketHoldback); // Set rates so one packet adds one ms of buffer level. const DataSize kPacketSize = DataSize::Bytes(kDefaultPacketSize); @@ -277,11 +278,11 @@ TEST(TaskQueuePacedSenderTest, ProbingOverridesCoalescingWindow) { const TimeDelta kCoalescingWindow = TimeDelta::Millis(5); GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); MockPacketRouter packet_router; - TaskQueuePacedSender pacer( - time_controller.GetClock(), &packet_router, - /*event_log=*/nullptr, - /*field_trials=*/nullptr, time_controller.GetTaskQueueFactory(), - kCoalescingWindow, TaskQueuePacedSender::kNoPacketHoldback); + TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, + /*event_log=*/nullptr, + /*field_trials=*/nullptr, + time_controller.GetTaskQueueFactory(), + kCoalescingWindow, kNoPacketHoldback); // Set rates so one packet adds one ms of buffer level. const DataSize kPacketSize = DataSize::Bytes(kDefaultPacketSize); @@ -305,7 +306,7 @@ TEST(TaskQueuePacedSenderTest, ProbingOverridesCoalescingWindow) { time_controller.AdvanceTime(kCoalescingWindow - TimeDelta::Millis(1)); } -TEST(TaskQueuePacedSenderTest, SchedulesProbeAtSentTime) { +TEST(TaskQueuePacedSenderTest, SchedulesProbeAtSetTime) { ScopedFieldTrials trials("WebRTC-Bwe-ProbingBehavior/min_probe_delta:1ms/"); GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); MockPacketRouter packet_router; @@ -313,7 +314,7 @@ TEST(TaskQueuePacedSenderTest, SchedulesProbeAtSentTime) { time_controller.GetClock(), &packet_router, /*event_log=*/nullptr, /*field_trials=*/nullptr, time_controller.GetTaskQueueFactory(), - PacingController::kMinSleepTime, TaskQueuePacedSender::kNoPacketHoldback); + PacingController::kMinSleepTime, kNoPacketHoldback); // Set rates so one packet adds 4ms of buffer level. const DataSize kPacketSize = DataSize::Bytes(kDefaultPacketSize); @@ -338,16 +339,15 @@ TEST(TaskQueuePacedSenderTest, SchedulesProbeAtSentTime) { // Advance to less than 3ms before next packet send time. time_controller.AdvanceTime(TimeDelta::Micros(1001)); - // Trigger a probe at 2x the current pacing rate and insert the number of + // Trigger a probe at 4x the current pacing rate and insert the number of // packets the probe needs. const DataRate kProbeRate = 2 * kPacingDataRate; const int kProbeClusterId = 1; pacer.CreateProbeCluster(kProbeRate, kProbeClusterId); - // Expected size for each probe in a cluster is twice the expected bits sent - // during min_probe_delta. - // Expect one additional call since probe always starts with a small (1 byte) - // padding packet that's not counted into the probe rate here. + // Expected size for each probe in a cluster is twice the expected bits + // sent during min_probe_delta. + // Expect one additional call since probe always starts with a small const TimeDelta kProbeTimeDelta = TimeDelta::Millis(2); const DataSize kProbeSize = kProbeRate * kProbeTimeDelta; const size_t kNumPacketsInProbe = @@ -381,7 +381,7 @@ TEST(TaskQueuePacedSenderTest, NoMinSleepTimeWhenProbing) { time_controller.GetClock(), &packet_router, /*event_log=*/nullptr, /*field_trials=*/nullptr, time_controller.GetTaskQueueFactory(), - PacingController::kMinSleepTime, TaskQueuePacedSender::kNoPacketHoldback); + PacingController::kMinSleepTime, kNoPacketHoldback); // Set rates so one packet adds 4ms of buffer level. const DataSize kPacketSize = DataSize::Bytes(kDefaultPacketSize); @@ -423,8 +423,8 @@ TEST(TaskQueuePacedSenderTest, NoMinSleepTimeWhenProbing) { // Verify the amount of probing data sent. // Probe always starts with a small (1 byte) padding packet that's not // counted into the probe rate here. - const DataSize kMinProbeSize = 2 * kMinProbeDelta * kProbingRate; - EXPECT_EQ(data_sent, DataSize::Bytes(1) + kPacketSize + 4 * kMinProbeSize); + EXPECT_EQ(data_sent, + kProbingRate * TimeDelta::Millis(1) + DataSize::Bytes(1)); } TEST(TaskQueuePacedSenderTest, PacketBasedCoalescing) { @@ -534,7 +534,7 @@ TEST(TaskQueuePacedSenderTest, Stats) { time_controller.GetClock(), &packet_router, /*event_log=*/nullptr, /*field_trials=*/nullptr, time_controller.GetTaskQueueFactory(), - PacingController::kMinSleepTime, TaskQueuePacedSender::kNoPacketHoldback); + PacingController::kMinSleepTime, kNoPacketHoldback); // Simulate ~2mbps video stream, covering one second. static constexpr size_t kPacketsToSend = 200; From 7c453589a91bda0ac343b1b6c89dd990e02632c1 Mon Sep 17 00:00:00 2001 From: Ilya Nikolaevskiy Date: Mon, 14 Mar 2022 10:22:06 +0000 Subject: [PATCH 160/847] Revert "Avoid using lld when compiling iin iOS with bitcode" This reverts commit b7ba6027659913883af3d64ec0fdfcba96176816. Reason for revert: Speculative revert as this seems to break the downstream project. Original change's description: > Avoid using lld when compiling iin iOS with bitcode > > The resulting framework's LLVM __bundle segment is empty otherwise. > > Bug: webrtc:13774 > Change-Id: I235a3005f8e0d68168f29108be0f7c5b7914182b > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253140 > Reviewed-by: Mirko Bonadei > Commit-Queue: Mirko Bonadei > Cr-Commit-Position: refs/heads/main@{#36178} Bug: webrtc:13774 Change-Id: Ib05469827783d8db5e48ab9c33b31fcebd14b52a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255302 Commit-Queue: Ilya Nikolaevskiy Bot-Commit: rubber-stamper@appspot.gserviceaccount.com Reviewed-by: Mirko Bonadei Commit-Queue: Mirko Bonadei Cr-Commit-Position: refs/heads/main@{#36186} --- tools_webrtc/ios/build_ios_libs.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tools_webrtc/ios/build_ios_libs.py b/tools_webrtc/ios/build_ios_libs.py index 9a4c3e32ad..15a912e4ba 100755 --- a/tools_webrtc/ios/build_ios_libs.py +++ b/tools_webrtc/ios/build_ios_libs.py @@ -180,7 +180,6 @@ def BuildWebRTC(output_dir, target_environment, target_arch, flavor, ('true' if libvpx_build_vp9 else 'false')) gn_args.append('enable_ios_bitcode=' + ('true' if use_bitcode else 'false')) - gn_args.append('use_lld=' + ('false' if use_bitcode else 'true')) gn_args.append('use_goma=' + ('true' if use_goma else 'false')) gn_args.append('rtc_enable_objc_symbol_export=true') From c5b9c95c88cefc06703c16958076b8fef7777c48 Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Mon, 14 Mar 2022 07:16:40 +0000 Subject: [PATCH 161/847] Break out first orange target from rtc_pc_base Bug: webrtc:13805 Change-Id: Ic0618da2cf94ff0c163f2ac72daa2117b0d3b5ce Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255300 Reviewed-by: Mirko Bonadei Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#36187} --- pc/BUILD.gn | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/pc/BUILD.gn b/pc/BUILD.gn index b03eb8e7b5..c227117808 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -69,13 +69,10 @@ rtc_library("rtc_pc_base") { sources = [ "channel.cc", "channel.h", - "channel_interface.h", "channel_manager.cc", "channel_manager.h", "dtls_srtp_transport.cc", "dtls_srtp_transport.h", - "dtls_transport.cc", - "dtls_transport.h", "jsep_transport.cc", "jsep_transport.h", "jsep_transport_collection.cc", @@ -92,7 +89,6 @@ rtc_library("rtc_pc_base") { "srtp_session.h", "srtp_transport.cc", "srtp_transport.h", - "used_ids.h", "video_track_source_proxy.cc", "video_track_source_proxy.h", ] @@ -220,6 +216,14 @@ rtc_source_set("channel") { } rtc_source_set("channel_interface") { visibility = [ ":*" ] + sources = [ "channel_interface.h" ] + deps = [ + ":rtp_transport_internal", + "../api:libjingle_peerconnection_api", + "../api:rtp_parameters", + "../media:rtc_media_base", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } rtc_source_set("channel_manager") { visibility = [ ":*" ] @@ -229,6 +233,25 @@ rtc_source_set("dtls_srtp_transport") { } rtc_source_set("dtls_transport") { visibility = [ ":*" ] + sources = [ + "dtls_transport.cc", + "dtls_transport.h", + ] + deps = [ + ":ice_transport", + "../api:libjingle_peerconnection_api", + "../api:scoped_refptr", + "../api:sequence_checker", + "../p2p:rtc_p2p", + "../rtc_base", + "../rtc_base:checks", + "../rtc_base:logging", + "../rtc_base:macromagic", + "../rtc_base:refcount", + "../rtc_base:threading", + "../rtc_base/synchronization:mutex", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } rtc_source_set("external_hmac") { visibility = [ ":*" ] @@ -431,6 +454,13 @@ rtc_source_set("transport_stats") { } rtc_source_set("used_ids") { visibility = [ ":*" ] + sources = [ "used_ids.h" ] + deps = [ + "../api:rtp_parameters", + "../media:rtc_media_base", + "../rtc_base:checks", + "../rtc_base:logging", + ] } rtc_source_set("video_track_source_proxy") { visibility = [ ":*" ] @@ -769,6 +799,7 @@ rtc_source_set("rtc_stats_collector") { "rtc_stats_collector.h", ] deps = [ + ":channel_interface", ":data_channel_utils", ":peer_connection_internal", ":rtc_pc_base", @@ -838,9 +869,11 @@ rtc_source_set("sdp_offer_answer") { "sdp_offer_answer.h", # dependent on peerconnection.h ] deps = [ + ":channel_interface", ":connection_context", ":data_channel_controller", ":data_channel_utils", + ":dtls_transport", ":ice_server_parsing", ":media_stream", ":media_stream_observer", @@ -927,9 +960,11 @@ rtc_source_set("peer_connection") { "peer_connection.h", ] deps = [ + ":channel_interface", ":connection_context", ":data_channel_controller", ":data_channel_utils", + ":dtls_transport", ":ice_server_parsing", ":peer_connection_internal", ":peer_connection_message_handler", @@ -1044,6 +1079,7 @@ rtc_source_set("stats_collector") { "stats_collector.h", ] deps = [ + ":channel_interface", ":data_channel_utils", ":peer_connection_internal", ":rtc_pc_base", @@ -1306,6 +1342,7 @@ rtc_library("rtp_transceiver") { "rtp_transceiver.h", ] deps = [ + ":channel_interface", ":proxy", ":rtc_pc_base", ":rtp_media_utils", @@ -1796,6 +1833,7 @@ if (rtc_include_tests && !build_with_chromium) { deps = [ ":audio_rtp_receiver", + ":dtls_transport", ":ice_transport", ":libjingle_peerconnection", ":media_protocol_names", @@ -1808,6 +1846,7 @@ if (rtc_include_tests && !build_with_chromium) { ":rtp_transport_internal", ":session_description", ":srtp_filter", + ":used_ids", ":video_rtp_receiver", "../api:array_view", "../api:audio_options_api", @@ -1982,6 +2021,8 @@ if (rtc_include_tests && !build_with_chromium) { deps = [ ":audio_rtp_receiver", ":audio_track", + ":channel_interface", + ":dtls_transport", ":dtmf_sender", ":ice_server_parsing", ":integration_test_helpers", @@ -2311,6 +2352,7 @@ if (rtc_include_tests && !build_with_chromium) { ] deps = [ + ":channel_interface", ":jitter_buffer_delay", ":libjingle_peerconnection", ":peer_connection_internal", From 9848890590b0d619a421b6c03fa7cd70edc9be18 Mon Sep 17 00:00:00 2001 From: Victor Boivie Date: Thu, 10 Mar 2022 20:25:10 +0100 Subject: [PATCH 162/847] dcsctp: Remove handover_state from RRSendQueue It's not used as a constructor parameter, but instead invoked by calling RestoreFromState. Removing this parameter avoids confusion. Bug: None Change-Id: I3bb8a0135808e3ae010be6d37439513517f71832 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254820 Auto-Submit: Victor Boivie Reviewed-by: Sergey Sukhanov Commit-Queue: Sergey Sukhanov Cr-Commit-Position: refs/heads/main@{#36188} --- net/dcsctp/tx/rr_send_queue.cc | 3 +-- net/dcsctp/tx/rr_send_queue.h | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/net/dcsctp/tx/rr_send_queue.cc b/net/dcsctp/tx/rr_send_queue.cc index a20ccb2448..f8f5ff2946 100644 --- a/net/dcsctp/tx/rr_send_queue.cc +++ b/net/dcsctp/tx/rr_send_queue.cc @@ -32,8 +32,7 @@ RRSendQueue::RRSendQueue(absl::string_view log_prefix, size_t buffer_size, std::function on_buffered_amount_low, size_t total_buffered_amount_low_threshold, - std::function on_total_buffered_amount_low, - const DcSctpSocketHandoverState* handover_state) + std::function on_total_buffered_amount_low) : log_prefix_(std::string(log_prefix) + "fcfs: "), buffer_size_(buffer_size), on_buffered_amount_low_(std::move(on_buffered_amount_low)), diff --git a/net/dcsctp/tx/rr_send_queue.h b/net/dcsctp/tx/rr_send_queue.h index 3007cd0fe8..fecb6e0f2e 100644 --- a/net/dcsctp/tx/rr_send_queue.h +++ b/net/dcsctp/tx/rr_send_queue.h @@ -47,8 +47,7 @@ class RRSendQueue : public SendQueue { size_t buffer_size, std::function on_buffered_amount_low, size_t total_buffered_amount_low_threshold, - std::function on_total_buffered_amount_low, - const DcSctpSocketHandoverState* handover_state = nullptr); + std::function on_total_buffered_amount_low); // Indicates if the buffer is full. Note that it's up to the caller to ensure // that the buffer is not full prior to adding new items to it. From 6364d0899e495eb6d6c1dc70a7bf65f7cd3d1fb2 Mon Sep 17 00:00:00 2001 From: Ali Tofigh Date: Mon, 14 Mar 2022 13:32:04 +0100 Subject: [PATCH 163/847] Adopt absl::string_view in rtc_base/log_sinks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is part of a large scale effort to increase adoption of absl::string_view across the WebRTC code base. This CL adds absl::string_view versions of the OnLogMessage functions in rtc::LogSink. The const std::string& versions are kept for now since downstream clients use subclasses of LogSink and need to be migrated before these are removed. Bug: webrtc:13579 Change-Id: I57bb72ad503805ff0ca16f1d7aece2d44c65cb73 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253980 Reviewed-by: Harald Alvestrand Reviewed-by: Xavier Lepaul‎ Owners-Override: Xavier Lepaul‎ Commit-Queue: Ali Tofigh Cr-Commit-Position: refs/heads/main@{#36189} --- call/BUILD.gn | 1 + call/bitrate_estimator_tests.cc | 13 +++++++++---- rtc_base/BUILD.gn | 1 + rtc_base/log_sinks.cc | 11 ++++++++--- rtc_base/log_sinks.h | 4 +++- rtc_base/logging.cc | 17 +++++++++++++++++ rtc_base/logging.h | 7 +++++++ rtc_base/logging_unittest.cc | 6 +++++- sdk/BUILD.gn | 5 +++++ sdk/android/BUILD.gn | 7 ++++++- .../stacktrace/stacktrace_unittest.cc | 4 ++++ sdk/android/src/jni/logging/log_sink.cc | 19 +++++++++++++------ sdk/android/src/jni/logging/log_sink.h | 6 +++++- sdk/objc/api/logging/RTCCallbackLogger.mm | 15 +++++++++++---- sdk/objc/helpers/NSString+StdString.h | 8 ++++++++ sdk/objc/helpers/NSString+StdString.mm | 12 ++++++++++++ 16 files changed, 115 insertions(+), 21 deletions(-) diff --git a/call/BUILD.gn b/call/BUILD.gn index 1bba3d7410..cb85febcaf 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -506,6 +506,7 @@ if (rtc_include_tests) { absl_deps = [ "//third_party/abseil-cpp/absl/container:inlined_vector", "//third_party/abseil-cpp/absl/memory", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:variant", ] diff --git a/call/bitrate_estimator_tests.cc b/call/bitrate_estimator_tests.cc index 4634f6e147..424cf0b038 100644 --- a/call/bitrate_estimator_tests.cc +++ b/call/bitrate_estimator_tests.cc @@ -12,6 +12,7 @@ #include #include +#include "absl/strings/string_view.h" #include "api/test/create_frame_generator.h" #include "call/call.h" #include "call/fake_network_pipe.h" @@ -50,13 +51,17 @@ class LogObserver { class Callback : public rtc::LogSink { public: void OnLogMessage(const std::string& message) override { + OnLogMessage(absl::string_view(message)); + } + + void OnLogMessage(absl::string_view message) override { MutexLock lock(&mutex_); // Ignore log lines that are due to missing AST extensions, these are // logged when we switch back from AST to TOF until the wrapping bitrate // estimator gives up on using AST. - if (message.find("BitrateEstimator") != std::string::npos && - message.find("packet is missing") == std::string::npos) { - received_log_lines_.push_back(message); + if (message.find("BitrateEstimator") != absl::string_view::npos && + message.find("packet is missing") == absl::string_view::npos) { + received_log_lines_.push_back(std::string(message)); } int num_popped = 0; @@ -66,7 +71,7 @@ class LogObserver { received_log_lines_.pop_front(); expected_log_lines_.pop_front(); num_popped++; - EXPECT_TRUE(a.find(b) != std::string::npos) << a << " != " << b; + EXPECT_TRUE(a.find(b) != absl::string_view::npos) << a << " != " << b; } if (expected_log_lines_.empty()) { if (num_popped > 0) { diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn index 0cac2a4f2b..1db186c0fc 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -1422,6 +1422,7 @@ if (rtc_include_tests) { "//third_party/abseil-cpp/absl/base:core_headers", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/numeric:bits", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/rtc_base/log_sinks.cc b/rtc_base/log_sinks.cc index 4365142517..b237e873ee 100644 --- a/rtc_base/log_sinks.cc +++ b/rtc_base/log_sinks.cc @@ -15,6 +15,7 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/checks.h" namespace rtc { @@ -36,14 +37,18 @@ FileRotatingLogSink::FileRotatingLogSink(FileRotatingStream* stream) FileRotatingLogSink::~FileRotatingLogSink() {} void FileRotatingLogSink::OnLogMessage(const std::string& message) { + OnLogMessage(absl::string_view(message)); +} + +void FileRotatingLogSink::OnLogMessage(absl::string_view message) { if (!stream_->IsOpen()) { std::fprintf(stderr, "Init() must be called before adding this sink.\n"); return; } - stream_->Write(message.c_str(), message.size()); + stream_->Write(message.data(), message.size()); } -void FileRotatingLogSink::OnLogMessage(const std::string& message, +void FileRotatingLogSink::OnLogMessage(absl::string_view message, LoggingSeverity sev, const char* tag) { if (!stream_->IsOpen()) { @@ -52,7 +57,7 @@ void FileRotatingLogSink::OnLogMessage(const std::string& message, } stream_->Write(tag, strlen(tag)); stream_->Write(": ", 2); - stream_->Write(message.c_str(), message.size()); + stream_->Write(message.data(), message.size()); } bool FileRotatingLogSink::Init() { diff --git a/rtc_base/log_sinks.h b/rtc_base/log_sinks.h index d2c286a86a..da339a54f1 100644 --- a/rtc_base/log_sinks.h +++ b/rtc_base/log_sinks.h @@ -16,6 +16,7 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/file_rotating_stream.h" #include "rtc_base/logging.h" @@ -39,7 +40,8 @@ class FileRotatingLogSink : public LogSink { // Writes the message to the current file. It will spill over to the next // file if needed. void OnLogMessage(const std::string& message) override; - void OnLogMessage(const std::string& message, + void OnLogMessage(absl::string_view message) override; + void OnLogMessage(absl::string_view message, LoggingSeverity sev, const char* tag) override; diff --git a/rtc_base/logging.cc b/rtc_base/logging.cc index 2b5c80b33c..102c1d1c70 100644 --- a/rtc_base/logging.cc +++ b/rtc_base/logging.cc @@ -42,6 +42,7 @@ static const int kMaxLogLineSize = 1024 - 60; #include #include "absl/base/attributes.h" +#include "absl/strings/string_view.h" #include "rtc_base/checks.h" #include "rtc_base/platform_thread_types.h" #include "rtc_base/string_encode.h" @@ -563,4 +564,20 @@ void LogSink::OnLogMessage(const std::string& msg, LoggingSeverity /* severity */) { OnLogMessage(msg); } + +// Inefficient default implementation, override is recommended. +void LogSink::OnLogMessage(absl::string_view msg, + LoggingSeverity severity, + const char* tag) { + OnLogMessage(tag + (": " + std::string(msg)), severity); +} + +void LogSink::OnLogMessage(absl::string_view msg, + LoggingSeverity /* severity */) { + OnLogMessage(msg); +} + +void LogSink::OnLogMessage(absl::string_view msg) { + OnLogMessage(std::string(msg)); +} } // namespace rtc diff --git a/rtc_base/logging.h b/rtc_base/logging.h index 8991f6f2b4..ee4d410bf4 100644 --- a/rtc_base/logging.h +++ b/rtc_base/logging.h @@ -112,6 +112,13 @@ class LogSink { LoggingSeverity severity); virtual void OnLogMessage(const std::string& message) = 0; + virtual void OnLogMessage(absl::string_view msg, + LoggingSeverity severity, + const char* tag); + virtual void OnLogMessage(absl::string_view message, + LoggingSeverity severity); + virtual void OnLogMessage(absl::string_view message); + private: friend class ::rtc::LogMessage; #if RTC_LOG_ENABLED() diff --git a/rtc_base/logging_unittest.cc b/rtc_base/logging_unittest.cc index dc1208f3f6..cd8d753fb3 100644 --- a/rtc_base/logging_unittest.cc +++ b/rtc_base/logging_unittest.cc @@ -16,6 +16,7 @@ #include +#include "absl/strings/string_view.h" #include "rtc_base/arraysize.h" #include "rtc_base/checks.h" #include "rtc_base/event.h" @@ -34,7 +35,10 @@ class LogSinkImpl : public LogSink { private: void OnLogMessage(const std::string& message) override { - log_data_->append(message); + OnLogMessage(absl::string_view(message)); + } + void OnLogMessage(absl::string_view message) override { + log_data_->append(message.begin(), message.end()); } std::string* const log_data_; }; diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn index 718d9274a1..a5c7d47579 100644 --- a/sdk/BUILD.gn +++ b/sdk/BUILD.gn @@ -149,6 +149,8 @@ if (is_ios || is_mac) { "../rtc_base:checks", ] + absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] + frameworks = [ "AVFoundation.framework", "CoreMedia.framework", @@ -180,6 +182,7 @@ if (is_ios || is_mac) { deps = [ ":base_objc", + ":helpers_objc", "../rtc_base", "../rtc_base:checks", "../rtc_base:logging", @@ -189,6 +192,8 @@ if (is_ios || is_mac) { "..:common_objc", ":used_from_extension", ] + + absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } rtc_library("file_logger_objc") { diff --git a/sdk/android/BUILD.gn b/sdk/android/BUILD.gn index 7bc30509c4..f81d3d5806 100644 --- a/sdk/android/BUILD.gn +++ b/sdk/android/BUILD.gn @@ -1137,6 +1137,8 @@ if (current_os == "linux" || is_android) { ":native_api_jni", "../../rtc_base", ] + + absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } rtc_library("audio_device_module_base") { @@ -1620,7 +1622,10 @@ if (is_android) { "../../test:test_support", "../../testing/gtest", ] - absl_deps = [ "//third_party/abseil-cpp/absl/memory" ] + absl_deps = [ + "//third_party/abseil-cpp/absl/memory", + "//third_party/abseil-cpp/absl/strings", + ] } rtc_android_library("native_unittests_java") { diff --git a/sdk/android/native_unittests/stacktrace/stacktrace_unittest.cc b/sdk/android/native_unittests/stacktrace/stacktrace_unittest.cc index b77d86719f..5cbd4aafe1 100644 --- a/sdk/android/native_unittests/stacktrace/stacktrace_unittest.cc +++ b/sdk/android/native_unittests/stacktrace/stacktrace_unittest.cc @@ -16,6 +16,7 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/event.h" #include "rtc_base/logging.h" #include "rtc_base/platform_thread.h" @@ -201,6 +202,9 @@ class LookoutLogSink final : public rtc::LogSink { explicit LookoutLogSink(std::string look_for) : look_for_(std::move(look_for)) {} void OnLogMessage(const std::string& message) override { + OnLogMessage(absl::string_view(message)); + } + void OnLogMessage(absl::string_view message) override { if (message.find(look_for_) != std::string::npos) { when_found_.Set(); } diff --git a/sdk/android/src/jni/logging/log_sink.cc b/sdk/android/src/jni/logging/log_sink.cc index cebc8669be..84394d8ee5 100644 --- a/sdk/android/src/jni/logging/log_sink.cc +++ b/sdk/android/src/jni/logging/log_sink.cc @@ -9,6 +9,7 @@ */ #include "sdk/android/src/jni/logging/log_sink.h" +#include "absl/strings/string_view.h" #include "sdk/android/generated_logging_jni/JNILogging_jni.h" namespace webrtc { @@ -18,17 +19,23 @@ JNILogSink::JNILogSink(JNIEnv* env, const JavaRef& j_logging) : j_logging_(env, j_logging) {} JNILogSink::~JNILogSink() = default; +void JNILogSink::OnLogMessage(const std::string& msg) { + RTC_DCHECK_NOTREACHED(); +} + void JNILogSink::OnLogMessage(const std::string& msg, rtc::LoggingSeverity severity, const char* tag) { - JNIEnv* env = AttachCurrentThreadIfNeeded(); - Java_JNILogging_logToInjectable(env, j_logging_, NativeToJavaString(env, msg), - NativeToJavaInteger(env, severity), - NativeToJavaString(env, tag)); + OnLogMessage(absl::string_view{msg}, severity, tag); } -void JNILogSink::OnLogMessage(const std::string& msg) { - RTC_DCHECK_NOTREACHED(); +void JNILogSink::OnLogMessage(absl::string_view msg, + rtc::LoggingSeverity severity, + const char* tag) { + JNIEnv* env = AttachCurrentThreadIfNeeded(); + Java_JNILogging_logToInjectable( + env, j_logging_, NativeToJavaString(env, std::string(msg)), + NativeToJavaInteger(env, severity), NativeToJavaString(env, tag)); } } // namespace jni diff --git a/sdk/android/src/jni/logging/log_sink.h b/sdk/android/src/jni/logging/log_sink.h index e48b88dcb7..8e681ac3ea 100644 --- a/sdk/android/src/jni/logging/log_sink.h +++ b/sdk/android/src/jni/logging/log_sink.h @@ -12,6 +12,7 @@ #include +#include "absl/strings/string_view.h" #include "rtc_base/logging.h" #include "sdk/android/native_api/jni/java_types.h" #include "sdk/android/src/jni/jni_helpers.h" @@ -24,10 +25,13 @@ class JNILogSink : public rtc::LogSink { JNILogSink(JNIEnv* env, const JavaRef& j_logging); ~JNILogSink() override; + void OnLogMessage(const std::string& msg) override; void OnLogMessage(const std::string& msg, rtc::LoggingSeverity severity, const char* tag) override; - void OnLogMessage(const std::string& msg) override; + void OnLogMessage(absl::string_view msg, + rtc::LoggingSeverity severity, + const char* tag) override; private: const ScopedJavaGlobalRef j_logging_; diff --git a/sdk/objc/api/logging/RTCCallbackLogger.mm b/sdk/objc/api/logging/RTCCallbackLogger.mm index 12cedd6c50..90bb8b0238 100644 --- a/sdk/objc/api/logging/RTCCallbackLogger.mm +++ b/sdk/objc/api/logging/RTCCallbackLogger.mm @@ -10,8 +10,11 @@ #import "RTCCallbackLogger.h" +#import "helpers/NSString+StdString.h" + #include +#include "absl/strings/string_view.h" #include "rtc_base/checks.h" #include "rtc_base/log_sinks.h" #include "rtc_base/logging.h" @@ -21,9 +24,13 @@ CallbackLogSink(RTCCallbackLoggerMessageHandler callbackHandler) : callback_handler_(callbackHandler) {} - void OnLogMessage(const std::string &message) override { + void OnLogMessage(const std::string& message) override { + OnLogMessage(absl::string_view(message)); + } + + void OnLogMessage(absl::string_view message) override { if (callback_handler_) { - callback_handler_([NSString stringWithUTF8String:message.c_str()]); + callback_handler_([NSString stringForAbslStringView:message]); } } @@ -38,10 +45,10 @@ void OnLogMessage(const std::string &message) override { void OnLogMessage(const std::string& message) override { RTC_DCHECK_NOTREACHED(); } - void OnLogMessage(const std::string& message, rtc::LoggingSeverity severity) override { + void OnLogMessage(absl::string_view message, rtc::LoggingSeverity severity) override { if (callback_handler_) { RTCLoggingSeverity loggingSeverity = NativeSeverityToObjcSeverity(severity); - callback_handler_([NSString stringWithUTF8String:message.c_str()], loggingSeverity); + callback_handler_([NSString stringForAbslStringView:message], loggingSeverity); } } diff --git a/sdk/objc/helpers/NSString+StdString.h b/sdk/objc/helpers/NSString+StdString.h index 7f51a9f3c6..b0324e8a19 100644 --- a/sdk/objc/helpers/NSString+StdString.h +++ b/sdk/objc/helpers/NSString+StdString.h @@ -12,6 +12,8 @@ #include +#include "absl/strings/string_view.h" + NS_ASSUME_NONNULL_BEGIN @interface NSString (StdString) @@ -23,4 +25,10 @@ NS_ASSUME_NONNULL_BEGIN @end +@interface NSString (AbslStringView) + ++ (NSString *)stringForAbslStringView:(const absl::string_view)abslStringView; + +@end + NS_ASSUME_NONNULL_END diff --git a/sdk/objc/helpers/NSString+StdString.mm b/sdk/objc/helpers/NSString+StdString.mm index 3210ff0b65..c98432c445 100644 --- a/sdk/objc/helpers/NSString+StdString.mm +++ b/sdk/objc/helpers/NSString+StdString.mm @@ -10,6 +10,8 @@ #import "NSString+StdString.h" +#include "absl/strings/string_view.h" + @implementation NSString (StdString) - (std::string)stdString { @@ -31,3 +33,13 @@ + (NSString *)stringForStdString:(const std::string&)stdString { } @end + +@implementation NSString (AbslStringView) + ++ (NSString *)stringForAbslStringView:(const absl::string_view)abslStringView { + return [[NSString alloc] initWithBytes:abslStringView.data() + length:abslStringView.length() + encoding:NSUTF8StringEncoding]; +} + +@end From e8193a9a13b155e2b42abca9ebd66c7bddea8db9 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Mon, 14 Mar 2022 05:02:47 -0700 Subject: [PATCH 164/847] Roll chromium_revision 12c232c43c..4f72619488 (980233:980515) Change log: https://chromium.googlesource.com/chromium/src/+log/12c232c43c..4f72619488 Full diff: https://chromium.googlesource.com/chromium/src/+/12c232c43c..4f72619488 Changed dependencies * src/build: https://chromium.googlesource.com/chromium/src/build/+log/525877587b..82ef032bfe * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/3b07d3ead2..95c966f7bb * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/f308ae6b5a..8d87ad3d0d * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/bb65cc1299..e6b922054b * src/third_party/androidx: s4aBuB5ULb4MMqBp4Xevo2Tf9qk_S5FxWr2xxansx68C..ZJtaPdQCjPuFTWcnohOdVfeuiXsz-eBjuMh0ZEu8CSgC * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/271796d312..b326cacd0e * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/ed445842ba..12c1fdb525 DEPS diff: https://chromium.googlesource.com/chromium/src/+/12c232c43c..4f72619488/DEPS No update to Clang. BUG=None Change-Id: I26dd522b7d029e8d5f47d61b8b349c5eb74f5b04 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255286 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36190} --- DEPS | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/DEPS b/DEPS index c8eb3ae1cc..01051d18e8 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': '12c232c43ce7324d308afab5349b38b7707d8226', + 'chromium_revision': '4f726194886f36cc5161288634935240be541e06', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -25,7 +25,7 @@ deps = { 'src/base': 'https://chromium.googlesource.com/chromium/src/base@3da6de3d00316c4563c2aa8e113c9c8b32a67bc6', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@525877587b3e153035256c724ce94d31980f28d1', + 'https://chromium.googlesource.com/chromium/src/build@82ef032bfe6e6661a774ff0d74b74b6e040bff73', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@113dd1badbcbffea108a8c95ac7c89c22bfd25f3', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@3b07d3ead212da6cc923987210919ce54624db4c', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@95c966f7bba0b3e5474b8522b404d815b6121e3b', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@f308ae6b5aed3e4c2a90c63d846b57178c0bea08', + 'https://chromium.googlesource.com/chromium/src/testing@8d87ad3d0dff1af42d07608e89399d6d36d367f3', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@bb65cc1299701b95d851268bee413d3353af45d9', + 'https://chromium.googlesource.com/chromium/src/third_party@e6b922054bf8d42d823c0641f83cbe72dbe4e97e', 'src/buildtools/linux64': { 'packages': [ @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@271796d312a4a2e751bd84da89e19aae3de1af20', + 'https://chromium.googlesource.com/catapult.git@b326cacd0ec11fef9b8ee9e68d4e9704f8010eb9', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@ed445842ba89ff12dd92148c3282a6a45e66c3bc', + 'https://chromium.googlesource.com/chromium/src/tools@12c1fdb5256c9704d75fb07365ba4ffb1a6f51b3', 'src/third_party/accessibility_test_framework': { 'packages': [ @@ -384,7 +384,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/androidx', - 'version': 's4aBuB5ULb4MMqBp4Xevo2Tf9qk_S5FxWr2xxansx68C', + 'version': 'ZJtaPdQCjPuFTWcnohOdVfeuiXsz-eBjuMh0ZEu8CSgC', }, ], 'condition': 'checkout_android', From 83240ac0bc75cd309b5867686359470a55693765 Mon Sep 17 00:00:00 2001 From: Mirko Bonadei Date: Mon, 14 Mar 2022 14:48:17 +0100 Subject: [PATCH 165/847] Only FindFullName should be injectable at link-time. When WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT is defined, only webrtc::field_trial::FindFullName should be defined at link time, the other functions should not be part of this interface. No-Try: True Bug: webrtc:10335 Change-Id: I81bcefcde6a51bcf8e410af91b5401f23e039d50 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255340 Reviewed-by: Ilya Nikolaevskiy Reviewed-by: Harald Alvestrand Commit-Queue: Mirko Bonadei Cr-Commit-Position: refs/heads/main@{#36191} --- system_wrappers/include/field_trial.h | 2 -- system_wrappers/source/field_trial.cc | 4 +--- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/system_wrappers/include/field_trial.h b/system_wrappers/include/field_trial.h index 52db33b0e9..48bad41d5c 100644 --- a/system_wrappers/include/field_trial.h +++ b/system_wrappers/include/field_trial.h @@ -84,7 +84,6 @@ void InitFieldTrialsFromString(const char* trials_string); const char* GetFieldTrialString(); -#ifndef WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT // Validates the given field trial string. bool FieldTrialsStringIsValid(const char* trials_string); @@ -94,7 +93,6 @@ bool FieldTrialsStringIsValid(const char* trials_string); // in 'second' takes precedence. // Shall only be called with valid FieldTrial strings. std::string MergeFieldTrialsStrings(const char* first, const char* second); -#endif // WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT } // namespace field_trial } // namespace webrtc diff --git a/system_wrappers/source/field_trial.cc b/system_wrappers/source/field_trial.cc index d16ea7e03f..8e447907d7 100644 --- a/system_wrappers/source/field_trial.cc +++ b/system_wrappers/source/field_trial.cc @@ -26,7 +26,6 @@ namespace field_trial { static const char* trials_init_string = NULL; -#ifndef WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT namespace { constexpr char kPersistentStringSeparator = '/'; // Validates the given field trial string. @@ -102,6 +101,7 @@ std::string MergeFieldTrialsStrings(const char* first, const char* second) { return merged; } +#ifndef WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT std::string FindFullName(const std::string& name) { if (trials_init_string == NULL) return std::string(); @@ -138,12 +138,10 @@ std::string FindFullName(const std::string& name) { // Optionally initialize field trial from a string. void InitFieldTrialsFromString(const char* trials_string) { RTC_LOG(LS_INFO) << "Setting field trial string:" << trials_string; -#ifndef WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT if (trials_string) { RTC_DCHECK(FieldTrialsStringIsValidInternal(trials_string)) << "Invalid field trials string:" << trials_string; }; -#endif // WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT trials_init_string = trials_string; } From 8ca06137dcb6372162f2c1add9c6ce27f6beae46 Mon Sep 17 00:00:00 2001 From: Jonas Oreland Date: Mon, 14 Mar 2022 12:52:48 +0100 Subject: [PATCH 166/847] WebRTC-DeprecateGlobalFieldTrialString/Enabled/ - part 4/inf convert almost all of video/ (and the collateral) Bug: webrtc:10335 Change-Id: Ic94e05937f54d11ee8a635b6b66fd146962d9f11 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254601 Reviewed-by: Harald Alvestrand Commit-Queue: Jonas Oreland Cr-Commit-Position: refs/heads/main@{#36192} --- call/call_perf_tests.cc | 4 +- call/rtp_video_sender_unittest.cc | 3 +- media/BUILD.gn | 1 + media/engine/fake_webrtc_call.cc | 10 +- media/engine/fake_webrtc_call.h | 24 +++- media/engine/webrtc_video_engine_unittest.cc | 78 +++++------- media/engine/webrtc_voice_engine_unittest.cc | 4 +- test/BUILD.gn | 1 + test/call_test.h | 4 +- test/scoped_key_value_config.cc | 7 +- video/BUILD.gn | 5 + .../video_stream_encoder_resource_manager.cc | 8 +- .../video_stream_encoder_resource_manager.h | 1 + video/buffered_frame_decryptor.cc | 5 +- video/buffered_frame_decryptor.h | 5 +- video/buffered_frame_decryptor_unittest.cc | 4 +- .../extended_reports_tests.cc | 3 +- video/end_to_end_tests/multi_stream_tester.cc | 2 +- video/frame_buffer_proxy.cc | 22 ++-- video/frame_buffer_proxy.h | 4 +- video/frame_buffer_proxy_unittest.cc | 18 +-- video/frame_cadence_adapter.cc | 19 +-- video/frame_cadence_adapter.h | 4 +- video/frame_cadence_adapter_unittest.cc | 80 +++++++----- video/quality_scaling_tests.cc | 114 +++++++++++------- video/receive_statistics_proxy.cc | 17 ++- video/receive_statistics_proxy.h | 5 +- video/receive_statistics_proxy2.cc | 11 +- video/receive_statistics_proxy2.h | 4 +- video/receive_statistics_proxy2_unittest.cc | 27 ++--- video/receive_statistics_proxy_unittest.cc | 31 ++--- video/rtp_video_stream_receiver.cc | 29 +++-- video/rtp_video_stream_receiver.h | 10 +- video/rtp_video_stream_receiver2.cc | 22 ++-- video/rtp_video_stream_receiver2.h | 4 +- video/rtp_video_stream_receiver2_unittest.cc | 12 +- video/rtp_video_stream_receiver_unittest.cc | 11 +- video/send_statistics_proxy.cc | 22 ++-- video/send_statistics_proxy.h | 4 +- video/send_statistics_proxy_unittest.cc | 41 ++++--- video/video_receive_stream2.cc | 28 +++-- video/video_receive_stream2.h | 1 + video/video_receive_stream2_unittest.cc | 20 +-- video/video_send_stream.cc | 30 ++--- video/video_send_stream_impl.cc | 9 +- video/video_send_stream_impl.h | 6 +- video/video_send_stream_impl_unittest.cc | 12 +- video/video_send_stream_tests.cc | 17 ++- video/video_stream_encoder.cc | 16 +-- video/video_stream_encoder.h | 1 + video/video_stream_encoder_unittest.cc | 21 ++-- 51 files changed, 477 insertions(+), 364 deletions(-) diff --git a/call/call_perf_tests.cc b/call/call_perf_tests.cc index f4a20b82fe..6acebf2bb7 100644 --- a/call/call_perf_tests.cc +++ b/call/call_perf_tests.cc @@ -766,8 +766,8 @@ TEST_F(CallPerfTest, MAYBE_KeepsHighBitrateWhenReconfiguringSender) { // We get lower bitrate than expected by this test if the following field // trial is enabled. - test::ScopedFieldTrials field_trials( - "WebRTC-SendSideBwe-WithOverhead/Disabled/"); + test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-SendSideBwe-WithOverhead/Disabled/"); class VideoStreamFactory : public VideoEncoderConfig::VideoStreamFactoryInterface { diff --git a/call/rtp_video_sender_unittest.cc b/call/rtp_video_sender_unittest.cc index 2f2ffb0446..7c7d005fa6 100644 --- a/call/rtp_video_sender_unittest.cc +++ b/call/rtp_video_sender_unittest.cc @@ -138,7 +138,8 @@ class RtpVideoSenderTestFixture { field_trials ? field_trials : &field_trials_), stats_proxy_(time_controller_.GetClock(), config_, - VideoEncoderConfig::ContentType::kRealtimeVideo), + VideoEncoderConfig::ContentType::kRealtimeVideo, + field_trials ? *field_trials : field_trials_), retransmission_rate_limiter_(time_controller_.GetClock(), kRetransmitWindowSizeMs) { transport_controller_.EnsureStarted(); diff --git a/media/BUILD.gn b/media/BUILD.gn index 8729168da5..b9d92089af 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -525,6 +525,7 @@ if (rtc_include_tests) { "../rtc_base:threading", "../rtc_base/synchronization:mutex", "../rtc_base/third_party/sigslot", + "../test:scoped_key_value_config", "../test:test_support", "//testing/gtest", ] diff --git a/media/engine/fake_webrtc_call.cc b/media/engine/fake_webrtc_call.cc index 7b9174d961..2f6efd6276 100644 --- a/media/engine/fake_webrtc_call.cc +++ b/media/engine/fake_webrtc_call.cc @@ -416,17 +416,19 @@ void FakeFlexfecReceiveStream::OnRtpPacket(const webrtc::RtpPacketReceived&) { RTC_DCHECK_NOTREACHED() << "Not implemented."; } -FakeCall::FakeCall() - : FakeCall(rtc::Thread::Current(), rtc::Thread::Current()) {} +FakeCall::FakeCall(webrtc::test::ScopedKeyValueConfig* field_trials) + : FakeCall(rtc::Thread::Current(), rtc::Thread::Current(), field_trials) {} FakeCall::FakeCall(webrtc::TaskQueueBase* worker_thread, - webrtc::TaskQueueBase* network_thread) + webrtc::TaskQueueBase* network_thread, + webrtc::test::ScopedKeyValueConfig* field_trials) : network_thread_(network_thread), worker_thread_(worker_thread), audio_network_state_(webrtc::kNetworkUp), video_network_state_(webrtc::kNetworkUp), num_created_send_streams_(0), - num_created_receive_streams_(0) {} + num_created_receive_streams_(0), + trials_(field_trials ? field_trials : &fallback_trials_) {} FakeCall::~FakeCall() { EXPECT_EQ(0u, video_send_streams_.size()); diff --git a/media/engine/fake_webrtc_call.h b/media/engine/fake_webrtc_call.h index b84c385b9c..96d881bb08 100644 --- a/media/engine/fake_webrtc_call.h +++ b/media/engine/fake_webrtc_call.h @@ -36,6 +36,7 @@ #include "call/video_send_stream.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" #include "rtc_base/buffer.h" +#include "test/scoped_key_value_config.h" namespace cricket { class FakeAudioSendStream final : public webrtc::AudioSendStream { @@ -313,9 +314,10 @@ class FakeFlexfecReceiveStream final : public webrtc::FlexfecReceiveStream { class FakeCall final : public webrtc::Call, public webrtc::PacketReceiver { public: - FakeCall(); + explicit FakeCall(webrtc::test::ScopedKeyValueConfig* field_trials = nullptr); FakeCall(webrtc::TaskQueueBase* worker_thread, - webrtc::TaskQueueBase* network_thread); + webrtc::TaskQueueBase* network_thread, + webrtc::test::ScopedKeyValueConfig* field_trials = nullptr); ~FakeCall() override; webrtc::MockRtpTransportControllerSend* GetMockTransportControllerSend() { @@ -353,6 +355,11 @@ class FakeCall final : public webrtc::Call, public webrtc::PacketReceiver { void SetClientBitratePreferences( const webrtc::BitrateSettings& preferences) override {} + void SetFieldTrial(const std::string& field_trial_string) { + trials_overrides_ = std::make_unique( + *trials_, field_trial_string); + } + private: webrtc::AudioSendStream* CreateAudioSendStream( const webrtc::AudioSendStream::Config& config) override; @@ -395,7 +402,7 @@ class FakeCall final : public webrtc::Call, public webrtc::PacketReceiver { webrtc::Call::Stats GetStats() const override; const webrtc::WebRtcKeyValueConfig& trials() const override { - return trials_; + return *trials_; } webrtc::TaskQueueBase* network_thread() const override; @@ -432,7 +439,16 @@ class FakeCall final : public webrtc::Call, public webrtc::PacketReceiver { int num_created_send_streams_; int num_created_receive_streams_; - webrtc::FieldTrialBasedConfig trials_; + + // The field trials that are in use, either supplied by caller + // or pointer to &fallback_trials_. + webrtc::test::ScopedKeyValueConfig* trials_; + + // fallback_trials_ is used if caller does not provide any field trials. + webrtc::test::ScopedKeyValueConfig fallback_trials_; + + // An extra field trial that can be set using SetFieldTrial. + std::unique_ptr trials_overrides_; }; } // namespace cricket diff --git a/media/engine/webrtc_video_engine_unittest.cc b/media/engine/webrtc_video_engine_unittest.cc index ab9ad1aab6..0c6c1695c8 100644 --- a/media/engine/webrtc_video_engine_unittest.cc +++ b/media/engine/webrtc_video_engine_unittest.cc @@ -1731,6 +1731,7 @@ class WebRtcVideoChannelBaseTest : public ::testing::Test { webrtc::RtcEventLogNull event_log_; webrtc::test::ScopedKeyValueConfig field_trials_; + std::unique_ptr override_field_trials_; std::unique_ptr task_queue_factory_; std::unique_ptr call_; std::unique_ptr @@ -1785,7 +1786,7 @@ TEST_F(WebRtcVideoChannelBaseTest, OverridesRecvBufferSize) { // Set field trial to override the default recv buffer size, and then re-run // setup where the interface is created and configured. const int kCustomRecvBufferSize = 123456; - webrtc::test::ScopedKeyValueConfig override_field_trials( + override_field_trials_ = std::make_unique( field_trials_, "WebRTC-IncreasedReceivebuffers/123456/"); ResetTest(); @@ -1802,7 +1803,7 @@ TEST_F(WebRtcVideoChannelBaseTest, OverridesRecvBufferSizeWithSuffix) { // Set field trial to override the default recv buffer size, and then re-run // setup where the interface is created and configured. const int kCustomRecvBufferSize = 123456; - webrtc::test::ScopedKeyValueConfig override_field_trials( + override_field_trials_ = std::make_unique( field_trials_, "WebRTC-IncreasedReceivebuffers/123456_Dogfood/"); ResetTest(); @@ -1812,54 +1813,32 @@ TEST_F(WebRtcVideoChannelBaseTest, OverridesRecvBufferSizeWithSuffix) { EXPECT_EQ(kCustomRecvBufferSize, network_interface_.recvbuf_size()); } +class InvalidRecvBufferSizeFieldTrial + : public WebRtcVideoChannelBaseTest, + public ::testing::WithParamInterface {}; + // Test that we properly set the send and recv buffer sizes when overriding // via field trials that don't make any sense. -TEST_F(WebRtcVideoChannelBaseTest, InvalidRecvBufferSize) { +TEST_P(InvalidRecvBufferSizeFieldTrial, InvalidRecvBufferSize) { // Set bogus field trial values to override the default recv buffer size, and // then re-run setup where the interface is created and configured. The // default value should still be used. + override_field_trials_ = std::make_unique( + field_trials_, + std::string("WebRTC-IncreasedReceivebuffers/") + GetParam() + "/"); - std::string field_trial_string; - for (std::string group : {" ", "NotANumber", "-1", "0"}) { - std::string trial_string = "WebRTC-IncreasedReceivebuffers/"; - trial_string += group; - trial_string += "/"; - - // Dear reader. Sorry for this... it's a bit of a mess. - // TODO(bugs.webrtc.org/12854): This test needs to be rewritten to not use - // ResetTest and changing global field trials in a loop. - TearDown(); - // This is a hack to appease tsan. Because of the way the test is written - // active state within Call, including running task queues may race with - // the test changing the global field trial variable. - // This particular hack, pauses the transport controller TQ while we - // change the field trial. - rtc::TaskQueue* tq = call_->GetTransportControllerSend()->GetWorkerQueue(); - rtc::Event waiting, resume, conclude; - tq->PostTask([&waiting, &resume, &conclude]() { - waiting.Set(); - resume.Wait(rtc::Event::kForever); - conclude.Set(); - }); - - waiting.Wait(rtc::Event::kForever); - webrtc::test::ScopedKeyValueConfig field_trial_override(field_trials_, - trial_string); - - SetUp(); - resume.Set(); - // Ensure we don't cause a UAF as the test scope exits. - conclude.Wait(rtc::Event::kForever); - - // OK, now the test can carry on. + ResetTest(); - EXPECT_TRUE(SetOneCodec(DefaultCodec())); - EXPECT_TRUE(SetSend(true)); - EXPECT_EQ(64 * 1024, network_interface_.sendbuf_size()); - EXPECT_EQ(256 * 1024, network_interface_.recvbuf_size()); - } + EXPECT_TRUE(SetOneCodec(DefaultCodec())); + EXPECT_TRUE(SetSend(true)); + EXPECT_EQ(64 * 1024, network_interface_.sendbuf_size()); + EXPECT_EQ(256 * 1024, network_interface_.recvbuf_size()); } +INSTANTIATE_TEST_SUITE_P(All, + InvalidRecvBufferSizeFieldTrial, + Values("NotANumber", "-1", " ", "0")); + // Test that stats work properly for a 1-1 call. TEST_F(WebRtcVideoChannelBaseTest, GetStats) { const int kDurationSec = 3; @@ -2480,7 +2459,7 @@ class WebRtcVideoChannelTest : public WebRtcVideoEngineTest { AddSupportedVideoCodecType("H264"); #endif - fake_call_.reset(new FakeCall()); + fake_call_.reset(new FakeCall(&field_trials_)); channel_.reset(engine_.CreateMediaChannel( fake_call_.get(), GetMediaConfig(), VideoOptions(), webrtc::CryptoOptions(), video_bitrate_allocator_factory_.get())); @@ -2494,6 +2473,7 @@ class WebRtcVideoChannelTest : public WebRtcVideoEngineTest { void TearDown() override { channel_->SetInterface(nullptr); channel_ = nullptr; + fake_call_ = nullptr; } void ResetTest() { @@ -2932,8 +2912,8 @@ TEST_F(WebRtcVideoChannelTest, RecvAbsoluteSendTimeHeaderExtensions) { } TEST_F(WebRtcVideoChannelTest, FiltersExtensionsPicksTransportSeqNum) { - webrtc::test::ScopedFieldTrials override_field_trials( - "WebRTC-FilterAbsSendTimeExtension/Enabled/"); + webrtc::test::ScopedKeyValueConfig override_field_trials( + field_trials_, "WebRTC-FilterAbsSendTimeExtension/Enabled/"); // Enable three redundant extensions. std::vector extensions; extensions.push_back(RtpExtension::kAbsSendTimeUri); @@ -7400,8 +7380,8 @@ TEST_F(WebRtcVideoChannelTest, // so that the bottom layer has width and height divisible by 2. // TODO(bugs.webrtc.org/8785): Remove this field trial when we fully trust // the number of simulcast layers set by the app. - webrtc::test::ScopedFieldTrials field_trial( - "WebRTC-NormalizeSimulcastResolution/Enabled-3/"); + webrtc::test::ScopedKeyValueConfig field_trial( + field_trials_, "WebRTC-NormalizeSimulcastResolution/Enabled-3/"); // Set up WebRtcVideoChannel for 3-layer VP8 simulcast. VideoSendParameters parameters; @@ -7555,8 +7535,8 @@ TEST_F(WebRtcVideoChannelTest, // so that the bottom layer has width and height divisible by 2. // TODO(bugs.webrtc.org/8785): Remove this field trial when we fully trust // the number of simulcast layers set by the app. - webrtc::test::ScopedFieldTrials field_trial( - "WebRTC-NormalizeSimulcastResolution/Enabled-3/"); + webrtc::test::ScopedKeyValueConfig field_trial( + field_trials_, "WebRTC-NormalizeSimulcastResolution/Enabled-3/"); // Set up WebRtcVideoChannel for 3-layer H264 simulcast. encoder_factory_->AddSupportedVideoCodecType(kH264CodecName); @@ -8830,13 +8810,13 @@ class WebRtcVideoChannelSimulcastTest : public ::testing::Test { return streams[streams.size() - 1]; } + webrtc::test::ScopedKeyValueConfig field_trials_; webrtc::RtcEventLogNull event_log_; FakeCall fake_call_; cricket::FakeWebRtcVideoEncoderFactory* encoder_factory_; cricket::FakeWebRtcVideoDecoderFactory* decoder_factory_; std::unique_ptr mock_rate_allocator_factory_; - webrtc::test::ScopedKeyValueConfig field_trials_; WebRtcVideoEngine engine_; std::unique_ptr channel_; uint32_t last_ssrc_; diff --git a/media/engine/webrtc_voice_engine_unittest.cc b/media/engine/webrtc_voice_engine_unittest.cc index 9ff91f4ff6..6f938292bf 100644 --- a/media/engine/webrtc_voice_engine_unittest.cc +++ b/media/engine/webrtc_voice_engine_unittest.cc @@ -188,7 +188,7 @@ class WebRtcVoiceEngineTestFake : public ::testing::TestWithParam { ? nullptr : rtc::make_ref_counted< StrictMock>()), - call_() { + call_(&field_trials_) { // AudioDeviceModule. AdmSetupExpectations(adm_); @@ -787,6 +787,7 @@ class WebRtcVoiceEngineTestFake : public ::testing::TestWithParam { protected: const bool use_null_apm_; + webrtc::test::ScopedKeyValueConfig field_trials_; std::unique_ptr task_queue_factory_; rtc::scoped_refptr adm_; rtc::scoped_refptr> apm_; @@ -797,7 +798,6 @@ class WebRtcVoiceEngineTestFake : public ::testing::TestWithParam { cricket::AudioRecvParameters recv_parameters_; FakeAudioSource fake_source_; webrtc::AudioProcessing::Config apm_config_; - webrtc::test::ScopedKeyValueConfig field_trials_; }; INSTANTIATE_TEST_SUITE_P(TestBothWithAndWithoutNullApm, diff --git a/test/BUILD.gn b/test/BUILD.gn index a791878baa..ae0f3ba8d3 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -861,6 +861,7 @@ rtc_library("test_common") { ":fake_video_codecs", ":fileutils", ":mock_transport", + ":scoped_key_value_config", ":test_support", ":video_test_common", "../api:array_view", diff --git a/test/call_test.h b/test/call_test.h index adb21dd7f0..f1f29f60fb 100644 --- a/test/call_test.h +++ b/test/call_test.h @@ -21,7 +21,6 @@ #include "api/task_queue/task_queue_factory.h" #include "api/test/video/function_video_decoder_factory.h" #include "api/test/video/function_video_encoder_factory.h" -#include "api/transport/field_trial_based_config.h" #include "api/video/video_bitrate_allocator_factory.h" #include "call/call.h" #include "modules/audio_device/include/test_audio_device.h" @@ -32,6 +31,7 @@ #include "test/frame_generator_capturer.h" #include "test/rtp_rtcp_observer.h" #include "test/run_loop.h" +#include "test/scoped_key_value_config.h" namespace webrtc { namespace test { @@ -180,7 +180,7 @@ class CallTest : public ::testing::Test, public RtpPacketSinkInterface { test::RunLoop loop_; Clock* const clock_; - const FieldTrialBasedConfig field_trials_; + test::ScopedKeyValueConfig field_trials_; std::unique_ptr task_queue_factory_; std::unique_ptr send_event_log_; diff --git a/test/scoped_key_value_config.cc b/test/scoped_key_value_config.cc index fe3f42635d..723be22261 100644 --- a/test/scoped_key_value_config.cc +++ b/test/scoped_key_value_config.cc @@ -66,8 +66,11 @@ ScopedKeyValueConfig::ScopedKeyValueConfig(ScopedKeyValueConfig* parent, const std::string& s) : parent_(parent), leaf_(nullptr) { InsertIntoMap(key_value_map_, s); - // Also store field trials in global string (until we get rid of it). - scoped_field_trials_ = std::make_unique(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_. diff --git a/video/BUILD.gn b/video/BUILD.gn index 7e016af4c5..e290abe81d 100644 --- a/video/BUILD.gn +++ b/video/BUILD.gn @@ -171,8 +171,10 @@ rtc_source_set("video_legacy") { "../api:array_view", "../api:scoped_refptr", "../api:sequence_checker", + "../api:webrtc_key_value_config", "../api/crypto:frame_decryptor_interface", "../api/task_queue", + "../api/transport:field_trial_based_config", "../api/units:timestamp", "../api/video:encoded_image", "../api/video:recordable_encoded_frame", @@ -275,6 +277,7 @@ rtc_library("frame_cadence_adapter") { deps = [ "../api:sequence_checker", + "../api:webrtc_key_value_config", "../api/task_queue", "../api/units:time_delta", "../api/video:video_frame", @@ -307,6 +310,7 @@ rtc_library("frame_buffer_proxy") { ":task_queue_frame_decode_scheduler", ":video_receive_stream_timeout_tracker", "../api:sequence_checker", + "../api:webrtc_key_value_config", "../api/metronome", "../api/task_queue", "../api/units:data_size", @@ -952,6 +956,7 @@ if (rtc_include_tests) { "../test:field_trial", "../test:mock_frame_transformer", "../test:mock_transport", + "../test:scoped_key_value_config", "../test:test_support", ] absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] diff --git a/video/adaptation/video_stream_encoder_resource_manager.cc b/video/adaptation/video_stream_encoder_resource_manager.cc index cb2ab144ed..3b88ce5b1e 100644 --- a/video/adaptation/video_stream_encoder_resource_manager.cc +++ b/video/adaptation/video_stream_encoder_resource_manager.cc @@ -33,7 +33,6 @@ #include "rtc_base/strings/string_builder.h" #include "rtc_base/time_utils.h" #include "rtc_base/trace_event.h" -#include "system_wrappers/include/field_trial.h" #include "video/adaptation/quality_scaler_resource.h" namespace webrtc { @@ -268,7 +267,8 @@ VideoStreamEncoderResourceManager::VideoStreamEncoderResourceManager( std::unique_ptr overuse_detector, DegradationPreferenceProvider* degradation_preference_provider, const WebRtcKeyValueConfig& field_trials) - : degradation_preference_provider_(degradation_preference_provider), + : field_trials_(field_trials), + degradation_preference_provider_(degradation_preference_provider), bitrate_constraint_(std::make_unique()), balanced_constraint_( std::make_unique(degradation_preference_provider_, @@ -292,7 +292,7 @@ VideoStreamEncoderResourceManager::VideoStreamEncoderResourceManager( std::make_unique(quality_scaler_resource_)), quality_scaling_experiment_enabled_(QualityScalingExperiment::Enabled()), pixel_limit_resource_experiment_enabled_( - field_trial::IsEnabled(kPixelLimitResourceFieldTrialName)), + field_trials.IsEnabled(kPixelLimitResourceFieldTrialName)), encoder_target_bitrate_bps_(absl::nullopt), quality_rampup_experiment_( QualityRampUpExperimentHelper::CreateIfEnabled(this, clock_)), @@ -361,7 +361,7 @@ void VideoStreamEncoderResourceManager::MaybeInitializePixelLimitResource() { } int max_pixels = 0; std::string pixel_limit_field_trial = - field_trial::FindFullName(kPixelLimitResourceFieldTrialName); + field_trials_.Lookup(kPixelLimitResourceFieldTrialName); if (sscanf(pixel_limit_field_trial.c_str(), "Enabled-%d", &max_pixels) != 1) { RTC_LOG(LS_ERROR) << "Couldn't parse " << kPixelLimitResourceFieldTrialName << " trial config: " << pixel_limit_field_trial; diff --git a/video/adaptation/video_stream_encoder_resource_manager.h b/video/adaptation/video_stream_encoder_resource_manager.h index 223af4e801..c01be84472 100644 --- a/video/adaptation/video_stream_encoder_resource_manager.h +++ b/video/adaptation/video_stream_encoder_resource_manager.h @@ -183,6 +183,7 @@ class VideoStreamEncoderResourceManager const std::map& active_counts); + const WebRtcKeyValueConfig& field_trials_; DegradationPreferenceProvider* const degradation_preference_provider_; std::unique_ptr bitrate_constraint_ RTC_GUARDED_BY(encoder_queue_); diff --git a/video/buffered_frame_decryptor.cc b/video/buffered_frame_decryptor.cc index 27a3c4cfc4..fb4ea76ce0 100644 --- a/video/buffered_frame_decryptor.cc +++ b/video/buffered_frame_decryptor.cc @@ -22,9 +22,10 @@ namespace webrtc { BufferedFrameDecryptor::BufferedFrameDecryptor( OnDecryptedFrameCallback* decrypted_frame_callback, - OnDecryptionStatusChangeCallback* decryption_status_change_callback) + OnDecryptionStatusChangeCallback* decryption_status_change_callback, + const WebRtcKeyValueConfig& field_trials) : generic_descriptor_auth_experiment_( - !field_trial::IsDisabled("WebRTC-GenericDescriptorAuth")), + !field_trials.IsDisabled("WebRTC-GenericDescriptorAuth")), decrypted_frame_callback_(decrypted_frame_callback), decryption_status_change_callback_(decryption_status_change_callback) {} diff --git a/video/buffered_frame_decryptor.h b/video/buffered_frame_decryptor.h index f6dd8d8c2a..a12fc5d03a 100644 --- a/video/buffered_frame_decryptor.h +++ b/video/buffered_frame_decryptor.h @@ -16,6 +16,7 @@ #include "api/crypto/crypto_options.h" #include "api/crypto/frame_decryptor_interface.h" +#include "api/webrtc_key_value_config.h" #include "modules/video_coding/frame_object.h" namespace webrtc { @@ -57,7 +58,9 @@ class BufferedFrameDecryptor final { // Constructs a new BufferedFrameDecryptor that can hold explicit BufferedFrameDecryptor( OnDecryptedFrameCallback* decrypted_frame_callback, - OnDecryptionStatusChangeCallback* decryption_status_change_callback); + OnDecryptionStatusChangeCallback* decryption_status_change_callback, + const WebRtcKeyValueConfig& field_trials); + ~BufferedFrameDecryptor(); // This object cannot be copied. BufferedFrameDecryptor(const BufferedFrameDecryptor&) = delete; diff --git a/video/buffered_frame_decryptor_unittest.cc b/video/buffered_frame_decryptor_unittest.cc index 7d0f6d3399..41ae1ecc0a 100644 --- a/video/buffered_frame_decryptor_unittest.cc +++ b/video/buffered_frame_decryptor_unittest.cc @@ -20,6 +20,7 @@ #include "system_wrappers/include/clock.h" #include "test/gmock.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" using ::testing::Return; @@ -88,12 +89,13 @@ class BufferedFrameDecryptorTest : public ::testing::Test, seq_num_ = 0; mock_frame_decryptor_ = rtc::make_ref_counted(); buffered_frame_decryptor_ = - std::make_unique(this, this); + std::make_unique(this, this, field_trials_); buffered_frame_decryptor_->SetFrameDecryptor(mock_frame_decryptor_); } static const size_t kMaxStashedFrames; + test::ScopedKeyValueConfig field_trials_; std::vector fake_packet_data_; rtc::scoped_refptr mock_frame_decryptor_; std::unique_ptr buffered_frame_decryptor_; diff --git a/video/end_to_end_tests/extended_reports_tests.cc b/video/end_to_end_tests/extended_reports_tests.cc index 959042dac6..bc5f648324 100644 --- a/video/end_to_end_tests/extended_reports_tests.cc +++ b/video/end_to_end_tests/extended_reports_tests.cc @@ -247,7 +247,8 @@ TEST_F(ExtendedReportsEndToEndTest, TEST_F(ExtendedReportsEndToEndTest, TestExtendedReportsWithoutRrtrWithTargetBitrateExplicitlySet) { - test::ScopedFieldTrials field_trials("WebRTC-Target-Bitrate-Rtcp/Enabled/"); + test::ScopedKeyValueConfig field_trials( + field_trials_, "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/multi_stream_tester.cc b/video/end_to_end_tests/multi_stream_tester.cc index 20e128c2ad..c7b2e23dcb 100644 --- a/video/end_to_end_tests/multi_stream_tester.cc +++ b/video/end_to_end_tests/multi_stream_tester.cc @@ -50,7 +50,7 @@ void MultiStreamTester::RunTest() { auto task_queue = task_queue_factory->CreateTaskQueue( "TaskQueue", TaskQueueFactory::Priority::HIGH); Call::Config config(&event_log); - FieldTrialBasedConfig field_trials; + test::ScopedKeyValueConfig field_trials; config.trials = &field_trials; config.task_queue_factory = task_queue_factory.get(); std::unique_ptr sender_call; diff --git a/video/frame_buffer_proxy.cc b/video/frame_buffer_proxy.cc index 2ec3ac41c9..657ffe9286 100644 --- a/video/frame_buffer_proxy.cc +++ b/video/frame_buffer_proxy.cc @@ -26,7 +26,6 @@ #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/thread_annotations.h" -#include "system_wrappers/include/field_trial.h" #include "video/frame_decode_timing.h" #include "video/task_queue_frame_decode_scheduler.h" #include "video/video_receive_stream_timeout_tracker.h" @@ -181,7 +180,8 @@ class FrameBuffer3Proxy : public FrameBufferProxy { FrameSchedulingReceiver* receiver, TimeDelta max_wait_for_keyframe, TimeDelta max_wait_for_frame, - std::unique_ptr frame_decode_scheduler) + std::unique_ptr frame_decode_scheduler, + const WebRtcKeyValueConfig& field_trials) : max_wait_for_keyframe_(max_wait_for_keyframe), max_wait_for_frame_(max_wait_for_frame), clock_(clock), @@ -214,7 +214,7 @@ class FrameBuffer3Proxy : public FrameBufferProxy { RTC_LOG(LS_WARNING) << "Using FrameBuffer3"; ParseFieldTrial({&zero_playout_delay_max_decode_queue_size_}, - field_trial::FindFullName("WebRTC-ZeroPlayoutDelay")); + field_trials.Lookup("WebRTC-ZeroPlayoutDelay")); } // FrameBufferProxy implementation. @@ -546,7 +546,8 @@ enum class FrameBufferArm { constexpr const char* kFrameBufferFieldTrial = "WebRTC-FrameBuffer3"; -FrameBufferArm ParseFrameBufferFieldTrial() { +FrameBufferArm ParseFrameBufferFieldTrial( + const WebRtcKeyValueConfig& field_trials) { webrtc::FieldTrialEnum arm( "arm", FrameBufferArm::kFrameBuffer2, { @@ -554,7 +555,7 @@ FrameBufferArm ParseFrameBufferFieldTrial() { {"FrameBuffer3", FrameBufferArm::kFrameBuffer3}, {"SyncDecoding", FrameBufferArm::kSyncDecode}, }); - ParseFieldTrial({&arm}, field_trial::FindFullName(kFrameBufferFieldTrial)); + ParseFieldTrial({&arm}, field_trials.Lookup(kFrameBufferFieldTrial)); return arm.Get(); } @@ -569,14 +570,16 @@ std::unique_ptr FrameBufferProxy::CreateFromFieldTrial( FrameSchedulingReceiver* receiver, TimeDelta max_wait_for_keyframe, TimeDelta max_wait_for_frame, - DecodeSynchronizer* decode_sync) { - switch (ParseFrameBufferFieldTrial()) { + DecodeSynchronizer* decode_sync, + const WebRtcKeyValueConfig& field_trials) { + switch (ParseFrameBufferFieldTrial(field_trials)) { case FrameBufferArm::kFrameBuffer3: { auto scheduler = std::make_unique(clock, worker_queue); return std::make_unique( clock, worker_queue, timing, stats_proxy, decode_queue, receiver, - max_wait_for_keyframe, max_wait_for_frame, std::move(scheduler)); + max_wait_for_keyframe, max_wait_for_frame, std::move(scheduler), + field_trials); } case FrameBufferArm::kSyncDecode: { std::unique_ptr scheduler; @@ -592,7 +595,8 @@ std::unique_ptr FrameBufferProxy::CreateFromFieldTrial( } return std::make_unique( clock, worker_queue, timing, stats_proxy, decode_queue, receiver, - max_wait_for_keyframe, max_wait_for_frame, std::move(scheduler)); + max_wait_for_keyframe, max_wait_for_frame, std::move(scheduler), + field_trials); } case FrameBufferArm::kFrameBuffer2: ABSL_FALLTHROUGH_INTENDED; diff --git a/video/frame_buffer_proxy.h b/video/frame_buffer_proxy.h index b419aedb76..1a61f9991c 100644 --- a/video/frame_buffer_proxy.h +++ b/video/frame_buffer_proxy.h @@ -16,6 +16,7 @@ #include "api/metronome/metronome.h" #include "api/task_queue/task_queue_base.h" #include "api/video/encoded_frame.h" +#include "api/webrtc_key_value_config.h" #include "modules/video_coding/include/video_coding_defines.h" #include "modules/video_coding/timing.h" #include "rtc_base/task_queue.h" @@ -47,7 +48,8 @@ class FrameBufferProxy { FrameSchedulingReceiver* receiver, TimeDelta max_wait_for_keyframe, TimeDelta max_wait_for_frame, - DecodeSynchronizer* decode_sync); + DecodeSynchronizer* decode_sync, + const WebRtcKeyValueConfig& field_trials); virtual ~FrameBufferProxy() = default; // Run on the worker thread. diff --git a/video/frame_buffer_proxy_unittest.cc b/video/frame_buffer_proxy_unittest.cc index e7307fd4ac..a6f3713d9a 100644 --- a/video/frame_buffer_proxy_unittest.cc +++ b/video/frame_buffer_proxy_unittest.cc @@ -28,11 +28,10 @@ #include "api/video/video_timing.h" #include "rtc_base/checks.h" #include "rtc_base/event.h" -#include "system_wrappers/include/field_trial.h" -#include "test/field_trial.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/run_loop.h" +#include "test/scoped_key_value_config.h" #include "test/time_controller/simulated_time_controller.h" #include "video/decode_synchronizer.h" @@ -199,9 +198,9 @@ class VCMReceiveStatisticsCallbackMock : public VCMReceiveStatisticsCallback { (override)); }; -bool IsFrameBuffer2Enabled() { - return field_trial::FindFullName("WebRTC-FrameBuffer3") - .find("arm:FrameBuffer2") != std::string::npos; +bool IsFrameBuffer2Enabled(const WebRtcKeyValueConfig& field_trials) { + return field_trials.Lookup("WebRTC-FrameBuffer3").find("arm:FrameBuffer2") != + std::string::npos; } } // namespace @@ -231,7 +230,8 @@ class FrameBufferProxyFixture this, kMaxWaitForKeyframe, kMaxWaitForFrame, - &decode_sync_)) { + &decode_sync_, + field_trials_)) { // Avoid starting with negative render times. timing_.set_min_playout_delay(TimeDelta::Millis(10)); @@ -302,7 +302,7 @@ class FrameBufferProxyFixture int dropped_frames() const { return dropped_frames_; } protected: - test::ScopedFieldTrials field_trials_; + test::ScopedKeyValueConfig field_trials_; GlobalSimulatedTimeController time_controller_; Clock* const clock_; test::RunLoop run_loop_; @@ -676,7 +676,7 @@ TEST_P(FrameBufferProxyTest, FrameCompleteCalledOnceForSingleTemporalUnit) { TEST_P(FrameBufferProxyTest, FrameCompleteCalledOnceForCompleteTemporalUnit) { // FrameBuffer2 logs the complete frame on the arrival of the last layer. - if (IsFrameBuffer2Enabled()) + if (IsFrameBuffer2Enabled(field_trials_)) return; StartNextDecodeForceKeyframe(); @@ -753,7 +753,7 @@ TEST_P(FrameBufferProxyTest, NextFrameWithOldTimestamp) { .AsLast() .Build()); // FrameBuffer2 drops the frame, while FrameBuffer3 will continue the stream. - if (!IsFrameBuffer2Enabled()) { + if (!IsFrameBuffer2Enabled(field_trials_)) { EXPECT_THAT(WaitForFrameOrTimeout(kFps30Delay), Frame(WithId(2))); } else { EXPECT_THAT(WaitForFrameOrTimeout(kMaxWaitForFrame), TimedOut()); diff --git a/video/frame_cadence_adapter.cc b/video/frame_cadence_adapter.cc index 30c16b1db4..10cabb3129 100644 --- a/video/frame_cadence_adapter.cc +++ b/video/frame_cadence_adapter.cc @@ -33,7 +33,6 @@ #include "rtc_base/thread_annotations.h" #include "rtc_base/time_utils.h" #include "system_wrappers/include/clock.h" -#include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/metrics.h" #include "system_wrappers/include/ntp_time.h" @@ -209,7 +208,9 @@ class ZeroHertzAdapterMode : public AdapterMode { class FrameCadenceAdapterImpl : public FrameCadenceAdapterInterface { public: - FrameCadenceAdapterImpl(Clock* clock, TaskQueueBase* queue); + FrameCadenceAdapterImpl(Clock* clock, + TaskQueueBase* queue, + const WebRtcKeyValueConfig& field_trials); ~FrameCadenceAdapterImpl(); // FrameCadenceAdapterInterface overrides. @@ -542,12 +543,14 @@ TimeDelta ZeroHertzAdapterMode::RepeatDuration(bool idle_repeat) const { : frame_delay_; } -FrameCadenceAdapterImpl::FrameCadenceAdapterImpl(Clock* clock, - TaskQueueBase* queue) +FrameCadenceAdapterImpl::FrameCadenceAdapterImpl( + Clock* clock, + TaskQueueBase* queue, + const WebRtcKeyValueConfig& field_trials) : clock_(clock), queue_(queue), zero_hertz_screenshare_enabled_( - !field_trial::IsDisabled("WebRTC-ZeroHertzScreenshare")) {} + !field_trials.IsDisabled("WebRTC-ZeroHertzScreenshare")) {} FrameCadenceAdapterImpl::~FrameCadenceAdapterImpl() { RTC_DLOG(LS_VERBOSE) << __func__ << " this " << this; @@ -737,8 +740,10 @@ void FrameCadenceAdapterImpl::MaybeReportFrameRateConstraintUmas() { } // namespace std::unique_ptr -FrameCadenceAdapterInterface::Create(Clock* clock, TaskQueueBase* queue) { - return std::make_unique(clock, queue); +FrameCadenceAdapterInterface::Create(Clock* clock, + TaskQueueBase* queue, + const WebRtcKeyValueConfig& field_trials) { + return std::make_unique(clock, queue, field_trials); } } // namespace webrtc diff --git a/video/frame_cadence_adapter.h b/video/frame_cadence_adapter.h index a881c61533..843d8ebd15 100644 --- a/video/frame_cadence_adapter.h +++ b/video/frame_cadence_adapter.h @@ -18,6 +18,7 @@ #include "api/units/time_delta.h" #include "api/video/video_frame.h" #include "api/video/video_sink_interface.h" +#include "api/webrtc_key_value_config.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/thread_annotations.h" #include "system_wrappers/include/clock.h" @@ -79,7 +80,8 @@ class FrameCadenceAdapterInterface // Callback::OnFrame on the |queue|. static std::unique_ptr Create( Clock* clock, - TaskQueueBase* queue); + TaskQueueBase* queue, + const WebRtcKeyValueConfig& field_trials); // Call before using the rest of the API. virtual void Initialize(Callback* callback) = 0; diff --git a/video/frame_cadence_adapter_unittest.cc b/video/frame_cadence_adapter_unittest.cc index b2ddfd8264..edc6caea32 100644 --- a/video/frame_cadence_adapter_unittest.cc +++ b/video/frame_cadence_adapter_unittest.cc @@ -27,9 +27,9 @@ #include "system_wrappers/include/metrics.h" #include "system_wrappers/include/ntp_time.h" #include "system_wrappers/include/sleep.h" -#include "test/field_trial.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 { @@ -59,8 +59,11 @@ VideoFrame CreateFrameWithTimestamps( .build(); } -std::unique_ptr CreateAdapter(Clock* clock) { - return FrameCadenceAdapterInterface::Create(clock, TaskQueueBase::Current()); +std::unique_ptr CreateAdapter( + const WebRtcKeyValueConfig& field_trials, + Clock* clock) { + return FrameCadenceAdapterInterface::Create(clock, TaskQueueBase::Current(), + field_trials); } class MockCallback : public FrameCadenceAdapterInterface::Callback { @@ -70,25 +73,28 @@ class MockCallback : public FrameCadenceAdapterInterface::Callback { MOCK_METHOD(void, RequestRefreshFrame, (), (override)); }; -class ZeroHertzFieldTrialDisabler : public test::ScopedFieldTrials { +class ZeroHertzFieldTrialDisabler : public test::ScopedKeyValueConfig { public: ZeroHertzFieldTrialDisabler() - : test::ScopedFieldTrials("WebRTC-ZeroHertzScreenshare/Disabled/") {} + : test::ScopedKeyValueConfig("WebRTC-ZeroHertzScreenshare/Disabled/") {} }; -class ZeroHertzFieldTrialEnabler : public test::ScopedFieldTrials { +class ZeroHertzFieldTrialEnabler : public test::ScopedKeyValueConfig { public: ZeroHertzFieldTrialEnabler() - : test::ScopedFieldTrials("WebRTC-ZeroHertzScreenshare/Enabled/") {} + : test::ScopedKeyValueConfig("WebRTC-ZeroHertzScreenshare/Enabled/") {} }; TEST(FrameCadenceAdapterTest, ForwardsFramesOnConstructionAndUnderDisabledFieldTrial) { GlobalSimulatedTimeController time_controller(Timestamp::Millis(1)); - auto disabler = std::make_unique(); + ZeroHertzFieldTrialDisabler disabled_field_trials; + test::ScopedKeyValueConfig no_field_trials; for (int i = 0; i != 2; i++) { MockCallback callback; - auto adapter = CreateAdapter(time_controller.GetClock()); + auto adapter = + CreateAdapter(i == 0 ? disabled_field_trials : no_field_trials, + time_controller.GetClock()); adapter->Initialize(&callback); VideoFrame frame = CreateFrame(); EXPECT_CALL(callback, OnFrame).Times(1); @@ -98,15 +104,14 @@ TEST(FrameCadenceAdapterTest, EXPECT_CALL(callback, OnDiscardedFrame).Times(1); adapter->OnDiscardedFrame(); Mock::VerifyAndClearExpectations(&callback); - - disabler = nullptr; } } TEST(FrameCadenceAdapterTest, CountsOutstandingFramesToProcess) { + test::ScopedKeyValueConfig no_field_trials; GlobalSimulatedTimeController time_controller(Timestamp::Millis(1)); MockCallback callback; - auto adapter = CreateAdapter(time_controller.GetClock()); + auto adapter = CreateAdapter(no_field_trials, time_controller.GetClock()); adapter->Initialize(&callback); EXPECT_CALL(callback, OnFrame(_, 2, _)).Times(1); EXPECT_CALL(callback, OnFrame(_, 1, _)).Times(1); @@ -120,8 +125,9 @@ TEST(FrameCadenceAdapterTest, CountsOutstandingFramesToProcess) { } TEST(FrameCadenceAdapterTest, FrameRateFollowsRateStatisticsByDefault) { + test::ScopedKeyValueConfig no_field_trials; GlobalSimulatedTimeController time_controller(Timestamp::Millis(0)); - auto adapter = CreateAdapter(time_controller.GetClock()); + auto adapter = CreateAdapter(no_field_trials, time_controller.GetClock()); adapter->Initialize(nullptr); // Create an "oracle" rate statistics which should be followed on a sequence @@ -143,7 +149,7 @@ TEST(FrameCadenceAdapterTest, FrameRateFollowsRateStatisticsWhenFeatureDisabled) { ZeroHertzFieldTrialDisabler feature_disabler; GlobalSimulatedTimeController time_controller(Timestamp::Millis(0)); - auto adapter = CreateAdapter(time_controller.GetClock()); + auto adapter = CreateAdapter(feature_disabler, time_controller.GetClock()); adapter->Initialize(nullptr); // Create an "oracle" rate statistics which should be followed on a sequence @@ -165,7 +171,7 @@ TEST(FrameCadenceAdapterTest, FrameRateFollowsMaxFpsWhenZeroHertzActivated) { ZeroHertzFieldTrialEnabler enabler; MockCallback callback; GlobalSimulatedTimeController time_controller(Timestamp::Millis(0)); - auto adapter = CreateAdapter(time_controller.GetClock()); + auto adapter = CreateAdapter(enabler, time_controller.GetClock()); adapter->Initialize(nullptr); adapter->SetZeroHertzModeEnabled( FrameCadenceAdapterInterface::ZeroHertzModeParams{}); @@ -182,7 +188,7 @@ TEST(FrameCadenceAdapterTest, ZeroHertzFieldTrialEnabler enabler; MockCallback callback; GlobalSimulatedTimeController time_controller(Timestamp::Millis(0)); - auto adapter = CreateAdapter(time_controller.GetClock()); + auto adapter = CreateAdapter(enabler, time_controller.GetClock()); adapter->Initialize(nullptr); adapter->SetZeroHertzModeEnabled( FrameCadenceAdapterInterface::ZeroHertzModeParams{}); @@ -211,7 +217,7 @@ TEST(FrameCadenceAdapterTest, ForwardsFramesDelayed) { ZeroHertzFieldTrialEnabler enabler; MockCallback callback; GlobalSimulatedTimeController time_controller(Timestamp::Millis(0)); - auto adapter = CreateAdapter(time_controller.GetClock()); + auto adapter = CreateAdapter(enabler, time_controller.GetClock()); adapter->Initialize(&callback); adapter->SetZeroHertzModeEnabled( FrameCadenceAdapterInterface::ZeroHertzModeParams{}); @@ -246,7 +252,7 @@ TEST(FrameCadenceAdapterTest, RepeatsFramesDelayed) { ZeroHertzFieldTrialEnabler enabler; MockCallback callback; GlobalSimulatedTimeController time_controller(Timestamp::Millis(47892223)); - auto adapter = CreateAdapter(time_controller.GetClock()); + auto adapter = CreateAdapter(enabler, time_controller.GetClock()); adapter->Initialize(&callback); adapter->SetZeroHertzModeEnabled( FrameCadenceAdapterInterface::ZeroHertzModeParams{}); @@ -300,7 +306,7 @@ TEST(FrameCadenceAdapterTest, ZeroHertzFieldTrialEnabler enabler; MockCallback callback; GlobalSimulatedTimeController time_controller(Timestamp::Millis(4711)); - auto adapter = CreateAdapter(time_controller.GetClock()); + auto adapter = CreateAdapter(enabler, time_controller.GetClock()); adapter->Initialize(&callback); adapter->SetZeroHertzModeEnabled( FrameCadenceAdapterInterface::ZeroHertzModeParams{}); @@ -333,7 +339,7 @@ TEST(FrameCadenceAdapterTest, StopsRepeatingFramesDelayed) { ZeroHertzFieldTrialEnabler enabler; MockCallback callback; GlobalSimulatedTimeController time_controller(Timestamp::Millis(0)); - auto adapter = CreateAdapter(time_controller.GetClock()); + auto adapter = CreateAdapter(enabler, time_controller.GetClock()); adapter->Initialize(&callback); adapter->SetZeroHertzModeEnabled( FrameCadenceAdapterInterface::ZeroHertzModeParams{}); @@ -361,7 +367,7 @@ TEST(FrameCadenceAdapterTest, RequestsRefreshFrameOnKeyFrameRequestWhenNew) { ZeroHertzFieldTrialEnabler enabler; MockCallback callback; GlobalSimulatedTimeController time_controller(Timestamp::Millis(0)); - auto adapter = CreateAdapter(time_controller.GetClock()); + auto adapter = CreateAdapter(enabler, time_controller.GetClock()); adapter->Initialize(&callback); adapter->SetZeroHertzModeEnabled( FrameCadenceAdapterInterface::ZeroHertzModeParams{}); @@ -375,7 +381,7 @@ TEST(FrameCadenceAdapterTest, IgnoresKeyFrameRequestShortlyAfterFrame) { ZeroHertzFieldTrialEnabler enabler; MockCallback callback; GlobalSimulatedTimeController time_controller(Timestamp::Millis(0)); - auto adapter = CreateAdapter(time_controller.GetClock()); + auto adapter = CreateAdapter(enabler, time_controller.GetClock()); adapter->Initialize(&callback); adapter->SetZeroHertzModeEnabled( FrameCadenceAdapterInterface::ZeroHertzModeParams{}); @@ -413,7 +419,7 @@ class FrameCadenceAdapterSimulcastLayersParamTest MockCallback callback_; GlobalSimulatedTimeController time_controller_{Timestamp::Millis(0)}; const std::unique_ptr adapter_{ - CreateAdapter(time_controller_.GetClock())}; + CreateAdapter(enabler_, time_controller_.GetClock())}; }; TEST_P(FrameCadenceAdapterSimulcastLayersParamTest, @@ -542,7 +548,7 @@ class ZeroHertzLayerQualityConvergenceTest : public ::testing::Test { MockCallback callback_; GlobalSimulatedTimeController time_controller_{Timestamp::Millis(0)}; std::unique_ptr adapter_{ - CreateAdapter(time_controller_.GetClock())}; + CreateAdapter(field_trial_enabler_, time_controller_.GetClock())}; }; TEST_F(ZeroHertzLayerQualityConvergenceTest, InitialStateUnconverged) { @@ -625,7 +631,8 @@ class FrameCadenceAdapterMetricsTest : public ::testing::Test { TEST_F(FrameCadenceAdapterMetricsTest, RecordsNoUmasWithNoFrameTransfer) { MockCallback callback; - auto adapter = CreateAdapter(nullptr); + test::ScopedKeyValueConfig no_field_trials; + auto adapter = CreateAdapter(no_field_trials, nullptr); adapter->Initialize(&callback); adapter->OnConstraintsChanged( VideoTrackSourceConstraints{absl::nullopt, absl::nullopt}); @@ -665,7 +672,8 @@ TEST_F(FrameCadenceAdapterMetricsTest, RecordsNoUmasWithNoFrameTransfer) { TEST_F(FrameCadenceAdapterMetricsTest, RecordsNoUmasWithoutEnabledContentType) { MockCallback callback; - auto adapter = CreateAdapter(time_controller_.GetClock()); + test::ScopedKeyValueConfig no_field_trials; + auto adapter = CreateAdapter(no_field_trials, time_controller_.GetClock()); adapter->Initialize(&callback); adapter->OnFrame(CreateFrame()); adapter->OnConstraintsChanged( @@ -706,7 +714,8 @@ TEST_F(FrameCadenceAdapterMetricsTest, RecordsNoUmasWithoutEnabledContentType) { TEST_F(FrameCadenceAdapterMetricsTest, RecordsNoConstraintsIfUnsetOnFrame) { MockCallback callback; - auto adapter = CreateAdapter(time_controller_.GetClock()); + test::ScopedKeyValueConfig no_field_trials; + auto adapter = CreateAdapter(no_field_trials, time_controller_.GetClock()); adapter->Initialize(&callback); adapter->SetZeroHertzModeEnabled( FrameCadenceAdapterInterface::ZeroHertzModeParams{}); @@ -719,7 +728,8 @@ TEST_F(FrameCadenceAdapterMetricsTest, RecordsNoConstraintsIfUnsetOnFrame) { TEST_F(FrameCadenceAdapterMetricsTest, RecordsEmptyConstraintsIfSetOnFrame) { MockCallback callback; - auto adapter = CreateAdapter(time_controller_.GetClock()); + test::ScopedKeyValueConfig no_field_trials; + auto adapter = CreateAdapter(no_field_trials, time_controller_.GetClock()); adapter->Initialize(&callback); adapter->SetZeroHertzModeEnabled( FrameCadenceAdapterInterface::ZeroHertzModeParams{}); @@ -759,7 +769,8 @@ TEST_F(FrameCadenceAdapterMetricsTest, RecordsEmptyConstraintsIfSetOnFrame) { TEST_F(FrameCadenceAdapterMetricsTest, RecordsMaxConstraintIfSetOnFrame) { MockCallback callback; - auto adapter = CreateAdapter(time_controller_.GetClock()); + test::ScopedKeyValueConfig no_field_trials; + auto adapter = CreateAdapter(no_field_trials, time_controller_.GetClock()); adapter->Initialize(&callback); adapter->SetZeroHertzModeEnabled( FrameCadenceAdapterInterface::ZeroHertzModeParams{}); @@ -796,7 +807,8 @@ TEST_F(FrameCadenceAdapterMetricsTest, RecordsMaxConstraintIfSetOnFrame) { TEST_F(FrameCadenceAdapterMetricsTest, RecordsMinConstraintIfSetOnFrame) { MockCallback callback; - auto adapter = CreateAdapter(time_controller_.GetClock()); + test::ScopedKeyValueConfig no_field_trials; + auto adapter = CreateAdapter(no_field_trials, time_controller_.GetClock()); adapter->Initialize(&callback); adapter->SetZeroHertzModeEnabled( FrameCadenceAdapterInterface::ZeroHertzModeParams{}); @@ -833,7 +845,8 @@ TEST_F(FrameCadenceAdapterMetricsTest, RecordsMinConstraintIfSetOnFrame) { TEST_F(FrameCadenceAdapterMetricsTest, RecordsMinGtMaxConstraintIfSetOnFrame) { MockCallback callback; - auto adapter = CreateAdapter(time_controller_.GetClock()); + test::ScopedKeyValueConfig no_field_trials; + auto adapter = CreateAdapter(no_field_trials, time_controller_.GetClock()); adapter->Initialize(&callback); adapter->SetZeroHertzModeEnabled( FrameCadenceAdapterInterface::ZeroHertzModeParams{}); @@ -869,7 +882,8 @@ TEST_F(FrameCadenceAdapterMetricsTest, RecordsMinGtMaxConstraintIfSetOnFrame) { TEST_F(FrameCadenceAdapterMetricsTest, RecordsMinLtMaxConstraintIfSetOnFrame) { MockCallback callback; - auto adapter = CreateAdapter(time_controller_.GetClock()); + test::ScopedKeyValueConfig no_field_trials; + auto adapter = CreateAdapter(no_field_trials, time_controller_.GetClock()); adapter->Initialize(&callback); adapter->SetZeroHertzModeEnabled( FrameCadenceAdapterInterface::ZeroHertzModeParams{}); @@ -907,7 +921,7 @@ TEST(FrameCadenceAdapterRealTimeTest, TimestampsDoNotDrift) { int64_t original_timestamp_us; rtc::Event event; queue->PostTask(ToQueuedTask([&] { - adapter = CreateAdapter(clock); + adapter = CreateAdapter(enabler, clock); adapter->Initialize(&callback); adapter->SetZeroHertzModeEnabled( FrameCadenceAdapterInterface::ZeroHertzModeParams{}); diff --git a/video/quality_scaling_tests.cc b/video/quality_scaling_tests.cc index c7c393e861..68890d33c9 100644 --- a/video/quality_scaling_tests.cc +++ b/video/quality_scaling_tests.cc @@ -216,7 +216,8 @@ class UpscalingObserver TEST_F(QualityScalingTest, AdaptsDownForHighQp_Vp8) { // qp_low:1, qp_high:1 -> kHighQp - test::ScopedFieldTrials field_trials(kPrefix + "1,1,0,0,0,0" + kEnd); + test::ScopedKeyValueConfig field_trials(field_trials_, + kPrefix + "1,1,0,0,0,0" + kEnd); DownscalingObserver test("VP8", /*streams_active=*/{true}, kHighStartBps, /*automatic_resize=*/true, @@ -226,7 +227,8 @@ TEST_F(QualityScalingTest, AdaptsDownForHighQp_Vp8) { TEST_F(QualityScalingTest, NoAdaptDownForHighQpIfScalingOff_Vp8) { // qp_low:1, qp_high:1 -> kHighQp - test::ScopedFieldTrials field_trials(kPrefix + "1,1,0,0,0,0" + kEnd); + test::ScopedKeyValueConfig field_trials(field_trials_, + kPrefix + "1,1,0,0,0,0" + kEnd); DownscalingObserver test("VP8", /*streams_active=*/{true}, kHighStartBps, /*automatic_resize=*/false, @@ -236,7 +238,8 @@ TEST_F(QualityScalingTest, NoAdaptDownForHighQpIfScalingOff_Vp8) { TEST_F(QualityScalingTest, NoAdaptDownForNormalQp_Vp8) { // qp_low:1, qp_high:127 -> kNormalQp - test::ScopedFieldTrials field_trials(kPrefix + "1,127,0,0,0,0" + kEnd); + test::ScopedKeyValueConfig field_trials(field_trials_, + kPrefix + "1,127,0,0,0,0" + kEnd); DownscalingObserver test("VP8", /*streams_active=*/{true}, kHighStartBps, /*automatic_resize=*/true, @@ -246,7 +249,8 @@ TEST_F(QualityScalingTest, NoAdaptDownForNormalQp_Vp8) { TEST_F(QualityScalingTest, AdaptsDownForLowStartBitrate_Vp8) { // qp_low:1, qp_high:127 -> kNormalQp - test::ScopedFieldTrials field_trials(kPrefix + "1,127,0,0,0,0" + kEnd); + test::ScopedKeyValueConfig field_trials(field_trials_, + kPrefix + "1,127,0,0,0,0" + kEnd); DownscalingObserver test("VP8", /*streams_active=*/{true}, kLowStartBps, /*automatic_resize=*/true, @@ -256,10 +260,11 @@ TEST_F(QualityScalingTest, AdaptsDownForLowStartBitrate_Vp8) { TEST_F(QualityScalingTest, AdaptsDownForLowStartBitrateAndThenUp) { // qp_low:127, qp_high:127 -> kLowQp - test::ScopedFieldTrials field_trials( + 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 + "WebRTC-Video-BalancedDegradationSettings/" + "pixels:230400|921600,fps:20|30,kbps:300|500/"); // should not affect UpscalingObserver test("VP8", /*streams_active=*/{true}, kDefaultVgaMinStartBps - 1, @@ -269,10 +274,10 @@ TEST_F(QualityScalingTest, AdaptsDownForLowStartBitrateAndThenUp) { TEST_F(QualityScalingTest, AdaptsDownAndThenUpWithBalanced) { // qp_low:127, qp_high:127 -> kLowQp - test::ScopedFieldTrials field_trials( - kPrefix + "127,127,0,0,0,0" + kEnd + - "WebRTC-Video-BalancedDegradationSettings/" - "pixels:230400|921600,fps:20|30,kbps:300|499/"); + 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/"); UpscalingObserver test("VP8", /*streams_active=*/{true}, kDefaultVgaMinStartBps - 1, @@ -283,10 +288,10 @@ TEST_F(QualityScalingTest, AdaptsDownAndThenUpWithBalanced) { TEST_F(QualityScalingTest, AdaptsDownButNotUpWithBalancedIfBitrateNotEnough) { // qp_low:127, qp_high:127 -> kLowQp - test::ScopedFieldTrials field_trials( - kPrefix + "127,127,0,0,0,0" + kEnd + - "WebRTC-Video-BalancedDegradationSettings/" - "pixels:230400|921600,fps:20|30,kbps:300|500/"); + 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/"); UpscalingObserver test("VP8", /*streams_active=*/{true}, kDefaultVgaMinStartBps - 1, @@ -297,7 +302,8 @@ TEST_F(QualityScalingTest, AdaptsDownButNotUpWithBalancedIfBitrateNotEnough) { TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrate_Simulcast) { // qp_low:1, qp_high:127 -> kNormalQp - test::ScopedFieldTrials field_trials(kPrefix + "1,127,0,0,0,0" + kEnd); + test::ScopedKeyValueConfig field_trials(field_trials_, + kPrefix + "1,127,0,0,0,0" + kEnd); DownscalingObserver test("VP8", /*streams_active=*/{true, true}, kLowStartBps, /*automatic_resize=*/false, @@ -307,7 +313,8 @@ TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrate_Simulcast) { TEST_F(QualityScalingTest, AdaptsDownForHighQp_HighestStreamActive_Vp8) { // qp_low:1, qp_high:1 -> kHighQp - test::ScopedFieldTrials field_trials(kPrefix + "1,1,0,0,0,0" + kEnd); + test::ScopedKeyValueConfig field_trials(field_trials_, + kPrefix + "1,1,0,0,0,0" + kEnd); DownscalingObserver test("VP8", /*streams_active=*/{false, false, true}, kHighStartBps, @@ -319,7 +326,8 @@ TEST_F(QualityScalingTest, AdaptsDownForHighQp_HighestStreamActive_Vp8) { TEST_F(QualityScalingTest, AdaptsDownForLowStartBitrate_HighestStreamActive_Vp8) { // qp_low:1, qp_high:127 -> kNormalQp - test::ScopedFieldTrials field_trials(kPrefix + "1,127,0,0,0,0" + kEnd); + test::ScopedKeyValueConfig field_trials(field_trials_, + kPrefix + "1,127,0,0,0,0" + kEnd); DownscalingObserver test("VP8", /*streams_active=*/{false, false, true}, kSinglecastLimits720pVp8->min_start_bitrate_bps - 1, @@ -330,7 +338,8 @@ TEST_F(QualityScalingTest, TEST_F(QualityScalingTest, AdaptsDownButNotUpWithMinStartBitrateLimit) { // qp_low:127, qp_high:127 -> kLowQp - test::ScopedFieldTrials field_trials(kPrefix + "127,127,0,0,0,0" + kEnd); + test::ScopedKeyValueConfig field_trials(field_trials_, + kPrefix + "127,127,0,0,0,0" + kEnd); UpscalingObserver test("VP8", /*streams_active=*/{false, true}, kSinglecastLimits720pVp8->min_start_bitrate_bps - 1, @@ -340,7 +349,8 @@ TEST_F(QualityScalingTest, AdaptsDownButNotUpWithMinStartBitrateLimit) { TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrateIfBitrateEnough_Vp8) { // qp_low:1, qp_high:127 -> kNormalQp - test::ScopedFieldTrials field_trials(kPrefix + "1,127,0,0,0,0" + kEnd); + test::ScopedKeyValueConfig field_trials(field_trials_, + kPrefix + "1,127,0,0,0,0" + kEnd); DownscalingObserver test("VP8", /*streams_active=*/{false, false, true}, kSinglecastLimits720pVp8->min_start_bitrate_bps, @@ -352,9 +362,9 @@ TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrateIfBitrateEnough_Vp8) { TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrateIfDefaultLimitsDisabled_Vp8) { // qp_low:1, qp_high:127 -> kNormalQp - test::ScopedFieldTrials field_trials( - kPrefix + "1,127,0,0,0,0" + kEnd + - "WebRTC-DefaultBitrateLimitsKillSwitch/Enabled/"); + test::ScopedKeyValueConfig field_trials( + field_trials_, kPrefix + "1,127,0,0,0,0" + kEnd + + "WebRTC-DefaultBitrateLimitsKillSwitch/Enabled/"); DownscalingObserver test("VP8", /*streams_active=*/{false, false, true}, kSinglecastLimits720pVp8->min_start_bitrate_bps - 1, @@ -366,7 +376,8 @@ TEST_F(QualityScalingTest, TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrate_OneStreamSinglecastLimitsNotUsed_Vp8) { // qp_low:1, qp_high:127 -> kNormalQp - test::ScopedFieldTrials field_trials(kPrefix + "1,127,0,0,0,0" + kEnd); + test::ScopedKeyValueConfig field_trials(field_trials_, + kPrefix + "1,127,0,0,0,0" + kEnd); DownscalingObserver test("VP8", /*streams_active=*/{true}, kSinglecastLimits720pVp8->min_start_bitrate_bps - 1, @@ -377,7 +388,8 @@ TEST_F(QualityScalingTest, TEST_F(QualityScalingTest, NoAdaptDownForHighQp_LowestStreamActive_Vp8) { // qp_low:1, qp_high:1 -> kHighQp - test::ScopedFieldTrials field_trials(kPrefix + "1,1,0,0,0,0" + kEnd); + test::ScopedKeyValueConfig field_trials(field_trials_, + kPrefix + "1,1,0,0,0,0" + kEnd); DownscalingObserver test("VP8", /*streams_active=*/{true, false, false}, kHighStartBps, @@ -389,7 +401,8 @@ TEST_F(QualityScalingTest, NoAdaptDownForHighQp_LowestStreamActive_Vp8) { TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrate_LowestStreamActive_Vp8) { // qp_low:1, qp_high:127 -> kNormalQp - test::ScopedFieldTrials field_trials(kPrefix + "1,127,0,0,0,0" + kEnd); + test::ScopedKeyValueConfig field_trials(field_trials_, + kPrefix + "1,127,0,0,0,0" + kEnd); DownscalingObserver test("VP8", /*streams_active=*/{true, false, false}, kLowStartBps, @@ -400,7 +413,8 @@ TEST_F(QualityScalingTest, TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrateIfScalingOff_Vp8) { // qp_low:1, qp_high:127 -> kNormalQp - test::ScopedFieldTrials field_trials(kPrefix + "1,127,0,0,0,0" + kEnd); + test::ScopedKeyValueConfig field_trials(field_trials_, + kPrefix + "1,127,0,0,0,0" + kEnd); DownscalingObserver test("VP8", /*streams_active=*/{true}, kLowStartBps, /*automatic_resize=*/false, @@ -410,8 +424,9 @@ TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrateIfScalingOff_Vp8) { TEST_F(QualityScalingTest, AdaptsDownForHighQp_Vp9) { // qp_low:1, qp_high:1 -> kHighQp - test::ScopedFieldTrials field_trials(kPrefix + "0,0,1,1,0,0" + kEnd + - "WebRTC-VP9QualityScaler/Enabled/"); + test::ScopedKeyValueConfig field_trials( + field_trials_, + kPrefix + "0,0,1,1,0,0" + kEnd + "WebRTC-VP9QualityScaler/Enabled/"); DownscalingObserver test("VP9", /*streams_active=*/{true}, kHighStartBps, /*automatic_resize=*/true, @@ -421,8 +436,9 @@ TEST_F(QualityScalingTest, AdaptsDownForHighQp_Vp9) { TEST_F(QualityScalingTest, NoAdaptDownForHighQpIfScalingOff_Vp9) { // qp_low:1, qp_high:1 -> kHighQp - test::ScopedFieldTrials field_trials(kPrefix + "0,0,1,1,0,0" + kEnd + - "WebRTC-VP9QualityScaler/Disabled/"); + test::ScopedKeyValueConfig field_trials( + field_trials_, + kPrefix + "0,0,1,1,0,0" + kEnd + "WebRTC-VP9QualityScaler/Disabled/"); DownscalingObserver test("VP9", /*streams_active=*/{true}, kHighStartBps, /*automatic_resize=*/true, @@ -432,8 +448,9 @@ TEST_F(QualityScalingTest, NoAdaptDownForHighQpIfScalingOff_Vp9) { TEST_F(QualityScalingTest, AdaptsDownForLowStartBitrate_Vp9) { // qp_low:1, qp_high:255 -> kNormalQp - test::ScopedFieldTrials field_trials(kPrefix + "0,0,1,255,0,0" + kEnd + - "WebRTC-VP9QualityScaler/Enabled/"); + test::ScopedKeyValueConfig field_trials( + field_trials_, + kPrefix + "0,0,1,255,0,0" + kEnd + "WebRTC-VP9QualityScaler/Enabled/"); DownscalingObserver test("VP9", /*streams_active=*/{true}, kLowStartBps, /*automatic_resize=*/true, @@ -443,8 +460,9 @@ TEST_F(QualityScalingTest, AdaptsDownForLowStartBitrate_Vp9) { TEST_F(QualityScalingTest, NoAdaptDownForHighQp_LowestStreamActive_Vp9) { // qp_low:1, qp_high:1 -> kHighQp - test::ScopedFieldTrials field_trials(kPrefix + "0,0,1,1,0,0" + kEnd + - "WebRTC-VP9QualityScaler/Enabled/"); + test::ScopedKeyValueConfig field_trials( + field_trials_, + kPrefix + "0,0,1,1,0,0" + kEnd + "WebRTC-VP9QualityScaler/Enabled/"); DownscalingObserver test("VP9", /*streams_active=*/{true, false, false}, kHighStartBps, @@ -456,8 +474,9 @@ TEST_F(QualityScalingTest, NoAdaptDownForHighQp_LowestStreamActive_Vp9) { TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrate_LowestStreamActive_Vp9) { // qp_low:1, qp_high:255 -> kNormalQp - test::ScopedFieldTrials field_trials(kPrefix + "0,0,1,255,0,0" + kEnd + - "WebRTC-VP9QualityScaler/Enabled/"); + test::ScopedKeyValueConfig field_trials( + field_trials_, + kPrefix + "0,0,1,255,0,0" + kEnd + "WebRTC-VP9QualityScaler/Enabled/"); DownscalingObserver test("VP9", /*streams_active=*/{true, false, false}, kLowStartBps, @@ -468,8 +487,9 @@ TEST_F(QualityScalingTest, TEST_F(QualityScalingTest, AdaptsDownForHighQp_MiddleStreamActive_Vp9) { // qp_low:1, qp_high:1 -> kHighQp - test::ScopedFieldTrials field_trials(kPrefix + "0,0,1,1,0,0" + kEnd + - "WebRTC-VP9QualityScaler/Enabled/"); + test::ScopedKeyValueConfig field_trials( + field_trials_, + kPrefix + "0,0,1,1,0,0" + kEnd + "WebRTC-VP9QualityScaler/Enabled/"); DownscalingObserver test("VP9", /*streams_active=*/{false, true, false}, kHighStartBps, @@ -481,8 +501,9 @@ TEST_F(QualityScalingTest, AdaptsDownForHighQp_MiddleStreamActive_Vp9) { TEST_F(QualityScalingTest, AdaptsDownForLowStartBitrate_MiddleStreamActive_Vp9) { // qp_low:1, qp_high:255 -> kNormalQp - test::ScopedFieldTrials field_trials(kPrefix + "0,0,1,255,0,0" + kEnd + - "WebRTC-VP9QualityScaler/Enabled/"); + test::ScopedKeyValueConfig field_trials( + field_trials_, + kPrefix + "0,0,1,255,0,0" + kEnd + "WebRTC-VP9QualityScaler/Enabled/"); DownscalingObserver test("VP9", /*streams_active=*/{false, true, false}, kSinglecastLimits360pVp9->min_start_bitrate_bps - 1, @@ -493,8 +514,9 @@ TEST_F(QualityScalingTest, TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrateIfBitrateEnough_Vp9) { // qp_low:1, qp_high:255 -> kNormalQp - test::ScopedFieldTrials field_trials(kPrefix + "0,0,1,255,0,0" + kEnd + - "WebRTC-VP9QualityScaler/Enabled/"); + test::ScopedKeyValueConfig field_trials( + field_trials_, + kPrefix + "0,0,1,255,0,0" + kEnd + "WebRTC-VP9QualityScaler/Enabled/"); DownscalingObserver test("VP9", /*streams_active=*/{false, true, false}, kSinglecastLimits360pVp9->min_start_bitrate_bps, @@ -506,7 +528,8 @@ TEST_F(QualityScalingTest, NoAdaptDownForLowStartBitrateIfBitrateEnough_Vp9) { #if defined(WEBRTC_USE_H264) TEST_F(QualityScalingTest, AdaptsDownForHighQp_H264) { // qp_low:1, qp_high:1 -> kHighQp - test::ScopedFieldTrials field_trials(kPrefix + "0,0,0,0,1,1" + kEnd); + test::ScopedKeyValueConfig field_trials(field_trials_, + kPrefix + "0,0,0,0,1,1" + kEnd); DownscalingObserver test("H264", /*streams_active=*/{true}, kHighStartBps, /*automatic_resize=*/true, @@ -516,7 +539,8 @@ TEST_F(QualityScalingTest, AdaptsDownForHighQp_H264) { TEST_F(QualityScalingTest, AdaptsDownForLowStartBitrate_H264) { // qp_low:1, qp_high:51 -> kNormalQp - test::ScopedFieldTrials field_trials(kPrefix + "0,0,0,0,1,51" + kEnd); + test::ScopedKeyValueConfig field_trials(field_trials_, + kPrefix + "0,0,0,0,1,51" + kEnd); DownscalingObserver test("H264", /*streams_active=*/{true}, kLowStartBps, /*automatic_resize=*/true, diff --git a/video/receive_statistics_proxy.cc b/video/receive_statistics_proxy.cc index 1384ae7dbe..0a854ce068 100644 --- a/video/receive_statistics_proxy.cc +++ b/video/receive_statistics_proxy.cc @@ -20,7 +20,6 @@ #include "rtc_base/strings/string_builder.h" #include "rtc_base/time_utils.h" #include "system_wrappers/include/clock.h" -#include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/metrics.h" namespace webrtc { @@ -78,14 +77,22 @@ std::string UmaSuffixForContentType(VideoContentType content_type) { return ss.str(); } +bool EnableDecodeTimeHistogram(const WebRtcKeyValueConfig* field_trials) { + if (field_trials == nullptr) { + return true; + } + return !field_trials->IsEnabled("WebRTC-DecodeTimeHistogramsKillSwitch"); +} + } // namespace -ReceiveStatisticsProxy::ReceiveStatisticsProxy(uint32_t remote_ssrc, - Clock* clock) +ReceiveStatisticsProxy::ReceiveStatisticsProxy( + uint32_t remote_ssrc, + Clock* clock, + const WebRtcKeyValueConfig* field_trials) : clock_(clock), start_ms_(clock->TimeInMilliseconds()), - enable_decode_time_histograms_( - !field_trial::IsEnabled("WebRTC-DecodeTimeHistogramsKillSwitch")), + enable_decode_time_histograms_(EnableDecodeTimeHistogram(field_trials)), last_sample_time_(clock->TimeInMilliseconds()), fps_threshold_(kLowFpsThreshold, kHighFpsThreshold, diff --git a/video/receive_statistics_proxy.h b/video/receive_statistics_proxy.h index 9560973118..8dab89716e 100644 --- a/video/receive_statistics_proxy.h +++ b/video/receive_statistics_proxy.h @@ -18,6 +18,7 @@ #include "absl/types/optional.h" #include "api/sequence_checker.h" +#include "api/webrtc_key_value_config.h" #include "call/video_receive_stream.h" #include "modules/include/module_common_types.h" #include "modules/video_coding/include/video_coding_defines.h" @@ -42,7 +43,9 @@ class ReceiveStatisticsProxy : public VCMReceiveStatisticsCallback, public RtcpPacketTypeCounterObserver, public CallStatsObserver { public: - ReceiveStatisticsProxy(uint32_t remote_ssrc, Clock* clock); + ReceiveStatisticsProxy(uint32_t remote_ssrc, + Clock* clock, + const WebRtcKeyValueConfig* field_trials = nullptr); ~ReceiveStatisticsProxy() = default; VideoReceiveStream::Stats GetStats() const; diff --git a/video/receive_statistics_proxy2.cc b/video/receive_statistics_proxy2.cc index aabfa5290e..5d49d36c43 100644 --- a/video/receive_statistics_proxy2.cc +++ b/video/receive_statistics_proxy2.cc @@ -22,7 +22,6 @@ #include "rtc_base/thread.h" #include "rtc_base/time_utils.h" #include "system_wrappers/include/clock.h" -#include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/metrics.h" #include "video/video_receive_stream2.h" @@ -98,13 +97,15 @@ bool IsCurrentTaskQueueOrThread(TaskQueueBase* task_queue) { } // namespace -ReceiveStatisticsProxy::ReceiveStatisticsProxy(uint32_t remote_ssrc, - Clock* clock, - TaskQueueBase* worker_thread) +ReceiveStatisticsProxy::ReceiveStatisticsProxy( + uint32_t remote_ssrc, + Clock* clock, + TaskQueueBase* worker_thread, + const WebRtcKeyValueConfig& field_trials) : clock_(clock), start_ms_(clock->TimeInMilliseconds()), enable_decode_time_histograms_( - !field_trial::IsEnabled("WebRTC-DecodeTimeHistogramsKillSwitch")), + !field_trials.IsEnabled("WebRTC-DecodeTimeHistogramsKillSwitch")), last_sample_time_(clock->TimeInMilliseconds()), fps_threshold_(kLowFpsThreshold, kHighFpsThreshold, diff --git a/video/receive_statistics_proxy2.h b/video/receive_statistics_proxy2.h index 32269f7381..afe7458c41 100644 --- a/video/receive_statistics_proxy2.h +++ b/video/receive_statistics_proxy2.h @@ -20,6 +20,7 @@ #include "api/sequence_checker.h" #include "api/task_queue/task_queue_base.h" #include "api/units/timestamp.h" +#include "api/webrtc_key_value_config.h" #include "call/video_receive_stream.h" #include "modules/include/module_common_types.h" #include "modules/video_coding/include/video_coding_defines.h" @@ -50,7 +51,8 @@ class ReceiveStatisticsProxy : public VCMReceiveStatisticsCallback, public: ReceiveStatisticsProxy(uint32_t remote_ssrc, Clock* clock, - TaskQueueBase* worker_thread); + TaskQueueBase* worker_thread, + const WebRtcKeyValueConfig& field_trials); ~ReceiveStatisticsProxy() override; VideoReceiveStream::Stats GetStats() const; diff --git a/video/receive_statistics_proxy2_unittest.cc b/video/receive_statistics_proxy2_unittest.cc index 72b4e3c3a9..2bee54c072 100644 --- a/video/receive_statistics_proxy2_unittest.cc +++ b/video/receive_statistics_proxy2_unittest.cc @@ -25,9 +25,9 @@ #include "rtc_base/task_utils/to_queued_task.h" #include "rtc_base/thread.h" #include "system_wrappers/include/metrics.h" -#include "test/field_trial.h" #include "test/gtest.h" #include "test/run_loop.h" +#include "test/scoped_key_value_config.h" #include "video/video_receive_stream2.h" namespace webrtc { @@ -43,10 +43,11 @@ const int kHeight = 720; // TODO(sakal): ReceiveStatisticsProxy is lacking unittesting. class ReceiveStatisticsProxy2Test : public ::testing::Test { public: - ReceiveStatisticsProxy2Test() : fake_clock_(1234) { + explicit ReceiveStatisticsProxy2Test(std::string field_trials = "") + : field_trials_(field_trials), fake_clock_(1234) { metrics::Reset(); statistics_proxy_.reset(new ReceiveStatisticsProxy( - kRemoteSsrc, &fake_clock_, loop_.task_queue())); + kRemoteSsrc, &fake_clock_, loop_.task_queue(), field_trials_)); } ~ReceiveStatisticsProxy2Test() override { statistics_proxy_.reset(); } @@ -102,6 +103,7 @@ class ReceiveStatisticsProxy2Test : public ::testing::Test { return VideoFrameMetaData(frame, Now()); } + test::ScopedKeyValueConfig field_trials_; SimulatedClock fake_clock_; std::unique_ptr statistics_proxy_; test::RunLoop loop_; @@ -1719,25 +1721,16 @@ TEST_P(ReceiveStatisticsProxy2TestWithContent, } } -class DecodeTimeHistogramsKillswitch { - public: - explicit DecodeTimeHistogramsKillswitch(bool disable_histograms) - : field_trial_(disable_histograms - ? "WebRTC-DecodeTimeHistogramsKillSwitch/Enabled/" - : "") {} - - private: - webrtc::test::ScopedFieldTrials field_trial_; -}; - class ReceiveStatisticsProxy2TestWithDecodeTimeHistograms - : public DecodeTimeHistogramsKillswitch, - public ::testing::WithParamInterface< + : public ::testing::WithParamInterface< std::tuple>, public ReceiveStatisticsProxy2Test { public: ReceiveStatisticsProxy2TestWithDecodeTimeHistograms() - : DecodeTimeHistogramsKillswitch(std::get<0>(GetParam())) {} + : ReceiveStatisticsProxy2Test( + std::get<0>(GetParam()) + ? "WebRTC-DecodeTimeHistogramsKillSwitch/Enabled/" + : "") {} protected: const std::string kUmaPrefix = "WebRTC.Video.DecodeTimePerFrameInMs."; diff --git a/video/receive_statistics_proxy_unittest.cc b/video/receive_statistics_proxy_unittest.cc index 97fcdd6f7b..a10092701c 100644 --- a/video/receive_statistics_proxy_unittest.cc +++ b/video/receive_statistics_proxy_unittest.cc @@ -23,8 +23,8 @@ #include "api/video/video_frame_buffer.h" #include "api/video/video_rotation.h" #include "system_wrappers/include/metrics.h" -#include "test/field_trial.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" namespace webrtc { namespace { @@ -39,14 +39,17 @@ const int kHeight = 720; // TODO(sakal): ReceiveStatisticsProxy is lacking unittesting. class ReceiveStatisticsProxyTest : public ::testing::Test { public: - ReceiveStatisticsProxyTest() : fake_clock_(1234), config_(GetTestConfig()) {} + explicit ReceiveStatisticsProxyTest(std::string field_trials = "") + : field_trials_(field_trials), + fake_clock_(1234), + config_(GetTestConfig()) {} virtual ~ReceiveStatisticsProxyTest() {} protected: virtual void SetUp() { metrics::Reset(); - statistics_proxy_.reset( - new ReceiveStatisticsProxy(config_.rtp.remote_ssrc, &fake_clock_)); + statistics_proxy_.reset(new ReceiveStatisticsProxy( + config_.rtp.remote_ssrc, &fake_clock_, &field_trials_)); } VideoReceiveStream::Config GetTestConfig() { @@ -76,6 +79,7 @@ class ReceiveStatisticsProxyTest : public ::testing::Test { return frame; } + test::ScopedKeyValueConfig field_trials_; SimulatedClock fake_clock_; const VideoReceiveStream::Config config_; std::unique_ptr statistics_proxy_; @@ -1692,25 +1696,16 @@ TEST_P(ReceiveStatisticsProxyTestWithContent, } } -class DecodeTimeHistogramsKillswitch { - public: - explicit DecodeTimeHistogramsKillswitch(bool disable_histograms) - : field_trial_(disable_histograms - ? "WebRTC-DecodeTimeHistogramsKillSwitch/Enabled/" - : "") {} - - private: - webrtc::test::ScopedFieldTrials field_trial_; -}; - class ReceiveStatisticsProxyTestWithDecodeTimeHistograms - : public DecodeTimeHistogramsKillswitch, - public ::testing::WithParamInterface< + : public ::testing::WithParamInterface< std::tuple>, public ReceiveStatisticsProxyTest { public: ReceiveStatisticsProxyTestWithDecodeTimeHistograms() - : DecodeTimeHistogramsKillswitch(std::get<0>(GetParam())) {} + : ReceiveStatisticsProxyTest( + std::get<0>(GetParam()) + ? "WebRTC-DecodeTimeHistogramsKillSwitch/Enabled/" + : "") {} protected: const std::string kUmaPrefix = "WebRTC.Video.DecodeTimePerFrameInMs."; diff --git a/video/rtp_video_stream_receiver.cc b/video/rtp_video_stream_receiver.cc index 7caa78bba4..bcee8350b1 100644 --- a/video/rtp_video_stream_receiver.cc +++ b/video/rtp_video_stream_receiver.cc @@ -19,6 +19,7 @@ #include "absl/algorithm/container.h" #include "absl/memory/memory.h" #include "absl/types/optional.h" +#include "api/webrtc_key_value_config.h" #include "media/base/media_constants.h" #include "modules/pacing/packet_router.h" #include "modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h" @@ -46,7 +47,6 @@ #include "rtc_base/location.h" #include "rtc_base/logging.h" #include "rtc_base/strings/string_builder.h" -#include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/metrics.h" #include "system_wrappers/include/ntp_time.h" #include "video/receive_statistics_proxy.h" @@ -59,11 +59,11 @@ namespace { constexpr int kPacketBufferStartSize = 512; constexpr int kPacketBufferMaxSize = 2048; -int PacketBufferMaxSize() { +int PacketBufferMaxSize(const WebRtcKeyValueConfig& field_trials) { // The group here must be a positive power of 2, in which case that is used as // size. All other values shall result in the default value being used. const std::string group_name = - webrtc::field_trial::FindFullName("WebRTC-PacketBufferMaxSize"); + field_trials.Lookup("WebRTC-PacketBufferMaxSize"); int packet_buffer_max_size = kPacketBufferMaxSize; if (!group_name.empty() && (sscanf(group_name.c_str(), "%d", &packet_buffer_max_size) != 1 || @@ -211,7 +211,8 @@ RtpVideoStreamReceiver::RtpVideoStreamReceiver( KeyFrameRequestSender* keyframe_request_sender, OnCompleteFrameCallback* complete_frame_callback, rtc::scoped_refptr frame_decryptor, - rtc::scoped_refptr frame_transformer) + rtc::scoped_refptr frame_transformer, + const WebRtcKeyValueConfig* field_trials) : RtpVideoStreamReceiver(clock, transport, rtt_stats, @@ -225,7 +226,8 @@ RtpVideoStreamReceiver::RtpVideoStreamReceiver( keyframe_request_sender, complete_frame_callback, frame_decryptor, - frame_transformer) {} + frame_transformer, + field_trials) {} RtpVideoStreamReceiver::RtpVideoStreamReceiver( Clock* clock, @@ -241,8 +243,10 @@ RtpVideoStreamReceiver::RtpVideoStreamReceiver( KeyFrameRequestSender* keyframe_request_sender, OnCompleteFrameCallback* complete_frame_callback, rtc::scoped_refptr frame_decryptor, - rtc::scoped_refptr frame_transformer) - : clock_(clock), + rtc::scoped_refptr frame_transformer, + const WebRtcKeyValueConfig* field_trials) + : field_trials_(field_trials ? *field_trials : owned_field_trials_), + clock_(clock), config_(*config), packet_router_(packet_router), process_thread_(process_thread), @@ -270,7 +274,8 @@ RtpVideoStreamReceiver::RtpVideoStreamReceiver( // TODO(bugs.webrtc.org/10336): Let `rtcp_feedback_buffer_` communicate // directly with `rtp_rtcp_`. rtcp_feedback_buffer_(this, nack_sender, this), - packet_buffer_(kPacketBufferStartSize, PacketBufferMaxSize()), + packet_buffer_(kPacketBufferStartSize, + PacketBufferMaxSize(field_trials_)), reference_finder_(std::make_unique()), has_received_frame_(false), frames_decryptable_(false), @@ -305,7 +310,7 @@ RtpVideoStreamReceiver::RtpVideoStreamReceiver( } ParseFieldTrial( {&forced_playout_delay_max_ms_, &forced_playout_delay_min_ms_}, - field_trial::FindFullName("WebRTC-ForcePlayoutDelay")); + field_trials_.Lookup("WebRTC-ForcePlayoutDelay")); process_thread_->RegisterModule(rtp_rtcp_.get(), RTC_FROM_HERE); @@ -324,7 +329,7 @@ RtpVideoStreamReceiver::RtpVideoStreamReceiver( // Only construct the encrypted receiver if frame encryption is enabled. if (config_.crypto_options.sframe.require_frame_encryption) { buffered_frame_decryptor_ = - std::make_unique(this, this); + std::make_unique(this, this, field_trials_); if (frame_decryptor != nullptr) { buffered_frame_decryptor_->SetFrameDecryptor(std::move(frame_decryptor)); } @@ -361,7 +366,7 @@ void RtpVideoStreamReceiver::AddReceiveCodec( const std::map& codec_params, bool raw_payload) { if (codec_params.count(cricket::kH264FmtpSpsPpsIdrInKeyframe) || - field_trial::IsEnabled("WebRTC-SpsPpsIdrIsH264Keyframe")) { + field_trials_.IsEnabled("WebRTC-SpsPpsIdrIsH264Keyframe")) { MutexLock lock(&packet_buffer_lock_); packet_buffer_.ForceSpsPpsIdrIsH264Keyframe(); } @@ -949,7 +954,7 @@ void RtpVideoStreamReceiver::SetFrameDecryptor( RTC_DCHECK_RUN_ON(&network_tc_); if (buffered_frame_decryptor_ == nullptr) { buffered_frame_decryptor_ = - std::make_unique(this, this); + std::make_unique(this, this, field_trials_); } buffered_frame_decryptor_->SetFrameDecryptor(std::move(frame_decryptor)); } diff --git a/video/rtp_video_stream_receiver.h b/video/rtp_video_stream_receiver.h index abd4452d1a..1e0f7bcf3a 100644 --- a/video/rtp_video_stream_receiver.h +++ b/video/rtp_video_stream_receiver.h @@ -23,6 +23,7 @@ #include "api/array_view.h" #include "api/crypto/frame_decryptor_interface.h" #include "api/sequence_checker.h" +#include "api/transport/field_trial_based_config.h" #include "api/units/timestamp.h" #include "api/video/color_space.h" #include "api/video/video_codec_type.h" @@ -101,7 +102,8 @@ class RtpVideoStreamReceiver : public LossNotificationSender, KeyFrameRequestSender* keyframe_request_sender, OnCompleteFrameCallback* complete_frame_callback, rtc::scoped_refptr frame_decryptor, - rtc::scoped_refptr frame_transformer); + rtc::scoped_refptr frame_transformer, + const WebRtcKeyValueConfig* field_trials = nullptr); RtpVideoStreamReceiver( Clock* clock, @@ -122,7 +124,8 @@ class RtpVideoStreamReceiver : public LossNotificationSender, KeyFrameRequestSender* keyframe_request_sender, OnCompleteFrameCallback* complete_frame_callback, rtc::scoped_refptr frame_decryptor, - rtc::scoped_refptr frame_transformer); + rtc::scoped_refptr frame_transformer, + const WebRtcKeyValueConfig* field_trials = nullptr); ~RtpVideoStreamReceiver() override; void AddReceiveCodec(uint8_t payload_type, @@ -326,6 +329,9 @@ class RtpVideoStreamReceiver : public LossNotificationSender, bool is_keyframe) RTC_RUN_ON(worker_task_checker_); + const WebRtcKeyValueConfig& field_trials_; + FieldTrialBasedConfig owned_field_trials_; + Clock* const clock_; // Ownership of this object lies with VideoReceiveStream, which owns `this`. const VideoReceiveStream::Config& config_; diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc index 7000f6b6bc..c5594ba96e 100644 --- a/video/rtp_video_stream_receiver2.cc +++ b/video/rtp_video_stream_receiver2.cc @@ -45,7 +45,6 @@ #include "rtc_base/location.h" #include "rtc_base/logging.h" #include "rtc_base/strings/string_builder.h" -#include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/metrics.h" #include "system_wrappers/include/ntp_time.h" @@ -57,11 +56,11 @@ namespace { constexpr int kPacketBufferStartSize = 512; constexpr int kPacketBufferMaxSize = 2048; -int PacketBufferMaxSize() { +int PacketBufferMaxSize(const WebRtcKeyValueConfig& field_trials) { // The group here must be a positive power of 2, in which case that is used as // size. All other values shall result in the default value being used. const std::string group_name = - webrtc::field_trial::FindFullName("WebRTC-PacketBufferMaxSize"); + field_trials.Lookup("WebRTC-PacketBufferMaxSize"); int packet_buffer_max_size = kPacketBufferMaxSize; if (!group_name.empty() && (sscanf(group_name.c_str(), "%d", &packet_buffer_max_size) != 1 || @@ -217,8 +216,10 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2( KeyFrameRequestSender* keyframe_request_sender, OnCompleteFrameCallback* complete_frame_callback, rtc::scoped_refptr frame_decryptor, - rtc::scoped_refptr frame_transformer) - : clock_(clock), + rtc::scoped_refptr frame_transformer, + const WebRtcKeyValueConfig& field_trials) + : field_trials_(field_trials), + clock_(clock), config_(*config), packet_router_(packet_router), ntp_estimator_(clock), @@ -252,7 +253,8 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2( clock_, &rtcp_feedback_buffer_, &rtcp_feedback_buffer_)), - packet_buffer_(kPacketBufferStartSize, PacketBufferMaxSize()), + packet_buffer_(kPacketBufferStartSize, + PacketBufferMaxSize(field_trials_)), reference_finder_(std::make_unique()), has_received_frame_(false), frames_decryptable_(false), @@ -289,7 +291,7 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2( ParseFieldTrial( {&forced_playout_delay_max_ms_, &forced_playout_delay_min_ms_}, - field_trial::FindFullName("WebRTC-ForcePlayoutDelay")); + field_trials_.Lookup("WebRTC-ForcePlayoutDelay")); if (config_.rtp.lntf.enabled) { loss_notification_controller_ = @@ -300,7 +302,7 @@ RtpVideoStreamReceiver2::RtpVideoStreamReceiver2( // Only construct the encrypted receiver if frame encryption is enabled. if (config_.crypto_options.sframe.require_frame_encryption) { buffered_frame_decryptor_ = - std::make_unique(this, this); + std::make_unique(this, this, field_trials_); if (frame_decryptor != nullptr) { buffered_frame_decryptor_->SetFrameDecryptor(std::move(frame_decryptor)); } @@ -330,7 +332,7 @@ void RtpVideoStreamReceiver2::AddReceiveCodec( bool raw_payload) { RTC_DCHECK_RUN_ON(&packet_sequence_checker_); if (codec_params.count(cricket::kH264FmtpSpsPpsIdrInKeyframe) || - field_trial::IsEnabled("WebRTC-SpsPpsIdrIsH264Keyframe")) { + field_trials_.IsEnabled("WebRTC-SpsPpsIdrIsH264Keyframe")) { packet_buffer_.ForceSpsPpsIdrIsH264Keyframe(); } payload_type_map_.emplace( @@ -887,7 +889,7 @@ void RtpVideoStreamReceiver2::SetFrameDecryptor( RTC_DCHECK_RUN_ON(&packet_sequence_checker_); if (buffered_frame_decryptor_ == nullptr) { buffered_frame_decryptor_ = - std::make_unique(this, this); + std::make_unique(this, this, field_trials_); } buffered_frame_decryptor_->SetFrameDecryptor(std::move(frame_decryptor)); } diff --git a/video/rtp_video_stream_receiver2.h b/video/rtp_video_stream_receiver2.h index 48aab34a41..88b012d63c 100644 --- a/video/rtp_video_stream_receiver2.h +++ b/video/rtp_video_stream_receiver2.h @@ -96,7 +96,8 @@ class RtpVideoStreamReceiver2 : public LossNotificationSender, KeyFrameRequestSender* keyframe_request_sender, OnCompleteFrameCallback* complete_frame_callback, rtc::scoped_refptr frame_decryptor, - rtc::scoped_refptr frame_transformer); + rtc::scoped_refptr frame_transformer, + const WebRtcKeyValueConfig& field_trials); ~RtpVideoStreamReceiver2() override; void AddReceiveCodec(uint8_t payload_type, @@ -286,6 +287,7 @@ class RtpVideoStreamReceiver2 : public LossNotificationSender, bool is_keyframe) RTC_RUN_ON(packet_sequence_checker_); + const WebRtcKeyValueConfig& field_trials_; Clock* const clock_; // Ownership of this object lies with VideoReceiveStream, which owns `this`. const VideoReceiveStream::Config& config_; diff --git a/video/rtp_video_stream_receiver2_unittest.cc b/video/rtp_video_stream_receiver2_unittest.cc index cf033ef8a2..062476269a 100644 --- a/video/rtp_video_stream_receiver2_unittest.cc +++ b/video/rtp_video_stream_receiver2_unittest.cc @@ -33,12 +33,11 @@ #include "rtc_base/byte_buffer.h" #include "rtc_base/logging.h" #include "system_wrappers/include/clock.h" -#include "system_wrappers/include/field_trial.h" -#include "test/field_trial.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/mock_frame_transformer.h" #include "test/mock_transport.h" +#include "test/scoped_key_value_config.h" #include "test/time_controller/simulated_task_queue.h" #include "test/time_controller/simulated_time_controller.h" @@ -152,7 +151,7 @@ class RtpVideoStreamReceiver2Test : public ::testing::Test, "RtpVideoStreamReceiver2Test", TaskQueueFactory::Priority::NORMAL)), task_queue_setter_(task_queue_.get()), - override_field_trials_(field_trials), + field_trials_(field_trials), config_(CreateConfig()) { rtp_receive_statistics_ = ReceiveStatistics::Create(Clock::GetRealTimeClock()); @@ -161,7 +160,7 @@ class RtpVideoStreamReceiver2Test : public ::testing::Test, nullptr, nullptr, &config_, rtp_receive_statistics_.get(), nullptr, nullptr, &nack_periodic_processor_, &mock_nack_sender_, &mock_key_frame_request_sender_, &mock_on_complete_frame_callback_, - nullptr, nullptr); + nullptr, nullptr, field_trials_); rtp_video_stream_receiver_->AddReceiveCodec(kPayloadType, kVideoCodecGeneric, {}, /*raw_payload=*/false); @@ -229,7 +228,7 @@ class RtpVideoStreamReceiver2Test : public ::testing::Test, std::unique_ptr task_queue_; TokenTaskQueue::CurrentTaskQueueSetter task_queue_setter_; - const webrtc::test::ScopedFieldTrials override_field_trials_; + webrtc::test::ScopedKeyValueConfig field_trials_; VideoReceiveStream::Config config_; NackPeriodicProcessor nack_periodic_processor_; MockNackSender mock_nack_sender_; @@ -1119,7 +1118,8 @@ TEST_F(RtpVideoStreamReceiver2Test, TransformFrame) { TaskQueueBase::Current(), Clock::GetRealTimeClock(), &mock_transport_, nullptr, nullptr, &config_, rtp_receive_statistics_.get(), nullptr, nullptr, &nack_periodic_processor_, &mock_nack_sender_, nullptr, - &mock_on_complete_frame_callback_, nullptr, mock_frame_transformer); + &mock_on_complete_frame_callback_, nullptr, mock_frame_transformer, + field_trials_); receiver->AddReceiveCodec(kPayloadType, kVideoCodecGeneric, {}, /*raw_payload=*/false); diff --git a/video/rtp_video_stream_receiver_unittest.cc b/video/rtp_video_stream_receiver_unittest.cc index 6c4148a091..0dc8075cb5 100644 --- a/video/rtp_video_stream_receiver_unittest.cc +++ b/video/rtp_video_stream_receiver_unittest.cc @@ -33,12 +33,11 @@ #include "rtc_base/byte_buffer.h" #include "rtc_base/logging.h" #include "system_wrappers/include/clock.h" -#include "system_wrappers/include/field_trial.h" -#include "test/field_trial.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/mock_frame_transformer.h" #include "test/mock_transport.h" +#include "test/scoped_key_value_config.h" using ::testing::_; using ::testing::ElementsAre; @@ -144,7 +143,7 @@ class RtpVideoStreamReceiverTest : public ::testing::Test { public: RtpVideoStreamReceiverTest() : RtpVideoStreamReceiverTest("") {} explicit RtpVideoStreamReceiverTest(std::string field_trials) - : override_field_trials_(field_trials), + : field_trials_(field_trials), config_(CreateConfig()), process_thread_(ProcessThread::Create("TestThread")) { rtp_receive_statistics_ = @@ -153,7 +152,7 @@ class RtpVideoStreamReceiverTest : public ::testing::Test { Clock::GetRealTimeClock(), &mock_transport_, nullptr, nullptr, &config_, rtp_receive_statistics_.get(), nullptr, nullptr, process_thread_.get(), &mock_nack_sender_, &mock_key_frame_request_sender_, - &mock_on_complete_frame_callback_, nullptr, nullptr); + &mock_on_complete_frame_callback_, nullptr, nullptr, &field_trials_); rtp_video_stream_receiver_->AddReceiveCodec(kPayloadType, kVideoCodecGeneric, {}, /*raw_payload=*/false); @@ -211,7 +210,7 @@ class RtpVideoStreamReceiverTest : public ::testing::Test { return config; } - const webrtc::test::ScopedFieldTrials override_field_trials_; + webrtc::test::ScopedKeyValueConfig field_trials_; VideoReceiveStream::Config config_; MockNackSender mock_nack_sender_; MockKeyFrameRequestSender mock_key_frame_request_sender_; @@ -1159,7 +1158,7 @@ TEST_F(RtpVideoStreamReceiverTest, TransformFrame) { Clock::GetRealTimeClock(), &mock_transport_, nullptr, nullptr, &config_, rtp_receive_statistics_.get(), nullptr, nullptr, process_thread_.get(), &mock_nack_sender_, nullptr, &mock_on_complete_frame_callback_, nullptr, - mock_frame_transformer); + mock_frame_transformer, &field_trials_); receiver->AddReceiveCodec(kPayloadType, kVideoCodecGeneric, {}, /*raw_payload=*/false); diff --git a/video/send_statistics_proxy.cc b/video/send_statistics_proxy.cc index 2eafa305c9..aa8a0781a9 100644 --- a/video/send_statistics_proxy.cc +++ b/video/send_statistics_proxy.cc @@ -25,7 +25,6 @@ #include "rtc_base/logging.h" #include "rtc_base/numerics/mod_ops.h" #include "rtc_base/strings/string_builder.h" -#include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/metrics.h" namespace webrtc { @@ -110,17 +109,17 @@ absl::optional GetFallbackMaxPixels(const std::string& group) { return absl::optional(max_pixels); } -absl::optional GetFallbackMaxPixelsIfFieldTrialEnabled() { - std::string group = - webrtc::field_trial::FindFullName(kVp8ForcedFallbackEncoderFieldTrial); +absl::optional GetFallbackMaxPixelsIfFieldTrialEnabled( + const webrtc::WebRtcKeyValueConfig& field_trials) { + std::string group = field_trials.Lookup(kVp8ForcedFallbackEncoderFieldTrial); return (absl::StartsWith(group, "Enabled")) ? GetFallbackMaxPixels(group.substr(7)) : absl::optional(); } -absl::optional GetFallbackMaxPixelsIfFieldTrialDisabled() { - std::string group = - webrtc::field_trial::FindFullName(kVp8ForcedFallbackEncoderFieldTrial); +absl::optional GetFallbackMaxPixelsIfFieldTrialDisabled( + const webrtc::WebRtcKeyValueConfig& field_trials) { + std::string group = field_trials.Lookup(kVp8ForcedFallbackEncoderFieldTrial); return (absl::StartsWith(group, "Disabled")) ? GetFallbackMaxPixels(group.substr(8)) : absl::optional(); @@ -132,12 +131,15 @@ const int SendStatisticsProxy::kStatsTimeoutMs = 5000; SendStatisticsProxy::SendStatisticsProxy( Clock* clock, const VideoSendStream::Config& config, - VideoEncoderConfig::ContentType content_type) + VideoEncoderConfig::ContentType content_type, + const WebRtcKeyValueConfig& field_trials) : clock_(clock), payload_name_(config.rtp.payload_name), rtp_config_(config.rtp), - fallback_max_pixels_(GetFallbackMaxPixelsIfFieldTrialEnabled()), - fallback_max_pixels_disabled_(GetFallbackMaxPixelsIfFieldTrialDisabled()), + fallback_max_pixels_( + GetFallbackMaxPixelsIfFieldTrialEnabled(field_trials)), + fallback_max_pixels_disabled_( + GetFallbackMaxPixelsIfFieldTrialDisabled(field_trials)), content_type_(content_type), start_ms_(clock->TimeInMilliseconds()), encode_time_(kEncodeTimeWeigthFactor), diff --git a/video/send_statistics_proxy.h b/video/send_statistics_proxy.h index c38488dd84..f5d17ea276 100644 --- a/video/send_statistics_proxy.h +++ b/video/send_statistics_proxy.h @@ -20,6 +20,7 @@ #include "api/video/video_codec_constants.h" #include "api/video/video_stream_encoder_observer.h" #include "api/video_codecs/video_encoder_config.h" +#include "api/webrtc_key_value_config.h" #include "call/video_send_stream.h" #include "modules/include/module_common_types_public.h" #include "modules/rtp_rtcp/include/report_block_data.h" @@ -51,7 +52,8 @@ class SendStatisticsProxy : public VideoStreamEncoderObserver, SendStatisticsProxy(Clock* clock, const VideoSendStream::Config& config, - VideoEncoderConfig::ContentType content_type); + VideoEncoderConfig::ContentType content_type, + const WebRtcKeyValueConfig& field_trials); ~SendStatisticsProxy() override; virtual VideoSendStream::Stats GetStats(); diff --git a/video/send_statistics_proxy_unittest.cc b/video/send_statistics_proxy_unittest.cc index 9c3b2c188b..b5731b5151 100644 --- a/video/send_statistics_proxy_unittest.cc +++ b/video/send_statistics_proxy_unittest.cc @@ -25,8 +25,8 @@ #include "api/video_codecs/video_encoder_config.h" #include "rtc_base/fake_clock.h" #include "system_wrappers/include/metrics.h" -#include "test/field_trial.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" namespace webrtc { namespace { @@ -70,9 +70,10 @@ class SendStatisticsProxyTest : public ::testing::Test { protected: virtual void SetUp() { metrics::Reset(); - statistics_proxy_.reset(new SendStatisticsProxy( - &fake_clock_, GetTestConfig(), - VideoEncoderConfig::ContentType::kRealtimeVideo)); + statistics_proxy_.reset( + new SendStatisticsProxy(&fake_clock_, GetTestConfig(), + VideoEncoderConfig::ContentType::kRealtimeVideo, + override_field_trials_)); expected_ = VideoSendStream::Stats(); for (const auto& ssrc : config_.rtp.ssrcs) { expected_.substreams[ssrc].type = @@ -175,7 +176,7 @@ class SendStatisticsProxyTest : public ::testing::Test { } } - test::ScopedFieldTrials override_field_trials_; + test::ScopedKeyValueConfig override_field_trials_; SimulatedClock fake_clock_; std::unique_ptr statistics_proxy_; VideoSendStream::Config config_; @@ -1925,10 +1926,12 @@ 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)); + &fake_clock_, config, VideoEncoderConfig::ContentType::kRealtimeVideo, + field_trials)); EncodedImage encoded_image; CodecSpecificInfo codec_info; @@ -1969,10 +1972,12 @@ TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_Vp9) { } 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)); + &fake_clock_, config, VideoEncoderConfig::ContentType::kRealtimeVideo, + field_trials)); EncodedImage encoded_image; CodecSpecificInfo codec_info; @@ -2504,9 +2509,10 @@ TEST_F(SendStatisticsProxyTest, GetStatsReportsIsRtx) { } TEST_F(SendStatisticsProxyTest, GetStatsReportsIsFlexFec) { - statistics_proxy_.reset( - new SendStatisticsProxy(&fake_clock_, GetTestConfigWithFlexFec(), - VideoEncoderConfig::ContentType::kRealtimeVideo)); + test::ScopedKeyValueConfig field_trials; + statistics_proxy_.reset(new SendStatisticsProxy( + &fake_clock_, GetTestConfigWithFlexFec(), + VideoEncoderConfig::ContentType::kRealtimeVideo, field_trials)); StreamDataCountersCallback* proxy = static_cast(statistics_proxy_.get()); @@ -2523,9 +2529,10 @@ TEST_F(SendStatisticsProxyTest, GetStatsReportsIsFlexFec) { } TEST_F(SendStatisticsProxyTest, SendBitratesAreReportedWithFlexFecEnabled) { - statistics_proxy_.reset( - new SendStatisticsProxy(&fake_clock_, GetTestConfigWithFlexFec(), - VideoEncoderConfig::ContentType::kRealtimeVideo)); + test::ScopedKeyValueConfig field_trials; + statistics_proxy_.reset(new SendStatisticsProxy( + &fake_clock_, GetTestConfigWithFlexFec(), + VideoEncoderConfig::ContentType::kRealtimeVideo, field_trials)); StreamDataCountersCallback* proxy = static_cast(statistics_proxy_.get()); @@ -2730,10 +2737,12 @@ 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)); + &fake_clock_, config, VideoEncoderConfig::ContentType::kRealtimeVideo, + field_trials)); StreamDataCountersCallback* proxy = static_cast(statistics_proxy_.get()); @@ -2781,10 +2790,12 @@ 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)); + &fake_clock_, config, VideoEncoderConfig::ContentType::kRealtimeVideo, + field_trials)); StreamDataCountersCallback* proxy = static_cast(statistics_proxy_.get()); diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc index c2e79460da..8a452fa23a 100644 --- a/video/video_receive_stream2.cc +++ b/video/video_receive_stream2.cc @@ -62,7 +62,6 @@ #include "rtc_base/time_utils.h" #include "rtc_base/trace_event.h" #include "system_wrappers/include/clock.h" -#include "system_wrappers/include/field_trial.h" #include "video/call_stats2.h" #include "video/frame_decode_scheduler.h" #include "video/frame_dumping_decoder.h" @@ -131,12 +130,12 @@ class WebRtcRecordableEncodedFrame : public RecordableEncodedFrame { absl::optional color_space_; }; -RenderResolution InitialDecoderResolution() { +RenderResolution InitialDecoderResolution( + const WebRtcKeyValueConfig& field_trials) { FieldTrialOptional width("w"); FieldTrialOptional height("h"); - ParseFieldTrial( - {&width, &height}, - field_trial::FindFullName("WebRTC-Video-InitialDecoderResolution")); + ParseFieldTrial({&width, &height}, + field_trials.Lookup("WebRTC-Video-InitialDecoderResolution")); if (width && height) { return RenderResolution(width.Value(), height.Value()); } @@ -221,7 +220,10 @@ VideoReceiveStream2::VideoReceiveStream2( clock_(clock), call_stats_(call_stats), source_tracker_(clock_), - stats_proxy_(config_.rtp.remote_ssrc, clock_, call->worker_thread()), + stats_proxy_(config_.rtp.remote_ssrc, + clock_, + call->worker_thread(), + call->trials()), rtp_receive_statistics_(ReceiveStatistics::Create(clock_)), timing_(timing), video_receiver_(clock_, timing_.get()), @@ -239,7 +241,8 @@ VideoReceiveStream2::VideoReceiveStream2( nullptr, // Use default KeyFrameRequestSender this, // OnCompleteFrameCallback std::move(config_.frame_decryptor), - std::move(config_.frame_transformer)), + std::move(config_.frame_transformer), + call->trials()), rtp_stream_sync_(call->worker_thread(), this), max_wait_for_keyframe_ms_(DetermineMaxWaitForFrame(config_, true)), max_wait_for_frame_ms_(DetermineMaxWaitForFrame(config_, false)), @@ -274,7 +277,7 @@ VideoReceiveStream2::VideoReceiveStream2( frame_buffer_ = FrameBufferProxy::CreateFromFieldTrial( clock_, call_->worker_thread(), timing_.get(), &stats_proxy_, &decode_queue_, this, TimeDelta::Millis(max_wait_for_keyframe_ms_), - TimeDelta::Millis(max_wait_for_frame_ms_), decode_sync_); + TimeDelta::Millis(max_wait_for_frame_ms_), decode_sync_, call_->trials()); if (config_.rtp.rtx_ssrc) { rtx_receive_stream_ = std::make_unique( @@ -287,12 +290,12 @@ VideoReceiveStream2::VideoReceiveStream2( ParseFieldTrial({&low_latency_renderer_enabled_, &low_latency_renderer_include_predecode_buffer_}, - field_trial::FindFullName("WebRTC-LowLatencyRenderer")); + call_->trials().Lookup("WebRTC-LowLatencyRenderer")); ParseFieldTrial( { &maximum_pre_stream_decoders_, }, - field_trial::FindFullName("WebRTC-PreStreamDecoders")); + call_->trials().Lookup("WebRTC-PreStreamDecoders")); } VideoReceiveStream2::~VideoReceiveStream2() { @@ -388,7 +391,8 @@ void VideoReceiveStream2::Start() { VideoDecoder::Settings settings; settings.set_codec_type( PayloadStringToCodecType(decoder.video_format.name)); - settings.set_max_render_resolution(InitialDecoderResolution()); + settings.set_max_render_resolution( + InitialDecoderResolution(call_->trials())); settings.set_number_of_cores(num_cpu_cores_); const bool raw_payload = @@ -504,7 +508,7 @@ void VideoReceiveStream2::CreateAndRegisterExternalDecoder( } std::string decoded_output_file = - field_trial::FindFullName("WebRTC-DecoderDataDumpDirectory"); + call_->trials().Lookup("WebRTC-DecoderDataDumpDirectory"); // Because '/' can't be used inside a field trial parameter, we use ';' // instead. // This is only relevant to WebRTC-DecoderDataDumpDirectory diff --git a/video/video_receive_stream2.h b/video/video_receive_stream2.h index 6a7795da69..2b65844c00 100644 --- a/video/video_receive_stream2.h +++ b/video/video_receive_stream2.h @@ -332,6 +332,7 @@ class VideoReceiveStream2 // Used to signal destruction to potentially pending tasks. ScopedTaskSafety task_safety_; }; + } // namespace internal } // namespace webrtc diff --git a/video/video_receive_stream2_unittest.cc b/video/video_receive_stream2_unittest.cc index 213df389c3..c7718454fb 100644 --- a/video/video_receive_stream2_unittest.cc +++ b/video/video_receive_stream2_unittest.cc @@ -33,11 +33,11 @@ #include "rtc_base/event.h" #include "system_wrappers/include/clock.h" #include "test/fake_decoder.h" -#include "test/field_trial.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/mock_transport.h" #include "test/run_loop.h" +#include "test/scoped_key_value_config.h" #include "test/time_controller/simulated_time_controller.h" #include "test/video_decoder_proxy_factory.h" #include "video/call_stats2.h" @@ -79,8 +79,9 @@ class VideoReceiveStream2Test : public ::testing::Test { : task_queue_factory_(CreateDefaultTaskQueueFactory()), h264_decoder_factory_(&mock_h264_video_decoder_), config_(&mock_transport_, &h264_decoder_factory_), - call_stats_(Clock::GetRealTimeClock(), loop_.task_queue()), - field_trials_("WebRTC-FrameBuffer3/arm:FrameBuffer3/") {} + call_stats_(Clock::GetRealTimeClock(), loop_.task_queue()) { + fake_call_.SetFieldTrial("WebRTC-FrameBuffer3/arm:FrameBuffer3/"); + } ~VideoReceiveStream2Test() override { if (video_receive_stream_) video_receive_stream_->UnregisterFromTransport(); @@ -127,7 +128,6 @@ class VideoReceiveStream2Test : public ::testing::Test { std::unique_ptr video_receive_stream_; Clock* clock_; VCMTiming* timing_; - const test::ScopedFieldTrials field_trials_; }; TEST_F(VideoReceiveStream2Test, CreateFrameFromH264FmtpSpropAndIdr) { @@ -538,9 +538,6 @@ class VideoReceiveStream2TestWithSimulatedClock VideoReceiveStream2TestWithSimulatedClock() : time_controller_(Timestamp::Millis(4711)), - field_trials_(std::get<1>(GetParam()) - ? "WebRTC-FrameBuffer3/arm:FrameBuffer3/" - : "WebRTC-FrameBuffer3/arm:FrameBuffer2/"), fake_decoder_factory_([this] { return std::make_unique([this] { OnFrameDecoded(); }); }), @@ -558,6 +555,11 @@ class VideoReceiveStream2TestWithSimulatedClock new VCMTiming(time_controller_.GetClock()), &nack_periodic_processor_, nullptr) { + if (std::get<1>(GetParam())) { + fake_call_.SetFieldTrial("WebRTC-FrameBuffer3/arm:FrameBuffer3/"); + } else { + fake_call_.SetFieldTrial("WebRTC-FrameBuffer3/arm:FrameBuffer2/"); + } video_receive_stream_.RegisterWithTransport( &rtp_stream_receiver_controller_); video_receive_stream_.Start(); @@ -582,7 +584,6 @@ class VideoReceiveStream2TestWithSimulatedClock protected: GlobalSimulatedTimeController time_controller_; - test::ScopedFieldTrials field_trials_; test::RunLoop loop_; test::FunctionVideoDecoderFactory fake_decoder_factory_; MockTransport mock_transport_; @@ -721,8 +722,7 @@ class VideoReceiveStream2TestWithLazyDecoderCreation : public ::testing::Test { } void SetUp() override { - webrtc::test::ScopedFieldTrials field_trials( - "WebRTC-PreStreamDecoders/max:0/"); + fake_call_.SetFieldTrial("WebRTC-PreStreamDecoders/max:0/"); constexpr int kDefaultNumCpuCores = 2; config_.rtp.remote_ssrc = 1111; config_.rtp.local_ssrc = 2222; diff --git a/video/video_send_stream.cc b/video/video_send_stream.cc index 8ab33dea68..ea51fb8f00 100644 --- a/video/video_send_stream.cc +++ b/video/video_send_stream.cc @@ -22,7 +22,6 @@ #include "rtc_base/strings/string_builder.h" #include "rtc_base/task_utils/to_queued_task.h" #include "system_wrappers/include/clock.h" -#include "system_wrappers/include/field_trial.h" #include "video/adaptation/overuse_frame_detector.h" #include "video/frame_cadence_adapter.h" #include "video/video_stream_encoder.h" @@ -63,7 +62,8 @@ size_t CalculateMaxHeaderSize(const RtpConfig& config) { } VideoStreamEncoder::BitrateAllocationCallbackType -GetBitrateAllocationCallbackType(const VideoSendStream::Config& config) { +GetBitrateAllocationCallbackType(const VideoSendStream::Config& config, + const WebRtcKeyValueConfig& field_trials) { if (webrtc::RtpExtension::FindHeaderExtensionByUri( config.rtp.extensions, webrtc::RtpExtension::kVideoLayersAllocationUri, @@ -73,7 +73,7 @@ GetBitrateAllocationCallbackType(const VideoSendStream::Config& config) { return VideoStreamEncoder::BitrateAllocationCallbackType:: kVideoLayersAllocation; } - if (field_trial::IsEnabled("WebRTC-Target-Bitrate-Rtcp")) { + if (field_trials.IsEnabled("WebRTC-Target-Bitrate-Rtcp")) { return VideoStreamEncoder::BitrateAllocationCallbackType:: kVideoBitrateAllocation; } @@ -123,7 +123,8 @@ std::unique_ptr CreateVideoStreamEncoder( return std::make_unique( clock, num_cpu_cores, stats_proxy, encoder_settings, std::make_unique(stats_proxy), - FrameCadenceAdapterInterface::Create(clock, encoder_queue_ptr), + FrameCadenceAdapterInterface::Create(clock, encoder_queue_ptr, + field_trials), std::move(encoder_queue), bitrate_allocation_callback_type, field_trials); } @@ -149,17 +150,17 @@ VideoSendStream::VideoSendStream( const WebRtcKeyValueConfig& field_trials) : rtp_transport_queue_(transport->GetWorkerQueue()), transport_(transport), - stats_proxy_(clock, config, encoder_config.content_type), + stats_proxy_(clock, config, encoder_config.content_type, field_trials), config_(std::move(config)), content_type_(encoder_config.content_type), - video_stream_encoder_( - CreateVideoStreamEncoder(clock, - num_cpu_cores, - task_queue_factory, - &stats_proxy_, - config_.encoder_settings, - GetBitrateAllocationCallbackType(config_), - field_trials)), + video_stream_encoder_(CreateVideoStreamEncoder( + clock, + num_cpu_cores, + task_queue_factory, + &stats_proxy_, + config_.encoder_settings, + GetBitrateAllocationCallbackType(config_, field_trials), + field_trials)), encoder_feedback_( clock, config_.rtp.ssrcs, @@ -191,7 +192,8 @@ VideoSendStream::VideoSendStream( encoder_config.max_bitrate_bps, encoder_config.bitrate_priority, encoder_config.content_type, - rtp_video_sender_) { + rtp_video_sender_, + field_trials) { RTC_DCHECK(config_.encoder_settings.encoder_factory); RTC_DCHECK(config_.encoder_settings.bitrate_allocator_factory); diff --git a/video/video_send_stream_impl.cc b/video/video_send_stream_impl.cc index 862dfde14c..27e5541d92 100644 --- a/video/video_send_stream_impl.cc +++ b/video/video_send_stream_impl.cc @@ -192,12 +192,12 @@ uint32_t GetInitialEncoderMaxBitrate(int initial_encoder_max_bitrate) { } // namespace -PacingConfig::PacingConfig() +PacingConfig::PacingConfig(const WebRtcKeyValueConfig& field_trials) : pacing_factor("factor", kStrictPacingMultiplier), max_pacing_delay("max_delay", TimeDelta::Millis(PacedSender::kMaxQueueLengthMs)) { ParseFieldTrial({&pacing_factor, &max_pacing_delay}, - field_trial::FindFullName("WebRTC-Video-Pacing")); + field_trials.Lookup("WebRTC-Video-Pacing")); } PacingConfig::PacingConfig(const PacingConfig&) = default; PacingConfig::~PacingConfig() = default; @@ -213,11 +213,12 @@ VideoSendStreamImpl::VideoSendStreamImpl( int initial_encoder_max_bitrate, double initial_encoder_bitrate_priority, VideoEncoderConfig::ContentType content_type, - RtpVideoSenderInterface* rtp_video_sender) + RtpVideoSenderInterface* rtp_video_sender, + const WebRtcKeyValueConfig& field_trials) : clock_(clock), has_alr_probing_(config->periodic_alr_bandwidth_probing || GetAlrSettings(content_type)), - pacing_config_(PacingConfig()), + pacing_config_(PacingConfig(field_trials)), stats_proxy_(stats_proxy), config_(config), rtp_transport_queue_(rtp_transport_queue), diff --git a/video/video_send_stream_impl.h b/video/video_send_stream_impl.h index 74f3a8631f..a2c3dfe430 100644 --- a/video/video_send_stream_impl.h +++ b/video/video_send_stream_impl.h @@ -25,6 +25,7 @@ #include "api/video/video_stream_encoder_interface.h" #include "api/video_codecs/video_encoder.h" #include "api/video_codecs/video_encoder_config.h" +#include "api/webrtc_key_value_config.h" #include "call/bitrate_allocator.h" #include "call/rtp_config.h" #include "call/rtp_transport_controller_send_interface.h" @@ -45,7 +46,7 @@ namespace internal { // Pacing buffer config; overridden by ALR config if provided. struct PacingConfig { - PacingConfig(); + explicit PacingConfig(const WebRtcKeyValueConfig& field_trials); PacingConfig(const PacingConfig&); PacingConfig& operator=(const PacingConfig&) = default; ~PacingConfig(); @@ -73,7 +74,8 @@ class VideoSendStreamImpl : public webrtc::BitrateAllocatorObserver, int initial_encoder_max_bitrate, double initial_encoder_bitrate_priority, VideoEncoderConfig::ContentType content_type, - RtpVideoSenderInterface* rtp_video_sender); + RtpVideoSenderInterface* rtp_video_sender, + const WebRtcKeyValueConfig& field_trials); ~VideoSendStreamImpl() override; void DeliverRtcp(const uint8_t* packet, size_t length); diff --git a/video/video_send_stream_impl_unittest.cc b/video/video_send_stream_impl_unittest.cc index 1a7381b030..e639aaf8cf 100644 --- a/video/video_send_stream_impl_unittest.cc +++ b/video/video_send_stream_impl_unittest.cc @@ -24,10 +24,10 @@ #include "rtc_base/experiments/alr_experiment.h" #include "rtc_base/fake_clock.h" #include "rtc_base/task_queue_for_test.h" -#include "test/field_trial.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/mock_transport.h" +#include "test/scoped_key_value_config.h" #include "video/test/mock_video_stream_encoder.h" #include "video/video_send_stream.h" @@ -119,7 +119,8 @@ class VideoSendStreamImplTest : public ::testing::Test { test_queue_("test_queue"), stats_proxy_(&clock_, config_, - VideoEncoderConfig::ContentType::kRealtimeVideo) { + VideoEncoderConfig::ContentType::kRealtimeVideo, + field_trials_) { config_.rtp.ssrcs.push_back(8080); config_.rtp.payload_type = 1; @@ -151,7 +152,7 @@ class VideoSendStreamImplTest : public ::testing::Test { &clock_, &stats_proxy_, &test_queue_, &transport_controller_, &bitrate_allocator_, &video_stream_encoder_, &config_, initial_encoder_max_bitrate, initial_encoder_bitrate_priority, - content_type, &rtp_video_sender_); + content_type, &rtp_video_sender_, field_trials_); // The call to GetStartBitrate() executes asynchronously on the tq. test_queue_.WaitForPreviouslyPostedTasks(); @@ -161,6 +162,7 @@ class VideoSendStreamImplTest : public ::testing::Test { } protected: + webrtc::test::ScopedKeyValueConfig field_trials_; NiceMock transport_; NiceMock transport_controller_; NiceMock bitrate_allocator_; @@ -338,8 +340,8 @@ TEST_F(VideoSendStreamImplTest, UpdatesObserverOnConfigurationChangeWithAlr) { TEST_F(VideoSendStreamImplTest, UpdatesObserverOnConfigurationChangeWithSimulcastVideoHysteresis) { - test::ScopedFieldTrials hysteresis_experiment( - "WebRTC-VideoRateControl/video_hysteresis:1.25/"); + test::ScopedKeyValueConfig hysteresis_experiment( + field_trials_, "WebRTC-VideoRateControl/video_hysteresis:1.25/"); auto vss_impl = CreateVideoSendStreamImpl( kDefaultInitialBitrateBps, kDefaultBitratePriority, diff --git a/video/video_send_stream_tests.cc b/video/video_send_stream_tests.cc index 01669a50dc..7ff9a8dea5 100644 --- a/video/video_send_stream_tests.cc +++ b/video/video_send_stream_tests.cc @@ -55,7 +55,6 @@ #include "test/configurable_frame_size_encoder.h" #include "test/fake_encoder.h" #include "test/fake_texture_frame.h" -#include "test/field_trial.h" #include "test/frame_forwarder.h" #include "test/frame_generator_capturer.h" #include "test/frame_utils.h" @@ -659,9 +658,10 @@ TEST_F(VideoSendStreamTest, SupportsUlpfecWithoutExtensions) { class VideoSendStreamWithoutUlpfecTest : public test::CallTest { protected: VideoSendStreamWithoutUlpfecTest() - : field_trial_("WebRTC-DisableUlpFecExperiment/Enabled/") {} + : field_trial_(field_trials_, "WebRTC-DisableUlpFecExperiment/Enabled/") { + } - test::ScopedFieldTrials field_trial_; + test::ScopedKeyValueConfig field_trial_; }; TEST_F(VideoSendStreamWithoutUlpfecTest, NoUlpfecIfDisabledThroughFieldTrial) { @@ -1680,10 +1680,9 @@ TEST_F(VideoSendStreamTest, DISABLED_RelayToDirectRoute) { static const int kStartBitrateBps = 300000; static const int kRelayBandwidthCapBps = 800000; static const int kMinPacketsToSend = 100; - webrtc::test::ScopedFieldTrials field_trials( - std::string(field_trial::GetFieldTrialString()) + - "WebRTC-Bwe-NetworkRouteConstraints/relay_cap:" + - std::to_string(kRelayBandwidthCapBps) + "bps/"); + webrtc::test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-Bwe-NetworkRouteConstraints/relay_cap:" + + std::to_string(kRelayBandwidthCapBps) + "bps/"); class RelayToDirectRouteTest : public test::EndToEndTest { public: @@ -2677,8 +2676,8 @@ TEST_F(VideoSendStreamTest, ReconfigureBitratesSetsEncoderBitratesCorrectly) { // TODO(bugs.webrtc.org/12058): If these fields trial are on, we get lower // bitrates than expected by this test, due to encoder pushback and subtracted // overhead. - webrtc::test::ScopedFieldTrials field_trials( - std::string(field_trial::GetFieldTrialString()) + + webrtc::test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-VideoRateControl/bitrate_adjuster:false/" "WebRTC-SendSideBwe-WithOverhead/Disabled/"); diff --git a/video/video_stream_encoder.cc b/video/video_stream_encoder.cc index 4c5975945b..58a262040b 100644 --- a/video/video_stream_encoder.cc +++ b/video/video_stream_encoder.cc @@ -48,7 +48,6 @@ #include "rtc_base/task_utils/to_queued_task.h" #include "rtc_base/thread_annotations.h" #include "rtc_base/trace_event.h" -#include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/metrics.h" #include "video/adaptation/video_stream_encoder_resource_manager.h" #include "video/alignment_adjuster.h" @@ -600,7 +599,8 @@ VideoStreamEncoder::VideoStreamEncoder( encoder_queue, BitrateAllocationCallbackType allocation_cb_type, const WebRtcKeyValueConfig& field_trials) - : worker_queue_(TaskQueueBase::Current()), + : field_trials_(field_trials), + worker_queue_(TaskQueueBase::Current()), number_of_cores_(number_of_cores), sink_(nullptr), settings_(settings), @@ -663,10 +663,10 @@ VideoStreamEncoder::VideoStreamEncoder( video_source_sink_controller_(/*sink=*/frame_cadence_adapter_.get(), /*source=*/nullptr), default_limits_allowed_( - !field_trial::IsEnabled("WebRTC-DefaultBitrateLimitsKillSwitch")), + !field_trials.IsEnabled("WebRTC-DefaultBitrateLimitsKillSwitch")), qp_parsing_allowed_( - !field_trial::IsEnabled("WebRTC-QpParsingKillSwitch")), - switch_encoder_on_init_failures_(!field_trial::IsDisabled( + !field_trials.IsEnabled("WebRTC-QpParsingKillSwitch")), + switch_encoder_on_init_failures_(!field_trials.IsDisabled( kSwitchEncoderOnInitializationFailuresFieldTrial)), encoder_queue_(std::move(encoder_queue)) { TRACE_EVENT0("webrtc", "VideoStreamEncoder::VideoStreamEncoder"); @@ -1220,7 +1220,7 @@ void VideoStreamEncoder::ReconfigureEncoder() { // * We have screensharing with layers. // * "WebRTC-FrameDropper" field trial is "Disabled". force_disable_frame_dropper_ = - field_trial::IsDisabled(kFrameDropperFieldTrial) || + field_trials_.IsDisabled(kFrameDropperFieldTrial) || (num_layers > 1 && codec.mode == VideoCodecMode::kScreensharing); VideoEncoder::EncoderInfo info = encoder_->GetEncoderInfo(); @@ -2263,8 +2263,8 @@ VideoStreamEncoder::AutomaticAnimationDetectionExperiment VideoStreamEncoder::ParseAutomatincAnimationDetectionFieldTrial() const { AutomaticAnimationDetectionExperiment result; - result.Parser()->Parse(webrtc::field_trial::FindFullName( - "WebRTC-AutomaticAnimationDetectionScreenshare")); + result.Parser()->Parse( + field_trials_.Lookup("WebRTC-AutomaticAnimationDetectionScreenshare")); if (!result.enabled) { RTC_LOG(LS_INFO) << "Automatic animation detection experiment is disabled."; diff --git a/video/video_stream_encoder.h b/video/video_stream_encoder.h index e89ba4a31c..679598694a 100644 --- a/video/video_stream_encoder.h +++ b/video/video_stream_encoder.h @@ -252,6 +252,7 @@ class VideoStreamEncoder : public VideoStreamEncoderInterface, void RequestEncoderSwitch() RTC_RUN_ON(&encoder_queue_); + const WebRtcKeyValueConfig& field_trials_; TaskQueueBase* const worker_queue_; const uint32_t number_of_cores_; diff --git a/video/video_stream_encoder_unittest.cc b/video/video_stream_encoder_unittest.cc index 03ee684cd8..d20b5ab891 100644 --- a/video/video_stream_encoder_unittest.cc +++ b/video/video_stream_encoder_unittest.cc @@ -611,8 +611,9 @@ class MockableSendStatisticsProxy : public SendStatisticsProxy { public: MockableSendStatisticsProxy(Clock* clock, const VideoSendStream::Config& config, - VideoEncoderConfig::ContentType content_type) - : SendStatisticsProxy(clock, config, content_type) {} + VideoEncoderConfig::ContentType content_type, + const WebRtcKeyValueConfig& field_trials) + : SendStatisticsProxy(clock, config, content_type, field_trials) {} VideoSendStream::Stats GetStats() override { MutexLock lock(&lock_); @@ -741,7 +742,8 @@ class SimpleVideoStreamEncoderFactory { std::make_unique( time_controller_.GetClock(), VideoSendStream::Config(nullptr), - webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo); + webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo, + field_trials_); std::unique_ptr bitrate_allocator_factory_ = CreateBuiltinVideoBitrateAllocatorFactory(); VideoStreamEncoderSettings encoder_settings_{ @@ -816,7 +818,8 @@ class VideoStreamEncoderTest : public ::testing::Test { stats_proxy_(new MockableSendStatisticsProxy( time_controller_.GetClock(), video_send_config_, - webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo)), + webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo, + field_trials_)), sink_(&time_controller_, &fake_encoder_) {} void SetUp() override { @@ -852,7 +855,7 @@ class VideoStreamEncoderTest : public ::testing::Test { TaskQueueBase* encoder_queue_ptr = encoder_queue.get(); std::unique_ptr cadence_adapter = FrameCadenceAdapterInterface::Create(time_controller_.GetClock(), - encoder_queue_ptr); + encoder_queue_ptr, field_trials_); video_stream_encoder_ = std::make_unique( &time_controller_, std::move(cadence_adapter), std::move(encoder_queue), stats_proxy_.get(), video_send_config_.encoder_settings, @@ -8901,10 +8904,11 @@ TEST(VideoStreamEncoderSimpleTest, CreateDestroy) { }; // Lots of boiler plate. + test::ScopedKeyValueConfig field_trials; GlobalSimulatedTimeController time_controller(Timestamp::Millis(0)); auto stats_proxy = std::make_unique( time_controller.GetClock(), VideoSendStream::Config(nullptr), - webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo); + webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo, field_trials); SimpleVideoStreamEncoderFactory::MockFakeEncoder mock_fake_encoder( time_controller.GetClock()); test::VideoEncoderProxyFactory encoder_factory(&mock_fake_encoder); @@ -8921,8 +8925,6 @@ TEST(VideoStreamEncoderSimpleTest, CreateDestroy) { std::unique_ptr encoder_queue(new SuperLazyTaskQueue()); - test::ScopedKeyValueConfig field_trials; - // Construct a VideoStreamEncoder instance and let it go out of scope without // doing anything else (including calling Stop()). This should be fine since // the posted init task will simply be deleted. @@ -9200,7 +9202,8 @@ TEST(VideoStreamEncoderFrameCadenceTest, test::ScopedKeyValueConfig field_trials( "WebRTC-ZeroHertzScreenshare/Enabled/"); auto adapter = FrameCadenceAdapterInterface::Create( - factory.GetTimeController()->GetClock(), encoder_queue.get()); + factory.GetTimeController()->GetClock(), encoder_queue.get(), + field_trials); FrameCadenceAdapterInterface* adapter_ptr = adapter.get(); MockVideoSourceInterface mock_source; From 2c4a4472a5fda609f91e3072513b91b78023e6ba Mon Sep 17 00:00:00 2001 From: Jeremy Leconte Date: Mon, 14 Mar 2022 15:22:37 +0100 Subject: [PATCH 167/847] Prepare uploader to be used as a 'merge script'. * Don't exit by throwing exceptions. * Rely on a dataclass instead of argument list. * Prepare to remove arg wait_upload because it's always true. * Remove unused args wait_timeout_sec and wait_timeout_secwait_polling_period_sec. Bug: webrtc:13806 Change-Id: I0879fa7fd22c72f5b174f8823bdd51d49f1f140b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255320 Reviewed-by: Mirko Bonadei Commit-Queue: Jeremy Leconte Reviewed-by: Andrey Logvin Cr-Commit-Position: refs/heads/main@{#36193} --- tools_webrtc/perf/catapult_uploader.py | 62 +++++++++++++++++--- tools_webrtc/perf/webrtc_dashboard_upload.py | 45 +++++++------- 2 files changed, 75 insertions(+), 32 deletions(-) diff --git a/tools_webrtc/perf/catapult_uploader.py b/tools_webrtc/perf/catapult_uploader.py index da376868b9..aae35ec656 100644 --- a/tools_webrtc/perf/catapult_uploader.py +++ b/tools_webrtc/perf/catapult_uploader.py @@ -14,6 +14,7 @@ import time import zlib +import dataclasses import httplib2 from tracing.value import histogram @@ -22,6 +23,41 @@ from tracing.value.diagnostics import reserved_infos +@dataclasses.dataclass +class UploaderOptions(): + """Required information to upload perf metrics. + + Attributes: + perf_dashboard_machine_group: The "master" the bots are grouped under. + This string is the group in the the perf dashboard path + group/bot/perf_id/metric/subtest. + bot: The bot running the test (e.g. webrtc-win-large-tests). + test_suite: The key for the test in the dashboard (i.e. what you select + in the top-level test suite selector in the dashboard + webrtc_git_hash: webrtc.googlesource.com commit hash. + commit_position: Commit pos corresponding to the git hash. + build_page_url: URL to the build page for this build. + dashboard_url: Which dashboard to use. + input_results_file: A HistogramSet proto file coming from WebRTC tests. + output_json_file: Where to write the output (for debugging). + wait_timeout_sec: Maximum amount of time in seconds that the script will + wait for the confirmation. + wait_polling_period_sec: Status will be requested from the Dashboard + every wait_polling_period_sec seconds. + """ + perf_dashboard_machine_group: str + bot: str + test_suite: str + webrtc_git_hash: str + commit_position: int + build_page_url: str + dashboard_url: str + input_results_file: str + output_json_file: str + wait_timeout_sec: datetime.timedelta = datetime.timedelta(seconds=1200) + wait_polling_period_sec: datetime.timedelta = datetime.timedelta(seconds=120) + + def _GenerateOauthToken(): args = ['luci-auth', 'token'] p = subprocess.Popen(args, @@ -195,7 +231,7 @@ def _NoInf(value): def _LoadHistogramSetFromProto(options): hs = histogram_set.HistogramSet() - with options.input_results_file as f: + with open(options.input_results_file, 'rb') as f: hs.ImportProto(f.read()) return hs @@ -217,11 +253,11 @@ def _AddBuildInfo(histograms, options): def _DumpOutput(histograms, output_file): - with output_file: - json.dump(_ApplyHacks(histograms.AsDicts()), output_file, indent=4) + with open(output_file, 'wb') as f: + json.dump(_ApplyHacks(histograms.AsDicts()), f, indent=4) -def UploadToDashboard(options): +def UploadToDashboardImpl(options): histograms = _LoadHistogramSetFromProto(options) _AddBuildInfo(histograms, options) @@ -236,15 +272,14 @@ def UploadToDashboard(options): return 1 upload_token = json.loads(content).get('token') - if not options.wait_for_upload or not upload_token: + if not upload_token: print(('Received 200 from dashboard. ', 'Not waiting for the upload status confirmation.')) return 0 response, resp_json = _WaitForUploadConfirmation( - options.dashboard_url, upload_token, - datetime.timedelta(seconds=options.wait_timeout_sec), - datetime.timedelta(seconds=options.wait_polling_period_sec)) + options.dashboard_url, upload_token, options.wait_timeout_sec, + options.wait_polling_period_sec) if ((resp_json and resp_json['state'] == 'COMPLETED') or _CheckFullUploadInfo(options.dashboard_url, upload_token)): @@ -260,6 +295,15 @@ def UploadToDashboard(options): print('Upload failed.') return 1 - print(('Upload wasn\'t completed in a given time: %d seconds.' % + print(('Upload wasn\'t completed in a given time: %s seconds.' % options.wait_timeout_sec)) return 1 + + +def UploadToDashboard(options): + try: + exit_code = UploadToDashboardImpl(options) + except RuntimeError as e: + print(e) + return 2 + return exit_code diff --git a/tools_webrtc/perf/webrtc_dashboard_upload.py b/tools_webrtc/perf/webrtc_dashboard_upload.py index 995d201ca8..0b58e58f78 100644 --- a/tools_webrtc/perf/webrtc_dashboard_upload.py +++ b/tools_webrtc/perf/webrtc_dashboard_upload.py @@ -32,9 +32,9 @@ def _CreateParser(): parser = argparse.ArgumentParser() parser.add_argument('--perf-dashboard-machine-group', required=True, - help='The "master" the bots are grouped under. This ' - 'string is the group in the the perf dashboard path ' - 'group/bot/perf_id/metric/subtest.') + help='The "machine_group" the bots are grouped under.' + 'This string is the group in the the perf dashboard ' + 'path group/bot/perf_id/metric/subtest.') parser.add_argument('--bot', required=True, help='The bot running the test (e.g. ' @@ -68,27 +68,14 @@ def _CreateParser(): parser.add_argument('--outdir', required=True, help='Path to the local out/ dir (usually out/Default)') + # TODO(crbug.com/webrtc/13806): Remove this argument. parser.add_argument('--wait-for-upload', action='store_true', - help='If specified, script will wait untill Chrome ' - 'perf dashboard confirms that the data was succesfully ' - 'proccessed and uploaded') - parser.add_argument('--wait-timeout-sec', - type=int, - default=1200, - help='Used only if wait-for-upload is True. Maximum ' - 'amount of time in seconds that the script will wait ' - 'for the confirmation.') - parser.add_argument('--wait-polling-period-sec', - type=int, - default=120, - help='Used only if wait-for-upload is True. Status ' - 'will be requested from the Dashboard every ' - 'wait-polling-period-sec seconds.') + help='DEPRECATED: this option will soon be removed') return parser -def _ConfigurePythonPath(options): +def _ConfigurePythonPath(outdir): # We just yank the python scripts we require into the PYTHONPATH. You could # also imagine a solution where we use for instance # protobuf:py_proto_runtime to copy catapult and protobuf code to out/. @@ -110,8 +97,8 @@ def _ConfigurePythonPath(options): # The webrtc_dashboard_upload gn rule will build the protobuf stub for # python, so put it in the path for this script before we attempt to import # it. - histogram_proto_path = os.path.join(options.outdir, 'pyproto', 'tracing', - 'tracing', 'proto') + histogram_proto_path = os.path.join(outdir, 'pyproto', 'tracing', 'tracing', + 'proto') sys.path.insert(0, histogram_proto_path) # Fail early in case the proto hasn't been built. @@ -127,11 +114,23 @@ def main(args): parser = _CreateParser() options = parser.parse_args(args) - _ConfigurePythonPath(options) + _ConfigurePythonPath(options.outdir) import catapult_uploader - return catapult_uploader.UploadToDashboard(options) + uploader_options = catapult_uploader.UploaderOptions( + perf_dashboard_machine_group=options.perf_dashboard_machine_group, + bot=options.bot, + test_suite=options.test_suite, + webrtc_git_hash=options.webrtc_git_hash, + commit_position=options.commit_position, + build_page_url=options.build_page_url, + dashboard_url=options.dashboard_url, + input_results_file=options.input_results_file, + output_json_file=options.output_json_file, + ) + + return catapult_uploader.UploadToDashboard(uploader_options) if __name__ == '__main__': From 19ba552e88350ef43c9cc78335b47d117d665771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Bostr=C3=B6m?= Date: Mon, 14 Mar 2022 15:19:43 +0100 Subject: [PATCH 168/847] Add TaskQueue::PostDelayedTaskWithPrecision helper method. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Just like the other PostTask methods, this is just short-hand for invoking the TaskQueueBase's version of the method. Drive-by fix: remove unnecessary return statement of void methods. Bug: webrtc:13604 Change-Id: I3d5cae66bfa06334058386909f041916dbfa5ab8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255342 Reviewed-by: Mirko Bonadei Commit-Queue: Henrik Boström Auto-Submit: Henrik Boström Reviewed-by: Mirko Bonadei Commit-Queue: Mirko Bonadei Cr-Commit-Position: refs/heads/main@{#36194} --- rtc_base/task_queue.cc | 13 ++++++++++--- rtc_base/task_queue.h | 16 ++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/rtc_base/task_queue.cc b/rtc_base/task_queue.cc index f0dbdb3ae0..0b54178405 100644 --- a/rtc_base/task_queue.cc +++ b/rtc_base/task_queue.cc @@ -30,18 +30,25 @@ bool TaskQueue::IsCurrent() const { } void TaskQueue::PostTask(std::unique_ptr task) { - return impl_->PostTask(std::move(task)); + impl_->PostTask(std::move(task)); } void TaskQueue::PostDelayedTask(std::unique_ptr task, uint32_t milliseconds) { - return impl_->PostDelayedTask(std::move(task), milliseconds); + impl_->PostDelayedTask(std::move(task), milliseconds); } void TaskQueue::PostDelayedHighPrecisionTask( std::unique_ptr task, uint32_t milliseconds) { - return impl_->PostDelayedHighPrecisionTask(std::move(task), milliseconds); + impl_->PostDelayedHighPrecisionTask(std::move(task), milliseconds); +} + +void TaskQueue::PostDelayedTaskWithPrecision( + webrtc::TaskQueueBase::DelayPrecision precision, + std::unique_ptr task, + uint32_t milliseconds) { + impl_->PostDelayedTaskWithPrecision(precision, std::move(task), milliseconds); } } // namespace rtc diff --git a/rtc_base/task_queue.h b/rtc_base/task_queue.h index 4ad3fedd95..ef97646988 100644 --- a/rtc_base/task_queue.h +++ b/rtc_base/task_queue.h @@ -100,6 +100,10 @@ class RTC_LOCKABLE RTC_EXPORT TaskQueue { uint32_t milliseconds); void PostDelayedHighPrecisionTask(std::unique_ptr task, uint32_t milliseconds); + void PostDelayedTaskWithPrecision( + webrtc::TaskQueueBase::DelayPrecision precision, + std::unique_ptr task, + uint32_t milliseconds); // std::enable_if is used here to make sure that calls to PostTask() with // std::unique_ptr would not end up being @@ -127,6 +131,18 @@ class RTC_LOCKABLE RTC_EXPORT TaskQueue { PostDelayedHighPrecisionTask( webrtc::ToQueuedTask(std::forward(closure)), milliseconds); } + template >::value>::type* = nullptr> + void PostDelayedTaskWithPrecision( + webrtc::TaskQueueBase::DelayPrecision precision, + Closure&& closure, + uint32_t milliseconds) { + PostDelayedTaskWithPrecision( + precision, webrtc::ToQueuedTask(std::forward(closure)), + milliseconds); + } private: webrtc::TaskQueueBase* const impl_; From fa2c945f73cc68a2a36c31475b2b89421f0aa933 Mon Sep 17 00:00:00 2001 From: Jeremy Leconte Date: Mon, 14 Mar 2022 18:05:38 +0100 Subject: [PATCH 169/847] Fix type issue for the uploader. This is a forward fix for https://webrtc-review.googlesource.com/c/src/+/255320. The error is the following: https://logs.chromium.org/logs/webrtc/buildbucket/cr-buildbucket/8819700229708372817/+/u/low_bandwidth_audio_perf_test_Dashboard_upload/stdout Bug: webrtc:13806 Change-Id: Ia7d5362d1131d9bab41a9112946a4c84e509d98f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255382 Reviewed-by: Mirko Bonadei Commit-Queue: Jeremy Leconte Cr-Commit-Position: refs/heads/main@{#36195} --- tools_webrtc/perf/webrtc_dashboard_upload.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools_webrtc/perf/webrtc_dashboard_upload.py b/tools_webrtc/perf/webrtc_dashboard_upload.py index 0b58e58f78..e141b2803f 100644 --- a/tools_webrtc/perf/webrtc_dashboard_upload.py +++ b/tools_webrtc/perf/webrtc_dashboard_upload.py @@ -58,12 +58,10 @@ def _CreateParser(): required=True, help='Which dashboard to use.') parser.add_argument('--input-results-file', - type=argparse.FileType('rb'), required=True, help='A HistogramSet proto file with output from ' 'WebRTC tests.') parser.add_argument('--output-json-file', - type=argparse.FileType('w'), help='Where to write the output (for debugging).') parser.add_argument('--outdir', required=True, From fa577c5eb6e4229f1b291b81a0bf7106a3a27a9c Mon Sep 17 00:00:00 2001 From: Jeremy Leconte Date: Mon, 14 Mar 2022 20:06:11 +0100 Subject: [PATCH 170/847] Fix file open mode issue for the uploader. This is a forward fix for https://webrtc-review.googlesource.com/c/src/+/255320. The error is the following: https://logs.chromium.org/logs/webrtc-internal/buildbucket/cr-buildbucket/8819696929332742321/+/u/webrtc_perf_tests_Dashboard_upload/stdout Bug: webrtc:13806 Change-Id: I1ccba1be69edf0b1023c1d197d2033bdc718f64b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255420 Owners-Override: Jeremy Leconte Reviewed-by: Jeremy Leconte Commit-Queue: Jeremy Leconte Cr-Commit-Position: refs/heads/main@{#36196} --- tools_webrtc/perf/catapult_uploader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools_webrtc/perf/catapult_uploader.py b/tools_webrtc/perf/catapult_uploader.py index aae35ec656..c33ac89d0c 100644 --- a/tools_webrtc/perf/catapult_uploader.py +++ b/tools_webrtc/perf/catapult_uploader.py @@ -253,7 +253,7 @@ def _AddBuildInfo(histograms, options): def _DumpOutput(histograms, output_file): - with open(output_file, 'wb') as f: + with open(output_file, 'w') as f: json.dump(_ApplyHacks(histograms.AsDicts()), f, indent=4) From 20b9eca8171926bd95a35a8fa1c8a3bb74baea3f Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Mon, 14 Mar 2022 15:01:39 -0700 Subject: [PATCH 171/847] Roll chromium_revision 4f72619488..133e39bd4f (980515:980799) Change log: https://chromium.googlesource.com/chromium/src/+log/4f72619488..133e39bd4f Full diff: https://chromium.googlesource.com/chromium/src/+/4f72619488..133e39bd4f Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/3da6de3d00..a87949dcf5 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/82ef032bfe..514a34c34d * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/95c966f7bb..4411a66d16 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/8d87ad3d0d..5c8b418145 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/e6b922054b..d831b95e88 * src/third_party/androidx: ZJtaPdQCjPuFTWcnohOdVfeuiXsz-eBjuMh0ZEu8CSgC..Hn2dB6ZTIa1GhUTs1KqxEzKA_xgWAAeP8xJN3GTY17cC * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/b326cacd0e..d55bdb952f * src/third_party/googletest/src: https://chromium.googlesource.com/external/github.com/google/googletest.git/+log/ae1b7ad430..ae5e06dd35 * src/third_party/r8: ZI5RPjew7GhVFtcZytIe_Sv91Pljm5KmhVan6HWxj8YC..ovozeRSDDfERnEFpDo_WS6OYOcEF7oT1JzGxCSf-g0kC * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/12c1fdb525..705846bd63 DEPS diff: https://chromium.googlesource.com/chromium/src/+/4f72619488..133e39bd4f/DEPS No update to Clang. BUG=None Change-Id: I3301d4e87f9c8698b577b70d59e92e9a59a16035 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255441 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36197} --- DEPS | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/DEPS b/DEPS index 01051d18e8..61fcdc561d 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': '4f726194886f36cc5161288634935240be541e06', + 'chromium_revision': '133e39bd4f0882e9c2b3e1225cee8f4767644207', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@3da6de3d00316c4563c2aa8e113c9c8b32a67bc6', + 'https://chromium.googlesource.com/chromium/src/base@a87949dcf55d15be38692a5efeeaa0af0804a3f0', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@82ef032bfe6e6661a774ff0d74b74b6e040bff73', + 'https://chromium.googlesource.com/chromium/src/build@514a34c34da56559bc13fbbe6ecb923f14ebf7ef', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@113dd1badbcbffea108a8c95ac7c89c22bfd25f3', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@95c966f7bba0b3e5474b8522b404d815b6121e3b', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@4411a66d163a6408c8c14f50a6a1c935ed690dd5', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@8d87ad3d0dff1af42d07608e89399d6d36d367f3', + 'https://chromium.googlesource.com/chromium/src/testing@5c8b4181457e77a36b1b821a4e51757e081c4cab', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@e6b922054bf8d42d823c0641f83cbe72dbe4e97e', + 'https://chromium.googlesource.com/chromium/src/third_party@d831b95e881a7ab952a733d507a7de4e6c9133b1', 'src/buildtools/linux64': { 'packages': [ @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@b326cacd0ec11fef9b8ee9e68d4e9704f8010eb9', + 'https://chromium.googlesource.com/catapult.git@d55bdb952f5c4c0a0abe36df3af65071a3801e0c', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -182,7 +182,7 @@ deps = { 'dep_type': 'cipd', }, 'src/third_party/googletest/src': - 'https://chromium.googlesource.com/external/github.com/google/googletest.git@ae1b7ad4308249bfa928e65d1a33be117fc0992c', + 'https://chromium.googlesource.com/external/github.com/google/googletest.git@ae5e06dd35c6137d335331b0815cf1f60fd7e3c5', 'src/third_party/icu': { 'url': 'https://chromium.googlesource.com/chromium/deps/icu.git@1fa4e3959ec6637182b7318ac1d382799454806d', }, @@ -253,7 +253,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/r8', - 'version': 'ZI5RPjew7GhVFtcZytIe_Sv91Pljm5KmhVan6HWxj8YC', + 'version': 'ovozeRSDDfERnEFpDo_WS6OYOcEF7oT1JzGxCSf-g0kC', }, ], 'condition': 'checkout_android', @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@12c1fdb5256c9704d75fb07365ba4ffb1a6f51b3', + 'https://chromium.googlesource.com/chromium/src/tools@705846bd63131a0150c1e73535311344f7afea82', 'src/third_party/accessibility_test_framework': { 'packages': [ @@ -384,7 +384,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/androidx', - 'version': 'ZJtaPdQCjPuFTWcnohOdVfeuiXsz-eBjuMh0ZEu8CSgC', + 'version': 'Hn2dB6ZTIa1GhUTs1KqxEzKA_xgWAAeP8xJN3GTY17cC', }, ], 'condition': 'checkout_android', From d041c975d16b0e3bdb5c764da9b5c668fe817988 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Mon, 14 Mar 2022 19:03:21 -0700 Subject: [PATCH 172/847] Roll chromium_revision 133e39bd4f..e4031d975b (980799:980920) Change log: https://chromium.googlesource.com/chromium/src/+log/133e39bd4f..e4031d975b Full diff: https://chromium.googlesource.com/chromium/src/+/133e39bd4f..e4031d975b Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/a87949dcf5..f9e1883ea5 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/514a34c34d..18a1f1939e * src/buildtools/linux64: git_revision:f27bae882b2178ccc3c24f314c88db9a34118992..git_revision:bd99dbf98cbdefe18a4128189665c5761263bcfb * src/buildtools/mac: git_revision:f27bae882b2178ccc3c24f314c88db9a34118992..git_revision:bd99dbf98cbdefe18a4128189665c5761263bcfb * src/buildtools/third_party/libc++abi/trunk: https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git/+log/289d52ce75..a897d0f3f8 * src/buildtools/win: git_revision:f27bae882b2178ccc3c24f314c88db9a34118992..git_revision:bd99dbf98cbdefe18a4128189665c5761263bcfb * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/4411a66d16..a44157ad6f * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/5c8b418145..252b25d19e * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/d831b95e88..3baf779ae4 * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/d55bdb952f..63a615bbdb * src/third_party/dav1d/libdav1d: https://chromium.googlesource.com/external/github.com/videolan/dav1d.git/+log/493ffb12f7..b1a5189c9d * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/c848a4ed33..3481645827 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/705846bd63..25e5713ef9 DEPS diff: https://chromium.googlesource.com/chromium/src/+/133e39bd4f..e4031d975b/DEPS No update to Clang. BUG=None Change-Id: I1603ab9bdda60b9aaf2dccf0dd2bdc9affd6abcc Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255460 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36198} --- DEPS | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/DEPS b/DEPS index 61fcdc561d..f1356a8ae9 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': '133e39bd4f0882e9c2b3e1225cee8f4767644207', + 'chromium_revision': 'e4031d975b126d7e5c9919f95e997bb9854fc08a', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@a87949dcf55d15be38692a5efeeaa0af0804a3f0', + 'https://chromium.googlesource.com/chromium/src/base@f9e1883ea5f1e2de9538c8a667d39b2951aa360f', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@514a34c34da56559bc13fbbe6ecb923f14ebf7ef', + 'https://chromium.googlesource.com/chromium/src/build@18a1f1939e1843a5bddca58fb95dda08e561aeeb', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@113dd1badbcbffea108a8c95ac7c89c22bfd25f3', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,19 +34,19 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@4411a66d163a6408c8c14f50a6a1c935ed690dd5', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@a44157ad6fae726c9e6049dbad6c4bb720f300c5', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@5c8b4181457e77a36b1b821a4e51757e081c4cab', + 'https://chromium.googlesource.com/chromium/src/testing@252b25d19eee6473b679246de6df1f44003be25c', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@d831b95e881a7ab952a733d507a7de4e6c9133b1', + 'https://chromium.googlesource.com/chromium/src/third_party@3baf779ae460b80a671ba3cecd31cf008432ca75', 'src/buildtools/linux64': { 'packages': [ { 'package': 'gn/gn/linux-amd64', - 'version': 'git_revision:f27bae882b2178ccc3c24f314c88db9a34118992', + 'version': 'git_revision:bd99dbf98cbdefe18a4128189665c5761263bcfb', } ], 'dep_type': 'cipd', @@ -56,7 +56,7 @@ deps = { 'packages': [ { 'package': 'gn/gn/mac-${{arch}}', - 'version': 'git_revision:f27bae882b2178ccc3c24f314c88db9a34118992', + 'version': 'git_revision:bd99dbf98cbdefe18a4128189665c5761263bcfb', } ], 'dep_type': 'cipd', @@ -66,7 +66,7 @@ deps = { 'packages': [ { 'package': 'gn/gn/windows-amd64', - 'version': 'git_revision:f27bae882b2178ccc3c24f314c88db9a34118992', + 'version': 'git_revision:bd99dbf98cbdefe18a4128189665c5761263bcfb', } ], 'dep_type': 'cipd', @@ -78,7 +78,7 @@ deps = { 'src/buildtools/third_party/libc++/trunk': 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxx.git@79a2e924d96e2fc1e4b937c42efd08898fa472d7', 'src/buildtools/third_party/libc++abi/trunk': - 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git@289d52ce75d6091a79e90ae6aead38c5c701d786', + 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git@a897d0f3f8e8c28ac2abf848f3b695b724409298', 'src/buildtools/third_party/libunwind/trunk': 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git@d1c7f92b8b0bff8d9f710ca40e44563a63db376e', @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@d55bdb952f5c4c0a0abe36df3af65071a3801e0c', + 'https://chromium.googlesource.com/catapult.git@63a615bbdb57ad0a2e794ed800b826dddcef2713', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@c848a4ed332e79a654cb4ee7ef29acd796f7147d', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@34816458276bf9a528f306f0bc26f33dfdb428c8', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -220,7 +220,7 @@ deps = { 'src/third_party/libsrtp': 'https://chromium.googlesource.com/chromium/deps/libsrtp.git@5b7c744eb8310250ccc534f3f86a2015b3887a0a', 'src/third_party/dav1d/libdav1d': - 'https://chromium.googlesource.com/external/github.com/videolan/dav1d.git@493ffb12f77df791f7dcde991b92d64bf873fefd', + 'https://chromium.googlesource.com/external/github.com/videolan/dav1d.git@b1a5189c9d37c837099ce50852b6ce9597b89b0c', 'src/third_party/libaom/source/libaom': 'https://aomedia.googlesource.com/aom.git@ee1ed1ccf2b9ecedd6aee438eafc7cc61c23342d', 'src/third_party/libunwindstack': { @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@705846bd63131a0150c1e73535311344f7afea82', + 'https://chromium.googlesource.com/chromium/src/tools@25e5713ef973939de9f32f67c2f87efa63b0d4b5', 'src/third_party/accessibility_test_framework': { 'packages': [ From b1e9402331e31b8f1faf5ef13fdb6bbe6b10bbc6 Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Mon, 14 Mar 2022 21:05:25 -0700 Subject: [PATCH 173/847] Update WebRTC code version (2022-03-15T04:05:24). Bug: None Change-Id: I658691cae7f5f9a78f94fd94a56ca4a59d29d29d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255462 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36199} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index 2de64f2e66..9cfda2a988 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 2022-03-14T04:04:50"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-03-15T04:05:24"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From a2d0a2ad99063a81c94d72e8fb8eea6f639472c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= Date: Thu, 10 Feb 2022 14:00:48 -0500 Subject: [PATCH 174/847] Ignore v4l2 select() return when stopping capture With some slightly broken webcams, it's possible that the select() returns with a timeout or no event. In that case, the v4l2 thread never returns. To fix this, just check if quit_ is set and exit unconditionally in that case. https://bugzilla.mozilla.org/show_bug.cgi?id=1752326 Bug: None Change-Id: Ic07ce15afd0016ff9f967c2cf64e646c20127457 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251540 Reviewed-by: Magnus Flodman Reviewed-by: Per Kjellander Commit-Queue: Per Kjellander Cr-Commit-Position: refs/heads/main@{#36200} --- AUTHORS | 1 + .../linux/video_capture_linux.cc | 23 ++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/AUTHORS b/AUTHORS index e4729a574b..212c990918 100644 --- a/AUTHORS +++ b/AUTHORS @@ -80,6 +80,7 @@ Mike Gilbert Min Wang Mo Zanaty Niek van der Maas +Olivier Crête Pali Rohar Paul Kapustin Peng Yu diff --git a/modules/video_capture/linux/video_capture_linux.cc b/modules/video_capture/linux/video_capture_linux.cc index 10f9713ec3..321355ffca 100644 --- a/modules/video_capture/linux/video_capture_linux.cc +++ b/modules/video_capture/linux/video_capture_linux.cc @@ -370,17 +370,6 @@ bool VideoCaptureModuleV4L2::CaptureProcess() { // _deviceFd written only in StartCapture, when this thread isn't running. retVal = select(_deviceFd + 1, &rSet, NULL, NULL, &timeout); - if (retVal < 0 && errno != EINTR) // continue if interrupted - { - // select failed - return false; - } else if (retVal == 0) { - // select timed out - return true; - } else if (!FD_ISSET(_deviceFd, &rSet)) { - // not event on camera handle - return true; - } { MutexLock lock(&capture_lock_); @@ -389,6 +378,18 @@ bool VideoCaptureModuleV4L2::CaptureProcess() { return false; } + if (retVal < 0 && errno != EINTR) // continue if interrupted + { + // select failed + return false; + } else if (retVal == 0) { + // select timed out + return true; + } else if (!FD_ISSET(_deviceFd, &rSet)) { + // not event on camera handle + return true; + } + if (_captureStarted) { struct v4l2_buffer buf; memset(&buf, 0, sizeof(struct v4l2_buffer)); From bc8c095537ac689208fde5a521d9cad9ec48a060 Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Tue, 15 Mar 2022 06:53:07 +0000 Subject: [PATCH 175/847] Permit all fuzzers to use sctp_utils Bug: chromium:1306284 Change-Id: Icaa4d13e9c85cdae48a2ae575b5067fe13d805b6 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255421 Reviewed-by: Mirko Bonadei Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#36201} --- pc/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pc/BUILD.gn b/pc/BUILD.gn index c227117808..f30bf9e9ad 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -398,7 +398,7 @@ rtc_source_set("sctp_transport") { rtc_source_set("sctp_utils") { visibility = [ ":*", - "../test/fuzzers:sctp_utils_fuzzer", + "../test/fuzzers:*", ] sources = [ "sctp_utils.cc", From b8ba8c9248ed92ac15b585e24c02ec9e21432ef0 Mon Sep 17 00:00:00 2001 From: Jeremy Leconte Date: Tue, 15 Mar 2022 09:08:29 +0100 Subject: [PATCH 176/847] Build //base/test:google_test_runner for iOS device. It seems the build failure is fixed and it is required so that "testRunGoogleTests" would be invoked as a "xctest". Bug: b/223364112 Change-Id: I2572af62d14c71e31b751c73a76e9f6e5d064ea8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254682 Reviewed-by: Mirko Bonadei Commit-Queue: Jeremy Leconte Cr-Commit-Position: refs/heads/main@{#36202} --- webrtc.gni | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/webrtc.gni b/webrtc.gni index 8040f628d9..b81f1605b2 100644 --- a/webrtc.gni +++ b/webrtc.gni @@ -498,10 +498,8 @@ template("rtc_test") { ] } - # When not targeting a simulator, building //base/test:google_test_runner - # fails, so it is added only when the test is not a real XCTest and when - # targeting a simulator. - if (is_ios && target_cpu == "x64" && rtc_include_tests) { + # Build //base/test:google_test_runner when the test is not a real XCTest. + if (is_ios && rtc_include_tests) { if (!defined(invoker.is_xctest) || !invoker.is_xctest) { xctest_module_target = "//base/test:google_test_runner" } @@ -530,6 +528,7 @@ template("rtc_test") { [ "//third_party/llvm-build/Release+Asserts/lib/libstdc++.so.6" ] } } + # TODO(crbug.com/webrtc/13556): Adding the .app folder in the runtime_deps # shoulnd't be necessary. this code should be removed and the same solution # as Chromium should be used. From 8f56242e984022821f1b630c94e107d0006d4b64 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Tue, 15 Mar 2022 03:09:47 -0700 Subject: [PATCH 177/847] Roll chromium_revision e4031d975b..ce4e107fd5 (980920:981033) Change log: https://chromium.googlesource.com/chromium/src/+log/e4031d975b..ce4e107fd5 Full diff: https://chromium.googlesource.com/chromium/src/+/e4031d975b..ce4e107fd5 Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/f9e1883ea5..e5f7e68061 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/18a1f1939e..7b0e5410ee * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/a44157ad6f..06df922804 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/252b25d19e..8399c3e77d * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/3baf779ae4..11468451f0 * src/third_party/androidx: Hn2dB6ZTIa1GhUTs1KqxEzKA_xgWAAeP8xJN3GTY17cC..GSeF5aW_033IJ7WfJr-L0ydknZykCwvytFFCrJfLMNMC * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/63a615bbdb..0c2e8d34dd * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/3481645827..79b4bab70c * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/e26fd0a8a5..bce4286eeb * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/25e5713ef9..33bdf7567c DEPS diff: https://chromium.googlesource.com/chromium/src/+/e4031d975b..ce4e107fd5/DEPS No update to Clang. BUG=None Change-Id: I2f2b8bfb994e4d1cee71d5c9cee251fa7165f192 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255501 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36203} --- DEPS | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/DEPS b/DEPS index f1356a8ae9..8dd21b47a3 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': 'e4031d975b126d7e5c9919f95e997bb9854fc08a', + 'chromium_revision': 'ce4e107fd5278cd673b0b9afc9345814f335e2ba', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@f9e1883ea5f1e2de9538c8a667d39b2951aa360f', + 'https://chromium.googlesource.com/chromium/src/base@e5f7e680619b8637c1c4cbb4826591e7cd926eee', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@18a1f1939e1843a5bddca58fb95dda08e561aeeb', + 'https://chromium.googlesource.com/chromium/src/build@7b0e5410ee10f5f31136eba2c08dbd61587c74fd', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@113dd1badbcbffea108a8c95ac7c89c22bfd25f3', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@a44157ad6fae726c9e6049dbad6c4bb720f300c5', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@06df922804765f56355e2517a31a6b756d06cc12', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@252b25d19eee6473b679246de6df1f44003be25c', + 'https://chromium.googlesource.com/chromium/src/testing@8399c3e77d6e79ba2407f74601ae5e1b0e5eba38', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@3baf779ae460b80a671ba3cecd31cf008432ca75', + 'https://chromium.googlesource.com/chromium/src/third_party@11468451f03eba197df106c59391ad2ecee42096', 'src/buildtools/linux64': { 'packages': [ @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@63a615bbdb57ad0a2e794ed800b826dddcef2713', + 'https://chromium.googlesource.com/catapult.git@0c2e8d34dde04fedf933d3b39d803acfe01d7554', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@34816458276bf9a528f306f0bc26f33dfdb428c8', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@79b4bab70c8da5d2a3770d445648f053a66a96cc', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -228,7 +228,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@e26fd0a8a5e96b82f71b3c86240d8c8c0429245e', + 'https://android.googlesource.com/platform/external/perfetto.git@bce4286eebf41c7e7f6689684dea989c0b010fe1', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -285,7 +285,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@25e5713ef973939de9f32f67c2f87efa63b0d4b5', + 'https://chromium.googlesource.com/chromium/src/tools@33bdf7567c93c577cbdcf499e5c48b8b290b9cc5', 'src/third_party/accessibility_test_framework': { 'packages': [ @@ -384,7 +384,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/androidx', - 'version': 'Hn2dB6ZTIa1GhUTs1KqxEzKA_xgWAAeP8xJN3GTY17cC', + 'version': 'GSeF5aW_033IJ7WfJr-L0ydknZykCwvytFFCrJfLMNMC', }, ], 'condition': 'checkout_android', From 2e7579aed23f2d011b513c4cc0357d6543b874bb Mon Sep 17 00:00:00 2001 From: Byoungchan Lee Date: Tue, 15 Mar 2022 20:12:11 +0900 Subject: [PATCH 178/847] Remove unused bazel related code They are no longer used after https://chromium-review.googlesource.com/c/chromium/src/+/3016508 and https://chromium-review.googlesource.com/c/chromium/src/+/3206870. Bug: None Change-Id: Id5d3def2d902886bc8ffd5512e2820943cac41bf Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255540 Auto-Submit: Daniel.L (Byoungchan) Lee Reviewed-by: Mirko Bonadei Commit-Queue: Mirko Bonadei Cr-Commit-Position: refs/heads/main@{#36204} --- DEPS | 11 ----------- tools_webrtc/autoroller/roll_deps.py | 1 - tools_webrtc/libs/generate_licenses.py | 1 - 3 files changed, 13 deletions(-) diff --git a/DEPS b/DEPS index 8dd21b47a3..dc31e4d40e 100644 --- a/DEPS +++ b/DEPS @@ -309,17 +309,6 @@ deps = { 'dep_type': 'cipd', }, - 'src/third_party/bazel': { - 'packages': [ - { - 'package': 'chromium/third_party/bazel', - 'version': 'VjMsf48QUWw8n7XtJP2AuSjIGmbQeYdWdwyxVvIRLmAC', - }, - ], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - 'src/third_party/bouncycastle': { 'packages': [ { diff --git a/tools_webrtc/autoroller/roll_deps.py b/tools_webrtc/autoroller/roll_deps.py index 2f374eb70c..60bb8a0827 100755 --- a/tools_webrtc/autoroller/roll_deps.py +++ b/tools_webrtc/autoroller/roll_deps.py @@ -45,7 +45,6 @@ def FindSrcDirPath(): 'src/ios', 'src/testing', 'src/third_party', - 'src/third_party/bazel', 'src/third_party/findbugs', 'src/third_party/gtest-parallel', 'src/third_party/yasm/binaries', diff --git a/tools_webrtc/libs/generate_licenses.py b/tools_webrtc/libs/generate_licenses.py index 1c2db06313..ac362a1dd8 100755 --- a/tools_webrtc/libs/generate_licenses.py +++ b/tools_webrtc/libs/generate_licenses.py @@ -40,7 +40,6 @@ 'third_party/android_deps/libs/' 'com_google_auto_service_auto_service/LICENSE' ], - 'bazel': ['third_party/bazel/LICENSE'], 'boringssl': ['third_party/boringssl/src/LICENSE'], 'crc32c': ['third_party/crc32c/src/LICENSE'], 'errorprone': [ From e486a7bdf72e02c65b80e29a8e4988d7754c1ec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Spr=C3=A5ng?= Date: Tue, 15 Mar 2022 15:13:25 +0100 Subject: [PATCH 179/847] Make KeyValueConfig mandatory in the pacer. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL also removes dependency on the legacy field trial methods. Bug: webrtc:11926 Change-Id: I53feeee86b92878cf0f2b8ebdce3d101f9e04014 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255381 Reviewed-by: Jonas Oreland Auto-Submit: Erik Språng Reviewed-by: Björn Terelius Commit-Queue: Björn Terelius Cr-Commit-Position: refs/heads/main@{#36205} --- call/rtp_transport_controller_send.cc | 24 ++++----- call/rtp_transport_controller_send.h | 4 +- call/rtp_transport_controller_send_factory.h | 3 +- call/rtp_video_sender_unittest.cc | 2 +- modules/pacing/BUILD.gn | 3 +- modules/pacing/paced_sender.cc | 7 ++- modules/pacing/paced_sender.h | 2 +- modules/pacing/paced_sender_unittest.cc | 3 +- modules/pacing/pacing_controller.cc | 22 ++++---- modules/pacing/pacing_controller.h | 5 +- modules/pacing/pacing_controller_unittest.cc | 54 +++++++++++-------- modules/pacing/round_robin_packet_queue.cc | 11 +--- modules/pacing/round_robin_packet_queue.h | 4 +- modules/pacing/task_queue_paced_sender.cc | 16 ++++++ modules/pacing/task_queue_paced_sender.h | 13 ++++- .../task_queue_paced_sender_unittest.cc | 46 ++++++++-------- .../rtc_event_log_visualizer/analyzer.cc | 4 -- 17 files changed, 118 insertions(+), 105 deletions(-) diff --git a/call/rtp_transport_controller_send.cc b/call/rtp_transport_controller_send.cc index f1a6201ce7..569ba9d730 100644 --- a/call/rtp_transport_controller_send.cc +++ b/call/rtp_transport_controller_send.cc @@ -59,14 +59,12 @@ TargetRateConstraints ConvertConstraints(const BitrateConstraints& contraints, contraints.start_bitrate_bps, clock); } -bool IsEnabled(const WebRtcKeyValueConfig* trials, absl::string_view key) { - RTC_DCHECK(trials != nullptr); - return absl::StartsWith(trials->Lookup(key), "Enabled"); +bool IsEnabled(const WebRtcKeyValueConfig& trials, absl::string_view key) { + return absl::StartsWith(trials.Lookup(key), "Enabled"); } -bool IsDisabled(const WebRtcKeyValueConfig* trials, absl::string_view key) { - RTC_DCHECK(trials != nullptr); - return absl::StartsWith(trials->Lookup(key), "Disabled"); +bool IsDisabled(const WebRtcKeyValueConfig& trials, absl::string_view key) { + return absl::StartsWith(trials.Lookup(key), "Disabled"); } bool IsRelayed(const rtc::NetworkRoute& route) { @@ -76,12 +74,12 @@ bool IsRelayed(const rtc::NetworkRoute& route) { } // namespace RtpTransportControllerSend::PacerSettings::PacerSettings( - const WebRtcKeyValueConfig* trials) + const WebRtcKeyValueConfig& trials) : tq_disabled("Disabled"), holdback_window("holdback_window", PacingController::kMinSleepTime), holdback_packets("holdback_packets", -1) { ParseFieldTrial({&tq_disabled, &holdback_window, &holdback_packets}, - trials->Lookup("WebRTC-TaskQueuePacer")); + trials.Lookup("WebRTC-TaskQueuePacer")); } RtpTransportControllerSend::RtpTransportControllerSend( @@ -92,7 +90,7 @@ RtpTransportControllerSend::RtpTransportControllerSend( const BitrateConstraints& bitrate_config, std::unique_ptr process_thread, TaskQueueFactory* task_queue_factory, - const WebRtcKeyValueConfig* trials) + const WebRtcKeyValueConfig& trials) : clock_(clock), event_log_(event_log), bitrate_configurator_(bitrate_config), @@ -135,18 +133,18 @@ RtpTransportControllerSend::RtpTransportControllerSend( task_queue_(task_queue_factory->CreateTaskQueue( "rtp_send_controller", TaskQueueFactory::Priority::NORMAL)), - field_trials_(*trials) { + field_trials_(trials) { ParseFieldTrial({&relay_bandwidth_cap_}, - trials->Lookup("WebRTC-Bwe-NetworkRouteConstraints")); + trials.Lookup("WebRTC-Bwe-NetworkRouteConstraints")); initial_config_.constraints = ConvertConstraints(bitrate_config, clock_); initial_config_.event_log = event_log; - initial_config_.key_value_config = trials; + initial_config_.key_value_config = &trials; RTC_DCHECK(bitrate_config.start_bitrate_bps > 0); pacer()->SetPacingRates( DataRate::BitsPerSec(bitrate_config.start_bitrate_bps), DataRate::Zero()); - if (absl::StartsWith(trials->Lookup("WebRTC-LazyPacerStart"), "Disabled")) { + if (absl::StartsWith(trials.Lookup("WebRTC-LazyPacerStart"), "Disabled")) { EnsureStarted(); } } diff --git a/call/rtp_transport_controller_send.h b/call/rtp_transport_controller_send.h index e45ab21cda..471ee7f5f4 100644 --- a/call/rtp_transport_controller_send.h +++ b/call/rtp_transport_controller_send.h @@ -59,7 +59,7 @@ class RtpTransportControllerSend final const BitrateConstraints& bitrate_config, std::unique_ptr process_thread, TaskQueueFactory* task_queue_factory, - const WebRtcKeyValueConfig* trials); + const WebRtcKeyValueConfig& trials); ~RtpTransportControllerSend() override; RtpTransportControllerSend(const RtpTransportControllerSend&) = delete; @@ -132,7 +132,7 @@ class RtpTransportControllerSend final private: struct PacerSettings { - explicit PacerSettings(const WebRtcKeyValueConfig* trials); + explicit PacerSettings(const WebRtcKeyValueConfig& trials); bool use_task_queue_pacer() const { return !tq_disabled.Get(); } diff --git a/call/rtp_transport_controller_send_factory.h b/call/rtp_transport_controller_send_factory.h index a857ca7e6f..bda0be04af 100644 --- a/call/rtp_transport_controller_send_factory.h +++ b/call/rtp_transport_controller_send_factory.h @@ -25,10 +25,11 @@ class RtpTransportControllerSendFactory const RtpTransportConfig& config, Clock* clock, std::unique_ptr process_thread) override { + RTC_CHECK(config.trials); return std::make_unique( clock, config.event_log, config.network_state_predictor_factory, config.network_controller_factory, config.bitrate_config, - std::move(process_thread), config.task_queue_factory, config.trials); + std::move(process_thread), config.task_queue_factory, *config.trials); } virtual ~RtpTransportControllerSendFactory() {} diff --git a/call/rtp_video_sender_unittest.cc b/call/rtp_video_sender_unittest.cc index 7c7d005fa6..7962ce29c9 100644 --- a/call/rtp_video_sender_unittest.cc +++ b/call/rtp_video_sender_unittest.cc @@ -135,7 +135,7 @@ class RtpVideoSenderTestFixture { bitrate_config_, time_controller_.CreateProcessThread("PacerThread"), time_controller_.GetTaskQueueFactory(), - field_trials ? field_trials : &field_trials_), + field_trials ? *field_trials : field_trials_), stats_proxy_(time_controller_.GetClock(), config_, VideoEncoderConfig::ContentType::kRealtimeVideo, diff --git a/modules/pacing/BUILD.gn b/modules/pacing/BUILD.gn index 013c2de599..4064c12151 100644 --- a/modules/pacing/BUILD.gn +++ b/modules/pacing/BUILD.gn @@ -102,9 +102,8 @@ if (rtc_include_tests) { "../../rtc_base:rtc_base_tests_utils", "../../rtc_base/experiments:alr_experiment", "../../system_wrappers", - "../../system_wrappers:field_trial", "../../test:explicit_key_value_config", - "../../test:field_trial", + "../../test:scoped_key_value_config", "../../test:test_support", "../../test/time_controller:time_controller", "../rtp_rtcp", diff --git a/modules/pacing/paced_sender.cc b/modules/pacing/paced_sender.cc index 2b2d064ef4..5eed6c2607 100644 --- a/modules/pacing/paced_sender.cc +++ b/modules/pacing/paced_sender.cc @@ -32,12 +32,11 @@ const float PacedSender::kDefaultPaceMultiplier = 2.5f; PacedSender::PacedSender(Clock* clock, PacketRouter* packet_router, RtcEventLog* event_log, - const WebRtcKeyValueConfig* field_trials, + const WebRtcKeyValueConfig& field_trials, ProcessThread* process_thread) : process_mode_( - (field_trials != nullptr && - absl::StartsWith(field_trials->Lookup("WebRTC-Pacer-DynamicProcess"), - "Enabled")) + absl::StartsWith(field_trials.Lookup("WebRTC-Pacer-DynamicProcess"), + "Enabled") ? PacingController::ProcessMode::kDynamic : PacingController::ProcessMode::kPeriodic), pacing_controller_(clock, diff --git a/modules/pacing/paced_sender.h b/modules/pacing/paced_sender.h index 4a53e0f9ba..88fd79697d 100644 --- a/modules/pacing/paced_sender.h +++ b/modules/pacing/paced_sender.h @@ -58,7 +58,7 @@ class PacedSender : public RtpPacketPacer, public RtpPacketSender { PacedSender(Clock* clock, PacketRouter* packet_router, RtcEventLog* event_log, - const WebRtcKeyValueConfig* field_trials = nullptr, + const WebRtcKeyValueConfig& field_trials, ProcessThread* process_thread = nullptr); ~PacedSender() override; diff --git a/modules/pacing/paced_sender_unittest.cc b/modules/pacing/paced_sender_unittest.cc index 7abd532417..27f373746f 100644 --- a/modules/pacing/paced_sender_unittest.cc +++ b/modules/pacing/paced_sender_unittest.cc @@ -19,7 +19,6 @@ #include "modules/pacing/packet_router.h" #include "modules/utility/include/mock/mock_process_thread.h" #include "system_wrappers/include/clock.h" -#include "test/field_trial.h" #include "test/gmock.h" #include "test/gtest.h" @@ -80,7 +79,7 @@ class PacedSenderTest .WillOnce(SaveArg<0>(&paced_module_)); pacer_ = std::make_unique(&clock_, &callback_, nullptr, - &trials_, &process_thread_); + trials_, &process_thread_); EXPECT_CALL(process_thread_, WakeUp).WillRepeatedly([&](Module* module) { clock_.AdvanceTimeMilliseconds(module->TimeUntilNextProcess()); }); diff --git a/modules/pacing/pacing_controller.cc b/modules/pacing/pacing_controller.cc index 9215462239..9bfe85c0a8 100644 --- a/modules/pacing/pacing_controller.cc +++ b/modules/pacing/pacing_controller.cc @@ -98,22 +98,20 @@ const TimeDelta PacingController::kMinSleepTime = TimeDelta::Millis(1); PacingController::PacingController(Clock* clock, PacketSender* packet_sender, RtcEventLog* event_log, - const WebRtcKeyValueConfig* field_trials, + const WebRtcKeyValueConfig& field_trials, ProcessMode mode) : mode_(mode), clock_(clock), packet_sender_(packet_sender), - fallback_field_trials_( - !field_trials ? std::make_unique() : nullptr), - field_trials_(field_trials ? field_trials : fallback_field_trials_.get()), + field_trials_(field_trials), drain_large_queues_( - !IsDisabled(*field_trials_, "WebRTC-Pacer-DrainQueue")), + !IsDisabled(field_trials_, "WebRTC-Pacer-DrainQueue")), send_padding_if_silent_( - IsEnabled(*field_trials_, "WebRTC-Pacer-PadInSilence")), - pace_audio_(IsEnabled(*field_trials_, "WebRTC-Pacer-BlockAudio")), + IsEnabled(field_trials_, "WebRTC-Pacer-PadInSilence")), + pace_audio_(IsEnabled(field_trials_, "WebRTC-Pacer-BlockAudio")), ignore_transport_overhead_( - IsEnabled(*field_trials_, "WebRTC-Pacer-IgnoreTransportOverhead")), - padding_target_duration_(GetDynamicPaddingTarget(*field_trials_)), + IsEnabled(field_trials_, "WebRTC-Pacer-IgnoreTransportOverhead")), + padding_target_duration_(GetDynamicPaddingTarget(field_trials_)), min_packet_limit_(kDefaultMinPacketLimit), transport_overhead_per_packet_(DataSize::Zero()), last_timestamp_(clock_->CurrentTime()), @@ -124,12 +122,12 @@ PacingController::PacingController(Clock* clock, padding_debt_(DataSize::Zero()), media_rate_(DataRate::Zero()), padding_rate_(DataRate::Zero()), - prober_(*field_trials_), + prober_(field_trials_), probing_send_failure_(false), pacing_bitrate_(DataRate::Zero()), last_process_time_(clock->CurrentTime()), last_send_time_(last_process_time_), - packet_queue_(last_process_time_, field_trials_), + packet_queue_(last_process_time_), packet_counter_(0), congestion_window_size_(DataSize::PlusInfinity()), outstanding_data_(DataSize::Zero()), @@ -142,7 +140,7 @@ PacingController::PacingController(Clock* clock, } FieldTrialParameter min_packet_limit_ms("", min_packet_limit_.ms()); ParseFieldTrial({&min_packet_limit_ms}, - field_trials_->Lookup("WebRTC-Pacer-MinPacketLimitMs")); + field_trials_.Lookup("WebRTC-Pacer-MinPacketLimitMs")); min_packet_limit_ = TimeDelta::Millis(min_packet_limit_ms.Get()); UpdateBudgetWithElapsedTime(min_packet_limit_); } diff --git a/modules/pacing/pacing_controller.h b/modules/pacing/pacing_controller.h index 5d6d26b917..f7c5601c91 100644 --- a/modules/pacing/pacing_controller.h +++ b/modules/pacing/pacing_controller.h @@ -82,7 +82,7 @@ class PacingController { PacingController(Clock* clock, PacketSender* packet_sender, RtcEventLog* event_log, - const WebRtcKeyValueConfig* field_trials, + const WebRtcKeyValueConfig& field_trials, ProcessMode mode); ~PacingController(); @@ -176,8 +176,7 @@ class PacingController { const ProcessMode mode_; Clock* const clock_; PacketSender* const packet_sender_; - const std::unique_ptr fallback_field_trials_; - const WebRtcKeyValueConfig* field_trials_; + const WebRtcKeyValueConfig& field_trials_; const bool drain_large_queues_; const bool send_padding_if_silent_; diff --git a/modules/pacing/pacing_controller_unittest.cc b/modules/pacing/pacing_controller_unittest.cc index a24960d896..af2ce548e0 100644 --- a/modules/pacing/pacing_controller_unittest.cc +++ b/modules/pacing/pacing_controller_unittest.cc @@ -21,7 +21,6 @@ #include "modules/pacing/packet_router.h" #include "system_wrappers/include/clock.h" #include "test/explicit_key_value_config.h" -#include "test/field_trial.h" #include "test/gmock.h" #include "test/gtest.h" @@ -209,13 +208,13 @@ class PacingControllerProbing : public PacingController::PacketSender { class PacingControllerTest : public ::testing::TestWithParam { protected: - PacingControllerTest() : clock_(123456) {} + PacingControllerTest() : clock_(123456), trials_("") {} void SetUp() override { srand(0); // Need to initialize PacingController after we initialize clock. pacer_ = std::make_unique(&clock_, &callback_, nullptr, - nullptr, GetParam()); + trials_, GetParam()); Init(); } @@ -320,6 +319,7 @@ class PacingControllerTest SimulatedClock clock_; ::testing::NiceMock callback_; + ExplicitKeyValueConfig trials_; std::unique_ptr pacer_; }; @@ -364,7 +364,8 @@ class PacingControllerFieldTrialTest }; TEST_P(PacingControllerFieldTrialTest, DefaultNoPaddingInSilence) { - PacingController pacer(&clock_, &callback_, nullptr, nullptr, GetParam()); + const test::ExplicitKeyValueConfig trials(""); + PacingController pacer(&clock_, &callback_, nullptr, trials, GetParam()); pacer.SetPacingRates(kTargetRate, DataRate::Zero()); // Video packet to reset last send time and provide padding data. InsertPacket(&pacer, &video); @@ -378,8 +379,9 @@ TEST_P(PacingControllerFieldTrialTest, DefaultNoPaddingInSilence) { } TEST_P(PacingControllerFieldTrialTest, PaddingInSilenceWithTrial) { - ScopedFieldTrials trial("WebRTC-Pacer-PadInSilence/Enabled/"); - PacingController pacer(&clock_, &callback_, nullptr, nullptr, GetParam()); + const test::ExplicitKeyValueConfig trials( + "WebRTC-Pacer-PadInSilence/Enabled/"); + PacingController pacer(&clock_, &callback_, nullptr, trials, GetParam()); pacer.SetPacingRates(kTargetRate, DataRate::Zero()); // Video packet to reset last send time and provide padding data. InsertPacket(&pacer, &video); @@ -393,9 +395,9 @@ TEST_P(PacingControllerFieldTrialTest, PaddingInSilenceWithTrial) { } TEST_P(PacingControllerFieldTrialTest, CongestionWindowAffectsAudioInTrial) { - ScopedFieldTrials trial("WebRTC-Pacer-BlockAudio/Enabled/"); + const test::ExplicitKeyValueConfig trials("WebRTC-Pacer-BlockAudio/Enabled/"); EXPECT_CALL(callback_, SendPadding).Times(0); - PacingController pacer(&clock_, &callback_, nullptr, nullptr, GetParam()); + PacingController pacer(&clock_, &callback_, nullptr, trials, GetParam()); pacer.SetPacingRates(DataRate::KilobitsPerSec(10000), DataRate::Zero()); pacer.SetCongestionWindow(DataSize::Bytes(video.packet_size - 100)); pacer.UpdateOutstandingData(DataSize::Zero()); @@ -422,7 +424,8 @@ TEST_P(PacingControllerFieldTrialTest, CongestionWindowAffectsAudioInTrial) { TEST_P(PacingControllerFieldTrialTest, DefaultCongestionWindowDoesNotAffectAudio) { EXPECT_CALL(callback_, SendPadding).Times(0); - PacingController pacer(&clock_, &callback_, nullptr, nullptr, GetParam()); + const test::ExplicitKeyValueConfig trials(""); + PacingController pacer(&clock_, &callback_, nullptr, trials, GetParam()); pacer.SetPacingRates(DataRate::BitsPerSec(10000000), DataRate::Zero()); pacer.SetCongestionWindow(DataSize::Bytes(800)); pacer.UpdateOutstandingData(DataSize::Zero()); @@ -437,8 +440,8 @@ TEST_P(PacingControllerFieldTrialTest, } TEST_P(PacingControllerFieldTrialTest, BudgetAffectsAudioInTrial) { - ScopedFieldTrials trial("WebRTC-Pacer-BlockAudio/Enabled/"); - PacingController pacer(&clock_, &callback_, nullptr, nullptr, GetParam()); + ExplicitKeyValueConfig trials("WebRTC-Pacer-BlockAudio/Enabled/"); + PacingController pacer(&clock_, &callback_, nullptr, trials, GetParam()); DataRate pacing_rate = DataRate::BitsPerSec(video.packet_size / 3 * 8 * kProcessIntervalsPerSecond); pacer.SetPacingRates(pacing_rate, DataRate::Zero()); @@ -468,7 +471,8 @@ TEST_P(PacingControllerFieldTrialTest, BudgetAffectsAudioInTrial) { TEST_P(PacingControllerFieldTrialTest, DefaultBudgetDoesNotAffectAudio) { EXPECT_CALL(callback_, SendPadding).Times(0); - PacingController pacer(&clock_, &callback_, nullptr, nullptr, GetParam()); + const test::ExplicitKeyValueConfig trials(""); + PacingController pacer(&clock_, &callback_, nullptr, trials, GetParam()); pacer.SetPacingRates(DataRate::BitsPerSec(video.packet_size / 3 * 8 * kProcessIntervalsPerSecond), DataRate::Zero()); @@ -867,7 +871,7 @@ TEST_P(PacingControllerTest, VerifyAverageBitrateVaryingMediaPayload) { const TimeDelta kAveragingWindowLength = TimeDelta::Seconds(10); PacingControllerPadding callback; pacer_ = std::make_unique(&clock_, &callback, nullptr, - nullptr, GetParam()); + trials_, GetParam()); pacer_->SetProbingEnabled(false); pacer_->SetPacingRates(kTargetRate * kPaceMultiplier, kTargetRate); @@ -1304,7 +1308,7 @@ TEST_P(PacingControllerTest, Pause) { TEST_P(PacingControllerTest, InactiveFromStart) { // Recreate the pacer without the inital time forwarding. pacer_ = std::make_unique(&clock_, &callback_, nullptr, - nullptr, GetParam()); + trials_, GetParam()); pacer_->SetProbingEnabled(false); pacer_->SetPacingRates(kTargetRate * kPaceMultiplier, kTargetRate); @@ -1403,7 +1407,7 @@ TEST_P(PacingControllerTest, ProbingWithInsertedPackets) { PacingControllerProbing packet_sender; pacer_ = std::make_unique(&clock_, &packet_sender, nullptr, - nullptr, GetParam()); + trials_, GetParam()); pacer_->CreateProbeCluster(kFirstClusterRate, /*cluster_id=*/0); pacer_->CreateProbeCluster(kSecondClusterRate, @@ -1463,7 +1467,7 @@ TEST_P(PacingControllerTest, SkipsProbesWhenProcessIntervalTooLarge) { : "WebRTC-Bwe-ProbingBehavior/" "abort_delayed_probes:0,max_probe_delay:2ms/"); pacer_ = std::make_unique(&clock_, &packet_sender, - nullptr, &trials, GetParam()); + nullptr, trials, GetParam()); pacer_->SetPacingRates( DataRate::BitsPerSec(kInitialBitrateBps * kPaceMultiplier), DataRate::BitsPerSec(kInitialBitrateBps)); @@ -1570,7 +1574,7 @@ TEST_P(PacingControllerTest, ProbingWithPaddingSupport) { PacingControllerProbing packet_sender; pacer_ = std::make_unique(&clock_, &packet_sender, nullptr, - nullptr, GetParam()); + trials_, GetParam()); pacer_->CreateProbeCluster(kFirstClusterRate, /*cluster_id=*/0); pacer_->SetPacingRates( @@ -1636,7 +1640,7 @@ TEST_P(PacingControllerTest, ProbeClusterId) { MockPacketSender callback; pacer_ = std::make_unique(&clock_, &callback, nullptr, - nullptr, GetParam()); + trials_, GetParam()); Init(); uint32_t ssrc = 12346; @@ -1693,7 +1697,7 @@ TEST_P(PacingControllerTest, ProbeClusterId) { TEST_P(PacingControllerTest, OwnedPacketPrioritizedOnType) { MockPacketSender callback; pacer_ = std::make_unique(&clock_, &callback, nullptr, - nullptr, GetParam()); + trials_, GetParam()); Init(); // Insert a packet of each type, from low to high priority. Since priority @@ -1740,7 +1744,7 @@ TEST_P(PacingControllerTest, OwnedPacketPrioritizedOnType) { TEST_P(PacingControllerTest, SmallFirstProbePacket) { MockPacketSender callback; pacer_ = std::make_unique(&clock_, &callback, nullptr, - nullptr, GetParam()); + trials_, GetParam()); pacer_->CreateProbeCluster(kFirstClusterRate, /*cluster_id=*/0); pacer_->SetPacingRates(kTargetRate * kPaceMultiplier, DataRate::Zero()); @@ -1899,7 +1903,7 @@ TEST_P(PacingControllerTest, MockPacketSender callback; EXPECT_CALL(callback, SendPacket).Times(::testing::AnyNumber()); pacer_ = std::make_unique(&clock_, &callback, nullptr, - nullptr, GetParam()); + trials_, GetParam()); pacer_->SetAccountForAudioPackets(account_for_audio); // First, saturate the padding budget. @@ -2073,9 +2077,13 @@ TEST_P(PacingControllerTest, PaddingTargetAccountsForPaddingRate) { // Re-init pacer with an explicitly set padding target of 10ms; const TimeDelta kPaddingTarget = TimeDelta::Millis(10); - ScopedFieldTrials field_trials( + ExplicitKeyValueConfig field_trials( "WebRTC-Pacer-DynamicPaddingTarget/timedelta:10ms/"); - SetUp(); + srand(0); + // Need to initialize PacingController after we initialize clock. + pacer_ = std::make_unique(&clock_, &callback_, nullptr, + field_trials, GetParam()); + Init(); const uint32_t kSsrc = 12345; const DataRate kPacingDataRate = DataRate::KilobitsPerSec(125); diff --git a/modules/pacing/round_robin_packet_queue.cc b/modules/pacing/round_robin_packet_queue.cc index ef37e5256b..9014c30cb6 100644 --- a/modules/pacing/round_robin_packet_queue.cc +++ b/modules/pacing/round_robin_packet_queue.cc @@ -107,16 +107,7 @@ RoundRobinPacketQueue::Stream::Stream() : size(DataSize::Zero()), ssrc(0) {} RoundRobinPacketQueue::Stream::Stream(const Stream& stream) = default; RoundRobinPacketQueue::Stream::~Stream() = default; -bool IsEnabled(const WebRtcKeyValueConfig* field_trials, const char* name) { - if (!field_trials) { - return false; - } - return absl::StartsWith(field_trials->Lookup(name), "Enabled"); -} - -RoundRobinPacketQueue::RoundRobinPacketQueue( - Timestamp start_time, - const WebRtcKeyValueConfig* field_trials) +RoundRobinPacketQueue::RoundRobinPacketQueue(Timestamp start_time) : transport_overhead_per_packet_(DataSize::Zero()), time_last_updated_(start_time), paused_(false), diff --git a/modules/pacing/round_robin_packet_queue.h b/modules/pacing/round_robin_packet_queue.h index dd35b90d93..f8255834b3 100644 --- a/modules/pacing/round_robin_packet_queue.h +++ b/modules/pacing/round_robin_packet_queue.h @@ -22,7 +22,6 @@ #include #include "absl/types/optional.h" -#include "api/transport/webrtc_key_value_config.h" #include "api/units/data_size.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" @@ -34,8 +33,7 @@ namespace webrtc { class RoundRobinPacketQueue { public: - RoundRobinPacketQueue(Timestamp start_time, - const WebRtcKeyValueConfig* field_trials); + explicit RoundRobinPacketQueue(Timestamp start_time); ~RoundRobinPacketQueue(); void Push(int priority, diff --git a/modules/pacing/task_queue_paced_sender.cc b/modules/pacing/task_queue_paced_sender.cc index c392a88720..620a54135e 100644 --- a/modules/pacing/task_queue_paced_sender.cc +++ b/modules/pacing/task_queue_paced_sender.cc @@ -29,6 +29,22 @@ TaskQueuePacedSender::TaskQueuePacedSender( TaskQueueFactory* task_queue_factory, TimeDelta max_hold_back_window, int max_hold_back_window_in_packets) + : TaskQueuePacedSender(clock, + packet_sender, + event_log, + *field_trials, + task_queue_factory, + max_hold_back_window, + max_hold_back_window_in_packets) {} + +TaskQueuePacedSender::TaskQueuePacedSender( + Clock* clock, + PacingController::PacketSender* packet_sender, + RtcEventLog* event_log, + const WebRtcKeyValueConfig& field_trials, + TaskQueueFactory* task_queue_factory, + TimeDelta max_hold_back_window, + int max_hold_back_window_in_packets) : clock_(clock), max_hold_back_window_(max_hold_back_window), max_hold_back_window_in_packets_(max_hold_back_window_in_packets), diff --git a/modules/pacing/task_queue_paced_sender.h b/modules/pacing/task_queue_paced_sender.h index 353f137963..61a625521d 100644 --- a/modules/pacing/task_queue_paced_sender.h +++ b/modules/pacing/task_queue_paced_sender.h @@ -19,6 +19,7 @@ #include #include +#include "absl/base/attributes.h" #include "absl/types/optional.h" #include "api/sequence_checker.h" #include "api/task_queue/task_queue_factory.h" @@ -39,6 +40,16 @@ class RtcEventLog; class TaskQueuePacedSender : public RtpPacketPacer, public RtpPacketSender { public: + ABSL_DEPRECATED("Use the version with field_trials reference instead.") + TaskQueuePacedSender( + Clock* clock, + PacingController::PacketSender* packet_sender, + RtcEventLog* event_log, + const WebRtcKeyValueConfig* field_trials, + TaskQueueFactory* task_queue_factory, + TimeDelta max_hold_back_window = PacingController::kMinSleepTime, + int max_hold_back_window_in_packets = -1); + // The `hold_back_window` parameter sets a lower bound on time to sleep if // there is currently a pacer queue and packets can't immediately be // processed. Increasing this reduces thread wakeups at the expense of higher @@ -48,7 +59,7 @@ class TaskQueuePacedSender : public RtpPacketPacer, public RtpPacketSender { Clock* clock, PacingController::PacketSender* packet_sender, RtcEventLog* event_log, - const WebRtcKeyValueConfig* field_trials, + const WebRtcKeyValueConfig& field_trials, TaskQueueFactory* task_queue_factory, TimeDelta max_hold_back_window = PacingController::kMinSleepTime, int max_hold_back_window_in_packets = -1); diff --git a/modules/pacing/task_queue_paced_sender_unittest.cc b/modules/pacing/task_queue_paced_sender_unittest.cc index d78365d499..a22ff6d164 100644 --- a/modules/pacing/task_queue_paced_sender_unittest.cc +++ b/modules/pacing/task_queue_paced_sender_unittest.cc @@ -20,9 +20,9 @@ #include "api/transport/network_types.h" #include "modules/pacing/packet_router.h" #include "modules/utility/include/mock/mock_process_thread.h" -#include "test/field_trial.h" #include "test/gmock.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" #include "test/time_controller/simulated_time_controller.h" using ::testing::_; @@ -116,10 +116,10 @@ std::vector> GeneratePackets( TEST(TaskQueuePacedSenderTest, PacesPackets) { GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); MockPacketRouter packet_router; + ScopedKeyValueConfig trials; TaskQueuePacedSender pacer( time_controller.GetClock(), &packet_router, - /*event_log=*/nullptr, - /*field_trials=*/nullptr, time_controller.GetTaskQueueFactory(), + /*event_log=*/nullptr, trials, time_controller.GetTaskQueueFactory(), PacingController::kMinSleepTime, kNoPacketHoldback); // Insert a number of packets, covering one second. @@ -156,10 +156,10 @@ TEST(TaskQueuePacedSenderTest, PacesPackets) { TEST(TaskQueuePacedSenderTest, ReschedulesProcessOnRateChange) { GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); MockPacketRouter packet_router; + ScopedKeyValueConfig trials; TaskQueuePacedSender pacer( time_controller.GetClock(), &packet_router, - /*event_log=*/nullptr, - /*field_trials=*/nullptr, time_controller.GetTaskQueueFactory(), + /*event_log=*/nullptr, trials, time_controller.GetTaskQueueFactory(), PacingController::kMinSleepTime, kNoPacketHoldback); // Insert a number of packets to be sent 200ms apart. @@ -208,10 +208,10 @@ TEST(TaskQueuePacedSenderTest, ReschedulesProcessOnRateChange) { TEST(TaskQueuePacedSenderTest, SendsAudioImmediately) { GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); MockPacketRouter packet_router; + ScopedKeyValueConfig trials; TaskQueuePacedSender pacer( time_controller.GetClock(), &packet_router, - /*event_log=*/nullptr, - /*field_trials=*/nullptr, time_controller.GetTaskQueueFactory(), + /*event_log=*/nullptr, trials, time_controller.GetTaskQueueFactory(), PacingController::kMinSleepTime, kNoPacketHoldback); const DataRate kPacingDataRate = DataRate::KilobitsPerSec(125); @@ -241,9 +241,9 @@ TEST(TaskQueuePacedSenderTest, SleepsDuringCoalscingWindow) { const TimeDelta kCoalescingWindow = TimeDelta::Millis(5); GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); MockPacketRouter packet_router; + ScopedKeyValueConfig trials; TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, - /*event_log=*/nullptr, - /*field_trials=*/nullptr, + /*event_log=*/nullptr, trials, time_controller.GetTaskQueueFactory(), kCoalescingWindow, kNoPacketHoldback); @@ -278,9 +278,9 @@ TEST(TaskQueuePacedSenderTest, ProbingOverridesCoalescingWindow) { const TimeDelta kCoalescingWindow = TimeDelta::Millis(5); GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); MockPacketRouter packet_router; + ScopedKeyValueConfig trials; TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, - /*event_log=*/nullptr, - /*field_trials=*/nullptr, + /*event_log=*/nullptr, trials, time_controller.GetTaskQueueFactory(), kCoalescingWindow, kNoPacketHoldback); @@ -307,13 +307,13 @@ TEST(TaskQueuePacedSenderTest, ProbingOverridesCoalescingWindow) { } TEST(TaskQueuePacedSenderTest, SchedulesProbeAtSetTime) { - ScopedFieldTrials trials("WebRTC-Bwe-ProbingBehavior/min_probe_delta:1ms/"); + ScopedKeyValueConfig trials( + "WebRTC-Bwe-ProbingBehavior/min_probe_delta:1ms/"); GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); MockPacketRouter packet_router; TaskQueuePacedSender pacer( time_controller.GetClock(), &packet_router, - /*event_log=*/nullptr, - /*field_trials=*/nullptr, time_controller.GetTaskQueueFactory(), + /*event_log=*/nullptr, trials, time_controller.GetTaskQueueFactory(), PacingController::kMinSleepTime, kNoPacketHoldback); // Set rates so one packet adds 4ms of buffer level. @@ -374,13 +374,13 @@ TEST(TaskQueuePacedSenderTest, SchedulesProbeAtSetTime) { TEST(TaskQueuePacedSenderTest, NoMinSleepTimeWhenProbing) { // Set min_probe_delta to be less than kMinSleepTime (1ms). const TimeDelta kMinProbeDelta = TimeDelta::Micros(100); - ScopedFieldTrials trials("WebRTC-Bwe-ProbingBehavior/min_probe_delta:100us/"); + ScopedKeyValueConfig trials( + "WebRTC-Bwe-ProbingBehavior/min_probe_delta:100us/"); GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); MockPacketRouter packet_router; TaskQueuePacedSender pacer( time_controller.GetClock(), &packet_router, - /*event_log=*/nullptr, - /*field_trials=*/nullptr, time_controller.GetTaskQueueFactory(), + /*event_log=*/nullptr, trials, time_controller.GetTaskQueueFactory(), PacingController::kMinSleepTime, kNoPacketHoldback); // Set rates so one packet adds 4ms of buffer level. @@ -433,9 +433,9 @@ TEST(TaskQueuePacedSenderTest, PacketBasedCoalescing) { GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); MockPacketRouter packet_router; + ScopedKeyValueConfig trials; TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, - /*event_log=*/nullptr, - /*field_trials=*/nullptr, + /*event_log=*/nullptr, trials, time_controller.GetTaskQueueFactory(), kFixedCoalescingWindow, kPacketBasedHoldback); @@ -484,9 +484,9 @@ TEST(TaskQueuePacedSenderTest, FixedHoldBackHasPriorityOverPackets) { GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); MockPacketRouter packet_router; + ScopedKeyValueConfig trials; TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, - /*event_log=*/nullptr, - /*field_trials=*/nullptr, + /*event_log=*/nullptr, trials, time_controller.GetTaskQueueFactory(), kFixedCoalescingWindow, kPacketBasedHoldback); @@ -530,10 +530,10 @@ TEST(TaskQueuePacedSenderTest, Stats) { static constexpr Timestamp kStartTime = Timestamp::Millis(1234); GlobalSimulatedTimeController time_controller(kStartTime); MockPacketRouter packet_router; + ScopedKeyValueConfig trials; TaskQueuePacedSender pacer( time_controller.GetClock(), &packet_router, - /*event_log=*/nullptr, - /*field_trials=*/nullptr, time_controller.GetTaskQueueFactory(), + /*event_log=*/nullptr, trials, time_controller.GetTaskQueueFactory(), PacingController::kMinSleepTime, kNoPacketHoldback); // Simulate ~2mbps video stream, covering one second. diff --git a/rtc_tools/rtc_event_log_visualizer/analyzer.cc b/rtc_tools/rtc_event_log_visualizer/analyzer.cc index 4c718185df..0185c7d89d 100644 --- a/rtc_tools/rtc_event_log_visualizer/analyzer.cc +++ b/rtc_tools/rtc_event_log_visualizer/analyzer.cc @@ -38,8 +38,6 @@ #include "modules/congestion_controller/goog_cc/delay_based_bwe.h" #include "modules/congestion_controller/include/receive_side_congestion_controller.h" #include "modules/congestion_controller/rtp/transport_feedback_adapter.h" -#include "modules/pacing/paced_sender.h" -#include "modules/pacing/packet_router.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/source/rtcp_packet.h" #include "modules/rtp_rtcp/source/rtcp_packet/common_header.h" @@ -1199,8 +1197,6 @@ void EventLogAnalyzer::CreateSendSideBweSimulationGraph(Plot* plot) { SimulatedClock clock(0); BitrateObserver observer; RtcEventLogNull null_event_log; - PacketRouter packet_router; - PacedSender pacer(&clock, &packet_router, &null_event_log); TransportFeedbackAdapter transport_feedback; auto factory = GoogCcNetworkControllerFactory(); TimeDelta process_interval = factory.GetProcessInterval(); From 023be3c977525a6e349cd17b3a2ed5d469b45d8a Mon Sep 17 00:00:00 2001 From: Florent Castelli Date: Tue, 15 Mar 2022 16:01:52 +0100 Subject: [PATCH 180/847] Data Channel Benchmarking tool Create a server using: ./data_channel_benchmark --server --port 12345 Start the flow of data from the server to a client using: ./data_channel_benchmark --port 12345 --transfer_size 100 The throughput is reported on the server console. The negotiation does not require a 3rd party server and is done over a gRPC transport. No TURN server is configured, so both peers need to be reachable using STUN only. Bug: webrtc:13288 Change-Id: Iac9a96cf390ab465ea45a46bf0b40950c56dfceb Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/235661 Reviewed-by: Harald Alvestrand Reviewed-by: Mirko Bonadei Commit-Queue: Florent Castelli Cr-Commit-Position: refs/heads/main@{#36206} --- DEPS | 3 + rtc_tools/BUILD.gn | 3 + rtc_tools/data_channel_benchmark/BUILD.gn | 62 ++++ .../data_channel_benchmark.cc | 323 ++++++++++++++++++ .../data_channel_benchmark/grpc_signaling.cc | 267 +++++++++++++++ .../data_channel_benchmark/grpc_signaling.h | 64 ++++ .../peer_connection_client.cc | 301 ++++++++++++++++ .../peer_connection_client.h | 108 ++++++ .../peer_connection_signaling.proto | 29 ++ .../signaling_interface.h | 42 +++ .../sanitizers/tsan_suppressions_webrtc.cc | 3 + webrtc.gni | 3 + 12 files changed, 1208 insertions(+) create mode 100644 rtc_tools/data_channel_benchmark/BUILD.gn create mode 100644 rtc_tools/data_channel_benchmark/data_channel_benchmark.cc create mode 100644 rtc_tools/data_channel_benchmark/grpc_signaling.cc create mode 100644 rtc_tools/data_channel_benchmark/grpc_signaling.h create mode 100644 rtc_tools/data_channel_benchmark/peer_connection_client.cc create mode 100644 rtc_tools/data_channel_benchmark/peer_connection_client.h create mode 100644 rtc_tools/data_channel_benchmark/peer_connection_signaling.proto create mode 100644 rtc_tools/data_channel_benchmark/signaling_interface.h diff --git a/DEPS b/DEPS index dc31e4d40e..99fb48d488 100644 --- a/DEPS +++ b/DEPS @@ -156,6 +156,9 @@ deps = { 'url': 'https://chromium.googlesource.com/chromium/deps/findbugs.git@4275d9ac8610db6b1bc9a5e887f97e41b33fac67', 'condition': 'checkout_android', }, + 'src/third_party/grpc/src': { + 'url': 'https://chromium.googlesource.com/external/github.com/grpc/grpc.git@f8a909e76fcd947949502832a7ab8e2cba2b8e27', + }, # Used for embedded builds. CrOS & Linux use the system version. 'src/third_party/fontconfig/src': { 'url': 'https://chromium.googlesource.com/external/fontconfig.git@452be8125f0e2a18a7dfef469e05d19374d36307', diff --git a/rtc_tools/BUILD.gn b/rtc_tools/BUILD.gn index b841228a8e..fa170138da 100644 --- a/rtc_tools/BUILD.gn +++ b/rtc_tools/BUILD.gn @@ -47,6 +47,9 @@ group("rtc_tools") { ":unpack_aecdump", ] } + if (!build_with_chromium && rtc_enable_grpc) { + deps += [ "data_channel_benchmark" ] + } } rtc_library("video_file_reader") { diff --git a/rtc_tools/data_channel_benchmark/BUILD.gn b/rtc_tools/data_channel_benchmark/BUILD.gn new file mode 100644 index 0000000000..c7fbb85f9b --- /dev/null +++ b/rtc_tools/data_channel_benchmark/BUILD.gn @@ -0,0 +1,62 @@ +# Copyright 2021 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//third_party/grpc/grpc_library.gni") +import("../../webrtc.gni") + +grpc_library("signaling_grpc_proto") { + testonly = true + sources = [ "peer_connection_signaling.proto" ] +} + +rtc_library("signaling_interface") { + sources = [ "signaling_interface.h" ] + deps = [ "../../api:libjingle_peerconnection_api" ] +} + +rtc_library("grpc_signaling") { + testonly = true + sources = [ + "grpc_signaling.cc", + "grpc_signaling.h", + ] + deps = [ + ":signaling_grpc_proto", + ":signaling_interface", + "../../api:libjingle_peerconnection_api", + "../../rtc_base:threading", + "//third_party/grpc:grpc++", + ] + + defines = [ "GPR_FORBID_UNREACHABLE_CODE=0" ] +} + +rtc_executable("data_channel_benchmark") { + testonly = true + sources = [ + "data_channel_benchmark.cc", + "peer_connection_client.cc", + "peer_connection_client.h", + ] + deps = [ + ":grpc_signaling", + ":signaling_interface", + "../../api:create_peerconnection_factory", + "../../api:libjingle_peerconnection_api", + "../../api:rtc_error", + "../../api:scoped_refptr", + "../../api/audio_codecs:builtin_audio_decoder_factory", + "../../api/audio_codecs:builtin_audio_encoder_factory", + "../../api/video_codecs:builtin_video_decoder_factory", + "../../api/video_codecs:builtin_video_encoder_factory", + "../../rtc_base", + "../../rtc_base:logging", + "../../rtc_base:refcount", + "../../rtc_base:threading", + "../../system_wrappers:field_trial", + "//third_party/abseil-cpp/absl/cleanup:cleanup", + "//third_party/abseil-cpp/absl/flags:flag", + "//third_party/abseil-cpp/absl/flags:parse", + ] +} diff --git a/rtc_tools/data_channel_benchmark/data_channel_benchmark.cc b/rtc_tools/data_channel_benchmark/data_channel_benchmark.cc new file mode 100644 index 0000000000..57ee8e5fc9 --- /dev/null +++ b/rtc_tools/data_channel_benchmark/data_channel_benchmark.cc @@ -0,0 +1,323 @@ +/* + * Copyright (c) 2021 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + * + * Data Channel Benchmarking tool. + * + * Create a server using: ./data_channel_benchmark --server --port 12345 + * Start the flow of data from the server to a client using: + * ./data_channel_benchmark --port 12345 --transfer_size 100 --packet_size 8196 + * The throughput is reported on the server console. + * + * The negotiation does not require a 3rd party server and is done over a gRPC + * transport. No TURN server is configured, so both peers need to be reachable + * using STUN only. + */ +#include + +#include + +#include "absl/cleanup/cleanup.h" +#include "absl/flags/flag.h" +#include "absl/flags/parse.h" +#include "rtc_base/event.h" +#include "rtc_base/ssl_adapter.h" +#include "rtc_base/thread.h" +#include "rtc_tools/data_channel_benchmark/grpc_signaling.h" +#include "rtc_tools/data_channel_benchmark/peer_connection_client.h" +#include "system_wrappers/include/field_trial.h" + +ABSL_FLAG(int, verbose, 0, "verbosity level (0-5)"); +ABSL_FLAG(bool, server, false, "Server mode"); +ABSL_FLAG(bool, oneshot, true, "Terminate after serving a client"); +ABSL_FLAG(std::string, address, "localhost", "Connect to server address"); +ABSL_FLAG(uint16_t, port, 0, "Connect to port (0 for random)"); +ABSL_FLAG(uint64_t, transfer_size, 2, "Transfer size (MiB)"); +ABSL_FLAG(uint64_t, packet_size, 256 * 1024, "Packet size"); +ABSL_FLAG(std::string, + force_fieldtrials, + "", + "Field trials control experimental feature code which can be forced. " + "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/" + " will assign the group Enable to field trial WebRTC-FooFeature."); + +struct SetupMessage { + size_t packet_size; + size_t transfer_size; + + std::string ToString() { + char buffer[64]; + rtc::SimpleStringBuilder sb(buffer); + sb << packet_size << "," << transfer_size; + + return sb.str(); + } + + static SetupMessage FromString(absl::string_view sv) { + SetupMessage result; + auto parameters = rtc::split(sv, ','); + std::from_chars(parameters[0].data(), + parameters[0].data() + parameters[0].size(), + result.packet_size, 10); + std::from_chars(parameters[1].data(), + parameters[1].data() + parameters[1].size(), + result.transfer_size, 10); + return result; + } +}; + +class DataChannelObserverImpl : public webrtc::DataChannelObserver { + public: + explicit DataChannelObserverImpl(webrtc::DataChannelInterface* dc) + : dc_(dc), bytes_received_(0) {} + void OnStateChange() override { + RTC_LOG(LS_INFO) << "State changed to " << dc_->state(); + switch (dc_->state()) { + case webrtc::DataChannelInterface::DataState::kOpen: + open_event_.Set(); + break; + case webrtc::DataChannelInterface::DataState::kClosed: + closed_event_.Set(); + break; + default: + break; + } + } + void OnMessage(const webrtc::DataBuffer& buffer) override { + bytes_received_ += buffer.data.size(); + if (bytes_received_threshold_ && + bytes_received_ >= bytes_received_threshold_) { + bytes_received_event_.Set(); + } + + if (setup_message_.empty() && !buffer.binary) { + setup_message_.assign(buffer.data.cdata(), buffer.data.size()); + setup_message_event_.Set(); + } + } + void OnBufferedAmountChange(uint64_t sent_data_size) override { + if (dc_->buffered_amount() < + webrtc::DataChannelInterface::MaxSendQueueSize() / 2) + low_buffered_threshold_event_.Set(); + else + low_buffered_threshold_event_.Reset(); + } + + bool WaitForOpenState(int duration_ms) { + return dc_->state() == webrtc::DataChannelInterface::DataState::kOpen || + open_event_.Wait(duration_ms); + } + bool WaitForClosedState(int duration_ms) { + return dc_->state() == webrtc::DataChannelInterface::DataState::kClosed || + closed_event_.Wait(duration_ms); + } + + // Set how many received bytes are required until + // WaitForBytesReceivedThreshold return true. + void SetBytesReceivedThreshold(uint64_t bytes_received_threshold) { + bytes_received_threshold_ = bytes_received_threshold; + if (bytes_received_ >= bytes_received_threshold_) + bytes_received_event_.Set(); + } + // Wait until the received byte count reaches the desired value. + bool WaitForBytesReceivedThreshold(int duration_ms) { + return (bytes_received_threshold_ && + bytes_received_ >= bytes_received_threshold_) || + bytes_received_event_.Wait(duration_ms); + } + + bool WaitForLowbufferedThreshold(int duration_ms) { + return low_buffered_threshold_event_.Wait(duration_ms); + } + std::string SetupMessage() { return setup_message_; } + bool WaitForSetupMessage(int duration_ms) { + return setup_message_event_.Wait(duration_ms); + } + + private: + webrtc::DataChannelInterface* dc_; + rtc::Event open_event_; + rtc::Event closed_event_; + rtc::Event bytes_received_event_; + absl::optional bytes_received_threshold_; + uint64_t bytes_received_; + rtc::Event low_buffered_threshold_event_; + std::string setup_message_; + rtc::Event setup_message_event_; +}; + +int RunServer() { + bool oneshot = absl::GetFlag(FLAGS_oneshot); + uint16_t port = absl::GetFlag(FLAGS_port); + + auto signaling_thread = rtc::Thread::Create(); + signaling_thread->Start(); + { + auto factory = webrtc::PeerConnectionClient::CreateDefaultFactory( + signaling_thread.get()); + + auto grpc_server = webrtc::GrpcSignalingServerInterface::Create( + [factory = rtc::scoped_refptr( + factory)](webrtc::SignalingInterface* signaling) { + webrtc::PeerConnectionClient client(factory.get(), signaling); + client.StartPeerConnection(); + auto peer_connection = client.peerConnection(); + + // Set up the data channel + auto dc_or_error = + peer_connection->CreateDataChannelOrError("benchmark", nullptr); + auto data_channel = dc_or_error.MoveValue(); + auto data_channel_observer = + std::make_unique(data_channel); + data_channel->RegisterObserver(data_channel_observer.get()); + absl::Cleanup unregister_observer( + [data_channel] { data_channel->UnregisterObserver(); }); + + // Wait for a first message from the remote peer. + // It configures how much data should be sent and how big the packets + // should be. + // First message is "packet_size,transfer_size". + data_channel_observer->WaitForSetupMessage(rtc::Event::kForever); + auto parameters = + SetupMessage::FromString(data_channel_observer->SetupMessage()); + + // Wait for the sender and receiver peers to stabilize (send all ACKs) + // This makes it easier to isolate the sending part when profiling. + absl::SleepFor(absl::Seconds(1)); + + std::string data(parameters.packet_size, '0'); + size_t remaining_data = parameters.transfer_size; + + auto begin_time = webrtc::Clock::GetRealTimeClock()->CurrentTime(); + + while (remaining_data) { + if (remaining_data < data.size()) + data.resize(remaining_data); + + rtc::CopyOnWriteBuffer buffer(data); + webrtc::DataBuffer data_buffer(buffer, true); + if (!data_channel->Send(data_buffer)) { + // If the send() call failed, the buffers are full. + // We wait until there's more room. + data_channel_observer->WaitForLowbufferedThreshold( + rtc::Event::kForever); + continue; + } + remaining_data -= buffer.size(); + fprintf(stderr, "Progress: %zu / %zu (%zu%%)\n", + (parameters.transfer_size - remaining_data), + parameters.transfer_size, + (100 - remaining_data * 100 / parameters.transfer_size)); + } + + // Receiver signals the data channel close event when it has received + // all the data it requested. + data_channel_observer->WaitForClosedState(rtc::Event::kForever); + + auto end_time = webrtc::Clock::GetRealTimeClock()->CurrentTime(); + auto duration_ms = (end_time - begin_time).ms(); + double throughput = (parameters.transfer_size / 1024. / 1024.) / + (duration_ms / 1000.); + printf("Elapsed time: %zums %gMiB/s\n", duration_ms, throughput); + }, + port, oneshot); + grpc_server->Start(); + + printf("Server listening on port %d\n", grpc_server->SelectedPort()); + grpc_server->Wait(); + } + + signaling_thread->Quit(); + return 0; +} + +int RunClient() { + uint16_t port = absl::GetFlag(FLAGS_port); + std::string server_address = absl::GetFlag(FLAGS_address); + size_t transfer_size = absl::GetFlag(FLAGS_transfer_size) * 1024 * 1024; + size_t packet_size = absl::GetFlag(FLAGS_packet_size); + + auto signaling_thread = rtc::Thread::Create(); + signaling_thread->Start(); + { + auto factory = webrtc::PeerConnectionClient::CreateDefaultFactory( + signaling_thread.get()); + auto grpc_client = webrtc::GrpcSignalingClientInterface::Create( + server_address + ":" + std::to_string(port)); + webrtc::PeerConnectionClient client(factory.get(), + grpc_client->signaling_client()); + + // Set up the callback to receive the data channel from the sender. + rtc::scoped_refptr data_channel; + rtc::Event got_data_channel; + client.SetOnDataChannel( + [&data_channel, &got_data_channel]( + rtc::scoped_refptr channel) { + data_channel = channel; + got_data_channel.Set(); + }); + + // Connect to the server. + if (!grpc_client->Start()) { + fprintf(stderr, "Failed to connect to server\n"); + return 1; + } + + // Wait for the data channel to be received + got_data_channel.Wait(rtc::Event::kForever); + + // DataChannel needs an observer to start draining the read queue + DataChannelObserverImpl observer(data_channel.get()); + observer.SetBytesReceivedThreshold(transfer_size); + data_channel->RegisterObserver(&observer); + absl::Cleanup unregister_observer( + [data_channel] { data_channel->UnregisterObserver(); }); + + // Send a configuration string to the server to tell it to send + // 'packet_size' bytes packets and send a total of 'transfer_size' MB. + observer.WaitForOpenState(rtc::Event::kForever); + SetupMessage setup_message = { + .packet_size = packet_size, + .transfer_size = transfer_size, + }; + if (!data_channel->Send(webrtc::DataBuffer(setup_message.ToString()))) { + fprintf(stderr, "Failed to send parameter string\n"); + return 1; + } + + // Wait until we have received all the data + observer.WaitForBytesReceivedThreshold(rtc::Event::kForever); + + // Close the data channel, signaling to the server we have received + // all the requested data. + data_channel->Close(); + } + + signaling_thread->Quit(); + + return 0; +} + +int main(int argc, char** argv) { + rtc::InitializeSSL(); + absl::ParseCommandLine(argc, argv); + + // Make sure that higher severity number means more logs by reversing the + // rtc::LoggingSeverity values. + auto logging_severity = + std::max(0, rtc::LS_NONE - absl::GetFlag(FLAGS_verbose)); + rtc::LogMessage::LogToDebug( + static_cast(logging_severity)); + + bool is_server = absl::GetFlag(FLAGS_server); + std::string field_trials = absl::GetFlag(FLAGS_force_fieldtrials); + + webrtc::field_trial::InitFieldTrialsFromString(field_trials.c_str()); + + return is_server ? RunServer() : RunClient(); +} diff --git a/rtc_tools/data_channel_benchmark/grpc_signaling.cc b/rtc_tools/data_channel_benchmark/grpc_signaling.cc new file mode 100644 index 0000000000..8db717fc71 --- /dev/null +++ b/rtc_tools/data_channel_benchmark/grpc_signaling.cc @@ -0,0 +1,267 @@ +/* + * Copyright (c) 2021 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ +#include "rtc_tools/data_channel_benchmark/grpc_signaling.h" + +#include +#include + +#include +#include + +#include "api/jsep.h" +#include "api/jsep_ice_candidate.h" +#include "rtc_base/thread.h" +#include "rtc_tools/data_channel_benchmark/peer_connection_signaling.grpc.pb.h" + +namespace webrtc { +namespace { + +using GrpcSignaling::IceCandidate; +using GrpcSignaling::PeerConnectionSignaling; +using GrpcSignaling::SessionDescription; +using GrpcSignaling::SignalingMessage; + +template +class SessionData : public webrtc::SignalingInterface { + public: + SessionData() {} + explicit SessionData(T* stream) : stream_(stream) {} + void SetStream(T* stream) { stream_ = stream; } + + void SendIceCandidate(const IceCandidateInterface* candidate) override { + RTC_LOG(LS_INFO) << "SendIceCandidate"; + std::string serialized_candidate; + if (!candidate->ToString(&serialized_candidate)) { + RTC_LOG(LS_ERROR) << "Failed to serialize ICE candidate"; + return; + } + + SignalingMessage message; + IceCandidate* proto_candidate = message.mutable_candidate(); + proto_candidate->set_description(serialized_candidate); + proto_candidate->set_mid(candidate->sdp_mid()); + proto_candidate->set_mline_index(candidate->sdp_mline_index()); + + stream_->Write(message); + } + + void SendDescription(const SessionDescriptionInterface* sdp) override { + RTC_LOG(LS_INFO) << "SendDescription"; + + std::string serialized_sdp; + sdp->ToString(&serialized_sdp); + + SignalingMessage message; + if (sdp->GetType() == SdpType::kOffer) + message.mutable_description()->set_type(SessionDescription::OFFER); + else if (sdp->GetType() == SdpType::kAnswer) + message.mutable_description()->set_type(SessionDescription::ANSWER); + message.mutable_description()->set_content(serialized_sdp); + + stream_->Write(message); + } + + void OnRemoteDescription( + std::function sdp)> + callback) override { + RTC_LOG(LS_INFO) << "OnRemoteDescription"; + remote_description_callback_ = callback; + } + + void OnIceCandidate( + std::function candidate)> + callback) override { + RTC_LOG(LS_INFO) << "OnIceCandidate"; + ice_candidate_callback_ = callback; + } + + T* stream_; + + std::function)> + ice_candidate_callback_; + std::function)> + remote_description_callback_; +}; + +using ServerSessionData = + SessionData>; +using ClientSessionData = + SessionData>; + +template +void ProcessMessages(StreamReader* stream, SessionData* session) { + MessageType message; + + while (stream->Read(&message)) { + switch (message.Content_case()) { + case SignalingMessage::ContentCase::kCandidate: { + webrtc::SdpParseError error; + auto jsep_candidate = std::make_unique( + message.candidate().mid(), message.candidate().mline_index()); + if (!jsep_candidate->Initialize(message.candidate().description(), + &error)) { + RTC_LOG(LS_ERROR) << "Failed to deserialize ICE candidate '" + << message.candidate().description() << "'"; + RTC_LOG(LS_ERROR) + << "Error at line " << error.line << ":" << error.description; + continue; + } + + session->ice_candidate_callback_(std::move(jsep_candidate)); + break; + } + case SignalingMessage::ContentCase::kDescription: { + auto& description = message.description(); + auto content = description.content(); + + auto sdp = webrtc::CreateSessionDescription( + description.type() == SessionDescription::OFFER + ? webrtc::SdpType::kOffer + : webrtc::SdpType::kAnswer, + description.content()); + session->remote_description_callback_(std::move(sdp)); + break; + } + default: + RTC_DCHECK_NOTREACHED(); + } + } +} + +class GrpcNegotiationServer : public GrpcSignalingServerInterface, + public PeerConnectionSignaling::Service { + public: + GrpcNegotiationServer( + std::function callback, + int port, + bool oneshot) + : connect_callback_(std::move(callback)), + requested_port_(port), + oneshot_(oneshot) {} + ~GrpcNegotiationServer() override { + Stop(); + if (server_stop_thread_) + server_stop_thread_->Stop(); + } + + void Start() override { + std::string server_address = "[::]"; + + grpc::ServerBuilder builder; + builder.AddListeningPort( + server_address + ":" + std::to_string(requested_port_), + grpc::InsecureServerCredentials(), &selected_port_); + builder.RegisterService(this); + server_ = builder.BuildAndStart(); + } + + void Wait() override { server_->Wait(); } + + void Stop() override { server_->Shutdown(); } + + int SelectedPort() override { return selected_port_; } + + grpc::Status Connect( + grpc::ServerContext* context, + grpc::ServerReaderWriter* stream) + override { + if (oneshot_) { + // Request the termination of the server early so we don't serve another + // client in parallel. + server_stop_thread_ = rtc::Thread::Create(); + server_stop_thread_->Start(); + server_stop_thread_->PostTask([this] { Stop(); }); + } + + ServerSessionData session(stream); + + auto reading_thread = rtc::Thread::Create(); + reading_thread->Start(); + reading_thread->PostTask([&session, &stream] { + ProcessMessages(stream, &session); + }); + + connect_callback_(&session); + + reading_thread->Stop(); + + return grpc::Status::OK; + } + + private: + std::function connect_callback_; + int requested_port_; + int selected_port_; + bool oneshot_; + + std::unique_ptr server_; + std::unique_ptr server_stop_thread_; +}; + +class GrpcNegotiationClient : public GrpcSignalingClientInterface { + public: + explicit GrpcNegotiationClient(const std::string& server) { + channel_ = grpc::CreateChannel(server, grpc::InsecureChannelCredentials()); + stub_ = PeerConnectionSignaling::NewStub(channel_); + } + + ~GrpcNegotiationClient() override { + context_.TryCancel(); + if (reading_thread_) + reading_thread_->Stop(); + } + + bool Start() override { + if (!channel_->WaitForConnected( + absl::ToChronoTime(absl::Now() + absl::Seconds(3)))) { + return false; + } + + stream_ = stub_->Connect(&context_); + session_.SetStream(stream_.get()); + + reading_thread_ = rtc::Thread::Create(); + reading_thread_->Start(); + reading_thread_->PostTask([this] { + ProcessMessages(stream_.get(), &session_); + }); + + return true; + } + + webrtc::SignalingInterface* signaling_client() override { return &session_; } + + private: + std::shared_ptr channel_; + std::unique_ptr stub_; + std::unique_ptr reading_thread_; + grpc::ClientContext context_; + std::unique_ptr< + ::grpc::ClientReaderWriter> + stream_; + ClientSessionData session_; +}; +} // namespace + +std::unique_ptr +GrpcSignalingServerInterface::Create( + std::function callback, + int port, + bool oneshot) { + return std::make_unique(std::move(callback), port, + oneshot); +} + +std::unique_ptr +GrpcSignalingClientInterface::Create(const std::string& server) { + return std::make_unique(server); +} + +} // namespace webrtc diff --git a/rtc_tools/data_channel_benchmark/grpc_signaling.h b/rtc_tools/data_channel_benchmark/grpc_signaling.h new file mode 100644 index 0000000000..15799d22b7 --- /dev/null +++ b/rtc_tools/data_channel_benchmark/grpc_signaling.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2021 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ +#ifndef RTC_TOOLS_DATA_CHANNEL_BENCHMARK_GRPC_SIGNALING_H_ +#define RTC_TOOLS_DATA_CHANNEL_BENCHMARK_GRPC_SIGNALING_H_ + +#include +#include + +#include "api/jsep.h" +#include "rtc_tools/data_channel_benchmark/signaling_interface.h" + +namespace webrtc { + +// This class defines a server enabling clients to perform a PeerConnection +// negotiation directly over gRPC. +// When a client connects, a callback is run to handle the request. +class GrpcSignalingServerInterface { + public: + virtual ~GrpcSignalingServerInterface() = default; + + // Start listening for connections. + virtual void Start() = 0; + + // Wait for the gRPC server to terminate. + virtual void Wait() = 0; + + // Stop the gRPC server instance. + virtual void Stop() = 0; + + // The port the server is listening on. + virtual int SelectedPort() = 0; + + // Create a gRPC server listening on |port| that will run |callback| on each + // request. If |oneshot| is true, it will terminate after serving one request. + static std::unique_ptr Create( + std::function callback, + int port, + bool oneshot); +}; + +// This class defines a client that can connect to a server and perform a +// PeerConnection negotiation directly over gRPC. +class GrpcSignalingClientInterface { + public: + virtual ~GrpcSignalingClientInterface() = default; + + // Connect the client to the gRPC server. + virtual bool Start() = 0; + virtual webrtc::SignalingInterface* signaling_client() = 0; + + // Create a client to connnect to a server at |server_address|. + static std::unique_ptr Create( + const std::string& server_address); +}; + +} // namespace webrtc +#endif // RTC_TOOLS_DATA_CHANNEL_BENCHMARK_GRPC_SIGNALING_H_ diff --git a/rtc_tools/data_channel_benchmark/peer_connection_client.cc b/rtc_tools/data_channel_benchmark/peer_connection_client.cc new file mode 100644 index 0000000000..6d2ee8101d --- /dev/null +++ b/rtc_tools/data_channel_benchmark/peer_connection_client.cc @@ -0,0 +1,301 @@ +/* + * Copyright (c) 2021 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ +#include "rtc_tools/data_channel_benchmark/peer_connection_client.h" + +#include +#include +#include + +#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/jsep.h" +#include "api/peer_connection_interface.h" +#include "api/rtc_error.h" +#include "api/scoped_refptr.h" +#include "api/set_remote_description_observer_interface.h" +#include "api/video_codecs/builtin_video_decoder_factory.h" +#include "api/video_codecs/builtin_video_encoder_factory.h" +#include "rtc_base/logging.h" +#include "rtc_base/thread.h" + +namespace { + +constexpr char kStunServer[] = "stun:stun.l.google.com:19302"; + +class SetLocalDescriptionObserverAdapter + : public webrtc::SetLocalDescriptionObserverInterface { + public: + using Callback = std::function; + static rtc::scoped_refptr Create( + Callback callback) { + return rtc::scoped_refptr( + new rtc::RefCountedObject( + std::move(callback))); + } + + explicit SetLocalDescriptionObserverAdapter(Callback callback) + : callback_(std::move(callback)) {} + ~SetLocalDescriptionObserverAdapter() override = default; + + private: + void OnSetLocalDescriptionComplete(webrtc::RTCError error) override { + callback_(std::move(error)); + } + + Callback callback_; +}; + +class SetRemoteDescriptionObserverAdapter + : public webrtc::SetRemoteDescriptionObserverInterface { + public: + using Callback = std::function; + static rtc::scoped_refptr Create( + Callback callback) { + return rtc::scoped_refptr( + new rtc::RefCountedObject( + std::move(callback))); + } + + explicit SetRemoteDescriptionObserverAdapter(Callback callback) + : callback_(std::move(callback)) {} + ~SetRemoteDescriptionObserverAdapter() override = default; + + private: + void OnSetRemoteDescriptionComplete(webrtc::RTCError error) override { + callback_(std::move(error)); + } + + Callback callback_; +}; + +class CreateSessionDescriptionObserverAdapter + : public webrtc::CreateSessionDescriptionObserver { + public: + using Success = std::function; + using Failure = std::function; + + static rtc::scoped_refptr Create( + Success success, + Failure failure) { + return rtc::scoped_refptr( + new rtc::RefCountedObject( + std::move(success), std::move(failure))); + } + + CreateSessionDescriptionObserverAdapter(Success success, Failure failure) + : success_(std::move(success)), failure_(std::move(failure)) {} + ~CreateSessionDescriptionObserverAdapter() override = default; + + private: + void OnSuccess(webrtc::SessionDescriptionInterface* desc) override { + success_(desc); + } + + void OnFailure(webrtc::RTCError error) override { + failure_(std::move(error)); + } + + Success success_; + Failure failure_; +}; + +} // namespace + +namespace webrtc { + +PeerConnectionClient::PeerConnectionClient( + webrtc::PeerConnectionFactoryInterface* factory, + webrtc::SignalingInterface* signaling) + : signaling_(signaling) { + signaling_->OnIceCandidate( + [&](std::unique_ptr candidate) { + AddIceCandidate(std::move(candidate)); + }); + signaling_->OnRemoteDescription( + [&](std::unique_ptr sdp) { + SetRemoteDescription(std::move(sdp)); + }); + InitializePeerConnection(factory); +} + +PeerConnectionClient::~PeerConnectionClient() { + Disconnect(); +} + +rtc::scoped_refptr +PeerConnectionClient::CreateDefaultFactory(rtc::Thread* signaling_thread) { + auto factory = webrtc::CreatePeerConnectionFactory( + /*network_thread=*/nullptr, /*worker_thread=*/nullptr, + /*signaling_thread*/ signaling_thread, + /*default_adm=*/nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), + webrtc::CreateBuiltinAudioDecoderFactory(), + webrtc::CreateBuiltinVideoEncoderFactory(), + webrtc::CreateBuiltinVideoDecoderFactory(), + /*audio_mixer=*/nullptr, /*audio_processing=*/nullptr); + + if (!factory) { + RTC_LOG(LS_ERROR) << "Failed to initialize PeerConnectionFactory"; + return nullptr; + } + + return factory; +} + +bool PeerConnectionClient::InitializePeerConnection( + webrtc::PeerConnectionFactoryInterface* factory) { + RTC_CHECK(factory) + << "Must call InitializeFactory before InitializePeerConnection"; + + webrtc::PeerConnectionInterface::RTCConfiguration config; + webrtc::PeerConnectionInterface::IceServer server; + server.urls.push_back(kStunServer); + config.servers.push_back(server); + config.sdp_semantics = webrtc::SdpSemantics::kUnifiedPlan; + config.enable_dtls_srtp = true; + + webrtc::PeerConnectionDependencies dependencies(this); + auto result = + factory->CreatePeerConnectionOrError(config, std::move(dependencies)); + + if (!result.ok()) { + RTC_LOG(LS_ERROR) << "Failed to create PeerConnection: " + << result.error().message(); + DeletePeerConnection(); + return false; + } + peer_connection_ = result.MoveValue(); + RTC_LOG(LS_INFO) << "PeerConnection created successfully"; + return true; +} + +bool PeerConnectionClient::StartPeerConnection() { + RTC_LOG(LS_INFO) << "Creating offer"; + + peer_connection_->SetLocalDescription( + SetLocalDescriptionObserverAdapter::Create([this]( + webrtc::RTCError error) { + if (error.ok()) + signaling_->SendDescription(peer_connection_->local_description()); + })); + + return true; +} + +bool PeerConnectionClient::IsConnected() { + return peer_connection_->peer_connection_state() == + webrtc::PeerConnectionInterface::PeerConnectionState::kConnected; +} + +// Disconnect from the call. +void PeerConnectionClient::Disconnect() { + for (auto& data_channel : data_channels_) { + data_channel->Close(); + data_channel.release(); + } + data_channels_.clear(); + DeletePeerConnection(); +} + +// Delete the WebRTC PeerConnection. +void PeerConnectionClient::DeletePeerConnection() { + RTC_LOG(LS_INFO); + + if (peer_connection_) { + peer_connection_->Close(); + } + peer_connection_.release(); +} + +void PeerConnectionClient::OnIceConnectionChange( + webrtc::PeerConnectionInterface::IceConnectionState new_state) { + if (new_state == webrtc::PeerConnectionInterface::IceConnectionState:: + kIceConnectionCompleted) { + RTC_LOG(LS_INFO) << "State is updating to connected"; + } else if (new_state == webrtc::PeerConnectionInterface::IceConnectionState:: + kIceConnectionDisconnected) { + RTC_LOG(LS_INFO) << "Disconnecting from peer"; + Disconnect(); + } +} + +void PeerConnectionClient::OnIceGatheringChange( + webrtc::PeerConnectionInterface::IceGatheringState new_state) { + if (new_state == webrtc::PeerConnectionInterface::kIceGatheringComplete) { + RTC_LOG(LS_INFO) << "Client is ready to receive remote SDP"; + } +} + +void PeerConnectionClient::OnIceCandidate( + const webrtc::IceCandidateInterface* candidate) { + signaling_->SendIceCandidate(candidate); +} + +void PeerConnectionClient::OnDataChannel( + rtc::scoped_refptr channel) { + RTC_LOG(LS_INFO) << __FUNCTION__ << " remote datachannel created"; + if (on_data_channel_callback_) + on_data_channel_callback_(channel); + data_channels_.push_back(channel); +} + +void PeerConnectionClient::SetOnDataChannel( + std::function)> + callback) { + on_data_channel_callback_ = callback; +} + +void PeerConnectionClient::OnNegotiationNeededEvent(uint32_t event_id) { + RTC_LOG(LS_INFO) << "OnNegotiationNeededEvent"; + + peer_connection_->SetLocalDescription( + SetLocalDescriptionObserverAdapter::Create([this]( + webrtc::RTCError error) { + if (error.ok()) + signaling_->SendDescription(peer_connection_->local_description()); + })); +} + +bool PeerConnectionClient::SetRemoteDescription( + std::unique_ptr desc) { + RTC_LOG(LS_INFO) << "SetRemoteDescription"; + auto type = desc->GetType(); + + peer_connection_->SetRemoteDescription( + std::move(desc), + SetRemoteDescriptionObserverAdapter::Create([&](webrtc::RTCError) { + RTC_LOG(LS_INFO) << "SetRemoteDescription done"; + + if (type == webrtc::SdpType::kOffer) { + // Got an offer from the remote, need to set an answer and send it. + peer_connection_->SetLocalDescription( + SetLocalDescriptionObserverAdapter::Create( + [this](webrtc::RTCError error) { + if (error.ok()) + signaling_->SendDescription( + peer_connection_->local_description()); + })); + } + })); + + return true; +} + +void PeerConnectionClient::AddIceCandidate( + std::unique_ptr candidate) { + RTC_LOG(LS_INFO) << "AddIceCandidate"; + + peer_connection_->AddIceCandidate( + std::move(candidate), [](const webrtc::RTCError& error) { + RTC_LOG(LS_INFO) << "Failed to add candidate: " << error.message(); + }); +} + +} // namespace webrtc diff --git a/rtc_tools/data_channel_benchmark/peer_connection_client.h b/rtc_tools/data_channel_benchmark/peer_connection_client.h new file mode 100644 index 0000000000..a9787fe709 --- /dev/null +++ b/rtc_tools/data_channel_benchmark/peer_connection_client.h @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2021 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ +#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 "api/jsep.h" +#include "api/peer_connection_interface.h" +#include "api/rtp_receiver_interface.h" +#include "api/scoped_refptr.h" +#include "api/set_local_description_observer_interface.h" +#include "rtc_base/logging.h" +#include "rtc_base/ref_counted_object.h" +#include "rtc_base/thread.h" +#include "rtc_tools/data_channel_benchmark/signaling_interface.h" + +namespace webrtc { + +// Handles all the details for creating a PeerConnection and negotiation using a +// SignalingInterface object. +class PeerConnectionClient : public webrtc::PeerConnectionObserver { + public: + explicit PeerConnectionClient(webrtc::PeerConnectionFactoryInterface* factory, + webrtc::SignalingInterface* signaling); + + ~PeerConnectionClient() override; + + PeerConnectionClient(const PeerConnectionClient&) = delete; + PeerConnectionClient& operator=(const PeerConnectionClient&) = delete; + + // Set the local description and send offer using the SignalingInterface, + // initiating the negotiation process. + bool StartPeerConnection(); + + // Whether the peer connection is connected to the remote peer. + bool IsConnected(); + + // Disconnect from the call. + void Disconnect(); + + rtc::scoped_refptr peerConnection() { + return peer_connection_; + } + + // Set a callback to run when a DataChannel is created by the remote peer. + void SetOnDataChannel( + std::function)> + callback); + + std::vector>& + dataChannels() { + return data_channels_; + } + + // Creates a default PeerConnectionFactory object. + static rtc::scoped_refptr + CreateDefaultFactory(rtc::Thread* signaling_thread); + + private: + void AddIceCandidate( + std::unique_ptr candidate); + bool SetRemoteDescription( + std::unique_ptr desc); + + // Initialize the PeerConnection with a given PeerConnectionFactory. + bool InitializePeerConnection( + webrtc::PeerConnectionFactoryInterface* factory); + void DeletePeerConnection(); + + // PeerConnectionObserver implementation. + void OnSignalingChange( + webrtc::PeerConnectionInterface::SignalingState new_state) override { + RTC_LOG(LS_INFO) << __FUNCTION__ << " new state: " << new_state; + } + void OnDataChannel( + rtc::scoped_refptr channel) override; + void OnNegotiationNeededEvent(uint32_t event_id) override; + void OnIceConnectionChange( + webrtc::PeerConnectionInterface::IceConnectionState new_state) override; + void OnIceGatheringChange( + webrtc::PeerConnectionInterface::IceGatheringState new_state) override; + void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override; + void OnIceConnectionReceivingChange(bool receiving) override { + RTC_LOG(LS_INFO) << __FUNCTION__ << " receiving? " << receiving; + } + + rtc::scoped_refptr peer_connection_; + std::function)> + on_data_channel_callback_; + std::vector> data_channels_; + webrtc::SignalingInterface* signaling_; +}; + +} // namespace webrtc + +#endif // RTC_TOOLS_DATA_CHANNEL_BENCHMARK_PEER_CONNECTION_CLIENT_H_ diff --git a/rtc_tools/data_channel_benchmark/peer_connection_signaling.proto b/rtc_tools/data_channel_benchmark/peer_connection_signaling.proto new file mode 100644 index 0000000000..9bd0aae912 --- /dev/null +++ b/rtc_tools/data_channel_benchmark/peer_connection_signaling.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; + +package webrtc.GrpcSignaling; + +service PeerConnectionSignaling { + rpc Connect(stream SignalingMessage) returns (stream SignalingMessage) {} +} + +message SignalingMessage { + oneof Content { + SessionDescription description = 1; + IceCandidate candidate = 2; + } +} + +message SessionDescription { + enum SessionDescriptionType { + OFFER = 0; + ANSWER = 1; + } + SessionDescriptionType type = 1; + string content = 2; +} + +message IceCandidate { + string mid = 1; + int32 mline_index = 2; + string description = 3; +} \ No newline at end of file diff --git a/rtc_tools/data_channel_benchmark/signaling_interface.h b/rtc_tools/data_channel_benchmark/signaling_interface.h new file mode 100644 index 0000000000..77c811acb3 --- /dev/null +++ b/rtc_tools/data_channel_benchmark/signaling_interface.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2021 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ +#ifndef RTC_TOOLS_DATA_CHANNEL_BENCHMARK_SIGNALING_INTERFACE_H_ +#define RTC_TOOLS_DATA_CHANNEL_BENCHMARK_SIGNALING_INTERFACE_H_ + +#include + +#include "api/jsep.h" + +namespace webrtc { +class SignalingInterface { + public: + virtual ~SignalingInterface() = default; + + // Send an ICE candidate over the transport. + virtual void SendIceCandidate( + const webrtc::IceCandidateInterface* candidate) = 0; + + // Send a local description over the transport. + virtual void SendDescription( + const webrtc::SessionDescriptionInterface* sdp) = 0; + + // Set a callback when receiving a description from the transport. + virtual void OnRemoteDescription( + std::function + sdp)> callback) = 0; + + // Set a callback when receiving an ICE candidate from the transport. + virtual void OnIceCandidate( + std::function + candidate)> callback) = 0; +}; +} // namespace webrtc + +#endif // RTC_TOOLS_DATA_CHANNEL_BENCHMARK_SIGNALING_INTERFACE_H_ diff --git a/tools_webrtc/sanitizers/tsan_suppressions_webrtc.cc b/tools_webrtc/sanitizers/tsan_suppressions_webrtc.cc index 6cbdf0b469..ae42d53b5c 100644 --- a/tools_webrtc/sanitizers/tsan_suppressions_webrtc.cc +++ b/tools_webrtc/sanitizers/tsan_suppressions_webrtc.cc @@ -69,6 +69,9 @@ char kTSanDefaultSuppressions[] = // http://crbug.com/244856 "race:libpulsecommon*.so\n" + // https://crbug.com/1158622 + "race:absl::synchronization_internal::Waiter::Post\n" + // End of suppressions. ; // Please keep this semicolon. diff --git a/webrtc.gni b/webrtc.gni index b81f1605b2..c4a62fc548 100644 --- a/webrtc.gni +++ b/webrtc.gni @@ -308,6 +308,9 @@ declare_args() { # Enable the usrsctp backend for DataChannels and related unittests rtc_build_usrsctp = !build_with_mozilla && rtc_enable_sctp + + # Enable gRPC used for negotiation in multiprocess tests + rtc_enable_grpc = rtc_enable_protobuf && (is_linux || is_mac) } # Make it possible to provide custom locations for some libraries (move these From f6f664e5e3116abe0b311fbecd1a16d0ea2efc52 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Tue, 15 Mar 2022 09:01:26 -0700 Subject: [PATCH 181/847] Roll chromium_revision ce4e107fd5..c0b7c18ca9 (981033:981135) Change log: https://chromium.googlesource.com/chromium/src/+log/ce4e107fd5..c0b7c18ca9 Full diff: https://chromium.googlesource.com/chromium/src/+/ce4e107fd5..c0b7c18ca9 Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/e5f7e68061..546ae94695 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/7b0e5410ee..d668a36b27 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/06df922804..5ee4341ada * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/8399c3e77d..711c344fb2 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/11468451f0..6343081f79 * src/third_party/androidx: GSeF5aW_033IJ7WfJr-L0ydknZykCwvytFFCrJfLMNMC..o519o3phZFQGY6K0mO0EJ-xJQUoucapeX-jwNBAal5wC * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/0c2e8d34dd..b6444dc2e1 * src/third_party/harfbuzz-ng/src: https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git/+log/0acf466c44..965cf1d665 * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/bce4286eeb..bc7a9c2bb6 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/33bdf7567c..1564451c05 DEPS diff: https://chromium.googlesource.com/chromium/src/+/ce4e107fd5..c0b7c18ca9/DEPS No update to Clang. BUG=None Change-Id: I62d86ab0fcd2e3ec8c150ed73bbf2d586d0852ac Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255620 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36207} --- DEPS | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/DEPS b/DEPS index 99fb48d488..55ed6c1de9 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': 'ce4e107fd5278cd673b0b9afc9345814f335e2ba', + 'chromium_revision': 'c0b7c18ca9a9eca411be7b548c864c9e8b629790', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@e5f7e680619b8637c1c4cbb4826591e7cd926eee', + 'https://chromium.googlesource.com/chromium/src/base@546ae9469561eb2532f55697dd270c8d36aa0d25', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@7b0e5410ee10f5f31136eba2c08dbd61587c74fd', + 'https://chromium.googlesource.com/chromium/src/build@d668a36b27d5868dc9acaf9e4cbda9757c76f72f', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@113dd1badbcbffea108a8c95ac7c89c22bfd25f3', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@06df922804765f56355e2517a31a6b756d06cc12', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@5ee4341ada844cdf585a542781c5c5b2ff372e95', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@8399c3e77d6e79ba2407f74601ae5e1b0e5eba38', + 'https://chromium.googlesource.com/chromium/src/testing@711c344fb2138639c75bc2f7e32958677fabe274', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@11468451f03eba197df106c59391ad2ecee42096', + 'https://chromium.googlesource.com/chromium/src/third_party@6343081f79677ca4350dbc4d4f5347c1e58505dd', 'src/buildtools/linux64': { 'packages': [ @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@0c2e8d34dde04fedf933d3b39d803acfe01d7554', + 'https://chromium.googlesource.com/catapult.git@b6444dc2e1be456786afb31e1e1ba13e5d874aca', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -167,7 +167,7 @@ deps = { 'src/third_party/freetype/src': 'https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@1e2eb65048f75c64b68708efed6ce904c31f3b2f', 'src/third_party/harfbuzz-ng/src': - 'https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git@0acf466c44143de2e9b9cc0375cb25ec67cb132f', + 'https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git@965cf1d66589b0db60e75961cc58f5a65521078e', 'src/third_party/google_benchmark/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/benchmark.git@f730846b0a3c0dc0699978846fb14ffb2fad0bdc', }, @@ -231,7 +231,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@bce4286eebf41c7e7f6689684dea989c0b010fe1', + 'https://android.googlesource.com/platform/external/perfetto.git@bc7a9c2bb682f97e2c5666bf19ec0a742c26ae26', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -288,7 +288,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@33bdf7567c93c577cbdcf499e5c48b8b290b9cc5', + 'https://chromium.googlesource.com/chromium/src/tools@1564451c051bfaf826337a5f61c35a0c93a3cf53', 'src/third_party/accessibility_test_framework': { 'packages': [ @@ -376,7 +376,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/androidx', - 'version': 'GSeF5aW_033IJ7WfJr-L0ydknZykCwvytFFCrJfLMNMC', + 'version': 'o519o3phZFQGY6K0mO0EJ-xJQUoucapeX-jwNBAal5wC', }, ], 'condition': 'checkout_android', From bd809b8e09a8bc7c273a219b2688d39d6d1c134c Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Tue, 15 Mar 2022 13:01:35 -0700 Subject: [PATCH 182/847] Roll chromium_revision c0b7c18ca9..a44a1bcd45 (981135:981274) Change log: https://chromium.googlesource.com/chromium/src/+log/c0b7c18ca9..a44a1bcd45 Full diff: https://chromium.googlesource.com/chromium/src/+/c0b7c18ca9..a44a1bcd45 Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/546ae94695..7284a9ac1a * src/build: https://chromium.googlesource.com/chromium/src/build/+log/d668a36b27..ef5cf25679 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/5ee4341ada..6b27aacc86 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/711c344fb2..a0375550cd * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/6343081f79..7f76214f0c * src/third_party/androidx: o519o3phZFQGY6K0mO0EJ-xJQUoucapeX-jwNBAal5wC..4144ITIgXUisP3mBnV8td3mdaIKKku5UW_bQjgoP9r8C * src/third_party/grpc/src: https://chromium.googlesource.com/external/github.com/grpc/grpc.git/+log/f8a909e76f..2a0d6234cb * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/bc7a9c2bb6..c899a37e18 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/1564451c05..008bc17706 DEPS diff: https://chromium.googlesource.com/chromium/src/+/c0b7c18ca9..a44a1bcd45/DEPS No update to Clang. BUG=None Change-Id: I40bbc4465a14d1dd7e2a11d0d6b2f9eb2ba9e79d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255660 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36208} --- DEPS | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/DEPS b/DEPS index 55ed6c1de9..568c085ee5 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': 'c0b7c18ca9a9eca411be7b548c864c9e8b629790', + 'chromium_revision': 'a44a1bcd4585bbed68c8bc88a204b357a678c607', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@546ae9469561eb2532f55697dd270c8d36aa0d25', + 'https://chromium.googlesource.com/chromium/src/base@7284a9ac1a3fd0d399b1922bca160bdcd07dd691', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@d668a36b27d5868dc9acaf9e4cbda9757c76f72f', + 'https://chromium.googlesource.com/chromium/src/build@ef5cf2567940e0dbaffd7eb6b4e4622d1916b348', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@113dd1badbcbffea108a8c95ac7c89c22bfd25f3', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@5ee4341ada844cdf585a542781c5c5b2ff372e95', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@6b27aacc8604993720c73fc1638da83fb98fe9db', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@711c344fb2138639c75bc2f7e32958677fabe274', + 'https://chromium.googlesource.com/chromium/src/testing@a0375550cd576b891f2d76d67341c53f3acc62d3', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@6343081f79677ca4350dbc4d4f5347c1e58505dd', + 'https://chromium.googlesource.com/chromium/src/third_party@7f76214f0cee72fff81fd10f86da81ba1fe94cf2', 'src/buildtools/linux64': { 'packages': [ @@ -157,7 +157,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/grpc/src': { - 'url': 'https://chromium.googlesource.com/external/github.com/grpc/grpc.git@f8a909e76fcd947949502832a7ab8e2cba2b8e27', + 'url': 'https://chromium.googlesource.com/external/github.com/grpc/grpc.git@2a0d6234cb2ccebb265c035ffd09ecc9a347b4bf', }, # Used for embedded builds. CrOS & Linux use the system version. 'src/third_party/fontconfig/src': { @@ -231,7 +231,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@bc7a9c2bb682f97e2c5666bf19ec0a742c26ae26', + 'https://android.googlesource.com/platform/external/perfetto.git@c899a37e18fcc1e4f0fcac2b648e491ac2e6c18a', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -288,7 +288,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@1564451c051bfaf826337a5f61c35a0c93a3cf53', + 'https://chromium.googlesource.com/chromium/src/tools@008bc17706b7f369e25520c8b3c13bb4204a4205', 'src/third_party/accessibility_test_framework': { 'packages': [ @@ -376,7 +376,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/androidx', - 'version': 'o519o3phZFQGY6K0mO0EJ-xJQUoucapeX-jwNBAal5wC', + 'version': '4144ITIgXUisP3mBnV8td3mdaIKKku5UW_bQjgoP9r8C', }, ], 'condition': 'checkout_android', From efe522b09f7fe51071685152be2214e81e1ee7d3 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Tue, 15 Mar 2022 17:01:33 -0700 Subject: [PATCH 183/847] Roll chromium_revision a44a1bcd45..63b2e05a1a (981274:981396) Change log: https://chromium.googlesource.com/chromium/src/+log/a44a1bcd45..63b2e05a1a Full diff: https://chromium.googlesource.com/chromium/src/+/a44a1bcd45..63b2e05a1a Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/7284a9ac1a..e96356a862 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/ef5cf25679..3d9590754d * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/6b27aacc86..a1933158c9 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/a0375550cd..f9164cb1ab * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/7f76214f0c..4974f3c678 * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/79b4bab70c..b199f54926 * src/third_party/icu: https://chromium.googlesource.com/chromium/deps/icu.git/+log/1fa4e3959e..8a5b728e4f * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/c899a37e18..ed54518ee4 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/008bc17706..b3447eb129 DEPS diff: https://chromium.googlesource.com/chromium/src/+/a44a1bcd45..63b2e05a1a/DEPS No update to Clang. BUG=None Change-Id: I62ff8336b6fd09ac672b3e4ca22062a8018ada0b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255720 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36209} --- DEPS | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/DEPS b/DEPS index 568c085ee5..1c7f0b9ee7 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': 'a44a1bcd4585bbed68c8bc88a204b357a678c607', + 'chromium_revision': '63b2e05a1a0a0956f3c35178b0b02d025d20c757', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@7284a9ac1a3fd0d399b1922bca160bdcd07dd691', + 'https://chromium.googlesource.com/chromium/src/base@e96356a86288f7ad87cb94def2d955557ef7f1d3', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@ef5cf2567940e0dbaffd7eb6b4e4622d1916b348', + 'https://chromium.googlesource.com/chromium/src/build@3d9590754d5d23e62d15472c5baf6777ca59df20', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@113dd1badbcbffea108a8c95ac7c89c22bfd25f3', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@6b27aacc8604993720c73fc1638da83fb98fe9db', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@a1933158c9430a912583d0d280ff826d4bad4fd2', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@a0375550cd576b891f2d76d67341c53f3acc62d3', + 'https://chromium.googlesource.com/chromium/src/testing@f9164cb1abdcb775d4ef2f7a9f32472b21b66ea6', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@7f76214f0cee72fff81fd10f86da81ba1fe94cf2', + 'https://chromium.googlesource.com/chromium/src/third_party@4974f3c67840a9f42f8eb850a5798e2ba4a1a2bc', 'src/buildtools/linux64': { 'packages': [ @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@79b4bab70c8da5d2a3770d445648f053a66a96cc', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@b199f549263a02900faef8c8c3d581c580e837c3', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -187,7 +187,7 @@ deps = { 'src/third_party/googletest/src': 'https://chromium.googlesource.com/external/github.com/google/googletest.git@ae5e06dd35c6137d335331b0815cf1f60fd7e3c5', 'src/third_party/icu': { - 'url': 'https://chromium.googlesource.com/chromium/deps/icu.git@1fa4e3959ec6637182b7318ac1d382799454806d', + 'url': 'https://chromium.googlesource.com/chromium/deps/icu.git@8a5b728e4f43b0eabdb9ea450f956d67cfb22719', }, 'src/third_party/jdk': { 'packages': [ @@ -231,7 +231,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@c899a37e18fcc1e4f0fcac2b648e491ac2e6c18a', + 'https://android.googlesource.com/platform/external/perfetto.git@ed54518ee42cbdec9fb90a12c4b256f2c5f8d22e', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -288,7 +288,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@008bc17706b7f369e25520c8b3c13bb4204a4205', + 'https://chromium.googlesource.com/chromium/src/tools@b3447eb129a8d4e9710fc50fa01b8008780caa8b', 'src/third_party/accessibility_test_framework': { 'packages': [ From 7b0f5384620eaa89e760dfd87a4aa57f8b8fbcab Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Tue, 15 Mar 2022 21:05:23 -0700 Subject: [PATCH 184/847] Update WebRTC code version (2022-03-16T04:05:20). Bug: None Change-Id: Idbdabfb918758492bd471ed80aabc98713098fe4 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255721 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36210} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index 9cfda2a988..21b5073e5b 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 2022-03-15T04:05:24"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-03-16T04:05:20"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From 4f7a41de70d3f28cd669401441c2f2176ad074da Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Tue, 15 Mar 2022 23:02:53 -0700 Subject: [PATCH 185/847] Roll chromium_revision 63b2e05a1a..674598587a (981396:981504) Change log: https://chromium.googlesource.com/chromium/src/+log/63b2e05a1a..674598587a Full diff: https://chromium.googlesource.com/chromium/src/+/63b2e05a1a..674598587a Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/e96356a862..cff566f022 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/3d9590754d..25cfbb99b6 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/f9164cb1ab..3a3158679d * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/4974f3c678..3c07994980 * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/b6444dc2e1..b3fe2c1779 * src/third_party/googletest/src: https://chromium.googlesource.com/external/github.com/google/googletest.git/+log/ae5e06dd35..b007c54f29 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/b3447eb129..da243b94e8 DEPS diff: https://chromium.googlesource.com/chromium/src/+/63b2e05a1a..674598587a/DEPS No update to Clang. BUG=None Change-Id: I9fdabeead0c396701d4937e88281e3ef22f39457 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255722 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36211} --- DEPS | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/DEPS b/DEPS index 1c7f0b9ee7..1690b135eb 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': '63b2e05a1a0a0956f3c35178b0b02d025d20c757', + 'chromium_revision': '674598587ab3c360318fb5c696d87f941770b072', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@e96356a86288f7ad87cb94def2d955557ef7f1d3', + 'https://chromium.googlesource.com/chromium/src/base@cff566f02292a8fa818cc7cceff5df0f1528fc80', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@3d9590754d5d23e62d15472c5baf6777ca59df20', + 'https://chromium.googlesource.com/chromium/src/build@25cfbb99b680ee76320102c35488b5b737cac2c4', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@113dd1badbcbffea108a8c95ac7c89c22bfd25f3', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -38,9 +38,9 @@ deps = { 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@f9164cb1abdcb775d4ef2f7a9f32472b21b66ea6', + 'https://chromium.googlesource.com/chromium/src/testing@3a3158679d7f58d1c2d10de9c7c350d4971ce811', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@4974f3c67840a9f42f8eb850a5798e2ba4a1a2bc', + 'https://chromium.googlesource.com/chromium/src/third_party@3c0799498064c0d20e7a5f2ac36c92506a65b931', 'src/buildtools/linux64': { 'packages': [ @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@b6444dc2e1be456786afb31e1e1ba13e5d874aca', + 'https://chromium.googlesource.com/catapult.git@b3fe2c177912640bc676b332a2f41dc812ea5843', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -185,7 +185,7 @@ deps = { 'dep_type': 'cipd', }, 'src/third_party/googletest/src': - 'https://chromium.googlesource.com/external/github.com/google/googletest.git@ae5e06dd35c6137d335331b0815cf1f60fd7e3c5', + 'https://chromium.googlesource.com/external/github.com/google/googletest.git@b007c54f2944e193ac44fba1bc997cb65826a0b9', 'src/third_party/icu': { 'url': 'https://chromium.googlesource.com/chromium/deps/icu.git@8a5b728e4f43b0eabdb9ea450f956d67cfb22719', }, @@ -288,7 +288,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@b3447eb129a8d4e9710fc50fa01b8008780caa8b', + 'https://chromium.googlesource.com/chromium/src/tools@da243b94e839d8ecd6db9186ac891d4d54d21a76', 'src/third_party/accessibility_test_framework': { 'packages': [ From 160b37b70f7d38f2f8ce7fb156f1859e50f9953b Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Tue, 15 Mar 2022 16:52:50 -0700 Subject: [PATCH 186/847] Don't include clang package's libstdc++.so in sanitizer builds LLVM binaries no longer need libstdc++.so as of https://crrev.com/c/3513603. Change-Id: I00c18e3d24167a8edda1b0a25a9ef00c0c2bde52 Bug: chromium:1286289 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255641 Reviewed-by: Mirko Bonadei Reviewed-by: Harald Alvestrand Commit-Queue: Mirko Bonadei Cr-Commit-Position: refs/heads/main@{#36212} --- webrtc.gni | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/webrtc.gni b/webrtc.gni index c4a62fc548..86803cd966 100644 --- a/webrtc.gni +++ b/webrtc.gni @@ -522,16 +522,6 @@ template("rtc_test") { } } - if (using_sanitizer) { - if (is_linux) { - if (!defined(invoker.data)) { - data = [] - } - data += - [ "//third_party/llvm-build/Release+Asserts/lib/libstdc++.so.6" ] - } - } - # TODO(crbug.com/webrtc/13556): Adding the .app folder in the runtime_deps # shoulnd't be necessary. this code should be removed and the same solution # as Chromium should be used. From 6e2b9e2210d6a38d352617bb47959238268e7b7d Mon Sep 17 00:00:00 2001 From: Jonas Oreland Date: Tue, 15 Mar 2022 14:29:00 +0100 Subject: [PATCH 187/847] WebRTC-DeprecateGlobalFieldTrialString/Enabled/ - part 5/inf Add field trials to audio api. It is added as a pointer with nullptr as default. It is not (yet) used anywhere. Usage of field trials comes in subsequent patches. Bug: webrtc:10335 Change-Id: Icbe22d95c356a6fefde34590f11ea63f005ab09e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255521 Reviewed-by: Mirko Bonadei Reviewed-by: Harald Alvestrand Commit-Queue: Jonas Oreland Cr-Commit-Position: refs/heads/main@{#36213} --- api/audio_codecs/BUILD.gn | 1 + api/audio_codecs/L16/BUILD.gn | 2 ++ api/audio_codecs/L16/audio_decoder_L16.cc | 3 ++- api/audio_codecs/L16/audio_decoder_L16.h | 4 ++- api/audio_codecs/L16/audio_encoder_L16.cc | 3 ++- api/audio_codecs/L16/audio_encoder_L16.h | 4 ++- .../audio_decoder_factory_template.h | 25 ++++++++++++++----- .../audio_encoder_factory_template.h | 24 +++++++++++++----- .../builtin_audio_encoder_factory.cc | 6 +++-- api/audio_codecs/g711/BUILD.gn | 2 ++ api/audio_codecs/g711/audio_decoder_g711.cc | 3 ++- api/audio_codecs/g711/audio_decoder_g711.h | 4 ++- api/audio_codecs/g711/audio_encoder_g711.cc | 3 ++- api/audio_codecs/g711/audio_encoder_g711.h | 4 ++- api/audio_codecs/g722/BUILD.gn | 2 ++ api/audio_codecs/g722/audio_decoder_g722.cc | 3 ++- api/audio_codecs/g722/audio_decoder_g722.h | 4 ++- api/audio_codecs/g722/audio_encoder_g722.cc | 3 ++- api/audio_codecs/g722/audio_encoder_g722.h | 4 ++- api/audio_codecs/ilbc/BUILD.gn | 2 ++ api/audio_codecs/ilbc/audio_decoder_ilbc.cc | 3 ++- api/audio_codecs/ilbc/audio_decoder_ilbc.h | 4 ++- api/audio_codecs/ilbc/audio_encoder_ilbc.cc | 3 ++- api/audio_codecs/ilbc/audio_encoder_ilbc.h | 4 ++- api/audio_codecs/isac/BUILD.gn | 4 +++ .../isac/audio_decoder_isac_fix.cc | 3 ++- .../isac/audio_decoder_isac_fix.h | 4 ++- .../isac/audio_decoder_isac_float.cc | 3 ++- .../isac/audio_decoder_isac_float.h | 4 ++- .../isac/audio_encoder_isac_fix.cc | 3 ++- .../isac/audio_encoder_isac_fix.h | 4 ++- .../isac/audio_encoder_isac_float.cc | 3 ++- .../isac/audio_encoder_isac_float.h | 4 ++- api/audio_codecs/opus/BUILD.gn | 4 +++ .../opus/audio_decoder_multi_channel_opus.cc | 3 ++- .../opus/audio_decoder_multi_channel_opus.h | 4 ++- api/audio_codecs/opus/audio_decoder_opus.cc | 3 ++- api/audio_codecs/opus/audio_decoder_opus.h | 4 ++- .../opus/audio_encoder_multi_channel_opus.cc | 3 ++- .../opus/audio_encoder_multi_channel_opus.h | 4 ++- api/audio_codecs/opus/audio_encoder_opus.cc | 3 ++- api/audio_codecs/opus/audio_encoder_opus.h | 4 ++- .../opus_audio_encoder_factory.cc | 6 +++-- api/audio_codecs/test/BUILD.gn | 1 + ...audio_decoder_factory_template_unittest.cc | 5 +++- ...audio_encoder_factory_template_unittest.cc | 5 +++- modules/audio_coding/BUILD.gn | 1 + 47 files changed, 152 insertions(+), 50 deletions(-) diff --git a/api/audio_codecs/BUILD.gn b/api/audio_codecs/BUILD.gn index 5926f5ec2e..3c84af8d19 100644 --- a/api/audio_codecs/BUILD.gn +++ b/api/audio_codecs/BUILD.gn @@ -32,6 +32,7 @@ rtc_library("audio_codecs_api") { "..:array_view", "..:bitrate_allocation", "..:scoped_refptr", + "../../api:webrtc_key_value_config", "../../rtc_base:checks", "../../rtc_base:rtc_base_approved", "../../rtc_base:sanitizer", diff --git a/api/audio_codecs/L16/BUILD.gn b/api/audio_codecs/L16/BUILD.gn index 1f7a1e5a0b..9e4a0f1002 100644 --- a/api/audio_codecs/L16/BUILD.gn +++ b/api/audio_codecs/L16/BUILD.gn @@ -21,6 +21,7 @@ rtc_library("audio_encoder_L16") { ] deps = [ "..:audio_codecs_api", + "../../../api:webrtc_key_value_config", "../../../modules/audio_coding:pcm16b", "../../../rtc_base:rtc_base_approved", "../../../rtc_base:safe_minmax", @@ -41,6 +42,7 @@ rtc_library("audio_decoder_L16") { ] deps = [ "..:audio_codecs_api", + "../../../api:webrtc_key_value_config", "../../../modules/audio_coding:pcm16b", "../../../rtc_base:rtc_base_approved", "../../../rtc_base/system:rtc_export", diff --git a/api/audio_codecs/L16/audio_decoder_L16.cc b/api/audio_codecs/L16/audio_decoder_L16.cc index 93863f1020..874a8a5111 100644 --- a/api/audio_codecs/L16/audio_decoder_L16.cc +++ b/api/audio_codecs/L16/audio_decoder_L16.cc @@ -37,7 +37,8 @@ void AudioDecoderL16::AppendSupportedDecoders( std::unique_ptr AudioDecoderL16::MakeAudioDecoder( const Config& config, - absl::optional /*codec_pair_id*/) { + absl::optional /*codec_pair_id*/, + const WebRtcKeyValueConfig* field_trials) { if (!config.IsOk()) { return nullptr; } diff --git a/api/audio_codecs/L16/audio_decoder_L16.h b/api/audio_codecs/L16/audio_decoder_L16.h index 581a5b82c1..ade8f98088 100644 --- a/api/audio_codecs/L16/audio_decoder_L16.h +++ b/api/audio_codecs/L16/audio_decoder_L16.h @@ -18,6 +18,7 @@ #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_format.h" +#include "api/webrtc_key_value_config.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { @@ -39,7 +40,8 @@ struct RTC_EXPORT AudioDecoderL16 { static void AppendSupportedDecoders(std::vector* specs); static std::unique_ptr MakeAudioDecoder( const Config& config, - absl::optional codec_pair_id = absl::nullopt); + absl::optional codec_pair_id = absl::nullopt, + const WebRtcKeyValueConfig* field_trials = nullptr); }; } // namespace webrtc diff --git a/api/audio_codecs/L16/audio_encoder_L16.cc b/api/audio_codecs/L16/audio_encoder_L16.cc index 590d3e32d9..3994f5c20d 100644 --- a/api/audio_codecs/L16/audio_encoder_L16.cc +++ b/api/audio_codecs/L16/audio_encoder_L16.cc @@ -59,7 +59,8 @@ AudioCodecInfo AudioEncoderL16::QueryAudioEncoder( std::unique_ptr AudioEncoderL16::MakeAudioEncoder( const AudioEncoderL16::Config& config, int payload_type, - absl::optional /*codec_pair_id*/) { + absl::optional /*codec_pair_id*/, + const WebRtcKeyValueConfig* field_trials) { AudioEncoderPcm16B::Config c; c.sample_rate_hz = config.sample_rate_hz; c.num_channels = config.num_channels; diff --git a/api/audio_codecs/L16/audio_encoder_L16.h b/api/audio_codecs/L16/audio_encoder_L16.h index 25d221148e..e0916dfb24 100644 --- a/api/audio_codecs/L16/audio_encoder_L16.h +++ b/api/audio_codecs/L16/audio_encoder_L16.h @@ -18,6 +18,7 @@ #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_format.h" +#include "api/webrtc_key_value_config.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { @@ -44,7 +45,8 @@ struct RTC_EXPORT AudioEncoderL16 { static std::unique_ptr MakeAudioEncoder( const Config& config, int payload_type, - absl::optional codec_pair_id = absl::nullopt); + absl::optional codec_pair_id = absl::nullopt, + const WebRtcKeyValueConfig* field_trials = nullptr); }; } // namespace webrtc diff --git a/api/audio_codecs/audio_decoder_factory_template.h b/api/audio_codecs/audio_decoder_factory_template.h index 976f9c62d7..4badd825b1 100644 --- a/api/audio_codecs/audio_decoder_factory_template.h +++ b/api/audio_codecs/audio_decoder_factory_template.h @@ -16,6 +16,7 @@ #include "api/audio_codecs/audio_decoder_factory.h" #include "api/scoped_refptr.h" +#include "api/webrtc_key_value_config.h" #include "rtc_base/ref_counted_object.h" namespace webrtc { @@ -32,7 +33,8 @@ struct Helper<> { static bool IsSupportedDecoder(const SdpAudioFormat& format) { return false; } static std::unique_ptr MakeAudioDecoder( const SdpAudioFormat& format, - absl::optional codec_pair_id) { + absl::optional codec_pair_id, + const WebRtcKeyValueConfig* field_trials) { return nullptr; } }; @@ -55,16 +57,22 @@ struct Helper { } static std::unique_ptr MakeAudioDecoder( const SdpAudioFormat& format, - absl::optional codec_pair_id) { + absl::optional codec_pair_id, + const WebRtcKeyValueConfig* field_trials) { auto opt_config = T::SdpToConfig(format); return opt_config ? T::MakeAudioDecoder(*opt_config, codec_pair_id) - : Helper::MakeAudioDecoder(format, codec_pair_id); + : Helper::MakeAudioDecoder(format, codec_pair_id, + field_trials); } }; template class AudioDecoderFactoryT : public AudioDecoderFactory { public: + explicit AudioDecoderFactoryT(const WebRtcKeyValueConfig* field_trials) { + field_trials_ = field_trials; + } + std::vector GetSupportedDecoders() override { std::vector specs; Helper::AppendSupportedDecoders(&specs); @@ -78,8 +86,11 @@ class AudioDecoderFactoryT : public AudioDecoderFactory { std::unique_ptr MakeAudioDecoder( const SdpAudioFormat& format, absl::optional codec_pair_id) override { - return Helper::MakeAudioDecoder(format, codec_pair_id); + return Helper::MakeAudioDecoder(format, codec_pair_id, + field_trials_); } + + const WebRtcKeyValueConfig* field_trials_; }; } // namespace audio_decoder_factory_template_impl @@ -115,7 +126,8 @@ class AudioDecoderFactoryT : public AudioDecoderFactory { // TODO(kwiberg): Point at CreateBuiltinAudioDecoderFactory() for an example of // how it is used. template -rtc::scoped_refptr CreateAudioDecoderFactory() { +rtc::scoped_refptr CreateAudioDecoderFactory( + const WebRtcKeyValueConfig* field_trials = nullptr) { // There's no technical reason we couldn't allow zero template parameters, // but such a factory couldn't create any decoders, and callers can do this // by mistake by simply forgetting the <> altogether. So we forbid it in @@ -124,7 +136,8 @@ rtc::scoped_refptr CreateAudioDecoderFactory() { "Caller must give at least one template parameter"); return rtc::make_ref_counted< - audio_decoder_factory_template_impl::AudioDecoderFactoryT>(); + audio_decoder_factory_template_impl::AudioDecoderFactoryT>( + field_trials); } } // namespace webrtc diff --git a/api/audio_codecs/audio_encoder_factory_template.h b/api/audio_codecs/audio_encoder_factory_template.h index 4dc0672c46..ceefab2dd5 100644 --- a/api/audio_codecs/audio_encoder_factory_template.h +++ b/api/audio_codecs/audio_encoder_factory_template.h @@ -16,6 +16,7 @@ #include "api/audio_codecs/audio_encoder_factory.h" #include "api/scoped_refptr.h" +#include "api/webrtc_key_value_config.h" #include "rtc_base/ref_counted_object.h" namespace webrtc { @@ -36,7 +37,8 @@ struct Helper<> { static std::unique_ptr MakeAudioEncoder( int payload_type, const SdpAudioFormat& format, - absl::optional codec_pair_id) { + absl::optional codec_pair_id, + const WebRtcKeyValueConfig* field_trials) { return nullptr; } }; @@ -63,13 +65,14 @@ struct Helper { static std::unique_ptr MakeAudioEncoder( int payload_type, const SdpAudioFormat& format, - absl::optional codec_pair_id) { + absl::optional codec_pair_id, + const WebRtcKeyValueConfig* field_trials) { auto opt_config = T::SdpToConfig(format); if (opt_config) { return T::MakeAudioEncoder(*opt_config, payload_type, codec_pair_id); } else { return Helper::MakeAudioEncoder(payload_type, format, - codec_pair_id); + codec_pair_id, field_trials); } } }; @@ -77,6 +80,10 @@ struct Helper { template class AudioEncoderFactoryT : public AudioEncoderFactory { public: + explicit AudioEncoderFactoryT(const WebRtcKeyValueConfig* field_trials) { + field_trials_ = field_trials; + } + std::vector GetSupportedEncoders() override { std::vector specs; Helper::AppendSupportedEncoders(&specs); @@ -92,8 +99,11 @@ class AudioEncoderFactoryT : public AudioEncoderFactory { int payload_type, const SdpAudioFormat& format, absl::optional codec_pair_id) override { - return Helper::MakeAudioEncoder(payload_type, format, codec_pair_id); + return Helper::MakeAudioEncoder(payload_type, format, codec_pair_id, + field_trials_); } + + const WebRtcKeyValueConfig* field_trials_; }; } // namespace audio_encoder_factory_template_impl @@ -134,7 +144,8 @@ class AudioEncoderFactoryT : public AudioEncoderFactory { // TODO(kwiberg): Point at CreateBuiltinAudioEncoderFactory() for an example of // how it is used. template -rtc::scoped_refptr CreateAudioEncoderFactory() { +rtc::scoped_refptr CreateAudioEncoderFactory( + const WebRtcKeyValueConfig* field_trials = nullptr) { // There's no technical reason we couldn't allow zero template parameters, // but such a factory couldn't create any encoders, and callers can do this // by mistake by simply forgetting the <> altogether. So we forbid it in @@ -143,7 +154,8 @@ rtc::scoped_refptr CreateAudioEncoderFactory() { "Caller must give at least one template parameter"); return rtc::make_ref_counted< - audio_encoder_factory_template_impl::AudioEncoderFactoryT>(); + audio_encoder_factory_template_impl::AudioEncoderFactoryT>( + field_trials); } } // namespace webrtc diff --git a/api/audio_codecs/builtin_audio_encoder_factory.cc b/api/audio_codecs/builtin_audio_encoder_factory.cc index 99fac09a57..4433893c1b 100644 --- a/api/audio_codecs/builtin_audio_encoder_factory.cc +++ b/api/audio_codecs/builtin_audio_encoder_factory.cc @@ -47,8 +47,10 @@ struct NotAdvertised { static std::unique_ptr MakeAudioEncoder( const Config& config, int payload_type, - absl::optional codec_pair_id = absl::nullopt) { - return T::MakeAudioEncoder(config, payload_type, codec_pair_id); + absl::optional codec_pair_id = absl::nullopt, + const WebRtcKeyValueConfig* field_trials = nullptr) { + return T::MakeAudioEncoder(config, payload_type, codec_pair_id, + field_trials); } }; diff --git a/api/audio_codecs/g711/BUILD.gn b/api/audio_codecs/g711/BUILD.gn index 92d77bed9f..1f0b7dff7a 100644 --- a/api/audio_codecs/g711/BUILD.gn +++ b/api/audio_codecs/g711/BUILD.gn @@ -21,6 +21,7 @@ rtc_library("audio_encoder_g711") { ] deps = [ "..:audio_codecs_api", + "../../../api:webrtc_key_value_config", "../../../modules/audio_coding:g711", "../../../rtc_base:rtc_base_approved", "../../../rtc_base:safe_minmax", @@ -41,6 +42,7 @@ rtc_library("audio_decoder_g711") { ] deps = [ "..:audio_codecs_api", + "../../../api:webrtc_key_value_config", "../../../modules/audio_coding:g711", "../../../rtc_base:rtc_base_approved", "../../../rtc_base/system:rtc_export", diff --git a/api/audio_codecs/g711/audio_decoder_g711.cc b/api/audio_codecs/g711/audio_decoder_g711.cc index f3d3378cf2..b34b464ebd 100644 --- a/api/audio_codecs/g711/audio_decoder_g711.cc +++ b/api/audio_codecs/g711/audio_decoder_g711.cc @@ -47,7 +47,8 @@ void AudioDecoderG711::AppendSupportedDecoders( std::unique_ptr AudioDecoderG711::MakeAudioDecoder( const Config& config, - absl::optional /*codec_pair_id*/) { + absl::optional /*codec_pair_id*/, + const WebRtcKeyValueConfig* field_trials) { if (!config.IsOk()) { RTC_DCHECK_NOTREACHED(); return nullptr; diff --git a/api/audio_codecs/g711/audio_decoder_g711.h b/api/audio_codecs/g711/audio_decoder_g711.h index 18c15a8d60..62b0f880d5 100644 --- a/api/audio_codecs/g711/audio_decoder_g711.h +++ b/api/audio_codecs/g711/audio_decoder_g711.h @@ -18,6 +18,7 @@ #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_format.h" +#include "api/webrtc_key_value_config.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { @@ -39,7 +40,8 @@ struct RTC_EXPORT AudioDecoderG711 { static void AppendSupportedDecoders(std::vector* specs); static std::unique_ptr MakeAudioDecoder( const Config& config, - absl::optional codec_pair_id = absl::nullopt); + absl::optional codec_pair_id = absl::nullopt, + const WebRtcKeyValueConfig* field_trials = nullptr); }; } // namespace webrtc diff --git a/api/audio_codecs/g711/audio_encoder_g711.cc b/api/audio_codecs/g711/audio_encoder_g711.cc index 4c1ce0f8e6..8c60304c20 100644 --- a/api/audio_codecs/g711/audio_encoder_g711.cc +++ b/api/audio_codecs/g711/audio_encoder_g711.cc @@ -64,7 +64,8 @@ AudioCodecInfo AudioEncoderG711::QueryAudioEncoder(const Config& config) { std::unique_ptr AudioEncoderG711::MakeAudioEncoder( const Config& config, int payload_type, - absl::optional /*codec_pair_id*/) { + absl::optional /*codec_pair_id*/, + const WebRtcKeyValueConfig* field_trials) { if (!config.IsOk()) { RTC_DCHECK_NOTREACHED(); return nullptr; diff --git a/api/audio_codecs/g711/audio_encoder_g711.h b/api/audio_codecs/g711/audio_encoder_g711.h index 29fe38f1a0..c2750e26ec 100644 --- a/api/audio_codecs/g711/audio_encoder_g711.h +++ b/api/audio_codecs/g711/audio_encoder_g711.h @@ -18,6 +18,7 @@ #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_format.h" +#include "api/webrtc_key_value_config.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { @@ -44,7 +45,8 @@ struct RTC_EXPORT AudioEncoderG711 { static std::unique_ptr MakeAudioEncoder( const Config& config, int payload_type, - absl::optional codec_pair_id = absl::nullopt); + absl::optional codec_pair_id = absl::nullopt, + const WebRtcKeyValueConfig* field_trials = nullptr); }; } // namespace webrtc diff --git a/api/audio_codecs/g722/BUILD.gn b/api/audio_codecs/g722/BUILD.gn index a186eabbb7..fbce2c5e33 100644 --- a/api/audio_codecs/g722/BUILD.gn +++ b/api/audio_codecs/g722/BUILD.gn @@ -27,6 +27,7 @@ rtc_library("audio_encoder_g722") { deps = [ ":audio_encoder_g722_config", "..:audio_codecs_api", + "../../../api:webrtc_key_value_config", "../../../modules/audio_coding:g722", "../../../rtc_base:rtc_base_approved", "../../../rtc_base:safe_minmax", @@ -47,6 +48,7 @@ rtc_library("audio_decoder_g722") { ] deps = [ "..:audio_codecs_api", + "../../../api:webrtc_key_value_config", "../../../modules/audio_coding:g722", "../../../rtc_base:rtc_base_approved", "../../../rtc_base/system:rtc_export", diff --git a/api/audio_codecs/g722/audio_decoder_g722.cc b/api/audio_codecs/g722/audio_decoder_g722.cc index 0049e5ab32..8f3a5c0d28 100644 --- a/api/audio_codecs/g722/audio_decoder_g722.cc +++ b/api/audio_codecs/g722/audio_decoder_g722.cc @@ -36,7 +36,8 @@ void AudioDecoderG722::AppendSupportedDecoders( std::unique_ptr AudioDecoderG722::MakeAudioDecoder( Config config, - absl::optional /*codec_pair_id*/) { + absl::optional /*codec_pair_id*/, + const WebRtcKeyValueConfig* field_trials) { if (!config.IsOk()) { RTC_DCHECK_NOTREACHED(); return nullptr; diff --git a/api/audio_codecs/g722/audio_decoder_g722.h b/api/audio_codecs/g722/audio_decoder_g722.h index 2a674926db..05e613055a 100644 --- a/api/audio_codecs/g722/audio_decoder_g722.h +++ b/api/audio_codecs/g722/audio_decoder_g722.h @@ -18,6 +18,7 @@ #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_format.h" +#include "api/webrtc_key_value_config.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { @@ -33,7 +34,8 @@ struct RTC_EXPORT AudioDecoderG722 { static void AppendSupportedDecoders(std::vector* specs); static std::unique_ptr MakeAudioDecoder( Config config, - absl::optional codec_pair_id = absl::nullopt); + absl::optional codec_pair_id = absl::nullopt, + const WebRtcKeyValueConfig* field_trials = nullptr); }; } // namespace webrtc diff --git a/api/audio_codecs/g722/audio_encoder_g722.cc b/api/audio_codecs/g722/audio_encoder_g722.cc index 66cf9e19d6..812d66ffc9 100644 --- a/api/audio_codecs/g722/audio_encoder_g722.cc +++ b/api/audio_codecs/g722/audio_encoder_g722.cc @@ -62,7 +62,8 @@ AudioCodecInfo AudioEncoderG722::QueryAudioEncoder( std::unique_ptr AudioEncoderG722::MakeAudioEncoder( const AudioEncoderG722Config& config, int payload_type, - absl::optional /*codec_pair_id*/) { + absl::optional /*codec_pair_id*/, + const WebRtcKeyValueConfig* field_trials) { if (!config.IsOk()) { RTC_DCHECK_NOTREACHED(); return nullptr; diff --git a/api/audio_codecs/g722/audio_encoder_g722.h b/api/audio_codecs/g722/audio_encoder_g722.h index 327c0af04a..14ddff72bd 100644 --- a/api/audio_codecs/g722/audio_encoder_g722.h +++ b/api/audio_codecs/g722/audio_encoder_g722.h @@ -19,6 +19,7 @@ #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/g722/audio_encoder_g722_config.h" +#include "api/webrtc_key_value_config.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { @@ -34,7 +35,8 @@ struct RTC_EXPORT AudioEncoderG722 { static std::unique_ptr MakeAudioEncoder( const AudioEncoderG722Config& config, int payload_type, - absl::optional codec_pair_id = absl::nullopt); + absl::optional codec_pair_id = absl::nullopt, + const WebRtcKeyValueConfig* field_trials = nullptr); }; } // namespace webrtc diff --git a/api/audio_codecs/ilbc/BUILD.gn b/api/audio_codecs/ilbc/BUILD.gn index b6a5045eaf..1cac7ed7b9 100644 --- a/api/audio_codecs/ilbc/BUILD.gn +++ b/api/audio_codecs/ilbc/BUILD.gn @@ -27,6 +27,7 @@ rtc_library("audio_encoder_ilbc") { deps = [ ":audio_encoder_ilbc_config", "..:audio_codecs_api", + "../../../api:webrtc_key_value_config", "../../../modules/audio_coding:ilbc", "../../../rtc_base:rtc_base_approved", "../../../rtc_base:safe_minmax", @@ -46,6 +47,7 @@ rtc_library("audio_decoder_ilbc") { ] deps = [ "..:audio_codecs_api", + "../../../api:webrtc_key_value_config", "../../../modules/audio_coding:ilbc", "../../../rtc_base:rtc_base_approved", ] diff --git a/api/audio_codecs/ilbc/audio_decoder_ilbc.cc b/api/audio_codecs/ilbc/audio_decoder_ilbc.cc index 237cef23c1..9a291ee41d 100644 --- a/api/audio_codecs/ilbc/audio_decoder_ilbc.cc +++ b/api/audio_codecs/ilbc/audio_decoder_ilbc.cc @@ -34,7 +34,8 @@ void AudioDecoderIlbc::AppendSupportedDecoders( std::unique_ptr AudioDecoderIlbc::MakeAudioDecoder( Config config, - absl::optional /*codec_pair_id*/) { + absl::optional /*codec_pair_id*/, + const WebRtcKeyValueConfig* field_trials) { return std::make_unique(); } diff --git a/api/audio_codecs/ilbc/audio_decoder_ilbc.h b/api/audio_codecs/ilbc/audio_decoder_ilbc.h index 9ab847977d..4d9a4b7d6a 100644 --- a/api/audio_codecs/ilbc/audio_decoder_ilbc.h +++ b/api/audio_codecs/ilbc/audio_decoder_ilbc.h @@ -18,6 +18,7 @@ #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_format.h" +#include "api/webrtc_key_value_config.h" namespace webrtc { @@ -29,7 +30,8 @@ struct AudioDecoderIlbc { static void AppendSupportedDecoders(std::vector* specs); static std::unique_ptr MakeAudioDecoder( Config config, - absl::optional codec_pair_id = absl::nullopt); + absl::optional codec_pair_id = absl::nullopt, + const WebRtcKeyValueConfig* field_trials = nullptr); }; } // namespace webrtc diff --git a/api/audio_codecs/ilbc/audio_encoder_ilbc.cc b/api/audio_codecs/ilbc/audio_encoder_ilbc.cc index 52ba8f6b88..6525887eab 100644 --- a/api/audio_codecs/ilbc/audio_encoder_ilbc.cc +++ b/api/audio_codecs/ilbc/audio_encoder_ilbc.cc @@ -76,7 +76,8 @@ AudioCodecInfo AudioEncoderIlbc::QueryAudioEncoder( std::unique_ptr AudioEncoderIlbc::MakeAudioEncoder( const AudioEncoderIlbcConfig& config, int payload_type, - absl::optional /*codec_pair_id*/) { + absl::optional /*codec_pair_id*/, + const WebRtcKeyValueConfig* field_trials) { if (!config.IsOk()) { RTC_DCHECK_NOTREACHED(); return nullptr; diff --git a/api/audio_codecs/ilbc/audio_encoder_ilbc.h b/api/audio_codecs/ilbc/audio_encoder_ilbc.h index e4aeca70de..8dd4928558 100644 --- a/api/audio_codecs/ilbc/audio_encoder_ilbc.h +++ b/api/audio_codecs/ilbc/audio_encoder_ilbc.h @@ -19,6 +19,7 @@ #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/ilbc/audio_encoder_ilbc_config.h" +#include "api/webrtc_key_value_config.h" namespace webrtc { @@ -33,7 +34,8 @@ struct AudioEncoderIlbc { static std::unique_ptr MakeAudioEncoder( const AudioEncoderIlbcConfig& config, int payload_type, - absl::optional codec_pair_id = absl::nullopt); + absl::optional codec_pair_id = absl::nullopt, + const WebRtcKeyValueConfig* field_trials = nullptr); }; } // namespace webrtc diff --git a/api/audio_codecs/isac/BUILD.gn b/api/audio_codecs/isac/BUILD.gn index 6ff6e5f092..b6aa810fb5 100644 --- a/api/audio_codecs/isac/BUILD.gn +++ b/api/audio_codecs/isac/BUILD.gn @@ -65,6 +65,7 @@ rtc_library("audio_encoder_isac_fix") { ] deps = [ "..:audio_codecs_api", + "../../../api:webrtc_key_value_config", "../../../modules/audio_coding:isac_fix", "../../../rtc_base:rtc_base_approved", "../../../rtc_base/system:rtc_export", @@ -84,6 +85,7 @@ rtc_library("audio_decoder_isac_fix") { ] deps = [ "..:audio_codecs_api", + "../../../api:webrtc_key_value_config", "../../../modules/audio_coding:isac_fix", "../../../rtc_base:rtc_base_approved", "../../../rtc_base/system:rtc_export", @@ -103,6 +105,7 @@ rtc_library("audio_encoder_isac_float") { ] deps = [ "..:audio_codecs_api", + "../../../api:webrtc_key_value_config", "../../../modules/audio_coding:isac", "../../../rtc_base:rtc_base_approved", "../../../rtc_base/system:rtc_export", @@ -122,6 +125,7 @@ rtc_library("audio_decoder_isac_float") { ] deps = [ "..:audio_codecs_api", + "../../../api:webrtc_key_value_config", "../../../modules/audio_coding:isac", "../../../rtc_base:rtc_base_approved", "../../../rtc_base/system:rtc_export", diff --git a/api/audio_codecs/isac/audio_decoder_isac_fix.cc b/api/audio_codecs/isac/audio_decoder_isac_fix.cc index 305e15a525..8927a164b0 100644 --- a/api/audio_codecs/isac/audio_decoder_isac_fix.cc +++ b/api/audio_codecs/isac/audio_decoder_isac_fix.cc @@ -33,7 +33,8 @@ void AudioDecoderIsacFix::AppendSupportedDecoders( std::unique_ptr AudioDecoderIsacFix::MakeAudioDecoder( Config config, - absl::optional /*codec_pair_id*/) { + absl::optional /*codec_pair_id*/, + const WebRtcKeyValueConfig* field_trials) { AudioDecoderIsacFixImpl::Config c; c.sample_rate_hz = 16000; return std::make_unique(c); diff --git a/api/audio_codecs/isac/audio_decoder_isac_fix.h b/api/audio_codecs/isac/audio_decoder_isac_fix.h index 200914adfe..11b87669c9 100644 --- a/api/audio_codecs/isac/audio_decoder_isac_fix.h +++ b/api/audio_codecs/isac/audio_decoder_isac_fix.h @@ -18,6 +18,7 @@ #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_format.h" +#include "api/webrtc_key_value_config.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { @@ -30,7 +31,8 @@ struct RTC_EXPORT AudioDecoderIsacFix { static void AppendSupportedDecoders(std::vector* specs); static std::unique_ptr MakeAudioDecoder( Config config, - absl::optional codec_pair_id = absl::nullopt); + absl::optional codec_pair_id = absl::nullopt, + const WebRtcKeyValueConfig* field_trials = nullptr); }; } // namespace webrtc diff --git a/api/audio_codecs/isac/audio_decoder_isac_float.cc b/api/audio_codecs/isac/audio_decoder_isac_float.cc index 683eb6c0ad..ef27293117 100644 --- a/api/audio_codecs/isac/audio_decoder_isac_float.cc +++ b/api/audio_codecs/isac/audio_decoder_isac_float.cc @@ -42,7 +42,8 @@ void AudioDecoderIsacFloat::AppendSupportedDecoders( std::unique_ptr AudioDecoderIsacFloat::MakeAudioDecoder( Config config, - absl::optional /*codec_pair_id*/) { + absl::optional /*codec_pair_id*/, + const WebRtcKeyValueConfig* field_trials) { AudioDecoderIsacFloatImpl::Config c; c.sample_rate_hz = config.sample_rate_hz; if (!config.IsOk()) { diff --git a/api/audio_codecs/isac/audio_decoder_isac_float.h b/api/audio_codecs/isac/audio_decoder_isac_float.h index e78f8b81ee..501edfcab9 100644 --- a/api/audio_codecs/isac/audio_decoder_isac_float.h +++ b/api/audio_codecs/isac/audio_decoder_isac_float.h @@ -18,6 +18,7 @@ #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_format.h" +#include "api/webrtc_key_value_config.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { @@ -35,7 +36,8 @@ struct RTC_EXPORT AudioDecoderIsacFloat { static void AppendSupportedDecoders(std::vector* specs); static std::unique_ptr MakeAudioDecoder( Config config, - absl::optional codec_pair_id = absl::nullopt); + absl::optional codec_pair_id = absl::nullopt, + const WebRtcKeyValueConfig* field_trials = nullptr); }; } // namespace webrtc diff --git a/api/audio_codecs/isac/audio_encoder_isac_fix.cc b/api/audio_codecs/isac/audio_encoder_isac_fix.cc index b590be1ea3..65a2d8f391 100644 --- a/api/audio_codecs/isac/audio_encoder_isac_fix.cc +++ b/api/audio_codecs/isac/audio_encoder_isac_fix.cc @@ -56,7 +56,8 @@ AudioCodecInfo AudioEncoderIsacFix::QueryAudioEncoder( std::unique_ptr AudioEncoderIsacFix::MakeAudioEncoder( AudioEncoderIsacFix::Config config, int payload_type, - absl::optional /*codec_pair_id*/) { + absl::optional /*codec_pair_id*/, + const WebRtcKeyValueConfig* field_trials) { AudioEncoderIsacFixImpl::Config c; c.frame_size_ms = config.frame_size_ms; c.bit_rate = config.bit_rate; diff --git a/api/audio_codecs/isac/audio_encoder_isac_fix.h b/api/audio_codecs/isac/audio_encoder_isac_fix.h index e50d9f5112..e8ff0fc57b 100644 --- a/api/audio_codecs/isac/audio_encoder_isac_fix.h +++ b/api/audio_codecs/isac/audio_encoder_isac_fix.h @@ -18,6 +18,7 @@ #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_format.h" +#include "api/webrtc_key_value_config.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { @@ -44,7 +45,8 @@ struct RTC_EXPORT AudioEncoderIsacFix { static std::unique_ptr MakeAudioEncoder( Config config, int payload_type, - absl::optional codec_pair_id = absl::nullopt); + absl::optional codec_pair_id = absl::nullopt, + const WebRtcKeyValueConfig* field_trials = nullptr); }; } // namespace webrtc diff --git a/api/audio_codecs/isac/audio_encoder_isac_float.cc b/api/audio_codecs/isac/audio_encoder_isac_float.cc index e2afeae84e..852cb69c9d 100644 --- a/api/audio_codecs/isac/audio_encoder_isac_float.cc +++ b/api/audio_codecs/isac/audio_encoder_isac_float.cc @@ -68,7 +68,8 @@ AudioCodecInfo AudioEncoderIsacFloat::QueryAudioEncoder( std::unique_ptr AudioEncoderIsacFloat::MakeAudioEncoder( const AudioEncoderIsacFloat::Config& config, int payload_type, - absl::optional /*codec_pair_id*/) { + absl::optional /*codec_pair_id*/, + const WebRtcKeyValueConfig* field_trials) { AudioEncoderIsacFloatImpl::Config c; c.payload_type = payload_type; c.sample_rate_hz = config.sample_rate_hz; diff --git a/api/audio_codecs/isac/audio_encoder_isac_float.h b/api/audio_codecs/isac/audio_encoder_isac_float.h index 0cb9c17d71..8e1d505c31 100644 --- a/api/audio_codecs/isac/audio_encoder_isac_float.h +++ b/api/audio_codecs/isac/audio_encoder_isac_float.h @@ -18,6 +18,7 @@ #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_format.h" +#include "api/webrtc_key_value_config.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { @@ -58,7 +59,8 @@ struct RTC_EXPORT AudioEncoderIsacFloat { static std::unique_ptr MakeAudioEncoder( const Config& config, int payload_type, - absl::optional codec_pair_id = absl::nullopt); + absl::optional codec_pair_id = absl::nullopt, + const WebRtcKeyValueConfig* field_trials = nullptr); }; } // namespace webrtc diff --git a/api/audio_codecs/opus/BUILD.gn b/api/audio_codecs/opus/BUILD.gn index 586e9b3dd8..fbb116b88a 100644 --- a/api/audio_codecs/opus/BUILD.gn +++ b/api/audio_codecs/opus/BUILD.gn @@ -46,6 +46,7 @@ rtc_library("audio_encoder_opus") { deps = [ ":audio_encoder_opus_config", "..:audio_codecs_api", + "../../../api:webrtc_key_value_config", "../../../modules/audio_coding:webrtc_opus", "../../../rtc_base:rtc_base_approved", "../../../rtc_base/system:rtc_export", @@ -65,6 +66,7 @@ rtc_library("audio_decoder_opus") { ] deps = [ "..:audio_codecs_api", + "../../../api:webrtc_key_value_config", "../../../modules/audio_coding:webrtc_opus", "../../../rtc_base:rtc_base_approved", "../../../rtc_base/system:rtc_export", @@ -82,6 +84,7 @@ rtc_library("audio_encoder_multiopus") { sources = [ "audio_encoder_multi_channel_opus.cc" ] deps = [ "..:audio_codecs_api", + "../../../api:webrtc_key_value_config", "../../../modules/audio_coding:webrtc_multiopus", "../../../rtc_base:rtc_base_approved", "../../../rtc_base/system:rtc_export", @@ -100,6 +103,7 @@ rtc_library("audio_decoder_multiopus") { deps = [ ":audio_decoder_opus_config", "..:audio_codecs_api", + "../../../api:webrtc_key_value_config", "../../../modules/audio_coding:webrtc_multiopus", "../../../rtc_base:rtc_base_approved", "../../../rtc_base/system:rtc_export", diff --git a/api/audio_codecs/opus/audio_decoder_multi_channel_opus.cc b/api/audio_codecs/opus/audio_decoder_multi_channel_opus.cc index 6ba2b6d9d3..5a0b794430 100644 --- a/api/audio_codecs/opus/audio_decoder_multi_channel_opus.cc +++ b/api/audio_codecs/opus/audio_decoder_multi_channel_opus.cc @@ -64,7 +64,8 @@ void AudioDecoderMultiChannelOpus::AppendSupportedDecoders( std::unique_ptr AudioDecoderMultiChannelOpus::MakeAudioDecoder( AudioDecoderMultiChannelOpusConfig config, - absl::optional /*codec_pair_id*/) { + absl::optional /*codec_pair_id*/, + const WebRtcKeyValueConfig* field_trials) { return AudioDecoderMultiChannelOpusImpl::MakeAudioDecoder(config); } } // namespace webrtc diff --git a/api/audio_codecs/opus/audio_decoder_multi_channel_opus.h b/api/audio_codecs/opus/audio_decoder_multi_channel_opus.h index b5ca0fe41b..2dcd26b102 100644 --- a/api/audio_codecs/opus/audio_decoder_multi_channel_opus.h +++ b/api/audio_codecs/opus/audio_decoder_multi_channel_opus.h @@ -19,6 +19,7 @@ #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/opus/audio_decoder_multi_channel_opus_config.h" +#include "api/webrtc_key_value_config.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { @@ -32,7 +33,8 @@ struct RTC_EXPORT AudioDecoderMultiChannelOpus { static void AppendSupportedDecoders(std::vector* specs); static std::unique_ptr MakeAudioDecoder( AudioDecoderMultiChannelOpusConfig config, - absl::optional codec_pair_id = absl::nullopt); + absl::optional codec_pair_id = absl::nullopt, + const WebRtcKeyValueConfig* field_trials = nullptr); }; } // namespace webrtc diff --git a/api/audio_codecs/opus/audio_decoder_opus.cc b/api/audio_codecs/opus/audio_decoder_opus.cc index 7e0d88b7ad..0fe3367a64 100644 --- a/api/audio_codecs/opus/audio_decoder_opus.cc +++ b/api/audio_codecs/opus/audio_decoder_opus.cc @@ -73,7 +73,8 @@ void AudioDecoderOpus::AppendSupportedDecoders( std::unique_ptr AudioDecoderOpus::MakeAudioDecoder( Config config, - absl::optional /*codec_pair_id*/) { + absl::optional /*codec_pair_id*/, + const WebRtcKeyValueConfig* field_trials) { if (!config.IsOk()) { RTC_DCHECK_NOTREACHED(); return nullptr; diff --git a/api/audio_codecs/opus/audio_decoder_opus.h b/api/audio_codecs/opus/audio_decoder_opus.h index ec0f61d5bb..4e44309c24 100644 --- a/api/audio_codecs/opus/audio_decoder_opus.h +++ b/api/audio_codecs/opus/audio_decoder_opus.h @@ -18,6 +18,7 @@ #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_codecs/audio_decoder.h" #include "api/audio_codecs/audio_format.h" +#include "api/webrtc_key_value_config.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { @@ -34,7 +35,8 @@ struct RTC_EXPORT AudioDecoderOpus { static void AppendSupportedDecoders(std::vector* specs); static std::unique_ptr MakeAudioDecoder( Config config, - absl::optional codec_pair_id = absl::nullopt); + absl::optional codec_pair_id = absl::nullopt, + const WebRtcKeyValueConfig* field_trials = nullptr); }; } // namespace webrtc diff --git a/api/audio_codecs/opus/audio_encoder_multi_channel_opus.cc b/api/audio_codecs/opus/audio_encoder_multi_channel_opus.cc index 758eaaeebe..b71a0003fd 100644 --- a/api/audio_codecs/opus/audio_encoder_multi_channel_opus.cc +++ b/api/audio_codecs/opus/audio_encoder_multi_channel_opus.cc @@ -66,7 +66,8 @@ AudioCodecInfo AudioEncoderMultiChannelOpus::QueryAudioEncoder( std::unique_ptr AudioEncoderMultiChannelOpus::MakeAudioEncoder( const AudioEncoderMultiChannelOpusConfig& config, int payload_type, - absl::optional /*codec_pair_id*/) { + absl::optional /*codec_pair_id*/, + const WebRtcKeyValueConfig* field_trials) { return AudioEncoderMultiChannelOpusImpl::MakeAudioEncoder(config, payload_type); } diff --git a/api/audio_codecs/opus/audio_encoder_multi_channel_opus.h b/api/audio_codecs/opus/audio_encoder_multi_channel_opus.h index 977a3a4b9c..58b959a9b8 100644 --- a/api/audio_codecs/opus/audio_encoder_multi_channel_opus.h +++ b/api/audio_codecs/opus/audio_encoder_multi_channel_opus.h @@ -19,6 +19,7 @@ #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/opus/audio_encoder_multi_channel_opus_config.h" +#include "api/webrtc_key_value_config.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { @@ -33,7 +34,8 @@ struct RTC_EXPORT AudioEncoderMultiChannelOpus { static std::unique_ptr MakeAudioEncoder( const Config& config, int payload_type, - absl::optional codec_pair_id = absl::nullopt); + absl::optional codec_pair_id = absl::nullopt, + const WebRtcKeyValueConfig* field_trials = nullptr); }; } // namespace webrtc diff --git a/api/audio_codecs/opus/audio_encoder_opus.cc b/api/audio_codecs/opus/audio_encoder_opus.cc index 6d950c5e74..26fe8cc786 100644 --- a/api/audio_codecs/opus/audio_encoder_opus.cc +++ b/api/audio_codecs/opus/audio_encoder_opus.cc @@ -32,7 +32,8 @@ AudioCodecInfo AudioEncoderOpus::QueryAudioEncoder( std::unique_ptr AudioEncoderOpus::MakeAudioEncoder( const AudioEncoderOpusConfig& config, int payload_type, - absl::optional /*codec_pair_id*/) { + absl::optional /*codec_pair_id*/, + const WebRtcKeyValueConfig* field_trials) { if (!config.IsOk()) { RTC_DCHECK_NOTREACHED(); return nullptr; diff --git a/api/audio_codecs/opus/audio_encoder_opus.h b/api/audio_codecs/opus/audio_encoder_opus.h index 03cb0d6b38..4fb0337490 100644 --- a/api/audio_codecs/opus/audio_encoder_opus.h +++ b/api/audio_codecs/opus/audio_encoder_opus.h @@ -19,6 +19,7 @@ #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/opus/audio_encoder_opus_config.h" +#include "api/webrtc_key_value_config.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { @@ -34,7 +35,8 @@ struct RTC_EXPORT AudioEncoderOpus { static std::unique_ptr MakeAudioEncoder( const AudioEncoderOpusConfig& config, int payload_type, - absl::optional codec_pair_id = absl::nullopt); + absl::optional codec_pair_id = absl::nullopt, + const WebRtcKeyValueConfig* field_trials = nullptr); }; } // namespace webrtc diff --git a/api/audio_codecs/opus_audio_encoder_factory.cc b/api/audio_codecs/opus_audio_encoder_factory.cc index 5f0c7147f5..867d200e5f 100644 --- a/api/audio_codecs/opus_audio_encoder_factory.cc +++ b/api/audio_codecs/opus_audio_encoder_factory.cc @@ -37,8 +37,10 @@ struct NotAdvertised { static std::unique_ptr MakeAudioEncoder( const Config& config, int payload_type, - absl::optional codec_pair_id = absl::nullopt) { - return T::MakeAudioEncoder(config, payload_type, codec_pair_id); + absl::optional codec_pair_id = absl::nullopt, + const WebRtcKeyValueConfig* field_trials = nullptr) { + return T::MakeAudioEncoder(config, payload_type, codec_pair_id, + field_trials); } }; diff --git a/api/audio_codecs/test/BUILD.gn b/api/audio_codecs/test/BUILD.gn index 575f062ce7..dabcc3da8d 100644 --- a/api/audio_codecs/test/BUILD.gn +++ b/api/audio_codecs/test/BUILD.gn @@ -23,6 +23,7 @@ if (rtc_include_tests) { "..:audio_codecs_api", "../../../rtc_base:rtc_base_approved", "../../../test:audio_codec_mocks", + "../../../test:scoped_key_value_config", "../../../test:test_support", "../L16:audio_decoder_L16", "../L16:audio_encoder_L16", diff --git a/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc b/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc index 464ecfd487..3662f3b76d 100644 --- a/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc +++ b/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc @@ -22,6 +22,7 @@ #include "test/gmock.h" #include "test/gtest.h" #include "test/mock_audio_decoder.h" +#include "test/scoped_key_value_config.h" namespace webrtc { @@ -77,9 +78,11 @@ struct AudioDecoderFakeApi { } // namespace TEST(AudioDecoderFactoryTemplateTest, NoDecoderTypes) { + test::ScopedKeyValueConfig field_trials; rtc::scoped_refptr factory( rtc::make_ref_counted< - audio_decoder_factory_template_impl::AudioDecoderFactoryT<>>()); + audio_decoder_factory_template_impl::AudioDecoderFactoryT<>>( + &field_trials)); EXPECT_THAT(factory->GetSupportedDecoders(), ::testing::IsEmpty()); EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1})); EXPECT_EQ(nullptr, diff --git a/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc b/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc index 110f9930bd..67b6883583 100644 --- a/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc +++ b/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc @@ -22,6 +22,7 @@ #include "test/gmock.h" #include "test/gtest.h" #include "test/mock_audio_encoder.h" +#include "test/scoped_key_value_config.h" namespace webrtc { @@ -77,9 +78,11 @@ struct AudioEncoderFakeApi { } // namespace TEST(AudioEncoderFactoryTemplateTest, NoEncoderTypes) { + test::ScopedKeyValueConfig field_trials; rtc::scoped_refptr factory( rtc::make_ref_counted< - audio_encoder_factory_template_impl::AudioEncoderFactoryT<>>()); + audio_encoder_factory_template_impl::AudioEncoderFactoryT<>>( + &field_trials)); EXPECT_THAT(factory->GetSupportedEncoders(), ::testing::IsEmpty()); EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"foo", 8000, 1})); EXPECT_EQ(nullptr, diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn index 0d5e429d42..c4814ce1f8 100644 --- a/modules/audio_coding/BUILD.gn +++ b/modules/audio_coding/BUILD.gn @@ -1396,6 +1396,7 @@ if (rtc_include_tests) { "../../rtc_base:rtc_base_approved", "../../rtc_base/synchronization:mutex", "../../test:fileutils", + "../../test:scoped_key_value_config", "../../test:test_support", ] absl_deps = [ From 43a69b3f46059b103c35079744dc09a0e2bb2948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Bostr=C3=B6m?= Date: Wed, 16 Mar 2022 10:16:29 +0100 Subject: [PATCH 188/847] Experimentally reduce TaskQueuePacedSender's delayed task precision. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL reduces the delayed task precision of non-probes in accordance with DD go/slacked-task-queue-paced-sender. The precision is only deduced if field trial "WebRTC-SlackedTaskQueuePacedSender" is enabled though. Bug: webrtc:13824 Change-Id: I37e53b24e343f4f08059be08a3cda74f5484cc05 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255341 Reviewed-by: Erik Språng Commit-Queue: Henrik Boström Cr-Commit-Position: refs/heads/main@{#36214} --- modules/pacing/BUILD.gn | 3 + modules/pacing/task_queue_paced_sender.cc | 26 ++- modules/pacing/task_queue_paced_sender.h | 11 ++ .../task_queue_paced_sender_unittest.cc | 174 ++++++++++++++++++ 4 files changed, 211 insertions(+), 3 deletions(-) diff --git a/modules/pacing/BUILD.gn b/modules/pacing/BUILD.gn index 4064c12151..90e0eb7134 100644 --- a/modules/pacing/BUILD.gn +++ b/modules/pacing/BUILD.gn @@ -35,6 +35,7 @@ rtc_library("pacing") { "..:module_api", "../../api:function_view", "../../api:sequence_checker", + "../../api:webrtc_key_value_config", "../../api/rtc_event_log", "../../api/task_queue:task_queue", "../../api/transport:field_trial_based_config", @@ -93,6 +94,7 @@ if (rtc_include_tests) { deps = [ ":interval_budget", ":pacing", + "../../api/task_queue:task_queue", "../../api/transport:network_control", "../../api/units:data_rate", "../../api/units:time_delta", @@ -101,6 +103,7 @@ if (rtc_include_tests) { "../../rtc_base:rtc_base_approved", "../../rtc_base:rtc_base_tests_utils", "../../rtc_base/experiments:alr_experiment", + "../../rtc_base/task_utils:to_queued_task", "../../system_wrappers", "../../test:explicit_key_value_config", "../../test:scoped_key_value_config", diff --git a/modules/pacing/task_queue_paced_sender.cc b/modules/pacing/task_queue_paced_sender.cc index 620a54135e..fb3d3cab00 100644 --- a/modules/pacing/task_queue_paced_sender.cc +++ b/modules/pacing/task_queue_paced_sender.cc @@ -12,6 +12,7 @@ #include #include + #include "absl/memory/memory.h" #include "rtc_base/checks.h" #include "rtc_base/event.h" @@ -21,6 +22,13 @@ namespace webrtc { +namespace { + +constexpr const char* kSlackedTaskQueuePacedSenderFieldTrial = + "WebRTC-SlackedTaskQueuePacedSender"; + +} // namespace + TaskQueuePacedSender::TaskQueuePacedSender( Clock* clock, PacingController::PacketSender* packet_sender, @@ -46,8 +54,13 @@ TaskQueuePacedSender::TaskQueuePacedSender( TimeDelta max_hold_back_window, int max_hold_back_window_in_packets) : clock_(clock), - max_hold_back_window_(max_hold_back_window), - max_hold_back_window_in_packets_(max_hold_back_window_in_packets), + allow_low_precision_( + field_trials.IsEnabled(kSlackedTaskQueuePacedSenderFieldTrial)), + max_hold_back_window_(allow_low_precision_ + ? PacingController::kMinSleepTime + : max_hold_back_window), + max_hold_back_window_in_packets_( + allow_low_precision_ ? 0 : max_hold_back_window_in_packets), pacing_controller_(clock, packet_sender, event_log, @@ -287,7 +300,14 @@ void TaskQueuePacedSender::MaybeProcessPackets( // Set a new scheduled process time and post a delayed task. next_process_time_ = next_process_time; - task_queue_.PostDelayedHighPrecisionTask( + // Prefer low precision if allowed and not probing. + TaskQueueBase::DelayPrecision precision = + allow_low_precision_ && !pacing_controller_.IsProbing() + ? TaskQueueBase::DelayPrecision::kLow + : TaskQueueBase::DelayPrecision::kHigh; + + task_queue_.PostDelayedTaskWithPrecision( + precision, [this, next_process_time]() { MaybeProcessPackets(next_process_time); }, time_to_next_process->ms()); } diff --git a/modules/pacing/task_queue_paced_sender.h b/modules/pacing/task_queue_paced_sender.h index 61a625521d..61f4d20eb8 100644 --- a/modules/pacing/task_queue_paced_sender.h +++ b/modules/pacing/task_queue_paced_sender.h @@ -26,6 +26,7 @@ #include "api/units/data_size.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" +#include "api/webrtc_key_value_config.h" #include "modules/pacing/pacing_controller.h" #include "modules/pacing/rtp_packet_pacer.h" #include "modules/rtp_rtcp/source/rtp_packet_to_send.h" @@ -144,6 +145,16 @@ class TaskQueuePacedSender : public RtpPacketPacer, public RtpPacketSender { Stats GetStats() const; Clock* const clock_; + // If `kSlackedTaskQueuePacedSenderFieldTrial` is enabled, delayed tasks + // invoking MaybeProcessPackets() are scheduled using low precision instead of + // high precision, resulting in less idle wake ups and packets being sent in + // bursts if the `task_queue_` implementation supports slack. + // + // When probing, high precision is used regardless of `allow_low_precision_` + // to ensure good bandwidth estimation. + const bool allow_low_precision_; + // The holdback window prevents too frequent delayed MaybeProcessPackets() + // calls. These are only applicable if `allow_low_precision_` is false. const TimeDelta max_hold_back_window_; const int max_hold_back_window_in_packets_; diff --git a/modules/pacing/task_queue_paced_sender_unittest.cc b/modules/pacing/task_queue_paced_sender_unittest.cc index a22ff6d164..cb6d6156b4 100644 --- a/modules/pacing/task_queue_paced_sender_unittest.cc +++ b/modules/pacing/task_queue_paced_sender_unittest.cc @@ -11,15 +11,19 @@ #include "modules/pacing/task_queue_paced_sender.h" #include +#include #include #include #include #include #include +#include "api/task_queue/task_queue_base.h" #include "api/transport/network_types.h" +#include "api/units/data_rate.h" #include "modules/pacing/packet_router.h" #include "modules/utility/include/mock/mock_process_thread.h" +#include "rtc_base/task_utils/to_queued_task.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/scoped_key_value_config.h" @@ -76,6 +80,88 @@ std::vector> GeneratePadding( return padding_packets; } +class TaskQueueWithFakePrecisionFactory : public TaskQueueFactory { + public: + explicit TaskQueueWithFakePrecisionFactory( + TaskQueueFactory* task_queue_factory) + : task_queue_factory_(task_queue_factory) {} + + std::unique_ptr CreateTaskQueue( + absl::string_view name, + Priority priority) const override { + return std::unique_ptr( + new TaskQueueWithFakePrecision( + const_cast(this), + task_queue_factory_)); + } + + int delayed_low_precision_count() const { + return delayed_low_precision_count_; + } + int delayed_high_precision_count() const { + return delayed_high_precision_count_; + } + + private: + friend class TaskQueueWithFakePrecision; + + class TaskQueueWithFakePrecision : public TaskQueueBase { + public: + TaskQueueWithFakePrecision( + TaskQueueWithFakePrecisionFactory* parent_factory, + TaskQueueFactory* task_queue_factory) + : parent_factory_(parent_factory), + task_queue_(task_queue_factory->CreateTaskQueue( + "TaskQueueWithFakePrecision", + TaskQueueFactory::Priority::NORMAL)) {} + ~TaskQueueWithFakePrecision() override {} + + void Delete() override { + // `task_queue_->Delete()` is implicitly called in the destructor due to + // TaskQueueDeleter. + delete this; + } + void PostTask(std::unique_ptr task) override { + task_queue_->PostTask( + ToQueuedTask([this, task = std::move(task)]() mutable { + RunTask(std::move(task)); + })); + } + void PostDelayedTask(std::unique_ptr task, + uint32_t milliseconds) override { + ++parent_factory_->delayed_low_precision_count_; + task_queue_->PostDelayedTask( + ToQueuedTask([this, task = std::move(task)]() mutable { + RunTask(std::move(task)); + }), + milliseconds); + } + void PostDelayedHighPrecisionTask(std::unique_ptr task, + uint32_t milliseconds) override { + ++parent_factory_->delayed_high_precision_count_; + task_queue_->PostDelayedHighPrecisionTask( + ToQueuedTask([this, task = std::move(task)]() mutable { + RunTask(std::move(task)); + }), + milliseconds); + } + + private: + void RunTask(std::unique_ptr task) { + CurrentTaskQueueSetter set_current(this); + if (!task->Run()) + task.release(); + } + + TaskQueueWithFakePrecisionFactory* parent_factory_; + std::unique_ptr task_queue_; + }; + + TaskQueueFactory* task_queue_factory_; + std::atomic delayed_low_precision_count_ = 0u; + std::atomic delayed_high_precision_count_ = 0u; +}; + } // namespace namespace test { @@ -597,5 +683,93 @@ TEST(TaskQueuePacedSenderTest, Stats) { EXPECT_TRUE(pacer.ExpectedQueueTime().IsZero()); } +TEST(TaskQueuePacedSenderTest, HighPrecisionPacingWhenSlackIsDisabled) { + test::ScopedKeyValueConfig experiments( + "WebRTC-SlackedTaskQueuePacedSender/Disabled/"); + + GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); + TaskQueueWithFakePrecisionFactory task_queue_factory( + time_controller.GetTaskQueueFactory()); + + MockPacketRouter packet_router; + TaskQueuePacedSender pacer( + time_controller.GetClock(), &packet_router, /*event_log=*/nullptr, + experiments, &task_queue_factory, PacingController::kMinSleepTime, + kNoPacketHoldback); + + // Send enough packets (covering one second) that pacing is triggered, i.e. + // delayed tasks being scheduled. + static constexpr size_t kPacketsToSend = 42; + static constexpr DataRate kPacingRate = + DataRate::BitsPerSec(kDefaultPacketSize * 8 * kPacketsToSend); + pacer.SetPacingRates(kPacingRate, DataRate::Zero()); + pacer.EnsureStarted(); + pacer.EnqueuePackets( + GeneratePackets(RtpPacketMediaType::kVideo, kPacketsToSend)); + // Expect all of them to be sent. + size_t packets_sent = 0; + EXPECT_CALL(packet_router, SendPacket) + .WillRepeatedly( + [&](std::unique_ptr packet, + const PacedPacketInfo& cluster_info) { ++packets_sent; }); + time_controller.AdvanceTime(TimeDelta::Seconds(1)); + EXPECT_EQ(packets_sent, kPacketsToSend); + + // Expect pacing to make use of high precision. + EXPECT_EQ(task_queue_factory.delayed_low_precision_count(), 0); + EXPECT_GT(task_queue_factory.delayed_high_precision_count(), 0); + + // Create probe cluster which is also high precision. + pacer.CreateProbeCluster(kPacingRate, 123); + pacer.EnqueuePackets(GeneratePackets(RtpPacketMediaType::kVideo, 1)); + time_controller.AdvanceTime(TimeDelta::Seconds(1)); + EXPECT_EQ(task_queue_factory.delayed_low_precision_count(), 0); + EXPECT_GT(task_queue_factory.delayed_high_precision_count(), 0); +} + +TEST(TaskQueuePacedSenderTest, LowPrecisionPacingWhenSlackIsEnabled) { + test::ScopedKeyValueConfig experiments( + "WebRTC-SlackedTaskQueuePacedSender/Enabled/"); + + GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); + TaskQueueWithFakePrecisionFactory task_queue_factory( + time_controller.GetTaskQueueFactory()); + + MockPacketRouter packet_router; + TaskQueuePacedSender pacer( + time_controller.GetClock(), &packet_router, /*event_log=*/nullptr, + experiments, &task_queue_factory, PacingController::kMinSleepTime, + kNoPacketHoldback); + + // Send enough packets (covering one second) that pacing is triggered, i.e. + // delayed tasks being scheduled. + static constexpr size_t kPacketsToSend = 42; + static constexpr DataRate kPacingRate = + DataRate::BitsPerSec(kDefaultPacketSize * 8 * kPacketsToSend); + pacer.SetPacingRates(kPacingRate, DataRate::Zero()); + pacer.EnsureStarted(); + pacer.EnqueuePackets( + GeneratePackets(RtpPacketMediaType::kVideo, kPacketsToSend)); + // Expect all of them to be sent. + size_t packets_sent = 0; + EXPECT_CALL(packet_router, SendPacket) + .WillRepeatedly( + [&](std::unique_ptr packet, + const PacedPacketInfo& cluster_info) { ++packets_sent; }); + time_controller.AdvanceTime(TimeDelta::Seconds(1)); + EXPECT_EQ(packets_sent, kPacketsToSend); + + // Expect pacing to make use of low precision. + EXPECT_GT(task_queue_factory.delayed_low_precision_count(), 0); + EXPECT_EQ(task_queue_factory.delayed_high_precision_count(), 0); + + // Create probe cluster, which uses high precision despite regular pacing + // being low precision. + pacer.CreateProbeCluster(kPacingRate, 123); + pacer.EnqueuePackets(GeneratePackets(RtpPacketMediaType::kVideo, 1)); + time_controller.AdvanceTime(TimeDelta::Seconds(1)); + EXPECT_GT(task_queue_factory.delayed_high_precision_count(), 0); +} + } // namespace test } // namespace webrtc From 7ddc7d548cf7f1a39b7efabd3a06f8162305baee Mon Sep 17 00:00:00 2001 From: Jonas Oreland Date: Wed, 16 Mar 2022 12:21:52 +0100 Subject: [PATCH 189/847] WebRTC-DeprecateGlobalFieldTrialString/Enabled/ - part 6/inf This patch just refactors creation of P2P transport channel, pushing down the IceTransportInit object rather than decomposing it going down. The IceTransportInit object will in subsequent patches be extended with a field trial container. Reason for splitting patch into this and subsequent is to allow changes to internal factories. Bug: webrtc:10335 Change-Id: Icc8b6e4142744b64d134bcb2d4a56777745db62b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255602 Reviewed-by: Mirko Bonadei Reviewed-by: Harald Alvestrand Commit-Queue: Jonas Oreland Cr-Commit-Position: refs/heads/main@{#36215} --- api/ice_transport_factory.cc | 15 ++------ api/ice_transport_interface.h | 10 ++++++ p2p/base/default_ice_transport_factory.cc | 6 ++-- p2p/base/p2p_transport_channel.cc | 41 +++++++--------------- p2p/base/p2p_transport_channel.h | 32 +++++++++++++++-- p2p/base/p2p_transport_channel_unittest.cc | 11 +++--- 6 files changed, 65 insertions(+), 50 deletions(-) diff --git a/api/ice_transport_factory.cc b/api/ice_transport_factory.cc index 26ef88bf1c..9e7e629a6f 100644 --- a/api/ice_transport_factory.cc +++ b/api/ice_transport_factory.cc @@ -58,18 +58,9 @@ rtc::scoped_refptr CreateIceTransport( rtc::scoped_refptr CreateIceTransport( IceTransportInit init) { - if (init.async_resolver_factory()) { - // Backwards compatibility mode - return rtc::make_ref_counted( - std::make_unique( - "", cricket::ICE_CANDIDATE_COMPONENT_RTP, init.port_allocator(), - init.async_resolver_factory(), init.event_log())); - } else { - return rtc::make_ref_counted( - cricket::P2PTransportChannel::Create( - "", cricket::ICE_CANDIDATE_COMPONENT_RTP, init.port_allocator(), - init.async_dns_resolver_factory(), init.event_log())); - } + return rtc::make_ref_counted( + cricket::P2PTransportChannel::Create( + "", cricket::ICE_CANDIDATE_COMPONENT_RTP, std::move(init))); } } // namespace webrtc diff --git a/api/ice_transport_interface.h b/api/ice_transport_interface.h index a3b364c87a..f202658acf 100644 --- a/api/ice_transport_interface.h +++ b/api/ice_transport_interface.h @@ -23,6 +23,7 @@ namespace cricket { class IceTransportInternal; class PortAllocator; +class IceControllerFactoryInterface; } // namespace cricket namespace webrtc { @@ -74,12 +75,21 @@ struct IceTransportInit final { RtcEventLog* event_log() { return event_log_; } void set_event_log(RtcEventLog* event_log) { event_log_ = event_log; } + void set_ice_controller_factory( + cricket::IceControllerFactoryInterface* ice_controller_factory) { + ice_controller_factory_ = ice_controller_factory; + } + cricket::IceControllerFactoryInterface* ice_controller_factory() { + return ice_controller_factory_; + } + private: cricket::PortAllocator* port_allocator_ = nullptr; AsyncDnsResolverFactoryInterface* async_dns_resolver_factory_ = nullptr; // For backwards compatibility. Only one resolver factory can be set. AsyncResolverFactory* async_resolver_factory_ = nullptr; RtcEventLog* event_log_ = nullptr; + cricket::IceControllerFactoryInterface* ice_controller_factory_ = nullptr; // TODO(https://crbug.com/webrtc/12657): Redesign to have const members. }; diff --git a/p2p/base/default_ice_transport_factory.cc b/p2p/base/default_ice_transport_factory.cc index 0a7175cfd8..8d87d66697 100644 --- a/p2p/base/default_ice_transport_factory.cc +++ b/p2p/base/default_ice_transport_factory.cc @@ -44,10 +44,10 @@ DefaultIceTransportFactory::CreateIceTransport( int component, IceTransportInit init) { BasicIceControllerFactory factory; + init.set_ice_controller_factory(&factory); return rtc::make_ref_counted( - cricket::P2PTransportChannel::Create( - transport_name, component, init.port_allocator(), - init.async_dns_resolver_factory(), init.event_log(), &factory)); + cricket::P2PTransportChannel::Create(transport_name, component, + std::move(init))); } } // namespace webrtc diff --git a/p2p/base/p2p_transport_channel.cc b/p2p/base/p2p_transport_channel.cc index f95534b3e0..5d7f895b61 100644 --- a/p2p/base/p2p_transport_channel.cc +++ b/p2p/base/p2p_transport_channel.cc @@ -109,18 +109,22 @@ bool IceCredentialsChanged(const std::string& old_ufrag, return (old_ufrag != new_ufrag) || (old_pwd != new_pwd); } -// static std::unique_ptr P2PTransportChannel::Create( const std::string& transport_name, int component, - PortAllocator* allocator, - webrtc::AsyncDnsResolverFactoryInterface* async_dns_resolver_factory, - webrtc::RtcEventLog* event_log, - IceControllerFactoryInterface* ice_controller_factory) { - return absl::WrapUnique(new P2PTransportChannel( - transport_name, component, allocator, async_dns_resolver_factory, - /* owned_dns_resolver_factory= */ nullptr, event_log, - ice_controller_factory)); + webrtc::IceTransportInit init) { + if (init.async_resolver_factory()) { + return absl::WrapUnique(new P2PTransportChannel( + transport_name, component, init.port_allocator(), nullptr, + std::make_unique( + init.async_resolver_factory()), + init.event_log(), init.ice_controller_factory())); + } else { + return absl::WrapUnique(new P2PTransportChannel( + transport_name, component, init.port_allocator(), + init.async_dns_resolver_factory(), nullptr, init.event_log(), + init.ice_controller_factory())); + } } P2PTransportChannel::P2PTransportChannel(const std::string& transport_name, @@ -204,25 +208,6 @@ P2PTransportChannel::P2PTransportChannel( } } -// Public constructor, exposed for backwards compatibility. -// Deprecated. -P2PTransportChannel::P2PTransportChannel( - const std::string& transport_name, - int component, - PortAllocator* allocator, - webrtc::AsyncResolverFactory* async_resolver_factory, - webrtc::RtcEventLog* event_log, - IceControllerFactoryInterface* ice_controller_factory) - : P2PTransportChannel( - transport_name, - component, - allocator, - nullptr, - std::make_unique( - async_resolver_factory), - event_log, - ice_controller_factory) {} - P2PTransportChannel::~P2PTransportChannel() { TRACE_EVENT0("webrtc", "P2PTransportChannel::~P2PTransportChannel"); RTC_DCHECK_RUN_ON(network_thread_); diff --git a/p2p/base/p2p_transport_channel.h b/p2p/base/p2p_transport_channel.h index a1c2de04a7..58bd1fb978 100644 --- a/p2p/base/p2p_transport_channel.h +++ b/p2p/base/p2p_transport_channel.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include "absl/base/attributes.h" @@ -36,12 +37,14 @@ #include "api/async_dns_resolver.h" #include "api/async_resolver_factory.h" #include "api/candidate.h" +#include "api/ice_transport_interface.h" #include "api/rtc_error.h" #include "api/sequence_checker.h" #include "api/transport/enums.h" #include "api/transport/stun.h" #include "logging/rtc_event_log/events/rtc_event_ice_candidate_pair_config.h" #include "logging/rtc_event_log/ice_logger.h" +#include "p2p/base/basic_async_resolver_factory.h" #include "p2p/base/candidate_pair_interface.h" #include "p2p/base/connection.h" #include "p2p/base/ice_controller_factory_interface.h" @@ -101,18 +104,33 @@ class RemoteCandidate : public Candidate { // two P2P clients connected to each other. class RTC_EXPORT P2PTransportChannel : public IceTransportInternal { public: + static std::unique_ptr Create( + const std::string& transport_name, + int component, + webrtc::IceTransportInit init); + + // TODO(jonaso): This is deprecated and will be removed. static std::unique_ptr Create( const std::string& transport_name, int component, PortAllocator* allocator, webrtc::AsyncDnsResolverFactoryInterface* async_dns_resolver_factory, webrtc::RtcEventLog* event_log = nullptr, - IceControllerFactoryInterface* ice_controller_factory = nullptr); + IceControllerFactoryInterface* ice_controller_factory = nullptr) { + webrtc::IceTransportInit init; + init.set_port_allocator(allocator); + init.set_async_dns_resolver_factory(async_dns_resolver_factory); + init.set_event_log(event_log); + init.set_ice_controller_factory(ice_controller_factory); + return Create(transport_name, component, std::move(init)); + } + // For testing only. // TODO(zstein): Remove once AsyncDnsResolverFactory is required. P2PTransportChannel(const std::string& transport_name, int component, PortAllocator* allocator); + ABSL_DEPRECATED("bugs.webrtc.org/12598") P2PTransportChannel( const std::string& transport_name, @@ -120,7 +138,17 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal { PortAllocator* allocator, webrtc::AsyncResolverFactory* async_resolver_factory, webrtc::RtcEventLog* event_log = nullptr, - IceControllerFactoryInterface* ice_controller_factory = nullptr); + IceControllerFactoryInterface* ice_controller_factory = nullptr) + : P2PTransportChannel( + transport_name, + component, + allocator, + nullptr, + std::make_unique( + async_resolver_factory), + event_log, + ice_controller_factory) {} + ~P2PTransportChannel() override; P2PTransportChannel(const P2PTransportChannel&) = delete; diff --git a/p2p/base/p2p_transport_channel_unittest.cc b/p2p/base/p2p_transport_channel_unittest.cc index 79bb2a340c..9acd7b1fa0 100644 --- a/p2p/base/p2p_transport_channel_unittest.cc +++ b/p2p/base/p2p_transport_channel_unittest.cc @@ -6074,11 +6074,12 @@ TEST(P2PTransportChannel, InjectIceController) { MockIceControllerFactory factory; FakePortAllocator pa(rtc::Thread::Current(), nullptr); EXPECT_CALL(factory, RecordIceControllerCreated()).Times(1); - auto dummy = std::make_unique( - "transport_name", - /* component= */ 77, &pa, - /* async_resolver_factory = */ nullptr, - /* event_log = */ nullptr, &factory); + webrtc::IceTransportInit init; + init.set_port_allocator(&pa); + init.set_ice_controller_factory(&factory); + auto dummy = + P2PTransportChannel::Create("transport_name", + /* component= */ 77, std::move(init)); } class ForgetLearnedStateController : public cricket::BasicIceController { From 6160ca53d113a4b6c6cb77f78a6d724344dfe8ef Mon Sep 17 00:00:00 2001 From: philipel Date: Wed, 16 Mar 2022 12:11:42 +0100 Subject: [PATCH 190/847] New VideoEncoderFactoryTemplate. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The VideoEncoderFactoryTemplate takes encoder implementations as template arguments, making it possible to easily implement a VideoEncoderFactory only using the implementations required for the particular application. This will replace the BuiltinVideoEncoderFactory. Change-Id: Ifb0e93d0d4491664fb7f7acf085190d8a90ddc0e Bug: webrtc:13573 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251904 Reviewed-by: Mirko Bonadei Reviewed-by: Erik Språng Commit-Queue: Philip Eliasson Cr-Commit-Position: refs/heads/main@{#36216} --- api/DEPS | 4 + api/video_codecs/BUILD.gn | 44 +++++ api/video_codecs/test/BUILD.gn | 17 ++ .../video_encoder_factory_template_tests.cc | 160 ++++++++++++++++++ .../video_encoder_factory_template.h | 116 +++++++++++++ ...oder_factory_template_libaom_av1_adapter.h | 40 +++++ ...oder_factory_template_libvpx_vp8_adapter.h | 37 ++++ ...oder_factory_template_libvpx_vp9_adapter.h | 37 ++++ ...coder_factory_template_open_h264_adapter.h | 41 +++++ 9 files changed, 496 insertions(+) create mode 100644 api/video_codecs/test/video_encoder_factory_template_tests.cc create mode 100644 api/video_codecs/video_encoder_factory_template.h create mode 100644 api/video_codecs/video_encoder_factory_template_libaom_av1_adapter.h create mode 100644 api/video_codecs/video_encoder_factory_template_libvpx_vp8_adapter.h create mode 100644 api/video_codecs/video_encoder_factory_template_libvpx_vp9_adapter.h create mode 100644 api/video_codecs/video_encoder_factory_template_open_h264_adapter.h diff --git a/api/DEPS b/api/DEPS index bdeab0ade6..06232d7890 100644 --- a/api/DEPS +++ b/api/DEPS @@ -312,6 +312,10 @@ specific_include_rules = { "+rtc_base/thread_annotations.h", ], + "video_encoder_factory_template.*\.h": [ + "+modules/video_coding", + ], + # .cc files in api/ should not be restricted in what they can #include, # so we re-add all the top-level directories here. (That's because .h # files leak their #includes to whoever's #including them, but .cc files diff --git a/api/video_codecs/BUILD.gn b/api/video_codecs/BUILD.gn index cab0f7a049..198c7f44aa 100644 --- a/api/video_codecs/BUILD.gn +++ b/api/video_codecs/BUILD.gn @@ -112,6 +112,50 @@ rtc_library("builtin_video_encoder_factory") { absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } +rtc_source_set("video_encoder_factory_template") { + visibility = [ "*" ] + allow_poison = [ "software_video_codecs" ] + public = [ "video_encoder_factory_template.h" ] + + deps = [ ":video_codecs_api" ] + absl_deps = [ "//third_party/abseil-cpp/absl/algorithm:container" ] +} + +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" ] + + deps = [ "../../modules/video_coding:webrtc_vp8" ] +} + +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" ] + + deps = [ "../../modules/video_coding:webrtc_vp9" ] +} + +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" ] + + deps = [ "../../modules/video_coding:webrtc_h264" ] +} + +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" ] + + deps = [ + "../../modules/video_coding/codecs/av1:libaom_av1_encoder", + "../../modules/video_coding/svc:scalability_structures", + ] +} + rtc_library("vp8_temporal_layers_factory") { visibility = [ "*" ] allow_poison = [ "software_video_codecs" ] diff --git a/api/video_codecs/test/BUILD.gn b/api/video_codecs/test/BUILD.gn index 14b54a1f99..3bee6b17ce 100644 --- a/api/video_codecs/test/BUILD.gn +++ b/api/video_codecs/test/BUILD.gn @@ -20,6 +20,7 @@ if (rtc_include_tests) { ] deps = [ + ":video_encoder_factory_template_tests", "..:builtin_video_encoder_factory", "..:rtc_software_fallback_wrappers", "..:video_codecs_api", @@ -43,4 +44,20 @@ if (rtc_include_tests) { ] absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } + + rtc_library("video_encoder_factory_template_tests") { + testonly = true + sources = [ "video_encoder_factory_template_tests.cc" ] + + deps = [ + "..:video_encoder_factory_template", + "..:video_encoder_factory_template_libaom_av1_adapter", + "..:video_encoder_factory_template_libvpx_vp8_adapter", + "..:video_encoder_factory_template_libvpx_vp9_adapter", + "..:video_encoder_factory_template_open_h264_adapter", + "../../:mock_video_encoder", + "../../../test:test_support", + "//testing/gtest", + ] + } } diff --git a/api/video_codecs/test/video_encoder_factory_template_tests.cc b/api/video_codecs/test/video_encoder_factory_template_tests.cc new file mode 100644 index 0000000000..e54b46c09f --- /dev/null +++ b/api/video_codecs/test/video_encoder_factory_template_tests.cc @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2022 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_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 "api/video_codecs/video_encoder_factory_template_open_h264_adapter.h" +#include "test/gmock.h" +#include "test/gtest.h" + +using ::testing::Each; +using ::testing::Eq; +using ::testing::Field; +using ::testing::IsEmpty; +using ::testing::Ne; +using ::testing::Not; +using ::testing::UnorderedElementsAre; + +namespace webrtc { +namespace { +using CodecSupport = VideoEncoderFactory::CodecSupport; +const SdpVideoFormat kFooSdp("Foo"); +const SdpVideoFormat kBarLowSdp("Bar", {{"profile", "low"}}); +const SdpVideoFormat kBarHighSdp("Bar", {{"profile", "high"}}); + +struct FooEncoderTemplateAdapter { + static std::vector SupportedFormats() { return {kFooSdp}; } + + static std::unique_ptr CreateEncoder( + const SdpVideoFormat& format) { + return std::make_unique>(); + } + + static bool IsScalabilityModeSupported( + const absl::string_view scalability_mode) { + return scalability_mode == "L1T2" || scalability_mode == "L1T3"; + } +}; + +struct BarEncoderTemplateAdapter { + static std::vector SupportedFormats() { + return {kBarLowSdp, kBarHighSdp}; + } + + static std::unique_ptr CreateEncoder( + const SdpVideoFormat& format) { + return std::make_unique>(); + } + + static bool IsScalabilityModeSupported( + const absl::string_view scalability_mode) { + return scalability_mode == "L1T2" || scalability_mode == "L1T3" || + scalability_mode == "S2T2" || scalability_mode == "S2T3"; + } +}; + +TEST(VideoEncoderFactoryTemplate, OneTemplateAdapterCreateEncoder) { + VideoEncoderFactoryTemplate factory; + EXPECT_THAT(factory.GetSupportedFormats(), UnorderedElementsAre(kFooSdp)); + EXPECT_THAT(factory.CreateVideoEncoder(kFooSdp), Ne(nullptr)); + EXPECT_THAT(factory.CreateVideoEncoder(SdpVideoFormat("FooX")), Eq(nullptr)); +} + +TEST(VideoEncoderFactoryTemplate, OneTemplateAdapterCodecSupport) { + VideoEncoderFactoryTemplate factory; + EXPECT_THAT(factory.QueryCodecSupport(kFooSdp, absl::nullopt), + Field(&CodecSupport::is_supported, true)); + EXPECT_THAT(factory.QueryCodecSupport(kFooSdp, "L1T2"), + Field(&CodecSupport::is_supported, true)); + EXPECT_THAT(factory.QueryCodecSupport(kFooSdp, "S2T3"), + Field(&CodecSupport::is_supported, false)); + EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat("FooX"), absl::nullopt), + Field(&CodecSupport::is_supported, false)); +} + +TEST(VideoEncoderFactoryTemplate, TwoTemplateAdaptersNoDuplicates) { + VideoEncoderFactoryTemplate + factory; + EXPECT_THAT(factory.GetSupportedFormats(), UnorderedElementsAre(kFooSdp)); +} + +TEST(VideoEncoderFactoryTemplate, TwoTemplateAdaptersCreateEncoders) { + VideoEncoderFactoryTemplate + factory; + EXPECT_THAT(factory.GetSupportedFormats(), + UnorderedElementsAre(kFooSdp, kBarLowSdp, kBarHighSdp)); + EXPECT_THAT(factory.CreateVideoEncoder(kFooSdp), Ne(nullptr)); + EXPECT_THAT(factory.CreateVideoEncoder(kBarLowSdp), Ne(nullptr)); + EXPECT_THAT(factory.CreateVideoEncoder(kBarHighSdp), Ne(nullptr)); + EXPECT_THAT(factory.CreateVideoEncoder(SdpVideoFormat("FooX")), Eq(nullptr)); + EXPECT_THAT(factory.CreateVideoEncoder(SdpVideoFormat("Bar")), Eq(nullptr)); +} + +TEST(VideoEncoderFactoryTemplate, TwoTemplateAdaptersCodecSupport) { + VideoEncoderFactoryTemplate + factory; + EXPECT_THAT(factory.QueryCodecSupport(kFooSdp, absl::nullopt), + Field(&CodecSupport::is_supported, true)); + EXPECT_THAT(factory.QueryCodecSupport(kFooSdp, "L1T2"), + Field(&CodecSupport::is_supported, true)); + EXPECT_THAT(factory.QueryCodecSupport(kFooSdp, "S2T3"), + Field(&CodecSupport::is_supported, false)); + EXPECT_THAT(factory.QueryCodecSupport(kBarLowSdp, absl::nullopt), + Field(&CodecSupport::is_supported, true)); + EXPECT_THAT(factory.QueryCodecSupport(kBarHighSdp, absl::nullopt), + Field(&CodecSupport::is_supported, true)); + EXPECT_THAT(factory.QueryCodecSupport(kBarLowSdp, "S2T2"), + Field(&CodecSupport::is_supported, true)); + EXPECT_THAT(factory.QueryCodecSupport(kBarHighSdp, "S3T2"), + Field(&CodecSupport::is_supported, false)); +} + +TEST(VideoEncoderFactoryTemplate, LibvpxVp8) { + VideoEncoderFactoryTemplate factory; + const SdpVideoFormat kVp8Sdp("VP8"); + EXPECT_THAT(factory.GetSupportedFormats(), UnorderedElementsAre(kVp8Sdp)); + EXPECT_THAT(factory.CreateVideoEncoder(kVp8Sdp), Ne(nullptr)); +} + +TEST(VideoEncoderFactoryTemplate, LibvpxVp9) { + VideoEncoderFactoryTemplate factory; + auto formats = factory.GetSupportedFormats(); + EXPECT_THAT(formats, Not(IsEmpty())); + EXPECT_THAT(formats, Each(Field(&SdpVideoFormat::name, "VP9"))); + EXPECT_THAT(factory.CreateVideoEncoder(formats[0]), Ne(nullptr)); +} + +// TODO(bugs.webrtc.org/13573): When OpenH264 is no longer a conditional build +// target remove this #ifdef. +#if defined(WEBRTC_USE_H264) +TEST(VideoEncoderFactoryTemplate, OpenH264) { + VideoEncoderFactoryTemplate factory; + auto formats = factory.GetSupportedFormats(); + EXPECT_THAT(formats, Not(IsEmpty())); + EXPECT_THAT(formats, Each(Field(&SdpVideoFormat::name, "H264"))); + EXPECT_THAT(factory.CreateVideoEncoder(formats[0]), Ne(nullptr)); +} +#endif // defined(WEBRTC_USE_H264) + +TEST(VideoEncoderFactoryTemplate, LibaomAv1) { + VideoEncoderFactoryTemplate factory; + const SdpVideoFormat kAv1Sdp("AV1"); + EXPECT_THAT(factory.GetSupportedFormats(), UnorderedElementsAre(kAv1Sdp)); + EXPECT_THAT(factory.CreateVideoEncoder(kAv1Sdp), Ne(nullptr)); +} + +} // namespace +} // namespace webrtc diff --git a/api/video_codecs/video_encoder_factory_template.h b/api/video_codecs/video_encoder_factory_template.h new file mode 100644 index 0000000000..f1581c5620 --- /dev/null +++ b/api/video_codecs/video_encoder_factory_template.h @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2022 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_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_TEMPLATE_H_ +#define API_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_TEMPLATE_H_ + +#include +#include +#include + +#include "absl/algorithm/container.h" +#include "api/video_codecs/video_encoder.h" +#include "api/video_codecs/video_encoder_factory.h" + +namespace webrtc { +// The VideoEncoderFactoryTemplate supports encoders implementations given as +// template arguments. +// +// To include an encoder in the factory it requires three static members +// functions to be defined: +// +// // Returns the supported SdpVideoFormats this encoder can produce. +// static std::vector SupportedFormats(); +// +// // Creates an encoder instance for the given format. +// static std::unique_ptr +// CreateEncoder(const SdpVideoFormat& format); +// +// // Returns true if the encoder supports the given scalability mode. +// static bool +// IsScalabilityModeSupported(const absl::string_view scalability_mode); +// +// Note that the order of the template arguments matter as the factory will +// query/return the first encoder implementation supporting the given +// SdpVideoFormat. +template +class VideoEncoderFactoryTemplate : public VideoEncoderFactory { + public: + std::vector GetSupportedFormats() const override { + std::vector formats; + GetSupportedFormatsInternal(formats); + return formats; + } + + std::unique_ptr CreateVideoEncoder( + const SdpVideoFormat& format) override { + return CreateVideoEncoderInternal(format); + } + + CodecSupport QueryCodecSupport( + const SdpVideoFormat& format, + absl::optional scalability_mode) const override { + return QueryCodecSupportInternal(format, scalability_mode); + } + + private: + template + bool IsFormatSupported(const SdpVideoFormat& format) const { + return absl::c_count(V::SupportedFormats(), format) > 0; + } + + template + void GetSupportedFormatsInternal(std::vector& formats) const { + auto supported_formats = V::SupportedFormats(); + for (const auto& format : supported_formats) { + if (absl::c_count(formats, format) == 0) { + formats.push_back(format); + } + } + + if constexpr (sizeof...(Vs) > 0) { + return GetSupportedFormatsInternal(formats); + } + } + + template + std::unique_ptr CreateVideoEncoderInternal( + const SdpVideoFormat& format) { + if (IsFormatSupported(format)) { + return V::CreateEncoder(format); + } + + if constexpr (sizeof...(Vs) > 0) { + return CreateVideoEncoderInternal(format); + } + + return nullptr; + } + + template + CodecSupport QueryCodecSupportInternal( + const SdpVideoFormat& format, + const absl::optional& scalability_mode) const { + if (IsFormatSupported(format)) { + return {.is_supported = !scalability_mode || + V::IsScalabilityModeSupported(*scalability_mode)}; + } + + if constexpr (sizeof...(Vs) > 0) { + return QueryCodecSupportInternal(format, scalability_mode); + } + + return {.is_supported = false}; + } +}; + +} // namespace webrtc + +#endif // API_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_TEMPLATE_H_ diff --git a/api/video_codecs/video_encoder_factory_template_libaom_av1_adapter.h b/api/video_codecs/video_encoder_factory_template_libaom_av1_adapter.h new file mode 100644 index 0000000000..dcbdc82b86 --- /dev/null +++ b/api/video_codecs/video_encoder_factory_template_libaom_av1_adapter.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2022 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_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_TEMPLATE_LIBAOM_AV1_ADAPTER_H_ +#define API_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_TEMPLATE_LIBAOM_AV1_ADAPTER_H_ + +#include +#include + +#include "modules/video_coding/codecs/av1/libaom_av1_encoder.h" +#include "modules/video_coding/svc/create_scalability_structure.h" + +namespace webrtc { +struct LibaomAv1EncoderTemplateAdapter { + static std::vector SupportedFormats() { + return {SdpVideoFormat("AV1")}; + } + + static std::unique_ptr CreateEncoder( + const SdpVideoFormat& format) { + return CreateLibaomAv1Encoder(); + } + + static bool IsScalabilityModeSupported(absl::string_view scalability_mode) { + // For libaom AV1, the scalability mode is supported if we can create the + // scalability structure. + return ScalabilityStructureConfig(scalability_mode) != absl::nullopt; + } +}; + +} // namespace webrtc + +#endif // API_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_TEMPLATE_LIBAOM_AV1_ADAPTER_H_ diff --git a/api/video_codecs/video_encoder_factory_template_libvpx_vp8_adapter.h b/api/video_codecs/video_encoder_factory_template_libvpx_vp8_adapter.h new file mode 100644 index 0000000000..935a87a216 --- /dev/null +++ b/api/video_codecs/video_encoder_factory_template_libvpx_vp8_adapter.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2022 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_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_TEMPLATE_LIBVPX_VP8_ADAPTER_H_ +#define API_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_TEMPLATE_LIBVPX_VP8_ADAPTER_H_ + +#include +#include + +#include "modules/video_coding/codecs/vp8/include/vp8.h" + +namespace webrtc { +struct LibvpxVp8EncoderTemplateAdapter { + static std::vector SupportedFormats() { + return {SdpVideoFormat("VP8")}; + } + + static std::unique_ptr CreateEncoder( + const SdpVideoFormat& format) { + return VP8Encoder::Create(); + } + + static bool IsScalabilityModeSupported( + const absl::string_view scalability_mode) { + return VP8Encoder::SupportsScalabilityMode(scalability_mode); + } +}; +} // namespace webrtc + +#endif // API_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_TEMPLATE_LIBVPX_VP8_ADAPTER_H_ diff --git a/api/video_codecs/video_encoder_factory_template_libvpx_vp9_adapter.h b/api/video_codecs/video_encoder_factory_template_libvpx_vp9_adapter.h new file mode 100644 index 0000000000..e203b079c6 --- /dev/null +++ b/api/video_codecs/video_encoder_factory_template_libvpx_vp9_adapter.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2022 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_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_TEMPLATE_LIBVPX_VP9_ADAPTER_H_ +#define API_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_TEMPLATE_LIBVPX_VP9_ADAPTER_H_ + +#include +#include + +#include "modules/video_coding/codecs/vp9/include/vp9.h" + +namespace webrtc { +struct LibvpxVp9EncoderTemplateAdapter { + static std::vector SupportedFormats() { + return SupportedVP9Codecs(); + } + + static std::unique_ptr CreateEncoder( + const SdpVideoFormat& format) { + return VP9Encoder::Create(); + } + + static bool IsScalabilityModeSupported( + const absl::string_view scalability_mode) { + return VP9Encoder::SupportsScalabilityMode(scalability_mode); + } +}; +} // namespace webrtc + +#endif // API_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_TEMPLATE_LIBVPX_VP9_ADAPTER_H_ diff --git a/api/video_codecs/video_encoder_factory_template_open_h264_adapter.h b/api/video_codecs/video_encoder_factory_template_open_h264_adapter.h new file mode 100644 index 0000000000..b127009f6e --- /dev/null +++ b/api/video_codecs/video_encoder_factory_template_open_h264_adapter.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2022 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_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_TEMPLATE_OPEN_H264_ADAPTER_H_ +#define API_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_TEMPLATE_OPEN_H264_ADAPTER_H_ + +#include +#include + +#include "modules/video_coding/codecs/h264/include/h264.h" + +namespace webrtc { +// TODO(bugs.webrtc.org/13573): When OpenH264 is no longer a conditional build +// target remove this #ifdef. +#if defined(WEBRTC_USE_H264) +struct OpenH264EncoderTemplateAdapter { + static std::vector SupportedFormats() { + return SupportedH264Codecs(); + } + + static std::unique_ptr CreateEncoder( + const SdpVideoFormat& format) { + return H264Encoder::Create(cricket::VideoCodec(format)); + } + + static bool IsScalabilityModeSupported( + const absl::string_view scalability_mode) { + return H264Encoder::SupportsScalabilityMode(scalability_mode); + } +}; +#endif // defined(WEBRTC_USE_H264) +} // namespace webrtc + +#endif // API_VIDEO_CODECS_VIDEO_ENCODER_FACTORY_TEMPLATE_OPEN_H264_ADAPTER_H_ From 4a08d5013b311d945b23120ea1b5d5117adbfa57 Mon Sep 17 00:00:00 2001 From: Mirko Bonadei Date: Wed, 16 Mar 2022 14:12:36 +0000 Subject: [PATCH 191/847] Revert "Experimentally reduce TaskQueuePacedSender's delayed task precision." MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 43a69b3f46059b103c35079744dc09a0e2bb2948. Reason for revert: Breaks downstream project. Original change's description: > Experimentally reduce TaskQueuePacedSender's delayed task precision. > > This CL reduces the delayed task precision of non-probes in accordance > with DD go/slacked-task-queue-paced-sender. The precision is only > deduced if field trial "WebRTC-SlackedTaskQueuePacedSender" is enabled > though. > > Bug: webrtc:13824 > Change-Id: I37e53b24e343f4f08059be08a3cda74f5484cc05 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255341 > Reviewed-by: Erik Språng > Commit-Queue: Henrik Boström > Cr-Commit-Position: refs/heads/main@{#36214} Bug: webrtc:13824 Change-Id: Iccdadcfaa0c490a1b9e5636cd695c5673c3c09a0 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255825 Auto-Submit: Mirko Bonadei Bot-Commit: rubber-stamper@appspot.gserviceaccount.com Owners-Override: Mirko Bonadei Commit-Queue: Mirko Bonadei Cr-Commit-Position: refs/heads/main@{#36217} --- modules/pacing/BUILD.gn | 3 - modules/pacing/task_queue_paced_sender.cc | 26 +-- modules/pacing/task_queue_paced_sender.h | 11 -- .../task_queue_paced_sender_unittest.cc | 174 ------------------ 4 files changed, 3 insertions(+), 211 deletions(-) diff --git a/modules/pacing/BUILD.gn b/modules/pacing/BUILD.gn index 90e0eb7134..4064c12151 100644 --- a/modules/pacing/BUILD.gn +++ b/modules/pacing/BUILD.gn @@ -35,7 +35,6 @@ rtc_library("pacing") { "..:module_api", "../../api:function_view", "../../api:sequence_checker", - "../../api:webrtc_key_value_config", "../../api/rtc_event_log", "../../api/task_queue:task_queue", "../../api/transport:field_trial_based_config", @@ -94,7 +93,6 @@ if (rtc_include_tests) { deps = [ ":interval_budget", ":pacing", - "../../api/task_queue:task_queue", "../../api/transport:network_control", "../../api/units:data_rate", "../../api/units:time_delta", @@ -103,7 +101,6 @@ if (rtc_include_tests) { "../../rtc_base:rtc_base_approved", "../../rtc_base:rtc_base_tests_utils", "../../rtc_base/experiments:alr_experiment", - "../../rtc_base/task_utils:to_queued_task", "../../system_wrappers", "../../test:explicit_key_value_config", "../../test:scoped_key_value_config", diff --git a/modules/pacing/task_queue_paced_sender.cc b/modules/pacing/task_queue_paced_sender.cc index fb3d3cab00..620a54135e 100644 --- a/modules/pacing/task_queue_paced_sender.cc +++ b/modules/pacing/task_queue_paced_sender.cc @@ -12,7 +12,6 @@ #include #include - #include "absl/memory/memory.h" #include "rtc_base/checks.h" #include "rtc_base/event.h" @@ -22,13 +21,6 @@ namespace webrtc { -namespace { - -constexpr const char* kSlackedTaskQueuePacedSenderFieldTrial = - "WebRTC-SlackedTaskQueuePacedSender"; - -} // namespace - TaskQueuePacedSender::TaskQueuePacedSender( Clock* clock, PacingController::PacketSender* packet_sender, @@ -54,13 +46,8 @@ TaskQueuePacedSender::TaskQueuePacedSender( TimeDelta max_hold_back_window, int max_hold_back_window_in_packets) : clock_(clock), - allow_low_precision_( - field_trials.IsEnabled(kSlackedTaskQueuePacedSenderFieldTrial)), - max_hold_back_window_(allow_low_precision_ - ? PacingController::kMinSleepTime - : max_hold_back_window), - max_hold_back_window_in_packets_( - allow_low_precision_ ? 0 : max_hold_back_window_in_packets), + max_hold_back_window_(max_hold_back_window), + max_hold_back_window_in_packets_(max_hold_back_window_in_packets), pacing_controller_(clock, packet_sender, event_log, @@ -300,14 +287,7 @@ void TaskQueuePacedSender::MaybeProcessPackets( // Set a new scheduled process time and post a delayed task. next_process_time_ = next_process_time; - // Prefer low precision if allowed and not probing. - TaskQueueBase::DelayPrecision precision = - allow_low_precision_ && !pacing_controller_.IsProbing() - ? TaskQueueBase::DelayPrecision::kLow - : TaskQueueBase::DelayPrecision::kHigh; - - task_queue_.PostDelayedTaskWithPrecision( - precision, + task_queue_.PostDelayedHighPrecisionTask( [this, next_process_time]() { MaybeProcessPackets(next_process_time); }, time_to_next_process->ms()); } diff --git a/modules/pacing/task_queue_paced_sender.h b/modules/pacing/task_queue_paced_sender.h index 61f4d20eb8..61a625521d 100644 --- a/modules/pacing/task_queue_paced_sender.h +++ b/modules/pacing/task_queue_paced_sender.h @@ -26,7 +26,6 @@ #include "api/units/data_size.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" -#include "api/webrtc_key_value_config.h" #include "modules/pacing/pacing_controller.h" #include "modules/pacing/rtp_packet_pacer.h" #include "modules/rtp_rtcp/source/rtp_packet_to_send.h" @@ -145,16 +144,6 @@ class TaskQueuePacedSender : public RtpPacketPacer, public RtpPacketSender { Stats GetStats() const; Clock* const clock_; - // If `kSlackedTaskQueuePacedSenderFieldTrial` is enabled, delayed tasks - // invoking MaybeProcessPackets() are scheduled using low precision instead of - // high precision, resulting in less idle wake ups and packets being sent in - // bursts if the `task_queue_` implementation supports slack. - // - // When probing, high precision is used regardless of `allow_low_precision_` - // to ensure good bandwidth estimation. - const bool allow_low_precision_; - // The holdback window prevents too frequent delayed MaybeProcessPackets() - // calls. These are only applicable if `allow_low_precision_` is false. const TimeDelta max_hold_back_window_; const int max_hold_back_window_in_packets_; diff --git a/modules/pacing/task_queue_paced_sender_unittest.cc b/modules/pacing/task_queue_paced_sender_unittest.cc index cb6d6156b4..a22ff6d164 100644 --- a/modules/pacing/task_queue_paced_sender_unittest.cc +++ b/modules/pacing/task_queue_paced_sender_unittest.cc @@ -11,19 +11,15 @@ #include "modules/pacing/task_queue_paced_sender.h" #include -#include #include #include #include #include #include -#include "api/task_queue/task_queue_base.h" #include "api/transport/network_types.h" -#include "api/units/data_rate.h" #include "modules/pacing/packet_router.h" #include "modules/utility/include/mock/mock_process_thread.h" -#include "rtc_base/task_utils/to_queued_task.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/scoped_key_value_config.h" @@ -80,88 +76,6 @@ std::vector> GeneratePadding( return padding_packets; } -class TaskQueueWithFakePrecisionFactory : public TaskQueueFactory { - public: - explicit TaskQueueWithFakePrecisionFactory( - TaskQueueFactory* task_queue_factory) - : task_queue_factory_(task_queue_factory) {} - - std::unique_ptr CreateTaskQueue( - absl::string_view name, - Priority priority) const override { - return std::unique_ptr( - new TaskQueueWithFakePrecision( - const_cast(this), - task_queue_factory_)); - } - - int delayed_low_precision_count() const { - return delayed_low_precision_count_; - } - int delayed_high_precision_count() const { - return delayed_high_precision_count_; - } - - private: - friend class TaskQueueWithFakePrecision; - - class TaskQueueWithFakePrecision : public TaskQueueBase { - public: - TaskQueueWithFakePrecision( - TaskQueueWithFakePrecisionFactory* parent_factory, - TaskQueueFactory* task_queue_factory) - : parent_factory_(parent_factory), - task_queue_(task_queue_factory->CreateTaskQueue( - "TaskQueueWithFakePrecision", - TaskQueueFactory::Priority::NORMAL)) {} - ~TaskQueueWithFakePrecision() override {} - - void Delete() override { - // `task_queue_->Delete()` is implicitly called in the destructor due to - // TaskQueueDeleter. - delete this; - } - void PostTask(std::unique_ptr task) override { - task_queue_->PostTask( - ToQueuedTask([this, task = std::move(task)]() mutable { - RunTask(std::move(task)); - })); - } - void PostDelayedTask(std::unique_ptr task, - uint32_t milliseconds) override { - ++parent_factory_->delayed_low_precision_count_; - task_queue_->PostDelayedTask( - ToQueuedTask([this, task = std::move(task)]() mutable { - RunTask(std::move(task)); - }), - milliseconds); - } - void PostDelayedHighPrecisionTask(std::unique_ptr task, - uint32_t milliseconds) override { - ++parent_factory_->delayed_high_precision_count_; - task_queue_->PostDelayedHighPrecisionTask( - ToQueuedTask([this, task = std::move(task)]() mutable { - RunTask(std::move(task)); - }), - milliseconds); - } - - private: - void RunTask(std::unique_ptr task) { - CurrentTaskQueueSetter set_current(this); - if (!task->Run()) - task.release(); - } - - TaskQueueWithFakePrecisionFactory* parent_factory_; - std::unique_ptr task_queue_; - }; - - TaskQueueFactory* task_queue_factory_; - std::atomic delayed_low_precision_count_ = 0u; - std::atomic delayed_high_precision_count_ = 0u; -}; - } // namespace namespace test { @@ -683,93 +597,5 @@ TEST(TaskQueuePacedSenderTest, Stats) { EXPECT_TRUE(pacer.ExpectedQueueTime().IsZero()); } -TEST(TaskQueuePacedSenderTest, HighPrecisionPacingWhenSlackIsDisabled) { - test::ScopedKeyValueConfig experiments( - "WebRTC-SlackedTaskQueuePacedSender/Disabled/"); - - GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); - TaskQueueWithFakePrecisionFactory task_queue_factory( - time_controller.GetTaskQueueFactory()); - - MockPacketRouter packet_router; - TaskQueuePacedSender pacer( - time_controller.GetClock(), &packet_router, /*event_log=*/nullptr, - experiments, &task_queue_factory, PacingController::kMinSleepTime, - kNoPacketHoldback); - - // Send enough packets (covering one second) that pacing is triggered, i.e. - // delayed tasks being scheduled. - static constexpr size_t kPacketsToSend = 42; - static constexpr DataRate kPacingRate = - DataRate::BitsPerSec(kDefaultPacketSize * 8 * kPacketsToSend); - pacer.SetPacingRates(kPacingRate, DataRate::Zero()); - pacer.EnsureStarted(); - pacer.EnqueuePackets( - GeneratePackets(RtpPacketMediaType::kVideo, kPacketsToSend)); - // Expect all of them to be sent. - size_t packets_sent = 0; - EXPECT_CALL(packet_router, SendPacket) - .WillRepeatedly( - [&](std::unique_ptr packet, - const PacedPacketInfo& cluster_info) { ++packets_sent; }); - time_controller.AdvanceTime(TimeDelta::Seconds(1)); - EXPECT_EQ(packets_sent, kPacketsToSend); - - // Expect pacing to make use of high precision. - EXPECT_EQ(task_queue_factory.delayed_low_precision_count(), 0); - EXPECT_GT(task_queue_factory.delayed_high_precision_count(), 0); - - // Create probe cluster which is also high precision. - pacer.CreateProbeCluster(kPacingRate, 123); - pacer.EnqueuePackets(GeneratePackets(RtpPacketMediaType::kVideo, 1)); - time_controller.AdvanceTime(TimeDelta::Seconds(1)); - EXPECT_EQ(task_queue_factory.delayed_low_precision_count(), 0); - EXPECT_GT(task_queue_factory.delayed_high_precision_count(), 0); -} - -TEST(TaskQueuePacedSenderTest, LowPrecisionPacingWhenSlackIsEnabled) { - test::ScopedKeyValueConfig experiments( - "WebRTC-SlackedTaskQueuePacedSender/Enabled/"); - - GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); - TaskQueueWithFakePrecisionFactory task_queue_factory( - time_controller.GetTaskQueueFactory()); - - MockPacketRouter packet_router; - TaskQueuePacedSender pacer( - time_controller.GetClock(), &packet_router, /*event_log=*/nullptr, - experiments, &task_queue_factory, PacingController::kMinSleepTime, - kNoPacketHoldback); - - // Send enough packets (covering one second) that pacing is triggered, i.e. - // delayed tasks being scheduled. - static constexpr size_t kPacketsToSend = 42; - static constexpr DataRate kPacingRate = - DataRate::BitsPerSec(kDefaultPacketSize * 8 * kPacketsToSend); - pacer.SetPacingRates(kPacingRate, DataRate::Zero()); - pacer.EnsureStarted(); - pacer.EnqueuePackets( - GeneratePackets(RtpPacketMediaType::kVideo, kPacketsToSend)); - // Expect all of them to be sent. - size_t packets_sent = 0; - EXPECT_CALL(packet_router, SendPacket) - .WillRepeatedly( - [&](std::unique_ptr packet, - const PacedPacketInfo& cluster_info) { ++packets_sent; }); - time_controller.AdvanceTime(TimeDelta::Seconds(1)); - EXPECT_EQ(packets_sent, kPacketsToSend); - - // Expect pacing to make use of low precision. - EXPECT_GT(task_queue_factory.delayed_low_precision_count(), 0); - EXPECT_EQ(task_queue_factory.delayed_high_precision_count(), 0); - - // Create probe cluster, which uses high precision despite regular pacing - // being low precision. - pacer.CreateProbeCluster(kPacingRate, 123); - pacer.EnqueuePackets(GeneratePackets(RtpPacketMediaType::kVideo, 1)); - time_controller.AdvanceTime(TimeDelta::Seconds(1)); - EXPECT_GT(task_queue_factory.delayed_high_precision_count(), 0); -} - } // namespace test } // namespace webrtc From 9524c0fa4f5a1318d411de189d683bbfacf3ba6a Mon Sep 17 00:00:00 2001 From: Hanna Silen Date: Wed, 16 Mar 2022 12:51:57 +0100 Subject: [PATCH 192/847] AgcManagerDirect: Modify clipping_predictor_evaluator_ configuration Increase the history size of clipping_predictor_evaluator_. Use one-sample accuracy in clipping detection for the evaluator. Bug: webrtc:12774 Change-Id: I8c1bbfe69fe55af73ce14992e49ef7295b3ce926 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/241602 Reviewed-by: Alessio Bazzica Commit-Queue: Hanna Silen Cr-Commit-Position: refs/heads/main@{#36218} --- modules/audio_processing/agc/agc_manager_direct.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/audio_processing/agc/agc_manager_direct.cc b/modules/audio_processing/agc/agc_manager_direct.cc index 8bce7690a3..fb54cf52f6 100644 --- a/modules/audio_processing/agc/agc_manager_direct.cc +++ b/modules/audio_processing/agc/agc_manager_direct.cc @@ -52,7 +52,7 @@ constexpr int kSurplusCompressionGain = 6; // History size for the clipping predictor evaluator (unit: number of 10 ms // frames). -constexpr int kClippingPredictorEvaluatorHistorySize = 32; +constexpr int kClippingPredictorEvaluatorHistorySize = 500; using ClippingPredictorConfig = AudioProcessing::Config::GainController1:: AnalogGainController::ClippingPredictor; @@ -609,9 +609,14 @@ void AgcManagerDirect::AnalyzePreProcess(const float* const* audio, } } // Clipping prediction evaluation. + // `clipping_detected` is not used to evaluate the clipping predictor + // since for this purpose a single clipping sample counts as clipping. + const bool one_or_more_clipped_samples = + clipped_ratio >= (1.0f / samples_per_channel); absl::optional prediction_interval = - clipping_predictor_evaluator_.Observe(clipping_detected, - clipping_predicted); + clipping_predictor_evaluator_.Observe( + /*clipping_detected=*/one_or_more_clipped_samples, + clipping_predicted); if (prediction_interval.has_value()) { RTC_HISTOGRAM_COUNTS_LINEAR( "WebRTC.Audio.Agc.ClippingPredictor.PredictionInterval", From e66e6a845b50f212ebb60234446cfc9db897879c Mon Sep 17 00:00:00 2001 From: Per Kjellander Date: Wed, 16 Mar 2022 14:27:24 +0100 Subject: [PATCH 193/847] Apply lower bound of delay based estimate in AimdRateControl::ClampBitrate This move the functionality of applying the lower bound of a network estimate to AimdRateControl::ClampBitrate instead of ChangeBitrate. The purpose is to be able to also clamp probe estimates set by AimdRateControl::SetEstimate as well. Bug: none Change-Id: I6a4d64d2e98bb99da06010e2edaf20dc42880e37 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255823 Reviewed-by: Per Kjellander Commit-Queue: Per Kjellander Reviewed-by: Diep Bui Cr-Commit-Position: refs/heads/main@{#36219} --- .../remote_bitrate_estimator/aimd_rate_control.cc | 11 ++++++----- .../aimd_rate_control_unittest.cc | 13 ++++++++++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/modules/remote_bitrate_estimator/aimd_rate_control.cc b/modules/remote_bitrate_estimator/aimd_rate_control.cc index 1714dd115a..3a4ba85a0f 100644 --- a/modules/remote_bitrate_estimator/aimd_rate_control.cc +++ b/modules/remote_bitrate_estimator/aimd_rate_control.cc @@ -338,11 +338,6 @@ void AimdRateControl::ChangeBitrate(const RateControlInput& input, decreased_bitrate = beta_ * link_capacity_.estimate(); } } - if (estimate_bounded_backoff_ && network_estimate_) { - decreased_bitrate = std::max( - decreased_bitrate, network_estimate_->link_capacity_lower * beta_); - } - // Avoid increasing the rate when over-using. if (decreased_bitrate < current_bitrate_) { new_bitrate = decreased_bitrate; @@ -386,6 +381,12 @@ DataRate AimdRateControl::ClampBitrate(DataRate new_bitrate) const { } new_bitrate = std::min(upper_bound, new_bitrate); } + if (estimate_bounded_backoff_ && network_estimate_ && + network_estimate_->link_capacity_lower.IsFinite() && + new_bitrate < current_bitrate_) { + new_bitrate = + std::max(new_bitrate, network_estimate_->link_capacity_lower * beta_); + } new_bitrate = std::max(new_bitrate, min_configured_bitrate_); return new_bitrate; } diff --git a/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc b/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc index 5d9c328e06..e217a1a7bc 100644 --- a/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc +++ b/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc @@ -255,7 +255,7 @@ TEST(AimdRateControlTest, SetEstimateIncreaseBweInAlr) { 2 * kInitialBitrateBps); } -TEST(AimdRateControlTest, SetEstimateClampedByNetworkEstimate) { +TEST(AimdRateControlTest, SetEstimateUpperLimitedByNetworkEstimate) { auto states = CreateAimdRateControlStates(/*send_side=*/true); NetworkStateEstimate network_estimate; network_estimate.link_capacity_upper = DataRate::KilobitsPerSec(400); @@ -265,6 +265,17 @@ TEST(AimdRateControlTest, SetEstimateClampedByNetworkEstimate) { network_estimate.link_capacity_upper); } +TEST(AimdRateControlTest, SetEstimateLowerLimitedByNetworkEstimate) { + auto states = CreateAimdRateControlStates(/*send_side=*/true); + NetworkStateEstimate network_estimate; + network_estimate.link_capacity_lower = DataRate::KilobitsPerSec(400); + states.aimd_rate_control->SetNetworkStateEstimate(network_estimate); + SetEstimate(states, 100'000); + // 0.85 is default backoff factor. (`beta_`) + EXPECT_EQ(states.aimd_rate_control->LatestEstimate(), + network_estimate.link_capacity_lower * 0.85); +} + TEST(AimdRateControlTest, SetEstimateIgnoresNetworkEstimatesLowerThanCurrent) { test::ScopedFieldTrials override_field_trials( "WebRTC-Bwe-EstimateBoundedIncrease/" From 667343777521c71d022ab7e67839f14e19e5932a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Spr=C3=A5ng?= Date: Wed, 16 Mar 2022 14:20:49 +0100 Subject: [PATCH 194/847] Move ownership of congestion window state to rtp sender controller. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When congestion window is used, two different mechanisms can currently update the outstanding data state in the pacer: * OnPacketSent() withing the pacer itself, when a packet is sent * UpdateOutstandingData(), when RtpTransportControllerSend either: a. Receives an OnPacketSent() callback (increase outstanding data) b. Receives transport feedback (decrease outstanding data) This creates a lot of calls to UpdateOutstandingData(), more than one per sent packet. Each requires locking and/or thread jumps. To avoid that, this CL moves the congestion window state to RtpTransportController send - and we only post a congested flag down the the pacer when the state is changed. The only benefit I can see is of the old way is we prevent sending new packets immedately when the window is full, rather than in some edge cases queue extra packets on the network task queue before the congestion signal is received. That should be rare and benign. I think this simplified logic, which is easier to read and more performant, is a better tradeoff. Bug: webrtc:13417 Change-Id: I326dd88db86dc0d6dc685c61920654ac024e57ef Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255600 Auto-Submit: Erik Språng Reviewed-by: Henrik Boström Commit-Queue: Henrik Boström Cr-Commit-Position: refs/heads/main@{#36220} --- call/rtp_transport_controller_send.cc | 31 ++++--- call/rtp_transport_controller_send.h | 4 + modules/pacing/paced_sender.cc | 12 +-- modules/pacing/paced_sender.h | 3 +- modules/pacing/pacing_controller.cc | 38 ++------- modules/pacing/pacing_controller.h | 8 +- modules/pacing/pacing_controller_unittest.cc | 89 +++----------------- modules/pacing/rtp_packet_pacer.h | 3 +- modules/pacing/task_queue_paced_sender.cc | 24 +----- modules/pacing/task_queue_paced_sender.h | 3 +- 10 files changed, 58 insertions(+), 157 deletions(-) diff --git a/call/rtp_transport_controller_send.cc b/call/rtp_transport_controller_send.cc index 569ba9d730..2bf24e1994 100644 --- a/call/rtp_transport_controller_send.cc +++ b/call/rtp_transport_controller_send.cc @@ -129,6 +129,8 @@ RtpTransportControllerSend::RtpTransportControllerSend( relay_bandwidth_cap_("relay_cap", DataRate::PlusInfinity()), transport_overhead_bytes_per_packet_(0), network_available_(false), + congestion_window_size_(DataSize::PlusInfinity()), + is_congested_(false), retransmission_rate_limiter_(clock, kRetransmitWindowSizeMs), task_queue_(task_queue_factory->CreateTaskQueue( "rtp_send_controller", @@ -202,6 +204,15 @@ void RtpTransportControllerSend::UpdateControlState() { observer_->OnTargetTransferRate(*update); } +void RtpTransportControllerSend::UpdateCongestedState() { + bool congested = transport_feedback_adapter_.GetOutstandingData() >= + congestion_window_size_; + if (congested != is_congested_) { + is_congested_ = congested; + pacer()->SetCongested(congested); + } +} + RtpPacketPacer* RtpTransportControllerSend::pacer() { if (pacer_settings_.use_task_queue_pacer()) { return task_queue_pacer_.get(); @@ -361,7 +372,8 @@ void RtpTransportControllerSend::OnNetworkRouteChanged( } else { UpdateInitialConstraints(msg.constraints); } - pacer()->UpdateOutstandingData(DataSize::Zero()); + is_congested_ = false; + pacer()->SetCongested(false); }); } } @@ -382,7 +394,8 @@ void RtpTransportControllerSend::OnNetworkAvailability(bool network_available) { } else { pacer()->Pause(); } - pacer()->UpdateOutstandingData(DataSize::Zero()); + is_congested_ = false; + pacer()->SetCongested(false); if (controller_) { control_handler_->SetNetworkAvailability(network_available_); @@ -421,12 +434,11 @@ void RtpTransportControllerSend::OnSentPacket( absl::optional packet_msg = transport_feedback_adapter_.ProcessSentPacket(sent_packet); if (packet_msg) { - // Only update outstanding data in pacer if: + // Only update outstanding data if: // 1. Packet feadback is used. // 2. The packet has not yet received an acknowledgement. // 3. It is not a retransmission of an earlier packet. - pacer()->UpdateOutstandingData( - transport_feedback_adapter_.GetOutstandingData()); + UpdateCongestedState(); if (controller_) PostUpdates(controller_->OnSentPacket(*packet_msg)); } @@ -583,10 +595,8 @@ void RtpTransportControllerSend::OnTransportFeedback( if (controller_) PostUpdates(controller_->OnTransportPacketsFeedback(*feedback_msg)); - // Only update outstanding data in pacer if any packet is first time - // acked. - pacer()->UpdateOutstandingData( - transport_feedback_adapter_.GetOutstandingData()); + // Only update outstanding data if any packet is first time acked. + UpdateCongestedState(); } }); } @@ -678,7 +688,8 @@ void RtpTransportControllerSend::UpdateStreamsConfig() { void RtpTransportControllerSend::PostUpdates(NetworkControlUpdate update) { if (update.congestion_window) { - pacer()->SetCongestionWindow(*update.congestion_window); + congestion_window_size_ = *update.congestion_window; + UpdateCongestedState(); } if (update.pacer_config) { pacer()->SetPacingRates(update.pacer_config->data_rate(), diff --git a/call/rtp_transport_controller_send.h b/call/rtp_transport_controller_send.h index 471ee7f5f4..ba14fdd24f 100644 --- a/call/rtp_transport_controller_send.h +++ b/call/rtp_transport_controller_send.h @@ -158,6 +158,7 @@ class RtpTransportControllerSend final RTC_RUN_ON(task_queue_); void PostUpdates(NetworkControlUpdate update) RTC_RUN_ON(task_queue_); void UpdateControlState() RTC_RUN_ON(task_queue_); + void UpdateCongestedState() RTC_RUN_ON(task_queue_); RtpPacketPacer* pacer(); const RtpPacketPacer* pacer() const; @@ -211,6 +212,9 @@ class RtpTransportControllerSend final RepeatingTaskHandle pacer_queue_update_task_ RTC_GUARDED_BY(task_queue_); RepeatingTaskHandle controller_task_ RTC_GUARDED_BY(task_queue_); + DataSize congestion_window_size_ RTC_GUARDED_BY(task_queue_); + bool is_congested_ RTC_GUARDED_BY(task_queue_); + // Protected by internal locks. RateLimiter retransmission_rate_limiter_; diff --git a/modules/pacing/paced_sender.cc b/modules/pacing/paced_sender.cc index 5eed6c2607..9b419f0380 100644 --- a/modules/pacing/paced_sender.cc +++ b/modules/pacing/paced_sender.cc @@ -87,18 +87,10 @@ void PacedSender::Resume() { } } -void PacedSender::SetCongestionWindow(DataSize congestion_window_size) { +void PacedSender::SetCongested(bool congested) { { MutexLock lock(&mutex_); - pacing_controller_.SetCongestionWindow(congestion_window_size); - } - MaybeWakupProcessThread(); -} - -void PacedSender::UpdateOutstandingData(DataSize outstanding_data) { - { - MutexLock lock(&mutex_); - pacing_controller_.UpdateOutstandingData(outstanding_data); + pacing_controller_.SetCongested(congested); } MaybeWakupProcessThread(); } diff --git a/modules/pacing/paced_sender.h b/modules/pacing/paced_sender.h index 88fd79697d..bf82e78dbe 100644 --- a/modules/pacing/paced_sender.h +++ b/modules/pacing/paced_sender.h @@ -80,8 +80,7 @@ class PacedSender : public RtpPacketPacer, public RtpPacketSender { // Resume sending packets. void Resume() override; - void SetCongestionWindow(DataSize congestion_window_size) override; - void UpdateOutstandingData(DataSize outstanding_data) override; + void SetCongested(bool congested) override; // Sets the pacing rates. Must be called once before packets can be sent. void SetPacingRates(DataRate pacing_rate, DataRate padding_rate) override; diff --git a/modules/pacing/pacing_controller.cc b/modules/pacing/pacing_controller.cc index 9bfe85c0a8..c9628e0eb5 100644 --- a/modules/pacing/pacing_controller.cc +++ b/modules/pacing/pacing_controller.cc @@ -129,8 +129,7 @@ PacingController::PacingController(Clock* clock, last_send_time_(last_process_time_), packet_queue_(last_process_time_), packet_counter_(0), - congestion_window_size_(DataSize::PlusInfinity()), - outstanding_data_(DataSize::Zero()), + congested_(false), queue_time_limit(kMaxExpectedQueueLength), account_for_audio_(false), include_overhead_(false) { @@ -169,29 +168,11 @@ bool PacingController::IsPaused() const { return paused_; } -void PacingController::SetCongestionWindow(DataSize congestion_window_size) { - const bool was_congested = Congested(); - congestion_window_size_ = congestion_window_size; - if (was_congested && !Congested()) { - TimeDelta elapsed_time = UpdateTimeAndGetElapsed(CurrentTime()); - UpdateBudgetWithElapsedTime(elapsed_time); - } -} - -void PacingController::UpdateOutstandingData(DataSize outstanding_data) { - const bool was_congested = Congested(); - outstanding_data_ = outstanding_data; - if (was_congested && !Congested()) { - TimeDelta elapsed_time = UpdateTimeAndGetElapsed(CurrentTime()); - UpdateBudgetWithElapsedTime(elapsed_time); +void PacingController::SetCongested(bool congested) { + if (congested_ && !congested) { + UpdateBudgetWithElapsedTime(UpdateTimeAndGetElapsed(CurrentTime())); } -} - -bool PacingController::Congested() const { - if (congestion_window_size_.IsFinite()) { - return outstanding_data_ >= congestion_window_size_; - } - return false; + congested_ = congested; } bool PacingController::IsProbing() const { @@ -327,7 +308,7 @@ TimeDelta PacingController::UpdateTimeAndGetElapsed(Timestamp now) { } bool PacingController::ShouldSendKeepalive(Timestamp now) const { - if (send_padding_if_silent_ || paused_ || Congested() || + if (send_padding_if_silent_ || paused_ || congested_ || packet_counter_ == 0) { // We send a padding packet every 500 ms to ensure we won't get stuck in // congested state due to no feedback being received. @@ -373,7 +354,7 @@ Timestamp PacingController::NextSendTime() const { } } - if (Congested() || packet_counter_ == 0) { + if (congested_ || packet_counter_ == 0) { // We need to at least send keep-alive packets with some interval. return last_send_time_ + kCongestedPacketInterval; } @@ -623,7 +604,7 @@ DataSize PacingController::PaddingToAdd(DataSize recommended_probe_size, return DataSize::Zero(); } - if (Congested()) { + if (congested_) { // Don't add padding if congested, even if requested for probing. return DataSize::Zero(); } @@ -665,7 +646,7 @@ std::unique_ptr PacingController::GetPendingPacket( !pace_audio_ && packet_queue_.LeadingAudioPacketEnqueueTime().has_value(); bool is_probe = pacing_info.probe_cluster_id != PacedPacketInfo::kNotAProbe; if (!unpaced_audio_packet && !is_probe) { - if (Congested()) { + if (congested_) { // Don't send anything if congested. return nullptr; } @@ -728,7 +709,6 @@ void PacingController::UpdateBudgetWithElapsedTime(TimeDelta delta) { } void PacingController::UpdateBudgetWithSentData(DataSize size) { - outstanding_data_ += size; if (mode_ == ProcessMode::kPeriodic) { media_budget_.UseBudget(size.bytes()); padding_budget_.UseBudget(size.bytes()); diff --git a/modules/pacing/pacing_controller.h b/modules/pacing/pacing_controller.h index f7c5601c91..d0c2e731ff 100644 --- a/modules/pacing/pacing_controller.h +++ b/modules/pacing/pacing_controller.h @@ -97,8 +97,7 @@ class PacingController { void Resume(); // Resume sending packets. bool IsPaused() const; - void SetCongestionWindow(DataSize congestion_window_size); - void UpdateOutstandingData(DataSize outstanding_data); + void SetCongested(bool congested); // Sets the pacing rates. Must be called once before packets can be sent. void SetPacingRates(DataRate pacing_rate, DataRate padding_rate); @@ -145,8 +144,6 @@ class PacingController { // is available. void ProcessPackets(); - bool Congested() const; - bool IsProbing() const; private: @@ -225,8 +222,7 @@ class PacingController { RoundRobinPacketQueue packet_queue_; uint64_t packet_counter_; - DataSize congestion_window_size_; - DataSize outstanding_data_; + bool congested_; TimeDelta queue_time_limit; bool account_for_audio_; diff --git a/modules/pacing/pacing_controller_unittest.cc b/modules/pacing/pacing_controller_unittest.cc index af2ce548e0..c3ab266853 100644 --- a/modules/pacing/pacing_controller_unittest.cc +++ b/modules/pacing/pacing_controller_unittest.cc @@ -399,12 +399,11 @@ TEST_P(PacingControllerFieldTrialTest, CongestionWindowAffectsAudioInTrial) { EXPECT_CALL(callback_, SendPadding).Times(0); PacingController pacer(&clock_, &callback_, nullptr, trials, GetParam()); pacer.SetPacingRates(DataRate::KilobitsPerSec(10000), DataRate::Zero()); - pacer.SetCongestionWindow(DataSize::Bytes(video.packet_size - 100)); - pacer.UpdateOutstandingData(DataSize::Zero()); // Video packet fills congestion window. InsertPacket(&pacer, &video); EXPECT_CALL(callback_, SendPacket).Times(1); ProcessNext(&pacer); + pacer.SetCongested(true); // Audio packet blocked due to congestion. InsertPacket(&pacer, &audio); EXPECT_CALL(callback_, SendPacket).Times(0); @@ -416,7 +415,7 @@ TEST_P(PacingControllerFieldTrialTest, CongestionWindowAffectsAudioInTrial) { ProcessNext(&pacer); // Audio packet unblocked when congestion window clear. ::testing::Mock::VerifyAndClearExpectations(&callback_); - pacer.UpdateOutstandingData(DataSize::Zero()); + pacer.SetCongested(false); EXPECT_CALL(callback_, SendPacket).Times(1); ProcessNext(&pacer); } @@ -427,12 +426,11 @@ TEST_P(PacingControllerFieldTrialTest, const test::ExplicitKeyValueConfig trials(""); PacingController pacer(&clock_, &callback_, nullptr, trials, GetParam()); pacer.SetPacingRates(DataRate::BitsPerSec(10000000), DataRate::Zero()); - pacer.SetCongestionWindow(DataSize::Bytes(800)); - pacer.UpdateOutstandingData(DataSize::Zero()); // Video packet fills congestion window. InsertPacket(&pacer, &video); EXPECT_CALL(callback_, SendPacket).Times(1); ProcessNext(&pacer); + pacer.SetCongested(true); // Audio not blocked due to congestion. InsertPacket(&pacer, &audio); EXPECT_CALL(callback_, SendPacket).Times(1); @@ -1062,21 +1060,18 @@ TEST_P(PacingControllerTest, SendsOnlyPaddingWhenCongested) { uint32_t ssrc = 202020; uint16_t sequence_number = 1000; int kPacketSize = 250; - int kCongestionWindow = kPacketSize * 10; - pacer_->UpdateOutstandingData(DataSize::Zero()); - pacer_->SetCongestionWindow(DataSize::Bytes(kCongestionWindow)); - int sent_data = 0; - while (sent_data < kCongestionWindow) { - sent_data += kPacketSize; - SendAndExpectPacket(RtpPacketMediaType::kVideo, ssrc, sequence_number++, - clock_.TimeInMilliseconds(), kPacketSize); - AdvanceTimeAndProcess(); - } + // Send an initial packet so we have a last send time. + SendAndExpectPacket(RtpPacketMediaType::kVideo, ssrc, sequence_number++, + clock_.TimeInMilliseconds(), kPacketSize); + AdvanceTimeAndProcess(); ::testing::Mock::VerifyAndClearExpectations(&callback_); + + // Set congested state, we should not send anything until the 500ms since + // last send time limit for keep-alives is triggered. EXPECT_CALL(callback_, SendPacket).Times(0); EXPECT_CALL(callback_, SendPadding).Times(0); - + pacer_->SetCongested(true); size_t blocked_packets = 0; int64_t expected_time_until_padding = 500; while (expected_time_until_padding > 5) { @@ -1087,6 +1082,7 @@ TEST_P(PacingControllerTest, SendsOnlyPaddingWhenCongested) { pacer_->ProcessPackets(); expected_time_until_padding -= 5; } + ::testing::Mock::VerifyAndClearExpectations(&callback_); EXPECT_CALL(callback_, SendPadding(1)).WillOnce(Return(1)); EXPECT_CALL(callback_, SendPacket(_, _, _, _, true)).Times(1); @@ -1105,15 +1101,13 @@ TEST_P(PacingControllerTest, DoesNotAllowOveruseAfterCongestion) { // to be sent in a row. pacer_->SetPacingRates(DataRate::BitsPerSec(400 * 8 * 1000 / 5), DataRate::Zero()); - // The congestion window is small enough to only let one packet through. - pacer_->SetCongestionWindow(DataSize::Bytes(800)); - pacer_->UpdateOutstandingData(DataSize::Zero()); // Not yet budget limited or congested, packet is sent. Send(RtpPacketMediaType::kVideo, ssrc, seq_num++, now_ms(), size); EXPECT_CALL(callback_, SendPacket).Times(1); clock_.AdvanceTimeMilliseconds(5); pacer_->ProcessPackets(); // Packet blocked due to congestion. + pacer_->SetCongested(true); Send(RtpPacketMediaType::kVideo, ssrc, seq_num++, now_ms(), size); EXPECT_CALL(callback_, SendPacket).Times(0); clock_.AdvanceTimeMilliseconds(5); @@ -1127,7 +1121,7 @@ TEST_P(PacingControllerTest, DoesNotAllowOveruseAfterCongestion) { Send(RtpPacketMediaType::kVideo, ssrc, seq_num++, now_ms(), size); EXPECT_CALL(callback_, SendPacket).Times(1); clock_.AdvanceTimeMilliseconds(5); - pacer_->UpdateOutstandingData(DataSize::Zero()); + pacer_->SetCongested(false); pacer_->ProcessPackets(); // Should be blocked due to budget limitation as congestion has be removed. Send(RtpPacketMediaType::kVideo, ssrc, seq_num++, now_ms(), size); @@ -1136,61 +1130,6 @@ TEST_P(PacingControllerTest, DoesNotAllowOveruseAfterCongestion) { pacer_->ProcessPackets(); } -TEST_P(PacingControllerTest, ResumesSendingWhenCongestionEnds) { - uint32_t ssrc = 202020; - uint16_t sequence_number = 1000; - int64_t kPacketSize = 250; - int64_t kCongestionCount = 10; - int64_t kCongestionWindow = kPacketSize * kCongestionCount; - int64_t kCongestionTimeMs = 1000; - - pacer_->UpdateOutstandingData(DataSize::Zero()); - pacer_->SetCongestionWindow(DataSize::Bytes(kCongestionWindow)); - int sent_data = 0; - while (sent_data < kCongestionWindow) { - sent_data += kPacketSize; - SendAndExpectPacket(RtpPacketMediaType::kVideo, ssrc, sequence_number++, - clock_.TimeInMilliseconds(), kPacketSize); - clock_.AdvanceTimeMilliseconds(5); - pacer_->ProcessPackets(); - } - ::testing::Mock::VerifyAndClearExpectations(&callback_); - EXPECT_CALL(callback_, SendPacket).Times(0); - int unacked_packets = 0; - for (int duration = 0; duration < kCongestionTimeMs; duration += 5) { - Send(RtpPacketMediaType::kVideo, ssrc, sequence_number++, - clock_.TimeInMilliseconds(), kPacketSize); - unacked_packets++; - clock_.AdvanceTimeMilliseconds(5); - pacer_->ProcessPackets(); - } - ::testing::Mock::VerifyAndClearExpectations(&callback_); - - // First mark half of the congested packets as cleared and make sure that just - // as many are sent - int ack_count = kCongestionCount / 2; - EXPECT_CALL(callback_, SendPacket(ssrc, _, _, false, _)).Times(ack_count); - pacer_->UpdateOutstandingData( - DataSize::Bytes(kCongestionWindow - kPacketSize * ack_count)); - - for (int duration = 0; duration < kCongestionTimeMs; duration += 5) { - clock_.AdvanceTimeMilliseconds(5); - pacer_->ProcessPackets(); - } - unacked_packets -= ack_count; - ::testing::Mock::VerifyAndClearExpectations(&callback_); - - // Second make sure all packets are sent if sent packets are continuously - // marked as acked. - EXPECT_CALL(callback_, SendPacket(ssrc, _, _, false, _)) - .Times(unacked_packets); - for (int duration = 0; duration < kCongestionTimeMs; duration += 5) { - pacer_->UpdateOutstandingData(DataSize::Zero()); - clock_.AdvanceTimeMilliseconds(5); - pacer_->ProcessPackets(); - } -} - TEST_P(PacingControllerTest, Pause) { uint32_t ssrc_low_priority = 12345; uint32_t ssrc = 12346; diff --git a/modules/pacing/rtp_packet_pacer.h b/modules/pacing/rtp_packet_pacer.h index 3dc2b27612..a201838858 100644 --- a/modules/pacing/rtp_packet_pacer.h +++ b/modules/pacing/rtp_packet_pacer.h @@ -34,8 +34,7 @@ class RtpPacketPacer { // Resume sending packets. virtual void Resume() = 0; - virtual void SetCongestionWindow(DataSize congestion_window_size) = 0; - virtual void UpdateOutstandingData(DataSize outstanding_data) = 0; + virtual void SetCongested(bool congested) = 0; // Sets the pacing rates. Must be called once before packets can be sent. virtual void SetPacingRates(DataRate pacing_rate, DataRate padding_rate) = 0; diff --git a/modules/pacing/task_queue_paced_sender.cc b/modules/pacing/task_queue_paced_sender.cc index 620a54135e..c2b376cfa7 100644 --- a/modules/pacing/task_queue_paced_sender.cc +++ b/modules/pacing/task_queue_paced_sender.cc @@ -105,28 +105,10 @@ void TaskQueuePacedSender::Resume() { }); } -void TaskQueuePacedSender::SetCongestionWindow( - DataSize congestion_window_size) { - task_queue_.PostTask([this, congestion_window_size]() { +void TaskQueuePacedSender::SetCongested(bool congested) { + task_queue_.PostTask([this, congested]() { RTC_DCHECK_RUN_ON(&task_queue_); - pacing_controller_.SetCongestionWindow(congestion_window_size); - MaybeProcessPackets(Timestamp::MinusInfinity()); - }); -} - -void TaskQueuePacedSender::UpdateOutstandingData(DataSize outstanding_data) { - if (task_queue_.IsCurrent()) { - RTC_DCHECK_RUN_ON(&task_queue_); - // Fast path since this can be called once per sent packet while on the - // task queue. - pacing_controller_.UpdateOutstandingData(outstanding_data); - MaybeProcessPackets(Timestamp::MinusInfinity()); - return; - } - - task_queue_.PostTask([this, outstanding_data]() { - RTC_DCHECK_RUN_ON(&task_queue_); - pacing_controller_.UpdateOutstandingData(outstanding_data); + pacing_controller_.SetCongested(congested); MaybeProcessPackets(Timestamp::MinusInfinity()); }); } diff --git a/modules/pacing/task_queue_paced_sender.h b/modules/pacing/task_queue_paced_sender.h index 61a625521d..33d7b5e3f4 100644 --- a/modules/pacing/task_queue_paced_sender.h +++ b/modules/pacing/task_queue_paced_sender.h @@ -86,8 +86,7 @@ class TaskQueuePacedSender : public RtpPacketPacer, public RtpPacketSender { // Resume sending packets. void Resume() override; - void SetCongestionWindow(DataSize congestion_window_size) override; - void UpdateOutstandingData(DataSize outstanding_data) override; + void SetCongested(bool congested) override; // Sets the pacing rates. Must be called once before packets can be sent. void SetPacingRates(DataRate pacing_rate, DataRate padding_rate) override; From 554bb39998b1a75eb9e15174696707a10ac634a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Bostr=C3=B6m?= Date: Wed, 16 Mar 2022 10:16:29 +0100 Subject: [PATCH 195/847] Reland "Experimentally reduce TaskQueuePacedSender's delayed task precision." MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a reland of commit 43a69b3f46059b103c35079744dc09a0e2bb2948 Original change's description: > Experimentally reduce TaskQueuePacedSender's delayed task precision. > > This CL reduces the delayed task precision of non-probes in accordance > with DD go/slacked-task-queue-paced-sender. The precision is only > deduced if field trial "WebRTC-SlackedTaskQueuePacedSender" is enabled > though. > > Bug: webrtc:13824 > Change-Id: I37e53b24e343f4f08059be08a3cda74f5484cc05 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255341 > Reviewed-by: Erik Språng > Commit-Queue: Henrik Boström > Cr-Commit-Position: refs/heads/main@{#36214} Bug: webrtc:13824 Change-Id: I86cace6f4f6bf23d51c75b3d18f8d24fff0f5b74 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255826 Auto-Submit: Mirko Bonadei Reviewed-by: Henrik Boström Reviewed-by: Erik Språng Commit-Queue: Erik Språng Commit-Queue: Henrik Boström Cr-Commit-Position: refs/heads/main@{#36221} --- modules/pacing/BUILD.gn | 3 + modules/pacing/task_queue_paced_sender.cc | 26 ++- modules/pacing/task_queue_paced_sender.h | 11 ++ .../task_queue_paced_sender_unittest.cc | 174 ++++++++++++++++++ 4 files changed, 211 insertions(+), 3 deletions(-) diff --git a/modules/pacing/BUILD.gn b/modules/pacing/BUILD.gn index 4064c12151..90e0eb7134 100644 --- a/modules/pacing/BUILD.gn +++ b/modules/pacing/BUILD.gn @@ -35,6 +35,7 @@ rtc_library("pacing") { "..:module_api", "../../api:function_view", "../../api:sequence_checker", + "../../api:webrtc_key_value_config", "../../api/rtc_event_log", "../../api/task_queue:task_queue", "../../api/transport:field_trial_based_config", @@ -93,6 +94,7 @@ if (rtc_include_tests) { deps = [ ":interval_budget", ":pacing", + "../../api/task_queue:task_queue", "../../api/transport:network_control", "../../api/units:data_rate", "../../api/units:time_delta", @@ -101,6 +103,7 @@ if (rtc_include_tests) { "../../rtc_base:rtc_base_approved", "../../rtc_base:rtc_base_tests_utils", "../../rtc_base/experiments:alr_experiment", + "../../rtc_base/task_utils:to_queued_task", "../../system_wrappers", "../../test:explicit_key_value_config", "../../test:scoped_key_value_config", diff --git a/modules/pacing/task_queue_paced_sender.cc b/modules/pacing/task_queue_paced_sender.cc index c2b376cfa7..4294bd86ab 100644 --- a/modules/pacing/task_queue_paced_sender.cc +++ b/modules/pacing/task_queue_paced_sender.cc @@ -12,6 +12,7 @@ #include #include + #include "absl/memory/memory.h" #include "rtc_base/checks.h" #include "rtc_base/event.h" @@ -21,6 +22,13 @@ namespace webrtc { +namespace { + +constexpr const char* kSlackedTaskQueuePacedSenderFieldTrial = + "WebRTC-SlackedTaskQueuePacedSender"; + +} // namespace + TaskQueuePacedSender::TaskQueuePacedSender( Clock* clock, PacingController::PacketSender* packet_sender, @@ -46,8 +54,13 @@ TaskQueuePacedSender::TaskQueuePacedSender( TimeDelta max_hold_back_window, int max_hold_back_window_in_packets) : clock_(clock), - max_hold_back_window_(max_hold_back_window), - max_hold_back_window_in_packets_(max_hold_back_window_in_packets), + allow_low_precision_( + field_trials.IsEnabled(kSlackedTaskQueuePacedSenderFieldTrial)), + max_hold_back_window_(allow_low_precision_ + ? PacingController::kMinSleepTime + : max_hold_back_window), + max_hold_back_window_in_packets_( + allow_low_precision_ ? 0 : max_hold_back_window_in_packets), pacing_controller_(clock, packet_sender, event_log, @@ -269,7 +282,14 @@ void TaskQueuePacedSender::MaybeProcessPackets( // Set a new scheduled process time and post a delayed task. next_process_time_ = next_process_time; - task_queue_.PostDelayedHighPrecisionTask( + // Prefer low precision if allowed and not probing. + TaskQueueBase::DelayPrecision precision = + allow_low_precision_ && !pacing_controller_.IsProbing() + ? TaskQueueBase::DelayPrecision::kLow + : TaskQueueBase::DelayPrecision::kHigh; + + task_queue_.PostDelayedTaskWithPrecision( + precision, [this, next_process_time]() { MaybeProcessPackets(next_process_time); }, time_to_next_process->ms()); } diff --git a/modules/pacing/task_queue_paced_sender.h b/modules/pacing/task_queue_paced_sender.h index 33d7b5e3f4..5c8dba7a92 100644 --- a/modules/pacing/task_queue_paced_sender.h +++ b/modules/pacing/task_queue_paced_sender.h @@ -26,6 +26,7 @@ #include "api/units/data_size.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" +#include "api/webrtc_key_value_config.h" #include "modules/pacing/pacing_controller.h" #include "modules/pacing/rtp_packet_pacer.h" #include "modules/rtp_rtcp/source/rtp_packet_to_send.h" @@ -143,6 +144,16 @@ class TaskQueuePacedSender : public RtpPacketPacer, public RtpPacketSender { Stats GetStats() const; Clock* const clock_; + // If `kSlackedTaskQueuePacedSenderFieldTrial` is enabled, delayed tasks + // invoking MaybeProcessPackets() are scheduled using low precision instead of + // high precision, resulting in less idle wake ups and packets being sent in + // bursts if the `task_queue_` implementation supports slack. + // + // When probing, high precision is used regardless of `allow_low_precision_` + // to ensure good bandwidth estimation. + const bool allow_low_precision_; + // The holdback window prevents too frequent delayed MaybeProcessPackets() + // calls. These are only applicable if `allow_low_precision_` is false. const TimeDelta max_hold_back_window_; const int max_hold_back_window_in_packets_; diff --git a/modules/pacing/task_queue_paced_sender_unittest.cc b/modules/pacing/task_queue_paced_sender_unittest.cc index a22ff6d164..cb6d6156b4 100644 --- a/modules/pacing/task_queue_paced_sender_unittest.cc +++ b/modules/pacing/task_queue_paced_sender_unittest.cc @@ -11,15 +11,19 @@ #include "modules/pacing/task_queue_paced_sender.h" #include +#include #include #include #include #include #include +#include "api/task_queue/task_queue_base.h" #include "api/transport/network_types.h" +#include "api/units/data_rate.h" #include "modules/pacing/packet_router.h" #include "modules/utility/include/mock/mock_process_thread.h" +#include "rtc_base/task_utils/to_queued_task.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/scoped_key_value_config.h" @@ -76,6 +80,88 @@ std::vector> GeneratePadding( return padding_packets; } +class TaskQueueWithFakePrecisionFactory : public TaskQueueFactory { + public: + explicit TaskQueueWithFakePrecisionFactory( + TaskQueueFactory* task_queue_factory) + : task_queue_factory_(task_queue_factory) {} + + std::unique_ptr CreateTaskQueue( + absl::string_view name, + Priority priority) const override { + return std::unique_ptr( + new TaskQueueWithFakePrecision( + const_cast(this), + task_queue_factory_)); + } + + int delayed_low_precision_count() const { + return delayed_low_precision_count_; + } + int delayed_high_precision_count() const { + return delayed_high_precision_count_; + } + + private: + friend class TaskQueueWithFakePrecision; + + class TaskQueueWithFakePrecision : public TaskQueueBase { + public: + TaskQueueWithFakePrecision( + TaskQueueWithFakePrecisionFactory* parent_factory, + TaskQueueFactory* task_queue_factory) + : parent_factory_(parent_factory), + task_queue_(task_queue_factory->CreateTaskQueue( + "TaskQueueWithFakePrecision", + TaskQueueFactory::Priority::NORMAL)) {} + ~TaskQueueWithFakePrecision() override {} + + void Delete() override { + // `task_queue_->Delete()` is implicitly called in the destructor due to + // TaskQueueDeleter. + delete this; + } + void PostTask(std::unique_ptr task) override { + task_queue_->PostTask( + ToQueuedTask([this, task = std::move(task)]() mutable { + RunTask(std::move(task)); + })); + } + void PostDelayedTask(std::unique_ptr task, + uint32_t milliseconds) override { + ++parent_factory_->delayed_low_precision_count_; + task_queue_->PostDelayedTask( + ToQueuedTask([this, task = std::move(task)]() mutable { + RunTask(std::move(task)); + }), + milliseconds); + } + void PostDelayedHighPrecisionTask(std::unique_ptr task, + uint32_t milliseconds) override { + ++parent_factory_->delayed_high_precision_count_; + task_queue_->PostDelayedHighPrecisionTask( + ToQueuedTask([this, task = std::move(task)]() mutable { + RunTask(std::move(task)); + }), + milliseconds); + } + + private: + void RunTask(std::unique_ptr task) { + CurrentTaskQueueSetter set_current(this); + if (!task->Run()) + task.release(); + } + + TaskQueueWithFakePrecisionFactory* parent_factory_; + std::unique_ptr task_queue_; + }; + + TaskQueueFactory* task_queue_factory_; + std::atomic delayed_low_precision_count_ = 0u; + std::atomic delayed_high_precision_count_ = 0u; +}; + } // namespace namespace test { @@ -597,5 +683,93 @@ TEST(TaskQueuePacedSenderTest, Stats) { EXPECT_TRUE(pacer.ExpectedQueueTime().IsZero()); } +TEST(TaskQueuePacedSenderTest, HighPrecisionPacingWhenSlackIsDisabled) { + test::ScopedKeyValueConfig experiments( + "WebRTC-SlackedTaskQueuePacedSender/Disabled/"); + + GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); + TaskQueueWithFakePrecisionFactory task_queue_factory( + time_controller.GetTaskQueueFactory()); + + MockPacketRouter packet_router; + TaskQueuePacedSender pacer( + time_controller.GetClock(), &packet_router, /*event_log=*/nullptr, + experiments, &task_queue_factory, PacingController::kMinSleepTime, + kNoPacketHoldback); + + // Send enough packets (covering one second) that pacing is triggered, i.e. + // delayed tasks being scheduled. + static constexpr size_t kPacketsToSend = 42; + static constexpr DataRate kPacingRate = + DataRate::BitsPerSec(kDefaultPacketSize * 8 * kPacketsToSend); + pacer.SetPacingRates(kPacingRate, DataRate::Zero()); + pacer.EnsureStarted(); + pacer.EnqueuePackets( + GeneratePackets(RtpPacketMediaType::kVideo, kPacketsToSend)); + // Expect all of them to be sent. + size_t packets_sent = 0; + EXPECT_CALL(packet_router, SendPacket) + .WillRepeatedly( + [&](std::unique_ptr packet, + const PacedPacketInfo& cluster_info) { ++packets_sent; }); + time_controller.AdvanceTime(TimeDelta::Seconds(1)); + EXPECT_EQ(packets_sent, kPacketsToSend); + + // Expect pacing to make use of high precision. + EXPECT_EQ(task_queue_factory.delayed_low_precision_count(), 0); + EXPECT_GT(task_queue_factory.delayed_high_precision_count(), 0); + + // Create probe cluster which is also high precision. + pacer.CreateProbeCluster(kPacingRate, 123); + pacer.EnqueuePackets(GeneratePackets(RtpPacketMediaType::kVideo, 1)); + time_controller.AdvanceTime(TimeDelta::Seconds(1)); + EXPECT_EQ(task_queue_factory.delayed_low_precision_count(), 0); + EXPECT_GT(task_queue_factory.delayed_high_precision_count(), 0); +} + +TEST(TaskQueuePacedSenderTest, LowPrecisionPacingWhenSlackIsEnabled) { + test::ScopedKeyValueConfig experiments( + "WebRTC-SlackedTaskQueuePacedSender/Enabled/"); + + GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); + TaskQueueWithFakePrecisionFactory task_queue_factory( + time_controller.GetTaskQueueFactory()); + + MockPacketRouter packet_router; + TaskQueuePacedSender pacer( + time_controller.GetClock(), &packet_router, /*event_log=*/nullptr, + experiments, &task_queue_factory, PacingController::kMinSleepTime, + kNoPacketHoldback); + + // Send enough packets (covering one second) that pacing is triggered, i.e. + // delayed tasks being scheduled. + static constexpr size_t kPacketsToSend = 42; + static constexpr DataRate kPacingRate = + DataRate::BitsPerSec(kDefaultPacketSize * 8 * kPacketsToSend); + pacer.SetPacingRates(kPacingRate, DataRate::Zero()); + pacer.EnsureStarted(); + pacer.EnqueuePackets( + GeneratePackets(RtpPacketMediaType::kVideo, kPacketsToSend)); + // Expect all of them to be sent. + size_t packets_sent = 0; + EXPECT_CALL(packet_router, SendPacket) + .WillRepeatedly( + [&](std::unique_ptr packet, + const PacedPacketInfo& cluster_info) { ++packets_sent; }); + time_controller.AdvanceTime(TimeDelta::Seconds(1)); + EXPECT_EQ(packets_sent, kPacketsToSend); + + // Expect pacing to make use of low precision. + EXPECT_GT(task_queue_factory.delayed_low_precision_count(), 0); + EXPECT_EQ(task_queue_factory.delayed_high_precision_count(), 0); + + // Create probe cluster, which uses high precision despite regular pacing + // being low precision. + pacer.CreateProbeCluster(kPacingRate, 123); + pacer.EnqueuePackets(GeneratePackets(RtpPacketMediaType::kVideo, 1)); + time_controller.AdvanceTime(TimeDelta::Seconds(1)); + EXPECT_GT(task_queue_factory.delayed_high_precision_count(), 0); +} + } // namespace test } // namespace webrtc From 026cfa3c8bde814ebbe5e94d0803dfd173c9bb02 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Wed, 16 Mar 2022 09:01:20 -0700 Subject: [PATCH 196/847] Roll chromium_revision 674598587a..3a6fd7d38b (981504:981666) Change log: https://chromium.googlesource.com/chromium/src/+log/674598587a..3a6fd7d38b Full diff: https://chromium.googlesource.com/chromium/src/+/674598587a..3a6fd7d38b Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/cff566f022..08d4ca7d7a * src/build: https://chromium.googlesource.com/chromium/src/build/+log/25cfbb99b6..cef7fc3d51 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/a1933158c9..d4729beee3 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/3a3158679d..c60f74e7ac * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/3c07994980..c671395e43 * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/ed54518ee4..86fc023993 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/da243b94e8..57304806ce DEPS diff: https://chromium.googlesource.com/chromium/src/+/674598587a..3a6fd7d38b/DEPS No update to Clang. BUG=None Change-Id: Ia8ea316cc4a9e36f82bf36ee5138d8b9a31eacd1 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255841 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36222} --- DEPS | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/DEPS b/DEPS index 1690b135eb..3f1e2f2a2e 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': '674598587ab3c360318fb5c696d87f941770b072', + 'chromium_revision': '3a6fd7d38b62d44a747a8d385cd6f1402039ebb4', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@cff566f02292a8fa818cc7cceff5df0f1528fc80', + 'https://chromium.googlesource.com/chromium/src/base@08d4ca7d7a079065468d9ec65496ea52cafebaa9', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@25cfbb99b680ee76320102c35488b5b737cac2c4', + 'https://chromium.googlesource.com/chromium/src/build@cef7fc3d5135ada930fb08bcebb97545063cd69e', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@113dd1badbcbffea108a8c95ac7c89c22bfd25f3', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@a1933158c9430a912583d0d280ff826d4bad4fd2', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@d4729beee3f8efb012536f83c79c18aad41e38b7', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@3a3158679d7f58d1c2d10de9c7c350d4971ce811', + 'https://chromium.googlesource.com/chromium/src/testing@c60f74e7ace93e7e815d617193d1de13b1c1954f', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@3c0799498064c0d20e7a5f2ac36c92506a65b931', + 'https://chromium.googlesource.com/chromium/src/third_party@c671395e43a423e2abecd3f2cb7a750ff58aab4f', 'src/buildtools/linux64': { 'packages': [ @@ -231,7 +231,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@ed54518ee42cbdec9fb90a12c4b256f2c5f8d22e', + 'https://android.googlesource.com/platform/external/perfetto.git@86fc023993c5b9b98d2333c389af8c2a3026ffcc', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -288,7 +288,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@da243b94e839d8ecd6db9186ac891d4d54d21a76', + 'https://chromium.googlesource.com/chromium/src/tools@57304806ceca8cb833da780754384840ff84e9e6', 'src/third_party/accessibility_test_framework': { 'packages': [ From 0f5b7ebcca575228ee2950c751312163c2500b18 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Wed, 16 Mar 2022 13:01:11 -0700 Subject: [PATCH 197/847] Roll chromium_revision 3a6fd7d38b..6a5628a6c8 (981666:981812) Change log: https://chromium.googlesource.com/chromium/src/+log/3a6fd7d38b..6a5628a6c8 Full diff: https://chromium.googlesource.com/chromium/src/+/3a6fd7d38b..6a5628a6c8 Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/08d4ca7d7a..96393bcabe * src/build: https://chromium.googlesource.com/chromium/src/build/+log/cef7fc3d51..0bc7d6146c * src/buildtools/third_party/libc++abi/trunk: https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git/+log/a897d0f3f8..93b8dcd57b * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/d4729beee3..f99fb26981 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/c60f74e7ac..31cc931e68 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/c671395e43..d0c465dfcd * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/86fc023993..02e3224f3e * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/57304806ce..751bd4d6d1 DEPS diff: https://chromium.googlesource.com/chromium/src/+/3a6fd7d38b..6a5628a6c8/DEPS No update to Clang. BUG=None Change-Id: Ibb7632f0ca3f2afcaac61850a6e2b828e0c60851 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255880 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36223} --- DEPS | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/DEPS b/DEPS index 3f1e2f2a2e..1d0bda569d 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': '3a6fd7d38b62d44a747a8d385cd6f1402039ebb4', + 'chromium_revision': '6a5628a6c8a634ebb76ce4d4547a8ee312861817', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@08d4ca7d7a079065468d9ec65496ea52cafebaa9', + 'https://chromium.googlesource.com/chromium/src/base@96393bcabe833399896c90557bf79217065d4e92', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@cef7fc3d5135ada930fb08bcebb97545063cd69e', + 'https://chromium.googlesource.com/chromium/src/build@0bc7d6146c725e9d540dea46074bdc03040453a6', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@113dd1badbcbffea108a8c95ac7c89c22bfd25f3', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@d4729beee3f8efb012536f83c79c18aad41e38b7', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@f99fb26981e60b7412d9c3e02cb1d76c0b941dc9', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@c60f74e7ace93e7e815d617193d1de13b1c1954f', + 'https://chromium.googlesource.com/chromium/src/testing@31cc931e68f4afaf02c74ceb7d2433001ed10870', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@c671395e43a423e2abecd3f2cb7a750ff58aab4f', + 'https://chromium.googlesource.com/chromium/src/third_party@d0c465dfcddbcce795fcdc35dbdeec694b327263', 'src/buildtools/linux64': { 'packages': [ @@ -78,7 +78,7 @@ deps = { 'src/buildtools/third_party/libc++/trunk': 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxx.git@79a2e924d96e2fc1e4b937c42efd08898fa472d7', 'src/buildtools/third_party/libc++abi/trunk': - 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git@a897d0f3f8e8c28ac2abf848f3b695b724409298', + 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git@93b8dcd57bd8ebe201ec24f7257339988ed2ef7c', 'src/buildtools/third_party/libunwind/trunk': 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git@d1c7f92b8b0bff8d9f710ca40e44563a63db376e', @@ -231,7 +231,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@86fc023993c5b9b98d2333c389af8c2a3026ffcc', + 'https://android.googlesource.com/platform/external/perfetto.git@02e3224f3e0a7f5f01c6daa4b8139a131be2e224', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -288,7 +288,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@57304806ceca8cb833da780754384840ff84e9e6', + 'https://chromium.googlesource.com/chromium/src/tools@751bd4d6d111a85fb6fb3cc2e08dbf41e60fecce', 'src/third_party/accessibility_test_framework': { 'packages': [ From 347f9b07b97366af5172aff24cdd8eb45ec81ba6 Mon Sep 17 00:00:00 2001 From: Sunggook Chue Date: Mon, 14 Mar 2022 11:49:25 -0700 Subject: [PATCH 198/847] getDisplayMedia shows black window on Youtube PiP in Windows. getDisplayMedia capture the view of the screens and windows in the capture dialog, but the issue is that captured view of the Youtube somehow is blank. It repros only in certain circumstances, for example, Canary channel. If user reinstall the Canary as fresh new, we observed that it doesn't repro. Cause: We aren't sure what's cause of this one yet. Solution: We decided to provide fallback WGC capturer when the main capturer (GDI) shows blank. WGC could show yellow outline in prior Win11 OS, but yellow outline looks better than blank. The blank detector and fallback capturer are what screen capturer already supported. So, the solution will follow similar pattern in the window capturer. Bug: webrtc:13726 Change-Id: I620c817d259d7bb5c295adab11c4444349ab1c6c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252625 Reviewed-by: Alexander Cooper Commit-Queue: Alexander Cooper Cr-Commit-Position: refs/heads/main@{#36224} --- ...blank_detector_desktop_capturer_wrapper.cc | 14 ++++++++-- .../blank_detector_desktop_capturer_wrapper.h | 7 ++++- .../desktop_capture/desktop_capture_options.h | 12 +++++++++ .../desktop_capture/win/wgc_capturer_win.cc | 24 +++++++++++++---- .../desktop_capture/win/wgc_capturer_win.h | 11 ++++++-- .../desktop_capture/window_capturer_win.cc | 27 ++++++++++++++++++- 6 files changed, 84 insertions(+), 11 deletions(-) diff --git a/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc b/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc index ca3a89f49b..c20843414b 100644 --- a/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc +++ b/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.cc @@ -23,8 +23,11 @@ namespace webrtc { BlankDetectorDesktopCapturerWrapper::BlankDetectorDesktopCapturerWrapper( std::unique_ptr capturer, - RgbaColor blank_pixel) - : capturer_(std::move(capturer)), blank_pixel_(blank_pixel) { + RgbaColor blank_pixel, + bool check_per_capture) + : capturer_(std::move(capturer)), + blank_pixel_(blank_pixel), + check_per_capture_(check_per_capture) { RTC_DCHECK(capturer_); } @@ -56,6 +59,13 @@ bool BlankDetectorDesktopCapturerWrapper::GetSourceList(SourceList* sources) { } bool BlankDetectorDesktopCapturerWrapper::SelectSource(SourceId id) { + if (check_per_capture_) { + // If we start capturing a new source, we must reset these members + // so we don't short circuit the blank detection logic. + is_first_frame_ = true; + non_blank_frame_received_ = false; + } + return capturer_->SelectSource(id); } diff --git a/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.h b/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.h index f5c2ce201b..d10f9cf725 100644 --- a/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.h +++ b/modules/desktop_capture/blank_detector_desktop_capturer_wrapper.h @@ -34,7 +34,8 @@ class BlankDetectorDesktopCapturerWrapper final // takes ownership of `capturer`. The `blank_pixel` is the unmodified color // returned by the `capturer`. BlankDetectorDesktopCapturerWrapper(std::unique_ptr capturer, - RgbaColor blank_pixel); + RgbaColor blank_pixel, + bool check_per_capture = false); ~BlankDetectorDesktopCapturerWrapper() override; // DesktopCapturer interface. @@ -70,6 +71,10 @@ class BlankDetectorDesktopCapturerWrapper final // Whether current frame is the first frame. bool is_first_frame_ = true; + // Blank inspection is made per capture instead of once for all + // screens or windows. + bool check_per_capture_ = false; + DesktopCapturer::Callback* callback_ = nullptr; }; diff --git a/modules/desktop_capture/desktop_capture_options.h b/modules/desktop_capture/desktop_capture_options.h index c6bc52f8a7..dd3cde0145 100644 --- a/modules/desktop_capture/desktop_capture_options.h +++ b/modules/desktop_capture/desktop_capture_options.h @@ -163,6 +163,17 @@ class RTC_EXPORT DesktopCaptureOptions { // precedence over the cropping, directx, and magnification flags. bool allow_wgc_capturer() const { return allow_wgc_capturer_; } void set_allow_wgc_capturer(bool allow) { allow_wgc_capturer_ = allow; } + + // This flag enables the WGC capturer for fallback capturer. + // The flag is useful when the first capturer (eg. WindowCapturerWinGdi) is + // unreliable in certain devices where WGC is supported, but not used by + // default. + bool allow_wgc_capturer_fallback() const { + return allow_wgc_capturer_fallback_; + } + void set_allow_wgc_capturer_fallback(bool allow) { + allow_wgc_capturer_fallback_ = allow; + } #endif // defined(RTC_ENABLE_WIN_WGC) #endif // defined(WEBRTC_WIN) @@ -203,6 +214,7 @@ class RTC_EXPORT DesktopCaptureOptions { bool allow_cropping_window_capturer_ = false; #if defined(RTC_ENABLE_WIN_WGC) bool allow_wgc_capturer_ = false; + bool allow_wgc_capturer_fallback_ = false; #endif #endif #if defined(WEBRTC_USE_X11) diff --git a/modules/desktop_capture/win/wgc_capturer_win.cc b/modules/desktop_capture/win/wgc_capturer_win.cc index 9b2cce4a8e..35d7bd1cec 100644 --- a/modules/desktop_capture/win/wgc_capturer_win.cc +++ b/modules/desktop_capture/win/wgc_capturer_win.cc @@ -47,18 +47,22 @@ void RecordWgcCapturerResult(WgcCapturerResult error) { WgcCapturerWin::WgcCapturerWin( std::unique_ptr source_factory, - std::unique_ptr source_enumerator) + std::unique_ptr source_enumerator, + bool allow_delayed_capturable_check) : source_factory_(std::move(source_factory)), - source_enumerator_(std::move(source_enumerator)) {} + source_enumerator_(std::move(source_enumerator)), + allow_delayed_capturable_check_(allow_delayed_capturable_check) {} WgcCapturerWin::~WgcCapturerWin() = default; // static std::unique_ptr WgcCapturerWin::CreateRawWindowCapturer( - const DesktopCaptureOptions& options) { + const DesktopCaptureOptions& options, + bool allow_delayed_capturable_check) { return std::make_unique( std::make_unique(), std::make_unique( - options.enumerate_current_process_windows())); + options.enumerate_current_process_windows()), + allow_delayed_capturable_check); } // static @@ -66,7 +70,7 @@ std::unique_ptr WgcCapturerWin::CreateRawScreenCapturer( const DesktopCaptureOptions& options) { return std::make_unique( std::make_unique(), - std::make_unique()); + std::make_unique(), false); } bool WgcCapturerWin::GetSourceList(SourceList* sources) { @@ -75,6 +79,9 @@ bool WgcCapturerWin::GetSourceList(SourceList* sources) { bool WgcCapturerWin::SelectSource(DesktopCapturer::SourceId id) { capture_source_ = source_factory_->CreateCaptureSource(id); + if (allow_delayed_capturable_check_) + return true; + return capture_source_->IsCapturable(); } @@ -135,6 +142,13 @@ void WgcCapturerWin::CaptureFrame() { return; } + if (allow_delayed_capturable_check_ && !capture_source_->IsCapturable()) { + RTC_LOG(LS_ERROR) << "Source is not capturable."; + callback_->OnCaptureResult(DesktopCapturer::Result::ERROR_PERMANENT, + /*frame=*/nullptr); + return; + } + int64_t capture_start_time_nanos = rtc::TimeNanos(); HRESULT hr; diff --git a/modules/desktop_capture/win/wgc_capturer_win.h b/modules/desktop_capture/win/wgc_capturer_win.h index 34e6874dc0..0eef5283c7 100644 --- a/modules/desktop_capture/win/wgc_capturer_win.h +++ b/modules/desktop_capture/win/wgc_capturer_win.h @@ -80,7 +80,8 @@ class ScreenEnumerator final : public SourceEnumerator { class WgcCapturerWin : public DesktopCapturer { public: WgcCapturerWin(std::unique_ptr source_factory, - std::unique_ptr source_enumerator); + std::unique_ptr source_enumerator, + bool allow_delayed_capturable_check); WgcCapturerWin(const WgcCapturerWin&) = delete; WgcCapturerWin& operator=(const WgcCapturerWin&) = delete; @@ -88,7 +89,8 @@ class WgcCapturerWin : public DesktopCapturer { ~WgcCapturerWin() override; static std::unique_ptr CreateRawWindowCapturer( - const DesktopCaptureOptions& options); + const DesktopCaptureOptions& options, + bool allow_delayed_capturable_check = false); static std::unique_ptr CreateRawScreenCapturer( const DesktopCaptureOptions& options); @@ -128,6 +130,11 @@ class WgcCapturerWin : public DesktopCapturer { // returns. Callback* callback_ = nullptr; + // WgcCaptureSource::IsCapturable is expensive to run. So, caller can + // delay capturable check till capture frame is called if the WgcCapturerWin + // is used as a fallback capturer. + bool allow_delayed_capturable_check_ = false; + // A Direct3D11 device that is shared amongst the WgcCaptureSessions, who // require one to perform the capture. Microsoft::WRL::ComPtr<::ID3D11Device> d3d11_device_; diff --git a/modules/desktop_capture/window_capturer_win.cc b/modules/desktop_capture/window_capturer_win.cc index 4bfa09f4d6..7f7bea6eff 100644 --- a/modules/desktop_capture/window_capturer_win.cc +++ b/modules/desktop_capture/window_capturer_win.cc @@ -12,12 +12,37 @@ #include "modules/desktop_capture/desktop_capturer.h" #include "modules/desktop_capture/win/window_capturer_win_gdi.h" +#if defined(RTC_ENABLE_WIN_WGC) +#include "modules/desktop_capture/blank_detector_desktop_capturer_wrapper.h" +#include "modules/desktop_capture/fallback_desktop_capturer_wrapper.h" +#include "modules/desktop_capture/win/wgc_capturer_win.h" +#include "rtc_base/win/windows_version.h" +#endif // defined(RTC_ENABLE_WIN_WGC) + namespace webrtc { // static std::unique_ptr DesktopCapturer::CreateRawWindowCapturer( const DesktopCaptureOptions& options) { - return WindowCapturerWinGdi::CreateRawWindowCapturer(options); + std::unique_ptr capturer( + WindowCapturerWinGdi::CreateRawWindowCapturer(options)); +#if defined(RTC_ENABLE_WIN_WGC) + if (options.allow_wgc_capturer_fallback() && + rtc::rtc_win::GetVersion() >= rtc::rtc_win::Version::VERSION_WIN10_RS5) { + // BlankDectector capturer will send an error when it detects a failed + // GDI rendering, then Fallback capturer will try to capture it again with + // WGC. + capturer = std::make_unique( + std::move(capturer), RgbaColor(0, 0, 0, 0), + /*check_per_capture*/ true); + + capturer = std::make_unique( + std::move(capturer), + WgcCapturerWin::CreateRawWindowCapturer( + options, /*allow_delayed_capturable_check*/ true)); + } +#endif // defined(RTC_ENABLE_WIN_WGC) + return capturer; } } // namespace webrtc From 4bac0bb2ccdba4d7de15005fd2c88aafb638740b Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Tue, 15 Mar 2022 13:21:59 +0000 Subject: [PATCH 199/847] Break out remaining orange targets from rtc_pc_base Bug: webrtc:13805 Change-Id: I97f000888c63209a557fbb6a428b176c2a79b5da Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255561 Reviewed-by: Mirko Bonadei Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#36225} --- pc/BUILD.gn | 54 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/pc/BUILD.gn b/pc/BUILD.gn index f30bf9e9ad..a9a5814896 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -81,12 +81,8 @@ rtc_library("rtc_pc_base") { "jsep_transport_controller.h", "media_session.cc", "media_session.h", - "rtp_transport.cc", - "rtp_transport.h", "sctp_transport.cc", "sctp_transport.h", - "srtp_session.cc", - "srtp_session.h", "srtp_transport.cc", "srtp_transport.h", "video_track_source_proxy.cc", @@ -362,6 +358,32 @@ rtc_source_set("rtp_sender_proxy") { } rtc_source_set("rtp_transport") { visibility = [ ":*" ] + sources = [ + "rtp_transport.cc", + "rtp_transport.h", + ] + deps = [ + ":rtp_transport_internal", + ":session_description", + "../api:array_view", + "../api/units:timestamp", + "../call:rtp_receiver", + "../call:video_stream_api", + "../media:rtc_media_base", + "../modules/rtp_rtcp:rtp_rtcp_format", + "../p2p:rtc_p2p", + "../rtc_base", + "../rtc_base:checks", + "../rtc_base:logging", + "../rtc_base:rtc_base_approved", + "../rtc_base:socket", + "../rtc_base/network:sent_packet", + "../rtc_base/third_party/sigslot", + ] + absl_deps = [ + "//third_party/abseil-cpp/absl/strings", + "//third_party/abseil-cpp/absl/types:optional", + ] } rtc_source_set("rtp_transport_internal") { visibility = [ @@ -436,6 +458,28 @@ rtc_source_set("srtp_filter") { } rtc_source_set("srtp_session") { visibility = [ ":*" ] + sources = [ + "srtp_session.cc", + "srtp_session.h", + ] + deps = [ + ":external_hmac", + "../api:array_view", + "../api:scoped_refptr", + "../api:sequence_checker", + "../api:webrtc_key_value_config", + "../modules/rtp_rtcp:rtp_rtcp_format", + "../rtc_base", + "../rtc_base:checks", + "../rtc_base:logging", + "../rtc_base:rtc_base_approved", + "../rtc_base/synchronization:mutex", + "../system_wrappers:metrics", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/base:core_headers" ] + if (rtc_build_libsrtp) { + deps += [ "//third_party/libsrtp" ] + } } rtc_source_set("srtp_transport") { visibility = [ ":*" ] @@ -1843,9 +1887,11 @@ if (rtc_include_tests && !build_with_chromium) { ":rtc_pc_base", ":rtcp_mux_filter", ":rtp_media_utils", + ":rtp_transport", ":rtp_transport_internal", ":session_description", ":srtp_filter", + ":srtp_session", ":used_ids", ":video_rtp_receiver", "../api:array_view", From 540c09ba0850946ea4414162a3aa9393d459fe53 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Wed, 16 Mar 2022 17:01:45 -0700 Subject: [PATCH 200/847] Roll chromium_revision 6a5628a6c8..80e0c32917 (981812:981921) Change log: https://chromium.googlesource.com/chromium/src/+log/6a5628a6c8..80e0c32917 Full diff: https://chromium.googlesource.com/chromium/src/+/6a5628a6c8..80e0c32917 Changed dependencies * src/build: https://chromium.googlesource.com/chromium/src/build/+log/0bc7d6146c..bea489b045 * src/buildtools: https://chromium.googlesource.com/chromium/src/buildtools/+log/113dd1badb..90ff2bf855 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/f99fb26981..a52b9d2541 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/31cc931e68..460523b697 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/d0c465dfcd..72089995ca * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/b3fe2c1779..5cc627712b * src/third_party/libyuv: https://chromium.googlesource.com/libyuv/libyuv.git/+log/b4ddbaf549..3aebf69d66 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/751bd4d6d1..8f7fec5404 DEPS diff: https://chromium.googlesource.com/chromium/src/+/6a5628a6c8..80e0c32917/DEPS No update to Clang. BUG=None Change-Id: I2e75469dfc4fd13c2065164160be8ede3b76b028 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255920 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36226} --- DEPS | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/DEPS b/DEPS index 1d0bda569d..e1a9a8be9f 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': '6a5628a6c8a634ebb76ce4d4547a8ee312861817', + 'chromium_revision': '80e0c3291769ccba086572140849096469de8776', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -25,22 +25,22 @@ deps = { 'src/base': 'https://chromium.googlesource.com/chromium/src/base@96393bcabe833399896c90557bf79217065d4e92', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@0bc7d6146c725e9d540dea46074bdc03040453a6', + 'https://chromium.googlesource.com/chromium/src/build@bea489b04572936e7b27e2d84e87ba85094954b5', 'src/buildtools': - 'https://chromium.googlesource.com/chromium/src/buildtools@113dd1badbcbffea108a8c95ac7c89c22bfd25f3', + 'https://chromium.googlesource.com/chromium/src/buildtools@90ff2bf8559c8eb9ce0c77cff53b40aa8a01e14a', # 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@f99fb26981e60b7412d9c3e02cb1d76c0b941dc9', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@a52b9d254180615b27a7ca7df68ea7867845d0df', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@31cc931e68f4afaf02c74ceb7d2433001ed10870', + 'https://chromium.googlesource.com/chromium/src/testing@460523b697f33ab3ca8fd91924697780b4bf9e58', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@d0c465dfcddbcce795fcdc35dbdeec694b327263', + 'https://chromium.googlesource.com/chromium/src/third_party@72089995cad7362516e122232256b09c576553c9', 'src/buildtools/linux64': { 'packages': [ @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@b3fe2c177912640bc676b332a2f41dc812ea5843', + 'https://chromium.googlesource.com/catapult.git@5cc627712b1270ce1f8d9e72638e79398832027a', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -235,7 +235,7 @@ deps = { 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': - 'https://chromium.googlesource.com/libyuv/libyuv.git@b4ddbaf549a1bf5572bf703fd2862d1eb7380c6a', + 'https://chromium.googlesource.com/libyuv/libyuv.git@3aebf69d668177e7ee6dbbe0025e5c3dbb525ff2', 'src/third_party/lss': { 'url': 'https://chromium.googlesource.com/linux-syscall-support.git@92a65a8f5d705d1928874420c8d0d15bde8c89e5', 'condition': 'checkout_android or checkout_linux', @@ -288,7 +288,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@751bd4d6d111a85fb6fb3cc2e08dbf41e60fecce', + 'https://chromium.googlesource.com/chromium/src/tools@8f7fec54048915daf9b502bd6e66df7740818a88', 'src/third_party/accessibility_test_framework': { 'packages': [ From a21c314815f03259c94831696b696269c6d02323 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Wed, 16 Mar 2022 21:02:15 -0700 Subject: [PATCH 201/847] Roll chromium_revision 80e0c32917..a79897884e (981921:982032) Change log: https://chromium.googlesource.com/chromium/src/+log/80e0c32917..a79897884e Full diff: https://chromium.googlesource.com/chromium/src/+/80e0c32917..a79897884e Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/96393bcabe..bfedbc1f92 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/bea489b045..344be2f95c * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/a52b9d2541..ae02fcbee0 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/460523b697..520807d3ec * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/72089995ca..2a0c661892 * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/5cc627712b..8ff5321b11 * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/b199f54926..950a6b4225 * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/02e3224f3e..deac2d35a1 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/8f7fec5404..d23956cfef DEPS diff: https://chromium.googlesource.com/chromium/src/+/80e0c32917..a79897884e/DEPS No update to Clang. BUG=None Change-Id: I598eba4fa481f889136ff5d4a8316875eb76614c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255902 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36227} --- DEPS | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/DEPS b/DEPS index e1a9a8be9f..91024dc09a 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': '80e0c3291769ccba086572140849096469de8776', + 'chromium_revision': 'a79897884e54b2977be79b3f11f5545c260a7d23', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@96393bcabe833399896c90557bf79217065d4e92', + 'https://chromium.googlesource.com/chromium/src/base@bfedbc1f926ef1db32317306af214c806885488c', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@bea489b04572936e7b27e2d84e87ba85094954b5', + 'https://chromium.googlesource.com/chromium/src/build@344be2f95cc135a10e1f609fad5693ff0ad8e09f', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@90ff2bf8559c8eb9ce0c77cff53b40aa8a01e14a', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@a52b9d254180615b27a7ca7df68ea7867845d0df', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@ae02fcbee070dadf12b31ff3e3443733bc973215', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@460523b697f33ab3ca8fd91924697780b4bf9e58', + 'https://chromium.googlesource.com/chromium/src/testing@520807d3ecdf5cd149f21044d8a2829343db3921', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@72089995cad7362516e122232256b09c576553c9', + 'https://chromium.googlesource.com/chromium/src/third_party@2a0c6618926e26304fdbe1ba4c4cd9e9159a096c', 'src/buildtools/linux64': { 'packages': [ @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@5cc627712b1270ce1f8d9e72638e79398832027a', + 'https://chromium.googlesource.com/catapult.git@8ff5321b11a8dadc44aa7ba9fdc3707377417a5a', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@b199f549263a02900faef8c8c3d581c580e837c3', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@950a6b4225ed3280aa0fbca2de51bfbaecd7695a', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -231,7 +231,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@02e3224f3e0a7f5f01c6daa4b8139a131be2e224', + 'https://android.googlesource.com/platform/external/perfetto.git@deac2d35a18ac8a216f70607fcbfe6615445869f', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -288,7 +288,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@8f7fec54048915daf9b502bd6e66df7740818a88', + 'https://chromium.googlesource.com/chromium/src/tools@d23956cfef8fb1a303811dcaa3b85ece9c072510', 'src/third_party/accessibility_test_framework': { 'packages': [ From e72f4bc524b52cb4aaa70005811835698f56785b Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Wed, 16 Mar 2022 21:07:29 -0700 Subject: [PATCH 202/847] Update WebRTC code version (2022-03-17T04:07:28). Bug: None Change-Id: Ib97334d7c83ea6759cc2736039db11c701a3d48a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255903 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36228} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index 21b5073e5b..b385936f74 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 2022-03-16T04:05:20"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-03-17T04:07:28"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From a943e730b2acced12fa1028ad43b9c9c91bf631c Mon Sep 17 00:00:00 2001 From: Jonas Oreland Date: Wed, 16 Mar 2022 13:50:58 +0100 Subject: [PATCH 203/847] WebRTC-DeprecateGlobalFieldTrialString/Enabled/ - part 7/inf Convert audio/ and collateral (audio encoder copy red). Bug: webrtc:10335 Change-Id: Iac54c0cfd2f62f4402f3deec35ae2725ec35b81a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255820 Reviewed-by: Harald Alvestrand Commit-Queue: Jonas Oreland Cr-Commit-Position: refs/heads/main@{#36229} --- audio/BUILD.gn | 2 + audio/audio_send_stream.cc | 69 ++++++++++--------- audio/audio_send_stream.h | 10 ++- audio/audio_send_stream_unittest.cc | 33 +++++---- audio/channel_send.cc | 14 ++-- audio/channel_send.h | 4 +- call/call.cc | 2 +- modules/audio_coding/BUILD.gn | 3 +- .../codecs/red/audio_encoder_copy_red.cc | 13 ++-- .../codecs/red/audio_encoder_copy_red.h | 4 +- .../red/audio_encoder_copy_red_unittest.cc | 40 ++++++----- modules/audio_coding/test/TestRedFec.cc | 3 +- modules/audio_coding/test/TestRedFec.h | 2 + 13 files changed, 117 insertions(+), 82 deletions(-) diff --git a/audio/BUILD.gn b/audio/BUILD.gn index b31ab0451e..dcafe3bf7b 100644 --- a/audio/BUILD.gn +++ b/audio/BUILD.gn @@ -49,6 +49,7 @@ rtc_library("audio") { "../api:scoped_refptr", "../api:sequence_checker", "../api:transport_api", + "../api:webrtc_key_value_config", "../api/audio:aec3_factory", "../api/audio:audio_frame_api", "../api/audio:audio_frame_processor", @@ -190,6 +191,7 @@ if (rtc_include_tests) { "../test:mock_transformable_frame", "../test:mock_transport", "../test:rtp_test_utils", + "../test:scoped_key_value_config", "../test:test_common", "../test:test_support", "utility:utility_tests", diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc index 08bb4e6bbf..6aa0ec940f 100644 --- a/audio/audio_send_stream.cc +++ b/audio/audio_send_stream.cc @@ -39,7 +39,6 @@ #include "rtc_base/logging.h" #include "rtc_base/strings/audio_format_to_string.h" #include "rtc_base/task_queue.h" -#include "system_wrappers/include/field_trial.h" namespace webrtc { namespace { @@ -88,8 +87,9 @@ std::unique_ptr AudioAllocationConfig::Parser() { "rate_prio", &bitrate_priority); } -AudioAllocationConfig::AudioAllocationConfig() { - Parser()->Parse(field_trial::FindFullName(kKey)); +AudioAllocationConfig::AudioAllocationConfig( + const WebRtcKeyValueConfig& field_trials) { + Parser()->Parse(field_trials.Lookup(kKey)); if (priority_bitrate_raw && !priority_bitrate.IsZero()) { RTC_LOG(LS_WARNING) << "'priority_bitrate' and '_raw' are mutually " "exclusive but both were configured."; @@ -106,28 +106,31 @@ AudioSendStream::AudioSendStream( BitrateAllocatorInterface* bitrate_allocator, RtcEventLog* event_log, RtcpRttStats* rtcp_rtt_stats, - const absl::optional& suspended_rtp_state) - : AudioSendStream(clock, - config, - audio_state, - task_queue_factory, - rtp_transport, - bitrate_allocator, - event_log, - suspended_rtp_state, - voe::CreateChannelSend( - clock, - task_queue_factory, - config.send_transport, - rtcp_rtt_stats, - event_log, - config.frame_encryptor, - config.crypto_options, - config.rtp.extmap_allow_mixed, - config.rtcp_report_interval_ms, - config.rtp.ssrc, - config.frame_transformer, - rtp_transport->transport_feedback_observer())) {} + const absl::optional& suspended_rtp_state, + const WebRtcKeyValueConfig& field_trials) + : AudioSendStream( + clock, + config, + audio_state, + task_queue_factory, + rtp_transport, + bitrate_allocator, + event_log, + suspended_rtp_state, + voe::CreateChannelSend(clock, + task_queue_factory, + config.send_transport, + rtcp_rtt_stats, + event_log, + config.frame_encryptor, + config.crypto_options, + config.rtp.extmap_allow_mixed, + config.rtcp_report_interval_ms, + config.rtp.ssrc, + config.frame_transformer, + rtp_transport->transport_feedback_observer(), + field_trials), + field_trials) {} AudioSendStream::AudioSendStream( Clock* clock, @@ -138,21 +141,24 @@ AudioSendStream::AudioSendStream( BitrateAllocatorInterface* bitrate_allocator, RtcEventLog* event_log, const absl::optional& suspended_rtp_state, - std::unique_ptr channel_send) + std::unique_ptr channel_send, + const WebRtcKeyValueConfig& field_trials) : clock_(clock), + field_trials_(field_trials), rtp_transport_queue_(rtp_transport->GetWorkerQueue()), allocate_audio_without_feedback_( - field_trial::IsEnabled("WebRTC-Audio-ABWENoTWCC")), + field_trials_.IsEnabled("WebRTC-Audio-ABWENoTWCC")), enable_audio_alr_probing_( - !field_trial::IsDisabled("WebRTC-Audio-AlrProbing")), + !field_trials_.IsDisabled("WebRTC-Audio-AlrProbing")), send_side_bwe_with_overhead_( - !field_trial::IsDisabled("WebRTC-SendSideBwe-WithOverhead")), + !field_trials_.IsDisabled("WebRTC-SendSideBwe-WithOverhead")), + allocation_settings_(field_trials_), config_(Config(/*send_transport=*/nullptr)), audio_state_(audio_state), channel_send_(std::move(channel_send)), event_log_(event_log), use_legacy_overhead_calculation_( - field_trial::IsEnabled("WebRTC-Audio-LegacyOverhead")), + field_trials_.IsEnabled("WebRTC-Audio-LegacyOverhead")), bitrate_allocator_(bitrate_allocator), rtp_transport_(rtp_transport), rtp_rtcp_module_(channel_send_->GetRtpRtcp()), @@ -640,7 +646,8 @@ bool AudioSendStream::SetupSendCodec(const Config& new_config) { AudioEncoderCopyRed::Config red_config; red_config.payload_type = *spec.red_payload_type; red_config.speech_encoder = std::move(encoder); - encoder = std::make_unique(std::move(red_config)); + encoder = std::make_unique(std::move(red_config), + field_trials_); } // Set currently known overhead (used in ANA, opus only). diff --git a/audio/audio_send_stream.h b/audio/audio_send_stream.h index b40750891c..ad40a8939b 100644 --- a/audio/audio_send_stream.h +++ b/audio/audio_send_stream.h @@ -16,6 +16,7 @@ #include #include "api/sequence_checker.h" +#include "api/webrtc_key_value_config.h" #include "audio/audio_level.h" #include "audio/channel_send.h" #include "call/audio_send_stream.h" @@ -46,7 +47,7 @@ struct AudioAllocationConfig { absl::optional bitrate_priority; std::unique_ptr Parser(); - AudioAllocationConfig(); + explicit AudioAllocationConfig(const WebRtcKeyValueConfig& field_trials); }; namespace internal { class AudioState; @@ -62,7 +63,8 @@ class AudioSendStream final : public webrtc::AudioSendStream, BitrateAllocatorInterface* bitrate_allocator, RtcEventLog* event_log, RtcpRttStats* rtcp_rtt_stats, - const absl::optional& suspended_rtp_state); + const absl::optional& suspended_rtp_state, + const WebRtcKeyValueConfig& field_trials); // For unit tests, which need to supply a mock ChannelSend. AudioSendStream(Clock* clock, const webrtc::AudioSendStream::Config& config, @@ -72,7 +74,8 @@ class AudioSendStream final : public webrtc::AudioSendStream, BitrateAllocatorInterface* bitrate_allocator, RtcEventLog* event_log, const absl::optional& suspended_rtp_state, - std::unique_ptr channel_send); + std::unique_ptr channel_send, + const WebRtcKeyValueConfig& field_trials); AudioSendStream() = delete; AudioSendStream(const AudioSendStream&) = delete; @@ -160,6 +163,7 @@ class AudioSendStream final : public webrtc::AudioSendStream, RTC_RUN_ON(worker_thread_checker_); Clock* clock_; + const WebRtcKeyValueConfig& field_trials_; SequenceChecker worker_thread_checker_; SequenceChecker pacer_thread_checker_; diff --git a/audio/audio_send_stream_unittest.cc b/audio/audio_send_stream_unittest.cc index 9228611e31..2d2e64c155 100644 --- a/audio/audio_send_stream_unittest.cc +++ b/audio/audio_send_stream_unittest.cc @@ -32,10 +32,10 @@ #include "modules/rtp_rtcp/mocks/mock_rtp_rtcp.h" #include "rtc_base/task_queue_for_test.h" #include "system_wrappers/include/clock.h" -#include "test/field_trial.h" #include "test/gtest.h" #include "test/mock_audio_encoder.h" #include "test/mock_audio_encoder_factory.h" +#include "test/scoped_key_value_config.h" namespace webrtc { namespace test { @@ -196,7 +196,8 @@ struct ConfigHelper { Clock::GetRealTimeClock(), stream_config_, audio_state_, task_queue_factory_.get(), &rtp_transport_, &bitrate_allocator_, &event_log_, absl::nullopt, - std::unique_ptr(channel_send_))); + std::unique_ptr(channel_send_), + field_trials)); } AudioSendStream::Config& config() { return stream_config_; } @@ -321,6 +322,8 @@ struct ConfigHelper { TaskQueueForTest* worker() { return &worker_queue_; } + test::ScopedKeyValueConfig field_trials; + private: SimulatedClock clock_; std::unique_ptr task_queue_factory_; @@ -659,10 +662,10 @@ TEST(AudioSendStreamTest, SSBweTargetInRangeRespected) { } TEST(AudioSendStreamTest, SSBweFieldTrialMinRespected) { - ScopedFieldTrials field_trials( - "WebRTC-Audio-Allocation/min:6kbps,max:64kbps/"); for (bool use_null_audio_processing : {false, true}) { ConfigHelper helper(true, true, use_null_audio_processing); + ScopedKeyValueConfig field_trials( + helper.field_trials, "WebRTC-Audio-Allocation/min:6kbps,max:64kbps/"); auto send_stream = helper.CreateAudioSendStream(); EXPECT_CALL( *helper.channel_send(), @@ -676,10 +679,10 @@ TEST(AudioSendStreamTest, SSBweFieldTrialMinRespected) { } TEST(AudioSendStreamTest, SSBweFieldTrialMaxRespected) { - ScopedFieldTrials field_trials( - "WebRTC-Audio-Allocation/min:6kbps,max:64kbps/"); for (bool use_null_audio_processing : {false, true}) { ConfigHelper helper(true, true, use_null_audio_processing); + ScopedKeyValueConfig field_trials( + helper.field_trials, "WebRTC-Audio-Allocation/min:6kbps,max:64kbps/"); auto send_stream = helper.CreateAudioSendStream(); EXPECT_CALL( *helper.channel_send(), @@ -693,10 +696,10 @@ TEST(AudioSendStreamTest, SSBweFieldTrialMaxRespected) { } TEST(AudioSendStreamTest, SSBweWithOverhead) { - ScopedFieldTrials field_trials( - "WebRTC-Audio-LegacyOverhead/Disabled/"); for (bool use_null_audio_processing : {false, true}) { ConfigHelper helper(true, true, use_null_audio_processing); + ScopedKeyValueConfig field_trials(helper.field_trials, + "WebRTC-Audio-LegacyOverhead/Disabled/"); EXPECT_CALL(*helper.rtp_rtcp(), ExpectedPerPacketOverhead) .WillRepeatedly(Return(kOverheadPerPacket.bytes())); auto send_stream = helper.CreateAudioSendStream(); @@ -714,11 +717,12 @@ TEST(AudioSendStreamTest, SSBweWithOverhead) { } TEST(AudioSendStreamTest, SSBweWithOverheadMinRespected) { - ScopedFieldTrials field_trials( - "WebRTC-Audio-LegacyOverhead/Disabled/" - "WebRTC-Audio-Allocation/min:6kbps,max:64kbps/"); for (bool use_null_audio_processing : {false, true}) { ConfigHelper helper(true, true, use_null_audio_processing); + ScopedKeyValueConfig field_trials( + helper.field_trials, + "WebRTC-Audio-LegacyOverhead/Disabled/" + "WebRTC-Audio-Allocation/min:6kbps,max:64kbps/"); EXPECT_CALL(*helper.rtp_rtcp(), ExpectedPerPacketOverhead) .WillRepeatedly(Return(kOverheadPerPacket.bytes())); auto send_stream = helper.CreateAudioSendStream(); @@ -734,11 +738,12 @@ TEST(AudioSendStreamTest, SSBweWithOverheadMinRespected) { } TEST(AudioSendStreamTest, SSBweWithOverheadMaxRespected) { - ScopedFieldTrials field_trials( - "WebRTC-Audio-LegacyOverhead/Disabled/" - "WebRTC-Audio-Allocation/min:6kbps,max:64kbps/"); for (bool use_null_audio_processing : {false, true}) { ConfigHelper helper(true, true, use_null_audio_processing); + ScopedKeyValueConfig field_trials( + helper.field_trials, + "WebRTC-Audio-LegacyOverhead/Disabled/" + "WebRTC-Audio-Allocation/min:6kbps,max:64kbps/"); EXPECT_CALL(*helper.rtp_rtcp(), ExpectedPerPacketOverhead) .WillRepeatedly(Return(kOverheadPerPacket.bytes())); auto send_stream = helper.CreateAudioSendStream(); diff --git a/audio/channel_send.cc b/audio/channel_send.cc index d1135e5adc..d6b5823f3e 100644 --- a/audio/channel_send.cc +++ b/audio/channel_send.cc @@ -43,7 +43,6 @@ #include "rtc_base/task_queue.h" #include "rtc_base/time_utils.h" #include "system_wrappers/include/clock.h" -#include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/metrics.h" namespace webrtc { @@ -78,7 +77,8 @@ class ChannelSend : public ChannelSendInterface, int rtcp_report_interval_ms, uint32_t ssrc, rtc::scoped_refptr frame_transformer, - TransportFeedbackObserver* feedback_observer); + TransportFeedbackObserver* feedback_observer, + const WebRtcKeyValueConfig& field_trials); ~ChannelSend() override; @@ -458,7 +458,8 @@ ChannelSend::ChannelSend( int rtcp_report_interval_ms, uint32_t ssrc, rtc::scoped_refptr frame_transformer, - TransportFeedbackObserver* feedback_observer) + TransportFeedbackObserver* feedback_observer, + const WebRtcKeyValueConfig& field_trials) : ssrc_(ssrc), event_log_(rtc_event_log), _timeStamp(0), // This is just an offset, RTP module will add it's own @@ -477,7 +478,7 @@ ChannelSend::ChannelSend( "AudioEncoder", TaskQueueFactory::Priority::NORMAL)), fixing_timestamp_stall_( - !field_trial::IsDisabled("WebRTC-Audio-FixTimestampStall")) { + field_trials.IsDisabled("WebRTC-Audio-FixTimestampStall")) { audio_coding_.reset(AudioCodingModule::Create(AudioCodingModule::Config())); RtpRtcpInterface::Configuration configuration; @@ -948,12 +949,13 @@ std::unique_ptr CreateChannelSend( int rtcp_report_interval_ms, uint32_t ssrc, rtc::scoped_refptr frame_transformer, - TransportFeedbackObserver* feedback_observer) { + TransportFeedbackObserver* feedback_observer, + const WebRtcKeyValueConfig& field_trials) { return std::make_unique( clock, task_queue_factory, rtp_transport, rtcp_rtt_stats, rtc_event_log, frame_encryptor, crypto_options, extmap_allow_mixed, rtcp_report_interval_ms, ssrc, std::move(frame_transformer), - feedback_observer); + feedback_observer, field_trials); } } // namespace voe diff --git a/audio/channel_send.h b/audio/channel_send.h index e100725460..bfbfbeedfa 100644 --- a/audio/channel_send.h +++ b/audio/channel_send.h @@ -21,6 +21,7 @@ #include "api/frame_transformer_interface.h" #include "api/function_view.h" #include "api/task_queue/task_queue_factory.h" +#include "api/webrtc_key_value_config.h" #include "modules/rtp_rtcp/include/report_block_data.h" #include "modules/rtp_rtcp/source/rtp_rtcp_interface.h" #include "modules/rtp_rtcp/source/rtp_sender_audio.h" @@ -135,7 +136,8 @@ std::unique_ptr CreateChannelSend( int rtcp_report_interval_ms, uint32_t ssrc, rtc::scoped_refptr frame_transformer, - TransportFeedbackObserver* feedback_observer); + TransportFeedbackObserver* feedback_observer, + const WebRtcKeyValueConfig& field_trials); } // namespace voe } // namespace webrtc diff --git a/call/call.cc b/call/call.cc index 16f7b9058f..f2101cfc6b 100644 --- a/call/call.cc +++ b/call/call.cc @@ -915,7 +915,7 @@ webrtc::AudioSendStream* Call::CreateAudioSendStream( AudioSendStream* send_stream = new AudioSendStream( clock_, config, config_.audio_state, task_queue_factory_, transport_send_.get(), bitrate_allocator_.get(), event_log_, - call_stats_->AsRtcpRttStats(), suspended_rtp_state); + call_stats_->AsRtcpRttStats(), suspended_rtp_state, trials()); RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) == audio_send_ssrcs_.end()); audio_send_ssrcs_[config.rtp.ssrc] = send_stream; diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn index c4814ce1f8..af76a11eae 100644 --- a/modules/audio_coding/BUILD.gn +++ b/modules/audio_coding/BUILD.gn @@ -118,12 +118,12 @@ rtc_library("red") { deps = [ "../../api:array_view", + "../../api:webrtc_key_value_config", "../../api/audio_codecs:audio_codecs_api", "../../api/units:time_delta", "../../common_audio", "../../rtc_base:checks", "../../rtc_base:rtc_base_approved", - "../../system_wrappers:field_trial", ] absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } @@ -2079,6 +2079,7 @@ if (rtc_include_tests) { "../../test:fileutils", "../../test:rtc_expect_death", "../../test:rtp_test_utils", + "../../test:scoped_key_value_config", "../../test:test_common", "../../test:test_support", "codecs/opus/test", 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 9643c7b1a5..c8a26e8c61 100644 --- a/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc +++ b/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc @@ -18,7 +18,6 @@ #include "rtc_base/byte_order.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" -#include "system_wrappers/include/field_trial.h" namespace webrtc { static constexpr const int kRedMaxPacketSize = @@ -40,9 +39,10 @@ AudioEncoderCopyRed::Config::Config() = default; AudioEncoderCopyRed::Config::Config(Config&&) = default; AudioEncoderCopyRed::Config::~Config() = default; -size_t GetMaxRedundancyFromFieldTrial() { +size_t GetMaxRedundancyFromFieldTrial( + const WebRtcKeyValueConfig& field_trials) { const std::string red_trial = - webrtc::field_trial::FindFullName("WebRTC-Audio-Red-For-Opus"); + field_trials.Lookup("WebRTC-Audio-Red-For-Opus"); size_t redundancy = 0; if (sscanf(red_trial.c_str(), "Enabled-%zu", &redundancy) != 1 || redundancy > 9) { @@ -51,14 +51,17 @@ size_t GetMaxRedundancyFromFieldTrial() { return redundancy; } -AudioEncoderCopyRed::AudioEncoderCopyRed(Config&& config) +AudioEncoderCopyRed::AudioEncoderCopyRed( + Config&& config, + const WebRtcKeyValueConfig& field_trials) : speech_encoder_(std::move(config.speech_encoder)), primary_encoded_(0, kAudioMaxRtpPacketLen), max_packet_length_(kAudioMaxRtpPacketLen), red_payload_type_(config.payload_type) { RTC_CHECK(speech_encoder_) << "Speech encoder not provided."; - auto number_of_redundant_encodings = GetMaxRedundancyFromFieldTrial(); + auto number_of_redundant_encodings = + GetMaxRedundancyFromFieldTrial(field_trials); for (size_t i = 0; i < number_of_redundant_encodings; i++) { std::pair redundant; redundant.second.EnsureCapacity(kAudioMaxRtpPacketLen); diff --git a/modules/audio_coding/codecs/red/audio_encoder_copy_red.h b/modules/audio_coding/codecs/red/audio_encoder_copy_red.h index d163193251..e7471b3e12 100644 --- a/modules/audio_coding/codecs/red/audio_encoder_copy_red.h +++ b/modules/audio_coding/codecs/red/audio_encoder_copy_red.h @@ -22,6 +22,7 @@ #include "api/array_view.h" #include "api/audio_codecs/audio_encoder.h" #include "api/units/time_delta.h" +#include "api/webrtc_key_value_config.h" #include "rtc_base/buffer.h" namespace webrtc { @@ -42,7 +43,8 @@ class AudioEncoderCopyRed final : public AudioEncoder { std::unique_ptr speech_encoder; }; - explicit AudioEncoderCopyRed(Config&& config); + AudioEncoderCopyRed(Config&& config, + const WebRtcKeyValueConfig& field_trials); ~AudioEncoderCopyRed() override; 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 0eeac011e0..795a996624 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 @@ -18,6 +18,7 @@ #include "test/field_trial.h" #include "test/gtest.h" #include "test/mock_audio_encoder.h" +#include "test/scoped_key_value_config.h" #include "test/testsupport/rtc_expect_death.h" using ::testing::_; @@ -49,7 +50,7 @@ class AudioEncoderCopyRedTest : public ::testing::Test { AudioEncoderCopyRed::Config config; config.payload_type = red_payload_type_; config.speech_encoder = std::unique_ptr(mock_encoder_); - red_.reset(new AudioEncoderCopyRed(std::move(config))); + red_.reset(new AudioEncoderCopyRed(std::move(config), field_trials_)); memset(audio_, 0, sizeof(audio_)); EXPECT_CALL(*mock_encoder_, NumChannels()).WillRepeatedly(Return(1U)); EXPECT_CALL(*mock_encoder_, SampleRateHz()) @@ -68,6 +69,7 @@ class AudioEncoderCopyRedTest : public ::testing::Test { timestamp_ += rtc::checked_cast(num_audio_samples_10ms); } + test::ScopedKeyValueConfig field_trials_; MockAudioEncoder* mock_encoder_; std::unique_ptr red_; uint32_t timestamp_; @@ -198,13 +200,13 @@ TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizes1) { // Checks that the correct payload sizes are populated into the redundancy // information for a redundancy level of 0. TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizes0) { - webrtc::test::ScopedFieldTrials field_trials( - "WebRTC-Audio-Red-For-Opus/Enabled-0/"); + webrtc::test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-Audio-Red-For-Opus/Enabled-0/"); // Recreate the RED encoder to take the new field trial setting into account. AudioEncoderCopyRed::Config config; config.payload_type = red_payload_type_; config.speech_encoder = std::move(red_->ReclaimContainedEncoders()[0]); - red_.reset(new AudioEncoderCopyRed(std::move(config))); + red_.reset(new AudioEncoderCopyRed(std::move(config), field_trials)); // Let the mock encoder return payload sizes 1, 2, 3, ..., 10 for the sequence // of calls. @@ -224,13 +226,13 @@ TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizes0) { // Checks that the correct payload sizes are populated into the redundancy // information for a redundancy level of 2. TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizes2) { - webrtc::test::ScopedFieldTrials field_trials( - "WebRTC-Audio-Red-For-Opus/Enabled-2/"); + webrtc::test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-Audio-Red-For-Opus/Enabled-2/"); // Recreate the RED encoder to take the new field trial setting into account. AudioEncoderCopyRed::Config config; config.payload_type = red_payload_type_; config.speech_encoder = std::move(red_->ReclaimContainedEncoders()[0]); - red_.reset(new AudioEncoderCopyRed(std::move(config))); + red_.reset(new AudioEncoderCopyRed(std::move(config), field_trials)); // Let the mock encoder return payload sizes 1, 2, 3, ..., 10 for the sequence // of calls. @@ -266,13 +268,13 @@ TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizes2) { // Checks that the correct payload sizes are populated into the redundancy // information for a redundancy level of 3. TEST_F(AudioEncoderCopyRedTest, CheckPayloadSizes3) { - webrtc::test::ScopedFieldTrials field_trials( - "WebRTC-Audio-Red-For-Opus/Enabled-3/"); + webrtc::test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-Audio-Red-For-Opus/Enabled-3/"); // Recreate the RED encoder to take the new field trial setting into account. AudioEncoderCopyRed::Config config; config.payload_type = red_payload_type_; config.speech_encoder = std::move(red_->ReclaimContainedEncoders()[0]); - red_.reset(new AudioEncoderCopyRed(std::move(config))); + red_.reset(new AudioEncoderCopyRed(std::move(config), field_trials_)); // Let the mock encoder return payload sizes 1, 2, 3, ..., 10 for the sequence // of calls. @@ -463,13 +465,13 @@ TEST_F(AudioEncoderCopyRedTest, CheckRFC2198Header) { // Variant with a redundancy of 0. TEST_F(AudioEncoderCopyRedTest, CheckRFC2198Header0) { - webrtc::test::ScopedFieldTrials field_trials( - "WebRTC-Audio-Red-For-Opus/Enabled-0/"); + webrtc::test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-Audio-Red-For-Opus/Enabled-0/"); // Recreate the RED encoder to take the new field trial setting into account. AudioEncoderCopyRed::Config config; config.payload_type = red_payload_type_; config.speech_encoder = std::move(red_->ReclaimContainedEncoders()[0]); - red_.reset(new AudioEncoderCopyRed(std::move(config))); + red_.reset(new AudioEncoderCopyRed(std::move(config), field_trials)); const int primary_payload_type = red_payload_type_ + 1; AudioEncoder::EncodedInfo info; @@ -491,13 +493,13 @@ TEST_F(AudioEncoderCopyRedTest, CheckRFC2198Header0) { } // Variant with a redundancy of 2. TEST_F(AudioEncoderCopyRedTest, CheckRFC2198Header2) { - webrtc::test::ScopedFieldTrials field_trials( - "WebRTC-Audio-Red-For-Opus/Enabled-2/"); + webrtc::test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-Audio-Red-For-Opus/Enabled-2/"); // Recreate the RED encoder to take the new field trial setting into account. AudioEncoderCopyRed::Config config; config.payload_type = red_payload_type_; config.speech_encoder = std::move(red_->ReclaimContainedEncoders()[0]); - red_.reset(new AudioEncoderCopyRed(std::move(config))); + red_.reset(new AudioEncoderCopyRed(std::move(config), field_trials)); const int primary_payload_type = red_payload_type_ + 1; AudioEncoder::EncodedInfo info; @@ -623,11 +625,13 @@ TEST_F(AudioEncoderCopyRedDeathTest, WrongFrameSize) { } TEST_F(AudioEncoderCopyRedDeathTest, NullSpeechEncoder) { + test::ScopedKeyValueConfig field_trials; AudioEncoderCopyRed* red = NULL; AudioEncoderCopyRed::Config config; config.speech_encoder = NULL; - RTC_EXPECT_DEATH(red = new AudioEncoderCopyRed(std::move(config)), - "Speech encoder not provided."); + RTC_EXPECT_DEATH( + red = new AudioEncoderCopyRed(std::move(config), field_trials), + "Speech encoder not provided."); // The delete operation is needed to avoid leak reports from memcheck. delete red; } diff --git a/modules/audio_coding/test/TestRedFec.cc b/modules/audio_coding/test/TestRedFec.cc index d2c8d8a132..892fbc83d6 100644 --- a/modules/audio_coding/test/TestRedFec.cc +++ b/modules/audio_coding/test/TestRedFec.cc @@ -190,7 +190,8 @@ void TestRedFec::RegisterSendCodec( AudioEncoderCopyRed::Config config; config.payload_type = red_payload_type; config.speech_encoder = std::move(encoder); - encoder = std::make_unique(std::move(config)); + encoder = std::make_unique(std::move(config), + field_trials_); receive_codecs.emplace( std::make_pair(red_payload_type, SdpAudioFormat("red", codec_format.clockrate_hz, 1))); diff --git a/modules/audio_coding/test/TestRedFec.h b/modules/audio_coding/test/TestRedFec.h index 0e92d27330..dbadd88487 100644 --- a/modules/audio_coding/test/TestRedFec.h +++ b/modules/audio_coding/test/TestRedFec.h @@ -19,6 +19,7 @@ #include "common_audio/vad/include/vad.h" #include "modules/audio_coding/test/Channel.h" #include "modules/audio_coding/test/PCMFile.h" +#include "test/scoped_key_value_config.h" namespace webrtc { @@ -37,6 +38,7 @@ class TestRedFec { void Run(); void OpenOutFile(int16_t testNumber); + test::ScopedKeyValueConfig field_trials_; const rtc::scoped_refptr encoder_factory_; const rtc::scoped_refptr decoder_factory_; std::unique_ptr _acmA; From 7e539921e4dc5c60f1069a31f912be3e779646ff Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Thu, 17 Mar 2022 06:26:03 +0000 Subject: [PATCH 204/847] rtc_pc_base breakup: Brick red targets This is the third wave of dependencies in the rtc_pc_base breakup. Bug: webrtc:13805 Change-Id: I79122f2f0395864d595fdffcc4dafa8ed09c560d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255960 Reviewed-by: Mirko Bonadei Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#36230} --- pc/BUILD.gn | 51 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/pc/BUILD.gn b/pc/BUILD.gn index a9a5814896..470a37a3d6 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -81,10 +81,6 @@ rtc_library("rtc_pc_base") { "jsep_transport_controller.h", "media_session.cc", "media_session.h", - "sctp_transport.cc", - "sctp_transport.h", - "srtp_transport.cc", - "srtp_transport.h", "video_track_source_proxy.cc", "video_track_source_proxy.h", ] @@ -416,6 +412,25 @@ rtc_source_set("sctp_data_channel_transport") { } rtc_source_set("sctp_transport") { visibility = [ ":*" ] + sources = [ + "sctp_transport.cc", + "sctp_transport.h", + ] + deps = [ + ":dtls_transport", + "../api:libjingle_peerconnection_api", + "../api:scoped_refptr", + "../api:sequence_checker", + "../media:rtc_data_sctp_transport_internal", + "../p2p:rtc_p2p", + "../rtc_base", + "../rtc_base:checks", + "../rtc_base:rtc_base_approved", + "../rtc_base:rtc_base_approved", + "../rtc_base:threading", + "../rtc_base/third_party/sigslot", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } rtc_source_set("sctp_utils") { visibility = [ @@ -483,6 +498,29 @@ rtc_source_set("srtp_session") { } rtc_source_set("srtp_transport") { visibility = [ ":*" ] + sources = [ + "srtp_transport.cc", + "srtp_transport.h", + ] + deps = [ + ":rtp_transport", + ":srtp_session", + "../api:libjingle_peerconnection_api", + "../api:rtc_error", + "../api:webrtc_key_value_config", + "../media:rtc_media_base", + "../modules/rtp_rtcp:rtp_rtcp_format", + "../p2p:rtc_p2p", + "../rtc_base", + "../rtc_base:checks", + "../rtc_base:rtc_base_approved", + "../rtc_base/third_party/base64", + "../rtc_base/third_party/sigslot", + ] + absl_deps = [ + "//third_party/abseil-cpp/absl/strings", + "//third_party/abseil-cpp/absl/types:optional", + ] } rtc_source_set("transport_stats") { visibility = [ ":*" ] @@ -933,6 +971,7 @@ rtc_source_set("sdp_offer_answer") { ":rtp_sender_proxy", ":rtp_transceiver", ":rtp_transmission_manager", + ":sctp_transport", ":sdp_state_provider", ":session_description", ":simulcast_description", @@ -1022,6 +1061,7 @@ rtc_source_set("peer_connection") { ":rtp_transmission_manager", ":rtp_transport_internal", ":sctp_data_channel", + ":sctp_transport", ":sdp_offer_answer", ":session_description", ":simulcast_description", @@ -1889,9 +1929,11 @@ if (rtc_include_tests && !build_with_chromium) { ":rtp_media_utils", ":rtp_transport", ":rtp_transport_internal", + ":sctp_transport", ":session_description", ":srtp_filter", ":srtp_session", + ":srtp_transport", ":used_ids", ":video_rtp_receiver", "../api:array_view", @@ -2094,6 +2136,7 @@ if (rtc_include_tests && !build_with_chromium) { ":rtp_transceiver", ":rtp_transport_internal", ":sctp_data_channel", + ":sctp_transport", ":sctp_utils", ":sdp_serializer", ":sdp_utils", From 340cb5e46ac75af5ac253639e02adb558ea9ba9d Mon Sep 17 00:00:00 2001 From: Jonas Oreland Date: Thu, 17 Mar 2022 09:14:16 +0100 Subject: [PATCH 205/847] WebRTC-DeprecateGlobalFieldTrialString/Enabled/ - part 8/inf Convert p2p/. This completes work started in https://webrtc-review.googlesource.com/c/src/+/255602 Bug: webrtc:10335 Change-Id: I39f70890be0599c8ef46ff7982d2a229e10e67ff Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255827 Reviewed-by: Harald Alvestrand Commit-Queue: Jonas Oreland Cr-Commit-Position: refs/heads/main@{#36231} --- api/ice_transport_interface.h | 7 + p2p/BUILD.gn | 1 + p2p/base/connection.cc | 10 +- p2p/base/p2p_transport_channel.cc | 162 ++++++++++-------- p2p/base/p2p_transport_channel.h | 44 +---- .../p2p_transport_channel_ice_field_trials.h | 6 + p2p/base/p2p_transport_channel_unittest.cc | 81 +++++---- p2p/base/port_unittest.cc | 1 - p2p/base/turn_port.cc | 27 +-- p2p/base/turn_port.h | 40 +++-- p2p/base/turn_port_unittest.cc | 21 ++- p2p/client/basic_port_allocator.cc | 49 +++--- p2p/client/basic_port_allocator.h | 21 ++- p2p/client/basic_port_allocator_unittest.cc | 6 +- p2p/client/relay_port_factory_interface.h | 2 + p2p/client/turn_port_factory.cc | 5 +- pc/jsep_transport_controller.cc | 1 + 17 files changed, 270 insertions(+), 214 deletions(-) diff --git a/api/ice_transport_interface.h b/api/ice_transport_interface.h index f202658acf..c82027a427 100644 --- a/api/ice_transport_interface.h +++ b/api/ice_transport_interface.h @@ -27,6 +27,7 @@ class IceControllerFactoryInterface; } // namespace cricket namespace webrtc { +class WebRtcKeyValueConfig; // An ICE transport, as represented to the outside world. // This object is refcounted, and is therefore alive until the @@ -83,6 +84,11 @@ struct IceTransportInit final { return ice_controller_factory_; } + const WebRtcKeyValueConfig* field_trials() { return field_trials_; } + void set_field_trials(const WebRtcKeyValueConfig* field_trials) { + field_trials_ = field_trials; + } + private: cricket::PortAllocator* port_allocator_ = nullptr; AsyncDnsResolverFactoryInterface* async_dns_resolver_factory_ = nullptr; @@ -90,6 +96,7 @@ struct IceTransportInit final { AsyncResolverFactory* async_resolver_factory_ = nullptr; RtcEventLog* event_log_ = nullptr; cricket::IceControllerFactoryInterface* ice_controller_factory_ = nullptr; + const WebRtcKeyValueConfig* field_trials_ = nullptr; // TODO(https://crbug.com/webrtc/12657): Redesign to have const members. }; diff --git a/p2p/BUILD.gn b/p2p/BUILD.gn index 66da247ade..758f8bfa33 100644 --- a/p2p/BUILD.gn +++ b/p2p/BUILD.gn @@ -97,6 +97,7 @@ rtc_library("rtc_p2p") { "../api/rtc_event_log", "../api/task_queue", "../api/transport:enums", + "../api/transport:field_trial_based_config", "../api/transport:stun_types", "../logging:ice_log", "../rtc_base", diff --git a/p2p/base/connection.cc b/p2p/base/connection.cc index 1d674e2bcb..efc2143977 100644 --- a/p2p/base/connection.cc +++ b/p2p/base/connection.cc @@ -33,7 +33,6 @@ #include "rtc_base/string_utils.h" #include "rtc_base/strings/string_builder.h" #include "rtc_base/third_party/base64/base64.h" -#include "system_wrappers/include/field_trial.h" namespace { @@ -191,8 +190,7 @@ void ConnectionRequest::Prepare(StunMessage* request) { request->AddAttribute(std::make_unique( STUN_ATTR_GOOG_NETWORK_INFO, network_info)); - if (webrtc::field_trial::IsEnabled( - "WebRTC-PiggybackIceCheckAcknowledgement") && + if (connection_->field_trials_->piggyback_ice_check_acknowledgement && connection_->last_ping_id_received()) { request->AddAttribute(std::make_unique( STUN_ATTR_GOOG_LAST_ICE_CHECK_RECEIVED, @@ -605,8 +603,7 @@ void Connection::HandleStunBindingOrGoogPingRequest(IceMessage* msg) { RTC_DCHECK_RUN_ON(network_thread_); // This connection should now be receiving. ReceivedPing(msg->transaction_id()); - if (webrtc::field_trial::IsEnabled("WebRTC-ExtraICEPing") && - last_ping_response_received_ == 0) { + if (field_trials_->extra_ice_ping && last_ping_response_received_ == 0) { if (local_candidate().type() == RELAY_PORT_TYPE || local_candidate().type() == PRFLX_PORT_TYPE || remote_candidate().type() == RELAY_PORT_TYPE || @@ -695,8 +692,7 @@ void Connection::HandleStunBindingOrGoogPingRequest(IceMessage* msg) { } } - if (webrtc::field_trial::IsEnabled( - "WebRTC-PiggybackIceCheckAcknowledgement")) { + if (field_trials_->piggyback_ice_check_acknowledgement) { HandlePiggybackCheckAcknowledgementIfAny(msg); } } diff --git a/p2p/base/p2p_transport_channel.cc b/p2p/base/p2p_transport_channel.cc index 5d7f895b61..a8d84b987d 100644 --- a/p2p/base/p2p_transport_channel.cc +++ b/p2p/base/p2p_transport_channel.cc @@ -25,6 +25,7 @@ #include "api/async_dns_resolver.h" #include "api/candidate.h" #include "api/task_queue/queued_task.h" +#include "api/webrtc_key_value_config.h" #include "logging/rtc_event_log/ice_logger.h" #include "p2p/base/basic_async_resolver_factory.h" #include "p2p/base/basic_ice_controller.h" @@ -44,7 +45,6 @@ #include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/time_utils.h" #include "rtc_base/trace_event.h" -#include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/metrics.h" namespace { @@ -60,12 +60,15 @@ cricket::PortInterface::CandidateOrigin GetOrigin( return cricket::PortInterface::ORIGIN_OTHER_PORT; } -uint32_t GetWeakPingIntervalInFieldTrial() { - uint32_t weak_ping_interval = ::strtoul( - webrtc::field_trial::FindFullName("WebRTC-StunInterPacketDelay").c_str(), - nullptr, 10); - if (weak_ping_interval) { - return static_cast(weak_ping_interval); +uint32_t GetWeakPingIntervalInFieldTrial( + const webrtc::WebRtcKeyValueConfig* field_trials) { + if (field_trials != nullptr) { + uint32_t weak_ping_interval = + ::strtoul(field_trials->Lookup("WebRTC-StunInterPacketDelay").c_str(), + nullptr, 10); + if (weak_ping_interval) { + return static_cast(weak_ping_interval); + } } return cricket::WEAK_PING_INTERVAL; } @@ -118,25 +121,28 @@ std::unique_ptr P2PTransportChannel::Create( transport_name, component, init.port_allocator(), nullptr, std::make_unique( init.async_resolver_factory()), - init.event_log(), init.ice_controller_factory())); + init.event_log(), init.ice_controller_factory(), init.field_trials())); } else { return absl::WrapUnique(new P2PTransportChannel( transport_name, component, init.port_allocator(), init.async_dns_resolver_factory(), nullptr, init.event_log(), - init.ice_controller_factory())); + init.ice_controller_factory(), init.field_trials())); } } -P2PTransportChannel::P2PTransportChannel(const std::string& transport_name, - int component, - PortAllocator* allocator) +P2PTransportChannel::P2PTransportChannel( + const std::string& transport_name, + int component, + PortAllocator* allocator, + const webrtc::WebRtcKeyValueConfig* field_trials) : P2PTransportChannel(transport_name, component, allocator, /* async_dns_resolver_factory= */ nullptr, /* owned_dns_resolver_factory= */ nullptr, /* event_log= */ nullptr, - /* ice_controller_factory= */ nullptr) {} + /* ice_controller_factory= */ nullptr, + field_trials) {} // Private constructor, called from Create() P2PTransportChannel::P2PTransportChannel( @@ -147,7 +153,8 @@ P2PTransportChannel::P2PTransportChannel( std::unique_ptr owned_dns_resolver_factory, webrtc::RtcEventLog* event_log, - IceControllerFactoryInterface* ice_controller_factory) + IceControllerFactoryInterface* ice_controller_factory, + const webrtc::WebRtcKeyValueConfig* field_trials) : transport_name_(transport_name), component_(component), allocator_(allocator), @@ -165,6 +172,7 @@ P2PTransportChannel::P2PTransportChannel( ice_role_(ICEROLE_UNKNOWN), tiebreaker_(0), gathering_state_(kIceGatheringNew), + weak_ping_interval_(GetWeakPingIntervalInFieldTrial(field_trials)), config_(RECEIVING_TIMEOUT, BACKUP_CONNECTION_PING_INTERVAL, GATHER_ONCE /* continual_gathering_policy */, @@ -175,7 +183,6 @@ P2PTransportChannel::P2PTransportChannel( RECEIVING_SWITCHING_DELAY) { TRACE_EVENT0("webrtc", "P2PTransportChannel::P2PTransportChannel"); RTC_DCHECK(allocator_ != nullptr); - weak_ping_interval_ = GetWeakPingIntervalInFieldTrial(); // Validate IceConfig even for mostly built-in constant default values in case // we change them. RTC_DCHECK(ValidateIceConfig(config_).ok()); @@ -191,6 +198,8 @@ P2PTransportChannel::P2PTransportChannel( this, &P2PTransportChannel::OnCandidateFilterChanged); ice_event_log_.set_event_log(event_log); + ParseFieldTrials(field_trials); + IceControllerFactoryArgs args{ [this] { return GetState(); }, [this] { return GetIceRole(); }, [this](const Connection* connection) { @@ -199,8 +208,9 @@ P2PTransportChannel::P2PTransportChannel( return IsPortPruned(connection->port()) || IsRemoteCandidatePruned(connection->remote_candidate()); }, - &field_trials_, - webrtc::field_trial::FindFullName("WebRTC-IceControllerFieldTrials")}; + &ice_field_trials_, + field_trials ? field_trials->Lookup("WebRTC-IceControllerFieldTrials") + : ""}; if (ice_controller_factory != nullptr) { ice_controller_ = ice_controller_factory->Create(args); } else { @@ -267,7 +277,7 @@ void P2PTransportChannel::AddConnection(Connection* connection) { had_connection_ = true; connection->set_ice_event_log(&ice_event_log_); - connection->SetIceFieldTrials(&field_trials_); + connection->SetIceFieldTrials(&ice_field_trials_); LogCandidatePairConfig(connection, webrtc::IceCandidatePairConfigType::kAdded); @@ -685,94 +695,105 @@ void P2PTransportChannel::SetIceConfig(const IceConfig& config) { << config.stun_keepalive_interval_or_default(); } - if (webrtc::field_trial::IsEnabled("WebRTC-ExtraICEPing")) { + webrtc::BasicRegatheringController::Config regathering_config; + regathering_config.regather_on_failed_networks_interval = + config_.regather_on_failed_networks_interval_or_default(); + regathering_controller_->SetConfig(regathering_config); + + config_.vpn_preference = config.vpn_preference; + allocator_->SetVpnPreference(config_.vpn_preference); + + ice_controller_->SetIceConfig(config_); + + RTC_DCHECK(ValidateIceConfig(config_).ok()); +} + +void P2PTransportChannel::ParseFieldTrials( + const webrtc::WebRtcKeyValueConfig* field_trials) { + if (field_trials == nullptr) { + return; + } + + if (field_trials->IsEnabled("WebRTC-ExtraICEPing")) { RTC_LOG(LS_INFO) << "Set WebRTC-ExtraICEPing: Enabled"; } - if (webrtc::field_trial::IsEnabled("WebRTC-TurnAddMultiMapping")) { + if (field_trials->IsEnabled("WebRTC-TurnAddMultiMapping")) { RTC_LOG(LS_INFO) << "Set WebRTC-TurnAddMultiMapping: Enabled"; } webrtc::StructParametersParser::Create( // go/skylift-light "skip_relay_to_non_relay_connections", - &field_trials_.skip_relay_to_non_relay_connections, + &ice_field_trials_.skip_relay_to_non_relay_connections, // Limiting pings sent. - "max_outstanding_pings", &field_trials_.max_outstanding_pings, + "max_outstanding_pings", &ice_field_trials_.max_outstanding_pings, // Delay initial selection of connection. - "initial_select_dampening", &field_trials_.initial_select_dampening, + "initial_select_dampening", &ice_field_trials_.initial_select_dampening, // Delay initial selection of connections, that are receiving. "initial_select_dampening_ping_received", - &field_trials_.initial_select_dampening_ping_received, + &ice_field_trials_.initial_select_dampening_ping_received, // Reply that we support goog ping. - "announce_goog_ping", &field_trials_.announce_goog_ping, + "announce_goog_ping", &ice_field_trials_.announce_goog_ping, // Use goog ping if remote support it. - "enable_goog_ping", &field_trials_.enable_goog_ping, + "enable_goog_ping", &ice_field_trials_.enable_goog_ping, // How fast does a RTT sample decay. - "rtt_estimate_halftime_ms", &field_trials_.rtt_estimate_halftime_ms, + "rtt_estimate_halftime_ms", &ice_field_trials_.rtt_estimate_halftime_ms, // Make sure that nomination reaching ICE controlled asap. "send_ping_on_switch_ice_controlling", - &field_trials_.send_ping_on_switch_ice_controlling, + &ice_field_trials_.send_ping_on_switch_ice_controlling, // Make sure that nomination reaching ICE controlled asap. "send_ping_on_selected_ice_controlling", - &field_trials_.send_ping_on_selected_ice_controlling, + &ice_field_trials_.send_ping_on_selected_ice_controlling, // Reply to nomination ASAP. "send_ping_on_nomination_ice_controlled", - &field_trials_.send_ping_on_nomination_ice_controlled, + &ice_field_trials_.send_ping_on_nomination_ice_controlled, // Allow connections to live untouched longer that 30s. - "dead_connection_timeout_ms", &field_trials_.dead_connection_timeout_ms, + "dead_connection_timeout_ms", + &ice_field_trials_.dead_connection_timeout_ms, // Stop gathering on strongly connected. "stop_gather_on_strongly_connected", - &field_trials_.stop_gather_on_strongly_connected) - ->Parse(webrtc::field_trial::FindFullName("WebRTC-IceFieldTrials")); + &ice_field_trials_.stop_gather_on_strongly_connected) + ->Parse(field_trials->Lookup("WebRTC-IceFieldTrials")); - if (field_trials_.dead_connection_timeout_ms < 30000) { + if (ice_field_trials_.dead_connection_timeout_ms < 30000) { RTC_LOG(LS_WARNING) << "dead_connection_timeout_ms set to " - << field_trials_.dead_connection_timeout_ms + << ice_field_trials_.dead_connection_timeout_ms << " increasing it to 30000"; - field_trials_.dead_connection_timeout_ms = 30000; + ice_field_trials_.dead_connection_timeout_ms = 30000; } - if (field_trials_.skip_relay_to_non_relay_connections) { + if (ice_field_trials_.skip_relay_to_non_relay_connections) { RTC_LOG(LS_INFO) << "Set skip_relay_to_non_relay_connections"; } - if (field_trials_.max_outstanding_pings.has_value()) { + if (ice_field_trials_.max_outstanding_pings.has_value()) { RTC_LOG(LS_INFO) << "Set max_outstanding_pings: " - << *field_trials_.max_outstanding_pings; + << *ice_field_trials_.max_outstanding_pings; } - if (field_trials_.initial_select_dampening.has_value()) { + if (ice_field_trials_.initial_select_dampening.has_value()) { RTC_LOG(LS_INFO) << "Set initial_select_dampening: " - << *field_trials_.initial_select_dampening; + << *ice_field_trials_.initial_select_dampening; } - if (field_trials_.initial_select_dampening_ping_received.has_value()) { - RTC_LOG(LS_INFO) << "Set initial_select_dampening_ping_received: " - << *field_trials_.initial_select_dampening_ping_received; + if (ice_field_trials_.initial_select_dampening_ping_received.has_value()) { + RTC_LOG(LS_INFO) + << "Set initial_select_dampening_ping_received: " + << *ice_field_trials_.initial_select_dampening_ping_received; } - webrtc::BasicRegatheringController::Config regathering_config; - regathering_config.regather_on_failed_networks_interval = - config_.regather_on_failed_networks_interval_or_default(); - regathering_controller_->SetConfig(regathering_config); - - config_.vpn_preference = config.vpn_preference; - allocator_->SetVpnPreference(config_.vpn_preference); - - ice_controller_->SetIceConfig(config_); - // DSCP override, allow user to specify (any) int value // that will be used for tagging all packets. webrtc::StructParametersParser::Create("override_dscp", - &field_trials_.override_dscp) - ->Parse(webrtc::field_trial::FindFullName("WebRTC-DscpFieldTrial")); + &ice_field_trials_.override_dscp) + ->Parse(field_trials->Lookup("WebRTC-DscpFieldTrial")); - if (field_trials_.override_dscp) { - SetOption(rtc::Socket::OPT_DSCP, *field_trials_.override_dscp); + if (ice_field_trials_.override_dscp) { + SetOption(rtc::Socket::OPT_DSCP, *ice_field_trials_.override_dscp); } std::string field_trial_string = - webrtc::field_trial::FindFullName("WebRTC-SetSocketReceiveBuffer"); + field_trials->Lookup("WebRTC-SetSocketReceiveBuffer"); int receive_buffer_size_kb = 0; sscanf(field_trial_string.c_str(), "Enabled-%d", &receive_buffer_size_kb); if (receive_buffer_size_kb > 0) { @@ -781,7 +802,11 @@ void P2PTransportChannel::SetIceConfig(const IceConfig& config) { SetOption(rtc::Socket::OPT_RCVBUF, receive_buffer_size_kb * 1024); } - RTC_DCHECK(ValidateIceConfig(config_).ok()); + ice_field_trials_.piggyback_ice_check_acknowledgement = + field_trials->IsEnabled("WebRTC-PiggybackIceCheckAcknowledgement"); + + ice_field_trials_.extra_ice_ping = + field_trials->IsEnabled("WebRTC-ExtraICEPing"); } const IceConfig& P2PTransportChannel::config() const { @@ -795,7 +820,7 @@ const IceConfig& P2PTransportChannel::config() const { RTCError P2PTransportChannel::ValidateIceConfig(const IceConfig& config) { if (config.ice_check_interval_strong_connectivity_or_default() < config.ice_check_interval_weak_connectivity.value_or( - GetWeakPingIntervalInFieldTrial())) { + GetWeakPingIntervalInFieldTrial(nullptr))) { return RTCError(RTCErrorType::INVALID_PARAMETER, "Ping interval of candidate pairs is shorter when ICE is " "strongly connected than that when ICE is weakly " @@ -1179,7 +1204,8 @@ void P2PTransportChannel::OnNominated(Connection* conn) { return; } - if (field_trials_.send_ping_on_nomination_ice_controlled && conn != nullptr) { + if (ice_field_trials_.send_ping_on_nomination_ice_controlled && + conn != nullptr) { PingConnection(conn); MarkConnectionPinged(conn); } @@ -1419,7 +1445,7 @@ bool P2PTransportChannel::CreateConnection(PortInterface* port, return false; } - if (field_trials_.skip_relay_to_non_relay_connections) { + if (ice_field_trials_.skip_relay_to_non_relay_connections) { if ((port->Type() != remote_candidate.type()) && (port->Type() == RELAY_PORT_TYPE || remote_candidate.type() == RELAY_PORT_TYPE)) { @@ -1535,8 +1561,8 @@ void P2PTransportChannel::RememberRemoteCandidate( // port objects. int P2PTransportChannel::SetOption(rtc::Socket::Option opt, int value) { RTC_DCHECK_RUN_ON(network_thread_); - if (field_trials_.override_dscp && opt == rtc::Socket::OPT_DSCP) { - value = *field_trials_.override_dscp; + if (ice_field_trials_.override_dscp && opt == rtc::Socket::OPT_DSCP) { + value = *ice_field_trials_.override_dscp; } OptionMap::iterator it = options_.find(opt); @@ -1855,9 +1881,9 @@ void P2PTransportChannel::SwitchSelectedConnection(Connection* conn, } if (conn != nullptr && ice_role_ == ICEROLE_CONTROLLING && - ((field_trials_.send_ping_on_switch_ice_controlling && + ((ice_field_trials_.send_ping_on_switch_ice_controlling && old_selected_connection != nullptr) || - field_trials_.send_ping_on_selected_ice_controlling)) { + ice_field_trials_.send_ping_on_selected_ice_controlling)) { PingConnection(conn); MarkConnectionPinged(conn); } @@ -2116,7 +2142,7 @@ void P2PTransportChannel::OnConnectionStateChange(Connection* connection) { // the connection is at the latest generation. It is not enough to check // that the connection becomes weakly connected because the connection may be // changing from (writable, receiving) to (writable, not receiving). - if (field_trials_.stop_gather_on_strongly_connected) { + if (ice_field_trials_.stop_gather_on_strongly_connected) { bool strongly_connected = !connection->weak(); bool latest_generation = connection->local_candidate().generation() >= allocator_session()->generation(); diff --git a/p2p/base/p2p_transport_channel.h b/p2p/base/p2p_transport_channel.h index 58bd1fb978..24c4b85b8c 100644 --- a/p2p/base/p2p_transport_channel.h +++ b/p2p/base/p2p_transport_channel.h @@ -109,45 +109,13 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal { int component, webrtc::IceTransportInit init); - // TODO(jonaso): This is deprecated and will be removed. - static std::unique_ptr Create( - const std::string& transport_name, - int component, - PortAllocator* allocator, - webrtc::AsyncDnsResolverFactoryInterface* async_dns_resolver_factory, - webrtc::RtcEventLog* event_log = nullptr, - IceControllerFactoryInterface* ice_controller_factory = nullptr) { - webrtc::IceTransportInit init; - init.set_port_allocator(allocator); - init.set_async_dns_resolver_factory(async_dns_resolver_factory); - init.set_event_log(event_log); - init.set_ice_controller_factory(ice_controller_factory); - return Create(transport_name, component, std::move(init)); - } - // For testing only. // TODO(zstein): Remove once AsyncDnsResolverFactory is required. - P2PTransportChannel(const std::string& transport_name, - int component, - PortAllocator* allocator); - - ABSL_DEPRECATED("bugs.webrtc.org/12598") P2PTransportChannel( const std::string& transport_name, int component, PortAllocator* allocator, - webrtc::AsyncResolverFactory* async_resolver_factory, - webrtc::RtcEventLog* event_log = nullptr, - IceControllerFactoryInterface* ice_controller_factory = nullptr) - : P2PTransportChannel( - transport_name, - component, - allocator, - nullptr, - std::make_unique( - async_resolver_factory), - event_log, - ice_controller_factory) {} + const webrtc::WebRtcKeyValueConfig* field_trials = nullptr); ~P2PTransportChannel() override; @@ -278,8 +246,9 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal { // on release, this pointer is set. std::unique_ptr owned_dns_resolver_factory, - webrtc::RtcEventLog* event_log = nullptr, - IceControllerFactoryInterface* ice_controller_factory = nullptr); + webrtc::RtcEventLog* event_log, + IceControllerFactoryInterface* ice_controller_factory, + const webrtc::WebRtcKeyValueConfig* field_trials); bool IsGettingPorts() { RTC_DCHECK_RUN_ON(network_thread_); return allocator_session()->IsGettingPorts(); @@ -431,6 +400,8 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal { int64_t ComputeEstimatedDisconnectedTimeMs(int64_t now, Connection* old_connection); + void ParseFieldTrials(const webrtc::WebRtcKeyValueConfig* field_trials); + webrtc::ScopedTaskSafety task_safety_; std::string transport_name_ RTC_GUARDED_BY(network_thread_); int component_ RTC_GUARDED_BY(network_thread_); @@ -531,7 +502,8 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal { // from connection->last_data_received() that uses rtc::TimeMillis(). int64_t last_data_received_ms_ = 0; - IceFieldTrials field_trials_; + // Parsed field trials. + IceFieldTrials ice_field_trials_; }; } // namespace cricket diff --git a/p2p/base/p2p_transport_channel_ice_field_trials.h b/p2p/base/p2p_transport_channel_ice_field_trials.h index f05623dd36..f19823b21e 100644 --- a/p2p/base/p2p_transport_channel_ice_field_trials.h +++ b/p2p/base/p2p_transport_channel_ice_field_trials.h @@ -19,6 +19,9 @@ namespace cricket { // put in separate file so that they can be shared e.g // with Connection. struct IceFieldTrials { + // This struct is built using the FieldTrialParser, and then not modified. + // TODO(jonaso) : Consider how members of this struct can be made const. + bool skip_relay_to_non_relay_connections = false; absl::optional max_outstanding_pings; @@ -64,6 +67,9 @@ struct IceFieldTrials { // DSCP taging. absl::optional override_dscp; + + bool piggyback_ice_check_acknowledgement = false; + bool extra_ice_ping = false; }; } // namespace cricket diff --git a/p2p/base/p2p_transport_channel_unittest.cc b/p2p/base/p2p_transport_channel_unittest.cc index 9acd7b1fa0..2685d59751 100644 --- a/p2p/base/p2p_transport_channel_unittest.cc +++ b/p2p/base/p2p_transport_channel_unittest.cc @@ -42,7 +42,7 @@ #include "rtc_base/thread.h" #include "rtc_base/virtual_socket_server.h" #include "system_wrappers/include/metrics.h" -#include "test/field_trial.h" +#include "test/scoped_key_value_config.h" namespace { @@ -451,9 +451,13 @@ class P2PTransportChannelTestBase : public ::testing::Test, int component, const IceParameters& local_ice, const IceParameters& remote_ice) { - auto channel = P2PTransportChannel::Create( - "test content name", component, GetAllocator(endpoint), + webrtc::IceTransportInit init; + init.set_port_allocator(GetAllocator(endpoint)); + init.set_async_dns_resolver_factory( GetEndpoint(endpoint)->async_dns_resolver_factory_); + init.set_field_trials(&field_trials_); + auto channel = P2PTransportChannel::Create("test content name", component, + std::move(init)); channel->SignalReadyToSend.connect( this, &P2PTransportChannelTestBase::OnReadyToSend); channel->SignalCandidateGathered.connect( @@ -994,6 +998,8 @@ class P2PTransportChannelTestBase : public ::testing::Test, void OnNominated(Connection* conn) { nominated_ = true; } bool nominated() { return nominated_; } + webrtc::test::ScopedKeyValueConfig field_trials_; + private: std::unique_ptr vss_; std::unique_ptr nss_; @@ -1257,7 +1263,7 @@ class P2PTransportChannelTestWithFieldTrials public ::testing::WithParamInterface { public: void Test(const Result& expected) override { - webrtc::test::ScopedFieldTrials field_trials(GetParam()); + webrtc::test::ScopedKeyValueConfig field_trials(field_trials_, GetParam()); P2PTransportChannelTest::Test(expected); } }; @@ -2423,8 +2429,8 @@ TEST_F(P2PTransportChannelTest, // acknowledgement in the connectivity check from the remote peer. TEST_F(P2PTransportChannelTest, CanConnectWithPiggybackCheckAcknowledgementWhenCheckResponseBlocked) { - webrtc::test::ScopedFieldTrials field_trials( - "WebRTC-PiggybackIceCheckAcknowledgement/Enabled/"); + webrtc::test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-PiggybackIceCheckAcknowledgement/Enabled/"); rtc::ScopedFakeClock clock; ConfigureEndpoints(OPEN, OPEN, kOnlyLocalPorts, kOnlyLocalPorts); IceConfig ep1_config; @@ -4057,10 +4063,10 @@ 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) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-IceFieldTrials/send_ping_on_nomination_ice_controlled:true/"); FakePortAllocator pa(rtc::Thread::Current(), nullptr); - P2PTransportChannel ch("receiving state change", 1, &pa); + P2PTransportChannel ch("receiving state change", 1, &pa, &field_trials); PrepareChannel(&ch); ch.SetIceConfig(ch.config()); ch.SetIceRole(ICEROLE_CONTROLLED); @@ -4097,10 +4103,10 @@ TEST_F(P2PTransportChannelPingTest, TestPingOnNomination) { // that sends a ping directly when switching to a new connection // on the ICE_CONTROLLING-side. TEST_F(P2PTransportChannelPingTest, TestPingOnSwitch) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-IceFieldTrials/send_ping_on_switch_ice_controlling:true/"); FakePortAllocator pa(rtc::Thread::Current(), nullptr); - P2PTransportChannel ch("receiving state change", 1, &pa); + P2PTransportChannel ch("receiving state change", 1, &pa, &field_trials); PrepareChannel(&ch); ch.SetIceConfig(ch.config()); ch.SetIceRole(ICEROLE_CONTROLLING); @@ -4134,10 +4140,10 @@ 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) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-IceFieldTrials/send_ping_on_selected_ice_controlling:true/"); FakePortAllocator pa(rtc::Thread::Current(), nullptr); - P2PTransportChannel ch("receiving state change", 1, &pa); + P2PTransportChannel ch("receiving state change", 1, &pa, &field_trials); PrepareChannel(&ch); ch.SetIceConfig(ch.config()); ch.SetIceRole(ICEROLE_CONTROLLING); @@ -4881,10 +4887,10 @@ TEST_F(P2PTransportChannelPingTest, TestPortDestroyedAfterTimeoutAndPruned) { } TEST_F(P2PTransportChannelPingTest, TestMaxOutstandingPingsFieldTrial) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-IceFieldTrials/max_outstanding_pings:3/"); FakePortAllocator pa(rtc::Thread::Current(), nullptr); - P2PTransportChannel ch("max", 1, &pa); + P2PTransportChannel ch("max", 1, &pa, &field_trials); ch.SetIceConfig(ch.config()); PrepareChannel(&ch); ch.MaybeStartGathering(); @@ -4922,8 +4928,10 @@ class P2PTransportChannelMostLikelyToWorkFirstTest P2PTransportChannel& StartTransportChannel( bool prioritize_most_likely_to_work, - int stable_writable_connection_ping_interval) { - channel_.reset(new P2PTransportChannel("checks", 1, allocator())); + int stable_writable_connection_ping_interval, + const webrtc::WebRtcKeyValueConfig* field_trials = nullptr) { + channel_.reset( + new P2PTransportChannel("checks", 1, allocator(), field_trials)); IceConfig config = channel_->config(); config.prioritize_most_likely_candidate_pairs = prioritize_most_likely_to_work; @@ -5090,9 +5098,9 @@ TEST_F(P2PTransportChannelMostLikelyToWorkFirstTest, // I.e that we never create connection between relay and non-relay. TEST_F(P2PTransportChannelMostLikelyToWorkFirstTest, TestSkipRelayToNonRelayConnectionsFieldTrial) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-IceFieldTrials/skip_relay_to_non_relay_connections:true/"); - P2PTransportChannel& ch = StartTransportChannel(true, 500); + P2PTransportChannel& ch = StartTransportChannel(true, 500, &field_trials); EXPECT_TRUE_WAIT(ch.ports().size() == 2, kDefaultTimeout); EXPECT_EQ(ch.ports()[0]->Type(), LOCAL_PORT_TYPE); EXPECT_EQ(ch.ports()[1]->Type(), RELAY_PORT_TYPE); @@ -5143,8 +5151,10 @@ TEST_F(P2PTransportChannelMostLikelyToWorkFirstTest, TestTcpTurn) { TEST(P2PTransportChannelResolverTest, HostnameCandidateIsResolved) { ResolverFactoryFixture resolver_fixture; FakePortAllocator allocator(rtc::Thread::Current(), nullptr); - auto channel = - P2PTransportChannel::Create("tn", 0, &allocator, &resolver_fixture); + webrtc::IceTransportInit init; + init.set_port_allocator(&allocator); + init.set_async_dns_resolver_factory(&resolver_fixture); + auto channel = P2PTransportChannel::Create("tn", 0, std::move(init)); Candidate hostname_candidate; SocketAddress hostname_address("fake.test", 1000); hostname_candidate.set_address(hostname_address); @@ -5906,7 +5916,8 @@ TEST_F(P2PTransportChannelTest, // i.e surface_ice_candidates_on_ice_transport_type_changed requires // coordination outside of webrtc to function properly. TEST_F(P2PTransportChannelTest, SurfaceRequiresCoordination) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( + field_trials_, "WebRTC-IceFieldTrials/skip_relay_to_non_relay_connections:true/"); rtc::ScopedFakeClock clock; @@ -5970,7 +5981,7 @@ TEST_F(P2PTransportChannelTest, SurfaceRequiresCoordination) { } TEST_F(P2PTransportChannelPingTest, TestInitialSelectDampening0) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-IceFieldTrials/initial_select_dampening:0/"); constexpr int kMargin = 10; @@ -5978,7 +5989,7 @@ TEST_F(P2PTransportChannelPingTest, TestInitialSelectDampening0) { clock.AdvanceTime(webrtc::TimeDelta::Seconds(1)); FakePortAllocator pa(rtc::Thread::Current(), nullptr); - P2PTransportChannel ch("test channel", 1, &pa); + P2PTransportChannel ch("test channel", 1, &pa, &field_trials); PrepareChannel(&ch); ch.SetIceConfig(ch.config()); ch.MaybeStartGathering(); @@ -5994,7 +6005,7 @@ TEST_F(P2PTransportChannelPingTest, TestInitialSelectDampening0) { } TEST_F(P2PTransportChannelPingTest, TestInitialSelectDampening) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-IceFieldTrials/initial_select_dampening:100/"); constexpr int kMargin = 10; @@ -6002,7 +6013,7 @@ TEST_F(P2PTransportChannelPingTest, TestInitialSelectDampening) { clock.AdvanceTime(webrtc::TimeDelta::Seconds(1)); FakePortAllocator pa(rtc::Thread::Current(), nullptr); - P2PTransportChannel ch("test channel", 1, &pa); + P2PTransportChannel ch("test channel", 1, &pa, &field_trials); PrepareChannel(&ch); ch.SetIceConfig(ch.config()); ch.MaybeStartGathering(); @@ -6018,7 +6029,7 @@ TEST_F(P2PTransportChannelPingTest, TestInitialSelectDampening) { } TEST_F(P2PTransportChannelPingTest, TestInitialSelectDampeningPingReceived) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-IceFieldTrials/initial_select_dampening_ping_received:100/"); constexpr int kMargin = 10; @@ -6026,7 +6037,7 @@ TEST_F(P2PTransportChannelPingTest, TestInitialSelectDampeningPingReceived) { clock.AdvanceTime(webrtc::TimeDelta::Seconds(1)); FakePortAllocator pa(rtc::Thread::Current(), nullptr); - P2PTransportChannel ch("test channel", 1, &pa); + P2PTransportChannel ch("test channel", 1, &pa, &field_trials); PrepareChannel(&ch); ch.SetIceConfig(ch.config()); ch.MaybeStartGathering(); @@ -6043,7 +6054,7 @@ TEST_F(P2PTransportChannelPingTest, TestInitialSelectDampeningPingReceived) { } TEST_F(P2PTransportChannelPingTest, TestInitialSelectDampeningBoth) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-IceFieldTrials/" "initial_select_dampening:100,initial_select_dampening_ping_received:" "50/"); @@ -6053,7 +6064,7 @@ TEST_F(P2PTransportChannelPingTest, TestInitialSelectDampeningBoth) { clock.AdvanceTime(webrtc::TimeDelta::Seconds(1)); FakePortAllocator pa(rtc::Thread::Current(), nullptr); - P2PTransportChannel ch("test channel", 1, &pa); + P2PTransportChannel ch("test channel", 1, &pa, &field_trials); PrepareChannel(&ch); ch.SetIceConfig(ch.config()); ch.MaybeStartGathering(); @@ -6128,8 +6139,12 @@ class ForgetLearnedStateControllerFactory TEST_F(P2PTransportChannelPingTest, TestForgetLearnedState) { ForgetLearnedStateControllerFactory factory; FakePortAllocator pa(rtc::Thread::Current(), nullptr); - auto ch = P2PTransportChannel::Create("ping sufficiently", 1, &pa, nullptr, - nullptr, &factory); + webrtc::IceTransportInit init; + init.set_port_allocator(&pa); + init.set_ice_controller_factory(&factory); + auto ch = + P2PTransportChannel::Create("ping sufficiently", 1, std::move(init)); + PrepareChannel(ch.get()); ch->MaybeStartGathering(); ch->AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1)); @@ -6246,7 +6261,7 @@ TEST_P(GatherAfterConnectedTest, GatherAfterConnected) { const std::string field_trial = std::string("WebRTC-IceFieldTrials/stop_gather_on_strongly_connected:") + (stop_gather_on_strongly_connected ? "true/" : "false/"); - webrtc::test::ScopedFieldTrials field_trials(field_trial); + webrtc::test::ScopedKeyValueConfig field_trials(field_trials_, field_trial); rtc::ScopedFakeClock clock; // Use local + relay @@ -6307,7 +6322,7 @@ TEST_P(GatherAfterConnectedTest, GatherAfterConnectedMultiHomed) { const std::string field_trial = std::string("WebRTC-IceFieldTrials/stop_gather_on_strongly_connected:") + (stop_gather_on_strongly_connected ? "true/" : "false/"); - webrtc::test::ScopedFieldTrials field_trials(field_trial); + webrtc::test::ScopedKeyValueConfig field_trials(field_trials_, field_trial); rtc::ScopedFakeClock clock; // Use local + relay diff --git a/p2p/base/port_unittest.cc b/p2p/base/port_unittest.cc index 6ab40a66ad..23b11a7a3d 100644 --- a/p2p/base/port_unittest.cc +++ b/p2p/base/port_unittest.cc @@ -63,7 +63,6 @@ #include "rtc_base/thread.h" #include "rtc_base/time_utils.h" #include "rtc_base/virtual_socket_server.h" -#include "test/field_trial.h" #include "test/gtest.h" using rtc::AsyncListenSocket; diff --git a/p2p/base/turn_port.cc b/p2p/base/turn_port.cc index bde5bf603c..9b09ae8360 100644 --- a/p2p/base/turn_port.cc +++ b/p2p/base/turn_port.cc @@ -29,7 +29,6 @@ #include "rtc_base/socket_address.h" #include "rtc_base/strings/string_builder.h" #include "rtc_base/task_utils/to_queued_task.h" -#include "system_wrappers/include/field_trial.h" namespace cricket { @@ -223,7 +222,8 @@ TurnPort::TurnPort(rtc::Thread* thread, const ProtocolAddress& server_address, const RelayCredentials& credentials, int server_priority, - webrtc::TurnCustomizer* customizer) + webrtc::TurnCustomizer* customizer, + const webrtc::WebRtcKeyValueConfig* field_trials) : Port(thread, RELAY_PORT_TYPE, factory, network, username, password), server_address_(server_address), tls_cert_verifier_(nullptr), @@ -236,7 +236,8 @@ TurnPort::TurnPort(rtc::Thread* thread, state_(STATE_CONNECTING), server_priority_(server_priority), allocate_mismatch_retries_(0), - turn_customizer_(customizer) { + turn_customizer_(customizer), + field_trials_(field_trials) { request_manager_.SignalSendPacket.connect(this, &TurnPort::OnSendStunPacket); } @@ -253,7 +254,8 @@ TurnPort::TurnPort(rtc::Thread* thread, const std::vector& tls_alpn_protocols, const std::vector& tls_elliptic_curves, webrtc::TurnCustomizer* customizer, - rtc::SSLCertificateVerifier* tls_cert_verifier) + rtc::SSLCertificateVerifier* tls_cert_verifier, + const webrtc::WebRtcKeyValueConfig* field_trials) : Port(thread, RELAY_PORT_TYPE, factory, @@ -275,7 +277,8 @@ TurnPort::TurnPort(rtc::Thread* thread, state_(STATE_CONNECTING), server_priority_(server_priority), allocate_mismatch_retries_(0), - turn_customizer_(customizer) { + turn_customizer_(customizer), + field_trials_(field_trials) { request_manager_.SignalSendPacket.connect(this, &TurnPort::OnSendStunPacket); } @@ -338,7 +341,7 @@ void TurnPort::PrepareAddress() { server_address_.address.SetPort(TURN_DEFAULT_PORT); } - if (!AllowedTurnPort(server_address_.address.port())) { + if (!AllowedTurnPort(server_address_.address.port(), field_trials_)) { // This can only happen after a 300 ALTERNATE SERVER, since the port can't // be created with a disallowed port number. RTC_LOG(LS_ERROR) << "Attempt to start allocation with disallowed port# " @@ -930,7 +933,9 @@ rtc::DiffServCodePoint TurnPort::StunDscpValue() const { } // static -bool TurnPort::AllowedTurnPort(int port) { +bool TurnPort::AllowedTurnPort( + int port, + const webrtc::WebRtcKeyValueConfig* field_trials) { // Port 53, 80 and 443 are used for existing deployments. // Ports above 1024 are assumed to be OK to use. if (port == 53 || port == 80 || port == 443 || port >= 1024) { @@ -938,7 +943,7 @@ bool TurnPort::AllowedTurnPort(int port) { } // Allow any port if relevant field trial is set. This allows disabling the // check. - if (webrtc::field_trial::IsEnabled("WebRTC-Turn-AllowSystemPorts")) { + if (field_trials && field_trials->IsEnabled("WebRTC-Turn-AllowSystemPorts")) { return true; } return false; @@ -1228,7 +1233,8 @@ bool TurnPort::CreateOrRefreshEntry(const rtc::SocketAddress& addr, RTC_DCHECK(GetConnection(addr)); } - if (webrtc::field_trial::IsEnabled("WebRTC-TurnAddMultiMapping")) { + if (field_trials_ && + field_trials_->IsEnabled("WebRTC-TurnAddMultiMapping")) { if (entry->get_remote_ufrag() != remote_ufrag) { RTC_LOG(LS_INFO) << ToString() << ": remote ufrag updated." @@ -1627,7 +1633,8 @@ void TurnCreatePermissionRequest::Prepare(StunMessage* request) { request->SetType(TURN_CREATE_PERMISSION_REQUEST); request->AddAttribute(std::make_unique( STUN_ATTR_XOR_PEER_ADDRESS, ext_addr_)); - if (webrtc::field_trial::IsEnabled("WebRTC-TurnAddMultiMapping")) { + if (port_->field_trials_ && + port_->field_trials_->IsEnabled("WebRTC-TurnAddMultiMapping")) { request->AddAttribute(std::make_unique( STUN_ATTR_MULTI_MAPPING, remote_ufrag_)); } diff --git a/p2p/base/turn_port.h b/p2p/base/turn_port.h index 172dcef5ad..797d19096e 100644 --- a/p2p/base/turn_port.h +++ b/p2p/base/turn_port.h @@ -63,7 +63,8 @@ class TurnPort : public Port { const ProtocolAddress& server_address, const RelayCredentials& credentials, int server_priority, - webrtc::TurnCustomizer* customizer) { + webrtc::TurnCustomizer* customizer, + const webrtc::WebRtcKeyValueConfig* field_trials = nullptr) { // Do basic parameter validation. if (credentials.username.size() > kMaxTurnUsernameLength) { RTC_LOG(LS_ERROR) << "Attempt to use TURN with a too long username " @@ -71,15 +72,15 @@ class TurnPort : public Port { return nullptr; } // Do not connect to low-numbered ports. The default STUN port is 3478. - if (!AllowedTurnPort(server_address.address.port())) { + if (!AllowedTurnPort(server_address.address.port(), field_trials)) { RTC_LOG(LS_ERROR) << "Attempt to use TURN to connect to port " << server_address.address.port(); return nullptr; } // Using `new` to access a non-public constructor. - return absl::WrapUnique( - new TurnPort(thread, factory, network, socket, username, password, - server_address, credentials, server_priority, customizer)); + return absl::WrapUnique(new TurnPort( + thread, factory, network, socket, username, password, server_address, + credentials, server_priority, customizer, field_trials)); } // TODO(steveanton): Remove once downstream clients have moved to `Create`. @@ -93,9 +94,11 @@ class TurnPort : public Port { const ProtocolAddress& server_address, const RelayCredentials& credentials, int server_priority, - webrtc::TurnCustomizer* customizer) { + webrtc::TurnCustomizer* customizer, + const webrtc::WebRtcKeyValueConfig* field_trials) { return Create(thread, factory, network, socket, username, password, - server_address, credentials, server_priority, customizer); + server_address, credentials, server_priority, customizer, + field_trials); } // Create a TURN port that will use a new socket, bound to `network` and @@ -114,7 +117,8 @@ class TurnPort : public Port { const std::vector& tls_alpn_protocols, const std::vector& tls_elliptic_curves, webrtc::TurnCustomizer* customizer, - rtc::SSLCertificateVerifier* tls_cert_verifier = nullptr) { + rtc::SSLCertificateVerifier* tls_cert_verifier = nullptr, + const webrtc::WebRtcKeyValueConfig* field_trials = nullptr) { // Do basic parameter validation. if (credentials.username.size() > kMaxTurnUsernameLength) { RTC_LOG(LS_ERROR) << "Attempt to use TURN with a too long username " @@ -122,7 +126,7 @@ class TurnPort : public Port { return nullptr; } // Do not connect to low-numbered ports. The default STUN port is 3478. - if (!AllowedTurnPort(server_address.address.port())) { + if (!AllowedTurnPort(server_address.address.port(), field_trials)) { RTC_LOG(LS_ERROR) << "Attempt to use TURN to connect to port " << server_address.address.port(); return nullptr; @@ -131,7 +135,7 @@ class TurnPort : public Port { return absl::WrapUnique(new TurnPort( thread, factory, network, min_port, max_port, username, password, server_address, credentials, server_priority, tls_alpn_protocols, - tls_elliptic_curves, customizer, tls_cert_verifier)); + tls_elliptic_curves, customizer, tls_cert_verifier, field_trials)); } // TODO(steveanton): Remove once downstream clients have moved to `Create`. @@ -149,11 +153,12 @@ class TurnPort : public Port { const std::vector& tls_alpn_protocols, const std::vector& tls_elliptic_curves, webrtc::TurnCustomizer* customizer, - rtc::SSLCertificateVerifier* tls_cert_verifier = nullptr) { + rtc::SSLCertificateVerifier* tls_cert_verifier = nullptr, + const webrtc::WebRtcKeyValueConfig* field_trials = nullptr) { return Create(thread, factory, network, min_port, max_port, username, password, server_address, credentials, server_priority, tls_alpn_protocols, tls_elliptic_curves, customizer, - tls_cert_verifier); + tls_cert_verifier, field_trials); } ~TurnPort() override; @@ -264,7 +269,8 @@ class TurnPort : public Port { const ProtocolAddress& server_address, const RelayCredentials& credentials, int server_priority, - webrtc::TurnCustomizer* customizer); + webrtc::TurnCustomizer* customizer, + const webrtc::WebRtcKeyValueConfig* field_trials = nullptr); TurnPort(rtc::Thread* thread, rtc::PacketSocketFactory* factory, @@ -279,7 +285,8 @@ class TurnPort : public Port { const std::vector& tls_alpn_protocols, const std::vector& tls_elliptic_curves, webrtc::TurnCustomizer* customizer, - rtc::SSLCertificateVerifier* tls_cert_verifier = nullptr); + rtc::SSLCertificateVerifier* tls_cert_verifier = nullptr, + const webrtc::WebRtcKeyValueConfig* field_trials = nullptr); // NOTE: This method needs to be accessible for StunPort // return true if entry was created (i.e channel_number consumed). @@ -304,7 +311,8 @@ class TurnPort : public Port { typedef std::map SocketOptionsMap; typedef std::set AttemptedServerSet; - static bool AllowedTurnPort(int port); + static bool AllowedTurnPort(int port, + const webrtc::WebRtcKeyValueConfig* field_trials); void OnMessage(rtc::Message* pmsg) override; bool CreateTurnClientSocket(); @@ -410,6 +418,8 @@ class TurnPort : public Port { // must outlive the TurnPort's lifetime. webrtc::TurnCustomizer* turn_customizer_ = nullptr; + const webrtc::WebRtcKeyValueConfig* field_trials_; + // Optional TurnLoggingId. // An identifier set by application that is added to TURN_ALLOCATE_REQUEST // and can be used to match client/backend logs. diff --git a/p2p/base/turn_port_unittest.cc b/p2p/base/turn_port_unittest.cc index 44d258363e..30ad2c009e 100644 --- a/p2p/base/turn_port_unittest.cc +++ b/p2p/base/turn_port_unittest.cc @@ -41,8 +41,8 @@ #include "rtc_base/thread.h" #include "rtc_base/time_utils.h" #include "rtc_base/virtual_socket_server.h" -#include "test/field_trial.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" using rtc::SocketAddress; @@ -293,9 +293,10 @@ class TurnPortTest : public ::testing::Test, const std::string& password, const ProtocolAddress& server_address) { RelayCredentials credentials(username, password); - turn_port_ = TurnPort::Create( - &main_, &socket_factory_, network, 0, 0, kIceUfrag1, kIcePwd1, - server_address, credentials, 0, {}, {}, turn_customizer_.get()); + turn_port_ = + TurnPort::Create(&main_, &socket_factory_, network, 0, 0, kIceUfrag1, + kIcePwd1, server_address, credentials, 0, {}, {}, + turn_customizer_.get(), nullptr, &field_trials_); if (!turn_port_) { return false; } @@ -327,9 +328,10 @@ class TurnPortTest : public ::testing::Test, } RelayCredentials credentials(username, password); - turn_port_ = TurnPort::Create( - &main_, &socket_factory_, MakeNetwork(kLocalAddr1), socket_.get(), - kIceUfrag1, kIcePwd1, server_address, credentials, 0, nullptr); + turn_port_ = + TurnPort::Create(&main_, &socket_factory_, MakeNetwork(kLocalAddr1), + socket_.get(), kIceUfrag1, kIcePwd1, server_address, + credentials, 0, nullptr, &field_trials_); // This TURN port will be the controlling. turn_port_->SetIceRole(ICEROLE_CONTROLLING); ConnectSignals(); @@ -760,6 +762,7 @@ class TurnPortTest : public ::testing::Test, } protected: + webrtc::test::ScopedKeyValueConfig field_trials_; rtc::ScopedFakeClock fake_clock_; // When a "create port" helper method is called with an IP, we create a // Network with that IP and add it to this list. Using a list instead of a @@ -1852,8 +1855,8 @@ TEST_F(TurnPortTest, TestTurnDangerousAlternateServer) { } TEST_F(TurnPortTest, TestTurnDangerousServerAllowedWithFieldTrial) { - webrtc::test::ScopedFieldTrials override_field_trials( - "WebRTC-Turn-AllowSystemPorts/Enabled/"); + webrtc::test::ScopedKeyValueConfig override_field_trials( + field_trials_, "WebRTC-Turn-AllowSystemPorts/Enabled/"); CreateTurnPort(kTurnUsername, kTurnPassword, kTurnDangerousProtoAddr); ASSERT_TRUE(turn_port_); } diff --git a/p2p/client/basic_port_allocator.cc b/p2p/client/basic_port_allocator.cc index 06eabb83dd..20032a99d7 100644 --- a/p2p/client/basic_port_allocator.cc +++ b/p2p/client/basic_port_allocator.cc @@ -20,6 +20,7 @@ #include "absl/algorithm/container.h" #include "absl/memory/memory.h" +#include "api/transport/field_trial_based_config.h" #include "p2p/base/basic_packet_socket_factory.h" #include "p2p/base/port.h" #include "p2p/base/stun_port.h" @@ -31,7 +32,6 @@ #include "rtc_base/logging.h" #include "rtc_base/task_utils/to_queued_task.h" #include "rtc_base/trace_event.h" -#include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/metrics.h" using rtc::CreateRandomId; @@ -152,7 +152,7 @@ BasicPortAllocator::BasicPortAllocator( webrtc::TurnCustomizer* customizer, RelayPortFactoryInterface* relay_port_factory) : network_manager_(network_manager), socket_factory_(socket_factory) { - InitRelayPortFactory(relay_port_factory); + Init(relay_port_factory, nullptr); RTC_DCHECK(relay_port_factory_ != nullptr); RTC_DCHECK(network_manager_ != nullptr); RTC_DCHECK(socket_factory_ != nullptr); @@ -162,7 +162,7 @@ BasicPortAllocator::BasicPortAllocator( BasicPortAllocator::BasicPortAllocator(rtc::NetworkManager* network_manager) : network_manager_(network_manager), socket_factory_(nullptr) { - InitRelayPortFactory(nullptr); + Init(nullptr, nullptr); RTC_DCHECK(relay_port_factory_ != nullptr); RTC_DCHECK(network_manager_ != nullptr); } @@ -177,7 +177,7 @@ BasicPortAllocator::BasicPortAllocator(rtc::NetworkManager* network_manager, rtc::PacketSocketFactory* socket_factory, const ServerAddresses& stun_servers) : network_manager_(network_manager), socket_factory_(socket_factory) { - InitRelayPortFactory(nullptr); + Init(nullptr, nullptr); RTC_DCHECK(relay_port_factory_ != nullptr); RTC_DCHECK(network_manager_ != nullptr); SetConfiguration(stun_servers, std::vector(), 0, @@ -251,14 +251,22 @@ void BasicPortAllocator::AddTurnServer(const RelayServerConfig& turn_server) { turn_port_prune_policy(), turn_customizer()); } -void BasicPortAllocator::InitRelayPortFactory( - RelayPortFactoryInterface* relay_port_factory) { +void BasicPortAllocator::Init( + RelayPortFactoryInterface* relay_port_factory, + const webrtc::WebRtcKeyValueConfig* field_trials) { if (relay_port_factory != nullptr) { relay_port_factory_ = relay_port_factory; } else { default_relay_port_factory_.reset(new TurnPortFactory()); relay_port_factory_ = default_relay_port_factory_.get(); } + + if (field_trials != nullptr) { + field_trials_ = field_trials; + } else { + owned_field_trials_ = std::make_unique(); + field_trials_ = owned_field_trials_.get(); + } } // BasicPortAllocatorSession @@ -602,8 +610,9 @@ void BasicPortAllocatorSession::UpdateIceParametersInternal() { void BasicPortAllocatorSession::GetPortConfigurations() { RTC_DCHECK_RUN_ON(network_thread_); - auto config = std::make_unique(allocator_->stun_servers(), - username(), password()); + auto config = std::make_unique( + allocator_->stun_servers(), username(), password(), + allocator()->field_trials()); for (const RelayServerConfig& turn_server : allocator_->turn_servers()) { config->AddRelay(turn_server); @@ -1565,6 +1574,7 @@ void AllocationSequence::CreateTurnPort(const RelayServerConfig& config) { args.server_address = &(*relay_port); args.config = &config; args.turn_customizer = session_->allocator()->turn_customizer(); + args.field_trials = session_->allocator()->field_trials(); std::unique_ptr port; // Shared socket mode must be enabled only for UDP based ports. Hence @@ -1658,24 +1668,19 @@ void AllocationSequence::OnPortDestroyed(PortInterface* port) { } } -// PortConfiguration -PortConfiguration::PortConfiguration(const rtc::SocketAddress& stun_address, - const std::string& username, - const std::string& password) - : stun_address(stun_address), username(username), password(password) { - if (!stun_address.IsNil()) - stun_servers.insert(stun_address); -} - -PortConfiguration::PortConfiguration(const ServerAddresses& stun_servers, - const std::string& username, - const std::string& password) +PortConfiguration::PortConfiguration( + const ServerAddresses& stun_servers, + const std::string& username, + const std::string& password, + const webrtc::WebRtcKeyValueConfig* field_trials) : stun_servers(stun_servers), username(username), password(password) { if (!stun_servers.empty()) stun_address = *(stun_servers.begin()); // Note that this won't change once the config is initialized. - use_turn_server_as_stun_server_disabled = - webrtc::field_trial::IsDisabled("WebRTC-UseTurnServerAsStunServer"); + if (field_trials) { + use_turn_server_as_stun_server_disabled = + field_trials->IsDisabled("WebRTC-UseTurnServerAsStunServer"); + } } ServerAddresses PortConfiguration::StunServers() { diff --git a/p2p/client/basic_port_allocator.h b/p2p/client/basic_port_allocator.h index b1dc7b12a2..946aa6b17e 100644 --- a/p2p/client/basic_port_allocator.h +++ b/p2p/client/basic_port_allocator.h @@ -16,6 +16,7 @@ #include #include "api/turn_customizer.h" +#include "api/webrtc_key_value_config.h" #include "p2p/base/port_allocator.h" #include "p2p/client/relay_port_factory_interface.h" #include "p2p/client/turn_port_factory.h" @@ -80,15 +81,23 @@ class RTC_EXPORT BasicPortAllocator : public PortAllocator { void SetVpnList(const std::vector& vpn_list) override; + const webrtc::WebRtcKeyValueConfig* field_trials() const { + return field_trials_; + } + private: void OnIceRegathering(PortAllocatorSession* session, IceRegatheringReason reason); - // This function makes sure that relay_port_factory_ is set properly. - void InitRelayPortFactory(RelayPortFactoryInterface* relay_port_factory); + // This function makes sure that relay_port_factory_ and field_trials_ is set + // properly. + void Init(RelayPortFactoryInterface* relay_port_factory, + const webrtc::WebRtcKeyValueConfig* field_trials); bool MdnsObfuscationEnabled() const override; + const webrtc::WebRtcKeyValueConfig* field_trials_; + std::unique_ptr owned_field_trials_; rtc::NetworkManager* network_manager_; rtc::PacketSocketFactory* socket_factory_; int network_ignore_mask_ = rtc::kDefaultNetworkIgnoreMask; @@ -298,14 +307,10 @@ struct RTC_EXPORT PortConfiguration { typedef std::vector RelayList; RelayList relays; - // TODO(jiayl): remove this ctor when Chrome is updated. - PortConfiguration(const rtc::SocketAddress& stun_address, - const std::string& username, - const std::string& password); - PortConfiguration(const ServerAddresses& stun_servers, const std::string& username, - const std::string& password); + const std::string& password, + const webrtc::WebRtcKeyValueConfig* field_trials = nullptr); // Returns addresses of both the explicitly configured STUN servers, // and TURN servers that should be used as STUN servers. diff --git a/p2p/client/basic_port_allocator_unittest.cc b/p2p/client/basic_port_allocator_unittest.cc index 6db82d2e30..aa04b78855 100644 --- a/p2p/client/basic_port_allocator_unittest.cc +++ b/p2p/client/basic_port_allocator_unittest.cc @@ -42,9 +42,9 @@ #include "rtc_base/thread.h" #include "rtc_base/virtual_socket_server.h" #include "system_wrappers/include/metrics.h" -#include "test/field_trial.h" #include "test/gmock.h" #include "test/gtest.h" +#include "test/scoped_key_value_config.h" using rtc::IPAddress; using rtc::SocketAddress; @@ -2444,12 +2444,12 @@ TEST_F(BasicPortAllocatorTest, TestUseTurnServerAsStunSever) { } TEST_F(BasicPortAllocatorTest, TestDoNotUseTurnServerAsStunSever) { - webrtc::test::ScopedFieldTrials field_trials( + webrtc::test::ScopedKeyValueConfig field_trials( "WebRTC-UseTurnServerAsStunServer/Disabled/"); ServerAddresses stun_servers; stun_servers.insert(kStunAddr); PortConfiguration port_config(stun_servers, "" /* user_name */, - "" /* password */); + "" /* password */, &field_trials); RelayServerConfig turn_servers = CreateTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr); port_config.AddRelay(turn_servers); diff --git a/p2p/client/relay_port_factory_interface.h b/p2p/client/relay_port_factory_interface.h index d3884126a6..cb4eb97483 100644 --- a/p2p/client/relay_port_factory_interface.h +++ b/p2p/client/relay_port_factory_interface.h @@ -26,6 +26,7 @@ class Thread; namespace webrtc { class TurnCustomizer; +class WebRtcKeyValueConfig; } // namespace webrtc namespace cricket { @@ -44,6 +45,7 @@ struct CreateRelayPortArgs { std::string username; std::string password; webrtc::TurnCustomizer* turn_customizer; + const webrtc::WebRtcKeyValueConfig* field_trials = nullptr; }; inline CreateRelayPortArgs::CreateRelayPortArgs() {} diff --git a/p2p/client/turn_port_factory.cc b/p2p/client/turn_port_factory.cc index feaada3a1c..07321b85d6 100644 --- a/p2p/client/turn_port_factory.cc +++ b/p2p/client/turn_port_factory.cc @@ -26,7 +26,8 @@ std::unique_ptr TurnPortFactory::Create( auto port = TurnPort::CreateUnique( args.network_thread, args.socket_factory, args.network, udp_socket, args.username, args.password, *args.server_address, - args.config->credentials, args.config->priority, args.turn_customizer); + args.config->credentials, args.config->priority, args.turn_customizer, + args.field_trials); if (!port) return nullptr; port->SetTlsCertPolicy(args.config->tls_cert_policy); @@ -42,7 +43,7 @@ std::unique_ptr TurnPortFactory::Create(const CreateRelayPortArgs& args, max_port, args.username, args.password, *args.server_address, args.config->credentials, args.config->priority, args.config->tls_alpn_protocols, args.config->tls_elliptic_curves, - args.turn_customizer, args.config->tls_cert_verifier); + args.turn_customizer, args.config->tls_cert_verifier, args.field_trials); if (!port) return nullptr; port->SetTlsCertPolicy(args.config->tls_cert_policy); diff --git a/pc/jsep_transport_controller.cc b/pc/jsep_transport_controller.cc index 6c69130a38..727a30a1ae 100644 --- a/pc/jsep_transport_controller.cc +++ b/pc/jsep_transport_controller.cc @@ -400,6 +400,7 @@ JsepTransportController::CreateIceTransport(const std::string& transport_name, init.set_port_allocator(port_allocator_); init.set_async_dns_resolver_factory(async_dns_resolver_factory_); init.set_event_log(config_.event_log); + init.set_field_trials(config_.field_trials); return config_.ice_transport_factory->CreateIceTransport( transport_name, component, std::move(init)); } From ae4fb618d7038ea7421844a62dab8193dfb2b616 Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Mon, 14 Mar 2022 12:31:46 +0100 Subject: [PATCH 206/847] Cleanup RtpToNtpEstimator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Use NtpTime instead of pair of uint32_t to represent ntp time - Increase precision estimate with NtpTime precision instead of ms precision - Hide helper structs as private types - Modernize interface to prefer return values over output parameters - embed LinearRegression helper into the only user: UpdateParameters Bug: webrtc:13757 Change-Id: I0a62a03e2869b2ae1eacaa15253accc43ba0a598 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254780 Reviewed-by: Niels Moller Reviewed-by: Erik Språng Commit-Queue: Danil Chapovalov Cr-Commit-Position: refs/heads/main@{#36232} --- .../source/remote_ntp_time_estimator.cc | 25 +- .../include/rtp_to_ntp_estimator.h | 65 ++-- .../source/rtp_to_ntp_estimator.cc | 165 +++----- .../source/rtp_to_ntp_estimator_unittest.cc | 353 +++++++----------- video/rtp_streams_synchronizer2.cc | 33 +- video/stream_synchronization.cc | 18 +- video/stream_synchronization_unittest.cc | 17 +- 7 files changed, 266 insertions(+), 410 deletions(-) diff --git a/modules/rtp_rtcp/source/remote_ntp_time_estimator.cc b/modules/rtp_rtcp/source/remote_ntp_time_estimator.cc index 723064eeba..b1602e5dcd 100644 --- a/modules/rtp_rtcp/source/remote_ntp_time_estimator.cc +++ b/modules/rtp_rtcp/source/remote_ntp_time_estimator.cc @@ -40,21 +40,21 @@ bool RemoteNtpTimeEstimator::UpdateRtcpTimestamp(int64_t rtt, uint32_t ntp_secs, uint32_t ntp_frac, uint32_t rtp_timestamp) { - bool new_rtcp_sr = false; - if (!rtp_to_ntp_.UpdateMeasurements(ntp_secs, ntp_frac, rtp_timestamp, - &new_rtcp_sr)) { - return false; - } - if (!new_rtcp_sr) { - // No new RTCP SR since last time this function was called. - return true; + NtpTime sender_send_time(ntp_secs, ntp_frac); + switch (rtp_to_ntp_.UpdateMeasurements(sender_send_time, rtp_timestamp)) { + case RtpToNtpEstimator::kInvalidMeasurement: + return false; + case RtpToNtpEstimator::kSameMeasurement: + // No new RTCP SR since last time this function was called. + return true; + case RtpToNtpEstimator::kNewMeasurement: + break; } // Update extrapolator with the new arrival time. // The extrapolator assumes the ntp time. int64_t receiver_arrival_time_ms = clock_->CurrentNtpInMilliseconds(); - int64_t sender_send_time_ms = NtpTime(ntp_secs, ntp_frac).ToMs(); - int64_t sender_arrival_time_ms = sender_send_time_ms + rtt / 2; + int64_t sender_arrival_time_ms = sender_send_time.ToMs() + rtt / 2; int64_t remote_to_local_clocks_offset = receiver_arrival_time_ms - sender_arrival_time_ms; ntp_clocks_offset_estimator_.Insert(remote_to_local_clocks_offset); @@ -62,10 +62,11 @@ bool RemoteNtpTimeEstimator::UpdateRtcpTimestamp(int64_t rtt, } int64_t RemoteNtpTimeEstimator::Estimate(uint32_t rtp_timestamp) { - int64_t sender_capture_ntp_ms = 0; - if (!rtp_to_ntp_.Estimate(rtp_timestamp, &sender_capture_ntp_ms)) { + NtpTime sender_capture = rtp_to_ntp_.Estimate(rtp_timestamp); + if (!sender_capture.Valid()) { return -1; } + int64_t sender_capture_ntp_ms = sender_capture.ToMs(); int64_t remote_to_local_clocks_offset = ntp_clocks_offset_estimator_.GetFilteredValue(); diff --git a/system_wrappers/include/rtp_to_ntp_estimator.h b/system_wrappers/include/rtp_to_ntp_estimator.h index 175063351a..3b62b78608 100644 --- a/system_wrappers/include/rtp_to_ntp_estimator.h +++ b/system_wrappers/include/rtp_to_ntp_estimator.h @@ -18,60 +18,51 @@ #include "absl/types/optional.h" #include "modules/include/module_common_types_public.h" #include "rtc_base/checks.h" -#include "rtc_base/numerics/moving_median_filter.h" #include "system_wrappers/include/ntp_time.h" namespace webrtc { -// Class for converting an RTP timestamp to the NTP domain in milliseconds. + +// Converts an RTP timestamp to the NTP domain. // The class needs to be trained with (at least 2) RTP/NTP timestamp pairs from // RTCP sender reports before the convertion can be done. class RtpToNtpEstimator { public: - RtpToNtpEstimator(); - ~RtpToNtpEstimator(); + static constexpr int kMaxInvalidSamples = 3; - // RTP and NTP timestamp pair from a RTCP SR report. - struct RtcpMeasurement { - RtcpMeasurement(uint32_t ntp_secs, - uint32_t ntp_frac, - int64_t unwrapped_timestamp); - bool IsEqual(const RtcpMeasurement& other) const; + RtpToNtpEstimator() = default; + RtpToNtpEstimator(const RtpToNtpEstimator&) = delete; + RtpToNtpEstimator& operator=(const RtpToNtpEstimator&) = delete; + ~RtpToNtpEstimator() = default; - NtpTime ntp_time; - int64_t unwrapped_rtp_timestamp; - }; + enum UpdateResult { kInvalidMeasurement, kSameMeasurement, kNewMeasurement }; + // Updates measurements with RTP/NTP timestamp pair from a RTCP sender report. + UpdateResult UpdateMeasurements(NtpTime ntp, uint32_t rtp_timestamp); - // Estimated parameters from RTP and NTP timestamp pairs in `measurements_`. - struct Parameters { - Parameters() : frequency_khz(0.0), offset_ms(0.0) {} + // Converts an RTP timestamp to the NTP domain. + // Returns invalid NtpTime (i.e. NtpTime(0)) on failure. + NtpTime Estimate(uint32_t rtp_timestamp) const; - Parameters(double frequency_khz, double offset_ms) - : frequency_khz(frequency_khz), offset_ms(offset_ms) {} + // Returns estimated rtp_timestamp frequency, or 0 on failure. + double EstimatedFrequencyKhz() const; - double frequency_khz; - double offset_ms; + private: + // Estimated parameters from RTP and NTP timestamp pairs in `measurements_`. + // Defines linear estimation: NtpTime (in units of 1s/2^32) = + // `Parameters::slope` * rtp_timestamp + `Parameters::offset`. + struct Parameters { + double slope; + double offset; }; - // Updates measurements with RTP/NTP timestamp pair from a RTCP sender report. - // `new_rtcp_sr` is set to true if a new report is added. - bool UpdateMeasurements(uint32_t ntp_secs, - uint32_t ntp_frac, - uint32_t rtp_timestamp, - bool* new_rtcp_sr); - - // Converts an RTP timestamp to the NTP domain in milliseconds. - // Returns true on success, false otherwise. - bool Estimate(int64_t rtp_timestamp, int64_t* ntp_timestamp_ms) const; - - // Returns estimated rtp to ntp linear transform parameters. - const absl::optional params() const; - - static const int kMaxInvalidSamples = 3; + // RTP and NTP timestamp pair from a RTCP SR report. + struct RtcpMeasurement { + NtpTime ntp_time; + int64_t unwrapped_rtp_timestamp; + }; - private: void UpdateParameters(); - int consecutive_invalid_samples_; + int consecutive_invalid_samples_ = 0; std::list measurements_; absl::optional params_; mutable TimestampUnwrapper unwrapper_; diff --git a/system_wrappers/source/rtp_to_ntp_estimator.cc b/system_wrappers/source/rtp_to_ntp_estimator.cc index d0b0ad447f..ef5d9a7508 100644 --- a/system_wrappers/source/rtp_to_ntp_estimator.cc +++ b/system_wrappers/source/rtp_to_ntp_estimator.cc @@ -18,132 +18,85 @@ #include "api/array_view.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" +#include "rtc_base/numerics/safe_conversions.h" namespace webrtc { namespace { // Maximum number of RTCP SR reports to use to map between RTP and NTP. -const size_t kNumRtcpReportsToUse = 20; +constexpr size_t kNumRtcpReportsToUse = 20; // Don't allow NTP timestamps to jump more than 1 hour. Chosen arbitrary as big // enough to not affect normal use-cases. Yet it is smaller than RTP wrap-around // half-period (90khz RTP clock wrap-arounds every 13.25 hours). After half of // wrap-around period it is impossible to unwrap RTP timestamps correctly. -const int kMaxAllowedRtcpNtpIntervalMs = 60 * 60 * 1000; - -bool Contains(const std::list& measurements, - const RtpToNtpEstimator::RtcpMeasurement& other) { - for (const auto& measurement : measurements) { - if (measurement.IsEqual(other)) - return true; - } - return false; -} +constexpr uint64_t kMaxAllowedRtcpNtpInterval = uint64_t{60 * 60} << 32; +} // namespace -// Given x[] and y[] writes out such k and b that line y=k*x+b approximates -// given points in the best way (Least Squares Method). -bool LinearRegression(rtc::ArrayView x, - rtc::ArrayView y, - double* k, - double* b) { - size_t n = x.size(); +void RtpToNtpEstimator::UpdateParameters() { + size_t n = measurements_.size(); if (n < 2) - return false; + return; - if (y.size() != n) - return false; + // Run linear regression: + // Given x[] and y[] writes out such k and b that line y=k*x+b approximates + // given points in the best way (Least Squares Method). + auto x = [](const RtcpMeasurement& m) { + return static_cast(m.unwrapped_rtp_timestamp); + }; + auto y = [](const RtcpMeasurement& m) { + return static_cast(static_cast(m.ntp_time)); + }; double avg_x = 0; double avg_y = 0; - for (size_t i = 0; i < n; ++i) { - avg_x += x[i]; - avg_y += y[i]; + for (const RtcpMeasurement& m : measurements_) { + avg_x += x(m); + avg_y += y(m); } avg_x /= n; avg_y /= n; double variance_x = 0; double covariance_xy = 0; - for (size_t i = 0; i < n; ++i) { - double normalized_x = x[i] - avg_x; - double normalized_y = y[i] - avg_y; + for (const RtcpMeasurement& m : measurements_) { + double normalized_x = x(m) - avg_x; + double normalized_y = y(m) - avg_y; variance_x += normalized_x * normalized_x; covariance_xy += normalized_x * normalized_y; } if (std::fabs(variance_x) < 1e-8) - return false; - - *k = static_cast(covariance_xy / variance_x); - *b = static_cast(avg_y - (*k) * avg_x); - return true; -} - -} // namespace - -RtpToNtpEstimator::RtcpMeasurement::RtcpMeasurement(uint32_t ntp_secs, - uint32_t ntp_frac, - int64_t unwrapped_timestamp) - : ntp_time(ntp_secs, ntp_frac), - unwrapped_rtp_timestamp(unwrapped_timestamp) {} - -bool RtpToNtpEstimator::RtcpMeasurement::IsEqual( - const RtcpMeasurement& other) const { - // Use || since two equal timestamps will result in zero frequency and in - // RtpToNtpMs, `rtp_timestamp_ms` is estimated by dividing by the frequency. - return (ntp_time == other.ntp_time) || - (unwrapped_rtp_timestamp == other.unwrapped_rtp_timestamp); -} - -// Class for converting an RTP timestamp to the NTP domain. -RtpToNtpEstimator::RtpToNtpEstimator() : consecutive_invalid_samples_(0) {} - -RtpToNtpEstimator::~RtpToNtpEstimator() {} - -void RtpToNtpEstimator::UpdateParameters() { - if (measurements_.size() < 2) return; - std::vector x; - std::vector y; - x.reserve(measurements_.size()); - y.reserve(measurements_.size()); - for (auto it = measurements_.begin(); it != measurements_.end(); ++it) { - x.push_back(it->unwrapped_rtp_timestamp); - y.push_back(it->ntp_time.ToMs()); - } - double slope, offset; - - if (!LinearRegression(x, y, &slope, &offset)) { - return; - } - - params_.emplace(1 / slope, offset); + double k = covariance_xy / variance_x; + double b = avg_y - k * avg_x; + params_ = {{.slope = k, .offset = b}}; } -bool RtpToNtpEstimator::UpdateMeasurements(uint32_t ntp_secs, - uint32_t ntp_frac, - uint32_t rtp_timestamp, - bool* new_rtcp_sr) { - *new_rtcp_sr = false; - +RtpToNtpEstimator::UpdateResult RtpToNtpEstimator::UpdateMeasurements( + NtpTime ntp, + uint32_t rtp_timestamp) { int64_t unwrapped_rtp_timestamp = unwrapper_.Unwrap(rtp_timestamp); - RtcpMeasurement new_measurement(ntp_secs, ntp_frac, unwrapped_rtp_timestamp); + RtcpMeasurement new_measurement = { + .ntp_time = ntp, .unwrapped_rtp_timestamp = unwrapped_rtp_timestamp}; - if (Contains(measurements_, new_measurement)) { - // RTCP SR report already added. - return true; + for (const RtcpMeasurement& measurement : measurements_) { + // Use || since two equal timestamps will result in zero frequency. + if (measurement.ntp_time == ntp || + measurement.unwrapped_rtp_timestamp == unwrapped_rtp_timestamp) { + return kSameMeasurement; + } } if (!new_measurement.ntp_time.Valid()) - return false; + return kInvalidMeasurement; - int64_t ntp_ms_new = new_measurement.ntp_time.ToMs(); + uint64_t ntp_new = static_cast(new_measurement.ntp_time); bool invalid_sample = false; if (!measurements_.empty()) { int64_t old_rtp_timestamp = measurements_.front().unwrapped_rtp_timestamp; - int64_t old_ntp_ms = measurements_.front().ntp_time.ToMs(); - if (ntp_ms_new <= old_ntp_ms || - ntp_ms_new > old_ntp_ms + kMaxAllowedRtcpNtpIntervalMs) { + uint64_t old_ntp = static_cast(measurements_.front().ntp_time); + if (ntp_new <= old_ntp || ntp_new > old_ntp + kMaxAllowedRtcpNtpInterval) { invalid_sample = true; } else if (unwrapped_rtp_timestamp <= old_rtp_timestamp) { RTC_LOG(LS_WARNING) @@ -158,7 +111,7 @@ bool RtpToNtpEstimator::UpdateMeasurements(uint32_t ntp_secs, if (invalid_sample) { ++consecutive_invalid_samples_; if (consecutive_invalid_samples_ < kMaxInvalidSamples) { - return false; + return kInvalidMeasurement; } RTC_LOG(LS_WARNING) << "Multiple consecutively invalid RTCP SR reports, " "clearing measurements."; @@ -172,37 +125,29 @@ bool RtpToNtpEstimator::UpdateMeasurements(uint32_t ntp_secs, measurements_.pop_back(); measurements_.push_front(new_measurement); - *new_rtcp_sr = true; // List updated, calculate new parameters. UpdateParameters(); - return true; + return kNewMeasurement; } -bool RtpToNtpEstimator::Estimate(int64_t rtp_timestamp, - int64_t* ntp_timestamp_ms) const { +NtpTime RtpToNtpEstimator::Estimate(uint32_t rtp_timestamp) const { if (!params_) - return false; - - int64_t rtp_timestamp_unwrapped = unwrapper_.Unwrap(rtp_timestamp); - - // params_calculated_ should not be true unless ms params.frequency_khz has - // been calculated to something non zero. - RTC_DCHECK_NE(params_->frequency_khz, 0.0); - double rtp_ms = - static_cast(rtp_timestamp_unwrapped) / params_->frequency_khz + - params_->offset_ms + 0.5f; + return NtpTime(); - if (rtp_ms < 0) - return false; + double estimated = + static_cast(unwrapper_.Unwrap(rtp_timestamp)) * params_->slope + + params_->offset + 0.5f; - *ntp_timestamp_ms = rtp_ms; - - return true; + return NtpTime(rtc::saturated_cast(estimated)); } -const absl::optional RtpToNtpEstimator::params() - const { - return params_; +double RtpToNtpEstimator::EstimatedFrequencyKhz() const { + if (!params_.has_value()) { + return 0.0; + } + static constexpr double kNtpUnitPerMs = 4.294967296E6; // 2^32 / 1000. + return kNtpUnitPerMs / params_->slope; } + } // namespace webrtc diff --git a/system_wrappers/source/rtp_to_ntp_estimator_unittest.cc b/system_wrappers/source/rtp_to_ntp_estimator_unittest.cc index 14bc6e0a89..29de76178b 100644 --- a/system_wrappers/source/rtp_to_ntp_estimator_unittest.cc +++ b/system_wrappers/source/rtp_to_ntp_estimator_unittest.cc @@ -17,332 +17,249 @@ namespace webrtc { namespace { -const uint32_t kOneMsInNtpFrac = 4294967; -const uint32_t kOneHourInNtpSec = 60 * 60; -const uint32_t kTimestampTicksPerMs = 90; +constexpr uint64_t kOneMsInNtp = 4294967; +constexpr uint64_t kOneHourInNtp = uint64_t{60 * 60} << 32; +constexpr uint32_t kTimestampTicksPerMs = 90; } // namespace TEST(WrapAroundTests, OldRtcpWrapped_OldRtpTimestamp) { RtpToNtpEstimator estimator; - bool new_sr; - uint32_t ntp_sec = 0; - uint32_t ntp_frac = 1; - uint32_t timestamp = 0; - EXPECT_TRUE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - ntp_frac += kOneMsInNtpFrac; - timestamp -= kTimestampTicksPerMs; + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(kOneMsInNtp), 0), + RtpToNtpEstimator::kNewMeasurement); // No wraparound will be detected, since we are not allowed to wrap below 0, // but there will be huge rtp timestamp jump, e.g. old_timestamp = 0, // new_timestamp = 4294967295, which should be detected. - EXPECT_FALSE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(2 * kOneMsInNtp), + -kTimestampTicksPerMs), + RtpToNtpEstimator::kInvalidMeasurement); } TEST(WrapAroundTests, OldRtcpWrapped_OldRtpTimestamp_Wraparound_Detected) { RtpToNtpEstimator estimator; - bool new_sr; - uint32_t ntp_sec = 0; - uint32_t ntp_frac = 1; - uint32_t timestamp = 0xFFFFFFFE; - EXPECT_TRUE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - ntp_frac += 2 * kOneMsInNtpFrac; - timestamp += 2 * kTimestampTicksPerMs; - EXPECT_TRUE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - ntp_frac += kOneMsInNtpFrac; - timestamp -= kTimestampTicksPerMs; + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(1), 0xFFFFFFFE), + RtpToNtpEstimator::kNewMeasurement); + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(1 + 2 * kOneMsInNtp), + 0xFFFFFFFE + 2 * kTimestampTicksPerMs), + RtpToNtpEstimator::kNewMeasurement); // Expected to fail since the older RTCP has a smaller RTP timestamp than the // newer (old:10, new:4294967206). - EXPECT_FALSE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(1 + 3 * kOneMsInNtp), + 0xFFFFFFFE + kTimestampTicksPerMs), + RtpToNtpEstimator::kInvalidMeasurement); } TEST(WrapAroundTests, NewRtcpWrapped) { RtpToNtpEstimator estimator; - bool new_sr; - uint32_t ntp_sec = 0; - uint32_t ntp_frac = 1; - uint32_t timestamp = 0xFFFFFFFF; - EXPECT_TRUE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - ntp_frac += kOneMsInNtpFrac; - timestamp += kTimestampTicksPerMs; - EXPECT_TRUE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - int64_t timestamp_ms = -1; - EXPECT_TRUE(estimator.Estimate(0xFFFFFFFF, ×tamp_ms)); + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(1), 0xFFFFFFFF), + RtpToNtpEstimator::kNewMeasurement); + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(1 + kOneMsInNtp), + 0xFFFFFFFF + kTimestampTicksPerMs), + RtpToNtpEstimator::kNewMeasurement); // Since this RTP packet has the same timestamp as the RTCP packet constructed // at time 0 it should be mapped to 0 as well. - EXPECT_EQ(0, timestamp_ms); + EXPECT_EQ(estimator.Estimate(0xFFFFFFFF), NtpTime(1)); } TEST(WrapAroundTests, RtpWrapped) { RtpToNtpEstimator estimator; - bool new_sr; - uint32_t ntp_sec = 0; - uint32_t ntp_frac = 1; - uint32_t timestamp = 0xFFFFFFFF - 2 * kTimestampTicksPerMs; - EXPECT_TRUE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - ntp_frac += kOneMsInNtpFrac; - timestamp += kTimestampTicksPerMs; - EXPECT_TRUE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(1), + 0xFFFFFFFF - 2 * kTimestampTicksPerMs), + RtpToNtpEstimator::kNewMeasurement); + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(1 + kOneMsInNtp), + 0xFFFFFFFF - kTimestampTicksPerMs), + RtpToNtpEstimator::kNewMeasurement); - int64_t timestamp_ms = -1; - EXPECT_TRUE( - estimator.Estimate(0xFFFFFFFF - 2 * kTimestampTicksPerMs, ×tamp_ms)); // Since this RTP packet has the same timestamp as the RTCP packet constructed // at time 0 it should be mapped to 0 as well. - EXPECT_EQ(0, timestamp_ms); + EXPECT_EQ(estimator.Estimate(0xFFFFFFFF - 2 * kTimestampTicksPerMs), + NtpTime(1)); // Two kTimestampTicksPerMs advanced. - timestamp += kTimestampTicksPerMs; - EXPECT_TRUE(estimator.Estimate(timestamp, ×tamp_ms)); - EXPECT_EQ(2, timestamp_ms); + EXPECT_EQ(estimator.Estimate(0xFFFFFFFF), NtpTime(1 + 2 * kOneMsInNtp)); // Wrapped rtp. - timestamp += kTimestampTicksPerMs; - EXPECT_TRUE(estimator.Estimate(timestamp, ×tamp_ms)); - EXPECT_EQ(3, timestamp_ms); + EXPECT_EQ(estimator.Estimate(0xFFFFFFFF + kTimestampTicksPerMs), + NtpTime(1 + 3 * kOneMsInNtp)); } TEST(WrapAroundTests, OldRtp_RtcpsWrapped) { RtpToNtpEstimator estimator; - bool new_sr; - uint32_t ntp_sec = 0; - uint32_t ntp_frac = 1; - uint32_t timestamp = 0xFFFFFFFF; - EXPECT_TRUE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - ntp_frac += kOneMsInNtpFrac; - timestamp += kTimestampTicksPerMs; - EXPECT_TRUE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - timestamp -= 2 * kTimestampTicksPerMs; - int64_t timestamp_ms = 0xFFFFFFFF; - EXPECT_FALSE(estimator.Estimate(timestamp, ×tamp_ms)); + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(1), 0xFFFFFFFF), + RtpToNtpEstimator::kNewMeasurement); + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(1 + kOneMsInNtp), + 0xFFFFFFFF + kTimestampTicksPerMs), + RtpToNtpEstimator::kNewMeasurement); + + EXPECT_FALSE(estimator.Estimate(0xFFFFFFFF - kTimestampTicksPerMs).Valid()); } TEST(WrapAroundTests, OldRtp_NewRtcpWrapped) { RtpToNtpEstimator estimator; - bool new_sr; - uint32_t ntp_sec = 0; - uint32_t ntp_frac = 1; - uint32_t timestamp = 0xFFFFFFFF; - EXPECT_TRUE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - ntp_frac += kOneMsInNtpFrac; - timestamp += kTimestampTicksPerMs; - EXPECT_TRUE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - timestamp -= kTimestampTicksPerMs; - int64_t timestamp_ms = -1; - EXPECT_TRUE(estimator.Estimate(timestamp, ×tamp_ms)); + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(1), 0xFFFFFFFF), + RtpToNtpEstimator::kNewMeasurement); + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(1 + kOneMsInNtp), + 0xFFFFFFFF + kTimestampTicksPerMs), + RtpToNtpEstimator::kNewMeasurement); + // Constructed at the same time as the first RTCP and should therefore be // mapped to zero. - EXPECT_EQ(0, timestamp_ms); + EXPECT_EQ(estimator.Estimate(0xFFFFFFFF), NtpTime(1)); } TEST(WrapAroundTests, GracefullyHandleRtpJump) { RtpToNtpEstimator estimator; - bool new_sr; - uint32_t ntp_sec = 0; - uint32_t ntp_frac = 1; - uint32_t timestamp = 0; - EXPECT_TRUE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - ntp_frac += kOneMsInNtpFrac; - timestamp += kTimestampTicksPerMs; - EXPECT_TRUE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - ntp_frac += kOneMsInNtpFrac; - timestamp -= kTimestampTicksPerMs; - int64_t timestamp_ms = -1; - EXPECT_TRUE(estimator.Estimate(timestamp, ×tamp_ms)); + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(1), 0xFFFFFFFF), + RtpToNtpEstimator::kNewMeasurement); + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(1 + kOneMsInNtp), + 0xFFFFFFFF + kTimestampTicksPerMs), + RtpToNtpEstimator::kNewMeasurement); + // Constructed at the same time as the first RTCP and should therefore be // mapped to zero. - EXPECT_EQ(0, timestamp_ms); + EXPECT_EQ(estimator.Estimate(0xFFFFFFFF), NtpTime(1)); - timestamp -= 0xFFFFF; + uint32_t timestamp = 0xFFFFFFFF - 0xFFFFF; + uint64_t ntp_raw = 1 + 2 * kOneMsInNtp; for (int i = 0; i < RtpToNtpEstimator::kMaxInvalidSamples - 1; ++i) { - EXPECT_FALSE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - ntp_frac += kOneMsInNtpFrac; + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(ntp_raw), timestamp), + RtpToNtpEstimator::kInvalidMeasurement); + ntp_raw += kOneMsInNtp; timestamp += kTimestampTicksPerMs; } - EXPECT_TRUE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - ntp_frac += kOneMsInNtpFrac; - timestamp += kTimestampTicksPerMs; - EXPECT_TRUE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - ntp_frac += kOneMsInNtpFrac; + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(ntp_raw), timestamp), + RtpToNtpEstimator::kNewMeasurement); + ntp_raw += kOneMsInNtp; timestamp += kTimestampTicksPerMs; + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(ntp_raw), timestamp), + RtpToNtpEstimator::kNewMeasurement); - timestamp_ms = -1; - EXPECT_TRUE(estimator.Estimate(timestamp, ×tamp_ms)); - // 6 milliseconds has passed since the start of the test. - EXPECT_EQ(6, timestamp_ms); + EXPECT_EQ(estimator.Estimate(timestamp), NtpTime(ntp_raw)); } TEST(UpdateRtcpMeasurementTests, FailsForZeroNtp) { RtpToNtpEstimator estimator; - uint32_t ntp_sec = 0; - uint32_t ntp_frac = 0; - uint32_t timestamp = 0x12345678; - bool new_sr; - EXPECT_FALSE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - EXPECT_FALSE(new_sr); + + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(0), 0x12345678), + RtpToNtpEstimator::kInvalidMeasurement); } TEST(UpdateRtcpMeasurementTests, FailsForEqualNtp) { RtpToNtpEstimator estimator; - uint32_t ntp_sec = 0; - uint32_t ntp_frac = 699925050; + NtpTime ntp(0, 699925050); uint32_t timestamp = 0x12345678; - bool new_sr; - EXPECT_TRUE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - EXPECT_TRUE(new_sr); + + EXPECT_EQ(estimator.UpdateMeasurements(ntp, timestamp), + RtpToNtpEstimator::kNewMeasurement); // Ntp time already added, list not updated. - ++timestamp; - EXPECT_TRUE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - EXPECT_FALSE(new_sr); + EXPECT_EQ(estimator.UpdateMeasurements(ntp, timestamp + 1), + RtpToNtpEstimator::kSameMeasurement); } TEST(UpdateRtcpMeasurementTests, FailsForOldNtp) { RtpToNtpEstimator estimator; - uint32_t ntp_sec = 1; - uint32_t ntp_frac = 699925050; + uint64_t ntp_raw = 699925050; + NtpTime ntp(ntp_raw); uint32_t timestamp = 0x12345678; - bool new_sr; - EXPECT_TRUE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - EXPECT_TRUE(new_sr); + EXPECT_EQ(estimator.UpdateMeasurements(ntp, timestamp), + RtpToNtpEstimator::kNewMeasurement); + // Old ntp time, list not updated. - ntp_frac -= kOneMsInNtpFrac; - timestamp += kTimestampTicksPerMs; - EXPECT_FALSE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(ntp_raw - kOneMsInNtp), + timestamp + kTimestampTicksPerMs), + RtpToNtpEstimator::kInvalidMeasurement); } TEST(UpdateRtcpMeasurementTests, FailsForTooNewNtp) { RtpToNtpEstimator estimator; - uint32_t ntp_sec = 1; - uint32_t ntp_frac = 699925050; + + uint64_t ntp_raw = 699925050; uint32_t timestamp = 0x12345678; - bool new_sr; - EXPECT_TRUE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - EXPECT_TRUE(new_sr); + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(ntp_raw), timestamp), + RtpToNtpEstimator::kNewMeasurement); + // Ntp time from far future, list not updated. - ntp_sec += kOneHourInNtpSec * 2; - timestamp += kTimestampTicksPerMs * 10; - EXPECT_FALSE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(ntp_raw + 2 * kOneHourInNtp), + timestamp + 10 * kTimestampTicksPerMs), + RtpToNtpEstimator::kInvalidMeasurement); } TEST(UpdateRtcpMeasurementTests, FailsForEqualTimestamp) { RtpToNtpEstimator estimator; - uint32_t ntp_sec = 0; - uint32_t ntp_frac = 2; + uint32_t timestamp = 0x12345678; - bool new_sr; - EXPECT_TRUE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - EXPECT_TRUE(new_sr); + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(2), timestamp), + RtpToNtpEstimator::kNewMeasurement); // Timestamp already added, list not updated. - ++ntp_frac; - EXPECT_TRUE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - EXPECT_FALSE(new_sr); + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(3), timestamp), + RtpToNtpEstimator::kSameMeasurement); } TEST(UpdateRtcpMeasurementTests, FailsForOldRtpTimestamp) { RtpToNtpEstimator estimator; - uint32_t ntp_sec = 0; - uint32_t ntp_frac = 2; uint32_t timestamp = 0x12345678; - bool new_sr; - EXPECT_TRUE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - EXPECT_TRUE(new_sr); + + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(2), timestamp), + RtpToNtpEstimator::kNewMeasurement); // Old timestamp, list not updated. - ntp_frac += kOneMsInNtpFrac; - timestamp -= kTimestampTicksPerMs; - EXPECT_FALSE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - EXPECT_FALSE(new_sr); + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(2 + kOneMsInNtp), + timestamp - kTimestampTicksPerMs), + RtpToNtpEstimator::kInvalidMeasurement); } TEST(UpdateRtcpMeasurementTests, VerifyParameters) { RtpToNtpEstimator estimator; - uint32_t ntp_sec = 1; - uint32_t ntp_frac = 2; uint32_t timestamp = 0x12345678; - bool new_sr; - EXPECT_TRUE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - EXPECT_TRUE(new_sr); - EXPECT_FALSE(estimator.params()); + + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(kOneMsInNtp), timestamp), + RtpToNtpEstimator::kNewMeasurement); + + EXPECT_DOUBLE_EQ(estimator.EstimatedFrequencyKhz(), 0.0); + // Add second report, parameters should be calculated. - ntp_frac += kOneMsInNtpFrac; - timestamp += kTimestampTicksPerMs; - EXPECT_TRUE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - EXPECT_TRUE(estimator.params()); - EXPECT_DOUBLE_EQ(90.0, estimator.params()->frequency_khz); - EXPECT_NE(0.0, estimator.params()->offset_ms); + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(2 * kOneMsInNtp), + timestamp + kTimestampTicksPerMs), + RtpToNtpEstimator::kNewMeasurement); + + EXPECT_NEAR(estimator.EstimatedFrequencyKhz(), kTimestampTicksPerMs, 0.01); } TEST(RtpToNtpTests, FailsForNoParameters) { RtpToNtpEstimator estimator; - uint32_t ntp_sec = 1; - uint32_t ntp_frac = 2; uint32_t timestamp = 0x12345678; - bool new_sr; - EXPECT_TRUE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - EXPECT_TRUE(new_sr); + + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(1), timestamp), + RtpToNtpEstimator::kNewMeasurement); // Parameters are not calculated, conversion of RTP to NTP time should fail. - EXPECT_FALSE(estimator.params()); - int64_t timestamp_ms = -1; - EXPECT_FALSE(estimator.Estimate(timestamp, ×tamp_ms)); + EXPECT_DOUBLE_EQ(estimator.EstimatedFrequencyKhz(), 0.0); + EXPECT_FALSE(estimator.Estimate(timestamp).Valid()); } TEST(RtpToNtpTests, AveragesErrorOut) { RtpToNtpEstimator estimator; - uint32_t ntp_sec = 1; - uint32_t ntp_frac = 90000000; // More than 1 ms. + uint64_t ntp_raw = 90000000; // More than 1 ms. + ASSERT_GT(ntp_raw, kOneMsInNtp); uint32_t timestamp = 0x12345678; - const int kNtpSecStep = 1; // 1 second. - const int kRtpTicksPerMs = 90; - const int kRtpStep = kRtpTicksPerMs * 1000; - bool new_sr; - EXPECT_TRUE( - estimator.UpdateMeasurements(ntp_sec, ntp_frac, timestamp, &new_sr)); - EXPECT_TRUE(new_sr); + constexpr uint64_t kNtpSecStep = uint64_t{1} << 32; // 1 second. + constexpr int kRtpTicksPerMs = 90; + constexpr int kRtpStep = kRtpTicksPerMs * 1000; + + EXPECT_EQ(estimator.UpdateMeasurements(NtpTime(ntp_raw), timestamp), + RtpToNtpEstimator::kNewMeasurement); Random rand(1123536L); for (size_t i = 0; i < 1000; i++) { // Advance both timestamps by exactly 1 second. - ntp_sec += kNtpSecStep; + ntp_raw += kNtpSecStep; timestamp += kRtpStep; // Add upto 1ms of errors to NTP and RTP timestamps passed to estimator. - EXPECT_TRUE(estimator.UpdateMeasurements( - ntp_sec, - ntp_frac + rand.Rand(-static_cast(kOneMsInNtpFrac), - static_cast(kOneMsInNtpFrac)), - timestamp + rand.Rand(-kRtpTicksPerMs, kRtpTicksPerMs), &new_sr)); - EXPECT_TRUE(new_sr); - - int64_t estimated_ntp_ms; - EXPECT_TRUE(estimator.Estimate(timestamp, &estimated_ntp_ms)); + EXPECT_EQ( + estimator.UpdateMeasurements( + NtpTime(ntp_raw + rand.Rand(-int{kOneMsInNtp}, int{kOneMsInNtp})), + timestamp + rand.Rand(-kRtpTicksPerMs, kRtpTicksPerMs)), + RtpToNtpEstimator::kNewMeasurement); + + NtpTime estimated_ntp = estimator.Estimate(timestamp); + EXPECT_TRUE(estimated_ntp.Valid()); // Allow upto 2 ms of error. - EXPECT_NEAR(NtpTime(ntp_sec, ntp_frac).ToMs(), estimated_ntp_ms, 2); + EXPECT_NEAR(ntp_raw, static_cast(estimated_ntp), 2 * kOneMsInNtp); } } diff --git a/video/rtp_streams_synchronizer2.cc b/video/rtp_streams_synchronizer2.cc index 4096fceb99..0fbb3916cb 100644 --- a/video/rtp_streams_synchronizer2.cc +++ b/video/rtp_streams_synchronizer2.cc @@ -29,10 +29,10 @@ bool UpdateMeasurements(StreamSynchronization::Measurements* stream, const Syncable::Info& info) { stream->latest_timestamp = info.latest_received_capture_timestamp; stream->latest_receive_time_ms = info.latest_receive_time_ms; - bool new_rtcp_sr = false; return stream->rtp_to_ntp.UpdateMeasurements( - info.capture_time_ntp_secs, info.capture_time_ntp_frac, - info.capture_time_source_clock, &new_rtcp_sr); + NtpTime(info.capture_time_ntp_secs, info.capture_time_ntp_frac), + info.capture_time_source_clock) != + RtpToNtpEstimator::kInvalidMeasurement; } } // namespace @@ -183,32 +183,35 @@ bool RtpStreamsSynchronizer::GetStreamSyncOffsetInMs( return false; } - int64_t latest_audio_ntp; - if (!audio_measurement_.rtp_to_ntp.Estimate(audio_rtp_timestamp, - &latest_audio_ntp)) { + NtpTime latest_audio_ntp = + audio_measurement_.rtp_to_ntp.Estimate(audio_rtp_timestamp); + if (!latest_audio_ntp.Valid()) { return false; } + int64_t latest_audio_ntp_ms = latest_audio_ntp.ToMs(); - syncable_audio_->SetEstimatedPlayoutNtpTimestampMs(latest_audio_ntp, time_ms); + syncable_audio_->SetEstimatedPlayoutNtpTimestampMs(latest_audio_ntp_ms, + time_ms); - int64_t latest_video_ntp; - if (!video_measurement_.rtp_to_ntp.Estimate(rtp_timestamp, - &latest_video_ntp)) { + NtpTime latest_video_ntp = + video_measurement_.rtp_to_ntp.Estimate(rtp_timestamp); + if (!latest_video_ntp.Valid()) { return false; } + int64_t latest_video_ntp_ms = latest_video_ntp.ToMs(); // Current audio ntp. int64_t now_ms = rtc::TimeMillis(); - latest_audio_ntp += (now_ms - time_ms); + latest_audio_ntp_ms += (now_ms - time_ms); // Remove video playout delay. int64_t time_to_render_ms = render_time_ms - now_ms; if (time_to_render_ms > 0) - latest_video_ntp -= time_to_render_ms; + latest_video_ntp_ms -= time_to_render_ms; - *video_playout_ntp_ms = latest_video_ntp; - *stream_offset_ms = latest_audio_ntp - latest_video_ntp; - *estimated_freq_khz = video_measurement_.rtp_to_ntp.params()->frequency_khz; + *video_playout_ntp_ms = latest_video_ntp_ms; + *stream_offset_ms = latest_audio_ntp_ms - latest_video_ntp_ms; + *estimated_freq_khz = video_measurement_.rtp_to_ntp.EstimatedFrequencyKhz(); return true; } diff --git a/video/stream_synchronization.cc b/video/stream_synchronization.cc index d5c77c1eca..d86cc79203 100644 --- a/video/stream_synchronization.cc +++ b/video/stream_synchronization.cc @@ -35,19 +35,19 @@ bool StreamSynchronization::ComputeRelativeDelay( const Measurements& audio_measurement, const Measurements& video_measurement, int* relative_delay_ms) { - int64_t audio_last_capture_time_ms; - if (!audio_measurement.rtp_to_ntp.Estimate(audio_measurement.latest_timestamp, - &audio_last_capture_time_ms)) { + NtpTime audio_last_capture_time = + audio_measurement.rtp_to_ntp.Estimate(audio_measurement.latest_timestamp); + if (!audio_last_capture_time.Valid()) { return false; } - int64_t video_last_capture_time_ms; - if (!video_measurement.rtp_to_ntp.Estimate(video_measurement.latest_timestamp, - &video_last_capture_time_ms)) { - return false; - } - if (video_last_capture_time_ms < 0) { + NtpTime video_last_capture_time = + video_measurement.rtp_to_ntp.Estimate(video_measurement.latest_timestamp); + if (!video_last_capture_time.Valid()) { return false; } + int64_t audio_last_capture_time_ms = audio_last_capture_time.ToMs(); + int64_t video_last_capture_time_ms = video_last_capture_time.ToMs(); + // Positive diff means that video_measurement is behind audio_measurement. *relative_delay_ms = video_measurement.latest_receive_time_ms - diff --git a/video/stream_synchronization_unittest.cc b/video/stream_synchronization_unittest.cc index 5c6c79f6f1..b733a1d2cf 100644 --- a/video/stream_synchronization_unittest.cc +++ b/video/stream_synchronization_unittest.cc @@ -47,32 +47,31 @@ class StreamSynchronizationTest : public ::testing::Test { static_cast(kDefaultVideoFrequency * video_clock_drift_ + 0.5); // Generate NTP/RTP timestamp pair for both streams corresponding to RTCP. - bool new_sr; StreamSynchronization::Measurements audio; StreamSynchronization::Measurements video; NtpTime ntp_time = clock_sender_.CurrentNtpTime(); uint32_t rtp_timestamp = clock_sender_.CurrentTime().ms() * audio_frequency / 1000; - EXPECT_TRUE(audio.rtp_to_ntp.UpdateMeasurements( - ntp_time.seconds(), ntp_time.fractions(), rtp_timestamp, &new_sr)); + EXPECT_EQ(audio.rtp_to_ntp.UpdateMeasurements(ntp_time, rtp_timestamp), + RtpToNtpEstimator::kNewMeasurement); clock_sender_.AdvanceTimeMilliseconds(100); clock_receiver_.AdvanceTimeMilliseconds(100); ntp_time = clock_sender_.CurrentNtpTime(); rtp_timestamp = clock_sender_.CurrentTime().ms() * video_frequency / 1000; - EXPECT_TRUE(video.rtp_to_ntp.UpdateMeasurements( - ntp_time.seconds(), ntp_time.fractions(), rtp_timestamp, &new_sr)); + EXPECT_EQ(video.rtp_to_ntp.UpdateMeasurements(ntp_time, rtp_timestamp), + RtpToNtpEstimator::kNewMeasurement); clock_sender_.AdvanceTimeMilliseconds(900); clock_receiver_.AdvanceTimeMilliseconds(900); ntp_time = clock_sender_.CurrentNtpTime(); rtp_timestamp = clock_sender_.CurrentTime().ms() * audio_frequency / 1000; - EXPECT_TRUE(audio.rtp_to_ntp.UpdateMeasurements( - ntp_time.seconds(), ntp_time.fractions(), rtp_timestamp, &new_sr)); + EXPECT_EQ(audio.rtp_to_ntp.UpdateMeasurements(ntp_time, rtp_timestamp), + RtpToNtpEstimator::kNewMeasurement); clock_sender_.AdvanceTimeMilliseconds(100); clock_receiver_.AdvanceTimeMilliseconds(100); ntp_time = clock_sender_.CurrentNtpTime(); rtp_timestamp = clock_sender_.CurrentTime().ms() * video_frequency / 1000; - EXPECT_TRUE(video.rtp_to_ntp.UpdateMeasurements( - ntp_time.seconds(), ntp_time.fractions(), rtp_timestamp, &new_sr)); + EXPECT_EQ(video.rtp_to_ntp.UpdateMeasurements(ntp_time, rtp_timestamp), + RtpToNtpEstimator::kNewMeasurement); clock_sender_.AdvanceTimeMilliseconds(900); clock_receiver_.AdvanceTimeMilliseconds(900); From c367346a7509c88b820247c0c7db155e71a6b9da Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Thu, 17 Mar 2022 08:39:31 +0000 Subject: [PATCH 207/847] Apply include reduction to channel.h and channel_manager.h (tools_webrtc/iwyu/apply-iwyu -r) This breaks the circular dependency between channel_manager.h and media_session.h Bug: webrtc:13805 Change-Id: I34c09e752b4110988ad8e0473de5d88605b5e6fe Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255961 Reviewed-by: Mirko Bonadei Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#36233} --- pc/channel.h | 26 -------------------------- pc/channel_manager.h | 1 - 2 files changed, 27 deletions(-) diff --git a/pc/channel.h b/pc/channel.h index 018cb43ba3..d7580a02c7 100644 --- a/pc/channel.h +++ b/pc/channel.h @@ -11,54 +11,35 @@ #ifndef PC_CHANNEL_H_ #define PC_CHANNEL_H_ -#include #include #include -#include #include -#include #include #include #include #include "absl/strings/string_view.h" #include "absl/types/optional.h" -#include "api/call/audio_sink.h" #include "api/crypto/crypto_options.h" -#include "api/function_view.h" #include "api/jsep.h" #include "api/media_types.h" #include "api/rtp_parameters.h" -#include "api/rtp_receiver_interface.h" #include "api/rtp_transceiver_direction.h" #include "api/scoped_refptr.h" #include "api/sequence_checker.h" -#include "api/video/video_sink_interface.h" -#include "api/video/video_source_interface.h" #include "call/rtp_demuxer.h" #include "call/rtp_packet_sink_interface.h" #include "media/base/media_channel.h" -#include "media/base/media_engine.h" #include "media/base/stream_params.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" -#include "p2p/base/dtls_transport_internal.h" -#include "p2p/base/packet_transport_internal.h" #include "pc/channel_interface.h" -#include "pc/dtls_srtp_transport.h" -#include "pc/media_session.h" -#include "pc/rtp_transport.h" #include "pc/rtp_transport_internal.h" #include "pc/session_description.h" -#include "pc/srtp_filter.h" -#include "pc/srtp_transport.h" #include "rtc_base/async_packet_socket.h" -#include "rtc_base/async_udp_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/location.h" -#include "rtc_base/network.h" #include "rtc_base/network/sent_packet.h" #include "rtc_base/network_route.h" #include "rtc_base/socket.h" @@ -66,17 +47,10 @@ #include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread.h" #include "rtc_base/thread_annotations.h" -#include "rtc_base/thread_message.h" #include "rtc_base/unique_id_generator.h" -namespace webrtc { -class AudioSinkInterface; -} // namespace webrtc - namespace cricket { -struct CryptoParams; - // BaseChannel contains logic common to voice and video, including enable, // marshaling calls to a worker and network threads, and connection and media // monitors. diff --git a/pc/channel_manager.h b/pc/channel_manager.h index 72bd1328b3..0e95c96c18 100644 --- a/pc/channel_manager.h +++ b/pc/channel_manager.h @@ -28,7 +28,6 @@ #include "media/base/media_engine.h" #include "pc/channel.h" #include "pc/channel_interface.h" -#include "pc/rtp_transport_internal.h" #include "pc/session_description.h" #include "rtc_base/system/file_wrapper.h" #include "rtc_base/thread.h" From 658b88a48ef7ef3b9ffb4555f6f0bbd736022572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Thu, 17 Mar 2022 10:47:42 +0100 Subject: [PATCH 208/847] Delete rtc::string_trim. Replaced with absl::StripAsciiWhitespace. Bug: webrtc:6424, webrtc:13579 Change-Id: I222e1bfb62d5f1f1a2c74e5fce1038e04e7bebfb Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255824 Reviewed-by: Ali Tofigh Reviewed-by: Tomas Gunnarsson Commit-Queue: Niels Moller Cr-Commit-Position: refs/heads/main@{#36234} --- .../win/full_screen_win_application_handler.cc | 17 +++++++++++------ pc/webrtc_sdp.cc | 16 ++++++++-------- rtc_base/string_utils.cc | 13 ------------- rtc_base/string_utils.h | 3 --- rtc_base/string_utils_unittest.cc | 8 -------- 5 files changed, 19 insertions(+), 38 deletions(-) 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 ad45047cfc..4222dfc01e 100644 --- a/modules/desktop_capture/win/full_screen_win_application_handler.cc +++ b/modules/desktop_capture/win/full_screen_win_application_handler.cc @@ -9,11 +9,14 @@ */ #include "modules/desktop_capture/win/full_screen_win_application_handler.h" + #include #include #include #include #include + +#include "absl/strings/ascii.h" #include "absl/strings/match.h" #include "modules/desktop_capture/win/screen_capture_utils.h" #include "modules/desktop_capture/win/window_capture_utils.h" @@ -145,7 +148,8 @@ class FullScreenPowerPointHandler : public FullScreenApplicationHandler { std::string GetDocumentFromEditorTitle(HWND window) const { std::string title = WindowText(window); auto position = title.find(kDocumentTitleSeparator); - return rtc::string_trim(title.substr(0, position)); + return std::string(absl::StripAsciiWhitespace( + absl::string_view(title).substr(0, position))); } std::string GetDocumentFromSlideShowTitle(HWND window) const { @@ -158,12 +162,13 @@ class FullScreenPowerPointHandler : public FullScreenApplicationHandler { if (right_pos > left_pos + kSeparatorLength) { auto result_len = right_pos - left_pos - kSeparatorLength; - auto document = title.substr(left_pos + kSeparatorLength, result_len); - return rtc::string_trim(document); + auto document = absl::string_view(title).substr( + left_pos + kSeparatorLength, result_len); + return std::string(absl::StripAsciiWhitespace(document)); } else { - auto document = - title.substr(left_pos + kSeparatorLength, std::wstring::npos); - return rtc::string_trim(document); + auto document = absl::string_view(title).substr( + left_pos + kSeparatorLength, std::wstring::npos); + return std::string(absl::StripAsciiWhitespace(document)); } } diff --git a/pc/webrtc_sdp.cc b/pc/webrtc_sdp.cc index ea7a148fe1..12e9dd8f68 100644 --- a/pc/webrtc_sdp.cc +++ b/pc/webrtc_sdp.cc @@ -25,6 +25,7 @@ #include #include "absl/algorithm/container.h" +#include "absl/strings/ascii.h" #include "api/candidate.h" #include "api/crypto_params.h" #include "api/jsep_ice_candidate.h" @@ -349,7 +350,7 @@ static bool ParseFmtpAttributes(const std::string& line, const cricket::MediaType media_type, MediaContentDescription* media_desc, SdpParseError* error); -static bool ParseFmtpParam(const std::string& line, +static bool ParseFmtpParam(absl::string_view line, std::string* parameter, std::string* value, SdpParseError* error); @@ -3643,14 +3644,14 @@ bool ParseRtpmapAttribute(const std::string& line, return true; } -bool ParseFmtpParam(const std::string& line, +bool ParseFmtpParam(absl::string_view line, std::string* parameter, std::string* value, SdpParseError* error) { if (!rtc::tokenize_first(line, kSdpDelimiterEqualChar, parameter, value)) { // Support for non-key-value lines like RFC 2198 or RFC 4733. *parameter = ""; - *value = line; + *value = std::string(line); return true; } // a=fmtp: =; =; ... @@ -3693,14 +3694,13 @@ bool ParseFmtpAttributes(const std::string& line, } // Parse out format specific parameters. - std::vector fields; - rtc::split(line_params, kSdpDelimiterSemicolonChar, &fields); - cricket::CodecParameterMap codec_params; - for (auto& iter : fields) { + for (absl::string_view param : + rtc::split(line_params, kSdpDelimiterSemicolonChar)) { std::string name; std::string value; - if (!ParseFmtpParam(rtc::string_trim(iter), &name, &value, error)) { + if (!ParseFmtpParam(absl::StripAsciiWhitespace(param), &name, &value, + error)) { return false; } if (codec_params.find(name) != codec_params.end()) { diff --git a/rtc_base/string_utils.cc b/rtc_base/string_utils.cc index 1720c62d5e..c03433541a 100644 --- a/rtc_base/string_utils.cc +++ b/rtc_base/string_utils.cc @@ -30,19 +30,6 @@ size_t strcpyn(char* buffer, return srclen; } -static const char kWhitespace[] = " \n\r\t"; - -std::string string_trim(const std::string& s) { - std::string::size_type first = s.find_first_not_of(kWhitespace); - std::string::size_type last = s.find_last_not_of(kWhitespace); - - if (first == std::string::npos || last == std::string::npos) { - return std::string(""); - } - - return s.substr(first, last - first + 1); -} - std::string ToHex(const int i) { char buffer[50]; snprintf(buffer, sizeof(buffer), "%x", i); diff --git a/rtc_base/string_utils.h b/rtc_base/string_utils.h index 6e8b0b599b..1bb9d17528 100644 --- a/rtc_base/string_utils.h +++ b/rtc_base/string_utils.h @@ -82,9 +82,6 @@ inline std::string ToUtf8(const std::wstring& wstr) { #endif // WEBRTC_WIN -// Remove leading and trailing whitespaces. -std::string string_trim(const std::string& s); - // TODO(jonasolsson): replace with absl::Hex when that becomes available. std::string ToHex(int i); diff --git a/rtc_base/string_utils_unittest.cc b/rtc_base/string_utils_unittest.cc index 120f7e60f5..4e4bebdda7 100644 --- a/rtc_base/string_utils_unittest.cc +++ b/rtc_base/string_utils_unittest.cc @@ -14,14 +14,6 @@ namespace rtc { -TEST(string_trim_Test, Trimming) { - EXPECT_EQ("temp", string_trim("\n\r\t temp \n\r\t")); - EXPECT_EQ("temp\n\r\t temp", string_trim(" temp\n\r\t temp ")); - EXPECT_EQ("temp temp", string_trim("temp temp")); - EXPECT_EQ("", string_trim(" \r\n\t")); - EXPECT_EQ("", string_trim("")); -} - TEST(string_toHexTest, ToHex) { EXPECT_EQ(ToHex(0), "0"); EXPECT_EQ(ToHex(0X1243E), "1243e"); From 2c9bba77419c8f40e0c4453c820cada2e9dca2cc Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Thu, 17 Mar 2022 05:05:36 -0700 Subject: [PATCH 209/847] Roll chromium_revision a79897884e..3a3c61276c (982032:982148) Change log: https://chromium.googlesource.com/chromium/src/+log/a79897884e..3a3c61276c Full diff: https://chromium.googlesource.com/chromium/src/+/a79897884e..3a3c61276c Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/bfedbc1f92..dd8c44c8f4 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/344be2f95c..2360da1f6c * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/ae02fcbee0..78e4405552 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/520807d3ec..d5dc373edb * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/2a0c661892..e8c5102e5d * src/third_party/turbine: VhmfIPuSDHHeilnA7WC0MhR9ShZNF25tA0Te4RYIZG8C..Go9J3Mz5ankZAgxmn5GxeXKdEDV73zaZp2ojNfGC1RQC * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/d23956cfef..da5dab661c DEPS diff: https://chromium.googlesource.com/chromium/src/+/a79897884e..3a3c61276c/DEPS No update to Clang. BUG=None Change-Id: Ia8ef6341898c319ac74ea3fb2e8caf8a7aa918b1 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255907 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36235} --- DEPS | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/DEPS b/DEPS index 91024dc09a..af45e5e3b2 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': 'a79897884e54b2977be79b3f11f5545c260a7d23', + 'chromium_revision': '3a3c61276c8a69d4de8f8a08f1f4766c4995b7f2', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@bfedbc1f926ef1db32317306af214c806885488c', + 'https://chromium.googlesource.com/chromium/src/base@dd8c44c8f4161b4cb6c9d3e5aa1a35eb4e99ec09', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@344be2f95cc135a10e1f609fad5693ff0ad8e09f', + 'https://chromium.googlesource.com/chromium/src/build@2360da1f6cb9d68697457ea7eed31f44b992b798', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@90ff2bf8559c8eb9ce0c77cff53b40aa8a01e14a', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@ae02fcbee070dadf12b31ff3e3443733bc973215', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@78e44055521ed198292afc253a99141437894255', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@520807d3ecdf5cd149f21044d8a2829343db3921', + 'https://chromium.googlesource.com/chromium/src/testing@d5dc373edb5a6fc9e16f571c65d99856060386ef', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@2a0c6618926e26304fdbe1ba4c4cd9e9159a096c', + 'https://chromium.googlesource.com/chromium/src/third_party@e8c5102e5d09d18ea4a391d49f136549c79c9b5a', 'src/buildtools/linux64': { 'packages': [ @@ -288,7 +288,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@d23956cfef8fb1a303811dcaa3b85ece9c072510', + 'https://chromium.googlesource.com/chromium/src/tools@da5dab661c3b349577c6007f953daf8632b5bc9f', 'src/third_party/accessibility_test_framework': { 'packages': [ @@ -470,7 +470,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/turbine', - 'version': 'VhmfIPuSDHHeilnA7WC0MhR9ShZNF25tA0Te4RYIZG8C', + 'version': 'Go9J3Mz5ankZAgxmn5GxeXKdEDV73zaZp2ojNfGC1RQC', }, ], 'condition': 'checkout_android', From 4ceea6584839e563ec992db0c2e4f5e081157c57 Mon Sep 17 00:00:00 2001 From: Diep Bui Date: Thu, 17 Mar 2022 11:59:47 +0000 Subject: [PATCH 210/847] Integrate trendline estimator into loss based bwe v2. Bug: webrtc:12707 Change-Id: I510d3799c14599344d1714178e42b29e7c0c06d7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254380 Reviewed-by: Per Kjellander Commit-Queue: Diep Bui Cr-Commit-Position: refs/heads/main@{#36236} --- .../congestion_controller/goog_cc/BUILD.gn | 3 + .../goog_cc/delay_based_bwe.cc | 35 +-- .../goog_cc/delay_based_bwe.h | 1 + .../goog_cc/goog_cc_network_control.cc | 7 +- .../goog_cc/loss_based_bwe_v2.cc | 138 ++++++++-- .../goog_cc/loss_based_bwe_v2.h | 27 +- .../goog_cc/loss_based_bwe_v2_test.cc | 242 ++++++++++++++++-- .../goog_cc/send_side_bandwidth_estimation.cc | 20 +- .../goog_cc/send_side_bandwidth_estimation.h | 9 +- ...send_side_bandwidth_estimation_unittest.cc | 10 +- 10 files changed, 412 insertions(+), 80 deletions(-) diff --git a/modules/congestion_controller/goog_cc/BUILD.gn b/modules/congestion_controller/goog_cc/BUILD.gn index 9aafedbcb4..2c50c32759 100644 --- a/modules/congestion_controller/goog_cc/BUILD.gn +++ b/modules/congestion_controller/goog_cc/BUILD.gn @@ -153,6 +153,7 @@ rtc_library("loss_based_bwe_v2") { ] deps = [ "../../../api:array_view", + "../../../api:network_state_predictor_api", "../../../api/transport:network_control", "../../../api/transport:webrtc_key_value_config", "../../../api/units:data_rate", @@ -195,6 +196,7 @@ rtc_library("send_side_bwe") { deps = [ ":loss_based_bwe_v1", ":loss_based_bwe_v2", + "../../../api:network_state_predictor_api", "../../../api/rtc_event_log", "../../../api/transport:network_control", "../../../api/transport:webrtc_key_value_config", @@ -325,6 +327,7 @@ if (rtc_include_tests) { ":probe_controller", ":pushback_controller", ":send_side_bwe", + "../../../api:network_state_predictor_api", "../../../api/rtc_event_log", "../../../api/test/network_emulation", "../../../api/test/network_emulation:create_cross_traffic", diff --git a/modules/congestion_controller/goog_cc/delay_based_bwe.cc b/modules/congestion_controller/goog_cc/delay_based_bwe.cc index 01dfbc44e4..95d98b2675 100644 --- a/modules/congestion_controller/goog_cc/delay_based_bwe.cc +++ b/modules/congestion_controller/goog_cc/delay_based_bwe.cc @@ -181,23 +181,22 @@ void DelayBasedBwe::IncomingPacketFeedback(const PacketResult& packet_feedback, } DataSize packet_size = packet_feedback.sent_packet.size; - TimeDelta send_delta = TimeDelta::Zero(); - TimeDelta recv_delta = TimeDelta::Zero(); - int size_delta = 0; - - InterArrivalDelta* inter_arrival_for_packet = - (separate_audio_.enabled && packet_feedback.sent_packet.audio) - ? video_inter_arrival_delta_.get() - : audio_inter_arrival_delta_.get(); - bool calculated_deltas = inter_arrival_for_packet->ComputeDeltas( - packet_feedback.sent_packet.send_time, packet_feedback.receive_time, - at_time, packet_size.bytes(), &send_delta, &recv_delta, &size_delta); - - delay_detector_for_packet->Update( - recv_delta.ms(), send_delta.ms(), - packet_feedback.sent_packet.send_time.ms(), - packet_feedback.receive_time.ms(), packet_size.bytes(), - calculated_deltas); + TimeDelta send_delta = TimeDelta::Zero(); + TimeDelta recv_delta = TimeDelta::Zero(); + int size_delta = 0; + + InterArrivalDelta* inter_arrival_for_packet = + (separate_audio_.enabled && packet_feedback.sent_packet.audio) + ? video_inter_arrival_delta_.get() + : audio_inter_arrival_delta_.get(); + bool calculated_deltas = inter_arrival_for_packet->ComputeDeltas( + packet_feedback.sent_packet.send_time, packet_feedback.receive_time, + at_time, packet_size.bytes(), &send_delta, &recv_delta, &size_delta); + + delay_detector_for_packet->Update(recv_delta.ms(), send_delta.ms(), + packet_feedback.sent_packet.send_time.ms(), + packet_feedback.receive_time.ms(), + packet_size.bytes(), calculated_deltas); } DataRate DelayBasedBwe::TriggerOveruse(Timestamp at_time, @@ -266,6 +265,8 @@ DelayBasedBwe::Result DelayBasedBwe::MaybeUpdateEstimate( prev_bitrate_ = bitrate; prev_state_ = detector_state; } + + result.delay_detector_state = detector_state; return result; } diff --git a/modules/congestion_controller/goog_cc/delay_based_bwe.h b/modules/congestion_controller/goog_cc/delay_based_bwe.h index 7823f77abe..d37e05f8dd 100644 --- a/modules/congestion_controller/goog_cc/delay_based_bwe.h +++ b/modules/congestion_controller/goog_cc/delay_based_bwe.h @@ -56,6 +56,7 @@ class DelayBasedBwe { DataRate target_bitrate = DataRate::Zero(); bool recovered_from_overuse; bool backoff_in_alr; + BandwidthUsage delay_detector_state; }; explicit DelayBasedBwe(const WebRtcKeyValueConfig* key_value_config, 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 ba656be234..8ae7f40cb2 100644 --- a/modules/congestion_controller/goog_cc/goog_cc_network_control.cc +++ b/modules/congestion_controller/goog_cc/goog_cc_network_control.cc @@ -495,7 +495,6 @@ NetworkControlUpdate GoogCcNetworkController::OnTransportPacketsFeedback( auto acknowledged_bitrate = acknowledged_bitrate_estimator_->bitrate(); bandwidth_estimation_->SetAcknowledgedRate(acknowledged_bitrate, report.feedback_time); - bandwidth_estimation_->IncomingPacketFeedbackVector(report); for (const auto& feedback : report.SortedByReceiveTime()) { if (feedback.sent_packet.pacing_info.probe_cluster_id != PacedPacketInfo::kNotAProbe) { @@ -553,11 +552,13 @@ NetworkControlUpdate GoogCcNetworkController::OnTransportPacketsFeedback( } // Since SetSendBitrate now resets the delay-based estimate, we have to // call UpdateDelayBasedEstimate after SetSendBitrate. - bandwidth_estimation_->UpdateDelayBasedEstimate(report.feedback_time, - result.target_bitrate); + bandwidth_estimation_->UpdateDelayBasedEstimate( + report.feedback_time, result.target_bitrate, + result.delay_detector_state); // Update the estimate in the ProbeController, in case we want to probe. MaybeTriggerOnNetworkChanged(&update, report.feedback_time); } + bandwidth_estimation_->UpdateLossBasedEstimatorFromFeedbackVector(report); recovered_from_overuse = result.recovered_from_overuse; backoff_in_alr = result.backoff_in_alr; 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 44041143bf..147c2107ab 100644 --- a/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc +++ b/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc @@ -21,6 +21,7 @@ #include "absl/algorithm/container.h" #include "absl/types/optional.h" #include "api/array_view.h" +#include "api/network_state_predictor.h" #include "api/transport/network_types.h" #include "api/transport/webrtc_key_value_config.h" #include "api/units/data_rate.h" @@ -89,18 +90,11 @@ double GetLossProbability(double inherent_loss, << ToString(loss_limited_bandwidth); } - // We approximate the loss model - // loss_probability = inherent_loss + (1 - inherent_loss) * - // max(0, sending_rate - bandwidth) / sending_rate - // by - // loss_probability = inherent_loss + - // max(0, sending_rate - bandwidth) / sending_rate - // as it allows for simpler calculations and makes little difference in - // practice. double loss_probability = inherent_loss; if (IsValid(sending_rate) && IsValid(loss_limited_bandwidth) && (sending_rate > loss_limited_bandwidth)) { - loss_probability += (sending_rate - loss_limited_bandwidth) / sending_rate; + loss_probability += (1 - inherent_loss) * + (sending_rate - loss_limited_bandwidth) / sending_rate; } return std::min(std::max(loss_probability, 1.0e-6), 1.0 - 1.0e-6); } @@ -138,7 +132,8 @@ bool LossBasedBweV2::IsReady() const { num_observations_ > 0; } -DataRate LossBasedBweV2::GetBandwidthEstimate() const { +DataRate LossBasedBweV2::GetBandwidthEstimate( + DataRate delay_based_limit) const { if (!IsReady()) { if (!IsEnabled()) { RTC_LOG(LS_WARNING) @@ -156,8 +151,14 @@ DataRate LossBasedBweV2::GetBandwidthEstimate() const { return DataRate::PlusInfinity(); } - return std::min(current_estimate_.loss_limited_bandwidth, - GetInstantUpperBound()); + if (delay_based_limit.IsFinite()) { + return std::min({current_estimate_.loss_limited_bandwidth, + GetInstantUpperBound(), + delay_based_limit * config_->delay_based_limit_factor}); + } else { + return std::min(current_estimate_.loss_limited_bandwidth, + GetInstantUpperBound()); + } } void LossBasedBweV2::SetAcknowledgedBitrate(DataRate acknowledged_bitrate) { @@ -180,7 +181,8 @@ void LossBasedBweV2::SetBandwidthEstimate(DataRate bandwidth_estimate) { void LossBasedBweV2::UpdateBandwidthEstimate( rtc::ArrayView packet_results, - DataRate delay_based_estimate) { + DataRate delay_based_estimate, + BandwidthUsage delay_detector_state) { if (!IsEnabled()) { RTC_LOG(LS_WARNING) << "The estimator must be enabled before it can be used."; @@ -192,7 +194,7 @@ void LossBasedBweV2::UpdateBandwidthEstimate( return; } - if (!PushBackObservation(packet_results)) { + if (!PushBackObservation(packet_results, delay_detector_state)) { return; } @@ -264,6 +266,15 @@ absl::optional LossBasedBweV2::CreateConfig( "InstantUpperBoundLossOffset", 0.05); FieldTrialParameter temporal_weight_factor("TemporalWeightFactor", 0.99); + FieldTrialParameter bandwidth_backoff_lower_bound_factor( + "BwBackoffLowerBoundFactor", 0.85); + FieldTrialParameter trendline_integration_enabled( + "TrendlineIntegrationEnabled", false); + FieldTrialParameter delay_based_limit_factor("DelayBasedLimitFactor", + 1.0); + FieldTrialParameter trendline_window_size("TrendlineWindowSize", 20); + FieldTrialParameter backoff_when_overusing("BackoffWhenOverusing", + false); if (key_value_config) { ParseFieldTrial({&enabled, @@ -287,7 +298,12 @@ absl::optional LossBasedBweV2::CreateConfig( &instant_upper_bound_temporal_weight_factor, &instant_upper_bound_bandwidth_balance, &instant_upper_bound_loss_offset, - &temporal_weight_factor}, + &temporal_weight_factor, + &bandwidth_backoff_lower_bound_factor, + &trendline_integration_enabled, + &delay_based_limit_factor, + &trendline_window_size, + &backoff_when_overusing}, key_value_config->Lookup("WebRTC-Bwe-LossBasedBweV2")); } @@ -328,6 +344,12 @@ absl::optional LossBasedBweV2::CreateConfig( config->instant_upper_bound_loss_offset = instant_upper_bound_loss_offset.Get(); config->temporal_weight_factor = temporal_weight_factor.Get(); + config->bandwidth_backoff_lower_bound_factor = + bandwidth_backoff_lower_bound_factor.Get(); + config->trendline_integration_enabled = trendline_integration_enabled.Get(); + config->delay_based_limit_factor = delay_based_limit_factor.Get(); + config->trendline_window_size = trendline_window_size.Get(); + config->backoff_when_overusing = backoff_when_overusing.Get(); return config; } @@ -470,7 +492,24 @@ bool LossBasedBweV2::IsConfigValid() const { << config_->temporal_weight_factor; valid = false; } - + if (config_->bandwidth_backoff_lower_bound_factor > 1.0) { + RTC_LOG(LS_WARNING) + << "The bandwidth backoff lower bound factor must not be greater than " + "1: " + << config_->bandwidth_backoff_lower_bound_factor; + valid = false; + } + if (config_->delay_based_limit_factor < 1.0) { + RTC_LOG(LS_WARNING) + << "The delay based limit factor must not be less than 1: " + << config_->delay_based_limit_factor; + valid = false; + } + if (config_->trendline_window_size < 2) { + RTC_LOG(LS_WARNING) << "The trendline window size must be at least 2: " + << config_->trendline_window_size; + valid = false; + } return valid; } @@ -521,19 +560,35 @@ DataRate LossBasedBweV2::GetCandidateBandwidthUpperBound() const { std::vector LossBasedBweV2::GetCandidates( DataRate delay_based_estimate) const { std::vector bandwidths; + bool can_increase_bitrate = TrendlineEsimateAllowBitrateIncrease(); + bool can_decrease_bitrate = TrendlineEsimateAllowBitrateDecrease(); for (double candidate_factor : config_->candidate_factors) { + if (!can_increase_bitrate && candidate_factor >= 1.0) { + // When the network is overusing, the estimate is forced to decrease + // even if there is no loss yet. + if (candidate_factor > 1 || config_->backoff_when_overusing) { + continue; + } + } + if (!can_decrease_bitrate && candidate_factor < 1.0) { + continue; + } bandwidths.push_back(candidate_factor * current_estimate_.loss_limited_bandwidth); } if (acknowledged_bitrate_.has_value() && - config_->append_acknowledged_rate_candidate) { - bandwidths.push_back(*acknowledged_bitrate_); + config_->append_acknowledged_rate_candidate && can_decrease_bitrate) { + bandwidths.push_back(*acknowledged_bitrate_ * + config_->bandwidth_backoff_lower_bound_factor); } if (IsValid(delay_based_estimate) && config_->append_delay_based_estimate_candidate) { - bandwidths.push_back(delay_based_estimate); + if (can_increase_bitrate && + delay_based_estimate > current_estimate_.loss_limited_bandwidth) { + bandwidths.push_back(delay_based_estimate); + } } const DataRate candidate_bandwidth_upper_bound = @@ -704,8 +759,47 @@ void LossBasedBweV2::NewtonsMethodUpdate( } } +bool LossBasedBweV2::TrendlineEsimateAllowBitrateDecrease() const { + if (!config_->trendline_integration_enabled) { + return true; + } + + for (const auto& detector_state : delay_detector_states_) { + if (detector_state == BandwidthUsage::kBwOverusing) { + return true; + } + } + + for (const auto& detector_state : delay_detector_states_) { + if (detector_state == BandwidthUsage::kBwUnderusing) { + return false; + } + } + return true; +} + +bool LossBasedBweV2::TrendlineEsimateAllowBitrateIncrease() const { + if (!config_->trendline_integration_enabled) { + return true; + } + + for (const auto& detector_state : delay_detector_states_) { + if (detector_state == BandwidthUsage::kBwOverusing) { + return false; + } + } + return true; +} + bool LossBasedBweV2::PushBackObservation( - rtc::ArrayView packet_results) { + rtc::ArrayView packet_results, + BandwidthUsage delay_detector_state) { + delay_detector_states_.push_front(delay_detector_state); + if (static_cast(delay_detector_states_.size()) > + config_->trendline_window_size) { + delay_detector_states_.pop_back(); + } + if (packet_results.empty()) { return false; } @@ -729,7 +823,9 @@ bool LossBasedBweV2::PushBackObservation( last_send_time - last_send_time_most_recent_observation_; // Too small to be meaningful. - if (observation_duration < config_->observation_duration_lower_bound) { + if (observation_duration < config_->observation_duration_lower_bound && + (delay_detector_state == BandwidthUsage::kBwNormal || + !config_->trendline_integration_enabled)) { return false; } diff --git a/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h b/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h index f764892b55..7e42b3e827 100644 --- a/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h +++ b/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h @@ -12,10 +12,12 @@ #define MODULES_CONGESTION_CONTROLLER_GOOG_CC_LOSS_BASED_BWE_V2_H_ #include +#include #include #include "absl/types/optional.h" #include "api/array_view.h" +#include "api/network_state_predictor.h" #include "api/transport/network_types.h" #include "api/transport/webrtc_key_value_config.h" #include "api/units/data_rate.h" @@ -42,14 +44,15 @@ class LossBasedBweV2 { bool IsReady() const; // Returns `DataRate::PlusInfinity` if no BWE can be calculated. - DataRate GetBandwidthEstimate() const; + DataRate GetBandwidthEstimate(DataRate delay_based_limit) const; void SetAcknowledgedBitrate(DataRate acknowledged_bitrate); void SetBandwidthEstimate(DataRate bandwidth_estimate); void UpdateBandwidthEstimate( rtc::ArrayView packet_results, - DataRate delay_based_estimate); + DataRate delay_based_estimate, + BandwidthUsage delay_detector_state); private: struct ChannelParameters { @@ -80,6 +83,11 @@ class LossBasedBweV2 { DataRate instant_upper_bound_bandwidth_balance = DataRate::MinusInfinity(); double instant_upper_bound_loss_offset = 0.0; double temporal_weight_factor = 0.0; + double bandwidth_backoff_lower_bound_factor = 0.0; + bool trendline_integration_enabled = false; + double delay_based_limit_factor = 1.0; + int trendline_window_size = 0; + bool backoff_when_overusing = false; }; struct Derivatives { @@ -124,9 +132,21 @@ class LossBasedBweV2 { void CalculateTemporalWeights(); void NewtonsMethodUpdate(ChannelParameters& channel_parameters) const; + // Returns true if either + // 1. At least one of states in the window is kBwOverusing, or + // 2. There are no kBwUnderusing states in the window. + bool TrendlineEsimateAllowBitrateDecrease() const; + + // Returns false if there exists an overusing state in the window. + bool TrendlineEsimateAllowBitrateIncrease() const; // Returns false if no observation was created. - bool PushBackObservation(rtc::ArrayView packet_results); + bool PushBackObservation(rtc::ArrayView packet_results, + BandwidthUsage delay_detector_state); + void UpdateTrendlineEstimator( + const std::vector& packet_feedbacks, + Timestamp at_time); + void UpdateDelayDetector(BandwidthUsage delay_detector_state); absl::optional acknowledged_bitrate_; absl::optional config_; @@ -139,6 +159,7 @@ class LossBasedBweV2 { absl::optional cached_instant_upper_bound_; std::vector instant_upper_bound_temporal_weights_; std::vector temporal_weights_; + std::deque delay_detector_states_; }; } // namespace webrtc 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 05334885f2..bf0a7e492e 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 @@ -12,6 +12,7 @@ #include +#include "api/network_state_predictor.h" #include "api/transport/network_types.h" #include "api/units/data_rate.h" #include "api/units/data_size.h" @@ -48,14 +49,16 @@ std::string Config(bool enabled, bool valid) { } config_string - << ",CandidateFactors:0.9|1.1,HigherBwBiasFactor:0.01," + << ",CandidateFactors:1.1|1.0|0.95,HigherBwBiasFactor:0.01," + "DelayBasedCandidate:true," "InherentLossLowerBound:0.001,InherentLossUpperBoundBwBalance:14kbps," "InherentLossUpperBoundOffset:0.9,InitialInherentLossEstimate:0.01," "NewtonIterations:2,NewtonStepSize:0.4,ObservationWindowSize:15," "SendingRateSmoothingFactor:0.01," "InstantUpperBoundTemporalWeightFactor:0.97," "InstantUpperBoundBwBalance:90kbps," - "InstantUpperBoundLossOffset:0.1,TemporalWeightFactor:0.98"; + "InstantUpperBoundLossOffset:0.1,TemporalWeightFactor:0.98," + "BackoffWhenOverusing:true"; config_string.AppendFormat( ",ObservationDurationLowerBound:%dms", @@ -133,10 +136,13 @@ TEST(LossBasedBweV2Test, BandwidthEstimateGivenInitializationAndThenFeedback) { loss_based_bandwidth_estimator.SetBandwidthEstimate( DataRate::KilobitsPerSec(600)); loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - enough_feedback, DataRate::PlusInfinity()); + enough_feedback, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal); EXPECT_TRUE(loss_based_bandwidth_estimator.IsReady()); - EXPECT_TRUE(loss_based_bandwidth_estimator.GetBandwidthEstimate().IsFinite()); + EXPECT_TRUE( + loss_based_bandwidth_estimator + .GetBandwidthEstimate(/*delay_based_limit=*/DataRate::PlusInfinity()) + .IsFinite()); } TEST(LossBasedBweV2Test, NoBandwidthEstimateGivenNoInitialization) { @@ -156,11 +162,13 @@ TEST(LossBasedBweV2Test, NoBandwidthEstimateGivenNoInitialization) { LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - enough_feedback, DataRate::PlusInfinity()); + enough_feedback, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal); EXPECT_FALSE(loss_based_bandwidth_estimator.IsReady()); EXPECT_TRUE( - loss_based_bandwidth_estimator.GetBandwidthEstimate().IsPlusInfinity()); + loss_based_bandwidth_estimator + .GetBandwidthEstimate(/*delay_based_limit=*/DataRate::PlusInfinity()) + .IsPlusInfinity()); } TEST(LossBasedBweV2Test, NoBandwidthEstimateGivenNotEnoughFeedback) { @@ -186,14 +194,18 @@ TEST(LossBasedBweV2Test, NoBandwidthEstimateGivenNotEnoughFeedback) { EXPECT_FALSE(loss_based_bandwidth_estimator.IsReady()); EXPECT_TRUE( - loss_based_bandwidth_estimator.GetBandwidthEstimate().IsPlusInfinity()); + loss_based_bandwidth_estimator + .GetBandwidthEstimate(/*delay_based_limit=*/DataRate::PlusInfinity()) + .IsPlusInfinity()); loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - not_enough_feedback, DataRate::PlusInfinity()); + not_enough_feedback, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal); EXPECT_FALSE(loss_based_bandwidth_estimator.IsReady()); EXPECT_TRUE( - loss_based_bandwidth_estimator.GetBandwidthEstimate().IsPlusInfinity()); + loss_based_bandwidth_estimator + .GetBandwidthEstimate(/*delay_based_limit=*/DataRate::PlusInfinity()) + .IsPlusInfinity()); } TEST(LossBasedBweV2Test, @@ -227,21 +239,24 @@ TEST(LossBasedBweV2Test, loss_based_bandwidth_estimator.SetBandwidthEstimate( DataRate::KilobitsPerSec(600)); loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - enough_feedback_1, DataRate::PlusInfinity()); + enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal); - EXPECT_NE(loss_based_bandwidth_estimator.GetBandwidthEstimate(), + EXPECT_NE(loss_based_bandwidth_estimator.GetBandwidthEstimate( + /*delay_based_limit=*/DataRate::PlusInfinity()), DataRate::KilobitsPerSec(600)); loss_based_bandwidth_estimator.SetBandwidthEstimate( DataRate::KilobitsPerSec(600)); - EXPECT_EQ(loss_based_bandwidth_estimator.GetBandwidthEstimate(), + EXPECT_EQ(loss_based_bandwidth_estimator.GetBandwidthEstimate( + /*delay_based_limit=*/DataRate::PlusInfinity()), DataRate::KilobitsPerSec(600)); loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - enough_feedback_2, DataRate::PlusInfinity()); + enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal); - EXPECT_NE(loss_based_bandwidth_estimator.GetBandwidthEstimate(), + EXPECT_NE(loss_based_bandwidth_estimator.GetBandwidthEstimate( + /*delay_based_limit=*/DataRate::PlusInfinity()), DataRate::KilobitsPerSec(600)); } @@ -279,26 +294,30 @@ TEST(LossBasedBweV2Test, loss_based_bandwidth_estimator_2.SetBandwidthEstimate( DataRate::KilobitsPerSec(600)); loss_based_bandwidth_estimator_1.UpdateBandwidthEstimate( - enough_feedback_1, DataRate::PlusInfinity()); + enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal); loss_based_bandwidth_estimator_2.UpdateBandwidthEstimate( - enough_feedback_1, DataRate::PlusInfinity()); + enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal); - EXPECT_EQ(loss_based_bandwidth_estimator_1.GetBandwidthEstimate(), + EXPECT_EQ(loss_based_bandwidth_estimator_1.GetBandwidthEstimate( + /*delay_based_limit=*/DataRate::PlusInfinity()), DataRate::KilobitsPerSec(660)); loss_based_bandwidth_estimator_1.SetAcknowledgedBitrate( DataRate::KilobitsPerSec(600)); - EXPECT_EQ(loss_based_bandwidth_estimator_1.GetBandwidthEstimate(), + EXPECT_EQ(loss_based_bandwidth_estimator_1.GetBandwidthEstimate( + /*delay_based_limit=*/DataRate::PlusInfinity()), DataRate::KilobitsPerSec(660)); loss_based_bandwidth_estimator_1.UpdateBandwidthEstimate( - enough_feedback_2, DataRate::PlusInfinity()); + enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal); loss_based_bandwidth_estimator_2.UpdateBandwidthEstimate( - enough_feedback_2, DataRate::PlusInfinity()); + enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal); - EXPECT_NE(loss_based_bandwidth_estimator_1.GetBandwidthEstimate(), - loss_based_bandwidth_estimator_2.GetBandwidthEstimate()); + EXPECT_NE(loss_based_bandwidth_estimator_1.GetBandwidthEstimate( + /*delay_based_limit=*/DataRate::PlusInfinity()), + loss_based_bandwidth_estimator_2.GetBandwidthEstimate( + /*delay_based_limit=*/DataRate::PlusInfinity())); } TEST(LossBasedBweV2Test, @@ -324,12 +343,187 @@ TEST(LossBasedBweV2Test, loss_based_bandwidth_estimator.SetBandwidthEstimate( DataRate::KilobitsPerSec(600)); loss_based_bandwidth_estimator.UpdateBandwidthEstimate( - enough_feedback_no_received_packets, DataRate::PlusInfinity()); + enough_feedback_no_received_packets, DataRate::PlusInfinity(), + BandwidthUsage::kBwNormal); - EXPECT_EQ(loss_based_bandwidth_estimator.GetBandwidthEstimate(), + EXPECT_EQ(loss_based_bandwidth_estimator.GetBandwidthEstimate( + /*delay_based_limit=*/DataRate::PlusInfinity()), DataRate::KilobitsPerSec(100)); } +// When network is overusing and flag `BackoffWhenOverusing` is true, +// the bandwidth estimate is forced to decrease even if there is no loss yet. +TEST(LossBasedBweV2Test, BandwidthEstimateDecreasesWhenOverusing) { + PacketResult enough_feedback_1[2]; + PacketResult enough_feedback_2[2]; + enough_feedback_1[0].sent_packet.size = DataSize::Bytes(15'000); + enough_feedback_1[1].sent_packet.size = DataSize::Bytes(15'000); + enough_feedback_2[0].sent_packet.size = DataSize::Bytes(15'000); + enough_feedback_2[1].sent_packet.size = DataSize::Bytes(15'000); + enough_feedback_1[0].sent_packet.send_time = Timestamp::Zero(); + enough_feedback_1[1].sent_packet.send_time = + Timestamp::Zero() + kObservationDurationLowerBound; + enough_feedback_2[0].sent_packet.send_time = + Timestamp::Zero() + 2 * kObservationDurationLowerBound; + enough_feedback_2[1].sent_packet.send_time = + Timestamp::Zero() + 3 * kObservationDurationLowerBound; + enough_feedback_1[0].receive_time = Timestamp::PlusInfinity(); + enough_feedback_1[1].receive_time = + Timestamp::Zero() + 2 * kObservationDurationLowerBound; + enough_feedback_2[0].receive_time = Timestamp::PlusInfinity(); + enough_feedback_2[1].receive_time = + Timestamp::Zero() + 4 * kObservationDurationLowerBound; + + ExplicitKeyValueConfig key_value_config( + Config(/*enabled=*/true, /*valid=*/true)); + LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); + loss_based_bandwidth_estimator.SetAcknowledgedBitrate( + DataRate::KilobitsPerSec(300)); + loss_based_bandwidth_estimator.SetBandwidthEstimate( + DataRate::KilobitsPerSec(600)); + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + enough_feedback_1, DataRate::PlusInfinity(), + BandwidthUsage::kBwOverusing); + EXPECT_LE(loss_based_bandwidth_estimator.GetBandwidthEstimate( + /*delay_based_limit=*/DataRate::PlusInfinity()), + DataRate::KilobitsPerSec(600)); + + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal); + EXPECT_LE(loss_based_bandwidth_estimator.GetBandwidthEstimate( + /*delay_based_limit=*/DataRate::PlusInfinity()), + DataRate::KilobitsPerSec(600)); +} + +TEST(LossBasedBweV2Test, BandwidthEstimateIncreasesWhenUnderusing) { + PacketResult enough_feedback_1[2]; + PacketResult enough_feedback_2[2]; + enough_feedback_1[0].sent_packet.size = DataSize::Bytes(15'000); + enough_feedback_1[1].sent_packet.size = DataSize::Bytes(15'000); + enough_feedback_2[0].sent_packet.size = DataSize::Bytes(15'000); + enough_feedback_2[1].sent_packet.size = DataSize::Bytes(15'000); + enough_feedback_1[0].sent_packet.send_time = Timestamp::Zero(); + enough_feedback_1[1].sent_packet.send_time = + Timestamp::Zero() + kObservationDurationLowerBound; + enough_feedback_2[0].sent_packet.send_time = + Timestamp::Zero() + 2 * kObservationDurationLowerBound; + enough_feedback_2[1].sent_packet.send_time = + Timestamp::Zero() + 3 * kObservationDurationLowerBound; + enough_feedback_1[0].receive_time = + Timestamp::Zero() + kObservationDurationLowerBound; + enough_feedback_1[1].receive_time = + Timestamp::Zero() + 2 * kObservationDurationLowerBound; + enough_feedback_2[0].receive_time = + Timestamp::Zero() + 3 * kObservationDurationLowerBound; + enough_feedback_2[1].receive_time = + Timestamp::Zero() + 4 * kObservationDurationLowerBound; + + ExplicitKeyValueConfig key_value_config( + Config(/*enabled=*/true, /*valid=*/true)); + LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); + + loss_based_bandwidth_estimator.SetBandwidthEstimate( + DataRate::KilobitsPerSec(600)); + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + enough_feedback_1, DataRate::PlusInfinity(), + BandwidthUsage::kBwUnderusing); + EXPECT_GT(loss_based_bandwidth_estimator.GetBandwidthEstimate( + /*delay_based_limit=*/DataRate::PlusInfinity()), + DataRate::KilobitsPerSec(600)); + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal); + EXPECT_GT(loss_based_bandwidth_estimator.GetBandwidthEstimate( + /*delay_based_limit=*/DataRate::PlusInfinity()), + DataRate::KilobitsPerSec(600)); +} + +TEST(LossBasedBweV2Test, + BandwidthEstimateCappedByDelayBasedEstimateWhenUnderusing) { + PacketResult enough_feedback_1[2]; + PacketResult enough_feedback_2[2]; + enough_feedback_1[0].sent_packet.size = DataSize::Bytes(15'000); + enough_feedback_1[1].sent_packet.size = DataSize::Bytes(15'000); + enough_feedback_2[0].sent_packet.size = DataSize::Bytes(15'000); + enough_feedback_2[1].sent_packet.size = DataSize::Bytes(15'000); + enough_feedback_1[0].sent_packet.send_time = Timestamp::Zero(); + enough_feedback_1[1].sent_packet.send_time = + Timestamp::Zero() + kObservationDurationLowerBound; + enough_feedback_2[0].sent_packet.send_time = + Timestamp::Zero() + 2 * kObservationDurationLowerBound; + enough_feedback_2[1].sent_packet.send_time = + Timestamp::Zero() + 3 * kObservationDurationLowerBound; + enough_feedback_1[0].receive_time = + Timestamp::Zero() + kObservationDurationLowerBound; + enough_feedback_1[1].receive_time = + Timestamp::Zero() + 2 * kObservationDurationLowerBound; + enough_feedback_2[0].receive_time = + Timestamp::Zero() + 3 * kObservationDurationLowerBound; + enough_feedback_2[1].receive_time = + Timestamp::Zero() + 4 * kObservationDurationLowerBound; + + ExplicitKeyValueConfig key_value_config( + Config(/*enabled=*/true, /*valid=*/true)); + LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); + + loss_based_bandwidth_estimator.SetBandwidthEstimate( + DataRate::KilobitsPerSec(600)); + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + enough_feedback_1, DataRate::PlusInfinity(), + BandwidthUsage::kBwUnderusing); + EXPECT_GT(loss_based_bandwidth_estimator.GetBandwidthEstimate( + /*delay_based_limit=*/DataRate::PlusInfinity()), + DataRate::KilobitsPerSec(600)); + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal); + EXPECT_EQ(loss_based_bandwidth_estimator.GetBandwidthEstimate( + /*delay_based_limit=*/DataRate::KilobitsPerSec(500)), + DataRate::KilobitsPerSec(500)); +} + +TEST(LossBasedBweV2Test, NotUseAckedBitrateInNormalState) { + PacketResult enough_feedback_1[2]; + PacketResult enough_feedback_2[2]; + enough_feedback_1[0].sent_packet.size = DataSize::Bytes(15'000); + enough_feedback_1[1].sent_packet.size = DataSize::Bytes(15'000); + enough_feedback_2[0].sent_packet.size = DataSize::Bytes(15'000); + enough_feedback_2[1].sent_packet.size = DataSize::Bytes(15'000); + enough_feedback_1[0].sent_packet.send_time = Timestamp::Zero(); + enough_feedback_1[1].sent_packet.send_time = + Timestamp::Zero() + kObservationDurationLowerBound; + enough_feedback_2[0].sent_packet.send_time = + Timestamp::Zero() + 2 * kObservationDurationLowerBound; + enough_feedback_2[1].sent_packet.send_time = + Timestamp::Zero() + 3 * kObservationDurationLowerBound; + enough_feedback_1[0].receive_time = + Timestamp::Zero() + kObservationDurationLowerBound; + enough_feedback_1[1].receive_time = + Timestamp::Zero() + 2 * kObservationDurationLowerBound; + enough_feedback_2[0].receive_time = + Timestamp::Zero() + 3 * kObservationDurationLowerBound; + enough_feedback_2[1].receive_time = + Timestamp::Zero() + 4 * kObservationDurationLowerBound; + + ExplicitKeyValueConfig key_value_config( + Config(/*enabled=*/true, /*valid=*/true)); + LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); + + loss_based_bandwidth_estimator.SetBandwidthEstimate( + DataRate::KilobitsPerSec(600)); + DataRate acked_bitrate = DataRate::KilobitsPerSec(300); + loss_based_bandwidth_estimator.SetAcknowledgedBitrate(acked_bitrate); + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal); + EXPECT_GT(loss_based_bandwidth_estimator.GetBandwidthEstimate( + /*delay_based_limit=*/DataRate::PlusInfinity()), + acked_bitrate); + + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal); + EXPECT_GT(loss_based_bandwidth_estimator.GetBandwidthEstimate( + /*delay_based_limit=*/DataRate::PlusInfinity()), + acked_bitrate); +} + } // namespace } // namespace webrtc 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 5bb145cf20..631ef86c65 100644 --- a/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc +++ b/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc @@ -17,6 +17,7 @@ #include #include "absl/strings/match.h" +#include "api/network_state_predictor.h" #include "api/rtc_event_log/rtc_event.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/transport/webrtc_key_value_config.h" @@ -229,7 +230,8 @@ SendSideBandwidthEstimation::SendSideBandwidthEstimation( bitrate_threshold_(kDefaultBitrateThreshold), loss_based_bandwidth_estimator_v1_(key_value_config), loss_based_bandwidth_estimator_v2_(key_value_config), - disable_receiver_limit_caps_only_("Disabled") { + disable_receiver_limit_caps_only_("Disabled"), + delay_detector_state_(BandwidthUsage::kBwNormal) { RTC_DCHECK(event_log); if (BweLossExperimentIsEnabled()) { uint32_t bitrate_threshold_kbps; @@ -271,6 +273,7 @@ void SendSideBandwidthEstimation::OnRouteChange() { uma_update_state_ = kNoUpdate; uma_rtt_state_ = kNoUpdate; last_rtc_event_log_ = Timestamp::MinusInfinity(); + delay_detector_state_ = BandwidthUsage::kBwNormal; } void SendSideBandwidthEstimation::SetBitrates( @@ -330,9 +333,12 @@ void SendSideBandwidthEstimation::UpdateReceiverEstimate(Timestamp at_time, ApplyTargetLimits(at_time); } -void SendSideBandwidthEstimation::UpdateDelayBasedEstimate(Timestamp at_time, - DataRate bitrate) { +void SendSideBandwidthEstimation::UpdateDelayBasedEstimate( + Timestamp at_time, + DataRate bitrate, + BandwidthUsage delay_detector_state) { link_capacity_.UpdateDelayBasedEstimate(at_time, bitrate); + delay_detector_state_ = delay_detector_state; // TODO(srte): Ensure caller passes PlusInfinity, not zero, to represent no // limitation. delay_based_limit_ = bitrate.IsZero() ? DataRate::PlusInfinity() : bitrate; @@ -356,7 +362,7 @@ void SendSideBandwidthEstimation::SetAcknowledgedRate( } } -void SendSideBandwidthEstimation::IncomingPacketFeedbackVector( +void SendSideBandwidthEstimation::UpdateLossBasedEstimatorFromFeedbackVector( const TransportPacketsFeedback& report) { if (LossBasedBandwidthEstimatorV1Enabled()) { loss_based_bandwidth_estimator_v1_.UpdateLossStatistics( @@ -364,7 +370,7 @@ void SendSideBandwidthEstimation::IncomingPacketFeedbackVector( } if (LossBasedBandwidthEstimatorV2Enabled()) { loss_based_bandwidth_estimator_v2_.UpdateBandwidthEstimate( - report.packet_feedbacks, delay_based_limit_); + report.packet_feedbacks, delay_based_limit_, delay_detector_state_); } } @@ -509,8 +515,8 @@ void SendSideBandwidthEstimation::UpdateEstimate(Timestamp at_time) { if (LossBasedBandwidthEstimatorV2ReadyForUse()) { DataRate new_bitrate = - loss_based_bandwidth_estimator_v2_.GetBandwidthEstimate(); - new_bitrate = std::min(new_bitrate, delay_based_limit_); + loss_based_bandwidth_estimator_v2_.GetBandwidthEstimate( + delay_based_limit_); UpdateTargetBitrate(new_bitrate, at_time); return; } 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 f31f30f70d..bb53be873b 100644 --- a/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.h +++ b/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.h @@ -20,6 +20,7 @@ #include #include "absl/types/optional.h" +#include "api/network_state_predictor.h" #include "api/transport/network_types.h" #include "api/transport/webrtc_key_value_config.h" #include "api/units/data_rate.h" @@ -97,7 +98,9 @@ class SendSideBandwidthEstimation { void UpdateReceiverEstimate(Timestamp at_time, DataRate bandwidth); // Call when a new delay-based estimate is available. - void UpdateDelayBasedEstimate(Timestamp at_time, DataRate bitrate); + void UpdateDelayBasedEstimate(Timestamp at_time, + DataRate bitrate, + BandwidthUsage delay_detector_state); // Call when we receive a RTCP message with a ReceiveBlock. void UpdatePacketsLost(int64_t packets_lost, @@ -116,7 +119,8 @@ class SendSideBandwidthEstimation { int GetMinBitrate() const; void SetAcknowledgedRate(absl::optional acknowledged_rate, Timestamp at_time); - void IncomingPacketFeedbackVector(const TransportPacketsFeedback& report); + void UpdateLossBasedEstimatorFromFeedbackVector( + const TransportPacketsFeedback& report); private: friend class GoogCcStatePrinter; @@ -199,6 +203,7 @@ class SendSideBandwidthEstimation { LossBasedBandwidthEstimation loss_based_bandwidth_estimator_v1_; LossBasedBweV2 loss_based_bandwidth_estimator_v2_; FieldTrialFlag disable_receiver_limit_caps_only_; + BandwidthUsage delay_detector_state_; }; } // namespace webrtc #endif // MODULES_CONGESTION_CONTROLLER_GOOG_CC_SEND_SIDE_BANDWIDTH_ESTIMATION_H_ diff --git a/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation_unittest.cc b/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation_unittest.cc index 85ce401098..e3db866cf7 100644 --- a/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation_unittest.cc +++ b/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation_unittest.cc @@ -10,6 +10,7 @@ #include "modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.h" +#include "api/network_state_predictor.h" #include "api/rtc_event_log/rtc_event.h" #include "logging/rtc_event_log/events/rtc_event_bwe_update_loss_based.h" #include "logging/rtc_event_log/mock/mock_rtc_event_log.h" @@ -54,7 +55,8 @@ void TestProbing(bool use_delay_based) { // Initial REMB applies immediately. if (use_delay_based) { bwe.UpdateDelayBasedEstimate(Timestamp::Millis(now_ms), - DataRate::BitsPerSec(kRembBps)); + DataRate::BitsPerSec(kRembBps), + BandwidthUsage::kBwNormal); } else { bwe.UpdateReceiverEstimate(Timestamp::Millis(now_ms), DataRate::BitsPerSec(kRembBps)); @@ -66,7 +68,8 @@ void TestProbing(bool use_delay_based) { now_ms += 2001; if (use_delay_based) { bwe.UpdateDelayBasedEstimate(Timestamp::Millis(now_ms), - DataRate::BitsPerSec(kSecondRembBps)); + DataRate::BitsPerSec(kSecondRembBps), + BandwidthUsage::kBwNormal); } else { bwe.UpdateReceiverEstimate(Timestamp::Millis(now_ms), DataRate::BitsPerSec(kSecondRembBps)); @@ -157,7 +160,8 @@ TEST(SendSideBweTest, SettingSendBitrateOverridesDelayBasedEstimate) { Timestamp::Millis(now_ms)); bwe.UpdateDelayBasedEstimate(Timestamp::Millis(now_ms), - DataRate::BitsPerSec(kDelayBasedBitrateBps)); + DataRate::BitsPerSec(kDelayBasedBitrateBps), + BandwidthUsage::kBwNormal); bwe.UpdateEstimate(Timestamp::Millis(now_ms)); EXPECT_GE(bwe.target_rate().bps(), kInitialBitrateBps); EXPECT_LE(bwe.target_rate().bps(), kDelayBasedBitrateBps); From 8e1ae8cf5768597bb55cc6380648ab063a710b65 Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Thu, 17 Mar 2022 13:13:51 +0000 Subject: [PATCH 211/847] Break up rtc_pc_base: Second round, yellow and orange Bug: webrtc:13805 Change-Id: Ic3560673abc8b27507ebac550576814776688138 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256001 Reviewed-by: Mirko Bonadei Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#36237} --- pc/BUILD.gn | 107 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 101 insertions(+), 6 deletions(-) diff --git a/pc/BUILD.gn b/pc/BUILD.gn index 470a37a3d6..d1ba8731b3 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -67,14 +67,8 @@ rtc_library("rtc_pc_base") { visibility = [ "*" ] # Used by Chromium and others defines = [] sources = [ - "channel.cc", - "channel.h", "channel_manager.cc", "channel_manager.h", - "dtls_srtp_transport.cc", - "dtls_srtp_transport.h", - "jsep_transport.cc", - "jsep_transport.h", "jsep_transport_collection.cc", "jsep_transport_collection.h", "jsep_transport_controller.cc", @@ -205,7 +199,45 @@ rtc_library("rtc_pc_base") { # Targets in preparation for breaking up rtc_pc_base target rtc_source_set("channel") { visibility = [ ":*" ] + sources = [ + "channel.cc", + "channel.h", + ] + deps = [ + ":channel_interface", + ":rtp_media_utils", + ":rtp_transport_internal", + ":session_description", + "../api:libjingle_peerconnection_api", + "../api:rtp_parameters", + "../api:rtp_transceiver_direction", + "../api:scoped_refptr", + "../api:sequence_checker", + "../api/crypto:options", + "../api/units:timestamp", + "../call:rtp_interfaces", + "../call:rtp_receiver", + "../media:rtc_media_base", + "../modules/rtp_rtcp:rtp_rtcp_format", + "../p2p:rtc_p2p", + "../rtc_base", + "../rtc_base:checks", + "../rtc_base:logging", + "../rtc_base:rtc_base_approved", + "../rtc_base:socket", + "../rtc_base:threading", + "../rtc_base/containers:flat_set", + "../rtc_base/network:sent_packet", + "../rtc_base/task_utils:pending_task_safety_flag", + "../rtc_base/task_utils:to_queued_task", + "../rtc_base/third_party/sigslot", + ] + absl_deps = [ + "//third_party/abseil-cpp/absl/strings", + "//third_party/abseil-cpp/absl/types:optional", + ] } + rtc_source_set("channel_interface") { visibility = [ ":*" ] sources = [ "channel_interface.h" ] @@ -217,12 +249,30 @@ rtc_source_set("channel_interface") { ] absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } + rtc_source_set("channel_manager") { visibility = [ ":*" ] } + rtc_source_set("dtls_srtp_transport") { visibility = [ ":*" ] + sources = [ + "dtls_srtp_transport.cc", + "dtls_srtp_transport.h", + ] + deps = [ + ":srtp_transport", + "../api:libjingle_peerconnection_api", + "../api:rtc_error", + "../p2p:rtc_p2p", + "../rtc_base", + "../rtc_base:checks", + "../rtc_base:logging", + "../rtc_base/third_party/sigslot", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } + rtc_source_set("dtls_transport") { visibility = [ ":*" ] sources = [ @@ -245,6 +295,7 @@ rtc_source_set("dtls_transport") { ] absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } + rtc_source_set("external_hmac") { visibility = [ ":*" ] sources = [ @@ -256,6 +307,7 @@ rtc_source_set("external_hmac") { deps += [ "//third_party/libsrtp" ] } } + rtc_source_set("ice_transport") { visibility = [ ":*" ] sources = [ @@ -272,6 +324,37 @@ rtc_source_set("ice_transport") { } rtc_source_set("jsep_transport") { visibility = [ ":*" ] + sources = [ + "jsep_transport.cc", + "jsep_transport.h", + ] + deps = [ + ":dtls_srtp_transport", + ":dtls_transport", + ":rtcp_mux_filter", + ":rtp_transport", + ":rtp_transport_internal", + ":sctp_data_channel_transport", + ":sctp_transport", + ":session_description", + ":srtp_filter", + ":srtp_transport", + ":transport_stats", + "../api:array_view", + "../api:libjingle_peerconnection_api", + "../api:rtc_error", + "../api:scoped_refptr", + "../api/transport:datagram_transport_interface", + "../media:rtc_data_sctp_transport_internal", + "../p2p:rtc_p2p", + "../rtc_base", + "../rtc_base:checks", + "../rtc_base:logging", + "../rtc_base:refcount", + "../rtc_base:rtc_base_approved", + "../rtc_base:threading", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } rtc_source_set("jsep_transport_collection") { visibility = [ ":*" ] @@ -834,6 +917,7 @@ rtc_source_set("data_channel_controller") { "data_channel_controller.h", ] deps = [ + ":channel", ":data_channel_utils", ":peer_connection_internal", ":rtc_pc_base", @@ -881,6 +965,7 @@ rtc_source_set("rtc_stats_collector") { "rtc_stats_collector.h", ] deps = [ + ":channel", ":channel_interface", ":data_channel_utils", ":peer_connection_internal", @@ -951,6 +1036,7 @@ rtc_source_set("sdp_offer_answer") { "sdp_offer_answer.h", # dependent on peerconnection.h ] deps = [ + ":channel", ":channel_interface", ":connection_context", ":data_channel_controller", @@ -1043,6 +1129,7 @@ rtc_source_set("peer_connection") { "peer_connection.h", ] deps = [ + ":channel", ":channel_interface", ":connection_context", ":data_channel_controller", @@ -1163,6 +1250,7 @@ rtc_source_set("stats_collector") { "stats_collector.h", ] deps = [ + ":channel", ":channel_interface", ":data_channel_utils", ":peer_connection_internal", @@ -1471,6 +1559,7 @@ rtc_library("rtp_transmission_manager") { ] deps = [ ":audio_rtp_receiver", + ":channel", ":rtc_pc_base", ":rtp_receiver", ":rtp_receiver_proxy", @@ -1721,6 +1810,7 @@ rtc_library("remote_audio_source") { "remote_audio_source.h", ] deps = [ + ":channel", ":rtc_pc_base", "../api:call_api", "../api:media_stream_interface", @@ -1917,8 +2007,11 @@ if (rtc_include_tests && !build_with_chromium) { deps = [ ":audio_rtp_receiver", + ":channel", + ":dtls_srtp_transport", ":dtls_transport", ":ice_transport", + ":jsep_transport", ":libjingle_peerconnection", ":media_protocol_names", ":pc_test_utils", @@ -2109,7 +2202,9 @@ if (rtc_include_tests && !build_with_chromium) { deps = [ ":audio_rtp_receiver", ":audio_track", + ":channel", ":channel_interface", + ":dtls_srtp_transport", ":dtls_transport", ":dtmf_sender", ":ice_server_parsing", From 1a08096998a38a40f76ed7b014805c3d7edfac4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Spr=C3=A5ng?= Date: Thu, 17 Mar 2022 15:16:59 +0100 Subject: [PATCH 212/847] Clean up the TaskQueuePacedSender constructor. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removes the unused event log pointer and the default arguments. Bug: webrtc:13417 Change-Id: I90341528cdfd7a5c102addaa4e7c83e875525386 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255562 Reviewed-by: Danil Chapovalov Commit-Queue: Erik Språng Cr-Commit-Position: refs/heads/main@{#36238} --- call/rtp_transport_controller_send.cc | 2 - modules/pacing/paced_sender.cc | 8 +-- modules/pacing/paced_sender.h | 2 - modules/pacing/paced_sender_unittest.cc | 4 +- modules/pacing/pacing_controller.cc | 1 - modules/pacing/pacing_controller.h | 2 - modules/pacing/pacing_controller_unittest.cc | 64 ++++++++--------- modules/pacing/task_queue_paced_sender.cc | 3 - modules/pacing/task_queue_paced_sender.h | 19 +++-- .../task_queue_paced_sender_unittest.cc | 70 +++++++++---------- 10 files changed, 75 insertions(+), 100 deletions(-) diff --git a/call/rtp_transport_controller_send.cc b/call/rtp_transport_controller_send.cc index 2bf24e1994..9b3f3cc0ab 100644 --- a/call/rtp_transport_controller_send.cc +++ b/call/rtp_transport_controller_send.cc @@ -101,14 +101,12 @@ RtpTransportControllerSend::RtpTransportControllerSend( ? nullptr : new PacedSender(clock, &packet_router_, - event_log, trials, process_thread_.get())), task_queue_pacer_( pacer_settings_.use_task_queue_pacer() ? new TaskQueuePacedSender(clock, &packet_router_, - event_log, trials, task_queue_factory, pacer_settings_.holdback_window.Get(), diff --git a/modules/pacing/paced_sender.cc b/modules/pacing/paced_sender.cc index 9b419f0380..56a14105f7 100644 --- a/modules/pacing/paced_sender.cc +++ b/modules/pacing/paced_sender.cc @@ -16,7 +16,6 @@ #include "absl/memory/memory.h" #include "absl/strings/match.h" -#include "api/rtc_event_log/rtc_event_log.h" #include "modules/utility/include/process_thread.h" #include "rtc_base/checks.h" #include "rtc_base/location.h" @@ -31,7 +30,6 @@ const float PacedSender::kDefaultPaceMultiplier = 2.5f; PacedSender::PacedSender(Clock* clock, PacketRouter* packet_router, - RtcEventLog* event_log, const WebRtcKeyValueConfig& field_trials, ProcessThread* process_thread) : process_mode_( @@ -39,11 +37,7 @@ PacedSender::PacedSender(Clock* clock, "Enabled") ? PacingController::ProcessMode::kDynamic : PacingController::ProcessMode::kPeriodic), - pacing_controller_(clock, - packet_router, - event_log, - field_trials, - process_mode_), + pacing_controller_(clock, packet_router, field_trials, process_mode_), clock_(clock), process_thread_(process_thread) { if (process_thread_) diff --git a/modules/pacing/paced_sender.h b/modules/pacing/paced_sender.h index bf82e78dbe..e938a1e9e3 100644 --- a/modules/pacing/paced_sender.h +++ b/modules/pacing/paced_sender.h @@ -37,7 +37,6 @@ namespace webrtc { class Clock; -class RtcEventLog; class PacedSender : public RtpPacketPacer, public RtpPacketSender { public: @@ -57,7 +56,6 @@ class PacedSender : public RtpPacketPacer, public RtpPacketSender { // optional once all callers have been updated. PacedSender(Clock* clock, PacketRouter* packet_router, - RtcEventLog* event_log, const WebRtcKeyValueConfig& field_trials, ProcessThread* process_thread = nullptr); diff --git a/modules/pacing/paced_sender_unittest.cc b/modules/pacing/paced_sender_unittest.cc index 27f373746f..6f2728b72b 100644 --- a/modules/pacing/paced_sender_unittest.cc +++ b/modules/pacing/paced_sender_unittest.cc @@ -78,8 +78,8 @@ class PacedSenderTest EXPECT_CALL(process_thread_, RegisterModule) .WillOnce(SaveArg<0>(&paced_module_)); - pacer_ = std::make_unique(&clock_, &callback_, nullptr, - trials_, &process_thread_); + pacer_ = std::make_unique(&clock_, &callback_, trials_, + &process_thread_); EXPECT_CALL(process_thread_, WakeUp).WillRepeatedly([&](Module* module) { clock_.AdvanceTimeMilliseconds(module->TimeUntilNextProcess()); }); diff --git a/modules/pacing/pacing_controller.cc b/modules/pacing/pacing_controller.cc index c9628e0eb5..93bfe7f7eb 100644 --- a/modules/pacing/pacing_controller.cc +++ b/modules/pacing/pacing_controller.cc @@ -97,7 +97,6 @@ const TimeDelta PacingController::kMinSleepTime = TimeDelta::Millis(1); PacingController::PacingController(Clock* clock, PacketSender* packet_sender, - RtcEventLog* event_log, const WebRtcKeyValueConfig& field_trials, ProcessMode mode) : mode_(mode), diff --git a/modules/pacing/pacing_controller.h b/modules/pacing/pacing_controller.h index d0c2e731ff..4ec4efaa80 100644 --- a/modules/pacing/pacing_controller.h +++ b/modules/pacing/pacing_controller.h @@ -20,7 +20,6 @@ #include "absl/types/optional.h" #include "api/function_view.h" -#include "api/rtc_event_log/rtc_event_log.h" #include "api/transport/field_trial_based_config.h" #include "api/transport/network_types.h" #include "api/transport/webrtc_key_value_config.h" @@ -81,7 +80,6 @@ class PacingController { PacingController(Clock* clock, PacketSender* packet_sender, - RtcEventLog* event_log, const WebRtcKeyValueConfig& field_trials, ProcessMode mode); diff --git a/modules/pacing/pacing_controller_unittest.cc b/modules/pacing/pacing_controller_unittest.cc index c3ab266853..33592e3194 100644 --- a/modules/pacing/pacing_controller_unittest.cc +++ b/modules/pacing/pacing_controller_unittest.cc @@ -29,6 +29,7 @@ using ::testing::Field; using ::testing::Pointee; using ::testing::Property; using ::testing::Return; +using ::testing::WithoutArgs; namespace webrtc { namespace test { @@ -213,8 +214,8 @@ class PacingControllerTest void SetUp() override { srand(0); // Need to initialize PacingController after we initialize clock. - pacer_ = std::make_unique(&clock_, &callback_, nullptr, - trials_, GetParam()); + pacer_ = std::make_unique(&clock_, &callback_, trials_, + GetParam()); Init(); } @@ -365,7 +366,7 @@ class PacingControllerFieldTrialTest TEST_P(PacingControllerFieldTrialTest, DefaultNoPaddingInSilence) { const test::ExplicitKeyValueConfig trials(""); - PacingController pacer(&clock_, &callback_, nullptr, trials, GetParam()); + PacingController pacer(&clock_, &callback_, trials, GetParam()); pacer.SetPacingRates(kTargetRate, DataRate::Zero()); // Video packet to reset last send time and provide padding data. InsertPacket(&pacer, &video); @@ -381,7 +382,7 @@ TEST_P(PacingControllerFieldTrialTest, DefaultNoPaddingInSilence) { TEST_P(PacingControllerFieldTrialTest, PaddingInSilenceWithTrial) { const test::ExplicitKeyValueConfig trials( "WebRTC-Pacer-PadInSilence/Enabled/"); - PacingController pacer(&clock_, &callback_, nullptr, trials, GetParam()); + PacingController pacer(&clock_, &callback_, trials, GetParam()); pacer.SetPacingRates(kTargetRate, DataRate::Zero()); // Video packet to reset last send time and provide padding data. InsertPacket(&pacer, &video); @@ -397,7 +398,7 @@ TEST_P(PacingControllerFieldTrialTest, PaddingInSilenceWithTrial) { TEST_P(PacingControllerFieldTrialTest, CongestionWindowAffectsAudioInTrial) { const test::ExplicitKeyValueConfig trials("WebRTC-Pacer-BlockAudio/Enabled/"); EXPECT_CALL(callback_, SendPadding).Times(0); - PacingController pacer(&clock_, &callback_, nullptr, trials, GetParam()); + PacingController pacer(&clock_, &callback_, trials, GetParam()); pacer.SetPacingRates(DataRate::KilobitsPerSec(10000), DataRate::Zero()); // Video packet fills congestion window. InsertPacket(&pacer, &video); @@ -424,7 +425,7 @@ TEST_P(PacingControllerFieldTrialTest, DefaultCongestionWindowDoesNotAffectAudio) { EXPECT_CALL(callback_, SendPadding).Times(0); const test::ExplicitKeyValueConfig trials(""); - PacingController pacer(&clock_, &callback_, nullptr, trials, GetParam()); + PacingController pacer(&clock_, &callback_, trials, GetParam()); pacer.SetPacingRates(DataRate::BitsPerSec(10000000), DataRate::Zero()); // Video packet fills congestion window. InsertPacket(&pacer, &video); @@ -439,7 +440,7 @@ TEST_P(PacingControllerFieldTrialTest, TEST_P(PacingControllerFieldTrialTest, BudgetAffectsAudioInTrial) { ExplicitKeyValueConfig trials("WebRTC-Pacer-BlockAudio/Enabled/"); - PacingController pacer(&clock_, &callback_, nullptr, trials, GetParam()); + PacingController pacer(&clock_, &callback_, trials, GetParam()); DataRate pacing_rate = DataRate::BitsPerSec(video.packet_size / 3 * 8 * kProcessIntervalsPerSecond); pacer.SetPacingRates(pacing_rate, DataRate::Zero()); @@ -451,10 +452,9 @@ TEST_P(PacingControllerFieldTrialTest, BudgetAffectsAudioInTrial) { InsertPacket(&pacer, &audio); Timestamp wait_start_time = clock_.CurrentTime(); Timestamp wait_end_time = Timestamp::MinusInfinity(); - EXPECT_CALL(callback_, SendPacket) - .WillOnce([&](uint32_t ssrc, uint16_t sequence_number, - int64_t capture_timestamp, bool retransmission, - bool padding) { wait_end_time = clock_.CurrentTime(); }); + EXPECT_CALL(callback_, SendPacket).WillOnce(WithoutArgs([&]() { + wait_end_time = clock_.CurrentTime(); + })); while (!wait_end_time.IsFinite()) { ProcessNext(&pacer); } @@ -470,7 +470,7 @@ TEST_P(PacingControllerFieldTrialTest, BudgetAffectsAudioInTrial) { TEST_P(PacingControllerFieldTrialTest, DefaultBudgetDoesNotAffectAudio) { EXPECT_CALL(callback_, SendPadding).Times(0); const test::ExplicitKeyValueConfig trials(""); - PacingController pacer(&clock_, &callback_, nullptr, trials, GetParam()); + PacingController pacer(&clock_, &callback_, trials, GetParam()); pacer.SetPacingRates(DataRate::BitsPerSec(video.packet_size / 3 * 8 * kProcessIntervalsPerSecond), DataRate::Zero()); @@ -868,8 +868,8 @@ TEST_P(PacingControllerTest, VerifyAverageBitrateVaryingMediaPayload) { const int kTimeStep = 5; const TimeDelta kAveragingWindowLength = TimeDelta::Seconds(10); PacingControllerPadding callback; - pacer_ = std::make_unique(&clock_, &callback, nullptr, - trials_, GetParam()); + pacer_ = std::make_unique(&clock_, &callback, trials_, + GetParam()); pacer_->SetProbingEnabled(false); pacer_->SetPacingRates(kTargetRate * kPaceMultiplier, kTargetRate); @@ -1246,8 +1246,8 @@ TEST_P(PacingControllerTest, Pause) { TEST_P(PacingControllerTest, InactiveFromStart) { // Recreate the pacer without the inital time forwarding. - pacer_ = std::make_unique(&clock_, &callback_, nullptr, - trials_, GetParam()); + pacer_ = std::make_unique(&clock_, &callback_, trials_, + GetParam()); pacer_->SetProbingEnabled(false); pacer_->SetPacingRates(kTargetRate * kPaceMultiplier, kTargetRate); @@ -1345,8 +1345,8 @@ TEST_P(PacingControllerTest, ProbingWithInsertedPackets) { uint16_t sequence_number = 1234; PacingControllerProbing packet_sender; - pacer_ = std::make_unique(&clock_, &packet_sender, nullptr, - trials_, GetParam()); + pacer_ = std::make_unique(&clock_, &packet_sender, trials_, + GetParam()); pacer_->CreateProbeCluster(kFirstClusterRate, /*cluster_id=*/0); pacer_->CreateProbeCluster(kSecondClusterRate, @@ -1405,8 +1405,8 @@ TEST_P(PacingControllerTest, SkipsProbesWhenProcessIntervalTooLarge) { "abort_delayed_probes:1,max_probe_delay:2ms/" : "WebRTC-Bwe-ProbingBehavior/" "abort_delayed_probes:0,max_probe_delay:2ms/"); - pacer_ = std::make_unique(&clock_, &packet_sender, - nullptr, trials, GetParam()); + pacer_ = std::make_unique(&clock_, &packet_sender, trials, + GetParam()); pacer_->SetPacingRates( DataRate::BitsPerSec(kInitialBitrateBps * kPaceMultiplier), DataRate::BitsPerSec(kInitialBitrateBps)); @@ -1512,8 +1512,8 @@ TEST_P(PacingControllerTest, ProbingWithPaddingSupport) { uint16_t sequence_number = 1234; PacingControllerProbing packet_sender; - pacer_ = std::make_unique(&clock_, &packet_sender, nullptr, - trials_, GetParam()); + pacer_ = std::make_unique(&clock_, &packet_sender, trials_, + GetParam()); pacer_->CreateProbeCluster(kFirstClusterRate, /*cluster_id=*/0); pacer_->SetPacingRates( @@ -1578,8 +1578,8 @@ TEST_P(PacingControllerTest, PaddingOveruse) { TEST_P(PacingControllerTest, ProbeClusterId) { MockPacketSender callback; - pacer_ = std::make_unique(&clock_, &callback, nullptr, - trials_, GetParam()); + pacer_ = std::make_unique(&clock_, &callback, trials_, + GetParam()); Init(); uint32_t ssrc = 12346; @@ -1635,8 +1635,8 @@ TEST_P(PacingControllerTest, ProbeClusterId) { TEST_P(PacingControllerTest, OwnedPacketPrioritizedOnType) { MockPacketSender callback; - pacer_ = std::make_unique(&clock_, &callback, nullptr, - trials_, GetParam()); + pacer_ = std::make_unique(&clock_, &callback, trials_, + GetParam()); Init(); // Insert a packet of each type, from low to high priority. Since priority @@ -1682,8 +1682,8 @@ TEST_P(PacingControllerTest, OwnedPacketPrioritizedOnType) { TEST_P(PacingControllerTest, SmallFirstProbePacket) { MockPacketSender callback; - pacer_ = std::make_unique(&clock_, &callback, nullptr, - trials_, GetParam()); + pacer_ = std::make_unique(&clock_, &callback, trials_, + GetParam()); pacer_->CreateProbeCluster(kFirstClusterRate, /*cluster_id=*/0); pacer_->SetPacingRates(kTargetRate * kPaceMultiplier, DataRate::Zero()); @@ -1841,8 +1841,8 @@ TEST_P(PacingControllerTest, uint16_t sequence_number = 1234; MockPacketSender callback; EXPECT_CALL(callback, SendPacket).Times(::testing::AnyNumber()); - pacer_ = std::make_unique(&clock_, &callback, nullptr, - trials_, GetParam()); + pacer_ = std::make_unique(&clock_, &callback, trials_, + GetParam()); pacer_->SetAccountForAudioPackets(account_for_audio); // First, saturate the padding budget. @@ -2020,8 +2020,8 @@ TEST_P(PacingControllerTest, PaddingTargetAccountsForPaddingRate) { "WebRTC-Pacer-DynamicPaddingTarget/timedelta:10ms/"); srand(0); // Need to initialize PacingController after we initialize clock. - pacer_ = std::make_unique(&clock_, &callback_, nullptr, - field_trials, GetParam()); + pacer_ = std::make_unique(&clock_, &callback_, field_trials, + GetParam()); Init(); const uint32_t kSsrc = 12345; diff --git a/modules/pacing/task_queue_paced_sender.cc b/modules/pacing/task_queue_paced_sender.cc index 4294bd86ab..ebfc7ece9a 100644 --- a/modules/pacing/task_queue_paced_sender.cc +++ b/modules/pacing/task_queue_paced_sender.cc @@ -39,7 +39,6 @@ TaskQueuePacedSender::TaskQueuePacedSender( int max_hold_back_window_in_packets) : TaskQueuePacedSender(clock, packet_sender, - event_log, *field_trials, task_queue_factory, max_hold_back_window, @@ -48,7 +47,6 @@ TaskQueuePacedSender::TaskQueuePacedSender( TaskQueuePacedSender::TaskQueuePacedSender( Clock* clock, PacingController::PacketSender* packet_sender, - RtcEventLog* event_log, const WebRtcKeyValueConfig& field_trials, TaskQueueFactory* task_queue_factory, TimeDelta max_hold_back_window, @@ -63,7 +61,6 @@ TaskQueuePacedSender::TaskQueuePacedSender( allow_low_precision_ ? 0 : max_hold_back_window_in_packets), pacing_controller_(clock, packet_sender, - event_log, field_trials, PacingController::ProcessMode::kDynamic), next_process_time_(Timestamp::MinusInfinity()), diff --git a/modules/pacing/task_queue_paced_sender.h b/modules/pacing/task_queue_paced_sender.h index 5c8dba7a92..7a1d5f2fd7 100644 --- a/modules/pacing/task_queue_paced_sender.h +++ b/modules/pacing/task_queue_paced_sender.h @@ -37,11 +37,11 @@ namespace webrtc { class Clock; -class RtcEventLog; class TaskQueuePacedSender : public RtpPacketPacer, public RtpPacketSender { public: - ABSL_DEPRECATED("Use the version with field_trials reference instead.") + // TODO(bugs.webrtc.org/13417): Remove when downstream usage is gone. + ABSL_DEPRECATED("Use the other version instead.") TaskQueuePacedSender( Clock* clock, PacingController::PacketSender* packet_sender, @@ -55,15 +55,12 @@ class TaskQueuePacedSender : public RtpPacketPacer, public RtpPacketSender { // there is currently a pacer queue and packets can't immediately be // processed. Increasing this reduces thread wakeups at the expense of higher // latency. - // TODO(bugs.webrtc.org/10809): Remove default values. - TaskQueuePacedSender( - Clock* clock, - PacingController::PacketSender* packet_sender, - RtcEventLog* event_log, - const WebRtcKeyValueConfig& field_trials, - TaskQueueFactory* task_queue_factory, - TimeDelta max_hold_back_window = PacingController::kMinSleepTime, - int max_hold_back_window_in_packets = -1); + TaskQueuePacedSender(Clock* clock, + PacingController::PacketSender* packet_sender, + const WebRtcKeyValueConfig& field_trials, + TaskQueueFactory* task_queue_factory, + TimeDelta max_hold_back_window, + int max_hold_back_window_in_packets); ~TaskQueuePacedSender() override; diff --git a/modules/pacing/task_queue_paced_sender_unittest.cc b/modules/pacing/task_queue_paced_sender_unittest.cc index cb6d6156b4..420d4f47e5 100644 --- a/modules/pacing/task_queue_paced_sender_unittest.cc +++ b/modules/pacing/task_queue_paced_sender_unittest.cc @@ -203,10 +203,10 @@ TEST(TaskQueuePacedSenderTest, PacesPackets) { GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); MockPacketRouter packet_router; ScopedKeyValueConfig trials; - TaskQueuePacedSender pacer( - time_controller.GetClock(), &packet_router, - /*event_log=*/nullptr, trials, time_controller.GetTaskQueueFactory(), - PacingController::kMinSleepTime, kNoPacketHoldback); + TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, trials, + time_controller.GetTaskQueueFactory(), + PacingController::kMinSleepTime, + kNoPacketHoldback); // Insert a number of packets, covering one second. static constexpr size_t kPacketsToSend = 42; @@ -243,10 +243,10 @@ TEST(TaskQueuePacedSenderTest, ReschedulesProcessOnRateChange) { GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); MockPacketRouter packet_router; ScopedKeyValueConfig trials; - TaskQueuePacedSender pacer( - time_controller.GetClock(), &packet_router, - /*event_log=*/nullptr, trials, time_controller.GetTaskQueueFactory(), - PacingController::kMinSleepTime, kNoPacketHoldback); + TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, trials, + time_controller.GetTaskQueueFactory(), + PacingController::kMinSleepTime, + kNoPacketHoldback); // Insert a number of packets to be sent 200ms apart. const size_t kPacketsPerSecond = 5; @@ -295,10 +295,10 @@ TEST(TaskQueuePacedSenderTest, SendsAudioImmediately) { GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); MockPacketRouter packet_router; ScopedKeyValueConfig trials; - TaskQueuePacedSender pacer( - time_controller.GetClock(), &packet_router, - /*event_log=*/nullptr, trials, time_controller.GetTaskQueueFactory(), - PacingController::kMinSleepTime, kNoPacketHoldback); + TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, trials, + time_controller.GetTaskQueueFactory(), + PacingController::kMinSleepTime, + kNoPacketHoldback); const DataRate kPacingDataRate = DataRate::KilobitsPerSec(125); const DataSize kPacketSize = DataSize::Bytes(kDefaultPacketSize); @@ -328,8 +328,7 @@ TEST(TaskQueuePacedSenderTest, SleepsDuringCoalscingWindow) { GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); MockPacketRouter packet_router; ScopedKeyValueConfig trials; - TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, - /*event_log=*/nullptr, trials, + TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, trials, time_controller.GetTaskQueueFactory(), kCoalescingWindow, kNoPacketHoldback); @@ -365,8 +364,7 @@ TEST(TaskQueuePacedSenderTest, ProbingOverridesCoalescingWindow) { GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); MockPacketRouter packet_router; ScopedKeyValueConfig trials; - TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, - /*event_log=*/nullptr, trials, + TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, trials, time_controller.GetTaskQueueFactory(), kCoalescingWindow, kNoPacketHoldback); @@ -397,10 +395,10 @@ TEST(TaskQueuePacedSenderTest, SchedulesProbeAtSetTime) { "WebRTC-Bwe-ProbingBehavior/min_probe_delta:1ms/"); GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); MockPacketRouter packet_router; - TaskQueuePacedSender pacer( - time_controller.GetClock(), &packet_router, - /*event_log=*/nullptr, trials, time_controller.GetTaskQueueFactory(), - PacingController::kMinSleepTime, kNoPacketHoldback); + TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, trials, + time_controller.GetTaskQueueFactory(), + PacingController::kMinSleepTime, + kNoPacketHoldback); // Set rates so one packet adds 4ms of buffer level. const DataSize kPacketSize = DataSize::Bytes(kDefaultPacketSize); @@ -464,10 +462,10 @@ TEST(TaskQueuePacedSenderTest, NoMinSleepTimeWhenProbing) { "WebRTC-Bwe-ProbingBehavior/min_probe_delta:100us/"); GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); MockPacketRouter packet_router; - TaskQueuePacedSender pacer( - time_controller.GetClock(), &packet_router, - /*event_log=*/nullptr, trials, time_controller.GetTaskQueueFactory(), - PacingController::kMinSleepTime, kNoPacketHoldback); + TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, trials, + time_controller.GetTaskQueueFactory(), + PacingController::kMinSleepTime, + kNoPacketHoldback); // Set rates so one packet adds 4ms of buffer level. const DataSize kPacketSize = DataSize::Bytes(kDefaultPacketSize); @@ -520,8 +518,7 @@ TEST(TaskQueuePacedSenderTest, PacketBasedCoalescing) { GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); MockPacketRouter packet_router; ScopedKeyValueConfig trials; - TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, - /*event_log=*/nullptr, trials, + TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, trials, time_controller.GetTaskQueueFactory(), kFixedCoalescingWindow, kPacketBasedHoldback); @@ -571,8 +568,7 @@ TEST(TaskQueuePacedSenderTest, FixedHoldBackHasPriorityOverPackets) { GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); MockPacketRouter packet_router; ScopedKeyValueConfig trials; - TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, - /*event_log=*/nullptr, trials, + TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, trials, time_controller.GetTaskQueueFactory(), kFixedCoalescingWindow, kPacketBasedHoldback); @@ -617,10 +613,10 @@ TEST(TaskQueuePacedSenderTest, Stats) { GlobalSimulatedTimeController time_controller(kStartTime); MockPacketRouter packet_router; ScopedKeyValueConfig trials; - TaskQueuePacedSender pacer( - time_controller.GetClock(), &packet_router, - /*event_log=*/nullptr, trials, time_controller.GetTaskQueueFactory(), - PacingController::kMinSleepTime, kNoPacketHoldback); + TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, trials, + time_controller.GetTaskQueueFactory(), + PacingController::kMinSleepTime, + kNoPacketHoldback); // Simulate ~2mbps video stream, covering one second. static constexpr size_t kPacketsToSend = 200; @@ -693,9 +689,8 @@ TEST(TaskQueuePacedSenderTest, HighPrecisionPacingWhenSlackIsDisabled) { MockPacketRouter packet_router; TaskQueuePacedSender pacer( - time_controller.GetClock(), &packet_router, /*event_log=*/nullptr, - experiments, &task_queue_factory, PacingController::kMinSleepTime, - kNoPacketHoldback); + time_controller.GetClock(), &packet_router, experiments, + &task_queue_factory, PacingController::kMinSleepTime, kNoPacketHoldback); // Send enough packets (covering one second) that pacing is triggered, i.e. // delayed tasks being scheduled. @@ -737,9 +732,8 @@ TEST(TaskQueuePacedSenderTest, LowPrecisionPacingWhenSlackIsEnabled) { MockPacketRouter packet_router; TaskQueuePacedSender pacer( - time_controller.GetClock(), &packet_router, /*event_log=*/nullptr, - experiments, &task_queue_factory, PacingController::kMinSleepTime, - kNoPacketHoldback); + time_controller.GetClock(), &packet_router, experiments, + &task_queue_factory, PacingController::kMinSleepTime, kNoPacketHoldback); // Send enough packets (covering one second) that pacing is triggered, i.e. // delayed tasks being scheduled. From 7fa9057a0558e315f822c505b1f4516952c9f6cc Mon Sep 17 00:00:00 2001 From: Ali Tofigh Date: Thu, 17 Mar 2022 15:47:49 +0100 Subject: [PATCH 213/847] Adopt absl::string_view in function parameters under rtc_base/ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is part of a large-scale effort to increase adoption of absl::string_view across the WebRTC code base. This CL converts the majority of "const std::string&"s in function parameters under rtc_base/ to absl::string_view. Bug: webrtc:13579 Change-Id: I2b1e3776aa42326aa405f76bb324a2d233b21dca Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254081 Reviewed-by: Niels Moller Reviewed-by: Mirko Bonadei Reviewed-by: Xavier Lepaul‎ Reviewed-by: Anders Lilienthal Reviewed-by: Per Kjellander Commit-Queue: Ali Tofigh Cr-Commit-Position: refs/heads/main@{#36239} --- p2p/base/port.cc | 3 +- rtc_base/BUILD.gn | 11 ++- rtc_base/boringssl_certificate.cc | 12 ++- rtc_base/boringssl_certificate.h | 7 +- rtc_base/boringssl_identity.cc | 13 +-- rtc_base/boringssl_identity.h | 11 ++- rtc_base/byte_buffer.h | 5 +- rtc_base/checks.cc | 11 ++- rtc_base/crc32.h | 6 +- rtc_base/experiments/BUILD.gn | 10 +- rtc_base/experiments/encoder_info_settings.cc | 10 +- rtc_base/experiments/encoder_info_settings.h | 3 +- rtc_base/experiments/field_trial_list.cc | 4 +- rtc_base/experiments/field_trial_list.h | 12 ++- .../experiments/field_trial_list_unittest.cc | 4 +- rtc_base/experiments/field_trial_parser.cc | 37 +++---- rtc_base/experiments/field_trial_parser.h | 42 ++++---- .../field_trial_parser_unittest.cc | 3 +- rtc_base/experiments/field_trial_units.cc | 20 ++-- rtc_base/experiments/field_trial_units.h | 7 +- .../experiments/field_trial_units_unittest.cc | 3 +- .../experiments/struct_parameters_parser.cc | 3 +- rtc_base/fake_ssl_identity.cc | 11 ++- rtc_base/fake_ssl_identity.h | 9 +- rtc_base/file_rotating_stream.cc | 97 ++++++++++--------- rtc_base/file_rotating_stream.h | 13 +-- rtc_base/file_rotating_stream_unittest.cc | 20 ++-- rtc_base/gunit.cc | 7 +- rtc_base/gunit.h | 5 +- rtc_base/helpers.cc | 7 +- rtc_base/helpers.h | 3 +- rtc_base/http_common.cc | 26 ++--- rtc_base/http_common.h | 10 +- rtc_base/ip_address.cc | 11 ++- rtc_base/ip_address.h | 8 +- rtc_base/ip_address_unittest.cc | 11 ++- rtc_base/mdns_responder_interface.h | 3 +- rtc_base/message_digest.cc | 33 ++++--- rtc_base/message_digest.h | 36 +++---- rtc_base/net_helper.cc | 4 +- rtc_base/net_helper.h | 4 +- rtc_base/network.cc | 12 ++- rtc_base/network.h | 11 ++- rtc_base/network_monitor.h | 11 ++- rtc_base/network_unittest.cc | 40 ++++---- rtc_base/openssl_adapter.cc | 4 +- rtc_base/openssl_adapter.h | 3 +- rtc_base/openssl_digest.cc | 8 +- rtc_base/openssl_digest.h | 7 +- rtc_base/openssl_key_pair.cc | 4 +- rtc_base/openssl_key_pair.h | 3 +- rtc_base/openssl_session_cache.cc | 7 +- rtc_base/openssl_session_cache.h | 8 +- rtc_base/openssl_stream_adapter.cc | 16 +-- rtc_base/openssl_stream_adapter.h | 7 +- rtc_base/openssl_utility.cc | 11 ++- rtc_base/openssl_utility.h | 6 +- rtc_base/ref_counted_object_unittest.cc | 3 +- rtc_base/rtc_certificate.h | 5 +- rtc_base/socket_adapters.cc | 10 +- rtc_base/socket_adapters.h | 7 +- rtc_base/socket_address.cc | 26 ++--- rtc_base/socket_address.h | 8 +- rtc_base/socket_unittest.cc | 3 +- rtc_base/socket_unittest.h | 3 +- rtc_base/ssl_adapter_unittest.cc | 14 +-- rtc_base/ssl_certificate.cc | 3 +- rtc_base/ssl_certificate.h | 5 +- rtc_base/ssl_fingerprint.cc | 22 +++-- rtc_base/ssl_fingerprint.h | 20 ++-- rtc_base/ssl_identity.cc | 35 ++++--- rtc_base/ssl_identity.h | 22 +++-- rtc_base/ssl_identity_unittest.cc | 11 ++- rtc_base/ssl_stream_adapter.cc | 9 +- rtc_base/ssl_stream_adapter.h | 12 ++- rtc_base/ssl_stream_adapter_unittest.cc | 30 +++--- rtc_base/string_encode.cc | 18 ++-- rtc_base/string_encode.h | 8 +- rtc_base/string_utils.cc | 2 + rtc_base/string_utils.h | 18 +++- rtc_base/strings/json.cc | 18 ++-- rtc_base/strings/json.h | 16 +-- rtc_base/strings/string_builder.cc | 9 +- rtc_base/strings/string_builder.h | 3 +- rtc_base/thread.cc | 6 +- rtc_base/thread.h | 4 +- rtc_base/unique_id_generator.cc | 8 +- rtc_base/unique_id_generator.h | 3 +- sdk/BUILD.gn | 5 + sdk/android/BUILD.gn | 5 +- .../src/jni/android_network_monitor.cc | 20 ++-- sdk/android/src/jni/android_network_monitor.h | 22 +++-- .../components/network/RTCNetworkMonitor.mm | 6 +- .../native/src/network_monitor_observer.h | 5 +- sdk/objc/native/src/objc_network_monitor.h | 17 ++-- sdk/objc/native/src/objc_network_monitor.mm | 18 ++-- 96 files changed, 677 insertions(+), 495 deletions(-) diff --git a/p2p/base/port.cc b/p2p/base/port.cc index f864150969..a061688b72 100644 --- a/p2p/base/port.cc +++ b/p2p/base/port.cc @@ -19,6 +19,7 @@ #include "absl/algorithm/container.h" #include "absl/strings/match.h" +#include "absl/strings/string_view.h" #include "p2p/base/connection.h" #include "p2p/base/port_allocator.h" #include "rtc_base/checks.h" @@ -301,7 +302,7 @@ bool Port::MaybeObfuscateAddress(Candidate* c, auto copy = *c; auto weak_ptr = weak_factory_.GetWeakPtr(); auto callback = [weak_ptr, copy, is_final](const rtc::IPAddress& addr, - const std::string& name) mutable { + absl::string_view name) mutable { RTC_DCHECK(copy.address().ipaddr() == addr); rtc::SocketAddress hostname_address(name, copy.address().port()); // In Port and Connection, we need the IP address information to diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn index 1db186c0fc..e09b62f936 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -96,6 +96,7 @@ rtc_library("rtc_base_approved") { absl_deps = [ "//third_party/abseil-cpp/absl/base:core_headers", "//third_party/abseil-cpp/absl/numeric:bits", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] public_deps = [] # no-presubmit-check TODO(webrtc:8603) @@ -683,6 +684,7 @@ rtc_library("rtc_json") { # expected to be when building json outside of the standalone build. defines += [ "WEBRTC_EXTERNAL_JSON" ] } + absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } rtc_library("net_helpers") { @@ -730,6 +732,7 @@ rtc_library("ip_address") { if (is_win) { deps += [ ":win32" ] } + absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } rtc_library("socket_address") { @@ -751,6 +754,7 @@ rtc_library("socket_address") { if (is_win) { deps += [ ":win32" ] } + absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } rtc_library("null_socket_server") { @@ -795,6 +799,7 @@ rtc_library("threading") { absl_deps = [ "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/base:core_headers", + "//third_party/abseil-cpp/absl/strings", ] deps = [ ":async_resolver_interface", @@ -1233,6 +1238,7 @@ rtc_library("rtc_base_tests_utils") { absl_deps = [ "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/memory", + "//third_party/abseil-cpp/absl/strings", ] } @@ -1326,7 +1332,10 @@ if (rtc_include_tests) { "third_party/sigslot", "//testing/gtest", ] - absl_deps = [ "//third_party/abseil-cpp/absl/memory" ] + absl_deps = [ + "//third_party/abseil-cpp/absl/memory", + "//third_party/abseil-cpp/absl/strings", + ] } rtc_library("rtc_base_approved_unittests") { diff --git a/rtc_base/boringssl_certificate.cc b/rtc_base/boringssl_certificate.cc index 99b2ab3e24..a866224496 100644 --- a/rtc_base/boringssl_certificate.cc +++ b/rtc_base/boringssl_certificate.cc @@ -10,6 +10,8 @@ #include "rtc_base/boringssl_certificate.h" +#include "absl/strings/string_view.h" + #if defined(WEBRTC_WIN) // Must be included first before openssl headers. #include "rtc_base/win32.h" // NOLINT @@ -116,7 +118,7 @@ bool AddSHA256SignatureAlgorithm(CBB* cbb, KeyType key_type) { } // Adds an X.509 Common Name to `cbb`. -bool AddCommonName(CBB* cbb, const std::string& common_name) { +bool AddCommonName(CBB* cbb, absl::string_view common_name) { // See RFC 4519. static const uint8_t kCommonName[] = {0x55, 0x04, 0x03}; @@ -138,7 +140,7 @@ bool AddCommonName(CBB* cbb, const std::string& common_name) { !CBB_add_bytes(&type, kCommonName, sizeof(kCommonName)) || !CBB_add_asn1(&attr, &value, CBS_ASN1_UTF8STRING) || !CBB_add_bytes(&value, - reinterpret_cast(common_name.c_str()), + reinterpret_cast(common_name.data()), common_name.size()) || !CBB_flush(cbb)) { return false; @@ -275,7 +277,7 @@ std::unique_ptr BoringSSLCertificate::Generate( } std::unique_ptr BoringSSLCertificate::FromPEMString( - const std::string& pem_string) { + absl::string_view pem_string) { std::string der; if (!SSLIdentity::PemToDer(kPemTypeCertificate, pem_string, &der)) { return nullptr; @@ -340,7 +342,7 @@ bool BoringSSLCertificate::GetSignatureDigestAlgorithm( return false; } -bool BoringSSLCertificate::ComputeDigest(const std::string& algorithm, +bool BoringSSLCertificate::ComputeDigest(absl::string_view algorithm, unsigned char* digest, size_t size, size_t* length) const { @@ -348,7 +350,7 @@ bool BoringSSLCertificate::ComputeDigest(const std::string& algorithm, } bool BoringSSLCertificate::ComputeDigest(const CRYPTO_BUFFER* cert_buffer, - const std::string& algorithm, + absl::string_view algorithm, unsigned char* digest, size_t size, size_t* length) { diff --git a/rtc_base/boringssl_certificate.h b/rtc_base/boringssl_certificate.h index 8b4577a17c..bd331686b7 100644 --- a/rtc_base/boringssl_certificate.h +++ b/rtc_base/boringssl_certificate.h @@ -18,6 +18,7 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/buffer.h" #include "rtc_base/ssl_certificate.h" #include "rtc_base/ssl_identity.h" @@ -38,7 +39,7 @@ class BoringSSLCertificate final : public SSLCertificate { OpenSSLKeyPair* key_pair, const SSLIdentityParams& params); static std::unique_ptr FromPEMString( - const std::string& pem_string); + absl::string_view pem_string); ~BoringSSLCertificate() override; @@ -55,14 +56,14 @@ class BoringSSLCertificate final : public SSLCertificate { bool operator!=(const BoringSSLCertificate& other) const; // Compute the digest of the certificate given `algorithm`. - bool ComputeDigest(const std::string& algorithm, + bool ComputeDigest(absl::string_view algorithm, unsigned char* digest, size_t size, size_t* length) const override; // Compute the digest of a certificate as a CRYPTO_BUFFER. static bool ComputeDigest(const CRYPTO_BUFFER* cert_buffer, - const std::string& algorithm, + absl::string_view algorithm, unsigned char* digest, size_t size, size_t* length); diff --git a/rtc_base/boringssl_identity.cc b/rtc_base/boringssl_identity.cc index d22c8ce529..a61524a679 100644 --- a/rtc_base/boringssl_identity.cc +++ b/rtc_base/boringssl_identity.cc @@ -22,6 +22,7 @@ #include #include "absl/memory/memory.h" +#include "absl/strings/string_view.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/numerics/safe_conversions.h" @@ -67,12 +68,12 @@ std::unique_ptr BoringSSLIdentity::CreateInternal( // static std::unique_ptr BoringSSLIdentity::CreateWithExpiration( - const std::string& common_name, + absl::string_view common_name, const KeyParams& key_params, time_t certificate_lifetime) { SSLIdentityParams params; params.key_params = key_params; - params.common_name = common_name; + params.common_name = std::string(common_name); time_t now = time(nullptr); params.not_before = now + kCertificateWindowInSeconds; params.not_after = now + certificate_lifetime; @@ -87,8 +88,8 @@ std::unique_ptr BoringSSLIdentity::CreateForTest( } std::unique_ptr BoringSSLIdentity::CreateFromPEMStrings( - const std::string& private_key, - const std::string& certificate) { + absl::string_view private_key, + absl::string_view certificate) { std::unique_ptr cert( BoringSSLCertificate::FromPEMString(certificate)); if (!cert) { @@ -108,8 +109,8 @@ std::unique_ptr BoringSSLIdentity::CreateFromPEMStrings( } std::unique_ptr BoringSSLIdentity::CreateFromPEMChainStrings( - const std::string& private_key, - const std::string& certificate_chain) { + absl::string_view private_key, + absl::string_view certificate_chain) { bssl::UniquePtr bio( BIO_new_mem_buf(certificate_chain.data(), rtc::dchecked_cast(certificate_chain.size()))); diff --git a/rtc_base/boringssl_identity.h b/rtc_base/boringssl_identity.h index e322afaba0..ffc8812af2 100644 --- a/rtc_base/boringssl_identity.h +++ b/rtc_base/boringssl_identity.h @@ -17,6 +17,7 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/boringssl_certificate.h" #include "rtc_base/openssl_key_pair.h" #include "rtc_base/ssl_certificate.h" @@ -30,17 +31,17 @@ namespace rtc { class BoringSSLIdentity final : public SSLIdentity { public: static std::unique_ptr CreateWithExpiration( - const std::string& common_name, + absl::string_view common_name, const KeyParams& key_params, time_t certificate_lifetime); static std::unique_ptr CreateForTest( const SSLIdentityParams& params); static std::unique_ptr CreateFromPEMStrings( - const std::string& private_key, - const std::string& certificate); + absl::string_view private_key, + absl::string_view certificate); static std::unique_ptr CreateFromPEMChainStrings( - const std::string& private_key, - const std::string& certificate_chain); + absl::string_view private_key, + absl::string_view certificate_chain); ~BoringSSLIdentity() override; BoringSSLIdentity(const BoringSSLIdentity&) = delete; diff --git a/rtc_base/byte_buffer.h b/rtc_base/byte_buffer.h index d2dda3c8e1..9bcbb838aa 100644 --- a/rtc_base/byte_buffer.h +++ b/rtc_base/byte_buffer.h @@ -16,6 +16,7 @@ #include +#include "absl/strings/string_view.h" #include "rtc_base/buffer.h" #include "rtc_base/byte_order.h" @@ -72,8 +73,8 @@ class ByteBufferWriterT { char last_byte = static_cast(val); WriteBytes(&last_byte, 1); } - void WriteString(const std::string& val) { - WriteBytes(val.c_str(), val.size()); + void WriteString(absl::string_view val) { + WriteBytes(val.data(), val.size()); } void WriteBytes(const char* val, size_t len) { buffer_.AppendData(val, len); } diff --git a/rtc_base/checks.cc b/rtc_base/checks.cc index 239ea9f0da..d6974d722f 100644 --- a/rtc_base/checks.cc +++ b/rtc_base/checks.cc @@ -15,6 +15,8 @@ #include #include +#include "absl/strings/string_view.h" + #if defined(WEBRTC_ANDROID) #define RTC_LOG_TAG_ANDROID "rtc" #include // NOLINT @@ -37,13 +39,14 @@ namespace { -RTC_NORETURN void WriteFatalLogAndAbort(const std::string& output) { - const char* output_c = output.c_str(); +RTC_NORETURN void WriteFatalLogAndAbort(absl::string_view output) { #if defined(WEBRTC_ANDROID) - __android_log_print(ANDROID_LOG_ERROR, RTC_LOG_TAG_ANDROID, "%s\n", output_c); + std::string output_str = std::string(output); + __android_log_print(ANDROID_LOG_ERROR, RTC_LOG_TAG_ANDROID, "%s\n", + output_str.c_str()); #endif fflush(stdout); - fprintf(stderr, "%s", output_c); + fwrite(output.data(), output.size(), 1, stderr); fflush(stderr); #if defined(WEBRTC_WIN) DebugBreak(); diff --git a/rtc_base/crc32.h b/rtc_base/crc32.h index ca8578d69c..93376a5a12 100644 --- a/rtc_base/crc32.h +++ b/rtc_base/crc32.h @@ -16,6 +16,8 @@ #include +#include "absl/strings/string_view.h" + namespace rtc { // Updates a CRC32 checksum with `len` bytes from `buf`. `initial` holds the @@ -26,8 +28,8 @@ uint32_t UpdateCrc32(uint32_t initial, const void* buf, size_t len); inline uint32_t ComputeCrc32(const void* buf, size_t len) { return UpdateCrc32(0, buf, len); } -inline uint32_t ComputeCrc32(const std::string& str) { - return ComputeCrc32(str.c_str(), str.size()); +inline uint32_t ComputeCrc32(absl::string_view str) { + return ComputeCrc32(str.data(), str.size()); } } // namespace rtc diff --git a/rtc_base/experiments/BUILD.gn b/rtc_base/experiments/BUILD.gn index b9d24ca6cc..5788484025 100644 --- a/rtc_base/experiments/BUILD.gn +++ b/rtc_base/experiments/BUILD.gn @@ -157,7 +157,10 @@ rtc_library("encoder_info_settings") { "../../api/video_codecs:video_codecs_api", "../../system_wrappers:field_trial", ] - absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] + absl_deps = [ + "//third_party/abseil-cpp/absl/strings", + "//third_party/abseil-cpp/absl/types:optional", + ] } rtc_library("rtt_mult_experiment") { @@ -296,6 +299,9 @@ if (rtc_include_tests && !build_with_chromium) { "../../test:test_main", "../../test:test_support", ] - absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] + absl_deps = [ + "//third_party/abseil-cpp/absl/strings", + "//third_party/abseil-cpp/absl/types:optional", + ] } } diff --git a/rtc_base/experiments/encoder_info_settings.cc b/rtc_base/experiments/encoder_info_settings.cc index b39c68468f..a74eb50a43 100644 --- a/rtc_base/experiments/encoder_info_settings.cc +++ b/rtc_base/experiments/encoder_info_settings.cc @@ -12,6 +12,7 @@ #include +#include "absl/strings/string_view.h" #include "rtc_base/experiments/field_trial_list.h" #include "rtc_base/logging.h" #include "system_wrappers/include/field_trial.h" @@ -155,7 +156,7 @@ EncoderInfoSettings::GetSinglecastBitrateLimitForResolutionWhenQpIsUntrusted( } } -EncoderInfoSettings::EncoderInfoSettings(std::string name) +EncoderInfoSettings::EncoderInfoSettings(absl::string_view name) : requested_resolution_alignment_("requested_resolution_alignment"), apply_alignment_to_all_simulcast_layers_( "apply_alignment_to_all_simulcast_layers") { @@ -174,14 +175,15 @@ EncoderInfoSettings::EncoderInfoSettings(std::string name) [](BitrateLimit* b) { return &b->max_bitrate_bps; })}, {}); - if (field_trial::FindFullName(name).empty()) { + std::string name_str = std::string(name); + if (field_trial::FindFullName(name_str).empty()) { // Encoder name not found, use common string applying to all encoders. - name = "WebRTC-GetEncoderInfoOverride"; + name_str = "WebRTC-GetEncoderInfoOverride"; } ParseFieldTrial({&bitrate_limits, &requested_resolution_alignment_, &apply_alignment_to_all_simulcast_layers_}, - field_trial::FindFullName(name)); + field_trial::FindFullName(name_str)); resolution_bitrate_limits_ = ToResolutionBitrateLimits(bitrate_limits.Get()); } diff --git a/rtc_base/experiments/encoder_info_settings.h b/rtc_base/experiments/encoder_info_settings.h index e4dc459fcf..d450697f47 100644 --- a/rtc_base/experiments/encoder_info_settings.h +++ b/rtc_base/experiments/encoder_info_settings.h @@ -14,6 +14,7 @@ #include #include +#include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "api/video_codecs/video_encoder.h" #include "rtc_base/experiments/field_trial_parser.h" @@ -58,7 +59,7 @@ class EncoderInfoSettings { resolution_bitrate_limits); protected: - explicit EncoderInfoSettings(std::string name); + explicit EncoderInfoSettings(absl::string_view name); private: FieldTrialOptional requested_resolution_alignment_; diff --git a/rtc_base/experiments/field_trial_list.cc b/rtc_base/experiments/field_trial_list.cc index ac3fd88f49..72cd79f2d2 100644 --- a/rtc_base/experiments/field_trial_list.cc +++ b/rtc_base/experiments/field_trial_list.cc @@ -9,9 +9,11 @@ */ #include "rtc_base/experiments/field_trial_list.h" +#include "absl/strings/string_view.h" + namespace webrtc { -FieldTrialListBase::FieldTrialListBase(std::string key) +FieldTrialListBase::FieldTrialListBase(absl::string_view key) : FieldTrialParameterInterface(key), failed_(false), parse_got_called_(false) {} diff --git a/rtc_base/experiments/field_trial_list.h b/rtc_base/experiments/field_trial_list.h index 00425be7b9..7b9f0d9dfc 100644 --- a/rtc_base/experiments/field_trial_list.h +++ b/rtc_base/experiments/field_trial_list.h @@ -15,6 +15,7 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/experiments/field_trial_parser.h" #include "rtc_base/string_encode.h" @@ -36,7 +37,7 @@ namespace webrtc { class FieldTrialListBase : public FieldTrialParameterInterface { protected: friend class FieldTrialListWrapper; - explicit FieldTrialListBase(std::string key); + explicit FieldTrialListBase(absl::string_view key); bool Failed() const; bool Used() const; @@ -52,8 +53,8 @@ class FieldTrialListBase : public FieldTrialParameterInterface { template class FieldTrialList : public FieldTrialListBase { public: - explicit FieldTrialList(std::string key) : FieldTrialList(key, {}) {} - FieldTrialList(std::string key, std::initializer_list default_values) + explicit FieldTrialList(absl::string_view key) : FieldTrialList(key, {}) {} + FieldTrialList(absl::string_view key, std::initializer_list default_values) : FieldTrialListBase(key), values_(default_values) {} std::vector Get() const { return values_; } @@ -132,7 +133,7 @@ struct LambdaTypeTraits { template struct TypedFieldTrialListWrapper : FieldTrialListWrapper { public: - TypedFieldTrialListWrapper(std::string key, + TypedFieldTrialListWrapper(absl::string_view key, std::function sink) : list_(key), sink_(sink) {} @@ -151,7 +152,8 @@ struct TypedFieldTrialListWrapper : FieldTrialListWrapper { template > -FieldTrialListWrapper* FieldTrialStructMember(std::string key, F accessor) { +FieldTrialListWrapper* FieldTrialStructMember(absl::string_view key, + F accessor) { return new field_trial_list_impl::TypedFieldTrialListWrapper< typename Traits::ret>(key, [accessor](void* s, typename Traits::ret t) { *accessor(static_cast(s)) = t; diff --git a/rtc_base/experiments/field_trial_list_unittest.cc b/rtc_base/experiments/field_trial_list_unittest.cc index 6d5e212eea..221a3c6929 100644 --- a/rtc_base/experiments/field_trial_list_unittest.cc +++ b/rtc_base/experiments/field_trial_list_unittest.cc @@ -10,6 +10,7 @@ #include "rtc_base/experiments/field_trial_list.h" +#include "absl/strings/string_view.h" #include "rtc_base/gunit.h" #include "test/gmock.h" @@ -25,7 +26,8 @@ struct Garment { // Only needed for testing. Garment() = default; - Garment(int p, std::string c, bool g) : price(p), color(c), has_glitter(g) {} + Garment(int p, absl::string_view c, bool g) + : price(p), color(c), has_glitter(g) {} bool operator==(const Garment& other) const { return price == other.price && color == other.color && diff --git a/rtc_base/experiments/field_trial_parser.cc b/rtc_base/experiments/field_trial_parser.cc index 952250b767..78d5489f5e 100644 --- a/rtc_base/experiments/field_trial_parser.cc +++ b/rtc_base/experiments/field_trial_parser.cc @@ -23,7 +23,8 @@ namespace webrtc { -FieldTrialParameterInterface::FieldTrialParameterInterface(std::string key) +FieldTrialParameterInterface::FieldTrialParameterInterface( + absl::string_view key) : key_(key) {} FieldTrialParameterInterface::~FieldTrialParameterInterface() { RTC_DCHECK(used_) << "Field trial parameter with key: '" << key_ @@ -111,7 +112,7 @@ void ParseFieldTrial( } template <> -absl::optional ParseTypedParameter(std::string str) { +absl::optional ParseTypedParameter(absl::string_view str) { if (str == "true" || str == "1") { return true; } else if (str == "false" || str == "0") { @@ -121,10 +122,10 @@ absl::optional ParseTypedParameter(std::string str) { } template <> -absl::optional ParseTypedParameter(std::string str) { +absl::optional ParseTypedParameter(absl::string_view str) { double value; char unit[2]{0, 0}; - if (sscanf(str.c_str(), "%lf%1s", &value, unit) >= 1) { + if (sscanf(std::string(str).c_str(), "%lf%1s", &value, unit) >= 1) { if (unit[0] == '%') return value / 100; return value; @@ -134,9 +135,9 @@ absl::optional ParseTypedParameter(std::string str) { } template <> -absl::optional ParseTypedParameter(std::string str) { +absl::optional ParseTypedParameter(absl::string_view str) { int64_t value; - if (sscanf(str.c_str(), "%" SCNd64, &value) == 1) { + if (sscanf(std::string(str).c_str(), "%" SCNd64, &value) == 1) { if (rtc::IsValueInRangeForNumericType(value)) { return static_cast(value); } @@ -145,9 +146,9 @@ absl::optional ParseTypedParameter(std::string str) { } template <> -absl::optional ParseTypedParameter(std::string str) { +absl::optional ParseTypedParameter(absl::string_view str) { int64_t value; - if (sscanf(str.c_str(), "%" SCNd64, &value) == 1) { + if (sscanf(std::string(str).c_str(), "%" SCNd64, &value) == 1) { if (rtc::IsValueInRangeForNumericType(value)) { return static_cast(value); } @@ -156,34 +157,36 @@ absl::optional ParseTypedParameter(std::string str) { } template <> -absl::optional ParseTypedParameter(std::string str) { - return std::move(str); +absl::optional ParseTypedParameter( + absl::string_view str) { + return std::string(str); } template <> absl::optional> ParseTypedParameter>( - std::string str) { + absl::string_view str) { return ParseOptionalParameter(str); } template <> absl::optional> ParseTypedParameter>( - std::string str) { + absl::string_view str) { return ParseOptionalParameter(str); } template <> absl::optional> -ParseTypedParameter>(std::string str) { +ParseTypedParameter>(absl::string_view str) { return ParseOptionalParameter(str); } template <> absl::optional> -ParseTypedParameter>(std::string str) { +ParseTypedParameter>(absl::string_view str) { return ParseOptionalParameter(str); } -FieldTrialFlag::FieldTrialFlag(std::string key) : FieldTrialFlag(key, false) {} +FieldTrialFlag::FieldTrialFlag(absl::string_view key) + : FieldTrialFlag(key, false) {} -FieldTrialFlag::FieldTrialFlag(std::string key, bool default_value) +FieldTrialFlag::FieldTrialFlag(absl::string_view key, bool default_value) : FieldTrialParameterInterface(key), value_(default_value) {} bool FieldTrialFlag::Get() const { @@ -208,7 +211,7 @@ bool FieldTrialFlag::Parse(absl::optional str_value) { } AbstractFieldTrialEnum::AbstractFieldTrialEnum( - std::string key, + absl::string_view key, int default_value, std::map mapping) : FieldTrialParameterInterface(key), diff --git a/rtc_base/experiments/field_trial_parser.h b/rtc_base/experiments/field_trial_parser.h index bd11eea20a..822895e70b 100644 --- a/rtc_base/experiments/field_trial_parser.h +++ b/rtc_base/experiments/field_trial_parser.h @@ -46,7 +46,7 @@ class FieldTrialParameterInterface { FieldTrialParameterInterface(const FieldTrialParameterInterface&) = default; FieldTrialParameterInterface& operator=(const FieldTrialParameterInterface&) = default; - explicit FieldTrialParameterInterface(std::string key); + explicit FieldTrialParameterInterface(absl::string_view key); friend void ParseFieldTrial( std::initializer_list fields, absl::string_view trial_string); @@ -71,14 +71,14 @@ void ParseFieldTrial( // Specialize this in code file for custom types. Should return absl::nullopt if // the given string cannot be properly parsed. template -absl::optional ParseTypedParameter(std::string); +absl::optional ParseTypedParameter(absl::string_view); // This class uses the ParseTypedParameter function to implement a parameter // implementation with an enforced default value. template class FieldTrialParameter : public FieldTrialParameterInterface { public: - FieldTrialParameter(std::string key, T default_value) + FieldTrialParameter(absl::string_view key, T default_value) : FieldTrialParameterInterface(key), value_(default_value) {} T Get() const { return value_; } operator T() const { return Get(); } @@ -108,7 +108,7 @@ class FieldTrialParameter : public FieldTrialParameterInterface { template class FieldTrialConstrained : public FieldTrialParameterInterface { public: - FieldTrialConstrained(std::string key, + FieldTrialConstrained(absl::string_view key, T default_value, absl::optional lower_limit, absl::optional upper_limit) @@ -141,7 +141,7 @@ class FieldTrialConstrained : public FieldTrialParameterInterface { class AbstractFieldTrialEnum : public FieldTrialParameterInterface { public: - AbstractFieldTrialEnum(std::string key, + AbstractFieldTrialEnum(absl::string_view key, int default_value, std::map mapping); ~AbstractFieldTrialEnum() override; @@ -162,7 +162,7 @@ class AbstractFieldTrialEnum : public FieldTrialParameterInterface { template class FieldTrialEnum : public AbstractFieldTrialEnum { public: - FieldTrialEnum(std::string key, + FieldTrialEnum(absl::string_view key, T default_value, std::map mapping) : AbstractFieldTrialEnum(key, @@ -185,9 +185,9 @@ class FieldTrialEnum : public AbstractFieldTrialEnum { template class FieldTrialOptional : public FieldTrialParameterInterface { public: - explicit FieldTrialOptional(std::string key) + explicit FieldTrialOptional(absl::string_view key) : FieldTrialParameterInterface(key) {} - FieldTrialOptional(std::string key, absl::optional default_value) + FieldTrialOptional(absl::string_view key, absl::optional default_value) : FieldTrialParameterInterface(key), value_(default_value) {} absl::optional GetOptional() const { return value_; } const T& Value() const { return value_.value(); } @@ -217,8 +217,8 @@ class FieldTrialOptional : public FieldTrialParameterInterface { // explicit value is provided, the flag evaluates to true. class FieldTrialFlag : public FieldTrialParameterInterface { public: - explicit FieldTrialFlag(std::string key); - FieldTrialFlag(std::string key, bool default_value); + explicit FieldTrialFlag(absl::string_view key); + FieldTrialFlag(absl::string_view key, bool default_value); bool Get() const; explicit operator bool() const; @@ -230,7 +230,8 @@ class FieldTrialFlag : public FieldTrialParameterInterface { }; template -absl::optional> ParseOptionalParameter(std::string str) { +absl::optional> ParseOptionalParameter( + absl::string_view str) { if (str.empty()) return absl::optional(); auto parsed = ParseTypedParameter(str); @@ -240,28 +241,29 @@ absl::optional> ParseOptionalParameter(std::string str) { } template <> -absl::optional ParseTypedParameter(std::string str); +absl::optional ParseTypedParameter(absl::string_view str); template <> -absl::optional ParseTypedParameter(std::string str); +absl::optional ParseTypedParameter(absl::string_view str); template <> -absl::optional ParseTypedParameter(std::string str); +absl::optional ParseTypedParameter(absl::string_view str); template <> -absl::optional ParseTypedParameter(std::string str); +absl::optional ParseTypedParameter(absl::string_view str); template <> -absl::optional ParseTypedParameter(std::string str); +absl::optional ParseTypedParameter( + absl::string_view str); template <> absl::optional> ParseTypedParameter>( - std::string str); + absl::string_view str); template <> absl::optional> ParseTypedParameter>( - std::string str); + absl::string_view str); template <> absl::optional> -ParseTypedParameter>(std::string str); +ParseTypedParameter>(absl::string_view str); template <> absl::optional> -ParseTypedParameter>(std::string str); +ParseTypedParameter>(absl::string_view str); // Accepts true, false, else parsed with sscanf %i, true if != 0. extern template class FieldTrialParameter; diff --git a/rtc_base/experiments/field_trial_parser_unittest.cc b/rtc_base/experiments/field_trial_parser_unittest.cc index d36b3c7d95..9916edee97 100644 --- a/rtc_base/experiments/field_trial_parser_unittest.cc +++ b/rtc_base/experiments/field_trial_parser_unittest.cc @@ -9,6 +9,7 @@ */ #include "rtc_base/experiments/field_trial_parser.h" +#include "absl/strings/string_view.h" #include "rtc_base/experiments/field_trial_list.h" #include "rtc_base/gunit.h" #include "system_wrappers/include/field_trial.h" @@ -28,7 +29,7 @@ struct DummyExperiment { FieldTrialParameter hash = FieldTrialParameter("h", "a80"); - explicit DummyExperiment(std::string field_trial) { + explicit DummyExperiment(absl::string_view field_trial) { ParseFieldTrial({&enabled, &factor, &retries, &size, &ping, &hash}, field_trial); } diff --git a/rtc_base/experiments/field_trial_units.cc b/rtc_base/experiments/field_trial_units.cc index 5aceab76a0..92af46a9e3 100644 --- a/rtc_base/experiments/field_trial_units.cc +++ b/rtc_base/experiments/field_trial_units.cc @@ -14,6 +14,7 @@ #include #include +#include "absl/strings/string_view.h" #include "absl/types/optional.h" // Large enough to fit "seconds", the longest supported unit name. @@ -28,7 +29,7 @@ struct ValueWithUnit { std::string unit; }; -absl::optional ParseValueWithUnit(std::string str) { +absl::optional ParseValueWithUnit(absl::string_view str) { if (str == "inf") { return ValueWithUnit{std::numeric_limits::infinity(), ""}; } else if (str == "-inf") { @@ -37,8 +38,8 @@ absl::optional ParseValueWithUnit(std::string str) { double double_val; char unit_char[RTC_TRIAL_UNIT_SIZE]; unit_char[0] = 0; - if (sscanf(str.c_str(), "%lf%" RTC_TRIAL_UNIT_LENGTH_STR "s", &double_val, - unit_char) >= 1) { + if (sscanf(std::string(str).c_str(), "%lf%" RTC_TRIAL_UNIT_LENGTH_STR "s", + &double_val, unit_char) >= 1) { return ValueWithUnit{double_val, unit_char}; } } @@ -47,7 +48,7 @@ absl::optional ParseValueWithUnit(std::string str) { } // namespace template <> -absl::optional ParseTypedParameter(std::string str) { +absl::optional ParseTypedParameter(absl::string_view str) { absl::optional result = ParseValueWithUnit(str); if (result) { if (result->unit.empty() || result->unit == "kbps") { @@ -60,7 +61,7 @@ absl::optional ParseTypedParameter(std::string str) { } template <> -absl::optional ParseTypedParameter(std::string str) { +absl::optional ParseTypedParameter(absl::string_view str) { absl::optional result = ParseValueWithUnit(str); if (result) { if (result->unit.empty() || result->unit == "bytes") @@ -70,7 +71,8 @@ absl::optional ParseTypedParameter(std::string str) { } template <> -absl::optional ParseTypedParameter(std::string str) { +absl::optional ParseTypedParameter( + absl::string_view str) { absl::optional result = ParseValueWithUnit(str); if (result) { if (result->unit == "s" || result->unit == "seconds") { @@ -86,17 +88,17 @@ absl::optional ParseTypedParameter(std::string str) { template <> absl::optional> -ParseTypedParameter>(std::string str) { +ParseTypedParameter>(absl::string_view str) { return ParseOptionalParameter(str); } template <> absl::optional> -ParseTypedParameter>(std::string str) { +ParseTypedParameter>(absl::string_view str) { return ParseOptionalParameter(str); } template <> absl::optional> -ParseTypedParameter>(std::string str) { +ParseTypedParameter>(absl::string_view str) { return ParseOptionalParameter(str); } diff --git a/rtc_base/experiments/field_trial_units.h b/rtc_base/experiments/field_trial_units.h index d85b2f04ba..408367c031 100644 --- a/rtc_base/experiments/field_trial_units.h +++ b/rtc_base/experiments/field_trial_units.h @@ -10,6 +10,7 @@ #ifndef RTC_BASE_EXPERIMENTS_FIELD_TRIAL_UNITS_H_ #define RTC_BASE_EXPERIMENTS_FIELD_TRIAL_UNITS_H_ +#include "absl/strings/string_view.h" #include "api/units/data_rate.h" #include "api/units/data_size.h" #include "api/units/time_delta.h" @@ -18,11 +19,11 @@ namespace webrtc { template <> -absl::optional ParseTypedParameter(std::string str); +absl::optional ParseTypedParameter(absl::string_view str); template <> -absl::optional ParseTypedParameter(std::string str); +absl::optional ParseTypedParameter(absl::string_view str); template <> -absl::optional ParseTypedParameter(std::string str); +absl::optional ParseTypedParameter(absl::string_view str); extern template class FieldTrialParameter; extern template class FieldTrialParameter; diff --git a/rtc_base/experiments/field_trial_units_unittest.cc b/rtc_base/experiments/field_trial_units_unittest.cc index 1f46d6f9ee..8996663d8e 100644 --- a/rtc_base/experiments/field_trial_units_unittest.cc +++ b/rtc_base/experiments/field_trial_units_unittest.cc @@ -11,6 +11,7 @@ #include +#include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "rtc_base/experiments/field_trial_parser.h" #include "test/gtest.h" @@ -25,7 +26,7 @@ struct DummyExperiment { FieldTrialOptional max_buffer = FieldTrialOptional("b", absl::nullopt); - explicit DummyExperiment(std::string field_trial) { + explicit DummyExperiment(absl::string_view field_trial) { ParseFieldTrial({&target_rate, &max_buffer, &period}, field_trial); } }; diff --git a/rtc_base/experiments/struct_parameters_parser.cc b/rtc_base/experiments/struct_parameters_parser.cc index d62eb6f1ea..011df3eaba 100644 --- a/rtc_base/experiments/struct_parameters_parser.cc +++ b/rtc_base/experiments/struct_parameters_parser.cc @@ -11,13 +11,14 @@ #include +#include "absl/strings/string_view.h" #include "rtc_base/logging.h" namespace webrtc { namespace { size_t FindOrEnd(absl::string_view str, size_t start, char delimiter) { size_t pos = str.find(delimiter, start); - pos = (pos == std::string::npos) ? str.length() : pos; + pos = (pos == absl::string_view::npos) ? str.length() : pos; return pos; } } // namespace diff --git a/rtc_base/fake_ssl_identity.cc b/rtc_base/fake_ssl_identity.cc index 87ede73985..73c843a2e7 100644 --- a/rtc_base/fake_ssl_identity.cc +++ b/rtc_base/fake_ssl_identity.cc @@ -14,12 +14,13 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/checks.h" #include "rtc_base/message_digest.h" namespace rtc { -FakeSSLCertificate::FakeSSLCertificate(const std::string& pem_string) +FakeSSLCertificate::FakeSSLCertificate(absl::string_view pem_string) : pem_string_(pem_string), digest_algorithm_(DIGEST_SHA_1), expiration_time_(-1) {} @@ -51,8 +52,8 @@ void FakeSSLCertificate::SetCertificateExpirationTime(int64_t expiration_time) { expiration_time_ = expiration_time; } -void FakeSSLCertificate::set_digest_algorithm(const std::string& algorithm) { - digest_algorithm_ = algorithm; +void FakeSSLCertificate::set_digest_algorithm(absl::string_view algorithm) { + digest_algorithm_ = std::string(algorithm); } bool FakeSSLCertificate::GetSignatureDigestAlgorithm( @@ -61,7 +62,7 @@ bool FakeSSLCertificate::GetSignatureDigestAlgorithm( return true; } -bool FakeSSLCertificate::ComputeDigest(const std::string& algorithm, +bool FakeSSLCertificate::ComputeDigest(absl::string_view algorithm, unsigned char* digest, size_t size, size_t* length) const { @@ -70,7 +71,7 @@ bool FakeSSLCertificate::ComputeDigest(const std::string& algorithm, return (*length != 0); } -FakeSSLIdentity::FakeSSLIdentity(const std::string& pem_string) +FakeSSLIdentity::FakeSSLIdentity(absl::string_view pem_string) : FakeSSLIdentity(FakeSSLCertificate(pem_string)) {} FakeSSLIdentity::FakeSSLIdentity(const std::vector& pem_strings) { diff --git a/rtc_base/fake_ssl_identity.h b/rtc_base/fake_ssl_identity.h index 512baba9fb..2b4ae2e57a 100644 --- a/rtc_base/fake_ssl_identity.h +++ b/rtc_base/fake_ssl_identity.h @@ -14,6 +14,7 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/ssl_certificate.h" #include "rtc_base/ssl_identity.h" @@ -23,7 +24,7 @@ class FakeSSLCertificate : public SSLCertificate { public: // SHA-1 is the default digest algorithm because it is available in all build // configurations used for unit testing. - explicit FakeSSLCertificate(const std::string& pem_string); + explicit FakeSSLCertificate(absl::string_view pem_string); FakeSSLCertificate(const FakeSSLCertificate&); ~FakeSSLCertificate() override; @@ -34,14 +35,14 @@ class FakeSSLCertificate : public SSLCertificate { void ToDER(Buffer* der_buffer) const override; int64_t CertificateExpirationTime() const override; bool GetSignatureDigestAlgorithm(std::string* algorithm) const override; - bool ComputeDigest(const std::string& algorithm, + bool ComputeDigest(absl::string_view algorithm, unsigned char* digest, size_t size, size_t* length) const override; void SetCertificateExpirationTime(int64_t expiration_time); - void set_digest_algorithm(const std::string& algorithm); + void set_digest_algorithm(absl::string_view algorithm); private: std::string pem_string_; @@ -52,7 +53,7 @@ class FakeSSLCertificate : public SSLCertificate { class FakeSSLIdentity : public SSLIdentity { public: - explicit FakeSSLIdentity(const std::string& pem_string); + explicit FakeSSLIdentity(absl::string_view pem_string); // For a certificate chain. explicit FakeSSLIdentity(const std::vector& pem_strings); explicit FakeSSLIdentity(const FakeSSLCertificate& cert); diff --git a/rtc_base/file_rotating_stream.cc b/rtc_base/file_rotating_stream.cc index 5a004a937b..c529b5b1b4 100644 --- a/rtc_base/file_rotating_stream.cc +++ b/rtc_base/file_rotating_stream.cc @@ -14,6 +14,8 @@ #include #include +#include "absl/strings/string_view.h" + #if defined(WEBRTC_WIN) #include @@ -29,6 +31,7 @@ #include "absl/types/optional.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" +#include "rtc_base/strings/string_builder.h" // Note: We use fprintf for logging in the write paths of this stream to avoid // infinite loops when logging. @@ -39,54 +42,58 @@ namespace { const char kCallSessionLogPrefix[] = "webrtc_log"; -std::string AddTrailingPathDelimiterIfNeeded(std::string directory); +std::string AddTrailingPathDelimiterIfNeeded(absl::string_view directory); // `dir` must have a trailing delimiter. `prefix` must not include wild card // characters. -std::vector GetFilesWithPrefix(const std::string& directory, - const std::string& prefix); -bool DeleteFile(const std::string& file); -bool MoveFile(const std::string& old_file, const std::string& new_file); -bool IsFile(const std::string& file); -bool IsFolder(const std::string& file); -absl::optional GetFileSize(const std::string& file); +std::vector GetFilesWithPrefix(absl::string_view directory, + absl::string_view prefix); +bool DeleteFile(absl::string_view file); +bool MoveFile(absl::string_view old_file, absl::string_view new_file); +bool IsFile(absl::string_view file); +bool IsFolder(absl::string_view file); +absl::optional GetFileSize(absl::string_view file); #if defined(WEBRTC_WIN) -std::string AddTrailingPathDelimiterIfNeeded(std::string directory) { +std::string AddTrailingPathDelimiterIfNeeded(absl::string_view directory) { if (absl::EndsWith(directory, "\\")) { - return directory; + return std::string(directory); } - return directory + "\\"; + return std::string(directory) + "\\"; } -std::vector GetFilesWithPrefix(const std::string& directory, - const std::string& prefix) { +std::vector GetFilesWithPrefix(absl::string_view directory, + absl::string_view prefix) { RTC_DCHECK(absl::EndsWith(directory, "\\")); WIN32_FIND_DATAW data; HANDLE handle; - handle = ::FindFirstFileW(ToUtf16(directory + prefix + '*').c_str(), &data); + StringBuilder pattern_builder{directory}; + pattern_builder << prefix << "*"; + handle = ::FindFirstFileW(ToUtf16(pattern_builder.str()).c_str(), &data); if (handle == INVALID_HANDLE_VALUE) return {}; std::vector file_list; do { - file_list.emplace_back(directory + ToUtf8(data.cFileName)); + StringBuilder file_builder{directory}; + file_builder << ToUtf8(data.cFileName); + file_list.emplace_back(file_builder.Release()); } while (::FindNextFileW(handle, &data) == TRUE); ::FindClose(handle); return file_list; } -bool DeleteFile(const std::string& file) { +bool DeleteFile(absl::string_view file) { return ::DeleteFileW(ToUtf16(file).c_str()) != 0; } -bool MoveFile(const std::string& old_file, const std::string& new_file) { +bool MoveFile(absl::string_view old_file, absl::string_view new_file) { return ::MoveFileW(ToUtf16(old_file).c_str(), ToUtf16(new_file).c_str()) != 0; } -bool IsFile(const std::string& file) { +bool IsFile(absl::string_view file) { WIN32_FILE_ATTRIBUTE_DATA data = {0}; if (0 == ::GetFileAttributesExW(ToUtf16(file).c_str(), GetFileExInfoStandard, &data)) @@ -94,7 +101,7 @@ bool IsFile(const std::string& file) { return (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0; } -bool IsFolder(const std::string& file) { +bool IsFolder(absl::string_view file) { WIN32_FILE_ATTRIBUTE_DATA data = {0}; if (0 == ::GetFileAttributesExW(ToUtf16(file).c_str(), GetFileExInfoStandard, &data)) @@ -103,7 +110,7 @@ bool IsFolder(const std::string& file) { FILE_ATTRIBUTE_DIRECTORY; } -absl::optional GetFileSize(const std::string& file) { +absl::optional GetFileSize(absl::string_view file) { WIN32_FILE_ATTRIBUTE_DATA data = {0}; if (::GetFileAttributesExW(ToUtf16(file).c_str(), GetFileExInfoStandard, &data) == 0) @@ -113,55 +120,57 @@ absl::optional GetFileSize(const std::string& file) { #else // defined(WEBRTC_WIN) -std::string AddTrailingPathDelimiterIfNeeded(std::string directory) { +std::string AddTrailingPathDelimiterIfNeeded(absl::string_view directory) { if (absl::EndsWith(directory, "/")) { - return directory; + return std::string(directory); } - return directory + "/"; + return std::string(directory) + "/"; } -std::vector GetFilesWithPrefix(const std::string& directory, - const std::string& prefix) { +std::vector GetFilesWithPrefix(absl::string_view directory, + absl::string_view prefix) { RTC_DCHECK(absl::EndsWith(directory, "/")); - DIR* dir = ::opendir(directory.c_str()); + std::string directory_str = std::string(directory); + DIR* dir = ::opendir(directory_str.c_str()); if (dir == nullptr) return {}; std::vector file_list; for (struct dirent* dirent = ::readdir(dir); dirent; dirent = ::readdir(dir)) { std::string name = dirent->d_name; - if (name.compare(0, prefix.size(), prefix) == 0) { - file_list.emplace_back(directory + name); + if (name.compare(0, prefix.size(), prefix.data(), prefix.size()) == 0) { + file_list.emplace_back(directory_str + name); } } ::closedir(dir); return file_list; } -bool DeleteFile(const std::string& file) { - return ::unlink(file.c_str()) == 0; +bool DeleteFile(absl::string_view file) { + return ::unlink(std::string(file).c_str()) == 0; } -bool MoveFile(const std::string& old_file, const std::string& new_file) { - return ::rename(old_file.c_str(), new_file.c_str()) == 0; +bool MoveFile(absl::string_view old_file, absl::string_view new_file) { + return ::rename(std::string(old_file).c_str(), + std::string(new_file).c_str()) == 0; } -bool IsFile(const std::string& file) { +bool IsFile(absl::string_view file) { struct stat st; - int res = ::stat(file.c_str(), &st); + int res = ::stat(std::string(file).c_str(), &st); // Treat symlinks, named pipes, etc. all as files. return res == 0 && !S_ISDIR(st.st_mode); } -bool IsFolder(const std::string& file) { +bool IsFolder(absl::string_view file) { struct stat st; - int res = ::stat(file.c_str(), &st); + int res = ::stat(std::string(file).c_str(), &st); return res == 0 && S_ISDIR(st.st_mode); } -absl::optional GetFileSize(const std::string& file) { +absl::optional GetFileSize(absl::string_view file) { struct stat st; - if (::stat(file.c_str(), &st) != 0) + if (::stat(std::string(file).c_str(), &st) != 0) return absl::nullopt; return st.st_size; } @@ -170,8 +179,8 @@ absl::optional GetFileSize(const std::string& file) { } // namespace -FileRotatingStream::FileRotatingStream(const std::string& dir_path, - const std::string& file_prefix, +FileRotatingStream::FileRotatingStream(absl::string_view dir_path, + absl::string_view file_prefix, size_t max_file_size, size_t num_files) : dir_path_(AddTrailingPathDelimiterIfNeeded(dir_path)), @@ -331,7 +340,7 @@ std::string FileRotatingStream::GetFilePath(size_t index, } CallSessionFileRotatingStream::CallSessionFileRotatingStream( - const std::string& dir_path, + absl::string_view dir_path, size_t max_total_log_size) : FileRotatingStream(dir_path, kCallSessionLogPrefix, @@ -376,8 +385,8 @@ size_t CallSessionFileRotatingStream::GetNumRotatingLogFiles( } FileRotatingStreamReader::FileRotatingStreamReader( - const std::string& dir_path, - const std::string& file_prefix) { + absl::string_view dir_path, + absl::string_view file_prefix) { file_names_ = GetFilesWithPrefix(AddTrailingPathDelimiterIfNeeded(dir_path), file_prefix); @@ -413,7 +422,7 @@ size_t FileRotatingStreamReader::ReadAll(void* buffer, size_t size) const { } CallSessionFileRotatingStreamReader::CallSessionFileRotatingStreamReader( - const std::string& dir_path) + absl::string_view dir_path) : FileRotatingStreamReader(dir_path, kCallSessionLogPrefix) {} } // namespace rtc diff --git a/rtc_base/file_rotating_stream.h b/rtc_base/file_rotating_stream.h index 6aaa0bd783..6ae2753098 100644 --- a/rtc_base/file_rotating_stream.h +++ b/rtc_base/file_rotating_stream.h @@ -17,6 +17,7 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/system/file_wrapper.h" namespace rtc { @@ -29,8 +30,8 @@ class FileRotatingStream { public: // Use this constructor for writing to a directory. Files in the directory // matching the prefix will be deleted on open. - FileRotatingStream(const std::string& dir_path, - const std::string& file_prefix, + FileRotatingStream(absl::string_view dir_path, + absl::string_view file_prefix, size_t max_file_size, size_t num_files); @@ -126,7 +127,7 @@ class CallSessionFileRotatingStream : public FileRotatingStream { // Use this constructor for writing to a directory. Files in the directory // matching what's used by the stream will be deleted. `max_total_log_size` // must be at least 4. - CallSessionFileRotatingStream(const std::string& dir_path, + CallSessionFileRotatingStream(absl::string_view dir_path, size_t max_total_log_size); ~CallSessionFileRotatingStream() override {} @@ -152,8 +153,8 @@ class CallSessionFileRotatingStream : public FileRotatingStream { // directory at construction time. class FileRotatingStreamReader { public: - FileRotatingStreamReader(const std::string& dir_path, - const std::string& file_prefix); + FileRotatingStreamReader(absl::string_view dir_path, + absl::string_view file_prefix); ~FileRotatingStreamReader(); size_t GetSize() const; size_t ReadAll(void* buffer, size_t size) const; @@ -164,7 +165,7 @@ class FileRotatingStreamReader { class CallSessionFileRotatingStreamReader : public FileRotatingStreamReader { public: - CallSessionFileRotatingStreamReader(const std::string& dir_path); + CallSessionFileRotatingStreamReader(absl::string_view dir_path); }; } // namespace rtc diff --git a/rtc_base/file_rotating_stream_unittest.cc b/rtc_base/file_rotating_stream_unittest.cc index 849b111148..a48dfe9a61 100644 --- a/rtc_base/file_rotating_stream_unittest.cc +++ b/rtc_base/file_rotating_stream_unittest.cc @@ -15,6 +15,7 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/arraysize.h" #include "test/gtest.h" #include "test/testsupport/file_utils.h" @@ -44,15 +45,15 @@ class MAYBE_FileRotatingStreamTest : public ::testing::Test { static const char* kFilePrefix; static const size_t kMaxFileSize; - void Init(const std::string& dir_name, - const std::string& file_prefix, + void Init(absl::string_view dir_name, + absl::string_view file_prefix, size_t max_file_size, size_t num_log_files, bool ensure_trailing_delimiter = true) { dir_path_ = webrtc::test::OutputPath(); // Append per-test output path in order to run within gtest parallel. - dir_path_.append(dir_name); + dir_path_.append(dir_name.begin(), dir_name.end()); if (ensure_trailing_delimiter) { dir_path_.append(webrtc::test::kPathDelimiter); } @@ -80,7 +81,7 @@ class MAYBE_FileRotatingStreamTest : public ::testing::Test { // end of stream result. void VerifyStreamRead(const char* expected_contents, const size_t expected_length, - const std::string& dir_path, + absl::string_view dir_path, const char* file_prefix) { FileRotatingStreamReader reader(dir_path, file_prefix); EXPECT_EQ(reader.GetSize(), expected_length); @@ -92,9 +93,10 @@ class MAYBE_FileRotatingStreamTest : public ::testing::Test { void VerifyFileContents(const char* expected_contents, const size_t expected_length, - const std::string& file_path) { + absl::string_view file_path) { std::unique_ptr buffer(new uint8_t[expected_length + 1]); - webrtc::FileWrapper f = webrtc::FileWrapper::OpenReadOnly(file_path); + webrtc::FileWrapper f = + webrtc::FileWrapper::OpenReadOnly(std::string(file_path)); ASSERT_TRUE(f.is_open()); size_t size_read = f.Read(buffer.get(), expected_length + 1); EXPECT_EQ(size_read, expected_length); @@ -255,11 +257,11 @@ TEST_F(MAYBE_FileRotatingStreamTest, GetFilePath) { class MAYBE_CallSessionFileRotatingStreamTest : public ::testing::Test { protected: - void Init(const std::string& dir_name, size_t max_total_log_size) { + void Init(absl::string_view dir_name, size_t max_total_log_size) { dir_path_ = webrtc::test::OutputPath(); // Append per-test output path in order to run within gtest parallel. - dir_path_.append(dir_name); + dir_path_.append(dir_name.begin(), dir_name.end()); dir_path_.append(webrtc::test::kPathDelimiter); ASSERT_TRUE(webrtc::test::CreateDir(dir_path_)); stream_.reset( @@ -285,7 +287,7 @@ class MAYBE_CallSessionFileRotatingStreamTest : public ::testing::Test { // end of stream result. void VerifyStreamRead(const char* expected_contents, const size_t expected_length, - const std::string& dir_path) { + absl::string_view dir_path) { CallSessionFileRotatingStreamReader reader(dir_path); EXPECT_EQ(reader.GetSize(), expected_length); std::unique_ptr buffer(new uint8_t[expected_length]); diff --git a/rtc_base/gunit.cc b/rtc_base/gunit.cc index 83ee8075fb..7cd60fe9ee 100644 --- a/rtc_base/gunit.cc +++ b/rtc_base/gunit.cc @@ -13,6 +13,7 @@ #include #include "absl/strings/match.h" +#include "absl/strings/string_view.h" ::testing::AssertionResult AssertStartsWith(const char* text_expr, const char* prefix_expr, @@ -30,9 +31,9 @@ ::testing::AssertionResult AssertStartsWith(const char* text_expr, ::testing::AssertionResult AssertStringContains(const char* str_expr, const char* substr_expr, - const std::string& str, - const std::string& substr) { - if (str.find(substr) != std::string::npos) { + absl::string_view str, + absl::string_view substr) { + if (str.find(substr) != absl::string_view::npos) { return ::testing::AssertionSuccess(); } else { return ::testing::AssertionFailure() diff --git a/rtc_base/gunit.h b/rtc_base/gunit.h index dedf3ee067..ac99c7ac4d 100644 --- a/rtc_base/gunit.h +++ b/rtc_base/gunit.h @@ -11,6 +11,7 @@ #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" @@ -162,7 +163,7 @@ testing::AssertionResult AssertStartsWith(const char* text_expr, // Usage: EXPECT_PRED_FORMAT2(AssertStringContains, str, "substring"); testing::AssertionResult AssertStringContains(const char* str_expr, const char* substr_expr, - const std::string& str, - const std::string& substr); + absl::string_view str, + absl::string_view substr); #endif // RTC_BASE_GUNIT_H_ diff --git a/rtc_base/helpers.cc b/rtc_base/helpers.cc index 64cab10335..337239894a 100644 --- a/rtc_base/helpers.cc +++ b/rtc_base/helpers.cc @@ -16,6 +16,7 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" @@ -145,10 +146,8 @@ bool CreateRandomString(size_t len, std::string* str) { return CreateRandomString(len, kBase64, 64, str); } -bool CreateRandomString(size_t len, - const std::string& table, - std::string* str) { - return CreateRandomString(len, table.c_str(), static_cast(table.size()), +bool CreateRandomString(size_t len, absl::string_view table, std::string* str) { + return CreateRandomString(len, table.data(), static_cast(table.size()), str); } diff --git a/rtc_base/helpers.h b/rtc_base/helpers.h index 2fd2fc5218..c214f5212f 100644 --- a/rtc_base/helpers.h +++ b/rtc_base/helpers.h @@ -16,6 +16,7 @@ #include +#include "absl/strings/string_view.h" #include "rtc_base/system/rtc_export.h" namespace rtc { @@ -42,7 +43,7 @@ RTC_EXPORT bool CreateRandomString(size_t length, std::string* str); // For ease of implementation, the function requires that the table // size evenly divide 256; otherwise, it returns false. RTC_EXPORT bool CreateRandomString(size_t length, - const std::string& table, + absl::string_view table, std::string* str); // Generates (cryptographically) random data of the given length. diff --git a/rtc_base/http_common.cc b/rtc_base/http_common.cc index 0d7832264b..88639a7c70 100644 --- a/rtc_base/http_common.cc +++ b/rtc_base/http_common.cc @@ -10,6 +10,8 @@ #include +#include "absl/strings/string_view.h" + #if defined(WEBRTC_WIN) #include #include @@ -185,7 +187,7 @@ void HttpParseAttributes(const char* data, } bool HttpHasAttribute(const HttpAttributeList& attributes, - const std::string& name, + absl::string_view name, std::string* value) { for (HttpAttributeList::const_iterator it = attributes.begin(); it != attributes.end(); ++it) { @@ -213,7 +215,7 @@ bool HttpHasNthAttribute(HttpAttributeList& attributes, return true; } -std::string quote(const std::string& str) { +std::string quote(absl::string_view str) { std::string result; result.push_back('"'); for (size_t i = 0; i < str.size(); ++i) { @@ -232,7 +234,7 @@ struct NegotiateAuthContext : public HttpAuthContext { size_t steps; bool specified_credentials; - NegotiateAuthContext(const std::string& auth, CredHandle c1, CtxtHandle c2) + NegotiateAuthContext(absl::string_view auth, CredHandle c1, CtxtHandle c2) : HttpAuthContext(auth), cred(c1), ctx(c2), @@ -251,9 +253,9 @@ struct NegotiateAuthContext : public HttpAuthContext { HttpAuthResult HttpAuthenticate(const char* challenge, size_t len, const SocketAddress& server, - const std::string& method, - const std::string& uri, - const std::string& username, + absl::string_view method, + absl::string_view uri, + absl::string_view username, const CryptString& password, HttpAuthContext*& context, std::string& response, @@ -326,7 +328,7 @@ HttpAuthResult HttpAuthenticate(const char* challenge, pos += strcpyn(sensitive + pos, len - pos, ":"); password.CopyTo(sensitive + pos, true); - std::string A2 = method + ":" + uri; + std::string A2 = std::string(method) + ":" + std::string(uri); std::string middle; if (has_qop) { qop = "auth"; @@ -459,11 +461,11 @@ HttpAuthResult HttpAuthenticate(const char* challenge, size_t len = password.GetLength() + 1; char* sensitive = new char[len]; password.CopyTo(sensitive, true); - std::string::size_type pos = username.find('\\'); - if (pos == std::string::npos) { + absl::string_view::size_type pos = username.find('\\'); + if (pos == absl::string_view::npos) { auth_id.UserLength = static_cast( std::min(sizeof(userbuf) - 1, username.size())); - memcpy(userbuf, username.c_str(), auth_id.UserLength); + memcpy(userbuf, username.data(), auth_id.UserLength); userbuf[auth_id.UserLength] = 0; auth_id.DomainLength = 0; domainbuf[auth_id.DomainLength] = 0; @@ -474,11 +476,11 @@ HttpAuthResult HttpAuthenticate(const char* challenge, } else { auth_id.UserLength = static_cast( std::min(sizeof(userbuf) - 1, username.size() - pos - 1)); - memcpy(userbuf, username.c_str() + pos + 1, auth_id.UserLength); + memcpy(userbuf, username.data() + pos + 1, auth_id.UserLength); userbuf[auth_id.UserLength] = 0; auth_id.DomainLength = static_cast(std::min(sizeof(domainbuf) - 1, pos)); - memcpy(domainbuf, username.c_str(), auth_id.DomainLength); + memcpy(domainbuf, username.data(), auth_id.DomainLength); domainbuf[auth_id.DomainLength] = 0; auth_id.PasswordLength = static_cast( std::min(sizeof(passbuf) - 1, password.GetLength())); diff --git a/rtc_base/http_common.h b/rtc_base/http_common.h index edf161fb4c..d287bd5d7c 100644 --- a/rtc_base/http_common.h +++ b/rtc_base/http_common.h @@ -13,6 +13,8 @@ #include +#include "absl/strings/string_view.h" + namespace rtc { class CryptString; @@ -24,7 +26,7 @@ class SocketAddress; struct HttpAuthContext { std::string auth_method; - HttpAuthContext(const std::string& auth) : auth_method(auth) {} + HttpAuthContext(absl::string_view auth) : auth_method(auth) {} virtual ~HttpAuthContext() {} }; @@ -37,9 +39,9 @@ enum HttpAuthResult { HAR_RESPONSE, HAR_IGNORE, HAR_CREDENTIALS, HAR_ERROR }; HttpAuthResult HttpAuthenticate(const char* challenge, size_t len, const SocketAddress& server, - const std::string& method, - const std::string& uri, - const std::string& username, + absl::string_view method, + absl::string_view uri, + absl::string_view username, const CryptString& password, HttpAuthContext*& context, std::string& response, diff --git a/rtc_base/ip_address.cc b/rtc_base/ip_address.cc index 86f42e0bf9..5ebb402145 100644 --- a/rtc_base/ip_address.cc +++ b/rtc_base/ip_address.cc @@ -11,6 +11,8 @@ #if defined(WEBRTC_POSIX) #include #include + +#include "absl/strings/string_view.h" #ifdef OPENBSD #include #endif @@ -276,14 +278,15 @@ bool IPFromAddrInfo(struct addrinfo* info, IPAddress* out) { return false; } -bool IPFromString(const std::string& str, IPAddress* out) { +bool IPFromString(absl::string_view str, IPAddress* out) { if (!out) { return false; } in_addr addr; - if (rtc::inet_pton(AF_INET, str.c_str(), &addr) == 0) { + const std::string str_copy = std::string(str); + if (rtc::inet_pton(AF_INET, str_copy.c_str(), &addr) == 0) { in6_addr addr6; - if (rtc::inet_pton(AF_INET6, str.c_str(), &addr6) == 0) { + if (rtc::inet_pton(AF_INET6, str_copy.c_str(), &addr6) == 0) { *out = IPAddress(); return false; } @@ -294,7 +297,7 @@ bool IPFromString(const std::string& str, IPAddress* out) { return true; } -bool IPFromString(const std::string& str, int flags, InterfaceAddress* out) { +bool IPFromString(absl::string_view str, int flags, InterfaceAddress* out) { IPAddress ip; if (!IPFromString(str, &ip)) { return false; diff --git a/rtc_base/ip_address.h b/rtc_base/ip_address.h index 8725417393..58ad8ba4b2 100644 --- a/rtc_base/ip_address.h +++ b/rtc_base/ip_address.h @@ -16,6 +16,8 @@ #include #include #include + +#include "absl/strings/string_view.h" #endif #if defined(WEBRTC_WIN) #include @@ -29,8 +31,8 @@ #if defined(WEBRTC_WIN) #include "rtc_base/win32.h" #endif +#include "absl/strings/string_view.h" #include "rtc_base/system/rtc_export.h" - namespace rtc { enum IPv6AddressFlag { @@ -155,8 +157,8 @@ class RTC_EXPORT InterfaceAddress : public IPAddress { }; bool IPFromAddrInfo(struct addrinfo* info, IPAddress* out); -RTC_EXPORT bool IPFromString(const std::string& str, IPAddress* out); -RTC_EXPORT bool IPFromString(const std::string& str, +RTC_EXPORT bool IPFromString(absl::string_view str, IPAddress* out); +RTC_EXPORT bool IPFromString(absl::string_view str, int flags, InterfaceAddress* out); bool IPIsAny(const IPAddress& ip); diff --git a/rtc_base/ip_address_unittest.cc b/rtc_base/ip_address_unittest.cc index f94649cfee..9ca05c95fe 100644 --- a/rtc_base/ip_address_unittest.cc +++ b/rtc_base/ip_address_unittest.cc @@ -10,6 +10,7 @@ #include "rtc_base/ip_address.h" +#include "absl/strings/string_view.h" #include "test/gtest.h" namespace rtc { @@ -118,7 +119,7 @@ bool AreEqual(const IPAddress& addr, const IPAddress& addr2) { return true; } -bool BrokenIPStringFails(const std::string& broken) { +bool BrokenIPStringFails(absl::string_view broken) { IPAddress addr(0); // Intentionally make it v4. if (IPFromString(kIPv4BrokenString1, &addr)) { return false; @@ -126,13 +127,13 @@ bool BrokenIPStringFails(const std::string& broken) { return addr.family() == AF_UNSPEC; } -bool CheckMaskCount(const std::string& mask, int expected_length) { +bool CheckMaskCount(absl::string_view mask, int expected_length) { IPAddress addr; return IPFromString(mask, &addr) && (expected_length == CountIPMaskBits(addr)); } -bool TryInvalidMaskCount(const std::string& mask) { +bool TryInvalidMaskCount(absl::string_view mask) { // We don't care about the result at all, but we do want to know if // CountIPMaskBits is going to crash or infinite loop or something. IPAddress addr; @@ -143,9 +144,9 @@ bool TryInvalidMaskCount(const std::string& mask) { return true; } -bool CheckTruncateIP(const std::string& initial, +bool CheckTruncateIP(absl::string_view initial, int truncate_length, - const std::string& expected_result) { + absl::string_view expected_result) { IPAddress addr, expected; IPFromString(initial, &addr); IPFromString(expected_result, &expected); diff --git a/rtc_base/mdns_responder_interface.h b/rtc_base/mdns_responder_interface.h index 64fb3cebff..14ef9a202d 100644 --- a/rtc_base/mdns_responder_interface.h +++ b/rtc_base/mdns_responder_interface.h @@ -14,6 +14,7 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/ip_address.h" namespace webrtc { @@ -23,7 +24,7 @@ namespace webrtc { class MdnsResponderInterface { public: using NameCreatedCallback = - std::function; + std::function; using NameRemovedCallback = std::function; MdnsResponderInterface() = default; diff --git a/rtc_base/message_digest.cc b/rtc_base/message_digest.cc index 62b4a6bc97..3b39cf9f18 100644 --- a/rtc_base/message_digest.cc +++ b/rtc_base/message_digest.cc @@ -15,6 +15,7 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/openssl_digest.h" #include "rtc_base/string_encode.h" @@ -30,7 +31,7 @@ const char DIGEST_SHA_512[] = "sha-512"; static const size_t kBlockSize = 64; // valid for SHA-256 and down -MessageDigest* MessageDigestFactory::Create(const std::string& alg) { +MessageDigest* MessageDigestFactory::Create(absl::string_view alg) { MessageDigest* digest = new OpenSSLDigest(alg); if (digest->Size() == 0) { // invalid algorithm delete digest; @@ -39,7 +40,7 @@ MessageDigest* MessageDigestFactory::Create(const std::string& alg) { return digest; } -bool IsFips180DigestAlgorithm(const std::string& alg) { +bool IsFips180DigestAlgorithm(absl::string_view alg) { // These are the FIPS 180 algorithms. According to RFC 4572 Section 5, // "Self-signed certificates (for which legacy certificates are not a // consideration) MUST use one of the FIPS 180 algorithms (SHA-1, @@ -59,7 +60,7 @@ size_t ComputeDigest(MessageDigest* digest, return digest->Finish(output, out_len); } -size_t ComputeDigest(const std::string& alg, +size_t ComputeDigest(absl::string_view alg, const void* input, size_t in_len, void* output, @@ -69,15 +70,15 @@ size_t ComputeDigest(const std::string& alg, : 0; } -std::string ComputeDigest(MessageDigest* digest, const std::string& input) { +std::string ComputeDigest(MessageDigest* digest, absl::string_view input) { std::unique_ptr output(new char[digest->Size()]); ComputeDigest(digest, input.data(), input.size(), output.get(), digest->Size()); return hex_encode(output.get(), digest->Size()); } -bool ComputeDigest(const std::string& alg, - const std::string& input, +bool ComputeDigest(absl::string_view alg, + absl::string_view input, std::string* output) { std::unique_ptr digest(MessageDigestFactory::Create(alg)); if (!digest) { @@ -87,7 +88,7 @@ bool ComputeDigest(const std::string& alg, return true; } -std::string ComputeDigest(const std::string& alg, const std::string& input) { +std::string ComputeDigest(absl::string_view alg, absl::string_view input) { std::string output; ComputeDigest(alg, input, &output); return output; @@ -135,7 +136,7 @@ size_t ComputeHmac(MessageDigest* digest, return digest->Finish(output, out_len); } -size_t ComputeHmac(const std::string& alg, +size_t ComputeHmac(absl::string_view alg, const void* key, size_t key_len, const void* input, @@ -151,17 +152,17 @@ size_t ComputeHmac(const std::string& alg, } std::string ComputeHmac(MessageDigest* digest, - const std::string& key, - const std::string& input) { + absl::string_view key, + absl::string_view input) { std::unique_ptr output(new char[digest->Size()]); ComputeHmac(digest, key.data(), key.size(), input.data(), input.size(), output.get(), digest->Size()); return hex_encode(output.get(), digest->Size()); } -bool ComputeHmac(const std::string& alg, - const std::string& key, - const std::string& input, +bool ComputeHmac(absl::string_view alg, + absl::string_view key, + absl::string_view input, std::string* output) { std::unique_ptr digest(MessageDigestFactory::Create(alg)); if (!digest) { @@ -171,9 +172,9 @@ bool ComputeHmac(const std::string& alg, return true; } -std::string ComputeHmac(const std::string& alg, - const std::string& key, - const std::string& input) { +std::string ComputeHmac(absl::string_view alg, + absl::string_view key, + absl::string_view input) { std::string output; ComputeHmac(alg, key, input, &output); return output; diff --git a/rtc_base/message_digest.h b/rtc_base/message_digest.h index 02e0bfd561..632b9af075 100644 --- a/rtc_base/message_digest.h +++ b/rtc_base/message_digest.h @@ -15,6 +15,8 @@ #include +#include "absl/strings/string_view.h" + namespace rtc { // Definitions for the digest algorithms. @@ -42,12 +44,12 @@ class MessageDigest { // A factory class for creating digest objects. class MessageDigestFactory { public: - static MessageDigest* Create(const std::string& alg); + static MessageDigest* Create(absl::string_view alg); }; // A check that an algorithm is in a list of approved digest algorithms // from RFC 4572 (FIPS 180). -bool IsFips180DigestAlgorithm(const std::string& alg); +bool IsFips180DigestAlgorithm(absl::string_view alg); // Functions to create hashes. @@ -63,25 +65,25 @@ size_t ComputeDigest(MessageDigest* digest, // Like the previous function, but creates a digest implementation based on // the desired digest name `alg`, e.g. DIGEST_SHA_1. Returns 0 if there is no // digest with the given name. -size_t ComputeDigest(const std::string& alg, +size_t ComputeDigest(absl::string_view alg, const void* input, size_t in_len, void* output, size_t out_len); // Computes the hash of `input` using the `digest` hash implementation, and // returns it as a hex-encoded string. -std::string ComputeDigest(MessageDigest* digest, const std::string& input); +std::string ComputeDigest(MessageDigest* digest, absl::string_view input); // Like the previous function, but creates a digest implementation based on // the desired digest name `alg`, e.g. DIGEST_SHA_1. Returns empty string if // there is no digest with the given name. -std::string ComputeDigest(const std::string& alg, const std::string& input); +std::string ComputeDigest(absl::string_view alg, absl::string_view input); // Like the previous function, but returns an explicit result code. -bool ComputeDigest(const std::string& alg, - const std::string& input, +bool ComputeDigest(absl::string_view alg, + absl::string_view input, std::string* output); // Shorthand way to compute a hex-encoded hash using MD5. -inline std::string MD5(const std::string& input) { +inline std::string MD5(absl::string_view input) { return ComputeDigest(DIGEST_MD5, input); } @@ -102,7 +104,7 @@ size_t ComputeHmac(MessageDigest* digest, // Like the previous function, but creates a digest implementation based on // the desired digest name `alg`, e.g. DIGEST_SHA_1. Returns 0 if there is no // digest with the given name. -size_t ComputeHmac(const std::string& alg, +size_t ComputeHmac(absl::string_view alg, const void* key, size_t key_len, const void* input, @@ -112,18 +114,18 @@ size_t ComputeHmac(const std::string& alg, // Computes the HMAC of `input` using the `digest` hash implementation and `key` // to key the HMAC, and returns it as a hex-encoded string. std::string ComputeHmac(MessageDigest* digest, - const std::string& key, - const std::string& input); + absl::string_view key, + absl::string_view input); // Like the previous function, but creates a digest implementation based on // the desired digest name `alg`, e.g. DIGEST_SHA_1. Returns empty string if // there is no digest with the given name. -std::string ComputeHmac(const std::string& alg, - const std::string& key, - const std::string& input); +std::string ComputeHmac(absl::string_view alg, + absl::string_view key, + absl::string_view input); // Like the previous function, but returns an explicit result code. -bool ComputeHmac(const std::string& alg, - const std::string& key, - const std::string& input, +bool ComputeHmac(absl::string_view alg, + absl::string_view key, + absl::string_view input, std::string* output); } // namespace rtc diff --git a/rtc_base/net_helper.cc b/rtc_base/net_helper.cc index 893b500d56..4afee7bfb0 100644 --- a/rtc_base/net_helper.cc +++ b/rtc_base/net_helper.cc @@ -10,6 +10,8 @@ #include "rtc_base/net_helper.h" +#include "absl/strings/string_view.h" + namespace cricket { const char UDP_PROTOCOL_NAME[] = "udp"; @@ -17,7 +19,7 @@ const char TCP_PROTOCOL_NAME[] = "tcp"; const char SSLTCP_PROTOCOL_NAME[] = "ssltcp"; const char TLS_PROTOCOL_NAME[] = "tls"; -int GetProtocolOverhead(const std::string& protocol) { +int GetProtocolOverhead(absl::string_view protocol) { if (protocol == TCP_PROTOCOL_NAME || protocol == SSLTCP_PROTOCOL_NAME) { return kTcpHeaderSize; } else if (protocol == UDP_PROTOCOL_NAME) { diff --git a/rtc_base/net_helper.h b/rtc_base/net_helper.h index 9abbbdefb2..758c0faad9 100644 --- a/rtc_base/net_helper.h +++ b/rtc_base/net_helper.h @@ -12,6 +12,8 @@ #include +#include "absl/strings/string_view.h" + // This header contains helper functions and constants used by different types // of transports. namespace cricket { @@ -25,7 +27,7 @@ constexpr int kTcpHeaderSize = 20; constexpr int kUdpHeaderSize = 8; // Get the transport layer overhead per packet based on the protocol. -int GetProtocolOverhead(const std::string& protocol); +int GetProtocolOverhead(absl::string_view protocol); } // namespace cricket diff --git a/rtc_base/network.cc b/rtc_base/network.cc index 295d39c5d9..52026308b7 100644 --- a/rtc_base/network.cc +++ b/rtc_base/network.cc @@ -10,6 +10,8 @@ #include "rtc_base/network.h" +#include "absl/strings/string_view.h" + #if defined(WEBRTC_POSIX) #include #endif // WEBRTC_POSIX @@ -190,7 +192,7 @@ const char kPublicIPv4Host[] = "8.8.8.8"; const char kPublicIPv6Host[] = "2001:4860:4860::8888"; const int kPublicPort = 53; // DNS port. -std::string MakeNetworkKey(const std::string& name, +std::string MakeNetworkKey(absl::string_view name, const IPAddress& prefix, int prefix_length) { rtc::StringBuilder ost; @@ -1055,8 +1057,8 @@ NetworkBindingResult BasicNetworkManager::BindSocketToNetwork( return network_monitor_->BindSocketToNetwork(socket_fd, address, if_name); } -Network::Network(const std::string& name, - const std::string& desc, +Network::Network(absl::string_view name, + absl::string_view desc, const IPAddress& prefix, int prefix_length) : name_(name), @@ -1073,8 +1075,8 @@ Network::Network(const std::string& name, add_network_cost_to_vpn_( webrtc::field_trial::IsEnabled("WebRTC-AddNetworkCostToVpn")) {} -Network::Network(const std::string& name, - const std::string& desc, +Network::Network(absl::string_view name, + absl::string_view desc, const IPAddress& prefix, int prefix_length, AdapterType type) diff --git a/rtc_base/network.h b/rtc_base/network.h index 83a2f7d272..bf14bef0e4 100644 --- a/rtc_base/network.h +++ b/rtc_base/network.h @@ -19,6 +19,7 @@ #include #include +#include "absl/strings/string_view.h" #include "api/array_view.h" #include "api/sequence_checker.h" #include "rtc_base/ip_address.h" @@ -51,7 +52,7 @@ const int kDefaultNetworkIgnoreMask = ADAPTER_TYPE_LOOPBACK; // Makes a string key for this network. Used in the network manager's maps. // Network objects are keyed on interface name, network prefix and the // length of that prefix. -std::string MakeNetworkKey(const std::string& name, +std::string MakeNetworkKey(absl::string_view name, const IPAddress& prefix, int prefix_length); @@ -350,13 +351,13 @@ class RTC_EXPORT BasicNetworkManager : public NetworkManagerBase, // Represents a Unix-type network interface, with a name and single address. class RTC_EXPORT Network { public: - Network(const std::string& name, - const std::string& description, + Network(absl::string_view name, + absl::string_view description, const IPAddress& prefix, int prefix_length); - Network(const std::string& name, - const std::string& description, + Network(absl::string_view name, + absl::string_view description, const IPAddress& prefix, int prefix_length, AdapterType type); diff --git a/rtc_base/network_monitor.h b/rtc_base/network_monitor.h index c0eea1ff52..72571d1497 100644 --- a/rtc_base/network_monitor.h +++ b/rtc_base/network_monitor.h @@ -14,6 +14,7 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/network_constants.h" namespace rtc { @@ -78,12 +79,12 @@ class NetworkMonitorInterface { virtual void Start() = 0; virtual void Stop() = 0; - virtual AdapterType GetAdapterType(const std::string& interface_name) = 0; + virtual AdapterType GetAdapterType(absl::string_view interface_name) = 0; virtual AdapterType GetVpnUnderlyingAdapterType( - const std::string& interface_name) = 0; + absl::string_view interface_name) = 0; virtual NetworkPreference GetNetworkPreference( - const std::string& interface_name) = 0; + absl::string_view interface_name) = 0; // Does `this` NetworkMonitorInterface implement BindSocketToNetwork? // Only Android returns true. @@ -94,7 +95,7 @@ class NetworkMonitorInterface { virtual NetworkBindingResult BindSocketToNetwork( int socket_fd, const IPAddress& address, - const std::string& interface_name) { + absl::string_view interface_name) { return NetworkBindingResult::NOT_IMPLEMENTED; } @@ -107,7 +108,7 @@ class NetworkMonitorInterface { // These specific use case this was added for was a phone with two SIM cards, // where attempting to use all interfaces returned from getifaddrs caused the // connection to be dropped. - virtual bool IsAdapterAvailable(const std::string& interface_name) { + virtual bool IsAdapterAvailable(absl::string_view interface_name) { return true; } diff --git a/rtc_base/network_unittest.cc b/rtc_base/network_unittest.cc index 5635f5d868..e622ca334a 100644 --- a/rtc_base/network_unittest.cc +++ b/rtc_base/network_unittest.cc @@ -18,6 +18,7 @@ #include "absl/algorithm/container.h" #include "absl/strings/match.h" +#include "absl/strings/string_view.h" #include "rtc_base/checks.h" #include "rtc_base/net_helpers.h" #include "rtc_base/network_monitor.h" @@ -45,7 +46,7 @@ namespace rtc { namespace { -IPAddress IPFromString(const std::string& str) { +IPAddress IPFromString(absl::string_view str) { IPAddress ip; RTC_CHECK(IPFromString(str, &ip)); return ip; @@ -56,7 +57,7 @@ class FakeNetworkMonitor : public NetworkMonitorInterface { void Start() override { started_ = true; } void Stop() override { started_ = false; } bool started() { return started_; } - AdapterType GetAdapterType(const std::string& if_name) override { + AdapterType GetAdapterType(absl::string_view if_name) override { // Note that the name matching rules are different from the // GetAdapterTypeFromName in NetworkManager. if (absl::StartsWith(if_name, "wifi")) { @@ -67,14 +68,14 @@ class FakeNetworkMonitor : public NetworkMonitorInterface { } return ADAPTER_TYPE_UNKNOWN; } - AdapterType GetVpnUnderlyingAdapterType(const std::string& if_name) override { + AdapterType GetVpnUnderlyingAdapterType(absl::string_view if_name) override { return ADAPTER_TYPE_UNKNOWN; } - NetworkPreference GetNetworkPreference(const std::string& if_name) override { + NetworkPreference GetNetworkPreference(absl::string_view if_name) override { return NetworkPreference::NEUTRAL; } - bool IsAdapterAvailable(const std::string& if_name) override { + bool IsAdapterAvailable(absl::string_view if_name) override { return absl::c_count(unavailable_adapters_, if_name) == 0; } @@ -85,16 +86,15 @@ class FakeNetworkMonitor : public NetworkMonitorInterface { bool SupportsBindSocketToNetwork() const override { return true; } - NetworkBindingResult BindSocketToNetwork( - int socket_fd, - const IPAddress& address, - const std::string& if_name) override { + NetworkBindingResult BindSocketToNetwork(int socket_fd, + const IPAddress& address, + absl::string_view if_name) override { if (absl::c_count(addresses_, address) > 0) { return NetworkBindingResult::SUCCESS; } for (auto const& iter : adapters_) { - if (if_name.find(iter) != std::string::npos) { + if (if_name.find(iter) != absl::string_view::npos) { return NetworkBindingResult::SUCCESS; } } @@ -209,7 +209,7 @@ class NetworkTest : public ::testing::Test, public sigslot::has_slots<> { include_ignored, networks); } - struct sockaddr_in6* CreateIpv6Addr(const std::string& ip_string, + struct sockaddr_in6* CreateIpv6Addr(absl::string_view ip_string, uint32_t scope_id) { struct sockaddr_in6* ipv6_addr = static_cast(malloc(sizeof(struct sockaddr_in6))); @@ -225,8 +225,8 @@ class NetworkTest : public ::testing::Test, public sigslot::has_slots<> { // Pointers created here need to be released via ReleaseIfAddrs. struct ifaddrs* AddIpv6Address(struct ifaddrs* list, char* if_name, - const std::string& ipv6_address, - const std::string& ipv6_netmask, + absl::string_view ipv6_address, + absl::string_view ipv6_netmask, uint32_t scope_id) { struct ifaddrs* if_addr = new struct ifaddrs; memset(if_addr, 0, sizeof(struct ifaddrs)); @@ -241,8 +241,8 @@ class NetworkTest : public ::testing::Test, public sigslot::has_slots<> { } struct ifaddrs* InstallIpv6Network(char* if_name, - const std::string& ipv6_address, - const std::string& ipv6_mask, + absl::string_view ipv6_address, + absl::string_view ipv6_mask, BasicNetworkManager& network_manager) { ifaddrs* addr_list = nullptr; addr_list = AddIpv6Address(addr_list, if_name, ipv6_address, ipv6_mask, 0); @@ -254,7 +254,7 @@ class NetworkTest : public ::testing::Test, public sigslot::has_slots<> { return addr_list; } - struct sockaddr_in* CreateIpv4Addr(const std::string& ip_string) { + struct sockaddr_in* CreateIpv4Addr(absl::string_view ip_string) { struct sockaddr_in* ipv4_addr = static_cast(malloc(sizeof(struct sockaddr_in))); memset(ipv4_addr, 0, sizeof(struct sockaddr_in)); @@ -268,8 +268,8 @@ class NetworkTest : public ::testing::Test, public sigslot::has_slots<> { // Pointers created here need to be released via ReleaseIfAddrs. struct ifaddrs* AddIpv4Address(struct ifaddrs* list, char* if_name, - const std::string& ipv4_address, - const std::string& ipv4_netmask) { + absl::string_view ipv4_address, + absl::string_view ipv4_netmask) { struct ifaddrs* if_addr = new struct ifaddrs; memset(if_addr, 0, sizeof(struct ifaddrs)); if_addr->ifa_name = if_name; @@ -283,8 +283,8 @@ class NetworkTest : public ::testing::Test, public sigslot::has_slots<> { } struct ifaddrs* InstallIpv4Network(char* if_name, - const std::string& ipv4_address, - const std::string& ipv4_mask, + absl::string_view ipv4_address, + absl::string_view ipv4_mask, BasicNetworkManager& network_manager) { ifaddrs* addr_list = nullptr; addr_list = AddIpv4Address(addr_list, if_name, ipv4_address, ipv4_mask); diff --git a/rtc_base/openssl_adapter.cc b/rtc_base/openssl_adapter.cc index bc10e619eb..dc9aefaa8e 100644 --- a/rtc_base/openssl_adapter.cc +++ b/rtc_base/openssl_adapter.cc @@ -13,6 +13,8 @@ #include #include #include + +#include "absl/strings/string_view.h" #ifdef OPENSSL_IS_BORINGSSL #include #endif @@ -744,7 +746,7 @@ void OpenSSLAdapter::OnCloseEvent(Socket* socket, int err) { AsyncSocketAdapter::OnCloseEvent(socket, err); } -bool OpenSSLAdapter::SSLPostConnectionCheck(SSL* ssl, const std::string& host) { +bool OpenSSLAdapter::SSLPostConnectionCheck(SSL* ssl, absl::string_view host) { bool is_valid_cert_name = openssl::VerifyPeerCertMatchesHost(ssl, host) && (SSL_get_verify_result(ssl) == X509_V_OK || custom_cert_verifier_status_); diff --git a/rtc_base/openssl_adapter.h b/rtc_base/openssl_adapter.h index 7e1f87b8ab..942d1fef12 100644 --- a/rtc_base/openssl_adapter.h +++ b/rtc_base/openssl_adapter.h @@ -19,6 +19,7 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/buffer.h" #include "rtc_base/message_handler.h" #ifdef OPENSSL_IS_BORINGSSL @@ -116,7 +117,7 @@ class OpenSSLAdapter final : public SSLAdapter, // an output parameter filled with the result of SSL_get_error. int DoSslWrite(const void* pv, size_t cb, int* error); void OnMessage(Message* msg) override; - bool SSLPostConnectionCheck(SSL* ssl, const std::string& host); + bool SSLPostConnectionCheck(SSL* ssl, absl::string_view host); #if !defined(NDEBUG) // In debug builds, logs info about the state of the SSL connection. diff --git a/rtc_base/openssl_digest.cc b/rtc_base/openssl_digest.cc index 1cf5bc09b4..bbf39570f6 100644 --- a/rtc_base/openssl_digest.cc +++ b/rtc_base/openssl_digest.cc @@ -10,12 +10,13 @@ #include "rtc_base/openssl_digest.h" +#include "absl/strings/string_view.h" #include "rtc_base/checks.h" // RTC_DCHECK, RTC_CHECK #include "rtc_base/openssl.h" namespace rtc { -OpenSSLDigest::OpenSSLDigest(const std::string& algorithm) { +OpenSSLDigest::OpenSSLDigest(absl::string_view algorithm) { ctx_ = EVP_MD_CTX_new(); RTC_CHECK(ctx_ != nullptr); EVP_MD_CTX_init(ctx_); @@ -55,7 +56,7 @@ size_t OpenSSLDigest::Finish(void* buf, size_t len) { return md_len; } -bool OpenSSLDigest::GetDigestEVP(const std::string& algorithm, +bool OpenSSLDigest::GetDigestEVP(absl::string_view algorithm, const EVP_MD** mdp) { const EVP_MD* md; if (algorithm == DIGEST_MD5) { @@ -105,8 +106,7 @@ bool OpenSSLDigest::GetDigestName(const EVP_MD* md, std::string* algorithm) { return true; } -bool OpenSSLDigest::GetDigestSize(const std::string& algorithm, - size_t* length) { +bool OpenSSLDigest::GetDigestSize(absl::string_view algorithm, size_t* length) { const EVP_MD* md; if (!GetDigestEVP(algorithm, &md)) return false; diff --git a/rtc_base/openssl_digest.h b/rtc_base/openssl_digest.h index 6da01a0ded..c6cc3bb86d 100644 --- a/rtc_base/openssl_digest.h +++ b/rtc_base/openssl_digest.h @@ -16,6 +16,7 @@ #include +#include "absl/strings/string_view.h" #include "rtc_base/message_digest.h" namespace rtc { @@ -24,7 +25,7 @@ namespace rtc { class OpenSSLDigest final : public MessageDigest { public: // Creates an OpenSSLDigest with `algorithm` as the hash algorithm. - explicit OpenSSLDigest(const std::string& algorithm); + explicit OpenSSLDigest(absl::string_view algorithm); ~OpenSSLDigest() override; // Returns the digest output size (e.g. 16 bytes for MD5). size_t Size() const override; @@ -34,11 +35,11 @@ class OpenSSLDigest final : public MessageDigest { size_t Finish(void* buf, size_t len) override; // Helper function to look up a digest's EVP by name. - static bool GetDigestEVP(const std::string& algorithm, const EVP_MD** md); + static bool GetDigestEVP(absl::string_view algorithm, const EVP_MD** md); // Helper function to look up a digest's name by EVP. static bool GetDigestName(const EVP_MD* md, std::string* algorithm); // Helper function to get the length of a digest. - static bool GetDigestSize(const std::string& algorithm, size_t* len); + static bool GetDigestSize(absl::string_view algorithm, size_t* len); private: EVP_MD_CTX* ctx_ = nullptr; diff --git a/rtc_base/openssl_key_pair.cc b/rtc_base/openssl_key_pair.cc index 6ac546e9bb..4c474f2d54 100644 --- a/rtc_base/openssl_key_pair.cc +++ b/rtc_base/openssl_key_pair.cc @@ -13,6 +13,8 @@ #include #include +#include "absl/strings/string_view.h" + #if defined(WEBRTC_WIN) // Must be included first before openssl headers. #include "rtc_base/win32.h" // NOLINT @@ -103,7 +105,7 @@ std::unique_ptr OpenSSLKeyPair::Generate( } std::unique_ptr OpenSSLKeyPair::FromPrivateKeyPEMString( - const std::string& pem_string) { + absl::string_view pem_string) { BIO* bio = BIO_new_mem_buf(const_cast(pem_string.data()), pem_string.size()); if (!bio) { diff --git a/rtc_base/openssl_key_pair.h b/rtc_base/openssl_key_pair.h index d9a4939a7e..d09bdb0d5e 100644 --- a/rtc_base/openssl_key_pair.h +++ b/rtc_base/openssl_key_pair.h @@ -16,6 +16,7 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/checks.h" #include "rtc_base/ssl_identity.h" @@ -34,7 +35,7 @@ class OpenSSLKeyPair final { // Constructs a key pair from the private key PEM string. This must not result // in missing public key parameters. Returns null on error. static std::unique_ptr FromPrivateKeyPEMString( - const std::string& pem_string); + absl::string_view pem_string); ~OpenSSLKeyPair(); diff --git a/rtc_base/openssl_session_cache.cc b/rtc_base/openssl_session_cache.cc index f8fcd473dc..d63724242a 100644 --- a/rtc_base/openssl_session_cache.cc +++ b/rtc_base/openssl_session_cache.cc @@ -10,6 +10,7 @@ #include "rtc_base/openssl_session_cache.h" +#include "absl/strings/string_view.h" #include "rtc_base/checks.h" #include "rtc_base/openssl.h" @@ -30,16 +31,16 @@ OpenSSLSessionCache::~OpenSSLSessionCache() { } SSL_SESSION* OpenSSLSessionCache::LookupSession( - const std::string& hostname) const { + absl::string_view hostname) const { auto it = sessions_.find(hostname); return (it != sessions_.end()) ? it->second : nullptr; } -void OpenSSLSessionCache::AddSession(const std::string& hostname, +void OpenSSLSessionCache::AddSession(absl::string_view hostname, SSL_SESSION* new_session) { SSL_SESSION* old_session = LookupSession(hostname); SSL_SESSION_free(old_session); - sessions_[hostname] = new_session; + sessions_.insert_or_assign(std::string(hostname), new_session); } SSL_CTX* OpenSSLSessionCache::GetSSLContext() const { diff --git a/rtc_base/openssl_session_cache.h b/rtc_base/openssl_session_cache.h index b801ec7b0b..75d8d9a0cf 100644 --- a/rtc_base/openssl_session_cache.h +++ b/rtc_base/openssl_session_cache.h @@ -16,7 +16,9 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/ssl_stream_adapter.h" +#include "rtc_base/string_utils.h" #ifndef OPENSSL_IS_BORINGSSL typedef struct ssl_session_st SSL_SESSION; @@ -40,10 +42,10 @@ class OpenSSLSessionCache final { OpenSSLSessionCache& operator=(const OpenSSLSessionCache&) = delete; // Looks up a session by hostname. The returned SSL_SESSION is not up_refed. - SSL_SESSION* LookupSession(const std::string& hostname) const; + SSL_SESSION* LookupSession(absl::string_view hostname) const; // Adds a session to the cache, and up_refs it. Any existing session with the // same hostname is replaced. - void AddSession(const std::string& hostname, SSL_SESSION* session); + void AddSession(absl::string_view hostname, SSL_SESSION* session); // Returns the true underlying SSL Context that holds these cached sessions. SSL_CTX* GetSSLContext() const; // The SSL Mode tht the OpenSSLSessionCache was constructed with. This cannot @@ -61,7 +63,7 @@ class OpenSSLSessionCache final { // Map of hostnames to SSL_SESSIONs; holds references to the SSL_SESSIONs, // which are cleaned up when the factory is destroyed. // TODO(juberti): Add LRU eviction to keep the cache from growing forever. - std::map sessions_; + std::map sessions_; // The cache should never be copied or assigned directly. }; diff --git a/rtc_base/openssl_stream_adapter.cc b/rtc_base/openssl_stream_adapter.cc index dd82e4f061..90870cd9cc 100644 --- a/rtc_base/openssl_stream_adapter.cc +++ b/rtc_base/openssl_stream_adapter.cc @@ -16,6 +16,8 @@ #include #include #include + +#include "absl/strings/string_view.h" #ifndef OPENSSL_IS_BORINGSSL #include #include @@ -327,7 +329,7 @@ void OpenSSLStreamAdapter::SetServerRole(SSLRole role) { } bool OpenSSLStreamAdapter::SetPeerCertificateDigest( - const std::string& digest_alg, + absl::string_view digest_alg, const unsigned char* digest_val, size_t digest_len, SSLPeerCertificateDigestError* error) { @@ -353,7 +355,7 @@ bool OpenSSLStreamAdapter::SetPeerCertificateDigest( } peer_certificate_digest_value_.SetData(digest_val, digest_len); - peer_certificate_digest_algorithm_ = digest_alg; + peer_certificate_digest_algorithm_ = std::string(digest_alg); if (!peer_cert_chain_) { // Normal case, where the digest is set before we obtain the certificate @@ -445,15 +447,15 @@ bool OpenSSLStreamAdapter::GetSslVersionBytes(int* version) const { } // Key Extractor interface -bool OpenSSLStreamAdapter::ExportKeyingMaterial(const std::string& label, +bool OpenSSLStreamAdapter::ExportKeyingMaterial(absl::string_view label, const uint8_t* context, size_t context_len, bool use_context, uint8_t* result, size_t result_len) { - if (SSL_export_keying_material(ssl_, result, result_len, label.c_str(), - label.length(), const_cast(context), - context_len, use_context) != 1) { + if (SSL_export_keying_material(ssl_, result, result_len, label.data(), + label.length(), context, context_len, + use_context) != 1) { return false; } return true; @@ -1263,7 +1265,7 @@ bool OpenSSLStreamAdapter::IsAcceptableCipher(int cipher, KeyType key_type) { return false; } -bool OpenSSLStreamAdapter::IsAcceptableCipher(const std::string& cipher, +bool OpenSSLStreamAdapter::IsAcceptableCipher(absl::string_view cipher, KeyType key_type) { if (key_type == KT_RSA) { for (const cipher_list& c : OK_RSA_ciphers) { diff --git a/rtc_base/openssl_stream_adapter.h b/rtc_base/openssl_stream_adapter.h index 236bdfdfea..de20ba93ce 100644 --- a/rtc_base/openssl_stream_adapter.h +++ b/rtc_base/openssl_stream_adapter.h @@ -19,6 +19,7 @@ #include #include +#include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "rtc_base/buffer.h" #ifdef OPENSSL_IS_BORINGSSL @@ -80,7 +81,7 @@ class OpenSSLStreamAdapter final : public SSLStreamAdapter { // Default argument is for compatibility void SetServerRole(SSLRole role = SSL_SERVER) override; bool SetPeerCertificateDigest( - const std::string& digest_alg, + absl::string_view digest_alg, const unsigned char* digest_val, size_t digest_len, SSLPeerCertificateDigestError* error = nullptr) override; @@ -113,7 +114,7 @@ class OpenSSLStreamAdapter final : public SSLStreamAdapter { SSLProtocolVersion GetSslVersion() const override; bool GetSslVersionBytes(int* version) const override; // Key Extractor interface - bool ExportKeyingMaterial(const std::string& label, + bool ExportKeyingMaterial(absl::string_view label, const uint8_t* context, size_t context_len, bool use_context, @@ -130,7 +131,7 @@ class OpenSSLStreamAdapter final : public SSLStreamAdapter { static bool IsBoringSsl(); static bool IsAcceptableCipher(int cipher, KeyType key_type); - static bool IsAcceptableCipher(const std::string& cipher, KeyType key_type); + static bool IsAcceptableCipher(absl::string_view cipher, KeyType key_type); // Use our timeutils.h source of timing in BoringSSL, allowing us to test // using a fake clock. diff --git a/rtc_base/openssl_utility.cc b/rtc_base/openssl_utility.cc index b5d649ca51..eba3788a94 100644 --- a/rtc_base/openssl_utility.cc +++ b/rtc_base/openssl_utility.cc @@ -9,6 +9,8 @@ */ #include "rtc_base/openssl_utility.h" + +#include "absl/strings/string_view.h" #if defined(WEBRTC_WIN) // Must be included first before openssl headers. #include "rtc_base/win32.h" // NOLINT @@ -184,7 +186,7 @@ bool ParseCertificate(CRYPTO_BUFFER* cert_buffer, } #endif // OPENSSL_IS_BORINGSSL -bool VerifyPeerCertMatchesHost(SSL* ssl, const std::string& host) { +bool VerifyPeerCertMatchesHost(SSL* ssl, absl::string_view host) { if (host.empty()) { RTC_DLOG(LS_ERROR) << "Hostname is empty. Cannot verify peer certificate."; return false; @@ -211,8 +213,7 @@ bool VerifyPeerCertMatchesHost(SSL* ssl, const std::string& host) { return false; } LogCertificates(ssl, x509.get()); - return X509_check_host(x509.get(), host.c_str(), host.size(), 0, nullptr) == - 1; + return X509_check_host(x509.get(), host.data(), host.size(), 0, nullptr) == 1; #else // OPENSSL_IS_BORINGSSL X509* certificate = SSL_get_peer_certificate(ssl); if (certificate == nullptr) { @@ -224,13 +225,13 @@ bool VerifyPeerCertMatchesHost(SSL* ssl, const std::string& host) { LogCertificates(ssl, certificate); bool is_valid_cert_name = - X509_check_host(certificate, host.c_str(), host.size(), 0, nullptr) == 1; + X509_check_host(certificate, host.data(), host.size(), 0, nullptr) == 1; X509_free(certificate); return is_valid_cert_name; #endif // !defined(OPENSSL_IS_BORINGSSL) } -void LogSSLErrors(const std::string& prefix) { +void LogSSLErrors(absl::string_view prefix) { char error_buf[200]; unsigned long err; // NOLINT diff --git a/rtc_base/openssl_utility.h b/rtc_base/openssl_utility.h index ee29ccd602..dd183c283a 100644 --- a/rtc_base/openssl_utility.h +++ b/rtc_base/openssl_utility.h @@ -15,6 +15,8 @@ #include +#include "absl/strings/string_view.h" + namespace rtc { // The openssl namespace holds static helper methods. All methods related // to OpenSSL that are commonly used and don't require global state should be @@ -35,11 +37,11 @@ bool ParseCertificate(CRYPTO_BUFFER* cert_buffer, // TODO(crbug.com/webrtc/11710): When OS certificate verification is available, // skip compiling this as it adds a dependency on OpenSSL X509 objects, which we // are trying to avoid in favor of CRYPTO_BUFFERs (see crbug.com/webrtc/11410). -bool VerifyPeerCertMatchesHost(SSL* ssl, const std::string& host); +bool VerifyPeerCertMatchesHost(SSL* ssl, absl::string_view host); // Logs all the errors in the OpenSSL errror queue from the current thread. A // prefix can be provided for context. -void LogSSLErrors(const std::string& prefix); +void LogSSLErrors(absl::string_view prefix); #ifndef WEBRTC_EXCLUDE_BUILT_IN_SSL_ROOT_CERTS // Attempt to add the certificates from the loader into the SSL_CTX. False is diff --git a/rtc_base/ref_counted_object_unittest.cc b/rtc_base/ref_counted_object_unittest.cc index 6b794e63f9..ab051d4f8a 100644 --- a/rtc_base/ref_counted_object_unittest.cc +++ b/rtc_base/ref_counted_object_unittest.cc @@ -15,6 +15,7 @@ #include #include +#include "absl/strings/string_view.h" #include "api/scoped_refptr.h" #include "rtc_base/ref_count.h" #include "test/gtest.h" @@ -52,7 +53,7 @@ class RefClassWithRvalue : public RefCountInterface { class RefClassWithMixedValues : public RefCountInterface { public: - RefClassWithMixedValues(std::unique_ptr a, int b, const std::string& c) + RefClassWithMixedValues(std::unique_ptr a, int b, absl::string_view c) : a_(std::move(a)), b_(b), c_(c) {} protected: diff --git a/rtc_base/rtc_certificate.h b/rtc_base/rtc_certificate.h index 0102c4f98c..67c5c29a89 100644 --- a/rtc_base/rtc_certificate.h +++ b/rtc_base/rtc_certificate.h @@ -17,6 +17,7 @@ #include #include "absl/base/attributes.h" +#include "absl/strings/string_view.h" #include "api/ref_counted_base.h" #include "api/scoped_refptr.h" #include "rtc_base/system/rtc_export.h" @@ -35,8 +36,8 @@ class SSLIdentity; // the string representations used by OpenSSL. class RTCCertificatePEM { public: - RTCCertificatePEM(const std::string& private_key, - const std::string& certificate) + RTCCertificatePEM(absl::string_view private_key, + absl::string_view certificate) : private_key_(private_key), certificate_(certificate) {} const std::string& private_key() const { return private_key_; } diff --git a/rtc_base/socket_adapters.cc b/rtc_base/socket_adapters.cc index 0bd6efad3e..bc7d2d85a9 100644 --- a/rtc_base/socket_adapters.cc +++ b/rtc_base/socket_adapters.cc @@ -12,15 +12,17 @@ #pragma warning(disable : 4786) #endif +#include "rtc_base/socket_adapters.h" + #include #include "absl/strings/match.h" +#include "absl/strings/string_view.h" #include "rtc_base/buffer.h" #include "rtc_base/byte_buffer.h" #include "rtc_base/checks.h" #include "rtc_base/http_common.h" #include "rtc_base/logging.h" -#include "rtc_base/socket_adapters.h" #include "rtc_base/strings/string_builder.h" #include "rtc_base/zero_memory.h" @@ -217,9 +219,9 @@ void AsyncSSLSocket::ProcessInput(char* data, size_t* len) { /////////////////////////////////////////////////////////////////////////////// AsyncHttpsProxySocket::AsyncHttpsProxySocket(Socket* socket, - const std::string& user_agent, + absl::string_view user_agent, const SocketAddress& proxy, - const std::string& username, + absl::string_view username, const CryptString& password) : BufferedReadAdapter(socket, 1024), proxy_(proxy), @@ -470,7 +472,7 @@ void AsyncHttpsProxySocket::Error(int error) { AsyncSocksProxySocket::AsyncSocksProxySocket(Socket* socket, const SocketAddress& proxy, - const std::string& username, + absl::string_view username, const CryptString& password) : BufferedReadAdapter(socket, 1024), state_(SS_ERROR), diff --git a/rtc_base/socket_adapters.h b/rtc_base/socket_adapters.h index 55f62115d3..e78ee18a27 100644 --- a/rtc_base/socket_adapters.h +++ b/rtc_base/socket_adapters.h @@ -13,6 +13,7 @@ #include +#include "absl/strings/string_view.h" #include "api/array_view.h" #include "rtc_base/async_socket.h" #include "rtc_base/crypt_string.h" @@ -82,9 +83,9 @@ class AsyncSSLSocket : public BufferedReadAdapter { class AsyncHttpsProxySocket : public BufferedReadAdapter { public: AsyncHttpsProxySocket(Socket* socket, - const std::string& user_agent, + absl::string_view user_agent, const SocketAddress& proxy, - const std::string& username, + absl::string_view username, const CryptString& password); ~AsyncHttpsProxySocket() override; @@ -143,7 +144,7 @@ class AsyncSocksProxySocket : public BufferedReadAdapter { public: AsyncSocksProxySocket(Socket* socket, const SocketAddress& proxy, - const std::string& username, + absl::string_view username, const CryptString& password); ~AsyncSocksProxySocket() override; diff --git a/rtc_base/socket_address.cc b/rtc_base/socket_address.cc index 2996ede9d2..93d6860a70 100644 --- a/rtc_base/socket_address.cc +++ b/rtc_base/socket_address.cc @@ -10,6 +10,7 @@ #include "rtc_base/socket_address.h" +#include "absl/strings/string_view.h" #include "rtc_base/numerics/safe_conversions.h" #if defined(WEBRTC_POSIX) @@ -43,7 +44,7 @@ SocketAddress::SocketAddress() { Clear(); } -SocketAddress::SocketAddress(const std::string& hostname, int port) { +SocketAddress::SocketAddress(absl::string_view hostname, int port) { SetIP(hostname); SetPort(port); } @@ -101,8 +102,8 @@ void SocketAddress::SetIP(const IPAddress& ip) { scope_id_ = 0; } -void SocketAddress::SetIP(const std::string& hostname) { - hostname_ = hostname; +void SocketAddress::SetIP(absl::string_view hostname) { + hostname_ = std::string(hostname); literal_ = IPFromString(hostname, &ip_); if (!literal_) { ip_ = IPAddress(); @@ -188,23 +189,24 @@ std::string SocketAddress::ToResolvedSensitiveString() const { return sb.str(); } -bool SocketAddress::FromString(const std::string& str) { +bool SocketAddress::FromString(absl::string_view str) { if (str.at(0) == '[') { - std::string::size_type closebracket = str.rfind(']'); - if (closebracket != std::string::npos) { - std::string::size_type colon = str.find(':', closebracket); - if (colon != std::string::npos && colon > closebracket) { - SetPort(strtoul(str.substr(colon + 1).c_str(), nullptr, 10)); + absl::string_view::size_type closebracket = str.rfind(']'); + if (closebracket != absl::string_view::npos) { + absl::string_view::size_type colon = str.find(':', closebracket); + if (colon != absl::string_view::npos && colon > closebracket) { + SetPort( + strtoul(std::string(str.substr(colon + 1)).c_str(), nullptr, 10)); SetIP(str.substr(1, closebracket - 1)); } else { return false; } } } else { - std::string::size_type pos = str.find(':'); - if (std::string::npos == pos) + absl::string_view::size_type pos = str.find(':'); + if (absl::string_view::npos == pos) return false; - SetPort(strtoul(str.substr(pos + 1).c_str(), nullptr, 10)); + SetPort(strtoul(std::string(str.substr(pos + 1)).c_str(), nullptr, 10)); SetIP(str.substr(0, pos)); } return true; diff --git a/rtc_base/socket_address.h b/rtc_base/socket_address.h index 570a71281e..99e14d8eab 100644 --- a/rtc_base/socket_address.h +++ b/rtc_base/socket_address.h @@ -12,6 +12,8 @@ #define RTC_BASE_SOCKET_ADDRESS_H_ #include + +#include "absl/strings/string_view.h" #ifdef WEBRTC_UNIT_TEST #include // no-presubmit-check TODO(webrtc:8982) #endif // WEBRTC_UNIT_TEST @@ -34,7 +36,7 @@ class RTC_EXPORT SocketAddress { // Creates the address with the given host and port. Host may be a // literal IP string or a hostname to be resolved later. // DCHECKs that port is in valid range (0 to 2^16-1). - SocketAddress(const std::string& hostname, int port); + SocketAddress(absl::string_view hostname, int port); // Creates the address with the given IP and port. // IP is given as an integer in host byte order. V4 only, to be deprecated. @@ -69,7 +71,7 @@ class RTC_EXPORT SocketAddress { // Changes the hostname of this address to the given one. // Does not resolve the address; use Resolve to do so. - void SetIP(const std::string& hostname); + void SetIP(absl::string_view hostname); // Sets the IP address while retaining the hostname. Useful for bypassing // DNS for a pre-resolved IP. @@ -129,7 +131,7 @@ class RTC_EXPORT SocketAddress { std::string ToResolvedSensitiveString() const; // Parses hostname:port and [hostname]:port. - bool FromString(const std::string& str); + bool FromString(absl::string_view str); #ifdef WEBRTC_UNIT_TEST inline std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982) diff --git a/rtc_base/socket_unittest.cc b/rtc_base/socket_unittest.cc index 01a2bed26d..0b9c2f2c58 100644 --- a/rtc_base/socket_unittest.cc +++ b/rtc_base/socket_unittest.cc @@ -17,6 +17,7 @@ #include #include "absl/memory/memory.h" +#include "absl/strings/string_view.h" #include "rtc_base/arraysize.h" #include "rtc_base/async_packet_socket.h" #include "rtc_base/async_udp_socket.h" @@ -287,7 +288,7 @@ void SocketTest::ConnectInternal(const IPAddress& loopback) { } void SocketTest::ConnectWithDnsLookupInternal(const IPAddress& loopback, - const std::string& host) { + absl::string_view host) { StreamSink sink; SocketAddress accept_addr; diff --git a/rtc_base/socket_unittest.h b/rtc_base/socket_unittest.h index 772df635d7..20ef003a80 100644 --- a/rtc_base/socket_unittest.h +++ b/rtc_base/socket_unittest.h @@ -11,6 +11,7 @@ #ifndef RTC_BASE_SOCKET_UNITTEST_H_ #define RTC_BASE_SOCKET_UNITTEST_H_ +#include "absl/strings/string_view.h" #include "rtc_base/gunit.h" #include "rtc_base/thread.h" @@ -74,7 +75,7 @@ class SocketTest : public ::testing::Test { private: void ConnectInternal(const IPAddress& loopback); void ConnectWithDnsLookupInternal(const IPAddress& loopback, - const std::string& host); + absl::string_view host); void ConnectFailInternal(const IPAddress& loopback); void ConnectWithDnsLookupFailInternal(const IPAddress& loopback); diff --git a/rtc_base/ssl_adapter_unittest.cc b/rtc_base/ssl_adapter_unittest.cc index 2b55211086..430343ecb8 100644 --- a/rtc_base/ssl_adapter_unittest.cc +++ b/rtc_base/ssl_adapter_unittest.cc @@ -8,16 +8,18 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include "rtc_base/ssl_adapter.h" + #include #include #include #include "absl/memory/memory.h" +#include "absl/strings/string_view.h" #include "rtc_base/gunit.h" #include "rtc_base/ip_address.h" #include "rtc_base/message_digest.h" #include "rtc_base/socket_stream.h" -#include "rtc_base/ssl_adapter.h" #include "rtc_base/ssl_identity.h" #include "rtc_base/ssl_stream_adapter.h" #include "rtc_base/stream.h" @@ -99,7 +101,7 @@ class SSLAdapterTestDummyClient : public sigslot::has_slots<> { const std::string& GetReceivedData() const { return data_; } - int Connect(const std::string& hostname, const rtc::SocketAddress& address) { + int Connect(absl::string_view hostname, const rtc::SocketAddress& address) { RTC_LOG(LS_INFO) << "Initiating connection with " << address.ToString(); int rv = ssl_adapter_->Connect(address); @@ -108,7 +110,7 @@ class SSLAdapterTestDummyClient : public sigslot::has_slots<> { RTC_LOG(LS_INFO) << "Starting " << GetSSLProtocolName(ssl_mode_) << " handshake with " << hostname; - if (ssl_adapter_->StartSSL(hostname.c_str()) != 0) { + if (ssl_adapter_->StartSSL(std::string(hostname).c_str()) != 0) { return -1; } } @@ -118,7 +120,7 @@ class SSLAdapterTestDummyClient : public sigslot::has_slots<> { int Close() { return ssl_adapter_->Close(); } - int Send(const std::string& message) { + int Send(absl::string_view message) { RTC_LOG(LS_INFO) << "Client sending '" << message << "'"; return ssl_adapter_->Send(message.data(), message.length()); @@ -189,7 +191,7 @@ class SSLAdapterTestDummyServer : public sigslot::has_slots<> { const std::string& GetReceivedData() const { return data_; } - int Send(const std::string& message) { + int Send(absl::string_view message) { if (ssl_stream_adapter_ == nullptr || ssl_stream_adapter_->GetState() != rtc::SS_OPEN) { // No connection yet. @@ -363,7 +365,7 @@ class SSLAdapterTestBase : public ::testing::Test, public sigslot::has_slots<> { } } - void TestTransfer(const std::string& message) { + void TestTransfer(absl::string_view message) { int rv; rv = client_->Send(message); diff --git a/rtc_base/ssl_certificate.cc b/rtc_base/ssl_certificate.cc index ed42998353..ddb1524f76 100644 --- a/rtc_base/ssl_certificate.cc +++ b/rtc_base/ssl_certificate.cc @@ -15,6 +15,7 @@ #include #include "absl/algorithm/container.h" +#include "absl/strings/string_view.h" #include "rtc_base/checks.h" #include "rtc_base/openssl.h" #ifdef OPENSSL_IS_BORINGSSL @@ -121,7 +122,7 @@ std::unique_ptr SSLCertChain::GetStats() const { // static std::unique_ptr SSLCertificate::FromPEMString( - const std::string& pem_string) { + absl::string_view pem_string) { #ifdef OPENSSL_IS_BORINGSSL return BoringSSLCertificate::FromPEMString(pem_string); #else diff --git a/rtc_base/ssl_certificate.h b/rtc_base/ssl_certificate.h index d0e60ee9cc..77fbba3e9e 100644 --- a/rtc_base/ssl_certificate.h +++ b/rtc_base/ssl_certificate.h @@ -22,6 +22,7 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/buffer.h" #include "rtc_base/system/rtc_export.h" @@ -55,7 +56,7 @@ class RTC_EXPORT SSLCertificate { // stored in *pem_length if it is non-null, and only if // parsing was successful. static std::unique_ptr FromPEMString( - const std::string& pem_string); + absl::string_view pem_string); virtual ~SSLCertificate() = default; // Returns a new SSLCertificate object instance wrapping the same @@ -73,7 +74,7 @@ class RTC_EXPORT SSLCertificate { virtual bool GetSignatureDigestAlgorithm(std::string* algorithm) const = 0; // Compute the digest of the certificate given algorithm - virtual bool ComputeDigest(const std::string& algorithm, + virtual bool ComputeDigest(absl::string_view algorithm, unsigned char* digest, size_t size, size_t* length) const = 0; diff --git a/rtc_base/ssl_fingerprint.cc b/rtc_base/ssl_fingerprint.cc index 358402eb03..a85b7a09ce 100644 --- a/rtc_base/ssl_fingerprint.cc +++ b/rtc_base/ssl_fingerprint.cc @@ -11,11 +11,13 @@ #include "rtc_base/ssl_fingerprint.h" #include + #include #include #include #include "absl/algorithm/container.h" +#include "absl/strings/string_view.h" #include "rtc_base/logging.h" #include "rtc_base/message_digest.h" #include "rtc_base/rtc_certificate.h" @@ -25,19 +27,19 @@ namespace rtc { -SSLFingerprint* SSLFingerprint::Create(const std::string& algorithm, +SSLFingerprint* SSLFingerprint::Create(absl::string_view algorithm, const rtc::SSLIdentity* identity) { return CreateUnique(algorithm, *identity).release(); } std::unique_ptr SSLFingerprint::CreateUnique( - const std::string& algorithm, + absl::string_view algorithm, const rtc::SSLIdentity& identity) { return Create(algorithm, identity.certificate()); } std::unique_ptr SSLFingerprint::Create( - const std::string& algorithm, + absl::string_view algorithm, const rtc::SSLCertificate& cert) { uint8_t digest_val[64]; size_t digest_len; @@ -51,14 +53,14 @@ std::unique_ptr SSLFingerprint::Create( } SSLFingerprint* SSLFingerprint::CreateFromRfc4572( - const std::string& algorithm, - const std::string& fingerprint) { + absl::string_view algorithm, + absl::string_view fingerprint) { return CreateUniqueFromRfc4572(algorithm, fingerprint).release(); } std::unique_ptr SSLFingerprint::CreateUniqueFromRfc4572( - const std::string& algorithm, - const std::string& fingerprint) { + absl::string_view algorithm, + absl::string_view fingerprint) { if (algorithm.empty() || !rtc::IsFips180DigestAlgorithm(algorithm)) return nullptr; @@ -67,7 +69,7 @@ std::unique_ptr SSLFingerprint::CreateUniqueFromRfc4572( char value[rtc::MessageDigest::kMaxSize]; size_t value_len = rtc::hex_decode_with_delimiter( - value, sizeof(value), fingerprint.c_str(), fingerprint.length(), ':'); + value, sizeof(value), fingerprint.data(), fingerprint.length(), ':'); if (!value_len) return nullptr; @@ -94,11 +96,11 @@ std::unique_ptr SSLFingerprint::CreateFromCertificate( return fingerprint; } -SSLFingerprint::SSLFingerprint(const std::string& algorithm, +SSLFingerprint::SSLFingerprint(absl::string_view algorithm, ArrayView digest_view) : algorithm(algorithm), digest(digest_view.data(), digest_view.size()) {} -SSLFingerprint::SSLFingerprint(const std::string& algorithm, +SSLFingerprint::SSLFingerprint(absl::string_view algorithm, const uint8_t* digest_in, size_t digest_len) : SSLFingerprint(algorithm, MakeArrayView(digest_in, digest_len)) {} diff --git a/rtc_base/ssl_fingerprint.h b/rtc_base/ssl_fingerprint.h index add3ab7911..cfa26dd433 100644 --- a/rtc_base/ssl_fingerprint.h +++ b/rtc_base/ssl_fingerprint.h @@ -13,8 +13,10 @@ #include #include + #include +#include "absl/strings/string_view.h" #include "rtc_base/copy_on_write_buffer.h" #include "rtc_base/system/rtc_export.h" @@ -26,34 +28,34 @@ class SSLIdentity; struct RTC_EXPORT SSLFingerprint { // TODO(steveanton): Remove once downstream projects have moved off of this. - static SSLFingerprint* Create(const std::string& algorithm, + static SSLFingerprint* Create(absl::string_view algorithm, const rtc::SSLIdentity* identity); // TODO(steveanton): Rename to Create once projects have migrated. static std::unique_ptr CreateUnique( - const std::string& algorithm, + absl::string_view algorithm, const rtc::SSLIdentity& identity); static std::unique_ptr Create( - const std::string& algorithm, + absl::string_view algorithm, const rtc::SSLCertificate& cert); // TODO(steveanton): Remove once downstream projects have moved off of this. - static SSLFingerprint* CreateFromRfc4572(const std::string& algorithm, - const std::string& fingerprint); + static SSLFingerprint* CreateFromRfc4572(absl::string_view algorithm, + absl::string_view fingerprint); // TODO(steveanton): Rename to CreateFromRfc4572 once projects have migrated. static std::unique_ptr CreateUniqueFromRfc4572( - const std::string& algorithm, - const std::string& fingerprint); + absl::string_view algorithm, + absl::string_view fingerprint); // Creates a fingerprint from a certificate, using the same digest algorithm // as the certificate's signature. static std::unique_ptr CreateFromCertificate( const RTCCertificate& cert); - SSLFingerprint(const std::string& algorithm, + SSLFingerprint(absl::string_view algorithm, ArrayView digest_view); // TODO(steveanton): Remove once downstream projects have moved off of this. - SSLFingerprint(const std::string& algorithm, + SSLFingerprint(absl::string_view algorithm, const uint8_t* digest_in, size_t digest_len); diff --git a/rtc_base/ssl_identity.cc b/rtc_base/ssl_identity.cc index 81cf1d78a3..984979a8a6 100644 --- a/rtc_base/ssl_identity.cc +++ b/rtc_base/ssl_identity.cc @@ -15,6 +15,7 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/checks.h" #ifdef OPENSSL_IS_BORINGSSL #include "rtc_base/boringssl_identity.h" @@ -169,30 +170,32 @@ KeyType IntKeyTypeFamilyToKeyType(int key_type_family) { // SSLIdentity ////////////////////////////////////////////////////////////////////// -bool SSLIdentity::PemToDer(const std::string& pem_type, - const std::string& pem_string, +bool SSLIdentity::PemToDer(absl::string_view pem_type, + absl::string_view pem_string, std::string* der) { // Find the inner body. We need this to fulfill the contract of returning // pem_length. - size_t header = pem_string.find("-----BEGIN " + pem_type + "-----"); - if (header == std::string::npos) { + std::string pem_type_str = std::string(pem_type); + size_t header = pem_string.find("-----BEGIN " + pem_type_str + "-----"); + if (header == absl::string_view::npos) { return false; } size_t body = pem_string.find('\n', header); - if (body == std::string::npos) { + if (body == absl::string_view::npos) { return false; } - size_t trailer = pem_string.find("-----END " + pem_type + "-----"); - if (trailer == std::string::npos) { + size_t trailer = pem_string.find("-----END " + pem_type_str + "-----"); + if (trailer == absl::string_view::npos) { return false; } - std::string inner = pem_string.substr(body + 1, trailer - (body + 1)); + std::string inner = + std::string(pem_string.substr(body + 1, trailer - (body + 1))); *der = Base64::Decode(inner, Base64::DO_PARSE_WHITE | Base64::DO_PAD_ANY | Base64::DO_TERM_BUFFER); return true; } -std::string SSLIdentity::DerToPem(const std::string& pem_type, +std::string SSLIdentity::DerToPem(absl::string_view pem_type, const unsigned char* data, size_t length) { rtc::StringBuilder result; @@ -214,7 +217,7 @@ std::string SSLIdentity::DerToPem(const std::string& pem_type, } // static -std::unique_ptr SSLIdentity::Create(const std::string& common_name, +std::unique_ptr SSLIdentity::Create(absl::string_view common_name, const KeyParams& key_param, time_t certificate_lifetime) { #ifdef OPENSSL_IS_BORINGSSL @@ -227,13 +230,13 @@ std::unique_ptr SSLIdentity::Create(const std::string& common_name, } // static -std::unique_ptr SSLIdentity::Create(const std::string& common_name, +std::unique_ptr SSLIdentity::Create(absl::string_view common_name, const KeyParams& key_param) { return Create(common_name, key_param, kDefaultCertificateLifetimeInSeconds); } // static -std::unique_ptr SSLIdentity::Create(const std::string& common_name, +std::unique_ptr SSLIdentity::Create(absl::string_view common_name, KeyType key_type) { return Create(common_name, KeyParams(key_type), kDefaultCertificateLifetimeInSeconds); @@ -252,8 +255,8 @@ std::unique_ptr SSLIdentity::CreateForTest( // Construct an identity from a private key and a certificate. // static std::unique_ptr SSLIdentity::CreateFromPEMStrings( - const std::string& private_key, - const std::string& certificate) { + absl::string_view private_key, + absl::string_view certificate) { #ifdef OPENSSL_IS_BORINGSSL return BoringSSLIdentity::CreateFromPEMStrings(private_key, certificate); #else @@ -264,8 +267,8 @@ std::unique_ptr SSLIdentity::CreateFromPEMStrings( // Construct an identity from a private key and a certificate chain. // static std::unique_ptr SSLIdentity::CreateFromPEMChainStrings( - const std::string& private_key, - const std::string& certificate_chain) { + absl::string_view private_key, + absl::string_view certificate_chain) { #ifdef OPENSSL_IS_BORINGSSL return BoringSSLIdentity::CreateFromPEMChainStrings(private_key, certificate_chain); diff --git a/rtc_base/ssl_identity.h b/rtc_base/ssl_identity.h index 78d1ec12b7..a0119bb1c4 100644 --- a/rtc_base/ssl_identity.h +++ b/rtc_base/ssl_identity.h @@ -14,10 +14,12 @@ #define RTC_BASE_SSL_IDENTITY_H_ #include + #include #include #include +#include "absl/strings/string_view.h" #include "rtc_base/system/rtc_export.h" namespace rtc { @@ -108,12 +110,12 @@ class RTC_EXPORT SSLIdentity { // should be a non-negative number. // Returns null on failure. // Caller is responsible for freeing the returned object. - static std::unique_ptr Create(const std::string& common_name, + static std::unique_ptr Create(absl::string_view common_name, const KeyParams& key_param, time_t certificate_lifetime); - static std::unique_ptr Create(const std::string& common_name, + static std::unique_ptr Create(absl::string_view common_name, const KeyParams& key_param); - static std::unique_ptr Create(const std::string& common_name, + static std::unique_ptr Create(absl::string_view common_name, KeyType key_type); // Allows fine-grained control over expiration time. @@ -122,13 +124,13 @@ class RTC_EXPORT SSLIdentity { // Construct an identity from a private key and a certificate. static std::unique_ptr CreateFromPEMStrings( - const std::string& private_key, - const std::string& certificate); + absl::string_view private_key, + absl::string_view certificate); // Construct an identity from a private key and a certificate chain. static std::unique_ptr CreateFromPEMChainStrings( - const std::string& private_key, - const std::string& certificate_chain); + absl::string_view private_key, + absl::string_view certificate_chain); virtual ~SSLIdentity() {} @@ -144,10 +146,10 @@ class RTC_EXPORT SSLIdentity { virtual std::string PublicKeyToPEMString() const = 0; // Helpers for parsing converting between PEM and DER format. - static bool PemToDer(const std::string& pem_type, - const std::string& pem_string, + static bool PemToDer(absl::string_view pem_type, + absl::string_view pem_string, std::string* der); - static std::string DerToPem(const std::string& pem_type, + static std::string DerToPem(absl::string_view pem_type, const unsigned char* data, size_t length); diff --git a/rtc_base/ssl_identity_unittest.cc b/rtc_base/ssl_identity_unittest.cc index 53f4a2ad10..1f0278ac71 100644 --- a/rtc_base/ssl_identity_unittest.cc +++ b/rtc_base/ssl_identity_unittest.cc @@ -8,19 +8,22 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include "rtc_base/ssl_identity.h" + #include + #include #include #include #include "absl/strings/str_replace.h" +#include "absl/strings/string_view.h" #include "rtc_base/checks.h" #include "rtc_base/fake_ssl_identity.h" #include "rtc_base/helpers.h" #include "rtc_base/logging.h" #include "rtc_base/message_digest.h" #include "rtc_base/ssl_fingerprint.h" -#include "rtc_base/ssl_identity.h" #include "test/gtest.h" using rtc::SSLIdentity; @@ -236,7 +239,7 @@ class SSLIdentityTest : public ::testing::Test { void TestDigestHelper(DigestType digest, const SSLIdentity* identity, - const std::string& algorithm, + absl::string_view algorithm, size_t expected_len) { DigestType digest1; size_t digest_len; @@ -258,7 +261,7 @@ class SSLIdentityTest : public ::testing::Test { EXPECT_EQ(0, memcmp(digest, digest1, expected_len)); } - void TestDigestForGeneratedCert(const std::string& algorithm, + void TestDigestForGeneratedCert(absl::string_view algorithm, size_t expected_len) { DigestType digest[4]; @@ -281,7 +284,7 @@ class SSLIdentityTest : public ::testing::Test { } } - void TestDigestForFixedCert(const std::string& algorithm, + void TestDigestForFixedCert(absl::string_view algorithm, size_t expected_len, const unsigned char* expected_digest) { bool rv; diff --git a/rtc_base/ssl_stream_adapter.cc b/rtc_base/ssl_stream_adapter.cc index b805fdc6c3..4b60d6d7b1 100644 --- a/rtc_base/ssl_stream_adapter.cc +++ b/rtc_base/ssl_stream_adapter.cc @@ -11,6 +11,7 @@ #include "rtc_base/ssl_stream_adapter.h" #include "absl/memory/memory.h" +#include "absl/strings/string_view.h" #include "rtc_base/openssl_stream_adapter.h" /////////////////////////////////////////////////////////////////////////////// @@ -39,7 +40,7 @@ std::string SrtpCryptoSuiteToName(int crypto_suite) { } } -int SrtpCryptoSuiteFromName(const std::string& crypto_suite) { +int SrtpCryptoSuiteFromName(absl::string_view crypto_suite) { if (crypto_suite == kCsAesCm128HmacSha1_32) return kSrtpAes128CmSha1_32; if (crypto_suite == kCsAesCm128HmacSha1_80) @@ -85,7 +86,7 @@ bool IsGcmCryptoSuite(int crypto_suite) { crypto_suite == kSrtpAeadAes128Gcm); } -bool IsGcmCryptoSuiteName(const std::string& crypto_suite) { +bool IsGcmCryptoSuiteName(absl::string_view crypto_suite) { return (crypto_suite == kCsAeadAes256Gcm || crypto_suite == kCsAeadAes128Gcm); } @@ -98,7 +99,7 @@ bool SSLStreamAdapter::GetSslCipherSuite(int* cipher_suite) { return false; } -bool SSLStreamAdapter::ExportKeyingMaterial(const std::string& label, +bool SSLStreamAdapter::ExportKeyingMaterial(absl::string_view label, const uint8_t* context, size_t context_len, bool use_context, @@ -122,7 +123,7 @@ bool SSLStreamAdapter::IsBoringSsl() { bool SSLStreamAdapter::IsAcceptableCipher(int cipher, KeyType key_type) { return OpenSSLStreamAdapter::IsAcceptableCipher(cipher, key_type); } -bool SSLStreamAdapter::IsAcceptableCipher(const std::string& cipher, +bool SSLStreamAdapter::IsAcceptableCipher(absl::string_view cipher, KeyType key_type) { return OpenSSLStreamAdapter::IsAcceptableCipher(cipher, key_type); } diff --git a/rtc_base/ssl_stream_adapter.h b/rtc_base/ssl_stream_adapter.h index 618ffca4d0..e68870c747 100644 --- a/rtc_base/ssl_stream_adapter.h +++ b/rtc_base/ssl_stream_adapter.h @@ -13,11 +13,13 @@ #include #include + #include #include #include #include "absl/memory/memory.h" +#include "absl/strings/string_view.h" #include "rtc_base/ssl_certificate.h" #include "rtc_base/ssl_identity.h" #include "rtc_base/stream.h" @@ -53,7 +55,7 @@ extern const char kCsAeadAes256Gcm[]; std::string SrtpCryptoSuiteToName(int crypto_suite); // The reverse of above conversion. -int SrtpCryptoSuiteFromName(const std::string& crypto_suite); +int SrtpCryptoSuiteFromName(absl::string_view crypto_suite); // Get key length and salt length for given crypto suite. Returns true for // valid suites, otherwise false. @@ -65,7 +67,7 @@ bool GetSrtpKeyAndSaltLengths(int crypto_suite, bool IsGcmCryptoSuite(int crypto_suite); // Returns true if the given crypto suite name uses a GCM cipher. -bool IsGcmCryptoSuiteName(const std::string& crypto_suite); +bool IsGcmCryptoSuiteName(absl::string_view crypto_suite); // SSLStreamAdapter : A StreamInterfaceAdapter that does SSL/TLS. // After SSL has been started, the stream will only open on successful @@ -176,7 +178,7 @@ class SSLStreamAdapter : public StreamInterface, public sigslot::has_slots<> { // Returns true if successful. // `error` is optional and provides more information about the failure. virtual bool SetPeerCertificateDigest( - const std::string& digest_alg, + absl::string_view digest_alg, const unsigned char* digest_val, size_t digest_len, SSLPeerCertificateDigestError* error = nullptr) = 0; @@ -208,7 +210,7 @@ class SSLStreamAdapter : public StreamInterface, public sigslot::has_slots<> { // zero-length ones). // result -- where to put the computed value // result_len -- the length of the computed value - virtual bool ExportKeyingMaterial(const std::string& label, + virtual bool ExportKeyingMaterial(absl::string_view label, const uint8_t* context, size_t context_len, bool use_context, @@ -233,7 +235,7 @@ class SSLStreamAdapter : public StreamInterface, public sigslot::has_slots<> { // Returns true iff the supplied cipher is deemed to be strong. // TODO(torbjorng): Consider removing the KeyType argument. static bool IsAcceptableCipher(int cipher, KeyType key_type); - static bool IsAcceptableCipher(const std::string& cipher, KeyType key_type); + static bool IsAcceptableCipher(absl::string_view cipher, KeyType key_type); // TODO(guoweis): Move this away from a static class method. Currently this is // introduced such that any caller could depend on sslstreamadapter.h without diff --git a/rtc_base/ssl_stream_adapter_unittest.cc b/rtc_base/ssl_stream_adapter_unittest.cc index f92958dd86..262eeefb79 100644 --- a/rtc_base/ssl_stream_adapter_unittest.cc +++ b/rtc_base/ssl_stream_adapter_unittest.cc @@ -8,12 +8,15 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include "rtc_base/ssl_stream_adapter.h" + #include #include #include #include #include "absl/memory/memory.h" +#include "absl/strings/string_view.h" #include "rtc_base/buffer_queue.h" #include "rtc_base/checks.h" #include "rtc_base/gunit.h" @@ -24,7 +27,6 @@ #include "rtc_base/openssl_stream_adapter.h" #include "rtc_base/ssl_adapter.h" #include "rtc_base/ssl_identity.h" -#include "rtc_base/ssl_stream_adapter.h" #include "rtc_base/stream.h" #include "rtc_base/task_utils/pending_task_safety_flag.h" #include "rtc_base/task_utils/to_queued_task.h" @@ -147,7 +149,7 @@ class SSLDummyStreamBase : public rtc::StreamInterface, public sigslot::has_slots<> { public: SSLDummyStreamBase(SSLStreamAdapterTestBase* test, - const std::string& side, + absl::string_view side, rtc::StreamInterface* in, rtc::StreamInterface* out) : test_base_(test), side_(side), in_(in), out_(out), first_packet_(true) { @@ -235,7 +237,7 @@ class SSLDummyStreamBase : public rtc::StreamInterface, class SSLDummyStreamTLS : public SSLDummyStreamBase { public: SSLDummyStreamTLS(SSLStreamAdapterTestBase* test, - const std::string& side, + absl::string_view side, rtc::FifoBuffer* in, rtc::FifoBuffer* out) : SSLDummyStreamBase(test, side, in, out) {} @@ -303,7 +305,7 @@ class BufferQueueStream : public rtc::StreamInterface { class SSLDummyStreamDTLS : public SSLDummyStreamBase { public: SSLDummyStreamDTLS(SSLStreamAdapterTestBase* test, - const std::string& side, + absl::string_view side, BufferQueueStream* in, BufferQueueStream* out) : SSLDummyStreamBase(test, side, in, out) {} @@ -317,8 +319,8 @@ class SSLStreamAdapterTestBase : public ::testing::Test, public sigslot::has_slots<> { public: SSLStreamAdapterTestBase( - const std::string& client_cert_pem, - const std::string& client_private_key_pem, + absl::string_view client_cert_pem, + absl::string_view client_private_key_pem, bool dtls, rtc::KeyParams client_key_type = rtc::KeyParams(rtc::KT_DEFAULT), rtc::KeyParams server_key_type = rtc::KeyParams(rtc::KT_DEFAULT)) @@ -864,8 +866,8 @@ class SSLStreamAdapterTestDTLSBase : public SSLStreamAdapterTestBase { count_(0), sent_(0) {} - SSLStreamAdapterTestDTLSBase(const std::string& cert_pem, - const std::string& private_key_pem) + SSLStreamAdapterTestDTLSBase(absl::string_view cert_pem, + absl::string_view private_key_pem) : SSLStreamAdapterTestBase(cert_pem, private_key_pem, true), client_buffer_(kBufferCapacity, kDefaultBufferSize), server_buffer_(kBufferCapacity, kDefaultBufferSize), @@ -983,8 +985,8 @@ class SSLStreamAdapterTestDTLS : SSLStreamAdapterTestDTLSBase(::testing::get<0>(GetParam()), ::testing::get<1>(GetParam())) {} - SSLStreamAdapterTestDTLS(const std::string& cert_pem, - const std::string& private_key_pem) + SSLStreamAdapterTestDTLS(absl::string_view cert_pem, + absl::string_view private_key_pem) : SSLStreamAdapterTestDTLSBase(cert_pem, private_key_pem) {} }; @@ -1551,8 +1553,8 @@ class SSLStreamAdapterTestDTLSLegacyProtocols // initialized, so we set the experiment while creationg client_ssl_ // and server_ssl_. - void ConfigureClient(std::string experiment) { - webrtc::test::ScopedFieldTrials trial(experiment); + void ConfigureClient(absl::string_view experiment) { + webrtc::test::ScopedFieldTrials trial{std::string(experiment)}; client_stream_ = new SSLDummyStreamDTLS(this, "c2s", &client_buffer_, &server_buffer_); client_ssl_ = @@ -1564,8 +1566,8 @@ class SSLStreamAdapterTestDTLSLegacyProtocols client_ssl_->SetIdentity(std::move(client_identity)); } - void ConfigureServer(std::string experiment) { - webrtc::test::ScopedFieldTrials trial(experiment); + void ConfigureServer(absl::string_view experiment) { + webrtc::test::ScopedFieldTrials trial{std::string(experiment)}; server_stream_ = new SSLDummyStreamDTLS(this, "s2c", &server_buffer_, &client_buffer_); server_ssl_ = diff --git a/rtc_base/string_encode.cc b/rtc_base/string_encode.cc index 85fb992507..fa99c7a439 100644 --- a/rtc_base/string_encode.cc +++ b/rtc_base/string_encode.cc @@ -12,6 +12,7 @@ #include +#include "absl/strings/string_view.h" #include "rtc_base/arraysize.h" #include "rtc_base/checks.h" @@ -77,8 +78,8 @@ void hex_encode_with_delimiter(char* buffer, } // namespace -std::string hex_encode(const std::string& str) { - return hex_encode(str.c_str(), str.size()); +std::string hex_encode(absl::string_view str) { + return hex_encode(str.data(), str.size()); } std::string hex_encode(const char* source, size_t srclen) { @@ -141,14 +142,14 @@ size_t hex_decode_with_delimiter(char* cbuffer, return bufpos; } -size_t hex_decode(char* buffer, size_t buflen, const std::string& source) { +size_t hex_decode(char* buffer, size_t buflen, absl::string_view source) { return hex_decode_with_delimiter(buffer, buflen, source, 0); } size_t hex_decode_with_delimiter(char* buffer, size_t buflen, - const std::string& source, + absl::string_view source, char delimiter) { - return hex_decode_with_delimiter(buffer, buflen, source.c_str(), + return hex_decode_with_delimiter(buffer, buflen, source.data(), source.length(), delimiter); } @@ -177,7 +178,7 @@ bool tokenize_first(absl::string_view source, std::string* rest) { // Find the first delimiter size_t left_pos = source.find(delimiter); - if (left_pos == std::string::npos) { + if (left_pos == absl::string_view::npos) { return false; } @@ -245,8 +246,9 @@ std::string ToString(const bool b) { std::string ToString(const char* const s) { return std::string(s); } -std::string ToString(const std::string s) { - return s; + +std::string ToString(absl::string_view s) { + return std::string(s); } std::string ToString(const short s) { diff --git a/rtc_base/string_encode.h b/rtc_base/string_encode.h index c63d5271fa..87c5bc8d44 100644 --- a/rtc_base/string_encode.h +++ b/rtc_base/string_encode.h @@ -28,7 +28,7 @@ namespace rtc { // String Encoding Utilities ////////////////////////////////////////////////////////////////////// -std::string hex_encode(const std::string& str); +std::string hex_encode(absl::string_view str); std::string hex_encode(const char* source, size_t srclen); std::string hex_encode_with_delimiter(const char* source, size_t srclen, @@ -51,10 +51,10 @@ size_t hex_decode_with_delimiter(char* buffer, char delimiter); // Helper functions for hex_decode. -size_t hex_decode(char* buffer, size_t buflen, const std::string& source); +size_t hex_decode(char* buffer, size_t buflen, absl::string_view source); size_t hex_decode_with_delimiter(char* buffer, size_t buflen, - const std::string& source, + absl::string_view source, char delimiter); // Joins the source vector of strings into a single string, with each @@ -89,7 +89,7 @@ bool tokenize_first(absl::string_view source, std::string ToString(bool b); std::string ToString(const char* s); -std::string ToString(std::string t); +std::string ToString(absl::string_view s); std::string ToString(short s); std::string ToString(unsigned short s); diff --git a/rtc_base/string_utils.cc b/rtc_base/string_utils.cc index c03433541a..e8c13464bd 100644 --- a/rtc_base/string_utils.cc +++ b/rtc_base/string_utils.cc @@ -10,6 +10,8 @@ #include "rtc_base/string_utils.h" +#include "absl/strings/string_view.h" + namespace rtc { size_t strcpyn(char* buffer, diff --git a/rtc_base/string_utils.h b/rtc_base/string_utils.h index 1bb9d17528..a9cdd61a7b 100644 --- a/rtc_base/string_utils.h +++ b/rtc_base/string_utils.h @@ -16,6 +16,8 @@ #include #include +#include "absl/strings/string_view.h" + #if defined(WEBRTC_WIN) #include #include @@ -30,10 +32,24 @@ #include +#include "absl/strings/string_view.h" + namespace rtc { const size_t SIZE_UNKNOWN = static_cast(-1); +// An absl::string_view comparator functor for use with container types such as +// std::map that support heterogenous lookup. +// +// Example usage: +// std::map my_map; +struct AbslStringViewCmp { + using is_transparent = void; + bool operator()(absl::string_view a, absl::string_view b) const { + return a < b; + } +}; + // Safe version of strncpy that always nul-terminate. size_t strcpyn(char* buffer, size_t buflen, @@ -57,7 +73,7 @@ inline std::wstring ToUtf16(const char* utf8, size_t len) { return ws; } -inline std::wstring ToUtf16(const std::string& str) { +inline std::wstring ToUtf16(absl::string_view str) { return ToUtf16(str.data(), str.length()); } diff --git a/rtc_base/strings/json.cc b/rtc_base/strings/json.cc index 99664404cf..af8ba184e7 100644 --- a/rtc_base/strings/json.cc +++ b/rtc_base/strings/json.cc @@ -14,6 +14,7 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/string_encode.h" namespace rtc { @@ -240,46 +241,47 @@ bool GetDoubleFromJsonArray(const Json::Value& in, size_t n, double* out) { } bool GetValueFromJsonObject(const Json::Value& in, - const std::string& k, + absl::string_view k, Json::Value* out) { - if (!in.isObject() || !in.isMember(k)) { + std::string k_str = std::string(k); + if (!in.isObject() || !in.isMember(k_str)) { return false; } - *out = in[k]; + *out = in[k_str]; return true; } bool GetIntFromJsonObject(const Json::Value& in, - const std::string& k, + absl::string_view k, int* out) { Json::Value x; return GetValueFromJsonObject(in, k, &x) && GetIntFromJson(x, out); } bool GetUIntFromJsonObject(const Json::Value& in, - const std::string& k, + absl::string_view k, unsigned int* out) { Json::Value x; return GetValueFromJsonObject(in, k, &x) && GetUIntFromJson(x, out); } bool GetStringFromJsonObject(const Json::Value& in, - const std::string& k, + absl::string_view k, std::string* out) { Json::Value x; return GetValueFromJsonObject(in, k, &x) && GetStringFromJson(x, out); } bool GetBoolFromJsonObject(const Json::Value& in, - const std::string& k, + absl::string_view k, bool* out) { Json::Value x; return GetValueFromJsonObject(in, k, &x) && GetBoolFromJson(x, out); } bool GetDoubleFromJsonObject(const Json::Value& in, - const std::string& k, + absl::string_view k, double* out) { Json::Value x; return GetValueFromJsonObject(in, k, &x) && GetDoubleFromJson(x, out); diff --git a/rtc_base/strings/json.h b/rtc_base/strings/json.h index 0cb9542c7f..618cb71b04 100644 --- a/rtc_base/strings/json.h +++ b/rtc_base/strings/json.h @@ -14,6 +14,8 @@ #include #include +#include "absl/strings/string_view.h" + #if !defined(WEBRTC_EXTERNAL_JSON) #include "json/json.h" #else @@ -62,22 +64,20 @@ Json::Value DoubleVectorToJsonArray(const std::vector& in); // Pull values out of a JSON object. bool GetValueFromJsonObject(const Json::Value& in, - const std::string& k, + absl::string_view k, Json::Value* out); -bool GetIntFromJsonObject(const Json::Value& in, - const std::string& k, - int* out); +bool GetIntFromJsonObject(const Json::Value& in, absl::string_view k, int* out); bool GetUIntFromJsonObject(const Json::Value& in, - const std::string& k, + absl::string_view k, unsigned int* out); bool GetStringFromJsonObject(const Json::Value& in, - const std::string& k, + absl::string_view k, std::string* out); bool GetBoolFromJsonObject(const Json::Value& in, - const std::string& k, + absl::string_view k, bool* out); bool GetDoubleFromJsonObject(const Json::Value& in, - const std::string& k, + absl::string_view k, double* out); // Writes out a Json value as a string. diff --git a/rtc_base/strings/string_builder.cc b/rtc_base/strings/string_builder.cc index 7536cd77dd..e3e25e631b 100644 --- a/rtc_base/strings/string_builder.cc +++ b/rtc_base/strings/string_builder.cc @@ -15,6 +15,7 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_minmax.h" @@ -26,16 +27,12 @@ SimpleStringBuilder::SimpleStringBuilder(rtc::ArrayView buffer) RTC_DCHECK(IsConsistent()); } -SimpleStringBuilder& SimpleStringBuilder::operator<<(const char* str) { - return Append(str, strlen(str)); -} - SimpleStringBuilder& SimpleStringBuilder::operator<<(char ch) { return Append(&ch, 1); } -SimpleStringBuilder& SimpleStringBuilder::operator<<(const std::string& str) { - return Append(str.c_str(), str.length()); +SimpleStringBuilder& SimpleStringBuilder::operator<<(absl::string_view str) { + return Append(str.data(), str.length()); } // Numeric conversion routines. diff --git a/rtc_base/strings/string_builder.h b/rtc_base/strings/string_builder.h index 6fe478ce4c..b35b7f1867 100644 --- a/rtc_base/strings/string_builder.h +++ b/rtc_base/strings/string_builder.h @@ -32,9 +32,8 @@ class SimpleStringBuilder { SimpleStringBuilder(const SimpleStringBuilder&) = delete; SimpleStringBuilder& operator=(const SimpleStringBuilder&) = delete; - SimpleStringBuilder& operator<<(const char* str); SimpleStringBuilder& operator<<(char ch); - SimpleStringBuilder& operator<<(const std::string& str); + SimpleStringBuilder& operator<<(absl::string_view str); SimpleStringBuilder& operator<<(int i); SimpleStringBuilder& operator<<(unsigned i); SimpleStringBuilder& operator<<(long i); // NOLINT diff --git a/rtc_base/thread.cc b/rtc_base/thread.cc index 307d499255..f9680650a9 100644 --- a/rtc_base/thread.cc +++ b/rtc_base/thread.cc @@ -10,6 +10,8 @@ #include "rtc_base/thread.h" +#include "absl/strings/string_view.h" + #if defined(WEBRTC_WIN) #include #elif defined(WEBRTC_POSIX) @@ -744,10 +746,10 @@ bool Thread::SleepMs(int milliseconds) { #endif } -bool Thread::SetName(const std::string& name, const void* obj) { +bool Thread::SetName(absl::string_view name, const void* obj) { RTC_DCHECK(!IsRunning()); - name_ = name; + name_ = std::string(name); if (obj) { // The %p specifier typically produce at most 16 hex digits, possibly with a // 0x prefix. But format is implementation defined, so add some margin. diff --git a/rtc_base/thread.h b/rtc_base/thread.h index 3c4ed558cd..052a71b22c 100644 --- a/rtc_base/thread.h +++ b/rtc_base/thread.h @@ -22,6 +22,8 @@ #include #include +#include "absl/strings/string_view.h" + #if defined(WEBRTC_POSIX) #include #endif @@ -348,7 +350,7 @@ class RTC_LOCKABLE RTC_EXPORT Thread : public webrtc::TaskQueueBase { // Sets the thread's name, for debugging. Must be called before Start(). // If `obj` is non-null, its value is appended to `name`. const std::string& name() const { return name_; } - bool SetName(const std::string& name, const void* obj); + bool SetName(absl::string_view name, const void* obj); // Sets the expected processing time in ms. The thread will write // log messages when Invoke() takes more time than this. diff --git a/rtc_base/unique_id_generator.cc b/rtc_base/unique_id_generator.cc index 9fa3021c6f..e68c643dbe 100644 --- a/rtc_base/unique_id_generator.cc +++ b/rtc_base/unique_id_generator.cc @@ -13,6 +13,7 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/helpers.h" #include "rtc_base/string_encode.h" #include "rtc_base/string_to_number.h" @@ -55,8 +56,11 @@ std::string UniqueStringGenerator::GenerateString() { return ToString(unique_number_generator_.GenerateNumber()); } -bool UniqueStringGenerator::AddKnownId(const std::string& value) { - absl::optional int_value = StringToNumber(value); +bool UniqueStringGenerator::AddKnownId(absl::string_view value) { + // TODO(webrtc:13579): remove string copy here once absl::string_view version + // of StringToNumber is available. + absl::optional int_value = + StringToNumber(std::string(value)); // The underlying generator works for uint32_t values, so if the provided // value is not a uint32_t it will never be generated anyway. if (int_value.has_value()) { diff --git a/rtc_base/unique_id_generator.h b/rtc_base/unique_id_generator.h index 3e2f9d7072..342dad7766 100644 --- a/rtc_base/unique_id_generator.h +++ b/rtc_base/unique_id_generator.h @@ -15,6 +15,7 @@ #include #include +#include "absl/strings/string_view.h" #include "api/array_view.h" #include "api/sequence_checker.h" #include "rtc_base/synchronization/mutex.h" @@ -103,7 +104,7 @@ class UniqueStringGenerator { // Adds an id that this generator should no longer generate. // Return value indicates whether the ID was hitherto unknown. - bool AddKnownId(const std::string& value); + bool AddKnownId(absl::string_view value); private: // This implementation will be simple and will generate "0", "1", ... diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn index a5c7d47579..a8e246d5f6 100644 --- a/sdk/BUILD.gn +++ b/sdk/BUILD.gn @@ -355,6 +355,8 @@ if (is_ios || is_mac) { "../rtc_base:network_constants", "../rtc_base:threading", ] + + absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } rtc_library("network_monitor_objc") { @@ -374,6 +376,7 @@ if (is_ios || is_mac) { ":base_objc", ":helpers_objc", ":network_monitor_observer", + "../rtc_base:stringutils", "../rtc_base/system:gcd_helpers", ] } @@ -1581,6 +1584,8 @@ if (is_ios || is_mac) { "../rtc_base/task_utils:pending_task_safety_flag", "../rtc_base/task_utils:to_queued_task", ] + + absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } } diff --git a/sdk/android/BUILD.gn b/sdk/android/BUILD.gn index f81d3d5806..e17fb33dac 100644 --- a/sdk/android/BUILD.gn +++ b/sdk/android/BUILD.gn @@ -592,7 +592,10 @@ if (current_os == "linux" || is_android) { "../../system_wrappers:field_trial", "../../system_wrappers:metrics", ] - absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] + absl_deps = [ + "//third_party/abseil-cpp/absl/strings", + "//third_party/abseil-cpp/absl/types:optional", + ] } rtc_library("audio_jni") { diff --git a/sdk/android/src/jni/android_network_monitor.cc b/sdk/android/src/jni/android_network_monitor.cc index 9dbc27fdc2..e6f2357912 100644 --- a/sdk/android/src/jni/android_network_monitor.cc +++ b/sdk/android/src/jni/android_network_monitor.cc @@ -11,6 +11,8 @@ #include "sdk/android/src/jni/android_network_monitor.h" #include + +#include "absl/strings/string_view.h" #ifndef RTLD_NOLOAD // This was added in Lollipop to dlfcn.h #define RTLD_NOLOAD 4 @@ -284,7 +286,7 @@ void AndroidNetworkMonitor::Stop() { rtc::NetworkBindingResult AndroidNetworkMonitor::BindSocketToNetwork( int socket_fd, const rtc::IPAddress& address, - const std::string& if_name) { + absl::string_view if_name) { RTC_DCHECK_RUN_ON(network_thread_); // Android prior to Lollipop didn't have support for binding sockets to @@ -417,7 +419,7 @@ void AndroidNetworkMonitor::OnNetworkConnected_n( absl::optional AndroidNetworkMonitor::FindNetworkHandleFromAddressOrName( const rtc::IPAddress& ip_address, - const std::string& if_name) const { + absl::string_view if_name) const { RTC_DCHECK_RUN_ON(network_thread_); RTC_LOG(LS_INFO) << "Find network handle."; if (find_network_handle_without_ipv6_temporary_part_) { @@ -443,11 +445,11 @@ AndroidNetworkMonitor::FindNetworkHandleFromAddressOrName( absl::optional AndroidNetworkMonitor::FindNetworkHandleFromIfname( - const std::string& if_name) const { + absl::string_view if_name) const { RTC_DCHECK_RUN_ON(network_thread_); if (bind_using_ifname_) { for (auto const& iter : network_info_by_handle_) { - if (if_name.find(iter.second.interface_name) != std::string::npos) { + if (if_name.find(iter.second.interface_name) != absl::string_view::npos) { // Use partial match so that e.g if_name="v4-wlan0" is matched // agains iter.first="wlan0" return absl::make_optional(iter.first); @@ -495,7 +497,7 @@ void AndroidNetworkMonitor::SetNetworkInfos( } rtc::AdapterType AndroidNetworkMonitor::GetAdapterType( - const std::string& if_name) { + absl::string_view if_name) { RTC_DCHECK_RUN_ON(network_thread_); auto iter = adapter_type_by_name_.find(if_name); rtc::AdapterType type = (iter == adapter_type_by_name_.end()) @@ -506,7 +508,7 @@ rtc::AdapterType AndroidNetworkMonitor::GetAdapterType( for (auto const& iter : adapter_type_by_name_) { // Use partial match so that e.g if_name="v4-wlan0" is matched // agains iter.first="wlan0" - if (if_name.find(iter.first) != std::string::npos) { + if (if_name.find(iter.first) != absl::string_view::npos) { type = iter.second; break; } @@ -520,7 +522,7 @@ rtc::AdapterType AndroidNetworkMonitor::GetAdapterType( } rtc::AdapterType AndroidNetworkMonitor::GetVpnUnderlyingAdapterType( - const std::string& if_name) { + absl::string_view if_name) { RTC_DCHECK_RUN_ON(network_thread_); auto iter = vpn_underlying_adapter_type_by_name_.find(if_name); rtc::AdapterType type = (iter == vpn_underlying_adapter_type_by_name_.end()) @@ -530,7 +532,7 @@ rtc::AdapterType AndroidNetworkMonitor::GetVpnUnderlyingAdapterType( // Use partial match so that e.g if_name="v4-wlan0" is matched // agains iter.first="wlan0" for (auto const& iter : vpn_underlying_adapter_type_by_name_) { - if (if_name.find(iter.first) != std::string::npos) { + if (if_name.find(iter.first) != absl::string_view::npos) { type = iter.second; break; } @@ -541,7 +543,7 @@ rtc::AdapterType AndroidNetworkMonitor::GetVpnUnderlyingAdapterType( } rtc::NetworkPreference AndroidNetworkMonitor::GetNetworkPreference( - const std::string& if_name) { + absl::string_view if_name) { RTC_DCHECK_RUN_ON(network_thread_); auto iter = adapter_type_by_name_.find(if_name); if (iter == adapter_type_by_name_.end()) { diff --git a/sdk/android/src/jni/android_network_monitor.h b/sdk/android/src/jni/android_network_monitor.h index 01e5fb7af7..dbf51c2020 100644 --- a/sdk/android/src/jni/android_network_monitor.h +++ b/sdk/android/src/jni/android_network_monitor.h @@ -17,9 +17,11 @@ #include #include +#include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "rtc_base/network_monitor.h" #include "rtc_base/network_monitor_factory.h" +#include "rtc_base/string_utils.h" #include "rtc_base/task_utils/pending_task_safety_flag.h" #include "rtc_base/thread.h" #include "rtc_base/thread_annotations.h" @@ -83,12 +85,12 @@ class AndroidNetworkMonitor : public rtc::NetworkMonitorInterface { rtc::NetworkBindingResult BindSocketToNetwork( int socket_fd, const rtc::IPAddress& address, - const std::string& if_name) override; - rtc::AdapterType GetAdapterType(const std::string& if_name) override; + absl::string_view if_name) override; + rtc::AdapterType GetAdapterType(absl::string_view if_name) override; rtc::AdapterType GetVpnUnderlyingAdapterType( - const std::string& if_name) override; + absl::string_view if_name) override; rtc::NetworkPreference GetNetworkPreference( - const std::string& if_name) override; + absl::string_view if_name) override; // Always expected to be called on the network thread. void SetNetworkInfos(const std::vector& network_infos); @@ -112,7 +114,7 @@ class AndroidNetworkMonitor : public rtc::NetworkMonitorInterface { // Visible for testing. absl::optional FindNetworkHandleFromAddressOrName( const rtc::IPAddress& address, - const std::string& ifname) const; + absl::string_view ifname) const; private: void OnNetworkConnected_n(const NetworkInformation& network_info); @@ -121,17 +123,17 @@ class AndroidNetworkMonitor : public rtc::NetworkMonitorInterface { rtc::NetworkPreference preference); absl::optional FindNetworkHandleFromIfname( - const std::string& ifname) const; + absl::string_view ifname) const; const int android_sdk_int_; ScopedJavaGlobalRef j_application_context_; ScopedJavaGlobalRef j_network_monitor_; rtc::Thread* const network_thread_; bool started_ RTC_GUARDED_BY(network_thread_) = false; - std::map adapter_type_by_name_ - RTC_GUARDED_BY(network_thread_); - std::map vpn_underlying_adapter_type_by_name_ - RTC_GUARDED_BY(network_thread_); + std::map + adapter_type_by_name_ RTC_GUARDED_BY(network_thread_); + std::map + vpn_underlying_adapter_type_by_name_ RTC_GUARDED_BY(network_thread_); std::map network_handle_by_address_ RTC_GUARDED_BY(network_thread_); std::map network_info_by_handle_ diff --git a/sdk/objc/components/network/RTCNetworkMonitor.mm b/sdk/objc/components/network/RTCNetworkMonitor.mm index 7ac4946ec3..7e75b2b4c0 100644 --- a/sdk/objc/components/network/RTCNetworkMonitor.mm +++ b/sdk/objc/components/network/RTCNetworkMonitor.mm @@ -15,6 +15,8 @@ #import "base/RTCLogging.h" #import "helpers/RTCDispatcher+Private.h" +#include "rtc_base/string_utils.h" + namespace { rtc::AdapterType AdapterTypeFromInterfaceType(nw_interface_type_t interfaceType) { @@ -78,8 +80,8 @@ - (instancetype)initWithObserver:(webrtc::NetworkMonitorObserver *)observer { } else if (status == nw_path_status_satisfiable) { RTCLog(@"NW path monitor status: satisfiable."); } - std::map *map = - new std::map(); + std::map *map = + new std::map(); nw_path_enumerate_interfaces( path, (nw_path_enumerate_interfaces_block_t) ^ (nw_interface_t interface) { const char *name = nw_interface_get_name(interface); diff --git a/sdk/objc/native/src/network_monitor_observer.h b/sdk/objc/native/src/network_monitor_observer.h index 6fd126a0ae..7c411a1db1 100644 --- a/sdk/objc/native/src/network_monitor_observer.h +++ b/sdk/objc/native/src/network_monitor_observer.h @@ -14,7 +14,9 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/network_constants.h" +#include "rtc_base/string_utils.h" #include "rtc_base/thread.h" namespace webrtc { @@ -28,7 +30,8 @@ class NetworkMonitorObserver { // adapter type, for all available interfaces on the current path. If an // interface name isn't present it can be assumed to be unavailable. virtual void OnPathUpdate( - std::map adapter_type_by_name) = 0; + std::map + adapter_type_by_name) = 0; protected: virtual ~NetworkMonitorObserver() {} diff --git a/sdk/objc/native/src/objc_network_monitor.h b/sdk/objc/native/src/objc_network_monitor.h index df4774efe2..05752e1f0c 100644 --- a/sdk/objc/native/src/objc_network_monitor.h +++ b/sdk/objc/native/src/objc_network_monitor.h @@ -13,9 +13,11 @@ #include +#include "absl/strings/string_view.h" #include "api/sequence_checker.h" #include "rtc_base/network_monitor.h" #include "rtc_base/network_monitor_factory.h" +#include "rtc_base/string_utils.h" #include "rtc_base/task_utils/pending_task_safety_flag.h" #include "rtc_base/thread.h" #include "rtc_base/thread_annotations.h" @@ -41,23 +43,24 @@ class ObjCNetworkMonitor : public rtc::NetworkMonitorInterface, void Start() override; void Stop() override; - rtc::AdapterType GetAdapterType(const std::string& interface_name) override; + rtc::AdapterType GetAdapterType(absl::string_view interface_name) override; rtc::AdapterType GetVpnUnderlyingAdapterType( - const std::string& interface_name) override; + absl::string_view interface_name) override; rtc::NetworkPreference GetNetworkPreference( - const std::string& interface_name) override; - bool IsAdapterAvailable(const std::string& interface_name) override; + absl::string_view interface_name) override; + bool IsAdapterAvailable(absl::string_view interface_name) override; // NetworkMonitorObserver override. // Fans out updates to observers on the correct thread. void OnPathUpdate( - std::map adapter_type_by_name) override; + std::map + adapter_type_by_name) override; private: rtc::Thread* thread_ = nullptr; bool started_ = false; - std::map adapter_type_by_name_ - RTC_GUARDED_BY(thread_); + std::map + adapter_type_by_name_ RTC_GUARDED_BY(thread_); rtc::scoped_refptr safety_flag_; RTCNetworkMonitor* network_monitor_ = nil; }; diff --git a/sdk/objc/native/src/objc_network_monitor.mm b/sdk/objc/native/src/objc_network_monitor.mm index 14ed73374c..1790798ab7 100644 --- a/sdk/objc/native/src/objc_network_monitor.mm +++ b/sdk/objc/native/src/objc_network_monitor.mm @@ -9,12 +9,14 @@ */ #include "sdk/objc/native/src/objc_network_monitor.h" +#include "absl/strings/string_view.h" #include "rtc_base/task_utils/to_queued_task.h" #include #include "rtc_base/logging.h" +#include "rtc_base/string_utils.h" namespace webrtc { @@ -56,24 +58,24 @@ started_ = false; } -rtc::AdapterType ObjCNetworkMonitor::GetAdapterType(const std::string& interface_name) { +rtc::AdapterType ObjCNetworkMonitor::GetAdapterType(absl::string_view interface_name) { RTC_DCHECK_RUN_ON(thread_); - if (adapter_type_by_name_.find(interface_name) == adapter_type_by_name_.end()) { + auto iter = adapter_type_by_name_.find(interface_name); + if (iter == adapter_type_by_name_.end()) { return rtc::ADAPTER_TYPE_UNKNOWN; } - return adapter_type_by_name_.at(interface_name); + return iter->second; } -rtc::AdapterType ObjCNetworkMonitor::GetVpnUnderlyingAdapterType( - const std::string& interface_name) { +rtc::AdapterType ObjCNetworkMonitor::GetVpnUnderlyingAdapterType(absl::string_view interface_name) { return rtc::ADAPTER_TYPE_UNKNOWN; } -rtc::NetworkPreference ObjCNetworkMonitor::GetNetworkPreference(const std::string& interface_name) { +rtc::NetworkPreference ObjCNetworkMonitor::GetNetworkPreference(absl::string_view interface_name) { return rtc::NetworkPreference::NEUTRAL; } -bool ObjCNetworkMonitor::IsAdapterAvailable(const std::string& interface_name) { +bool ObjCNetworkMonitor::IsAdapterAvailable(absl::string_view interface_name) { RTC_DCHECK_RUN_ON(thread_); if (adapter_type_by_name_.empty()) { // If we have no path update, assume everything's available, because it's @@ -84,7 +86,7 @@ } void ObjCNetworkMonitor::OnPathUpdate( - std::map adapter_type_by_name) { + std::map adapter_type_by_name) { RTC_DCHECK(network_monitor_ != nil); thread_->PostTask(ToQueuedTask(safety_flag_, [this, adapter_type_by_name] { RTC_DCHECK_RUN_ON(thread_); From c2cd814cdd8cbf8dda6ccec2266327a5321fbde8 Mon Sep 17 00:00:00 2001 From: Jan Grulich Date: Tue, 15 Mar 2022 14:31:55 +0100 Subject: [PATCH 214/847] PipeWire capturer: check existence of cursor metadata Check whether there are any cursor metadata before we try to validate and use them, otherwise we might crash on this. Bug: webrtc:13429 Change-Id: I365da59a189b6b974cebafc94fec49d5b942efae Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255601 Reviewed-by: Alexander Cooper Commit-Queue: Alexander Cooper Cr-Commit-Position: refs/heads/main@{#36240} --- .../desktop_capture/linux/wayland/shared_screencast_stream.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc index a8c86e267b..9e81df4ca8 100644 --- a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc +++ b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc @@ -650,7 +650,7 @@ void SharedScreenCastStreamPrivate::ProcessBuffer(pw_buffer* buffer) { const struct spa_meta_cursor* cursor = static_cast(spa_buffer_find_meta_data( spa_buffer, SPA_META_Cursor, sizeof(*cursor))); - if (spa_meta_cursor_is_valid(cursor)) { + if (cursor && spa_meta_cursor_is_valid(cursor)) { struct spa_meta_bitmap* bitmap = nullptr; if (cursor->bitmap_offset) From 3e6c601e245a0553bf37a89537e26256775d6326 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Thu, 17 Mar 2022 13:01:59 -0700 Subject: [PATCH 215/847] Roll chromium_revision 3a3c61276c..7fc7e127cd (982148:982354) Change log: https://chromium.googlesource.com/chromium/src/+log/3a3c61276c..7fc7e127cd Full diff: https://chromium.googlesource.com/chromium/src/+/3a3c61276c..7fc7e127cd Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/dd8c44c8f4..68127bb5f9 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/2360da1f6c..3accbb4b4d * src/buildtools: https://chromium.googlesource.com/chromium/src/buildtools/+log/90ff2bf855..f0259e64a3 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/78e4405552..dbde37f9b8 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/d5dc373edb..cb66ad8363 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/e8c5102e5d..a3813e6a9a * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/8ff5321b11..4cc26bd5a0 * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/deac2d35a1..a2dabf80a3 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/da5dab661c..91235624de DEPS diff: https://chromium.googlesource.com/chromium/src/+/3a3c61276c..7fc7e127cd/DEPS No update to Clang. BUG=None Change-Id: Id2e745bab95ed44536a9a25cf811ef79e9bb43eb Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256042 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36241} --- DEPS | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/DEPS b/DEPS index af45e5e3b2..6ab319705b 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': '3a3c61276c8a69d4de8f8a08f1f4766c4995b7f2', + 'chromium_revision': '7fc7e127cd14edd614a894a46b94926e9c6a5588', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,24 +23,24 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@dd8c44c8f4161b4cb6c9d3e5aa1a35eb4e99ec09', + 'https://chromium.googlesource.com/chromium/src/base@68127bb5f98da9dad19ee394187229391f369303', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@2360da1f6cb9d68697457ea7eed31f44b992b798', + 'https://chromium.googlesource.com/chromium/src/build@3accbb4b4d6a8293b1e2214948955757e626ed2a', 'src/buildtools': - 'https://chromium.googlesource.com/chromium/src/buildtools@90ff2bf8559c8eb9ce0c77cff53b40aa8a01e14a', + 'https://chromium.googlesource.com/chromium/src/buildtools@f0259e64a3c238824b3323ced30edb2f45c63c8d', # 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@78e44055521ed198292afc253a99141437894255', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@dbde37f9b8cb2f5e6ad9440955b7381e5a842b16', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@d5dc373edb5a6fc9e16f571c65d99856060386ef', + 'https://chromium.googlesource.com/chromium/src/testing@cb66ad83632584f17b24f113a0ec3a3d36d79976', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@e8c5102e5d09d18ea4a391d49f136549c79c9b5a', + 'https://chromium.googlesource.com/chromium/src/third_party@a3813e6a9a285502ebb677ab29d0c3bdb6363c62', 'src/buildtools/linux64': { 'packages': [ @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@8ff5321b11a8dadc44aa7ba9fdc3707377417a5a', + 'https://chromium.googlesource.com/catapult.git@4cc26bd5a059cf275feff2c934f744617dd26e8c', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -231,7 +231,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@deac2d35a18ac8a216f70607fcbfe6615445869f', + 'https://android.googlesource.com/platform/external/perfetto.git@a2dabf80a38b16846d9a3209d61f452a1bfc8f15', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -288,7 +288,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@da5dab661c3b349577c6007f953daf8632b5bc9f', + 'https://chromium.googlesource.com/chromium/src/tools@91235624dec195f243cca3cedd3b8a4b3b4f02b8', 'src/third_party/accessibility_test_framework': { 'packages': [ From 2464612bbec82b5bc388390b837941e12f475d10 Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Thu, 17 Mar 2022 21:05:47 -0700 Subject: [PATCH 216/847] Update WebRTC code version (2022-03-18T04:05:46). Bug: None Change-Id: Iae0332ef971075f07c88f53c305d1789f1752109 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256045 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36242} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index b385936f74..a315d82397 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 2022-03-17T04:07:28"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-03-18T04:05:46"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From 979706bd3b8d8ceaf6bcf93f82ca3b4acdf3d453 Mon Sep 17 00:00:00 2001 From: Jeremy Leconte Date: Thu, 17 Mar 2022 15:09:43 +0100 Subject: [PATCH 217/847] Add some eng prod owners to PRESUBMIT.py. Bug: webrtc:13836 Change-Id: I6c8dd171aad03609802a4974a0b06437359673ec Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256002 Reviewed-by: Christoffer Jansson Reviewed-by: Mirko Bonadei Reviewed-by: Harald Alvestrand Commit-Queue: Jeremy Leconte Cr-Commit-Position: refs/heads/main@{#36243} --- OWNERS | 2 ++ sdk/android/OWNERS | 3 +++ 2 files changed, 5 insertions(+) diff --git a/OWNERS b/OWNERS index 4702befd9e..185c34e742 100644 --- a/OWNERS +++ b/OWNERS @@ -18,3 +18,5 @@ per-file WATCHLISTS=* per-file native-api.md=mbonadei@webrtc.org per-file ....lua=titovartem@webrtc.org per-file .style.yapf=jleconte@webrtc.org +per-file .py=jansson@webrtc.org +per-file .py=jleconte@webrtc.org diff --git a/sdk/android/OWNERS b/sdk/android/OWNERS index 890f642341..d75ffde97b 100644 --- a/sdk/android/OWNERS +++ b/sdk/android/OWNERS @@ -7,3 +7,6 @@ ssilkin@webrtc.org magjed@webrtc.org xalep@webrtc.org per-file ...Audio*.java=henrika@webrtc.org + +per-file PRESUBMIT.py=jansson@webrtc.org +per-file PRESUBMIT.py=jleconte@webrtc.org From 3f82d02742a80530a872231222b55e08db757462 Mon Sep 17 00:00:00 2001 From: Jeremy Leconte Date: Fri, 18 Mar 2022 07:11:27 +0100 Subject: [PATCH 218/847] mb: decode process output for Python3 CL from chromium's mb: https://chromium-review.googlesource.com/c/chromium/src/+/3321055 Bug: webrtc:13839 Change-Id: Ie90eceaff8c824aa23bc27149dc88b9ac4cd1936 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256006 Reviewed-by: Mirko Bonadei Commit-Queue: Jeremy Leconte Cr-Commit-Position: refs/heads/main@{#36244} --- tools_webrtc/mb/mb.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools_webrtc/mb/mb.py b/tools_webrtc/mb/mb.py index bbb5b6f472..8a44a9bcc0 100755 --- a/tools_webrtc/mb/mb.py +++ b/tools_webrtc/mb/mb.py @@ -1213,6 +1213,8 @@ def Call(self, cmd, env=None, buffer_output=True): stderr=subprocess.PIPE, env=env) out, err = p.communicate() + out = out.decode('utf-8') + err = err.decode('utf-8') else: p = subprocess.Popen(cmd, shell=False, cwd=self.src_dir, env=env) p.wait() From 66ddd5ab6d853c0e8ece811bb2d8b642b8602fc7 Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Fri, 18 Mar 2022 09:02:59 +0000 Subject: [PATCH 219/847] rtc_pc_base breakup: Make a target visible to Chrome Bug: webrtc:13805 Change-Id: I129bf3ecb69bd7dee363f16f2b6ba39cf9d06bac Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256008 Reviewed-by: Mirko Bonadei Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#36245} --- pc/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pc/BUILD.gn b/pc/BUILD.gn index d1ba8731b3..bafe028edc 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -363,7 +363,7 @@ rtc_source_set("jsep_transport_controller") { visibility = [ ":*" ] } rtc_source_set("media_session") { - visibility = [ ":*" ] + visibility = [ "*" ] # Used by Chrome } rtc_source_set("media_stream_proxy") { visibility = [ ":*" ] From 017a606836c031148dbccc53f6d016c9314a831a Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Thu, 17 Mar 2022 19:31:32 +0100 Subject: [PATCH 220/847] Avoid sending empty receiver reports with RTCPSender MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit in reduced size mode, i.e. when rtcp-rsize sdp attribute is negotiated Bug: webrtc:13833 Change-Id: I55fa5248d3f66dc2240d7a6fbbb399319f1a2e03 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256004 Reviewed-by: Åsa Persson Commit-Queue: Danil Chapovalov Cr-Commit-Position: refs/heads/main@{#36246} --- modules/rtp_rtcp/source/rtcp_sender.cc | 4 +++- modules/rtp_rtcp/source/rtcp_sender_unittest.cc | 13 ++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/rtp_rtcp/source/rtcp_sender.cc b/modules/rtp_rtcp/source/rtcp_sender.cc index a07e5aa641..04f8041bd4 100644 --- a/modules/rtp_rtcp/source/rtcp_sender.cc +++ b/modules/rtp_rtcp/source/rtcp_sender.cc @@ -484,7 +484,9 @@ void RTCPSender::BuildRR(const RtcpContext& ctx, PacketSender& sender) { rtcp::ReceiverReport report; report.SetSenderSsrc(ssrc_); report.SetReportBlocks(CreateReportBlocks(ctx.feedback_state_)); - sender.AppendPacket(report); + if (method_ == RtcpMode::kCompound || !report.report_blocks().empty()) { + sender.AppendPacket(report); + } } void RTCPSender::BuildPLI(const RtcpContext& ctx, PacketSender& sender) { diff --git a/modules/rtp_rtcp/source/rtcp_sender_unittest.cc b/modules/rtp_rtcp/source/rtcp_sender_unittest.cc index d05d8d6dd5..38a9302b67 100644 --- a/modules/rtp_rtcp/source/rtcp_sender_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_sender_unittest.cc @@ -252,13 +252,20 @@ TEST_F(RtcpSenderTest, DoNotSendCompundBeforeRtp) { TEST_F(RtcpSenderTest, SendRr) { auto rtcp_sender = CreateRtcpSender(GetDefaultConfig()); - rtcp_sender->SetRTCPStatus(RtcpMode::kReducedSize); + rtcp_sender->SetRTCPStatus(RtcpMode::kCompound); EXPECT_EQ(0, rtcp_sender->SendRTCP(feedback_state(), kRtcpRr)); EXPECT_EQ(1, parser()->receiver_report()->num_packets()); EXPECT_EQ(kSenderSsrc, parser()->receiver_report()->sender_ssrc()); EXPECT_EQ(0U, parser()->receiver_report()->report_blocks().size()); } +TEST_F(RtcpSenderTest, DoesntSendEmptyRrInReducedSizeMode) { + auto rtcp_sender = CreateRtcpSender(GetDefaultConfig()); + rtcp_sender->SetRTCPStatus(RtcpMode::kReducedSize); + rtcp_sender->SendRTCP(feedback_state(), kRtcpRr); + EXPECT_EQ(parser()->receiver_report()->num_packets(), 0); +} + TEST_F(RtcpSenderTest, SendRrWithOneReportBlock) { const uint16_t kSeqNum = 11111; auto rtcp_sender = CreateRtcpSender(GetDefaultConfig()); @@ -415,7 +422,7 @@ TEST_F(RtcpSenderTest, SendLossNotificationBufferingAllowed) { TEST_F(RtcpSenderTest, RembNotIncludedBeforeSet) { auto rtcp_sender = CreateRtcpSender(GetDefaultConfig()); - rtcp_sender->SetRTCPStatus(RtcpMode::kReducedSize); + rtcp_sender->SetRTCPStatus(RtcpMode::kCompound); rtcp_sender->SendRTCP(feedback_state(), kRtcpRr); @@ -427,7 +434,7 @@ TEST_F(RtcpSenderTest, RembNotIncludedAfterUnset) { const int64_t kBitrate = 261011; const std::vector kSsrcs = {kRemoteSsrc, kRemoteSsrc + 1}; auto rtcp_sender = CreateRtcpSender(GetDefaultConfig()); - rtcp_sender->SetRTCPStatus(RtcpMode::kReducedSize); + rtcp_sender->SetRTCPStatus(RtcpMode::kCompound); rtcp_sender->SetRemb(kBitrate, kSsrcs); rtcp_sender->SendRTCP(feedback_state(), kRtcpRr); ASSERT_EQ(1, parser()->receiver_report()->num_packets()); From bb986cbddbd28e2a6ac94af571b925a84c28e752 Mon Sep 17 00:00:00 2001 From: Alessio Bazzica Date: Thu, 17 Mar 2022 17:19:17 +0100 Subject: [PATCH 221/847] APM `audioproc_f`: adding `--override_key_pressed` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a flag to override the key pressed state when simulating APM. The current behavior changes as follows: - Wav files simulation: instead of simulating continuous key press events only if the transient suppressor (TS) sub-module is active, allow to simulate the events regardless of whether TS is used; the default key pressed state is used if the command line flag is unspecified, otherwise it is overridden (either always false or always true) - AEC dump simulation: instead of simulating continuous key press events when `--ts 2` is specified, allow to simulate the events regardless of whether TS is used; the state recorded in the AEC dump is used if the command line flag is unspecified, otherwise it is overridden (either always false or always true) - The `--ts 2` option (continuous key events) is now equivalent to `--ts 1`. Bug: webrtc:13663 Change-Id: I5ebe96283db73ee235ec2b2795d91d4e241a3527 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256003 Reviewed-by: Per Åhgren Commit-Queue: Alessio Bazzica Cr-Commit-Position: refs/heads/main@{#36247} --- .../audio_processing/test/aec_dump_based_simulator.cc | 11 +++++------ .../test/audio_processing_simulator.h | 1 + modules/audio_processing/test/audioproc_float_impl.cc | 11 +++++++++-- modules/audio_processing/test/wav_based_simulator.cc | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/modules/audio_processing/test/aec_dump_based_simulator.cc b/modules/audio_processing/test/aec_dump_based_simulator.cc index 621c3a43d0..ec35dd345c 100644 --- a/modules/audio_processing/test/aec_dump_based_simulator.cc +++ b/modules/audio_processing/test/aec_dump_based_simulator.cc @@ -164,15 +164,14 @@ void AecDumpBasedSimulator::PrepareProcessStreamCall( } } - if (!settings_.use_ts || *settings_.use_ts == 1) { - // Transient suppressor activated (1) or not specified. + if (settings_.override_key_pressed.has_value()) { + // Key pressed state overridden. + ap_->set_stream_key_pressed(*settings_.override_key_pressed); + } else { + // Set the recorded key pressed state. if (msg.has_keypress()) { ap_->set_stream_key_pressed(msg.keypress()); } - } else { - // Transient suppressor deactivated (0) or activated with continuous key - // events (2). - ap_->set_stream_key_pressed(*settings_.use_ts == 2); } // Level is always logged in AEC dumps. diff --git a/modules/audio_processing/test/audio_processing_simulator.h b/modules/audio_processing/test/audio_processing_simulator.h index 71f8eab160..b63bc12d6f 100644 --- a/modules/audio_processing/test/audio_processing_simulator.h +++ b/modules/audio_processing/test/audio_processing_simulator.h @@ -119,6 +119,7 @@ struct SimulationSettings { absl::optional analog_mic_gain_emulation_initial_level; absl::optional ns_level; absl::optional ns_analysis_on_linear_aec_output; + absl::optional override_key_pressed; absl::optional maximum_internal_processing_rate; int initial_mic_level; bool simulate_mic_gain = false; diff --git a/modules/audio_processing/test/audioproc_float_impl.cc b/modules/audio_processing/test/audioproc_float_impl.cc index 9055b64081..dc38172666 100644 --- a/modules/audio_processing/test/audioproc_float_impl.cc +++ b/modules/audio_processing/test/audioproc_float_impl.cc @@ -111,8 +111,7 @@ ABSL_FLAG(int, ABSL_FLAG(int, ts, kParameterNotSpecifiedValue, - "Activate (1), deactivate (0) or activate the transient suppressor " - "with continuous key events (2)"); + "Activate (1) or deactivate (0) the transient suppressor"); ABSL_FLAG(int, analog_agc, kParameterNotSpecifiedValue, @@ -218,6 +217,12 @@ ABSL_FLAG(int, simulated_mic_kind, kParameterNotSpecifiedValue, "Specify which microphone kind to use for microphone simulation"); +ABSL_FLAG(int, + override_key_pressed, + kParameterNotSpecifiedValue, + "Always set to true (1) or to false (0) the key press state. If " + "unspecified, false is set with Wav files or, with AEC dumps, the " + "recorded event is used."); ABSL_FLAG(int, frame_for_sending_capture_output_used_false, kParameterNotSpecifiedValue, @@ -459,6 +464,8 @@ SimulationSettings CreateSettings() { settings.simulate_mic_gain = absl::GetFlag(FLAGS_simulate_mic_gain); SetSettingIfSpecified(absl::GetFlag(FLAGS_simulated_mic_kind), &settings.simulated_mic_kind); + SetSettingIfFlagSet(absl::GetFlag(FLAGS_override_key_pressed), + &settings.override_key_pressed); SetSettingIfSpecified( absl::GetFlag(FLAGS_frame_for_sending_capture_output_used_false), &settings.frame_for_sending_capture_output_used_false); diff --git a/modules/audio_processing/test/wav_based_simulator.cc b/modules/audio_processing/test/wav_based_simulator.cc index 10c0d3717e..52a05a3871 100644 --- a/modules/audio_processing/test/wav_based_simulator.cc +++ b/modules/audio_processing/test/wav_based_simulator.cc @@ -82,7 +82,7 @@ void WavBasedSimulator::PrepareProcessStreamCall() { if (settings_.fixed_interface) { fwd_frame_.CopyFrom(*in_buf_); } - ap_->set_stream_key_pressed(settings_.use_ts && (*settings_.use_ts)); + ap_->set_stream_key_pressed(settings_.override_key_pressed.value_or(false)); if (!settings_.use_stream_delay || *settings_.use_stream_delay) { RTC_CHECK_EQ(AudioProcessing::kNoError, From 865d94e45258c9c8876ea4cbdd5dade510cb7d93 Mon Sep 17 00:00:00 2001 From: Per Kjellander Date: Fri, 18 Mar 2022 10:49:28 +0000 Subject: [PATCH 222/847] Revert "Apply lower bound of delay based estimate in AimdRateControl::ClampBitrate" This reverts commit e66e6a845b50f212ebb60234446cfc9db897879c. Reason for revert: May cause BWE to increase on delay increase if link capacity estimate is too high. Original change's description: > Apply lower bound of delay based estimate in AimdRateControl::ClampBitrate > > This move the functionality of applying the lower bound of a network estimate to AimdRateControl::ClampBitrate instead of ChangeBitrate. > The purpose is to be able to also clamp probe estimates set by AimdRateControl::SetEstimate as well. > > Bug: none > Change-Id: I6a4d64d2e98bb99da06010e2edaf20dc42880e37 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255823 > Reviewed-by: Per Kjellander > Commit-Queue: Per Kjellander > Reviewed-by: Diep Bui > Cr-Commit-Position: refs/heads/main@{#36219} Bug: none Change-Id: I8c65b1461160dbf3d35e50ef2cc6f9bc305c2b15 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256011 Bot-Commit: rubber-stamper@appspot.gserviceaccount.com Commit-Queue: Per Kjellander Reviewed-by: Diep Bui Cr-Commit-Position: refs/heads/main@{#36248} --- .../remote_bitrate_estimator/aimd_rate_control.cc | 11 +++++------ .../aimd_rate_control_unittest.cc | 13 +------------ 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/modules/remote_bitrate_estimator/aimd_rate_control.cc b/modules/remote_bitrate_estimator/aimd_rate_control.cc index 3a4ba85a0f..1714dd115a 100644 --- a/modules/remote_bitrate_estimator/aimd_rate_control.cc +++ b/modules/remote_bitrate_estimator/aimd_rate_control.cc @@ -338,6 +338,11 @@ void AimdRateControl::ChangeBitrate(const RateControlInput& input, decreased_bitrate = beta_ * link_capacity_.estimate(); } } + if (estimate_bounded_backoff_ && network_estimate_) { + decreased_bitrate = std::max( + decreased_bitrate, network_estimate_->link_capacity_lower * beta_); + } + // Avoid increasing the rate when over-using. if (decreased_bitrate < current_bitrate_) { new_bitrate = decreased_bitrate; @@ -381,12 +386,6 @@ DataRate AimdRateControl::ClampBitrate(DataRate new_bitrate) const { } new_bitrate = std::min(upper_bound, new_bitrate); } - if (estimate_bounded_backoff_ && network_estimate_ && - network_estimate_->link_capacity_lower.IsFinite() && - new_bitrate < current_bitrate_) { - new_bitrate = - std::max(new_bitrate, network_estimate_->link_capacity_lower * beta_); - } new_bitrate = std::max(new_bitrate, min_configured_bitrate_); return new_bitrate; } diff --git a/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc b/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc index e217a1a7bc..5d9c328e06 100644 --- a/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc +++ b/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc @@ -255,7 +255,7 @@ TEST(AimdRateControlTest, SetEstimateIncreaseBweInAlr) { 2 * kInitialBitrateBps); } -TEST(AimdRateControlTest, SetEstimateUpperLimitedByNetworkEstimate) { +TEST(AimdRateControlTest, SetEstimateClampedByNetworkEstimate) { auto states = CreateAimdRateControlStates(/*send_side=*/true); NetworkStateEstimate network_estimate; network_estimate.link_capacity_upper = DataRate::KilobitsPerSec(400); @@ -265,17 +265,6 @@ TEST(AimdRateControlTest, SetEstimateUpperLimitedByNetworkEstimate) { network_estimate.link_capacity_upper); } -TEST(AimdRateControlTest, SetEstimateLowerLimitedByNetworkEstimate) { - auto states = CreateAimdRateControlStates(/*send_side=*/true); - NetworkStateEstimate network_estimate; - network_estimate.link_capacity_lower = DataRate::KilobitsPerSec(400); - states.aimd_rate_control->SetNetworkStateEstimate(network_estimate); - SetEstimate(states, 100'000); - // 0.85 is default backoff factor. (`beta_`) - EXPECT_EQ(states.aimd_rate_control->LatestEstimate(), - network_estimate.link_capacity_lower * 0.85); -} - TEST(AimdRateControlTest, SetEstimateIgnoresNetworkEstimatesLowerThanCurrent) { test::ScopedFieldTrials override_field_trials( "WebRTC-Bwe-EstimateBoundedIncrease/" From b2a5785e79410da4a9fd2e09b2c768bd15545ed4 Mon Sep 17 00:00:00 2001 From: Mirko Bonadei Date: Fri, 18 Mar 2022 12:19:56 +0100 Subject: [PATCH 223/847] Don't assume strict order of IPs Bug: None Change-Id: I2005a4472b8a14e03a273f430fc6986f6ec0a4bd Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256012 Reviewed-by: Harald Alvestrand Commit-Queue: Mirko Bonadei Cr-Commit-Position: refs/heads/main@{#36249} --- rtc_base/network_unittest.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rtc_base/network_unittest.cc b/rtc_base/network_unittest.cc index e622ca334a..afff0b5923 100644 --- a/rtc_base/network_unittest.cc +++ b/rtc_base/network_unittest.cc @@ -1058,8 +1058,8 @@ TEST_F(NetworkTest, TestMergeNetworkList) { // IPAddresses. EXPECT_EQ(list2.size(), 1uL); EXPECT_EQ(list2[0]->GetIPs().size(), 2uL); - EXPECT_EQ(list2[0]->GetIPs()[0], InterfaceAddress(ip1)); - EXPECT_EQ(list2[0]->GetIPs()[1], InterfaceAddress(ip2)); + EXPECT_THAT(list2[0]->GetIPs(), UnorderedElementsAre(InterfaceAddress(ip1), + InterfaceAddress(ip2))); } // Test that MergeNetworkList successfully detects the change if From 9b88e299baa8d63480e5557030662654702a6a0b Mon Sep 17 00:00:00 2001 From: Mirko Bonadei Date: Fri, 18 Mar 2022 13:35:27 +0100 Subject: [PATCH 224/847] Skip NetworkTest.TestMultipleIPMergeNetworkList. Bug: webrtc:13846 Change-Id: I6098ef931e355c1d58b661962baab4ccb28916a3 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256014 Reviewed-by: Harald Alvestrand Commit-Queue: Mirko Bonadei Reviewed-by: Niels Moller Cr-Commit-Position: refs/heads/main@{#36250} --- rtc_base/network_unittest.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rtc_base/network_unittest.cc b/rtc_base/network_unittest.cc index afff0b5923..0b5f3e94ac 100644 --- a/rtc_base/network_unittest.cc +++ b/rtc_base/network_unittest.cc @@ -638,9 +638,10 @@ TEST_F(NetworkTest, MergeWithChangedIP) { EXPECT_EQ(changed_ip, network_to_change->GetIPs().at(0)); } +// TODO(bugs.webrtc.org/13846): Re-enable when the ASan issue is fixed. // Testing a similar case to above, but checking that a network can be updated // with additional IPs (not just a replacement). -TEST_F(NetworkTest, TestMultipleIPMergeNetworkList) { +TEST_F(NetworkTest, DISABLED_TestMultipleIPMergeNetworkList) { PhysicalSocketServer socket_server; BasicNetworkManager manager(&socket_server); manager.SignalNetworksChanged.connect(static_cast(this), From e9a6ada2e3e2c2c9e2f57ed336d91e7828255082 Mon Sep 17 00:00:00 2001 From: Jeremy Leconte Date: Fri, 18 Mar 2022 07:49:45 +0100 Subject: [PATCH 225/847] Fix add some eng prod owners to PRESUBMIT.py. Bug: webrtc:13836 Change-Id: I220fcef0412fa477627e8632b49e05a2b130eb53 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256007 Reviewed-by: Mirko Bonadei Reviewed-by: Harald Alvestrand Commit-Queue: Jeremy Leconte Cr-Commit-Position: refs/heads/main@{#36251} --- OWNERS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OWNERS b/OWNERS index 185c34e742..6ae4b59a95 100644 --- a/OWNERS +++ b/OWNERS @@ -18,5 +18,5 @@ per-file WATCHLISTS=* per-file native-api.md=mbonadei@webrtc.org per-file ....lua=titovartem@webrtc.org per-file .style.yapf=jleconte@webrtc.org -per-file .py=jansson@webrtc.org -per-file .py=jleconte@webrtc.org +per-file *.py=jansson@webrtc.org +per-file *.py=jleconte@webrtc.org From 4fc9bd9f69a0d88889d86d0cc9f8e27406e8a342 Mon Sep 17 00:00:00 2001 From: Jeremy Leconte Date: Fri, 18 Mar 2022 10:21:07 +0100 Subject: [PATCH 226/847] Add a new script to upload perf tests. Also add a script to do the bridge between a python 2 and a python 3 interpreter. This should be removed when the merge scripts will be using python 3 (https://crbug.com/webrtc/13835). Note that webrtc_dashboard_upload.py will be removed when the new script is stabilized. Bug: webrtc:13806 Change-Id: I806fa11f417ef37674bdaeb5126c71570e3697d7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255560 Reviewed-by: Mirko Bonadei Reviewed-by: Christoffer Jansson Reviewed-by: Artem Titov Reviewed-by: Christoffer Jansson Commit-Queue: Jeremy Leconte Cr-Commit-Position: refs/heads/main@{#36252} --- PRESUBMIT.py | 5 +- tools_webrtc/perf/catapult_uploader.py | 5 +- tools_webrtc/perf/process_perf_results.py | 123 ++++++++++++++++++ tools_webrtc/perf/process_perf_results_py2.py | 25 ++++ .../perf/process_perf_results_test.py | 70 ++++++++++ 5 files changed, 224 insertions(+), 4 deletions(-) create mode 100644 tools_webrtc/perf/process_perf_results.py create mode 100644 tools_webrtc/perf/process_perf_results_py2.py create mode 100644 tools_webrtc/perf/process_perf_results_test.py diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 5c7db2e9d6..f01338f2ef 100755 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -820,9 +820,10 @@ def Join(*args): return input_api.os_path.join(input_api.PresubmitLocalPath(), *args) excluded_files = [ - # This test should be run manually after webrtc_dashboard_upload target + # These tests should be run manually after webrtc_dashboard_upload target # has been built. - 'catapult_uploader_test.py' + 'catapult_uploader_test.py', + 'process_perf_results_test.py', ] test_directories = [ diff --git a/tools_webrtc/perf/catapult_uploader.py b/tools_webrtc/perf/catapult_uploader.py index c33ac89d0c..d07c287f28 100644 --- a/tools_webrtc/perf/catapult_uploader.py +++ b/tools_webrtc/perf/catapult_uploader.py @@ -14,6 +14,7 @@ import time import zlib +from typing import Optional import dataclasses import httplib2 @@ -53,7 +54,7 @@ class UploaderOptions(): build_page_url: str dashboard_url: str input_results_file: str - output_json_file: str + output_json_file: Optional[str] = None wait_timeout_sec: datetime.timedelta = datetime.timedelta(seconds=1200) wait_polling_period_sec: datetime.timedelta = datetime.timedelta(seconds=120) @@ -305,5 +306,5 @@ def UploadToDashboard(options): exit_code = UploadToDashboardImpl(options) except RuntimeError as e: print(e) - return 2 + return 1 return exit_code diff --git a/tools_webrtc/perf/process_perf_results.py b/tools_webrtc/perf/process_perf_results.py new file mode 100644 index 0000000000..e91b1f66e9 --- /dev/null +++ b/tools_webrtc/perf/process_perf_results.py @@ -0,0 +1,123 @@ +#!/usr/bin/env vpython3 + +# Copyright (c) 2022 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. +"""Adds build info to perf results and uploads them. + +The tests don't know which bot executed the tests or at what revision, so we +need to take their output and enrich it with this information. We load the proto +from the tests, add the build information as shared diagnostics and then +upload it to the dashboard. + +This script can't be in recipes, because we can't access the catapult APIs from +there. It needs to be here source-side. +""" + +import argparse +import json +import os +import sys + +from pathlib import Path + +# Even if protobuf is not used directly, this allows transitive imports +# of the protobuf library to use the vpython wheel specified in the root +# level .vpython (see bugs.webrtc.org/12211 for context). +import google.protobuf # pylint: disable=unused-import + + +def _ConfigurePythonPath(outdir): + # We just yank the python scripts we require into the PYTHONPATH. You could + # also imagine a solution where we use for instance + # protobuf:py_proto_runtime to copy catapult and protobuf code to out/. + # This is the convention in Chromium and WebRTC python scripts. We do need + # to build histogram_pb2 however, so that's why we add out/ to sys.path + # below. + # + # It would be better if there was an equivalent to py_binary in GN, but + # there's not. + script_dir = os.path.dirname(os.path.realpath(__file__)) + checkout_root = os.path.abspath(os.path.join(script_dir, os.pardir, + os.pardir)) + + sys.path.insert( + 0, os.path.join(checkout_root, 'third_party', 'catapult', 'tracing')) + sys.path.insert( + 0, os.path.join(checkout_root, 'third_party', 'protobuf', 'python')) + + # The webrtc_dashboard_upload gn rule will build the protobuf stub for + # python, so put it in the path for this script before we attempt to import + # it. + histogram_proto_path = os.path.join(outdir, 'pyproto', 'tracing', 'tracing', + 'proto') + sys.path.insert(0, histogram_proto_path) + + # Fail early in case the proto hasn't been built. + from tracing.proto import histogram_proto + if not histogram_proto.HAS_PROTO: + print('Could not find histogram_pb2. You need to build the ' + 'webrtc_dashboard_upload target before invoking this ' + 'script. Expected to find ' + 'histogram_pb2.py in %s.' % histogram_proto_path) + return 1 + return 0 + + +def _UploadToDasboard(args): + build_properties = json.loads(args.build_properties) + exit_code = _ConfigurePythonPath(build_properties['outdir']) + if exit_code != 0: + return exit_code + + import catapult_uploader + + perftest_outputs = [ + f.absolute() for f in Path(args.task_output_dir).rglob('perftest-output*') + if f.is_file() + ] + for perftest_output in perftest_outputs: + uploader_options = catapult_uploader.UploaderOptions( + perf_dashboard_machine_group=( + build_properties['perf_dashboard_machine_group']), + bot=build_properties['bot'], + webrtc_git_hash=build_properties['webrtc_git_hash'], + commit_position=build_properties['commit_position'], + build_page_url=build_properties['build_page_url'], + dashboard_url=build_properties['dashboard_url'], + test_suite=args.test_suite, + input_results_file=perftest_output, + ) + exit_code = catapult_uploader.UploadToDashboard(uploader_options) + if exit_code != 0: + return exit_code + return 0 + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('--build-properties', help=argparse.SUPPRESS) + parser.add_argument('--summary-json', help=argparse.SUPPRESS) + parser.add_argument('--task-output-dir', help=argparse.SUPPRESS) + parser.add_argument('--test-suite', help=argparse.SUPPRESS) + parser.add_argument('-o', '--output-json', help=argparse.SUPPRESS) + parser.add_argument('json_files', nargs='*', help=argparse.SUPPRESS) + args = parser.parse_args() + + exit_code = _UploadToDasboard(args) + if exit_code != 0: + with open(args.output_json, 'w') as f: + json.dump({ + "global_tags": ["UNRELIABLE_RESULTS"], + "missing_shards": [0] + }, f) + return exit_code + return 0 + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/tools_webrtc/perf/process_perf_results_py2.py b/tools_webrtc/perf/process_perf_results_py2.py new file mode 100644 index 0000000000..14b6858093 --- /dev/null +++ b/tools_webrtc/perf/process_perf_results_py2.py @@ -0,0 +1,25 @@ +#!/usr/bin/env vpython3 + +# Copyright (c) 2022 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. +"""Calls process_perf_results.py with a python 3 interpreter.""" + +import sys +import subprocess + + +# TODO(crbug.com/webrtc/13835): Delete this file and use +# process_perf_results.py instead. +def main(): + cmd = sys.argv[0].replace('_py2', '') + print('Calling "%s" with py3 in case this script was called with py2.' % cmd) + return subprocess.call(['vpython3', cmd] + sys.argv[1:]) + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/tools_webrtc/perf/process_perf_results_test.py b/tools_webrtc/perf/process_perf_results_test.py new file mode 100644 index 0000000000..3aa5afd75c --- /dev/null +++ b/tools_webrtc/perf/process_perf_results_test.py @@ -0,0 +1,70 @@ +#!/usr/bin/env vpython3 + +# Copyright (c) 2022 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 os +import sys + +import unittest +from unittest import mock + +_SCRIPT_DIR = os.path.dirname(__file__) +_SRC_DIR = os.path.normpath(os.path.join(_SCRIPT_DIR, '..', '..')) + +sys.path.insert(0, os.path.join(_SRC_DIR, 'third_party', 'protobuf', 'python')) +import process_perf_results + + +class ProcessPerfResultsTest(unittest.TestCase): + def testConfigurePythonPath(self): + # pylint: disable=protected-access + self.assertEqual( + 0, + process_perf_results._ConfigurePythonPath( + os.path.join(_SRC_DIR, 'out/Default'))) + + def testUploadToDasboard(self): + outdir = os.path.join(_SRC_DIR, 'out/Default') + args = mock.Mock( + build_properties='{' + '"outdir":"' + outdir + '", ' + + '"perf_dashboard_machine_group":"mock_machine_group", ' + + '"bot":"mock_bot", ' + '"webrtc_git_hash":"mock_webrtc_git_hash", ' + + '"commit_position":"123456", ' + + '"build_page_url":"mock_build_page_url", ' + + '"dashboard_url":"mock_dashboard_url"' + '}', + summary_json='mock_sumary_json', + task_output_dir='mock_task_output_dir', + test_suite='mock_test_suite', + ) + perftest_output = mock.Mock( + absolute=lambda: 'dummy_path/perftest-output.pb', + is_file=lambda: True, + ) + with mock.patch('pathlib.Path.rglob') as mocked_rglob: + with mock.patch('catapult_uploader.UploadToDashboard') as mocked_upload: + mocked_rglob.return_value = [perftest_output] + mocked_upload.return_value = 0 + # pylint: disable=protected-access + self.assertEqual(0, process_perf_results._UploadToDasboard(args)) + + import catapult_uploader + mocked_upload.assert_called_once_with( + catapult_uploader.UploaderOptions( + perf_dashboard_machine_group='mock_machine_group', + bot='mock_bot', + test_suite='mock_test_suite', + webrtc_git_hash='mock_webrtc_git_hash', + commit_position='123456', + build_page_url='mock_build_page_url', + dashboard_url='mock_dashboard_url', + input_results_file=perftest_output.absolute())) + + +if (__name__) == '__main__': + unittest.main() From 16af378884f9996ab1f8ce4629c910cb82ec54b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Spr=C3=A5ng?= Date: Fri, 18 Mar 2022 14:34:35 +0100 Subject: [PATCH 227/847] Remove deprecated TaskQueuePacedSender constructor. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:13417 Change-Id: I1486aedf2069d70c515fad97c665c7a5a94b6c38 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256017 Auto-Submit: Erik Språng Reviewed-by: Danil Chapovalov Commit-Queue: Danil Chapovalov Cr-Commit-Position: refs/heads/main@{#36253} --- modules/pacing/task_queue_paced_sender.cc | 15 --------------- modules/pacing/task_queue_paced_sender.h | 11 ----------- 2 files changed, 26 deletions(-) diff --git a/modules/pacing/task_queue_paced_sender.cc b/modules/pacing/task_queue_paced_sender.cc index ebfc7ece9a..f6591235b3 100644 --- a/modules/pacing/task_queue_paced_sender.cc +++ b/modules/pacing/task_queue_paced_sender.cc @@ -29,21 +29,6 @@ constexpr const char* kSlackedTaskQueuePacedSenderFieldTrial = } // namespace -TaskQueuePacedSender::TaskQueuePacedSender( - Clock* clock, - PacingController::PacketSender* packet_sender, - RtcEventLog* event_log, - const WebRtcKeyValueConfig* field_trials, - TaskQueueFactory* task_queue_factory, - TimeDelta max_hold_back_window, - int max_hold_back_window_in_packets) - : TaskQueuePacedSender(clock, - packet_sender, - *field_trials, - task_queue_factory, - max_hold_back_window, - max_hold_back_window_in_packets) {} - TaskQueuePacedSender::TaskQueuePacedSender( Clock* clock, PacingController::PacketSender* packet_sender, diff --git a/modules/pacing/task_queue_paced_sender.h b/modules/pacing/task_queue_paced_sender.h index 7a1d5f2fd7..4df8aafbdb 100644 --- a/modules/pacing/task_queue_paced_sender.h +++ b/modules/pacing/task_queue_paced_sender.h @@ -40,17 +40,6 @@ class Clock; class TaskQueuePacedSender : public RtpPacketPacer, public RtpPacketSender { public: - // TODO(bugs.webrtc.org/13417): Remove when downstream usage is gone. - ABSL_DEPRECATED("Use the other version instead.") - TaskQueuePacedSender( - Clock* clock, - PacingController::PacketSender* packet_sender, - RtcEventLog* event_log, - const WebRtcKeyValueConfig* field_trials, - TaskQueueFactory* task_queue_factory, - TimeDelta max_hold_back_window = PacingController::kMinSleepTime, - int max_hold_back_window_in_packets = -1); - // The `hold_back_window` parameter sets a lower bound on time to sleep if // there is currently a pacer queue and packets can't immediately be // processed. Increasing this reduces thread wakeups at the expense of higher From ef6b028c928e52d66c49f80e1a1c833ab9affdbb Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Fri, 18 Mar 2022 14:49:12 +0100 Subject: [PATCH 228/847] Implement recieving NACK in RtcpTranceiver Bug: webrtc:8239 Change-Id: I41d6c3252bbffeab66ded7ed294f82134351541a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254800 Reviewed-by: Emil Lundmark Commit-Queue: Danil Chapovalov Cr-Commit-Position: refs/heads/main@{#36254} --- .../rtp_rtcp/source/rtcp_transceiver_config.h | 3 ++ .../rtp_rtcp/source/rtcp_transceiver_impl.cc | 32 ++++++++++++++++--- .../rtp_rtcp/source/rtcp_transceiver_impl.h | 3 ++ .../source/rtcp_transceiver_impl_unittest.cc | 29 +++++++++++++++++ 4 files changed, 63 insertions(+), 4 deletions(-) diff --git a/modules/rtp_rtcp/source/rtcp_transceiver_config.h b/modules/rtp_rtcp/source/rtcp_transceiver_config.h index 34789dbd0b..8b0a8fad62 100644 --- a/modules/rtp_rtcp/source/rtcp_transceiver_config.h +++ b/modules/rtp_rtcp/source/rtcp_transceiver_config.h @@ -97,6 +97,9 @@ class RtpStreamRtcpHandler { int last_clock_rate_ = 90'000; }; virtual RtpStats SentStats() = 0; + + virtual void OnNack(uint32_t sender_ssrc, + rtc::ArrayView sequence_numbers) {} }; struct RtcpTransceiverConfig { diff --git a/modules/rtp_rtcp/source/rtcp_transceiver_impl.cc b/modules/rtp_rtcp/source/rtcp_transceiver_impl.cc index 382e9f19ff..a43edbde17 100644 --- a/modules/rtp_rtcp/source/rtcp_transceiver_impl.cc +++ b/modules/rtp_rtcp/source/rtcp_transceiver_impl.cc @@ -351,10 +351,34 @@ void RtcpTransceiverImpl::HandlePayloadSpecificFeedback( void RtcpTransceiverImpl::HandleRtpFeedback( const rtcp::CommonHeader& rtcp_packet_header, Timestamp now) { - // Transport feedback is the only message handled right now. - if (rtcp_packet_header.fmt() != - rtcp::TransportFeedback::kFeedbackMessageType || - config_.network_link_observer == nullptr) { + switch (rtcp_packet_header.fmt()) { + case rtcp::Nack::kFeedbackMessageType: + HandleNack(rtcp_packet_header); + break; + case rtcp::TransportFeedback::kFeedbackMessageType: + HandleTransportFeedback(rtcp_packet_header, now); + break; + } +} + +void RtcpTransceiverImpl::HandleNack( + const rtcp::CommonHeader& rtcp_packet_header) { + rtcp::Nack nack; + if (local_senders_.empty() || !nack.Parse(rtcp_packet_header)) { + return; + } + auto it = local_senders_by_ssrc_.find(nack.media_ssrc()); + if (it != local_senders_by_ssrc_.end()) { + it->second->handler->OnNack(nack.sender_ssrc(), nack.packet_ids()); + } +} + +void RtcpTransceiverImpl::HandleTransportFeedback( + const rtcp::CommonHeader& rtcp_packet_header, + Timestamp now) { + RTC_DCHECK_EQ(rtcp_packet_header.fmt(), + rtcp::TransportFeedback::kFeedbackMessageType); + if (config_.network_link_observer == nullptr) { return; } rtcp::TransportFeedback feedback; diff --git a/modules/rtp_rtcp/source/rtcp_transceiver_impl.h b/modules/rtp_rtcp/source/rtcp_transceiver_impl.h index be9a98188e..9e0da6a42d 100644 --- a/modules/rtp_rtcp/source/rtcp_transceiver_impl.h +++ b/modules/rtp_rtcp/source/rtcp_transceiver_impl.h @@ -105,6 +105,9 @@ class RtcpTransceiverImpl { Timestamp now); void HandleRtpFeedback(const rtcp::CommonHeader& rtcp_packet_header, Timestamp now); + void HandleNack(const rtcp::CommonHeader& rtcp_packet_header); + void HandleTransportFeedback(const rtcp::CommonHeader& rtcp_packet_header, + Timestamp now); void HandleExtendedReports(const rtcp::CommonHeader& rtcp_packet_header, Timestamp now); // Extended Reports blocks handlers. diff --git a/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc b/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc index 744b4eb6a2..e90cf047f2 100644 --- a/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc @@ -40,6 +40,7 @@ namespace { using ::testing::_; using ::testing::ElementsAre; +using ::testing::ElementsAreArray; using ::testing::Ge; using ::testing::NiceMock; using ::testing::Return; @@ -82,6 +83,10 @@ class MockRtpStreamRtcpHandler : public RtpStreamRtcpHandler { } MOCK_METHOD(RtpStats, SentStats, (), (override)); + MOCK_METHOD(void, + OnNack, + (uint32_t, rtc::ArrayView), + (override)); private: int num_calls_ = 0; @@ -1044,6 +1049,30 @@ TEST(RtcpTransceiverImplTest, SendsNack) { EXPECT_EQ(rtcp_parser.nack()->packet_ids(), kMissingSequenceNumbers); } +TEST(RtcpTransceiverImplTest, ReceivesNack) { + static constexpr uint32_t kRemoteSsrc = 4321; + static constexpr uint32_t kMediaSsrc1 = 1234; + static constexpr uint32_t kMediaSsrc2 = 1235; + std::vector kMissingSequenceNumbers = {34, 37, 38}; + RtcpTransceiverConfig config = DefaultTestConfig(); + RtcpTransceiverImpl rtcp_transceiver(config); + + MockRtpStreamRtcpHandler local_stream1; + MockRtpStreamRtcpHandler local_stream2; + EXPECT_CALL(local_stream1, + OnNack(kRemoteSsrc, ElementsAreArray(kMissingSequenceNumbers))); + EXPECT_CALL(local_stream2, OnNack).Times(0); + + EXPECT_TRUE(rtcp_transceiver.AddMediaSender(kMediaSsrc1, &local_stream1)); + EXPECT_TRUE(rtcp_transceiver.AddMediaSender(kMediaSsrc2, &local_stream2)); + + rtcp::Nack nack; + nack.SetSenderSsrc(kRemoteSsrc); + nack.SetMediaSsrc(kMediaSsrc1); + nack.SetPacketIds(kMissingSequenceNumbers); + rtcp_transceiver.ReceivePacket(nack.Build(), config.clock->CurrentTime()); +} + TEST(RtcpTransceiverImplTest, RequestKeyFrameWithPictureLossIndication) { const uint32_t kSenderSsrc = 1234; const uint32_t kRemoteSsrc = 4321; From 29ad53e466b5128c2f85d421fbddcdcd209c85cd Mon Sep 17 00:00:00 2001 From: Tomas Gunnarsson Date: Fri, 18 Mar 2022 14:46:48 +0100 Subject: [PATCH 229/847] Remove 'owned proxy' macros from proxy.h. This seems to be unused and also differs from other proxy implementations in that proxies are generally for reference counted interfaces whereas the 'owned proxy' macros are not. Bug: webrtc:13464, webrtc:12701 Change-Id: I2fc2c2f186bccab8388928d41610112c3b5f88ac Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256018 Reviewed-by: Harald Alvestrand Reviewed-by: Niels Moller Commit-Queue: Tomas Gunnarsson Cr-Commit-Position: refs/heads/main@{#36255} --- pc/proxy.h | 15 ------------- pc/proxy_unittest.cc | 50 -------------------------------------------- 2 files changed, 65 deletions(-) diff --git a/pc/proxy.h b/pc/proxy.h index e48f479183..feeb06338e 100644 --- a/pc/proxy.h +++ b/pc/proxy.h @@ -53,8 +53,6 @@ // The variant defined with BEGIN_PRIMARY_PROXY_MAP is unaware of // the secondary thread, and invokes all methods on the primary thread. // -// The variant defined with BEGIN_OWNED_PROXY_MAP does not use -// refcounting, and instead just takes ownership of the object being proxied. #ifndef PC_PROXY_H_ #define PC_PROXY_H_ @@ -309,19 +307,6 @@ class ConstMethodCall : public QueuedTask { primary_thread, secondary_thread, c); \ } -#define BEGIN_OWNED_PROXY_MAP(class_name) \ - PROXY_MAP_BOILERPLATE(class_name) \ - SECONDARY_PROXY_MAP_BOILERPLATE(class_name) \ - OWNED_PROXY_MAP_BOILERPLATE(class_name) \ - public: \ - static std::unique_ptr Create( \ - rtc::Thread* primary_thread, rtc::Thread* secondary_thread, \ - std::unique_ptr c) { \ - return std::unique_ptr( \ - new class_name##ProxyWithInternal(primary_thread, secondary_thread, \ - c.release())); \ - } - #define PROXY_PRIMARY_THREAD_DESTRUCTOR() \ private: \ rtc::Thread* destructor_thread() const { return primary_thread_; } \ diff --git a/pc/proxy_unittest.cc b/pc/proxy_unittest.cc index ef3d97eddc..ab02359d53 100644 --- a/pc/proxy_unittest.cc +++ b/pc/proxy_unittest.cc @@ -256,54 +256,4 @@ TEST_F(ProxyTest, WorkerMethod2) { EXPECT_EQ("Method2", fake_proxy_->Method2(arg1, arg2)); } -// Interface for testing OWNED_PROXY_MAP. -class FooInterface { - public: - virtual ~FooInterface() {} - virtual void Bar() = 0; -}; - -class Foo : public FooInterface { - public: - Foo() {} - MOCK_METHOD(void, Bar, (), (override)); -}; - -BEGIN_OWNED_PROXY_MAP(Foo) -PROXY_PRIMARY_THREAD_DESTRUCTOR() -PROXY_METHOD0(void, Bar) -END_PROXY_MAP(Foo) - -class OwnedProxyTest : public ::testing::Test { - public: - OwnedProxyTest() - : signaling_thread_(rtc::Thread::Create()), - worker_thread_(rtc::Thread::Create()), - foo_(new Foo()), - foo_proxy_(FooProxy::Create(signaling_thread_.get(), - worker_thread_.get(), - std::unique_ptr(foo_))) { - signaling_thread_->Start(); - worker_thread_->Start(); - } - - void CheckSignalingThread() { EXPECT_TRUE(signaling_thread_->IsCurrent()); } - void CheckWorkerThread() { EXPECT_TRUE(worker_thread_->IsCurrent()); } - - protected: - std::unique_ptr signaling_thread_; - std::unique_ptr worker_thread_; - Foo* foo_; // Owned by foo_proxy_, not this class. - std::unique_ptr foo_proxy_; -}; - -// Just tests that a method can be invoked using an "owned proxy" (as opposed -// to normal ref-counted version). -TEST_F(OwnedProxyTest, BasicTest) { - EXPECT_CALL(*foo_, Bar()) - .Times(Exactly(1)) - .WillOnce(InvokeWithoutArgs(this, &OwnedProxyTest::CheckSignalingThread)); - foo_proxy_->Bar(); -} - } // namespace webrtc From 76dd735a143c4e8e721698ae8347b10c1a84abc4 Mon Sep 17 00:00:00 2001 From: Salman Malik Date: Wed, 16 Mar 2022 21:07:11 +0000 Subject: [PATCH 230/847] desktop_capturer: Extract helpers from screencast portal Extract helper methods from screencast portal that can be reused for remote desktop portal client. Bug: chromium:1291247 Change-Id: I66d09c75f0c34d81c7ceff8998720fbbd1902ac8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/249860 Reviewed-by: Alexander Cooper Commit-Queue: Salman Malik Cr-Commit-Position: refs/heads/main@{#36256} --- modules/desktop_capture/BUILD.gn | 2 + .../linux/wayland/base_capturer_pipewire.cc | 16 +- .../linux/wayland/base_capturer_pipewire.h | 3 +- .../linux/wayland/screencast_portal.cc | 289 ++++-------------- .../linux/wayland/screencast_portal.h | 35 +-- .../linux/wayland/xdg_desktop_portal_utils.cc | 169 ++++++++++ .../linux/wayland/xdg_desktop_portal_utils.h | 234 ++++++++++++++ 7 files changed, 492 insertions(+), 256 deletions(-) create mode 100644 modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.cc create mode 100644 modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.h diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn index 6c855b9c1c..0faad43a1f 100644 --- a/modules/desktop_capture/BUILD.gn +++ b/modules/desktop_capture/BUILD.gn @@ -574,6 +574,8 @@ rtc_library("desktop_capture_generic") { "linux/wayland/screencast_portal.h", "linux/wayland/shared_screencast_stream.cc", "linux/wayland/shared_screencast_stream.h", + "linux/wayland/xdg_desktop_portal_utils.cc", + "linux/wayland/xdg_desktop_portal_utils.h", ] configs += [ diff --git a/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc b/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc index b6120ee68c..ae26570a7c 100644 --- a/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc +++ b/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc @@ -12,11 +12,18 @@ #include "modules/desktop_capture/desktop_capture_options.h" #include "modules/desktop_capture/desktop_capturer.h" +#include "modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" namespace webrtc { +namespace { + +using xdg_portal::RequestResponse; + +} // namespace + BaseCapturerPipeWire::BaseCapturerPipeWire(const DesktopCaptureOptions& options) : options_(options) { screencast_portal_ = std::make_unique( @@ -25,11 +32,10 @@ BaseCapturerPipeWire::BaseCapturerPipeWire(const DesktopCaptureOptions& options) BaseCapturerPipeWire::~BaseCapturerPipeWire() {} -void BaseCapturerPipeWire::OnScreenCastRequestResult( - ScreenCastPortal::RequestResponse result, - uint32_t stream_node_id, - int fd) { - if (result != ScreenCastPortal::RequestResponse::kSuccess || +void BaseCapturerPipeWire::OnScreenCastRequestResult(RequestResponse result, + uint32_t stream_node_id, + int fd) { + if (result != RequestResponse::kSuccess || !options_.screencast_stream()->StartScreenCastStream(stream_node_id, fd)) { capturer_failed_ = true; diff --git a/modules/desktop_capture/linux/wayland/base_capturer_pipewire.h b/modules/desktop_capture/linux/wayland/base_capturer_pipewire.h index 7663cb60ae..e9d67d04be 100644 --- a/modules/desktop_capture/linux/wayland/base_capturer_pipewire.h +++ b/modules/desktop_capture/linux/wayland/base_capturer_pipewire.h @@ -15,6 +15,7 @@ #include "modules/desktop_capture/desktop_capturer.h" #include "modules/desktop_capture/linux/wayland/screencast_portal.h" #include "modules/desktop_capture/linux/wayland/shared_screencast_stream.h" +#include "modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.h" namespace webrtc { @@ -34,7 +35,7 @@ class BaseCapturerPipeWire : public DesktopCapturer, bool SelectSource(SourceId id) override; // ScreenCastPortal::PortalNotifier interface. - void OnScreenCastRequestResult(ScreenCastPortal::RequestResponse result, + void OnScreenCastRequestResult(xdg_portal::RequestResponse result, uint32_t stream_node_id, int fd) override; void OnScreenCastSessionClosed() override; diff --git a/modules/desktop_capture/linux/wayland/screencast_portal.cc b/modules/desktop_capture/linux/wayland/screencast_portal.cc index ac0e9700ed..0b9db6ffb0 100644 --- a/modules/desktop_capture/linux/wayland/screencast_portal.cc +++ b/modules/desktop_capture/linux/wayland/screencast_portal.cc @@ -14,189 +14,96 @@ #include #include "modules/desktop_capture/linux/wayland/scoped_glib.h" +#include "modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" namespace webrtc { - -const char kDesktopBusName[] = "org.freedesktop.portal.Desktop"; -const char kDesktopObjectPath[] = "/org/freedesktop/portal/desktop"; -const char kDesktopRequestObjectPath[] = - "/org/freedesktop/portal/desktop/request"; -const char kSessionInterfaceName[] = "org.freedesktop.portal.Session"; -const char kRequestInterfaceName[] = "org.freedesktop.portal.Request"; -const char kScreenCastInterfaceName[] = "org.freedesktop.portal.ScreenCast"; - -ScreenCastPortal::ScreenCastPortal(CaptureSourceType source_type, - PortalNotifier* notifier) +namespace { + +using xdg_portal::kScreenCastInterfaceName; +using xdg_portal::PrepareSignalHandle; +using xdg_portal::RequestResponse; +using xdg_portal::RequestSessionProxy; +using xdg_portal::RequestSessionUsingProxy; +using xdg_portal::SessionRequestHandler; +using xdg_portal::SessionRequestResponseSignalHelper; +using xdg_portal::SetupRequestResponseSignal; +using xdg_portal::SetupSessionRequestHandlers; +using xdg_portal::StartRequestedHandler; +using xdg_portal::StartSessionRequest; +using xdg_portal::TearDownSession; + +} // namespace + +ScreenCastPortal::ScreenCastPortal( + ScreenCastPortal::CaptureSourceType source_type, + PortalNotifier* notifier) : notifier_(notifier), capture_source_type_(source_type) {} ScreenCastPortal::~ScreenCastPortal() { + UnsubscribeSignalHandlers(); + TearDownSession(std::move(session_handle_), proxy_, cancellable_, + connection_); + cancellable_ = nullptr; + proxy_ = nullptr; + + if (pw_fd_ != -1) { + close(pw_fd_); + } +} + +void ScreenCastPortal::UnsubscribeSignalHandlers() { if (start_request_signal_id_) { g_dbus_connection_signal_unsubscribe(connection_, start_request_signal_id_); + start_request_signal_id_ = 0; } + if (sources_request_signal_id_) { g_dbus_connection_signal_unsubscribe(connection_, sources_request_signal_id_); + sources_request_signal_id_ = 0; } + if (session_request_signal_id_) { g_dbus_connection_signal_unsubscribe(connection_, session_request_signal_id_); - } - - if (!session_handle_.empty()) { - Scoped message( - g_dbus_message_new_method_call(kDesktopBusName, session_handle_.c_str(), - kSessionInterfaceName, "Close")); - if (message.get()) { - Scoped error; - g_dbus_connection_send_message(connection_, message.get(), - G_DBUS_SEND_MESSAGE_FLAGS_NONE, - /*out_serial=*/nullptr, error.receive()); - if (error.get()) { - RTC_LOG(LS_ERROR) << "Failed to close the session: " << error->message; - } - } - } - - if (cancellable_) { - g_cancellable_cancel(cancellable_); - g_object_unref(cancellable_); - cancellable_ = nullptr; - } - - if (proxy_) { - g_object_unref(proxy_); - proxy_ = nullptr; - } - - if (pw_fd_ != -1) { - close(pw_fd_); + session_request_signal_id_ = 0; } } void ScreenCastPortal::Start() { cancellable_ = g_cancellable_new(); - g_dbus_proxy_new_for_bus( - G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, /*info=*/nullptr, - kDesktopBusName, kDesktopObjectPath, kScreenCastInterfaceName, - cancellable_, reinterpret_cast(OnProxyRequested), - this); + RequestSessionProxy(kScreenCastInterfaceName, OnProxyRequested, cancellable_, + this); } void ScreenCastPortal::PortalFailed(RequestResponse result) { notifier_->OnScreenCastRequestResult(result, pw_stream_node_id_, pw_fd_); } -uint32_t ScreenCastPortal::SetupRequestResponseSignal( - const char* object_path, - GDBusSignalCallback callback) { - return g_dbus_connection_signal_subscribe( - connection_, kDesktopBusName, kRequestInterfaceName, "Response", - object_path, /*arg0=*/nullptr, G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE, - callback, this, /*user_data_free_func=*/nullptr); -} - // static -void ScreenCastPortal::OnProxyRequested(GObject* /*object*/, +void ScreenCastPortal::OnProxyRequested(GObject* gobject, GAsyncResult* result, gpointer user_data) { - ScreenCastPortal* that = static_cast(user_data); - RTC_DCHECK(that); - - Scoped error; - GDBusProxy* proxy = g_dbus_proxy_new_finish(result, error.receive()); - if (!proxy) { - if (g_error_matches(error.get(), G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - RTC_LOG(LS_ERROR) << "Failed to create a proxy for the screen cast portal: " - << error->message; - that->PortalFailed(RequestResponse::kError); - return; - } - that->proxy_ = proxy; - that->connection_ = g_dbus_proxy_get_connection(that->proxy_); - - RTC_LOG(LS_INFO) << "Created proxy for the screen cast portal."; - - that->SessionRequest(); + RequestSessionUsingProxy( + static_cast(user_data), gobject, result); } -// static -std::string ScreenCastPortal::PrepareSignalHandle(GDBusConnection* connection, - const char* token) { - Scoped sender( - g_strdup(g_dbus_connection_get_unique_name(connection) + 1)); - for (int i = 0; sender.get()[i]; ++i) { - if (sender.get()[i] == '.') { - sender.get()[i] = '_'; - } - } - - const char* handle = g_strconcat(kDesktopRequestObjectPath, "/", sender.get(), - "/", token, /*end of varargs*/ nullptr); - - return handle; -} - -void ScreenCastPortal::SessionRequest() { - GVariantBuilder builder; - Scoped variant_string; - - g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT); - variant_string = - g_strdup_printf("webrtc_session%d", g_random_int_range(0, G_MAXINT)); - g_variant_builder_add(&builder, "{sv}", "session_handle_token", - g_variant_new_string(variant_string.get())); - variant_string = g_strdup_printf("webrtc%d", g_random_int_range(0, G_MAXINT)); - g_variant_builder_add(&builder, "{sv}", "handle_token", - g_variant_new_string(variant_string.get())); - - portal_handle_ = PrepareSignalHandle(connection_, variant_string.get()); - session_request_signal_id_ = SetupRequestResponseSignal( - portal_handle_.c_str(), OnSessionRequestResponseSignal); - - RTC_LOG(LS_INFO) << "Screen cast session requested."; - g_dbus_proxy_call(proxy_, "CreateSession", g_variant_new("(a{sv})", &builder), - G_DBUS_CALL_FLAGS_NONE, /*timeout=*/-1, cancellable_, - reinterpret_cast(OnSessionRequested), - this); +void ScreenCastPortal::SessionRequest(GDBusProxy* proxy) { + proxy_ = proxy; + connection_ = g_dbus_proxy_get_connection(proxy_); + SetupSessionRequestHandlers( + "webrtc", OnSessionRequested, OnSessionRequestResponseSignal, connection_, + proxy_, cancellable_, portal_handle_, session_request_signal_id_, this); } // static void ScreenCastPortal::OnSessionRequested(GDBusProxy* proxy, GAsyncResult* result, gpointer user_data) { - ScreenCastPortal* that = static_cast(user_data); - RTC_DCHECK(that); - - Scoped error; - Scoped variant( - g_dbus_proxy_call_finish(proxy, result, error.receive())); - if (!variant) { - if (g_error_matches(error.get(), G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - RTC_LOG(LS_ERROR) << "Failed to create a screen cast session: " - << error->message; - that->PortalFailed(RequestResponse::kError); - return; - } - RTC_LOG(LS_INFO) << "Initializing the screen cast session."; - - Scoped handle; - g_variant_get_child(variant.get(), 0, "o", &handle); - if (!handle) { - RTC_LOG(LS_ERROR) << "Failed to initialize the screen cast session."; - if (that->session_request_signal_id_) { - g_dbus_connection_signal_unsubscribe(that->connection_, - that->session_request_signal_id_); - that->session_request_signal_id_ = 0; - } - that->PortalFailed(RequestResponse::kError); - return; - } - - RTC_LOG(LS_INFO) << "Subscribing to the screen cast session."; + SessionRequestHandler(static_cast(user_data), proxy, + result, user_data); } // static @@ -210,30 +117,9 @@ void ScreenCastPortal::OnSessionRequestResponseSignal( gpointer user_data) { ScreenCastPortal* that = static_cast(user_data); RTC_DCHECK(that); - - RTC_LOG(LS_INFO) - << "Received response for the screen cast session subscription."; - - uint32_t portal_response; - Scoped response_data; - g_variant_get(parameters, "(u@a{sv})", &portal_response, - response_data.receive()); - Scoped session_handle( - g_variant_lookup_value(response_data.get(), "session_handle", nullptr)); - that->session_handle_ = g_variant_dup_string(session_handle.get(), nullptr); - - if (that->session_handle_.empty() || portal_response) { - RTC_LOG(LS_ERROR) - << "Failed to request the screen cast session subscription."; - that->PortalFailed(RequestResponse::kError); - return; - } - - that->session_closed_signal_id_ = g_dbus_connection_signal_subscribe( - that->connection_, kDesktopBusName, kSessionInterfaceName, "Closed", - that->session_handle_.c_str(), /*arg0=*/nullptr, G_DBUS_SIGNAL_FLAGS_NONE, - OnSessionClosedSignal, that, /*user_data_free_func=*/nullptr); - + SessionRequestResponseSignalHelper( + OnSessionClosedSignal, that, that->connection_, that->session_handle_, + parameters, that->session_closed_signal_id_); that->SourcesRequest(); } @@ -289,9 +175,10 @@ void ScreenCastPortal::SourcesRequest() { g_variant_builder_add(&builder, "{sv}", "handle_token", g_variant_new_string(variant_string.get())); - sources_handle_ = PrepareSignalHandle(connection_, variant_string.get()); + sources_handle_ = PrepareSignalHandle(variant_string.get(), connection_); sources_request_signal_id_ = SetupRequestResponseSignal( - sources_handle_.c_str(), OnSourcesRequestResponseSignal); + sources_handle_.c_str(), OnSourcesRequestResponseSignal, this, + connection_); RTC_LOG(LS_INFO) << "Requesting sources from the screen cast session."; g_dbus_proxy_call( @@ -364,66 +251,17 @@ void ScreenCastPortal::OnSourcesRequestResponseSignal( } void ScreenCastPortal::StartRequest() { - GVariantBuilder builder; - Scoped variant_string; - - g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT); - variant_string = g_strdup_printf("webrtc%d", g_random_int_range(0, G_MAXINT)); - g_variant_builder_add(&builder, "{sv}", "handle_token", - g_variant_new_string(variant_string.get())); - - start_handle_ = PrepareSignalHandle(connection_, variant_string.get()); - start_request_signal_id_ = SetupRequestResponseSignal( - start_handle_.c_str(), OnStartRequestResponseSignal); - - // "Identifier for the application window", this is Wayland, so not "x11:...". - const char parent_window[] = ""; - - RTC_LOG(LS_INFO) << "Starting the screen cast session."; - g_dbus_proxy_call(proxy_, "Start", - g_variant_new("(osa{sv})", session_handle_.c_str(), - parent_window, &builder), - G_DBUS_CALL_FLAGS_NONE, /*timeout=*/-1, cancellable_, - reinterpret_cast(OnStartRequested), - this); + StartSessionRequest("webrtc", session_handle_, OnStartRequestResponseSignal, + OnStartRequested, proxy_, connection_, cancellable_, + start_request_signal_id_, start_handle_, this); } // static void ScreenCastPortal::OnStartRequested(GDBusProxy* proxy, GAsyncResult* result, gpointer user_data) { - ScreenCastPortal* that = static_cast(user_data); - RTC_DCHECK(that); - - Scoped error; - Scoped variant( - g_dbus_proxy_call_finish(proxy, result, error.receive())); - if (!variant) { - if (g_error_matches(error.get(), G_IO_ERROR, G_IO_ERROR_CANCELLED)) - return; - RTC_LOG(LS_ERROR) << "Failed to start the screen cast session: " - << error->message; - that->PortalFailed(RequestResponse::kError); - return; - } - - RTC_LOG(LS_INFO) << "Initializing the start of the screen cast session."; - - Scoped handle; - g_variant_get_child(variant.get(), 0, "o", handle.receive()); - if (!handle) { - RTC_LOG(LS_ERROR) - << "Failed to initialize the start of the screen cast session."; - if (that->start_request_signal_id_) { - g_dbus_connection_signal_unsubscribe(that->connection_, - that->start_request_signal_id_); - that->start_request_signal_id_ = 0; - } - that->PortalFailed(RequestResponse::kError); - return; - } - - RTC_LOG(LS_INFO) << "Subscribed to the start signal."; + StartRequestedHandler(static_cast(user_data), proxy, + result); } // static @@ -525,8 +363,7 @@ void ScreenCastPortal::OnOpenPipeWireRemoteRequested(GDBusProxy* proxy, } that->notifier_->OnScreenCastRequestResult( - ScreenCastPortal::RequestResponse::kSuccess, that->pw_stream_node_id_, - that->pw_fd_); + RequestResponse::kSuccess, that->pw_stream_node_id_, that->pw_fd_); } } // namespace webrtc diff --git a/modules/desktop_capture/linux/wayland/screencast_portal.h b/modules/desktop_capture/linux/wayland/screencast_portal.h index fd6bb1d468..75884450db 100644 --- a/modules/desktop_capture/linux/wayland/screencast_portal.h +++ b/modules/desktop_capture/linux/wayland/screencast_portal.h @@ -15,7 +15,7 @@ #include -#include "absl/types/optional.h" +#include "modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.h" namespace webrtc { @@ -43,20 +43,9 @@ class ScreenCastPortal { }; // Interface that must be implemented by the ScreenCastPortal consumers. - enum class RequestResponse { - // Success, the request is carried out. - kSuccess, - // The user cancelled the interaction. - kUserCancelled, - // The user interaction was ended in some other way. - kError, - - kMaxValue = kError - }; - class PortalNotifier { public: - virtual void OnScreenCastRequestResult(RequestResponse result, + virtual void OnScreenCastRequestResult(xdg_portal::RequestResponse result, uint32_t stream_node_id, int fd) = 0; virtual void OnScreenCastSessionClosed() = 0; @@ -66,7 +55,7 @@ class ScreenCastPortal { virtual ~PortalNotifier() = default; }; - explicit ScreenCastPortal(CaptureSourceType source_type, + explicit ScreenCastPortal(ScreenCastPortal::CaptureSourceType source_type, PortalNotifier* notifier); ~ScreenCastPortal(); @@ -79,6 +68,14 @@ class ScreenCastPortal { // information in order to continue working with PipeWire. void Start(); + // Method to notify the reason for failure of a portal request. + void PortalFailed(xdg_portal::RequestResponse result); + + // Sends a create session request to the portal. + void SessionRequest(GDBusProxy* proxy); + + void UnsubscribeSignalHandlers(); + private: PortalNotifier* notifier_; @@ -104,19 +101,9 @@ class ScreenCastPortal { guint start_request_signal_id_ = 0; guint session_closed_signal_id_ = 0; - void PortalFailed(RequestResponse result); - - uint32_t SetupRequestResponseSignal(const char* object_path, - GDBusSignalCallback callback); - static void OnProxyRequested(GObject* object, GAsyncResult* result, gpointer user_data); - - static std::string PrepareSignalHandle(GDBusConnection* connection, - const char* token); - - void SessionRequest(); static void OnSessionRequested(GDBusProxy* proxy, GAsyncResult* result, gpointer user_data); diff --git a/modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.cc b/modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.cc new file mode 100644 index 0000000000..ca98044c97 --- /dev/null +++ b/modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.cc @@ -0,0 +1,169 @@ +/* + * Copyright 2022 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ +#include "modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.h" + +#include "modules/desktop_capture/linux/wayland/scoped_glib.h" +#include "rtc_base/logging.h" + +namespace webrtc { +namespace xdg_portal { + +std::string RequestResponseToString(RequestResponse request) { + switch (request) { + case RequestResponse::kSuccess: + return "kSuccess"; + case RequestResponse::kUserCancelled: + return "kUserCancelled"; + case RequestResponse::kError: + return "kError"; + default: + return "Uknown"; + } +} + +std::string PrepareSignalHandle(const char* token, + GDBusConnection* connection) { + Scoped sender( + g_strdup(g_dbus_connection_get_unique_name(connection) + 1)); + for (int i = 0; sender.get()[i]; ++i) { + if (sender.get()[i] == '.') { + sender.get()[i] = '_'; + } + } + const char* handle = g_strconcat(kDesktopRequestObjectPath, "/", sender.get(), + "/", token, /*end of varargs*/ nullptr); + return handle; +} + +uint32_t SetupRequestResponseSignal(const char* object_path, + const GDBusSignalCallback callback, + gpointer user_data, + GDBusConnection* connection) { + return g_dbus_connection_signal_subscribe( + connection, kDesktopBusName, kRequestInterfaceName, "Response", + object_path, /*arg0=*/nullptr, G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE, + callback, user_data, /*user_data_free_func=*/nullptr); +} + +void RequestSessionProxy(const char* interface_name, + const ProxyRequestCallback proxy_request_callback, + GCancellable* cancellable, + gpointer user_data) { + g_dbus_proxy_new_for_bus( + G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, /*info=*/nullptr, + kDesktopBusName, kDesktopObjectPath, interface_name, cancellable, + reinterpret_cast(proxy_request_callback), user_data); +} + +void SetupSessionRequestHandlers( + const std::string& portal_prefix, + const SessionRequestCallback session_request_callback, + const SessionRequestResponseSignalHandler request_response_signale_handler, + GDBusConnection* connection, + GDBusProxy* proxy, + GCancellable* cancellable, + std::string& portal_handle, + guint& session_request_signal_id, + gpointer user_data) { + GVariantBuilder builder; + Scoped variant_string; + + g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT); + variant_string = g_strdup_printf("%s_session%d", portal_prefix.c_str(), + g_random_int_range(0, G_MAXINT)); + g_variant_builder_add(&builder, "{sv}", "session_handle_token", + g_variant_new_string(variant_string.get())); + + variant_string = g_strdup_printf("%s_%d", portal_prefix.c_str(), + g_random_int_range(0, G_MAXINT)); + g_variant_builder_add(&builder, "{sv}", "handle_token", + g_variant_new_string(variant_string.get())); + + portal_handle = PrepareSignalHandle(variant_string.get(), connection); + session_request_signal_id = SetupRequestResponseSignal( + portal_handle.c_str(), request_response_signale_handler, user_data, + connection); + + RTC_LOG(LS_INFO) << "Desktop session requested."; + g_dbus_proxy_call( + proxy, "CreateSession", g_variant_new("(a{sv})", &builder), + G_DBUS_CALL_FLAGS_NONE, /*timeout=*/-1, cancellable, + reinterpret_cast(session_request_callback), + user_data); +} + +void StartSessionRequest( + const std::string& prefix, + const std::string session_handle, + const StartRequestResponseSignalHandler signal_handler, + const SessionStartRequestedHandler session_started_handler, + GDBusProxy* proxy, + GDBusConnection* connection, + GCancellable* cancellable, + guint& start_request_signal_id, + std::string& start_handle, + gpointer user_data) { + GVariantBuilder builder; + Scoped variant_string; + + g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT); + variant_string = + g_strdup_printf("%s%d", prefix.c_str(), g_random_int_range(0, G_MAXINT)); + g_variant_builder_add(&builder, "{sv}", "handle_token", + g_variant_new_string(variant_string.get())); + + start_handle = PrepareSignalHandle(variant_string.get(), connection); + start_request_signal_id = SetupRequestResponseSignal( + start_handle.c_str(), signal_handler, user_data, connection); + + // "Identifier for the application window", this is Wayland, so not "x11:...". + const char parent_window[] = ""; + + RTC_LOG(LS_INFO) << "Starting the portal session."; + g_dbus_proxy_call( + proxy, "Start", + g_variant_new("(osa{sv})", session_handle.c_str(), parent_window, + &builder), + G_DBUS_CALL_FLAGS_NONE, /*timeout=*/-1, cancellable, + reinterpret_cast(session_started_handler), + user_data); +} + +void TearDownSession(std::string session_handle, + GDBusProxy* proxy, + GCancellable* cancellable, + GDBusConnection* connection) { + if (!session_handle.empty()) { + Scoped message( + g_dbus_message_new_method_call(kDesktopBusName, session_handle.c_str(), + kSessionInterfaceName, "Close")); + if (message.get()) { + Scoped error; + g_dbus_connection_send_message(connection, message.get(), + G_DBUS_SEND_MESSAGE_FLAGS_NONE, + /*out_serial=*/nullptr, error.receive()); + if (error.get()) { + RTC_LOG(LS_ERROR) << "Failed to close the session: " << error->message; + } + } + } + + if (cancellable) { + g_cancellable_cancel(cancellable); + g_object_unref(cancellable); + } + + if (proxy) { + g_object_unref(proxy); + } +} + +} // namespace xdg_portal +} // namespace webrtc diff --git a/modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.h b/modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.h new file mode 100644 index 0000000000..9b7953424d --- /dev/null +++ b/modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.h @@ -0,0 +1,234 @@ +/* + * Copyright 2022 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_DESKTOP_CAPTURE_LINUX_WAYLAND_XDG_DESKTOP_PORTAL_UTILS_H_ +#define MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_XDG_DESKTOP_PORTAL_UTILS_H_ + +#include +#include + +#include +#include + +#include "modules/desktop_capture/linux/wayland/scoped_glib.h" +#include "rtc_base/checks.h" +#include "rtc_base/logging.h" + +namespace webrtc { +namespace xdg_portal { + +constexpr char kDesktopBusName[] = "org.freedesktop.portal.Desktop"; +constexpr char kDesktopObjectPath[] = "/org/freedesktop/portal/desktop"; +constexpr char kDesktopRequestObjectPath[] = + "/org/freedesktop/portal/desktop/request"; +constexpr char kSessionInterfaceName[] = "org.freedesktop.portal.Session"; +constexpr char kRequestInterfaceName[] = "org.freedesktop.portal.Request"; +constexpr char kScreenCastInterfaceName[] = "org.freedesktop.portal.ScreenCast"; + +using ProxyRequestCallback = void (*)(GObject*, GAsyncResult*, gpointer); +using SessionRequestCallback = void (*)(GDBusProxy*, GAsyncResult*, gpointer); +using SessionRequestResponseSignalHandler = void (*)(GDBusConnection*, + const char*, + const char*, + const char*, + const char*, + GVariant*, + gpointer); +using SessionRequestResponseSignalCallback = void (*)(std::string); +using SessionClosedSignalHandler = void (*)(GDBusConnection*, + const char*, + const char*, + const char*, + const char*, + GVariant*, + gpointer); +using StartRequestResponseSignalHandler = void (*)(GDBusConnection*, + const char*, + const char*, + const char*, + const char*, + GVariant*, + gpointer); +using SessionStartRequestedHandler = void (*)(GDBusProxy*, + GAsyncResult*, + gpointer); + +// Contains type of responses that can be observed when making a request to +// a desktop portal interface. +enum class RequestResponse { + // Success, the request is carried out. + kSuccess, + // The user cancelled the interaction. + kUserCancelled, + // The user interaction was ended in some other way. + kError, + + kMaxValue = kError, +}; + +std::string RequestResponseToString(RequestResponse request); + +// Returns a string path for signal handle based on the provided connection and +// token. +std::string PrepareSignalHandle(const char* token, GDBusConnection* connection); + +// Sets up the callback to execute when a response signal is received for the +// given object. +uint32_t SetupRequestResponseSignal(const char* object_path, + const GDBusSignalCallback callback, + gpointer user_data, + GDBusConnection* connection); + +void RequestSessionProxy(const char* interface_name, + const ProxyRequestCallback proxy_request_callback, + GCancellable* cancellable, + gpointer user_data); + +void SetupSessionRequestHandlers( + const std::string& portal_prefix, + const SessionRequestCallback session_request_callback, + const SessionRequestResponseSignalHandler request_response_signale_handler, + GDBusConnection* connection, + GDBusProxy* proxy, + GCancellable* cancellable, + std::string& portal_handle, + guint& session_request_signal_id, + gpointer user_data); + +void StartSessionRequest( + const std::string& prefix, + const std::string session_handle, + const StartRequestResponseSignalHandler signal_handler, + const SessionStartRequestedHandler session_started_handler, + GDBusProxy* proxy, + GDBusConnection* connection, + GCancellable* cancellable, + guint& start_request_signal_id, + std::string& start_handle, + gpointer user_data); + +// Tears down the portal session and cleans up related objects. +void TearDownSession(std::string session_handle, + GDBusProxy* proxy, + GCancellable* cancellable, + GDBusConnection* connection); + +template +void RequestSessionUsingProxy(T* portal, + GObject* gobject, + GAsyncResult* result) { + RTC_DCHECK(portal); + Scoped error; + GDBusProxy* proxy = g_dbus_proxy_new_finish(result, error.receive()); + if (!proxy) { + if (g_error_matches(error.get(), G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + RTC_LOG(LS_ERROR) << "Failed to get a proxy for the portal: " + << error->message; + portal->PortalFailed(RequestResponse::kError); + return; + } + + RTC_LOG(LS_INFO) << "Successfully created proxy for the portal."; + portal->SessionRequest(proxy); +} + +template +void SessionRequestHandler(T* portal, + GDBusProxy* proxy, + GAsyncResult* result, + gpointer user_data) { + RTC_DCHECK(portal); + + Scoped error; + Scoped variant( + g_dbus_proxy_call_finish(proxy, result, error.receive())); + if (!variant) { + if (g_error_matches(error.get(), G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + RTC_LOG(LS_ERROR) << "Failed to session: " << error->message; + portal->PortalFailed(RequestResponse::kError); + return; + } + + RTC_LOG(LS_INFO) << "Initializing the session."; + + Scoped handle; + g_variant_get_child(variant.get(), /*index=*/0, /*format_string=*/"o", + &handle); + if (!handle) { + RTC_LOG(LS_ERROR) << "Failed to initialize the session."; + portal->UnsubscribeSignalHandlers(); + portal->PortalFailed(RequestResponse::kError); + return; + } +} + +template +void SessionRequestResponseSignalHelper( + const SessionClosedSignalHandler session_close_signal_handler, + T* portal, + GDBusConnection* connection, + std::string& session_handle, + GVariant* parameters, + guint& session_closed_signal_id) { + uint32_t portal_response; + Scoped response_data; + g_variant_get(parameters, /*format_string=*/"(u@a{sv})", &portal_response, + response_data.receive()); + Scoped g_session_handle( + g_variant_lookup_value(response_data.get(), /*key=*/"session_handle", + /*expected_type=*/nullptr)); + session_handle = g_variant_dup_string( + /*value=*/g_session_handle.get(), /*length=*/nullptr); + + if (session_handle.empty() || portal_response) { + RTC_LOG(LS_ERROR) << "Failed to request the session subscription."; + portal->PortalFailed(RequestResponse::kError); + return; + } + + session_closed_signal_id = g_dbus_connection_signal_subscribe( + connection, kDesktopBusName, kSessionInterfaceName, /*member=*/"Closed", + session_handle.c_str(), /*arg0=*/nullptr, G_DBUS_SIGNAL_FLAGS_NONE, + session_close_signal_handler, portal, /*user_data_free_func=*/nullptr); +} + +template +void StartRequestedHandler(T* portal, GDBusProxy* proxy, GAsyncResult* result) { + RTC_DCHECK(portal); + Scoped error; + Scoped variant( + g_dbus_proxy_call_finish(proxy, result, error.receive())); + if (!variant) { + if (g_error_matches(error.get(), G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return; + RTC_LOG(LS_ERROR) << "Failed to start the portal session: " + << error->message; + portal->PortalFailed(RequestResponse::kError); + return; + } + + Scoped handle; + g_variant_get_child(variant.get(), 0, "o", handle.receive()); + if (!handle) { + RTC_LOG(LS_ERROR) << "Failed to initialize the start portal session."; + portal->UnsubscribeSignalHandlers(); + portal->PortalFailed(RequestResponse::kError); + return; + } + + RTC_LOG(LS_INFO) << "Subscribed to the start signal."; +} + +} // namespace xdg_portal +} // namespace webrtc + +#endif // MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_XDG_DESKTOP_PORTAL_UTILS_H_ From be74b8058be60096bed9423f218b64a4133e5bb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Fri, 18 Mar 2022 14:10:15 +0100 Subject: [PATCH 231/847] Fix spelling of receiver and transceiver. Bug: None Change-Id: I439e217d67283b182833e48da15af9ae367ac14e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256015 Reviewed-by: Harald Alvestrand Commit-Queue: Niels Moller Cr-Commit-Position: refs/heads/main@{#36257} --- media/sctp/usrsctp_transport.h | 2 +- media/sctp/usrsctp_transport_unittest.cc | 2 +- .../codecs/isac/fix/include/isacfix.h | 2 +- .../codecs/isac/fix/source/isacfix.c | 2 +- .../audio_coding/codecs/isac/main/include/isac.h | 2 +- .../audio_coding/codecs/isac/main/source/isac.c | 2 +- modules/audio_device/audio_device_buffer.h | 2 +- ...eceive_side_congestion_controller_unittest.cc | 4 ++-- .../source/rtcp_packet/loss_notification.h | 4 ++-- .../source/rtcp_transceiver_impl_unittest.cc | 2 +- pc/media_session_unittest.cc | 2 +- pc/sdp_offer_answer.h | 2 +- rtc_base/callback_list_unittest.cc | 2 +- rtc_tools/video_replay.cc | 4 ++-- sdk/objc/base/RTCVideoEncoder.h | 2 +- .../components/audio/RTCAudioSession+Private.h | 4 ++-- .../video/default_video_quality_analyzer_test.cc | 2 +- test/scenario/video_stream_unittest.cc | 2 +- video/rtp_video_stream_receiver.cc | 16 ++++++++-------- video/rtp_video_stream_receiver2.cc | 16 ++++++++-------- 20 files changed, 38 insertions(+), 38 deletions(-) diff --git a/media/sctp/usrsctp_transport.h b/media/sctp/usrsctp_transport.h index 2dd6abf9c5..7c7ce8c4a8 100644 --- a/media/sctp/usrsctp_transport.h +++ b/media/sctp/usrsctp_transport.h @@ -63,7 +63,7 @@ struct SctpInboundPacket; // 11. SctpTransport::OnDataFromSctpToTransport(data) // 12. SctpTransport::SignalDataReceived(data) // [from the same thread, methods registered/connected to -// SctpTransport are called with the recieved data] +// SctpTransport are called with the received data] class UsrsctpTransport : public SctpTransportInternal, public sigslot::has_slots<> { public: diff --git a/media/sctp/usrsctp_transport_unittest.cc b/media/sctp/usrsctp_transport_unittest.cc index 59e9c59b3d..8fdbabc14a 100644 --- a/media/sctp/usrsctp_transport_unittest.cc +++ b/media/sctp/usrsctp_transport_unittest.cc @@ -36,7 +36,7 @@ static const int kTransport2Port = 5002; namespace cricket { -// This is essentially a buffer to hold recieved data. It stores only the last +// This is essentially a buffer to hold received data. It stores only the last // received data. Calling OnDataReceived twice overwrites old data with the // newer one. // TODO(ldixon): Implement constraints, and allow new data to be added to old diff --git a/modules/audio_coding/codecs/isac/fix/include/isacfix.h b/modules/audio_coding/codecs/isac/fix/include/isacfix.h index 87956a6997..dcc7b0991d 100644 --- a/modules/audio_coding/codecs/isac/fix/include/isacfix.h +++ b/modules/audio_coding/codecs/isac/fix/include/isacfix.h @@ -394,7 +394,7 @@ int16_t WebRtcIsacfix_FreeInternal(ISACFIX_MainStruct* ISAC_main_inst); /**************************************************************************** * WebRtcIsacfix_GetNewBitStream(...) * - * This function returns encoded data, with the recieved bwe-index in the + * This function returns encoded data, with the received bwe-index in the * stream. It should always return a complete packet, i.e. only called once * even for 60 msec frames * diff --git a/modules/audio_coding/codecs/isac/fix/source/isacfix.c b/modules/audio_coding/codecs/isac/fix/source/isacfix.c index 9a66591de1..a7d44e883d 100644 --- a/modules/audio_coding/codecs/isac/fix/source/isacfix.c +++ b/modules/audio_coding/codecs/isac/fix/source/isacfix.c @@ -381,7 +381,7 @@ int WebRtcIsacfix_Encode(ISACFIX_MainStruct *ISAC_main_inst, /**************************************************************************** * WebRtcIsacfix_GetNewBitStream(...) * - * This function returns encoded data, with the recieved bwe-index in the + * This function returns encoded data, with the received bwe-index in the * stream. It should always return a complete packet, i.e. only called once * even for 60 msec frames * diff --git a/modules/audio_coding/codecs/isac/main/include/isac.h b/modules/audio_coding/codecs/isac/main/include/isac.h index f45bbb3897..3b05a8bcda 100644 --- a/modules/audio_coding/codecs/isac/main/include/isac.h +++ b/modules/audio_coding/codecs/isac/main/include/isac.h @@ -453,7 +453,7 @@ int16_t WebRtcIsac_SetEncSampRate(ISACStruct* ISAC_main_inst, /****************************************************************************** * WebRtcIsac_GetNewBitStream(...) * - * This function returns encoded data, with the recieved bwe-index in the + * This function returns encoded data, with the received bwe-index in the * stream. If the rate is set to a value less than bottleneck of codec * the new bistream will be re-encoded with the given target rate. * It should always return a complete packet, i.e. only called once diff --git a/modules/audio_coding/codecs/isac/main/source/isac.c b/modules/audio_coding/codecs/isac/main/source/isac.c index 73f132c228..456f447d9a 100644 --- a/modules/audio_coding/codecs/isac/main/source/isac.c +++ b/modules/audio_coding/codecs/isac/main/source/isac.c @@ -678,7 +678,7 @@ int WebRtcIsac_Encode(ISACStruct* ISAC_main_inst, /****************************************************************************** * WebRtcIsac_GetNewBitStream(...) * - * This function returns encoded data, with the recieved bwe-index in the + * This function returns encoded data, with the received bwe-index in the * stream. If the rate is set to a value less than bottleneck of codec * the new bistream will be re-encoded with the given target rate. * It should always return a complete packet, i.e. only called once diff --git a/modules/audio_device/audio_device_buffer.h b/modules/audio_device/audio_device_buffer.h index ea6ab9a93e..9a6a88a1be 100644 --- a/modules/audio_device/audio_device_buffer.h +++ b/modules/audio_device/audio_device_buffer.h @@ -228,7 +228,7 @@ class AudioDeviceBuffer { // being printed in the LogStats() task. bool log_stats_ RTC_GUARDED_BY(task_queue_); - // Used for converting capture timestaps (recieved from AudioRecordThread + // Used for converting capture timestaps (received from AudioRecordThread // via AudioRecordJni::DataIsRecorded) to RTC clock. rtc::TimestampAligner timestamp_aligner_; diff --git a/modules/congestion_controller/receive_side_congestion_controller_unittest.cc b/modules/congestion_controller/receive_side_congestion_controller_unittest.cc index 2aade06cbc..f2fd6d11d7 100644 --- a/modules/congestion_controller/receive_side_congestion_controller_unittest.cc +++ b/modules/congestion_controller/receive_side_congestion_controller_unittest.cc @@ -81,7 +81,7 @@ TEST(ReceiveSideCongestionControllerTest, } TEST(ReceiveSideCongestionControllerTest, ConvergesToCapacity) { - Scenario s("recieve_cc_unit/converge"); + Scenario s("receive_cc_unit/converge"); NetworkSimulationConfig net_conf; net_conf.bandwidth = DataRate::KilobitsPerSec(1000); net_conf.delay = TimeDelta::Millis(50); @@ -100,7 +100,7 @@ TEST(ReceiveSideCongestionControllerTest, ConvergesToCapacity) { } TEST(ReceiveSideCongestionControllerTest, IsFairToTCP) { - Scenario s("recieve_cc_unit/tcp_fairness"); + Scenario s("receive_cc_unit/tcp_fairness"); NetworkSimulationConfig net_conf; net_conf.bandwidth = DataRate::KilobitsPerSec(1000); net_conf.delay = TimeDelta::Millis(50); diff --git a/modules/rtp_rtcp/source/rtcp_packet/loss_notification.h b/modules/rtp_rtcp/source/rtcp_packet/loss_notification.h index b23008c528..0f70cf75c3 100644 --- a/modules/rtp_rtcp/source/rtcp_packet/loss_notification.h +++ b/modules/rtp_rtcp/source/rtcp_packet/loss_notification.h @@ -42,8 +42,8 @@ class LossNotification : public Psfb { // Set all of the values transmitted by the loss notification message. // If the values may not be represented by a loss notification message, // false is returned, and no change is made to the object; this happens - // when `last_recieved` is ahead of `last_decoded` by more than 0x7fff. - // This is because `last_recieved` is represented on the wire as a delta, + // when `last_received` is ahead of `last_decoded` by more than 0x7fff. + // This is because `last_received` is represented on the wire as a delta, // and only 15 bits are available for that delta. ABSL_MUST_USE_RESULT bool Set(uint16_t last_decoded, diff --git a/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc b/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc index e90cf047f2..ea6b49525a 100644 --- a/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc +++ b/modules/rtp_rtcp/source/rtcp_transceiver_impl_unittest.cc @@ -1405,7 +1405,7 @@ TEST(RtcpTransceiverImplTest, ParsesRemb) { } TEST(RtcpTransceiverImplTest, - CombinesReportBlocksFromSenderAndRecieverReports) { + CombinesReportBlocksFromSenderAndReceiverReports) { MockNetworkLinkRtcpObserver link_observer; RtcpTransceiverConfig config = DefaultTestConfig(); config.network_link_observer = &link_observer; diff --git a/pc/media_session_unittest.cc b/pc/media_session_unittest.cc index ee71c6ba7d..9d01e0772f 100644 --- a/pc/media_session_unittest.cc +++ b/pc/media_session_unittest.cc @@ -4405,7 +4405,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestSetAudioCodecs) { std::vector recv_codecs = MAKE_VECTOR(kAudioCodecs2); // The merged list of codecs should contain any send codecs that are also - // nominally in the recieve codecs list. Payload types should be picked from + // nominally in the receive codecs list. Payload types should be picked from // the send codecs and a number-of-channels of 0 and 1 should be equivalent // (set to 1). This equals what happens when the send codecs are used in an // offer and the receive codecs are used in the following answer. diff --git a/pc/sdp_offer_answer.h b/pc/sdp_offer_answer.h index a32ece930b..15c092723e 100644 --- a/pc/sdp_offer_answer.h +++ b/pc/sdp_offer_answer.h @@ -386,7 +386,7 @@ class SdpOfferAnswerHandler : public SdpStateProvider, // to the SDP semantics. void FillInMissingRemoteMids(cricket::SessionDescription* remote_description); - // Returns an RtpTransciever, if available, that can be used to receive the + // Returns an RtpTransceiver, if available, that can be used to receive the // given media type according to JSEP rules. rtc::scoped_refptr> FindAvailableTransceiverToReceive(cricket::MediaType media_type) const; diff --git a/rtc_base/callback_list_unittest.cc b/rtc_base/callback_list_unittest.cc index 23dfff0bdd..e2bc6d515e 100644 --- a/rtc_base/callback_list_unittest.cc +++ b/rtc_base/callback_list_unittest.cc @@ -17,7 +17,7 @@ namespace webrtc { namespace { -TEST(CallbackList, NoRecieverSingleMessageTest) { +TEST(CallbackList, NoReceiverSingleMessageTest) { CallbackList c; c.Send("message"); diff --git a/rtc_tools/video_replay.cc b/rtc_tools/video_replay.cc index c9fe40ffc3..c03cc6cbc4 100644 --- a/rtc_tools/video_replay.cc +++ b/rtc_tools/video_replay.cc @@ -312,7 +312,7 @@ class DecoderIvfFileWriter : public test::FakeDecoder { }; // The RtpReplayer is responsible for parsing the configuration provided by the -// user, setting up the windows, recieve streams and decoders and then replaying +// user, setting up the windows, receive streams and decoders and then replaying // the provided RTP dump. class RtpReplayer final { public: @@ -382,7 +382,7 @@ class RtpReplayer final { } private: - // Holds all the shared memory structures required for a recieve stream. This + // Holds all the shared memory structures required for a receive stream. This // structure is used to prevent members being deallocated before the replay // has been finished. struct StreamState { diff --git a/sdk/objc/base/RTCVideoEncoder.h b/sdk/objc/base/RTCVideoEncoder.h index 2b5c952afa..2445d432d6 100644 --- a/sdk/objc/base/RTCVideoEncoder.h +++ b/sdk/objc/base/RTCVideoEncoder.h @@ -50,7 +50,7 @@ RTC_OBJC_EXPORT scaled, all resolutions comply with 'resolutionAlignment'. */ @property(nonatomic, readonly) BOOL applyAlignmentToAllSimulcastLayers; -/** If YES, the reciever is expected to resample/scale the source texture to the expected output +/** If YES, the receiver is expected to resample/scale the source texture to the expected output size. */ @property(nonatomic, readonly) BOOL supportsNativeHandle; diff --git a/sdk/objc/components/audio/RTCAudioSession+Private.h b/sdk/objc/components/audio/RTCAudioSession+Private.h index 4f5107f7e9..2be1b9fb3d 100644 --- a/sdk/objc/components/audio/RTCAudioSession+Private.h +++ b/sdk/objc/components/audio/RTCAudioSession+Private.h @@ -73,10 +73,10 @@ NS_ASSUME_NONNULL_BEGIN /** Returns a configuration error with the given description. */ - (NSError *)configurationErrorWithDescription:(NSString *)description; -/** Notifies the reciever that a playout glitch was detected. */ +/** Notifies the receiver that a playout glitch was detected. */ - (void)notifyDidDetectPlayoutGlitch:(int64_t)totalNumberOfGlitches; -/** Notifies the reciever that there was an error when starting an audio unit. */ +/** Notifies the receiver that there was an error when starting an audio unit. */ - (void)notifyAudioUnitStartFailedWithError:(OSStatus)error; // Properties and methods for tests. diff --git a/test/pc/e2e/analyzer/video/default_video_quality_analyzer_test.cc b/test/pc/e2e/analyzer/video/default_video_quality_analyzer_test.cc index d5bc2cd3f2..ec2bf587ba 100644 --- a/test/pc/e2e/analyzer/video/default_video_quality_analyzer_test.cc +++ b/test/pc/e2e/analyzer/video/default_video_quality_analyzer_test.cc @@ -1074,7 +1074,7 @@ TEST(DefaultVideoQualityAnalyzerTest, } TEST(DefaultVideoQualityAnalyzerTest, - FrameCanBeReceivedByRecieverAfterItWasReceivedBySender) { + FrameCanBeReceivedByReceiverAfterItWasReceivedBySender) { std::unique_ptr frame_generator = test::CreateSquareFrameGenerator(kFrameWidth, kFrameHeight, /*type=*/absl::nullopt, diff --git a/test/scenario/video_stream_unittest.cc b/test/scenario/video_stream_unittest.cc index c1649a39b3..b37530dc50 100644 --- a/test/scenario/video_stream_unittest.cc +++ b/test/scenario/video_stream_unittest.cc @@ -70,7 +70,7 @@ TEST(VideoStreamTest, ReceivesFramesFromFileBasedStreams) { EXPECT_GE(frame_counts[1], expected_counts[1]); } -TEST(VideoStreamTest, RecievesVp8SimulcastFrames) { +TEST(VideoStreamTest, ReceivesVp8SimulcastFrames) { TimeDelta kRunTime = TimeDelta::Millis(500); int kFrameRate = 30; diff --git a/video/rtp_video_stream_receiver.cc b/video/rtp_video_stream_receiver.cc index bcee8350b1..093a232907 100644 --- a/video/rtp_video_stream_receiver.cc +++ b/video/rtp_video_stream_receiver.cc @@ -1110,18 +1110,18 @@ bool RtpVideoStreamReceiver::DeliverRtcp(const uint8_t* rtcp_packet, uint32_t ntp_secs = 0; uint32_t ntp_frac = 0; uint32_t rtp_timestamp = 0; - uint32_t recieved_ntp_secs = 0; - uint32_t recieved_ntp_frac = 0; - if (rtp_rtcp_->RemoteNTP(&ntp_secs, &ntp_frac, &recieved_ntp_secs, - &recieved_ntp_frac, &rtp_timestamp) != 0) { + uint32_t received_ntp_secs = 0; + uint32_t received_ntp_frac = 0; + if (rtp_rtcp_->RemoteNTP(&ntp_secs, &ntp_frac, &received_ntp_secs, + &received_ntp_frac, &rtp_timestamp) != 0) { // Waiting for RTCP. return true; } - NtpTime recieved_ntp(recieved_ntp_secs, recieved_ntp_frac); - int64_t time_since_recieved = - clock_->CurrentNtpInMilliseconds() - recieved_ntp.ToMs(); + NtpTime received_ntp(received_ntp_secs, received_ntp_frac); + int64_t time_since_received = + clock_->CurrentNtpInMilliseconds() - received_ntp.ToMs(); // Don't use old SRs to estimate time. - if (time_since_recieved <= 1) { + if (time_since_received <= 1) { ntp_estimator_.UpdateRtcpTimestamp(rtt, ntp_secs, ntp_frac, rtp_timestamp); absl::optional remote_to_local_clock_offset_ms = ntp_estimator_.EstimateRemoteToLocalClockOffsetMs(); diff --git a/video/rtp_video_stream_receiver2.cc b/video/rtp_video_stream_receiver2.cc index c5594ba96e..5e9788ecf9 100644 --- a/video/rtp_video_stream_receiver2.cc +++ b/video/rtp_video_stream_receiver2.cc @@ -1028,18 +1028,18 @@ bool RtpVideoStreamReceiver2::DeliverRtcp(const uint8_t* rtcp_packet, uint32_t ntp_secs = 0; uint32_t ntp_frac = 0; uint32_t rtp_timestamp = 0; - uint32_t recieved_ntp_secs = 0; - uint32_t recieved_ntp_frac = 0; - if (rtp_rtcp_->RemoteNTP(&ntp_secs, &ntp_frac, &recieved_ntp_secs, - &recieved_ntp_frac, &rtp_timestamp) != 0) { + uint32_t received_ntp_secs = 0; + uint32_t received_ntp_frac = 0; + if (rtp_rtcp_->RemoteNTP(&ntp_secs, &ntp_frac, &received_ntp_secs, + &received_ntp_frac, &rtp_timestamp) != 0) { // Waiting for RTCP. return true; } - NtpTime recieved_ntp(recieved_ntp_secs, recieved_ntp_frac); - int64_t time_since_recieved = - clock_->CurrentNtpInMilliseconds() - recieved_ntp.ToMs(); + NtpTime received_ntp(received_ntp_secs, received_ntp_frac); + int64_t time_since_received = + clock_->CurrentNtpInMilliseconds() - received_ntp.ToMs(); // Don't use old SRs to estimate time. - if (time_since_recieved <= 1) { + if (time_since_received <= 1) { ntp_estimator_.UpdateRtcpTimestamp(rtt, ntp_secs, ntp_frac, rtp_timestamp); absl::optional remote_to_local_clock_offset_ms = ntp_estimator_.EstimateRemoteToLocalClockOffsetMs(); From 3c60f2d31c7d43d0f6fb3ab50bbfbce058f25ae2 Mon Sep 17 00:00:00 2001 From: Diep Bui Date: Thu, 17 Mar 2022 21:28:45 +0000 Subject: [PATCH 232/847] Change the default value of bandwidth_backoff_factor to 1.0. The default backoff behavior of loss based 2.0 should remain the same. Bug: webrtc:12707 Change-Id: Ica7b8da26c11317a6cb7cd9272c07d03d066f30b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256005 Reviewed-by: Per Kjellander Commit-Queue: Diep Bui Cr-Commit-Position: refs/heads/main@{#36258} --- modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 147c2107ab..03822e1710 100644 --- a/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc +++ b/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc @@ -267,7 +267,7 @@ absl::optional LossBasedBweV2::CreateConfig( FieldTrialParameter temporal_weight_factor("TemporalWeightFactor", 0.99); FieldTrialParameter bandwidth_backoff_lower_bound_factor( - "BwBackoffLowerBoundFactor", 0.85); + "BwBackoffLowerBoundFactor", 1.0); FieldTrialParameter trendline_integration_enabled( "TrendlineIntegrationEnabled", false); FieldTrialParameter delay_based_limit_factor("DelayBasedLimitFactor", From 66eb789b41232ecedcca61b987d0860f990938b1 Mon Sep 17 00:00:00 2001 From: Jonas Oreland Date: Fri, 18 Mar 2022 15:04:36 +0100 Subject: [PATCH 233/847] Add class for pointer or owned object. To be used as part of field trial conversion effort. Bug: webrtc:10335 Change-Id: Iaeff520d5a83331926ead945c9e414716e61cac8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256013 Reviewed-by: Niels Moller Reviewed-by: Tomas Gunnarsson Reviewed-by: Harald Alvestrand Commit-Queue: Jonas Oreland Cr-Commit-Position: refs/heads/main@{#36259} --- rtc_base/memory/BUILD.gn | 4 +++ rtc_base/memory/always_valid_pointer.h | 40 ++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 rtc_base/memory/always_valid_pointer.h diff --git a/rtc_base/memory/BUILD.gn b/rtc_base/memory/BUILD.gn index ee66ac0df8..583278ee6e 100644 --- a/rtc_base/memory/BUILD.gn +++ b/rtc_base/memory/BUILD.gn @@ -53,3 +53,7 @@ rtc_library("unittests") { "../../test:test_support", ] } + +rtc_source_set("always_valid_pointer") { + sources = [ "always_valid_pointer.h" ] +} diff --git a/rtc_base/memory/always_valid_pointer.h b/rtc_base/memory/always_valid_pointer.h new file mode 100644 index 0000000000..c73512d3c5 --- /dev/null +++ b/rtc_base/memory/always_valid_pointer.h @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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_MEMORY_ALWAYS_VALID_POINTER_H_ +#define RTC_BASE_MEMORY_ALWAYS_VALID_POINTER_H_ + +#include + +namespace webrtc { + +// This template allows the instantiation of a pointer to Interface in such a +// way that if it is passed a null pointer, an object of class Default will be +// created, which will be deallocated when the pointer is deleted. +template +class AlwaysValidPointer { + public: + explicit AlwaysValidPointer(Interface* pointer) + : owned_instance_(pointer ? nullptr : std::make_unique()), + pointer_(pointer ? pointer : owned_instance_.get()) { + RTC_DCHECK(pointer_); + } + + Interface* get() { return pointer_; } + Interface* operator->() { return pointer_; } + Interface& operator*() { return *pointer_; } + + private: + const std::unique_ptr owned_instance_; + Interface* const pointer_; +}; + +} // namespace webrtc + +#endif // RTC_BASE_MEMORY_ALWAYS_VALID_POINTER_H_ From 7bd06dda3c9e057df99e743679116e12dfbc738e Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Fri, 18 Mar 2022 07:06:45 -0700 Subject: [PATCH 234/847] Roll chromium_revision 7fc7e127cd..176855dcc8 (982354:982693) Change log: https://chromium.googlesource.com/chromium/src/+log/7fc7e127cd..176855dcc8 Full diff: https://chromium.googlesource.com/chromium/src/+/7fc7e127cd..176855dcc8 Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/68127bb5f9..ad8d9a01a5 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/3accbb4b4d..0e41ee9abf * src/buildtools: https://chromium.googlesource.com/chromium/src/buildtools/+log/f0259e64a3..d8c375426d * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/dbde37f9b8..332d8dee2d * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/cb66ad8363..4c179bb28c * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/a3813e6a9a..fc55284d0c * src/third_party/android_build_tools/aapt2: yQIf5Ev_-q9u6Pr_a0APd1dHcImJSmotVADw4Pj151QC..wicn5Ce1ay6ivbZ1GNFF0gRSS3NYv_7hJTPtVga3O-QC * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/4cc26bd5a0..389f33bb40 * src/third_party/dav1d/libdav1d: https://chromium.googlesource.com/external/github.com/videolan/dav1d.git/+log/b1a5189c9d..56e7ffc0db * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/950a6b4225..76979dae56 * src/third_party/freetype/src: https://chromium.googlesource.com/chromium/src/third_party/freetype2.git/+log/1e2eb65048..53dfdcd819 * src/third_party/icu: https://chromium.googlesource.com/chromium/deps/icu.git/+log/8a5b728e4f..ea8c08d878 * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/a2dabf80a3..9b8eaa21f1 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/91235624de..4b90fc63cc DEPS diff: https://chromium.googlesource.com/chromium/src/+/7fc7e127cd..176855dcc8/DEPS No update to Clang. BUG=None Change-Id: Icf50126e0a84cdd676f26d76c1987f5f49e7e369 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256050 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36260} --- DEPS | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/DEPS b/DEPS index 6ab319705b..cfdcadcaf3 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': '7fc7e127cd14edd614a894a46b94926e9c6a5588', + 'chromium_revision': '176855dcc8b016411806e6b5380f39b061aba57f', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,24 +23,24 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@68127bb5f98da9dad19ee394187229391f369303', + 'https://chromium.googlesource.com/chromium/src/base@ad8d9a01a5acc611e0fb335c5f180afc995f77c7', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@3accbb4b4d6a8293b1e2214948955757e626ed2a', + 'https://chromium.googlesource.com/chromium/src/build@0e41ee9abfdfe163bc93c4ce19d17c92f6b0e6e2', 'src/buildtools': - 'https://chromium.googlesource.com/chromium/src/buildtools@f0259e64a3c238824b3323ced30edb2f45c63c8d', + 'https://chromium.googlesource.com/chromium/src/buildtools@d8c375426d8f7f4147f7d4109bb63c12655fb8d6', # 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@dbde37f9b8cb2f5e6ad9440955b7381e5a842b16', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@332d8dee2dcb4742ab45458f380082c262c41428', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@cb66ad83632584f17b24f113a0ec3a3d36d79976', + 'https://chromium.googlesource.com/chromium/src/testing@4c179bb28c6e90c45291f1225700ad34e18ebeb8', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@a3813e6a9a285502ebb677ab29d0c3bdb6363c62', + 'https://chromium.googlesource.com/chromium/src/third_party@fc55284d0c7a6878725513fb3b7ddccb02003f74', 'src/buildtools/linux64': { 'packages': [ @@ -117,7 +117,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/android_build_tools/aapt2', - 'version': 'yQIf5Ev_-q9u6Pr_a0APd1dHcImJSmotVADw4Pj151QC', + 'version': 'wicn5Ce1ay6ivbZ1GNFF0gRSS3NYv_7hJTPtVga3O-QC', }, ], 'condition': 'checkout_android', @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@4cc26bd5a059cf275feff2c934f744617dd26e8c', + 'https://chromium.googlesource.com/catapult.git@389f33bb40a3345b73a68613178c789476ceaecf', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@950a6b4225ed3280aa0fbca2de51bfbaecd7695a', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@76979dae56c08d24b092347a1bdd2abe474555a3', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -165,7 +165,7 @@ deps = { 'condition': 'checkout_linux', }, 'src/third_party/freetype/src': - 'https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@1e2eb65048f75c64b68708efed6ce904c31f3b2f', + 'https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@53dfdcd8198d2b3201a23c4bad9190519ba918db', 'src/third_party/harfbuzz-ng/src': 'https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git@965cf1d66589b0db60e75961cc58f5a65521078e', 'src/third_party/google_benchmark/src': { @@ -187,7 +187,7 @@ deps = { 'src/third_party/googletest/src': 'https://chromium.googlesource.com/external/github.com/google/googletest.git@b007c54f2944e193ac44fba1bc997cb65826a0b9', 'src/third_party/icu': { - 'url': 'https://chromium.googlesource.com/chromium/deps/icu.git@8a5b728e4f43b0eabdb9ea450f956d67cfb22719', + 'url': 'https://chromium.googlesource.com/chromium/deps/icu.git@ea8c08d8783fceda86c19618694881149e23f305', }, 'src/third_party/jdk': { 'packages': [ @@ -223,7 +223,7 @@ deps = { 'src/third_party/libsrtp': 'https://chromium.googlesource.com/chromium/deps/libsrtp.git@5b7c744eb8310250ccc534f3f86a2015b3887a0a', 'src/third_party/dav1d/libdav1d': - 'https://chromium.googlesource.com/external/github.com/videolan/dav1d.git@b1a5189c9d37c837099ce50852b6ce9597b89b0c', + 'https://chromium.googlesource.com/external/github.com/videolan/dav1d.git@56e7ffc0dbe44970a4d55ec2241824c67add9dd5', 'src/third_party/libaom/source/libaom': 'https://aomedia.googlesource.com/aom.git@ee1ed1ccf2b9ecedd6aee438eafc7cc61c23342d', 'src/third_party/libunwindstack': { @@ -231,7 +231,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@a2dabf80a38b16846d9a3209d61f452a1bfc8f15', + 'https://android.googlesource.com/platform/external/perfetto.git@9b8eaa21f16d10cffefdf758a8b900e014e4788d', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -288,7 +288,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@91235624dec195f243cca3cedd3b8a4b3b4f02b8', + 'https://chromium.googlesource.com/chromium/src/tools@4b90fc63cc138bd63ed66f2dfdefae2e82dbf0fd', 'src/third_party/accessibility_test_framework': { 'packages': [ From 0d5ce62d015cdb69a21d11171e9f01f2d32bfce7 Mon Sep 17 00:00:00 2001 From: Tomas Gunnarsson Date: Fri, 18 Mar 2022 15:57:15 +0100 Subject: [PATCH 235/847] Make RtpTransceiver not inherit from RefCountedObject. Also update API proxy Create() factory functions to accept the inner reference counted object via scoped_refptr instead of a raw pointer. This is to avoid accidentally creating and deleting an object when passing an inner object to a proxy class. Consider something like: auto proxy = MyProxy::Create( signaling_thread(), make_ref_counted()); Bug: webrtc:13464, webrtc:12701 Change-Id: I55ccfff43bbc164a5e909b2c9020e306ebb09075 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256010 Reviewed-by: Niels Moller Commit-Queue: Tomas Gunnarsson Cr-Commit-Position: refs/heads/main@{#36261} --- pc/peer_connection.cc | 6 +- pc/proxy.h | 58 ++++----- pc/proxy_unittest.cc | 6 +- pc/rtp_transceiver.h | 6 +- pc/rtp_transceiver_unittest.cc | 157 ++++++++++++----------- pc/rtp_transmission_manager.cc | 2 +- pc/sctp_data_channel.cc | 7 +- pc/test/fake_peer_connection_for_stats.h | 3 +- pc/video_track.cc | 5 +- pc/video_track_source_proxy.cc | 4 +- 10 files changed, 130 insertions(+), 124 deletions(-) diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc index fb1f86c007..e5a83b0a18 100644 --- a/pc/peer_connection.cc +++ b/pc/peer_connection.cc @@ -649,11 +649,13 @@ RTCError PeerConnection::Initialize( rtp_manager()->transceivers()->Add( RtpTransceiverProxyWithInternal::Create( signaling_thread(), - new RtpTransceiver(cricket::MEDIA_TYPE_AUDIO, channel_manager()))); + rtc::make_ref_counted(cricket::MEDIA_TYPE_AUDIO, + channel_manager()))); rtp_manager()->transceivers()->Add( RtpTransceiverProxyWithInternal::Create( signaling_thread(), - new RtpTransceiver(cricket::MEDIA_TYPE_VIDEO, channel_manager()))); + rtc::make_ref_counted(cricket::MEDIA_TYPE_VIDEO, + channel_manager()))); } int delay_ms = configuration.report_usage_pattern_delay_ms diff --git a/pc/proxy.h b/pc/proxy.h index feeb06338e..2c347d6249 100644 --- a/pc/proxy.h +++ b/pc/proxy.h @@ -227,26 +227,26 @@ class ConstMethodCall : public QueuedTask { constexpr char class_name##ProxyWithInternal::proxy_name_[]; // clang-format on -#define PRIMARY_PROXY_MAP_BOILERPLATE(class_name) \ - protected: \ - class_name##ProxyWithInternal(rtc::Thread* primary_thread, \ - INTERNAL_CLASS* c) \ - : primary_thread_(primary_thread), c_(c) {} \ - \ - private: \ +#define PRIMARY_PROXY_MAP_BOILERPLATE(class_name) \ + protected: \ + class_name##ProxyWithInternal(rtc::Thread* primary_thread, \ + rtc::scoped_refptr c) \ + : primary_thread_(primary_thread), c_(std::move(c)) {} \ + \ + private: \ mutable rtc::Thread* primary_thread_; -#define SECONDARY_PROXY_MAP_BOILERPLATE(class_name) \ - protected: \ - class_name##ProxyWithInternal(rtc::Thread* primary_thread, \ - rtc::Thread* secondary_thread, \ - INTERNAL_CLASS* c) \ - : primary_thread_(primary_thread), \ - secondary_thread_(secondary_thread), \ - c_(c) {} \ - \ - private: \ - mutable rtc::Thread* primary_thread_; \ +#define SECONDARY_PROXY_MAP_BOILERPLATE(class_name) \ + protected: \ + class_name##ProxyWithInternal(rtc::Thread* primary_thread, \ + rtc::Thread* secondary_thread, \ + rtc::scoped_refptr c) \ + : primary_thread_(primary_thread), \ + secondary_thread_(secondary_thread), \ + c_(std::move(c)) {} \ + \ + private: \ + mutable rtc::Thread* primary_thread_; \ mutable rtc::Thread* secondary_thread_; // Note that the destructor is protected so that the proxy can only be @@ -284,15 +284,15 @@ class ConstMethodCall : public QueuedTask { void DestroyInternal() { delete c_; } \ INTERNAL_CLASS* c_; -#define BEGIN_PRIMARY_PROXY_MAP(class_name) \ - PROXY_MAP_BOILERPLATE(class_name) \ - PRIMARY_PROXY_MAP_BOILERPLATE(class_name) \ - REFCOUNTED_PROXY_MAP_BOILERPLATE(class_name) \ - public: \ - static rtc::scoped_refptr Create( \ - rtc::Thread* primary_thread, INTERNAL_CLASS* c) { \ - return rtc::make_ref_counted( \ - primary_thread, c); \ +#define BEGIN_PRIMARY_PROXY_MAP(class_name) \ + PROXY_MAP_BOILERPLATE(class_name) \ + PRIMARY_PROXY_MAP_BOILERPLATE(class_name) \ + REFCOUNTED_PROXY_MAP_BOILERPLATE(class_name) \ + public: \ + static rtc::scoped_refptr Create( \ + rtc::Thread* primary_thread, rtc::scoped_refptr c) { \ + return rtc::make_ref_counted( \ + primary_thread, std::move(c)); \ } #define BEGIN_PROXY_MAP(class_name) \ @@ -302,9 +302,9 @@ class ConstMethodCall : public QueuedTask { public: \ static rtc::scoped_refptr Create( \ rtc::Thread* primary_thread, rtc::Thread* secondary_thread, \ - INTERNAL_CLASS* c) { \ + rtc::scoped_refptr c) { \ return rtc::make_ref_counted( \ - primary_thread, secondary_thread, c); \ + primary_thread, secondary_thread, std::move(c)); \ } #define PROXY_PRIMARY_THREAD_DESTRUCTOR() \ diff --git a/pc/proxy_unittest.cc b/pc/proxy_unittest.cc index ab02359d53..48c087f690 100644 --- a/pc/proxy_unittest.cc +++ b/pc/proxy_unittest.cc @@ -98,7 +98,7 @@ class SignalingProxyTest : public ::testing::Test { ASSERT_TRUE(signaling_thread_->Start()); fake_ = Fake::Create(); fake_signaling_proxy_ = - FakeSignalingProxy::Create(signaling_thread_.get(), fake_.get()); + FakeSignalingProxy::Create(signaling_thread_.get(), fake_); } protected: @@ -186,8 +186,8 @@ class ProxyTest : public ::testing::Test { ASSERT_TRUE(signaling_thread_->Start()); ASSERT_TRUE(worker_thread_->Start()); fake_ = Fake::Create(); - fake_proxy_ = FakeProxy::Create(signaling_thread_.get(), - worker_thread_.get(), fake_.get()); + fake_proxy_ = + FakeProxy::Create(signaling_thread_.get(), worker_thread_.get(), fake_); } protected: diff --git a/pc/rtp_transceiver.h b/pc/rtp_transceiver.h index e7e3fb9be1..e71fdc1695 100644 --- a/pc/rtp_transceiver.h +++ b/pc/rtp_transceiver.h @@ -39,7 +39,6 @@ #include "pc/rtp_sender_proxy.h" #include "pc/rtp_transport_internal.h" #include "pc/session_description.h" -#include "rtc_base/ref_counted_object.h" #include "rtc_base/task_utils/pending_task_safety_flag.h" #include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread_annotations.h" @@ -76,9 +75,8 @@ namespace webrtc { // MediaType specified in the constructor. Audio RtpTransceivers will have // AudioRtpSenders, AudioRtpReceivers, and a VoiceChannel. Video RtpTransceivers // will have VideoRtpSenders, VideoRtpReceivers, and a VideoChannel. -class RtpTransceiver final - : public rtc::RefCountedObject, - public sigslot::has_slots<> { +class RtpTransceiver : public RtpTransceiverInterface, + public sigslot::has_slots<> { public: // Construct a Plan B-style RtpTransceiver with no senders, receivers, or // channel set. diff --git a/pc/rtp_transceiver_unittest.cc b/pc/rtp_transceiver_unittest.cc index e5c7733178..9c2a0461b3 100644 --- a/pc/rtp_transceiver_unittest.cc +++ b/pc/rtp_transceiver_unittest.cc @@ -52,7 +52,8 @@ class ChannelManagerForTest : public cricket::ChannelManager { TEST(RtpTransceiverTest, CannotSetChannelOnStoppedTransceiver) { ChannelManagerForTest cm; const std::string content_name("my_mid"); - RtpTransceiver transceiver(cricket::MediaType::MEDIA_TYPE_AUDIO, &cm); + auto transceiver = rtc::make_ref_counted( + cricket::MediaType::MEDIA_TYPE_AUDIO, &cm); cricket::MockChannelInterface channel1; EXPECT_CALL(channel1, media_type()) .WillRepeatedly(Return(cricket::MediaType::MEDIA_TYPE_AUDIO)); @@ -60,35 +61,37 @@ TEST(RtpTransceiverTest, CannotSetChannelOnStoppedTransceiver) { EXPECT_CALL(channel1, SetFirstPacketReceivedCallback(_)); EXPECT_CALL(channel1, SetRtpTransport(_)).WillRepeatedly(Return(true)); - transceiver.SetChannel(&channel1, [&](const std::string& mid) { + transceiver->SetChannel(&channel1, [&](const std::string& mid) { EXPECT_EQ(mid, content_name); return nullptr; }); - EXPECT_EQ(&channel1, transceiver.channel()); + EXPECT_EQ(&channel1, transceiver->channel()); // Stop the transceiver. - transceiver.StopInternal(); - EXPECT_EQ(&channel1, transceiver.channel()); + transceiver->StopInternal(); + EXPECT_EQ(&channel1, transceiver->channel()); cricket::MockChannelInterface channel2; EXPECT_CALL(channel2, media_type()) .WillRepeatedly(Return(cricket::MediaType::MEDIA_TYPE_AUDIO)); // Channel can no longer be set, so this call should be a no-op. - transceiver.SetChannel(&channel2, [](const std::string&) { return nullptr; }); - EXPECT_EQ(&channel1, transceiver.channel()); + transceiver->SetChannel(&channel2, + [](const std::string&) { return nullptr; }); + EXPECT_EQ(&channel1, transceiver->channel()); // Clear the current channel before `transceiver` goes out of scope. EXPECT_CALL(channel1, SetFirstPacketReceivedCallback(_)); EXPECT_CALL(cm, DestroyChannel(&channel1)).WillRepeatedly(testing::Return()); - transceiver.SetChannel(nullptr, nullptr); + transceiver->SetChannel(nullptr, nullptr); } // Checks that a channel can be unset on a stopped `RtpTransceiver` TEST(RtpTransceiverTest, CanUnsetChannelOnStoppedTransceiver) { ChannelManagerForTest cm; const std::string content_name("my_mid"); - RtpTransceiver transceiver(cricket::MediaType::MEDIA_TYPE_VIDEO, &cm); + auto transceiver = rtc::make_ref_counted( + cricket::MediaType::MEDIA_TYPE_VIDEO, &cm); cricket::MockChannelInterface channel; EXPECT_CALL(channel, media_type()) .WillRepeatedly(Return(cricket::MediaType::MEDIA_TYPE_VIDEO)); @@ -98,34 +101,35 @@ TEST(RtpTransceiverTest, CanUnsetChannelOnStoppedTransceiver) { EXPECT_CALL(channel, SetRtpTransport(_)).WillRepeatedly(Return(true)); EXPECT_CALL(cm, DestroyChannel(&channel)).WillRepeatedly(testing::Return()); - transceiver.SetChannel(&channel, [&](const std::string& mid) { + transceiver->SetChannel(&channel, [&](const std::string& mid) { EXPECT_EQ(mid, content_name); return nullptr; }); - EXPECT_EQ(&channel, transceiver.channel()); + EXPECT_EQ(&channel, transceiver->channel()); // Stop the transceiver. - transceiver.StopInternal(); - EXPECT_EQ(&channel, transceiver.channel()); + transceiver->StopInternal(); + EXPECT_EQ(&channel, transceiver->channel()); // Set the channel to `nullptr`. - transceiver.SetChannel(nullptr, nullptr); - EXPECT_EQ(nullptr, transceiver.channel()); + transceiver->SetChannel(nullptr, nullptr); + EXPECT_EQ(nullptr, transceiver->channel()); } class RtpTransceiverUnifiedPlanTest : public ::testing::Test { public: RtpTransceiverUnifiedPlanTest() - : transceiver_(RtpSenderProxyWithInternal::Create( - rtc::Thread::Current(), - sender_), - RtpReceiverProxyWithInternal::Create( - rtc::Thread::Current(), - rtc::Thread::Current(), - receiver_), - &channel_manager_, - channel_manager_.GetSupportedAudioRtpHeaderExtensions(), - /* on_negotiation_needed= */ [] {}) {} + : transceiver_(rtc::make_ref_counted( + RtpSenderProxyWithInternal::Create( + rtc::Thread::Current(), + sender_), + RtpReceiverProxyWithInternal::Create( + rtc::Thread::Current(), + rtc::Thread::Current(), + receiver_), + &channel_manager_, + channel_manager_.GetSupportedAudioRtpHeaderExtensions(), + /* on_negotiation_needed= */ [] {})) {} static rtc::scoped_refptr MockReceiver() { auto receiver = rtc::make_ref_counted(); @@ -144,7 +148,7 @@ class RtpTransceiverUnifiedPlanTest : public ::testing::Test { rtc::scoped_refptr receiver_ = MockReceiver(); rtc::scoped_refptr sender_ = MockSender(); ChannelManagerForTest channel_manager_; - RtpTransceiver transceiver_; + rtc::scoped_refptr transceiver_; }; // Basic tests for Stop() @@ -154,16 +158,16 @@ TEST_F(RtpTransceiverUnifiedPlanTest, StopSetsDirection) { EXPECT_CALL(*sender_.get(), SetTransceiverAsStopped()); EXPECT_CALL(*sender_.get(), Stop()); - EXPECT_EQ(RtpTransceiverDirection::kInactive, transceiver_.direction()); - EXPECT_FALSE(transceiver_.current_direction()); - transceiver_.StopStandard(); - EXPECT_EQ(RtpTransceiverDirection::kStopped, transceiver_.direction()); - EXPECT_FALSE(transceiver_.current_direction()); - transceiver_.StopTransceiverProcedure(); - EXPECT_TRUE(transceiver_.current_direction()); - EXPECT_EQ(RtpTransceiverDirection::kStopped, transceiver_.direction()); + EXPECT_EQ(RtpTransceiverDirection::kInactive, transceiver_->direction()); + EXPECT_FALSE(transceiver_->current_direction()); + transceiver_->StopStandard(); + EXPECT_EQ(RtpTransceiverDirection::kStopped, transceiver_->direction()); + EXPECT_FALSE(transceiver_->current_direction()); + transceiver_->StopTransceiverProcedure(); + EXPECT_TRUE(transceiver_->current_direction()); + EXPECT_EQ(RtpTransceiverDirection::kStopped, transceiver_->direction()); EXPECT_EQ(RtpTransceiverDirection::kStopped, - *transceiver_.current_direction()); + *transceiver_->current_direction()); } class RtpTransceiverTestForHeaderExtensions : public ::testing::Test { @@ -182,16 +186,17 @@ class RtpTransceiverTestForHeaderExtensions : public ::testing::Test { RtpHeaderExtensionCapability(RtpExtension::kVideoRotationUri, 4, RtpTransceiverDirection::kSendRecv)}), - transceiver_(RtpSenderProxyWithInternal::Create( - rtc::Thread::Current(), - sender_), - RtpReceiverProxyWithInternal::Create( - rtc::Thread::Current(), - rtc::Thread::Current(), - receiver_), - &channel_manager_, - extensions_, - /* on_negotiation_needed= */ [] {}) {} + transceiver_(rtc::make_ref_counted( + RtpSenderProxyWithInternal::Create( + rtc::Thread::Current(), + sender_), + RtpReceiverProxyWithInternal::Create( + rtc::Thread::Current(), + rtc::Thread::Current(), + receiver_), + &channel_manager_, + extensions_, + /* on_negotiation_needed= */ [] {})) {} static rtc::scoped_refptr MockReceiver() { auto receiver = rtc::make_ref_counted(); @@ -212,7 +217,7 @@ class RtpTransceiverTestForHeaderExtensions : public ::testing::Test { EXPECT_CALL(mock_channel, SetFirstPacketReceivedCallback(_)); EXPECT_CALL(channel_manager_, DestroyChannel(&mock_channel)) .WillRepeatedly(testing::Return()); - transceiver_.SetChannel(nullptr, nullptr); + transceiver_->SetChannel(nullptr, nullptr); } rtc::scoped_refptr receiver_ = MockReceiver(); @@ -220,7 +225,7 @@ class RtpTransceiverTestForHeaderExtensions : public ::testing::Test { ChannelManagerForTest channel_manager_; std::vector extensions_; - RtpTransceiver transceiver_; + rtc::scoped_refptr transceiver_; }; TEST_F(RtpTransceiverTestForHeaderExtensions, OffersChannelManagerList) { @@ -229,7 +234,7 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, OffersChannelManagerList) { EXPECT_CALL(*sender_.get(), SetTransceiverAsStopped()); EXPECT_CALL(*sender_.get(), Stop()); - EXPECT_EQ(transceiver_.HeaderExtensionsToOffer(), extensions_); + EXPECT_EQ(transceiver_->HeaderExtensionsToOffer(), extensions_); } TEST_F(RtpTransceiverTestForHeaderExtensions, ModifiesDirection) { @@ -241,20 +246,20 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, ModifiesDirection) { auto modified_extensions = extensions_; modified_extensions[0].direction = RtpTransceiverDirection::kSendOnly; EXPECT_TRUE( - transceiver_.SetOfferedRtpHeaderExtensions(modified_extensions).ok()); - EXPECT_EQ(transceiver_.HeaderExtensionsToOffer(), modified_extensions); + transceiver_->SetOfferedRtpHeaderExtensions(modified_extensions).ok()); + EXPECT_EQ(transceiver_->HeaderExtensionsToOffer(), modified_extensions); modified_extensions[0].direction = RtpTransceiverDirection::kRecvOnly; EXPECT_TRUE( - transceiver_.SetOfferedRtpHeaderExtensions(modified_extensions).ok()); - EXPECT_EQ(transceiver_.HeaderExtensionsToOffer(), modified_extensions); + transceiver_->SetOfferedRtpHeaderExtensions(modified_extensions).ok()); + EXPECT_EQ(transceiver_->HeaderExtensionsToOffer(), modified_extensions); modified_extensions[0].direction = RtpTransceiverDirection::kSendRecv; EXPECT_TRUE( - transceiver_.SetOfferedRtpHeaderExtensions(modified_extensions).ok()); - EXPECT_EQ(transceiver_.HeaderExtensionsToOffer(), modified_extensions); + transceiver_->SetOfferedRtpHeaderExtensions(modified_extensions).ok()); + EXPECT_EQ(transceiver_->HeaderExtensionsToOffer(), modified_extensions); modified_extensions[0].direction = RtpTransceiverDirection::kInactive; EXPECT_TRUE( - transceiver_.SetOfferedRtpHeaderExtensions(modified_extensions).ok()); - EXPECT_EQ(transceiver_.HeaderExtensionsToOffer(), modified_extensions); + transceiver_->SetOfferedRtpHeaderExtensions(modified_extensions).ok()); + EXPECT_EQ(transceiver_->HeaderExtensionsToOffer(), modified_extensions); } TEST_F(RtpTransceiverTestForHeaderExtensions, AcceptsStoppedExtension) { @@ -266,8 +271,8 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, AcceptsStoppedExtension) { auto modified_extensions = extensions_; modified_extensions[0].direction = RtpTransceiverDirection::kStopped; EXPECT_TRUE( - transceiver_.SetOfferedRtpHeaderExtensions(modified_extensions).ok()); - EXPECT_EQ(transceiver_.HeaderExtensionsToOffer(), modified_extensions); + transceiver_->SetOfferedRtpHeaderExtensions(modified_extensions).ok()); + EXPECT_EQ(transceiver_->HeaderExtensionsToOffer(), modified_extensions); } TEST_F(RtpTransceiverTestForHeaderExtensions, RejectsUnsupportedExtension) { @@ -279,9 +284,9 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, RejectsUnsupportedExtension) { std::vector modified_extensions( {RtpHeaderExtensionCapability("uri3", 1, RtpTransceiverDirection::kSendRecv)}); - EXPECT_THAT(transceiver_.SetOfferedRtpHeaderExtensions(modified_extensions), + EXPECT_THAT(transceiver_->SetOfferedRtpHeaderExtensions(modified_extensions), Property(&RTCError::type, RTCErrorType::UNSUPPORTED_PARAMETER)); - EXPECT_EQ(transceiver_.HeaderExtensionsToOffer(), extensions_); + EXPECT_EQ(transceiver_->HeaderExtensionsToOffer(), extensions_); } TEST_F(RtpTransceiverTestForHeaderExtensions, @@ -294,15 +299,15 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, std::vector modified_extensions = extensions_; // Attempting to stop the mandatory MID extension. modified_extensions[2].direction = RtpTransceiverDirection::kStopped; - EXPECT_THAT(transceiver_.SetOfferedRtpHeaderExtensions(modified_extensions), + EXPECT_THAT(transceiver_->SetOfferedRtpHeaderExtensions(modified_extensions), Property(&RTCError::type, RTCErrorType::INVALID_MODIFICATION)); - EXPECT_EQ(transceiver_.HeaderExtensionsToOffer(), extensions_); + EXPECT_EQ(transceiver_->HeaderExtensionsToOffer(), extensions_); modified_extensions = extensions_; // Attempting to stop the mandatory video orientation extension. modified_extensions[3].direction = RtpTransceiverDirection::kStopped; - EXPECT_THAT(transceiver_.SetOfferedRtpHeaderExtensions(modified_extensions), + EXPECT_THAT(transceiver_->SetOfferedRtpHeaderExtensions(modified_extensions), Property(&RTCError::type, RTCErrorType::INVALID_MODIFICATION)); - EXPECT_EQ(transceiver_.HeaderExtensionsToOffer(), extensions_); + EXPECT_EQ(transceiver_->HeaderExtensionsToOffer(), extensions_); } TEST_F(RtpTransceiverTestForHeaderExtensions, @@ -311,7 +316,7 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, EXPECT_CALL(*receiver_.get(), SetMediaChannel(_)); EXPECT_CALL(*sender_.get(), SetTransceiverAsStopped()); EXPECT_CALL(*sender_.get(), Stop()); - EXPECT_THAT(transceiver_.HeaderExtensionsNegotiated(), ElementsAre()); + EXPECT_THAT(transceiver_->HeaderExtensionsNegotiated(), ElementsAre()); } TEST_F(RtpTransceiverTestForHeaderExtensions, @@ -329,9 +334,9 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, EXPECT_CALL(mock_channel, media_channel()).WillRepeatedly(Return(nullptr)); EXPECT_CALL(mock_channel, mid()).WillRepeatedly(ReturnRef(content_name)); EXPECT_CALL(mock_channel, SetRtpTransport(_)).WillRepeatedly(Return(true)); - transceiver_.SetChannel(&mock_channel, - [](const std::string&) { return nullptr; }); - EXPECT_THAT(transceiver_.HeaderExtensionsNegotiated(), ElementsAre()); + transceiver_->SetChannel(&mock_channel, + [](const std::string&) { return nullptr; }); + EXPECT_THAT(transceiver_->HeaderExtensionsNegotiated(), ElementsAre()); ClearChannel(mock_channel); } @@ -356,11 +361,11 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, ReturnsNegotiatedHdrExts) { webrtc::RtpExtension("uri2", 2)}; cricket::AudioContentDescription description; description.set_rtp_header_extensions(extensions); - transceiver_.OnNegotiationUpdate(SdpType::kAnswer, &description); + transceiver_->OnNegotiationUpdate(SdpType::kAnswer, &description); - transceiver_.SetChannel(&mock_channel, - [](const std::string&) { return nullptr; }); - EXPECT_THAT(transceiver_.HeaderExtensionsNegotiated(), + transceiver_->SetChannel(&mock_channel, + [](const std::string&) { return nullptr; }); + EXPECT_THAT(transceiver_->HeaderExtensionsNegotiated(), ElementsAre(RtpHeaderExtensionCapability( "uri1", 1, RtpTransceiverDirection::kSendRecv), RtpHeaderExtensionCapability( @@ -380,9 +385,9 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, webrtc::RtpExtension("uri2", 2)}; cricket::AudioContentDescription description; description.set_rtp_header_extensions(extensions); - transceiver_.OnNegotiationUpdate(SdpType::kAnswer, &description); + transceiver_->OnNegotiationUpdate(SdpType::kAnswer, &description); - EXPECT_THAT(transceiver_.HeaderExtensionsNegotiated(), + EXPECT_THAT(transceiver_->HeaderExtensionsNegotiated(), ElementsAre(RtpHeaderExtensionCapability( "uri1", 1, RtpTransceiverDirection::kSendRecv), RtpHeaderExtensionCapability( @@ -391,9 +396,9 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, extensions = {webrtc::RtpExtension("uri3", 4), webrtc::RtpExtension("uri5", 6)}; description.set_rtp_header_extensions(extensions); - transceiver_.OnNegotiationUpdate(SdpType::kAnswer, &description); + transceiver_->OnNegotiationUpdate(SdpType::kAnswer, &description); - EXPECT_THAT(transceiver_.HeaderExtensionsNegotiated(), + EXPECT_THAT(transceiver_->HeaderExtensionsNegotiated(), ElementsAre(RtpHeaderExtensionCapability( "uri3", 4, RtpTransceiverDirection::kSendRecv), RtpHeaderExtensionCapability( diff --git a/pc/rtp_transmission_manager.cc b/pc/rtp_transmission_manager.cc index 5dbb765098..538fa62fe7 100644 --- a/pc/rtp_transmission_manager.cc +++ b/pc/rtp_transmission_manager.cc @@ -271,7 +271,7 @@ RtpTransmissionManager::CreateAndAddTransceiver( RTC_DCHECK(!FindSenderById(sender->id())); auto transceiver = RtpTransceiverProxyWithInternal::Create( signaling_thread(), - new RtpTransceiver( + rtc::make_ref_counted( sender, receiver, channel_manager(), sender->media_type() == cricket::MEDIA_TYPE_AUDIO ? channel_manager()->GetSupportedAudioRtpHeaderExtensions() diff --git a/pc/sctp_data_channel.cc b/pc/sctp_data_channel.cc index c63f820acf..356493658a 100644 --- a/pc/sctp_data_channel.cc +++ b/pc/sctp_data_channel.cc @@ -158,11 +158,8 @@ rtc::scoped_refptr SctpDataChannel::Create( rtc::scoped_refptr SctpDataChannel::CreateProxy( rtc::scoped_refptr channel) { // TODO(bugs.webrtc.org/11547): incorporate the network thread in the proxy. - // Also, consider allowing the proxy object to own the reference (std::move). - // As is, the proxy has a raw pointer and no reference to the channel object - // and trusting that the lifetime management aligns with the - // sctp_data_channels_ array in SctpDataChannelController. - return DataChannelProxy::Create(channel->signaling_thread_, channel.get()); + auto* signaling_thread = channel->signaling_thread_; + return DataChannelProxy::Create(signaling_thread, std::move(channel)); } SctpDataChannel::SctpDataChannel(const InternalDataChannelInit& config, diff --git a/pc/test/fake_peer_connection_for_stats.h b/pc/test/fake_peer_connection_for_stats.h index 4c1f73af8a..7f8559d4de 100644 --- a/pc/test/fake_peer_connection_for_stats.h +++ b/pc/test/fake_peer_connection_for_stats.h @@ -406,7 +406,8 @@ class FakePeerConnectionForStats : public FakePeerConnectionBase { } } auto transceiver = RtpTransceiverProxyWithInternal::Create( - signaling_thread_, new RtpTransceiver(media_type, &channel_manager_)); + signaling_thread_, + rtc::make_ref_counted(media_type, &channel_manager_)); transceivers_.push_back(transceiver); return transceiver; } diff --git a/pc/video_track.cc b/pc/video_track.cc index 744800c9f3..aa8e0df922 100644 --- a/pc/video_track.cc +++ b/pc/video_track.cc @@ -136,8 +136,9 @@ rtc::scoped_refptr VideoTrack::Create( rtc::Thread* worker_thread) { rtc::scoped_refptr< VideoTrackSourceProxyWithInternal> - source_proxy = VideoTrackSourceProxy::Create(rtc::Thread::Current(), - worker_thread, source); + source_proxy = VideoTrackSourceProxy::Create( + rtc::Thread::Current(), worker_thread, + rtc::scoped_refptr(source)); return rtc::make_ref_counted(id, std::move(source_proxy), worker_thread); diff --git a/pc/video_track_source_proxy.cc b/pc/video_track_source_proxy.cc index 26f0ecec98..c3e95e23cc 100644 --- a/pc/video_track_source_proxy.cc +++ b/pc/video_track_source_proxy.cc @@ -21,7 +21,9 @@ rtc::scoped_refptr CreateVideoTrackSourceProxy( rtc::Thread* signaling_thread, rtc::Thread* worker_thread, VideoTrackSourceInterface* source) { - return VideoTrackSourceProxy::Create(signaling_thread, worker_thread, source); + return VideoTrackSourceProxy::Create( + signaling_thread, worker_thread, + rtc::scoped_refptr(source)); } } // namespace webrtc From ea021333cbf6c5923ef4ea8b803e5769c4687835 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Fri, 18 Mar 2022 13:01:34 -0700 Subject: [PATCH 236/847] Roll chromium_revision 176855dcc8..f55241d014 (982693:982852) Change log: https://chromium.googlesource.com/chromium/src/+log/176855dcc8..f55241d014 Full diff: https://chromium.googlesource.com/chromium/src/+/176855dcc8..f55241d014 Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/ad8d9a01a5..bee216d673 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/0e41ee9abf..b42b203381 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/332d8dee2d..043ae4b9e4 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/4c179bb28c..c4769e51cb * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/fc55284d0c..7835795588 * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/76979dae56..bc93924b3b * src/third_party/icu: https://chromium.googlesource.com/chromium/deps/icu.git/+log/ea8c08d878..a9359a84a3 * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/9b8eaa21f1..6dadd2c3b2 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/4b90fc63cc..3c7dc0d25c DEPS diff: https://chromium.googlesource.com/chromium/src/+/176855dcc8..f55241d014/DEPS No update to Clang. BUG=None Change-Id: Iac3a522d3dd92121d664b103a9ea6d674bfbe944 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256120 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36262} --- DEPS | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/DEPS b/DEPS index cfdcadcaf3..e8f8a68070 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': '176855dcc8b016411806e6b5380f39b061aba57f', + 'chromium_revision': 'f55241d0144f3599fa90e4e6038b96634d2b4d42', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@ad8d9a01a5acc611e0fb335c5f180afc995f77c7', + 'https://chromium.googlesource.com/chromium/src/base@bee216d6736d6a471879c5fcd32c8aba863d4755', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@0e41ee9abfdfe163bc93c4ce19d17c92f6b0e6e2', + 'https://chromium.googlesource.com/chromium/src/build@b42b2033819f95b3e43f24e541938c671110966d', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@d8c375426d8f7f4147f7d4109bb63c12655fb8d6', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@332d8dee2dcb4742ab45458f380082c262c41428', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@043ae4b9e442fed9d4a53c88ab708775f8e079cd', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@4c179bb28c6e90c45291f1225700ad34e18ebeb8', + 'https://chromium.googlesource.com/chromium/src/testing@c4769e51cb122096ea4cdc5ed6f7e57aa2315447', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@fc55284d0c7a6878725513fb3b7ddccb02003f74', + 'https://chromium.googlesource.com/chromium/src/third_party@7835795588c74a353beb1e03b74d45fabfdf295f', 'src/buildtools/linux64': { 'packages': [ @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@76979dae56c08d24b092347a1bdd2abe474555a3', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@bc93924b3b2b84515d91ba49bb60ac0b89d928e1', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -187,7 +187,7 @@ deps = { 'src/third_party/googletest/src': 'https://chromium.googlesource.com/external/github.com/google/googletest.git@b007c54f2944e193ac44fba1bc997cb65826a0b9', 'src/third_party/icu': { - 'url': 'https://chromium.googlesource.com/chromium/deps/icu.git@ea8c08d8783fceda86c19618694881149e23f305', + 'url': 'https://chromium.googlesource.com/chromium/deps/icu.git@a9359a84a3969b3019db7d62899afb19642eefcd', }, 'src/third_party/jdk': { 'packages': [ @@ -231,7 +231,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@9b8eaa21f16d10cffefdf758a8b900e014e4788d', + 'https://android.googlesource.com/platform/external/perfetto.git@6dadd2c3b267bd4776762dc5c0a4acb391abbc5e', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -288,7 +288,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@4b90fc63cc138bd63ed66f2dfdefae2e82dbf0fd', + 'https://chromium.googlesource.com/chromium/src/tools@3c7dc0d25c91195a7d9b31947b14739d57f6c728', 'src/third_party/accessibility_test_framework': { 'packages': [ From 0627cb3920d958f954edff1c263abbfd6a747c5e Mon Sep 17 00:00:00 2001 From: Salman Malik Date: Fri, 18 Mar 2022 16:31:58 +0000 Subject: [PATCH 237/847] shared_screencast_stream: Set rectangle on the frame The diff capturer wrapper doesn't work if the frame doesn't have any rectangle and a static image is observed while chromoting. This change adds a rectangle to the frame object, as done by other capturers, and this in turn ensures that the wrapper that calulcates diffs from one frame to the next can do its job. Bug: chromium:1291247 Change-Id: I5bf1981f34b3a88ad4d82a081fed1ce210f71ed0 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251205 Reviewed-by: Alexander Cooper Commit-Queue: Salman Malik Cr-Commit-Position: refs/heads/main@{#36263} --- .../desktop_capture/linux/wayland/shared_screencast_stream.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc index 9e81df4ca8..720234fba8 100644 --- a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc +++ b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc @@ -819,6 +819,9 @@ void SharedScreenCastStreamPrivate::ProcessBuffer(pw_buffer* buffer) { tmp_src += queue_.current_frame()->stride(); } } + + queue_.current_frame()->mutable_updated_region()->SetRect( + DesktopRect::MakeSize(queue_.current_frame()->size())); } void SharedScreenCastStreamPrivate::ConvertRGBxToBGRx(uint8_t* frame, From e0e91a624aecba25909bed63878f8caf0ad010ae Mon Sep 17 00:00:00 2001 From: Jonas Oreland Date: Sat, 19 Mar 2022 00:29:48 +0100 Subject: [PATCH 238/847] AlwaysValidPointer - forwarding constructor and tests Bug: webrtc:10335 Change-Id: I1305ccf8d4f1b25f89fef7d26b090741d5f57f7e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256106 Reviewed-by: Harald Alvestrand Commit-Queue: Jonas Oreland Cr-Commit-Position: refs/heads/main@{#36264} --- rtc_base/memory/BUILD.gn | 3 ++ rtc_base/memory/always_valid_pointer.h | 13 ++++- .../memory/always_valid_pointer_unittest.cc | 49 +++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 rtc_base/memory/always_valid_pointer_unittest.cc diff --git a/rtc_base/memory/BUILD.gn b/rtc_base/memory/BUILD.gn index 583278ee6e..8965a2c702 100644 --- a/rtc_base/memory/BUILD.gn +++ b/rtc_base/memory/BUILD.gn @@ -45,10 +45,12 @@ rtc_library("unittests") { testonly = true sources = [ "aligned_malloc_unittest.cc", + "always_valid_pointer_unittest.cc", "fifo_buffer_unittest.cc", ] deps = [ ":aligned_malloc", + ":always_valid_pointer", ":fifo_buffer", "../../test:test_support", ] @@ -56,4 +58,5 @@ rtc_library("unittests") { rtc_source_set("always_valid_pointer") { sources = [ "always_valid_pointer.h" ] + deps = [ "..:checks" ] } diff --git a/rtc_base/memory/always_valid_pointer.h b/rtc_base/memory/always_valid_pointer.h index c73512d3c5..570ad938fd 100644 --- a/rtc_base/memory/always_valid_pointer.h +++ b/rtc_base/memory/always_valid_pointer.h @@ -11,13 +11,16 @@ #define RTC_BASE_MEMORY_ALWAYS_VALID_POINTER_H_ #include +#include + +#include "rtc_base/checks.h" namespace webrtc { // This template allows the instantiation of a pointer to Interface in such a // way that if it is passed a null pointer, an object of class Default will be // created, which will be deallocated when the pointer is deleted. -template +template class AlwaysValidPointer { public: explicit AlwaysValidPointer(Interface* pointer) @@ -26,6 +29,14 @@ class AlwaysValidPointer { RTC_DCHECK(pointer_); } + template + AlwaysValidPointer(Interface* pointer, Args... args) + : owned_instance_( + pointer ? nullptr : std::make_unique(std::move(args...))), + pointer_(pointer ? pointer : owned_instance_.get()) { + RTC_DCHECK(pointer_); + } + Interface* get() { return pointer_; } Interface* operator->() { return pointer_; } Interface& operator*() { return *pointer_; } diff --git a/rtc_base/memory/always_valid_pointer_unittest.cc b/rtc_base/memory/always_valid_pointer_unittest.cc new file mode 100644 index 0000000000..dbb0671e32 --- /dev/null +++ b/rtc_base/memory/always_valid_pointer_unittest.cc @@ -0,0 +1,49 @@ +/* + * 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 "rtc_base/memory/always_valid_pointer.h" + +#include + +#include "test/gtest.h" + +namespace webrtc { + +TEST(AlwaysValidPointerTest, DefaultToEmptyValue) { + AlwaysValidPointer ptr(nullptr); + EXPECT_EQ(*ptr, ""); +} +TEST(AlwaysValidPointerTest, DefaultWithForwardedArgument) { + AlwaysValidPointer ptr(nullptr, "test"); + EXPECT_EQ(*ptr, "test"); +} +TEST(AlwaysValidPointerTest, DefaultToSubclass) { + struct A { + virtual ~A() {} + virtual int f() = 0; + }; + struct B : public A { + int b = 0; + explicit B(int val) : b(val) {} + virtual ~B() {} + int f() override { return b; } + }; + AlwaysValidPointer ptr(nullptr, 3); + EXPECT_EQ(ptr->f(), 3); + EXPECT_EQ((*ptr).f(), 3); + EXPECT_EQ(ptr.get()->f(), 3); +} +TEST(AlwaysValidPointerTest, NonDefaultValue) { + std::string str("keso"); + AlwaysValidPointer ptr(&str, "test"); + EXPECT_EQ(*ptr, "keso"); +} + +} // namespace webrtc From 36addb3139fdad957cd6f4604f750f7751180f6b Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Fri, 18 Mar 2022 21:07:03 -0700 Subject: [PATCH 239/847] Roll chromium_revision f55241d014..b0887fb2d1 (982852:983014) Change log: https://chromium.googlesource.com/chromium/src/+log/f55241d014..b0887fb2d1 Full diff: https://chromium.googlesource.com/chromium/src/+/f55241d014..b0887fb2d1 Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/bee216d673..bba9c68f4d * src/build: https://chromium.googlesource.com/chromium/src/build/+log/b42b203381..3f1e2153f3 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/043ae4b9e4..91ce947590 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/c4769e51cb..fd6103c22b * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/7835795588..39a80fa616 * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/389f33bb40..54219055fc * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/bc93924b3b..fbb927599f * src/third_party/grpc/src: https://chromium.googlesource.com/external/github.com/grpc/grpc.git/+log/2a0d6234cb..208619cdce * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/6dadd2c3b2..5f95e72333 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/3c7dc0d25c..f0bd7bdb78 DEPS diff: https://chromium.googlesource.com/chromium/src/+/f55241d014..b0887fb2d1/DEPS No update to Clang. BUG=None Change-Id: I261f8fb459b95dc7230eb2892c947097092e149d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256142 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36265} --- DEPS | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/DEPS b/DEPS index e8f8a68070..f5846bb029 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': 'f55241d0144f3599fa90e4e6038b96634d2b4d42', + 'chromium_revision': 'b0887fb2d1b952c9568de65ddda4533a9e23086c', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@bee216d6736d6a471879c5fcd32c8aba863d4755', + 'https://chromium.googlesource.com/chromium/src/base@bba9c68f4d81285f2ebea543eba07f6cdccb3e6e', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@b42b2033819f95b3e43f24e541938c671110966d', + 'https://chromium.googlesource.com/chromium/src/build@3f1e2153f3058902f851909553bf08c7092ff590', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@d8c375426d8f7f4147f7d4109bb63c12655fb8d6', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@043ae4b9e442fed9d4a53c88ab708775f8e079cd', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@91ce947590d8352df90a2400293cdda90a774503', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@c4769e51cb122096ea4cdc5ed6f7e57aa2315447', + 'https://chromium.googlesource.com/chromium/src/testing@fd6103c22b0dcd683a6143b723d27620fc652df4', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@7835795588c74a353beb1e03b74d45fabfdf295f', + 'https://chromium.googlesource.com/chromium/src/third_party@39a80fa616049efac24c0bf33ff95ab88d417940', 'src/buildtools/linux64': { 'packages': [ @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@389f33bb40a3345b73a68613178c789476ceaecf', + 'https://chromium.googlesource.com/catapult.git@54219055fcf8c7ace26e9095715dd1587ea3fbe6', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@bc93924b3b2b84515d91ba49bb60ac0b89d928e1', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@fbb927599f97cd1636493c40f0a87a18c8d335c4', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -157,7 +157,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/grpc/src': { - 'url': 'https://chromium.googlesource.com/external/github.com/grpc/grpc.git@2a0d6234cb2ccebb265c035ffd09ecc9a347b4bf', + 'url': 'https://chromium.googlesource.com/external/github.com/grpc/grpc.git@208619cdce3b7cdc681cb50c29db619e46dd5af6', }, # Used for embedded builds. CrOS & Linux use the system version. 'src/third_party/fontconfig/src': { @@ -231,7 +231,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@6dadd2c3b267bd4776762dc5c0a4acb391abbc5e', + 'https://android.googlesource.com/platform/external/perfetto.git@5f95e723334de734243833fd44456be8951ff0a0', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -288,7 +288,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@3c7dc0d25c91195a7d9b31947b14739d57f6c728', + 'https://chromium.googlesource.com/chromium/src/tools@f0bd7bdb78b6ce867bb6f472c416f49187398daf', 'src/third_party/accessibility_test_framework': { 'packages': [ From 346abbc68a5ab10a7ac0195843ee6e53d37c148b Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Fri, 18 Mar 2022 21:04:26 -0700 Subject: [PATCH 240/847] Update WebRTC code version (2022-03-19T04:04:24). Bug: None Change-Id: Ib8158e2d3116652dc268e955832aa81d19fa5aaa Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256141 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36266} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index a315d82397..834f964f0e 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 2022-03-18T04:05:46"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-03-19T04:04:24"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From d67903d284353dffcf28dfb92819e3d7c4b69bfd Mon Sep 17 00:00:00 2001 From: Tomas Gunnarsson Date: Sat, 19 Mar 2022 16:27:57 +0100 Subject: [PATCH 241/847] Make MockPeerConnectionInterface not inherit from RefCountedObject Bug: webrtc:12701 Change-Id: I51fb7caf12b97d70f35af12703104112f9fdfaff Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256107 Auto-Submit: Tomas Gunnarsson Reviewed-by: Harald Alvestrand Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#36267} --- api/test/mock_peerconnectioninterface.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/api/test/mock_peerconnectioninterface.h b/api/test/mock_peerconnectioninterface.h index effd24e294..adc09f9585 100644 --- a/api/test/mock_peerconnectioninterface.h +++ b/api/test/mock_peerconnectioninterface.h @@ -25,8 +25,7 @@ namespace webrtc { -class MockPeerConnectionInterface - : public rtc::RefCountedObject { +class MockPeerConnectionInterface : public PeerConnectionInterface { public: static rtc::scoped_refptr Create() { return rtc::make_ref_counted(); @@ -199,7 +198,9 @@ class MockPeerConnectionInterface MOCK_METHOD(void, Close, (), (override)); }; -static_assert(!std::is_abstract::value, ""); +static_assert(!std::is_abstract< + rtc::RefCountedObject>::value, + ""); } // namespace webrtc From 1568f55668af466d5e21ef9b9198a9266c0037cd Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Sat, 19 Mar 2022 21:05:31 -0700 Subject: [PATCH 242/847] Update WebRTC code version (2022-03-20T04:05:29). Bug: None Change-Id: Ia96519e30bf8ccef120f3c53e1e92d7bc784f3d8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256156 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36268} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index 834f964f0e..01dddcf33a 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 2022-03-19T04:04:24"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-03-20T04:05:29"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From 83929a852593206145bf02b9160f099b61c61fc1 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Sun, 20 Mar 2022 03:02:02 -0700 Subject: [PATCH 243/847] Roll chromium_revision b0887fb2d1..b76e799ccc (983014:983116) Change log: https://chromium.googlesource.com/chromium/src/+log/b0887fb2d1..b76e799ccc Full diff: https://chromium.googlesource.com/chromium/src/+/b0887fb2d1..b76e799ccc Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/bba9c68f4d..30c6152ced * src/build: https://chromium.googlesource.com/chromium/src/build/+log/3f1e2153f3..2a9033b2ea * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/91ce947590..d0ddd84c26 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/fd6103c22b..0f9838ee47 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/39a80fa616..a3946cc010 * src/third_party/freetype/src: https://chromium.googlesource.com/chromium/src/third_party/freetype2.git/+log/53dfdcd819..d2c3bbcd8e * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/f0bd7bdb78..25fb123606 DEPS diff: https://chromium.googlesource.com/chromium/src/+/b0887fb2d1..b76e799ccc/DEPS No update to Clang. BUG=None Change-Id: I47f16d3d3558817229f8e02da894408efd390f3b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256182 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36269} --- DEPS | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/DEPS b/DEPS index f5846bb029..cad2bc08ba 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': 'b0887fb2d1b952c9568de65ddda4533a9e23086c', + 'chromium_revision': 'b76e799ccc2e9daa9924bec5aa21d31734acb383', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@bba9c68f4d81285f2ebea543eba07f6cdccb3e6e', + 'https://chromium.googlesource.com/chromium/src/base@30c6152ced1169144461c591a5e7c9f50e1a2ee2', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@3f1e2153f3058902f851909553bf08c7092ff590', + 'https://chromium.googlesource.com/chromium/src/build@2a9033b2ea4f190ebf0e682b19444a4bcabb1f33', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@d8c375426d8f7f4147f7d4109bb63c12655fb8d6', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@91ce947590d8352df90a2400293cdda90a774503', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@d0ddd84c26568b63aab1a032d3de217b12f91917', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@fd6103c22b0dcd683a6143b723d27620fc652df4', + 'https://chromium.googlesource.com/chromium/src/testing@0f9838ee4754daaedbd0dd06f5845bcef140cec3', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@39a80fa616049efac24c0bf33ff95ab88d417940', + 'https://chromium.googlesource.com/chromium/src/third_party@a3946cc010a87a539a63a5a731fc17690e4b26fd', 'src/buildtools/linux64': { 'packages': [ @@ -165,7 +165,7 @@ deps = { 'condition': 'checkout_linux', }, 'src/third_party/freetype/src': - 'https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@53dfdcd8198d2b3201a23c4bad9190519ba918db', + 'https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@d2c3bbcd8ec175a750d76f0bf50162ea9e3aaf85', 'src/third_party/harfbuzz-ng/src': 'https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git@965cf1d66589b0db60e75961cc58f5a65521078e', 'src/third_party/google_benchmark/src': { @@ -288,7 +288,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@f0bd7bdb78b6ce867bb6f472c416f49187398daf', + 'https://chromium.googlesource.com/chromium/src/tools@25fb123606aff37f2e3962df2be999176f01e37f', 'src/third_party/accessibility_test_framework': { 'packages': [ From 0a5e12b07d920cc57cba9e1555ea295cece0ab5d Mon Sep 17 00:00:00 2001 From: Per Kjellander Date: Fri, 18 Mar 2022 15:13:52 +0100 Subject: [PATCH 244/847] Reland "Apply lower bound of delay based estimate in AimdRateControl::ClampBitrate" This reverts commit 865d94e45258c9c8876ea4cbdd5dade510cb7d93. First patch is the same as original cl. Second patch includes a fix to ensure the clamped bitrate does not increase to 85% of the last network estimate. Bug: none Change-Id: Idf1b2af3fb60c0d392c48c1b6c0d8526f900f9d6 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256016 Reviewed-by: Diep Bui Commit-Queue: Per Kjellander Cr-Commit-Position: refs/heads/main@{#36270} --- .../aimd_rate_control.cc | 12 +++++---- .../aimd_rate_control_unittest.cc | 27 ++++++++++++++++++- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/modules/remote_bitrate_estimator/aimd_rate_control.cc b/modules/remote_bitrate_estimator/aimd_rate_control.cc index 1714dd115a..3297df9c83 100644 --- a/modules/remote_bitrate_estimator/aimd_rate_control.cc +++ b/modules/remote_bitrate_estimator/aimd_rate_control.cc @@ -338,11 +338,6 @@ void AimdRateControl::ChangeBitrate(const RateControlInput& input, decreased_bitrate = beta_ * link_capacity_.estimate(); } } - if (estimate_bounded_backoff_ && network_estimate_) { - decreased_bitrate = std::max( - decreased_bitrate, network_estimate_->link_capacity_lower * beta_); - } - // Avoid increasing the rate when over-using. if (decreased_bitrate < current_bitrate_) { new_bitrate = decreased_bitrate; @@ -386,6 +381,13 @@ DataRate AimdRateControl::ClampBitrate(DataRate new_bitrate) const { } new_bitrate = std::min(upper_bound, new_bitrate); } + if (estimate_bounded_backoff_ && network_estimate_ && + network_estimate_->link_capacity_lower.IsFinite() && + new_bitrate < current_bitrate_) { + new_bitrate = std::min( + current_bitrate_, + std::max(new_bitrate, network_estimate_->link_capacity_lower * beta_)); + } new_bitrate = std::max(new_bitrate, min_configured_bitrate_); return new_bitrate; } diff --git a/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc b/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc index 5d9c328e06..1fe5799545 100644 --- a/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc +++ b/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc @@ -255,7 +255,7 @@ TEST(AimdRateControlTest, SetEstimateIncreaseBweInAlr) { 2 * kInitialBitrateBps); } -TEST(AimdRateControlTest, SetEstimateClampedByNetworkEstimate) { +TEST(AimdRateControlTest, SetEstimateUpperLimitedByNetworkEstimate) { auto states = CreateAimdRateControlStates(/*send_side=*/true); NetworkStateEstimate network_estimate; network_estimate.link_capacity_upper = DataRate::KilobitsPerSec(400); @@ -265,6 +265,31 @@ TEST(AimdRateControlTest, SetEstimateClampedByNetworkEstimate) { network_estimate.link_capacity_upper); } +TEST(AimdRateControlTest, SetEstimateLowerLimitedByNetworkEstimate) { + auto states = CreateAimdRateControlStates(/*send_side=*/true); + NetworkStateEstimate network_estimate; + network_estimate.link_capacity_lower = DataRate::KilobitsPerSec(400); + states.aimd_rate_control->SetNetworkStateEstimate(network_estimate); + SetEstimate(states, 100'000); + // 0.85 is default backoff factor. (`beta_`) + EXPECT_EQ(states.aimd_rate_control->LatestEstimate(), + network_estimate.link_capacity_lower * 0.85); +} + +TEST(AimdRateControlTest, + SetEstimateIgnoredIfLowerThanNetworkEstimateAndCurrent) { + auto states = CreateAimdRateControlStates(/*send_side=*/true); + SetEstimate(states, 200'000); + ASSERT_EQ(states.aimd_rate_control->LatestEstimate().kbps(), 200); + NetworkStateEstimate network_estimate; + network_estimate.link_capacity_lower = DataRate::KilobitsPerSec(400); + states.aimd_rate_control->SetNetworkStateEstimate(network_estimate); + // Ignore the next SetEstimate, since the estimate is lower than 85% of + // the network estimate. + SetEstimate(states, 100'000); + EXPECT_EQ(states.aimd_rate_control->LatestEstimate().kbps(), 200); +} + TEST(AimdRateControlTest, SetEstimateIgnoresNetworkEstimatesLowerThanCurrent) { test::ScopedFieldTrials override_field_trials( "WebRTC-Bwe-EstimateBoundedIncrease/" From 82c94af48f74699bc1cd2bcad4f91073fd4b88cc Mon Sep 17 00:00:00 2001 From: Tomas Gunnarsson Date: Sun, 20 Mar 2022 18:38:25 +0000 Subject: [PATCH 245/847] Revert "Make MockPeerConnectionInterface not inherit from RefCountedObject" This reverts commit d67903d284353dffcf28dfb92819e3d7c4b69bfd. Reason for revert: A downstream issue needs to be fixed. Original change's description: > Make MockPeerConnectionInterface not inherit from RefCountedObject > > Bug: webrtc:12701 > Change-Id: I51fb7caf12b97d70f35af12703104112f9fdfaff > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256107 > Auto-Submit: Tomas Gunnarsson > Reviewed-by: Harald Alvestrand > Commit-Queue: Harald Alvestrand > Cr-Commit-Position: refs/heads/main@{#36267} Bug: webrtc:12701 Change-Id: I25e2d6004d257dd0b1d17fb1f7726d04d29e6eed Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256109 Bot-Commit: rubber-stamper@appspot.gserviceaccount.com Reviewed-by: Tomas Gunnarsson Commit-Queue: Tomas Gunnarsson Cr-Commit-Position: refs/heads/main@{#36271} --- api/test/mock_peerconnectioninterface.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/api/test/mock_peerconnectioninterface.h b/api/test/mock_peerconnectioninterface.h index adc09f9585..effd24e294 100644 --- a/api/test/mock_peerconnectioninterface.h +++ b/api/test/mock_peerconnectioninterface.h @@ -25,7 +25,8 @@ namespace webrtc { -class MockPeerConnectionInterface : public PeerConnectionInterface { +class MockPeerConnectionInterface + : public rtc::RefCountedObject { public: static rtc::scoped_refptr Create() { return rtc::make_ref_counted(); @@ -198,9 +199,7 @@ class MockPeerConnectionInterface : public PeerConnectionInterface { MOCK_METHOD(void, Close, (), (override)); }; -static_assert(!std::is_abstract< - rtc::RefCountedObject>::value, - ""); +static_assert(!std::is_abstract::value, ""); } // namespace webrtc From 9d52093ff9b4b1107dbf7b158391bfd0fd8f3fe5 Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Sun, 20 Mar 2022 21:05:31 -0700 Subject: [PATCH 246/847] Update WebRTC code version (2022-03-21T04:05:30). Bug: None Change-Id: I5701b2ffa1d17aab2ac159d8d7094acd068b2dc7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256205 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36272} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index 01dddcf33a..b3b6f8b753 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 2022-03-20T04:05:29"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-03-21T04:05:30"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From 60c588d77e4ef4bf42786636b1fce2bee1cc6ac9 Mon Sep 17 00:00:00 2001 From: David Sanders Date: Sat, 19 Mar 2022 01:43:10 -0700 Subject: [PATCH 247/847] Fixed typos, candiate -> candidate Bug: None Change-Id: I2dee549aa79f1eb6bddd58cfc6c9f67eb6ba3663 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256147 Reviewed-by: Tomas Gunnarsson Reviewed-by: Harald Alvestrand Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#36273} --- AUTHORS | 1 + examples/unityplugin/README | 26 +++++++++---------- .../unityplugin/simple_peer_connection.cc | 10 +++---- examples/unityplugin/simple_peer_connection.h | 4 +-- examples/unityplugin/unity_plugin_apis.cc | 4 +-- examples/unityplugin/unity_plugin_apis.h | 2 +- p2p/base/p2p_transport_channel_unittest.cc | 8 +++--- p2p/base/port_unittest.cc | 2 +- p2p/base/turn_port.cc | 2 +- pc/webrtc_sdp_unittest.cc | 2 +- 10 files changed, 31 insertions(+), 30 deletions(-) diff --git a/AUTHORS b/AUTHORS index 212c990918..6c6a0cd017 100644 --- a/AUTHORS +++ b/AUTHORS @@ -35,6 +35,7 @@ CZ Theng Danail Kirov Dave Cowart David Porter +David Sanders Dax Booysen Dennis Angelo Dharmesh Chauhan diff --git a/examples/unityplugin/README b/examples/unityplugin/README index 5f26b89488..da8f07aa11 100644 --- a/examples/unityplugin/README +++ b/examples/unityplugin/README @@ -124,13 +124,13 @@ namespace SimplePeerConnectionM { LocalSdpReadytoSendInternalDelegate callback); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private delegate void IceCandiateReadytoSendInternalDelegate( + private delegate void IceCandidateReadytoSendInternalDelegate( string candidate, int sdpMlineIndex, string sdpMid); - public delegate void IceCandiateReadytoSendDelegate( + public delegate void IceCandidateReadytoSendDelegate( int id, string candidate, int sdpMlineIndex, string sdpMid); [DllImport(dllPath, CallingConvention = CallingConvention.Cdecl)] - private static extern bool RegisterOnIceCandiateReadytoSend( - int peerConnectionId, IceCandiateReadytoSendInternalDelegate callback); + private static extern bool RegisterOnIceCandidateReadytoSend( + int peerConnectionId, IceCandidateReadytoSendInternalDelegate callback); [DllImport(dllPath, CallingConvention = CallingConvention.Cdecl)] private static extern bool SetRemoteDescription(int peerConnectionId, string type, string sdp); @@ -215,10 +215,10 @@ namespace SimplePeerConnectionM { RaiseLocalSdpReadytoSend); RegisterOnLocalSdpReadytoSend(mPeerConnectionId, localSdpReadytoSendDelegate); - iceCandiateReadytoSendDelegate = - new IceCandiateReadytoSendInternalDelegate(RaiseIceCandiateReadytoSend); - RegisterOnIceCandiateReadytoSend( - mPeerConnectionId, iceCandiateReadytoSendDelegate); + iceCandidateReadytoSendDelegate = + new IceCandidateReadytoSendInternalDelegate(RaiseIceCandidateReadytoSend); + RegisterOnIceCandidateReadytoSend( + mPeerConnectionId, iceCandidateReadytoSendDelegate); } private void RaiseLocalDataChannelReady() { @@ -267,9 +267,9 @@ namespace SimplePeerConnectionM { OnLocalSdpReadytoSend(mPeerConnectionId, type, sdp); } - private void RaiseIceCandiateReadytoSend(string candidate, int sdpMlineIndex, string sdpMid) { - if (OnIceCandiateReadytoSend != null) - OnIceCandiateReadytoSend(mPeerConnectionId, candidate, sdpMlineIndex, sdpMid); + private void RaiseIceCandidateReadytoSend(string candidate, int sdpMlineIndex, string sdpMid) { + if (OnIceCandidateReadytoSend != null) + OnIceCandidateReadytoSend(mPeerConnectionId, candidate, sdpMlineIndex, sdpMid); } public void AddQueuedIceCandidate(List iceCandidateQueue) { @@ -301,8 +301,8 @@ namespace SimplePeerConnectionM { private LocalSdpReadytoSendInternalDelegate localSdpReadytoSendDelegate = null; public event LocalSdpReadytoSendDelegate OnLocalSdpReadytoSend; - private IceCandiateReadytoSendInternalDelegate iceCandiateReadytoSendDelegate = null; - public event IceCandiateReadytoSendDelegate OnIceCandiateReadytoSend; + private IceCandidateReadytoSendInternalDelegate iceCandidateReadytoSendDelegate = null; + public event IceCandidateReadytoSendDelegate OnIceCandidateReadytoSend; private int mPeerConnectionId = -1; } diff --git a/examples/unityplugin/simple_peer_connection.cc b/examples/unityplugin/simple_peer_connection.cc index 16c580e767..90bbef7c16 100644 --- a/examples/unityplugin/simple_peer_connection.cc +++ b/examples/unityplugin/simple_peer_connection.cc @@ -286,9 +286,9 @@ void SimplePeerConnection::OnIceCandidate( return; } - if (OnIceCandiateReady) - OnIceCandiateReady(sdp.c_str(), candidate->sdp_mline_index(), - candidate->sdp_mid().c_str()); + if (OnIceCandidateReady) + OnIceCandidateReady(sdp.c_str(), candidate->sdp_mline_index(), + candidate->sdp_mid().c_str()); } void SimplePeerConnection::RegisterOnLocalI420FrameReady( @@ -327,9 +327,9 @@ void SimplePeerConnection::RegisterOnLocalSdpReadytoSend( OnLocalSdpReady = callback; } -void SimplePeerConnection::RegisterOnIceCandiateReadytoSend( +void SimplePeerConnection::RegisterOnIceCandidateReadytoSend( ICECANDIDATEREADYTOSEND_CALLBACK callback) { - OnIceCandiateReady = callback; + OnIceCandidateReady = callback; } bool SimplePeerConnection::SetRemoteDescription(const char* type, diff --git a/examples/unityplugin/simple_peer_connection.h b/examples/unityplugin/simple_peer_connection.h index d5cebc9940..5d681dc4ca 100644 --- a/examples/unityplugin/simple_peer_connection.h +++ b/examples/unityplugin/simple_peer_connection.h @@ -52,7 +52,7 @@ class SimplePeerConnection : public webrtc::PeerConnectionObserver, void RegisterOnFailure(FAILURE_CALLBACK callback); void RegisterOnAudioBusReady(AUDIOBUSREADY_CALLBACK callback); void RegisterOnLocalSdpReadytoSend(LOCALSDPREADYTOSEND_CALLBACK callback); - void RegisterOnIceCandiateReadytoSend( + void RegisterOnIceCandidateReadytoSend( ICECANDIDATEREADYTOSEND_CALLBACK callback); bool SetRemoteDescription(const char* type, const char* sdp); bool AddIceCandidate(const char* sdp, @@ -121,7 +121,7 @@ class SimplePeerConnection : public webrtc::PeerConnectionObserver, AUDIOBUSREADY_CALLBACK OnAudioReady = nullptr; LOCALSDPREADYTOSEND_CALLBACK OnLocalSdpReady = nullptr; - ICECANDIDATEREADYTOSEND_CALLBACK OnIceCandiateReady = nullptr; + ICECANDIDATEREADYTOSEND_CALLBACK OnIceCandidateReady = nullptr; bool is_mute_audio_ = false; bool is_record_audio_ = false; diff --git a/examples/unityplugin/unity_plugin_apis.cc b/examples/unityplugin/unity_plugin_apis.cc index 672330faec..6e34d7e1e0 100644 --- a/examples/unityplugin/unity_plugin_apis.cc +++ b/examples/unityplugin/unity_plugin_apis.cc @@ -184,13 +184,13 @@ bool RegisterOnLocalSdpReadytoSend(int peer_connection_id, return true; } -bool RegisterOnIceCandiateReadytoSend( +bool RegisterOnIceCandidateReadytoSend( int peer_connection_id, ICECANDIDATEREADYTOSEND_CALLBACK callback) { if (!g_peer_connection_map.count(peer_connection_id)) return false; - g_peer_connection_map[peer_connection_id]->RegisterOnIceCandiateReadytoSend( + g_peer_connection_map[peer_connection_id]->RegisterOnIceCandidateReadytoSend( callback); return true; } diff --git a/examples/unityplugin/unity_plugin_apis.h b/examples/unityplugin/unity_plugin_apis.h index 8b8fe0fe80..9790dc57b9 100644 --- a/examples/unityplugin/unity_plugin_apis.h +++ b/examples/unityplugin/unity_plugin_apis.h @@ -100,7 +100,7 @@ WEBRTC_PLUGIN_API bool RegisterOnAudioBusReady(int peer_connection_id, WEBRTC_PLUGIN_API bool RegisterOnLocalSdpReadytoSend( int peer_connection_id, LOCALSDPREADYTOSEND_CALLBACK callback); -WEBRTC_PLUGIN_API bool RegisterOnIceCandiateReadytoSend( +WEBRTC_PLUGIN_API bool RegisterOnIceCandidateReadytoSend( int peer_connection_id, ICECANDIDATEREADYTOSEND_CALLBACK callback); } diff --git a/p2p/base/p2p_transport_channel_unittest.cc b/p2p/base/p2p_transport_channel_unittest.cc index 2685d59751..c69530b0ef 100644 --- a/p2p/base/p2p_transport_channel_unittest.cc +++ b/p2p/base/p2p_transport_channel_unittest.cc @@ -6307,11 +6307,11 @@ TEST_P(GatherAfterConnectedTest, GatherAfterConnected) { clock.AdvanceTime(webrtc::TimeDelta::Millis(10 * delay)); if (stop_gather_on_strongly_connected) { - // The relay candiates gathered has not been propagated to channel. + // The relay candidates gathered has not been propagated to channel. EXPECT_EQ(ep1->saved_candidates_.size(), 0u); EXPECT_EQ(ep2->saved_candidates_.size(), 0u); } else { - // The relay candiates gathered has been propagated to channel. + // The relay candidates gathered has been propagated to channel. EXPECT_EQ(ep1->saved_candidates_.size(), 1u); EXPECT_EQ(ep2->saved_candidates_.size(), 1u); } @@ -6369,11 +6369,11 @@ TEST_P(GatherAfterConnectedTest, GatherAfterConnectedMultiHomed) { clock.AdvanceTime(webrtc::TimeDelta::Millis(10 * delay)); if (stop_gather_on_strongly_connected) { - // The relay candiates gathered has not been propagated to channel. + // The relay candidates gathered has not been propagated to channel. EXPECT_EQ(ep1->saved_candidates_.size(), 0u); EXPECT_EQ(ep2->saved_candidates_.size(), 0u); } else { - // The relay candiates gathered has been propagated. + // The relay candidates gathered has been propagated. EXPECT_EQ(ep1->saved_candidates_.size(), 2u); EXPECT_EQ(ep2->saved_candidates_.size(), 1u); } diff --git a/p2p/base/port_unittest.cc b/p2p/base/port_unittest.cc index 23b11a7a3d..1197c44ab6 100644 --- a/p2p/base/port_unittest.cc +++ b/p2p/base/port_unittest.cc @@ -2626,7 +2626,7 @@ TEST_F(PortTest, TestCandidateFoundation) { } // This test verifies the related addresses of different types of -// ICE candiates. +// ICE candidates. TEST_F(PortTest, TestCandidateRelatedAddress) { auto nat_server = CreateNatServer(kNatAddr1, NAT_OPEN_CONE); auto udpport = CreateUdpPort(kLocalAddr1); diff --git a/p2p/base/turn_port.cc b/p2p/base/turn_port.cc index 9b09ae8360..45fe212c65 100644 --- a/p2p/base/turn_port.cc +++ b/p2p/base/turn_port.cc @@ -560,7 +560,7 @@ Connection* TurnPort::CreateConnection(const Candidate& remote_candidate, return nullptr; } - // A TURN port will have two candiates, STUN and TURN. STUN may not + // A TURN port will have two candidates, STUN and TURN. STUN may not // present in all cases. If present stun candidate will be added first // and TURN candidate later. for (size_t index = 0; index < Candidates().size(); ++index) { diff --git a/pc/webrtc_sdp_unittest.cc b/pc/webrtc_sdp_unittest.cc index ea1b07d06a..a081d74aa4 100644 --- a/pc/webrtc_sdp_unittest.cc +++ b/pc/webrtc_sdp_unittest.cc @@ -2783,7 +2783,7 @@ TEST_F(WebRtcSdpTest, DeserializeCandidate) { } // This test verifies the deserialization of candidate-attribute -// as per RFC 5245. Candiate-attribute will be of the format +// as per RFC 5245. Candidate-attribute will be of the format // candidate:. This format will be used when candidates // are trickled. TEST_F(WebRtcSdpTest, DeserializeRawCandidateAttribute) { From f11a04d0f5399716b8782de083994bdc59190572 Mon Sep 17 00:00:00 2001 From: Jonas Oreland Date: Mon, 21 Mar 2022 07:33:50 +0100 Subject: [PATCH 248/847] remove all but 2 redundant factory methods in TurnPort and those will be fixed after I fixed downstream. Bug: webrtc:10335 Change-Id: Ie824b422b4240fbcdb5d7ee40ae9be91655abae7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256111 Reviewed-by: Harald Alvestrand Commit-Queue: Jonas Oreland Cr-Commit-Position: refs/heads/main@{#36274} --- p2p/base/port_unittest.cc | 18 +++- p2p/base/turn_port.cc | 7 +- p2p/base/turn_port.h | 106 +++++++++++++--------- p2p/base/turn_port_unittest.cc | 37 ++++++-- p2p/client/relay_port_factory_interface.h | 5 +- p2p/client/turn_port_factory.cc | 13 +-- 6 files changed, 111 insertions(+), 75 deletions(-) diff --git a/p2p/base/port_unittest.cc b/p2p/base/port_unittest.cc index 1197c44ab6..c5a89599c5 100644 --- a/p2p/base/port_unittest.cc +++ b/p2p/base/port_unittest.cc @@ -556,11 +556,21 @@ class PortTest : public ::testing::Test, public sigslot::has_slots<> { ProtocolType int_proto, ProtocolType ext_proto, const rtc::SocketAddress& server_addr) { - return TurnPort::Create(&main_, socket_factory, MakeNetwork(addr), 0, 0, - username_, password_, - ProtocolAddress(server_addr, int_proto), - kRelayCredentials, 0, {}, {}, nullptr, nullptr); + RelayServerConfig config; + config.credentials = kRelayCredentials; + ProtocolAddress server_address(server_addr, int_proto); + CreateRelayPortArgs args; + args.network_thread = &main_; + args.socket_factory = socket_factory; + args.network = MakeNetwork(addr); + args.username = username_; + args.password = password_; + args.server_address = &server_address; + args.config = &config; + + return TurnPort::Create(args, 0, 0); } + std::unique_ptr CreateNatServer(const SocketAddress& addr, rtc::NATType type) { return std::make_unique(type, ss_.get(), addr, addr, diff --git a/p2p/base/turn_port.cc b/p2p/base/turn_port.cc index 45fe212c65..3f5b95e0d8 100644 --- a/p2p/base/turn_port.cc +++ b/p2p/base/turn_port.cc @@ -222,11 +222,16 @@ TurnPort::TurnPort(rtc::Thread* thread, const ProtocolAddress& server_address, const RelayCredentials& credentials, int server_priority, + const std::vector& tls_alpn_protocols, + const std::vector& tls_elliptic_curves, webrtc::TurnCustomizer* customizer, + rtc::SSLCertificateVerifier* tls_cert_verifier, const webrtc::WebRtcKeyValueConfig* field_trials) : Port(thread, RELAY_PORT_TYPE, factory, network, username, password), server_address_(server_address), - tls_cert_verifier_(nullptr), + tls_alpn_protocols_(tls_alpn_protocols), + tls_elliptic_curves_(tls_elliptic_curves), + tls_cert_verifier_(tls_cert_verifier), credentials_(credentials), socket_(socket), error_(0), diff --git a/p2p/base/turn_port.h b/p2p/base/turn_port.h index 797d19096e..7458871023 100644 --- a/p2p/base/turn_port.h +++ b/p2p/base/turn_port.h @@ -52,7 +52,60 @@ class TurnPort : public Port { // packets. }; + static bool Validate(const CreateRelayPortArgs& args) { + // Do basic parameter validation. + if (args.config->credentials.username.size() > kMaxTurnUsernameLength) { + RTC_LOG(LS_ERROR) << "Attempt to use TURN with a too long username " + << "of length " + << args.config->credentials.username.size(); + return false; + } + // Do not connect to low-numbered ports. The default STUN port is 3478. + if (!AllowedTurnPort(args.server_address->address.port(), + args.field_trials)) { + RTC_LOG(LS_ERROR) << "Attempt to use TURN to connect to port " + << args.server_address->address.port(); + return false; + } + return true; + } + + // Create a TURN port using the shared UDP socket, `socket`. + static std::unique_ptr Create(const CreateRelayPortArgs& args, + rtc::AsyncPacketSocket* socket) { + if (!Validate(args)) { + return nullptr; + } + // Using `new` to access a non-public constructor. + return absl::WrapUnique( + new TurnPort(args.network_thread, args.socket_factory, args.network, + socket, args.username, args.password, *args.server_address, + args.config->credentials, args.config->priority, + args.config->tls_alpn_protocols, + args.config->tls_elliptic_curves, args.turn_customizer, + args.config->tls_cert_verifier, args.field_trials)); + } + + // Create a TURN port that will use a new socket, bound to `network` and + // using a port in the range between `min_port` and `max_port`. + static std::unique_ptr Create(const CreateRelayPortArgs& args, + int min_port, + int max_port) { + if (!Validate(args)) { + return nullptr; + } + // Using `new` to access a non-public constructor. + return absl::WrapUnique( + new TurnPort(args.network_thread, args.socket_factory, args.network, + min_port, max_port, args.username, args.password, + *args.server_address, args.config->credentials, + args.config->priority, args.config->tls_alpn_protocols, + args.config->tls_elliptic_curves, args.turn_customizer, + args.config->tls_cert_verifier, args.field_trials)); + } + // Create a TURN port using the shared UDP socket, `socket`. + // TODO(jonaso) : remove in favor or CreateRelayPortArgs version. static std::unique_ptr Create( rtc::Thread* thread, rtc::PacketSocketFactory* factory, @@ -75,32 +128,15 @@ class TurnPort : public Port { if (!AllowedTurnPort(server_address.address.port(), field_trials)) { RTC_LOG(LS_ERROR) << "Attempt to use TURN to connect to port " << server_address.address.port(); - return nullptr; } // Using `new` to access a non-public constructor. - return absl::WrapUnique(new TurnPort( - thread, factory, network, socket, username, password, server_address, - credentials, server_priority, customizer, field_trials)); - } - - // TODO(steveanton): Remove once downstream clients have moved to `Create`. - static std::unique_ptr CreateUnique( - rtc::Thread* thread, - rtc::PacketSocketFactory* factory, - rtc::Network* network, - rtc::AsyncPacketSocket* socket, - const std::string& username, // ice username. - const std::string& password, // ice password. - const ProtocolAddress& server_address, - const RelayCredentials& credentials, - int server_priority, - webrtc::TurnCustomizer* customizer, - const webrtc::WebRtcKeyValueConfig* field_trials) { - return Create(thread, factory, network, socket, username, password, - server_address, credentials, server_priority, customizer, - field_trials); + return absl::WrapUnique(new TurnPort(thread, factory, network, socket, + username, password, server_address, + credentials, server_priority, {}, {}, + customizer, nullptr, field_trials)); } + // TODO(jonaso) : remove in favor or CreateRelayPortArgs version. // Create a TURN port that will use a new socket, bound to `network` and // using a port in the range between `min_port` and `max_port`. static std::unique_ptr Create( @@ -138,29 +174,6 @@ class TurnPort : public Port { tls_elliptic_curves, customizer, tls_cert_verifier, field_trials)); } - // TODO(steveanton): Remove once downstream clients have moved to `Create`. - static std::unique_ptr CreateUnique( - rtc::Thread* thread, - rtc::PacketSocketFactory* factory, - rtc::Network* network, - uint16_t min_port, - uint16_t max_port, - const std::string& username, // ice username. - const std::string& password, // ice password. - const ProtocolAddress& server_address, - const RelayCredentials& credentials, - int server_priority, - const std::vector& tls_alpn_protocols, - const std::vector& tls_elliptic_curves, - webrtc::TurnCustomizer* customizer, - rtc::SSLCertificateVerifier* tls_cert_verifier = nullptr, - const webrtc::WebRtcKeyValueConfig* field_trials = nullptr) { - return Create(thread, factory, network, min_port, max_port, username, - password, server_address, credentials, server_priority, - tls_alpn_protocols, tls_elliptic_curves, customizer, - tls_cert_verifier, field_trials); - } - ~TurnPort() override; const ProtocolAddress& server_address() const { return server_address_; } @@ -269,7 +282,10 @@ class TurnPort : public Port { const ProtocolAddress& server_address, const RelayCredentials& credentials, int server_priority, + const std::vector& tls_alpn_protocols, + const std::vector& tls_elliptic_curves, webrtc::TurnCustomizer* customizer, + rtc::SSLCertificateVerifier* tls_cert_verifier = nullptr, const webrtc::WebRtcKeyValueConfig* field_trials = nullptr); TurnPort(rtc::Thread* thread, diff --git a/p2p/base/turn_port_unittest.cc b/p2p/base/turn_port_unittest.cc index 30ad2c009e..e713e2b4a7 100644 --- a/p2p/base/turn_port_unittest.cc +++ b/p2p/base/turn_port_unittest.cc @@ -292,11 +292,20 @@ class TurnPortTest : public ::testing::Test, const std::string& username, const std::string& password, const ProtocolAddress& server_address) { - RelayCredentials credentials(username, password); - turn_port_ = - TurnPort::Create(&main_, &socket_factory_, network, 0, 0, kIceUfrag1, - kIcePwd1, server_address, credentials, 0, {}, {}, - turn_customizer_.get(), nullptr, &field_trials_); + RelayServerConfig config; + config.credentials = RelayCredentials(username, password); + CreateRelayPortArgs args; + args.network_thread = &main_; + args.socket_factory = &socket_factory_; + args.network = network; + args.username = kIceUfrag1; + args.password = kIcePwd1; + args.server_address = &server_address; + args.config = &config; + args.turn_customizer = turn_customizer_.get(); + args.field_trials = &field_trials_; + + turn_port_ = TurnPort::Create(args, 0, 0); if (!turn_port_) { return false; } @@ -327,11 +336,19 @@ class TurnPortTest : public ::testing::Test, &TurnPortTest::OnSocketReadPacket); } - RelayCredentials credentials(username, password); - turn_port_ = - TurnPort::Create(&main_, &socket_factory_, MakeNetwork(kLocalAddr1), - socket_.get(), kIceUfrag1, kIcePwd1, server_address, - credentials, 0, nullptr, &field_trials_); + RelayServerConfig config; + config.credentials = RelayCredentials(username, password); + CreateRelayPortArgs args; + args.network_thread = &main_; + args.socket_factory = &socket_factory_; + args.network = MakeNetwork(kLocalAddr1); + args.username = kIceUfrag1; + args.password = kIcePwd1; + args.server_address = &server_address; + args.config = &config; + args.turn_customizer = turn_customizer_.get(); + args.field_trials = &field_trials_; + turn_port_ = TurnPort::Create(args, socket_.get()); // This TURN port will be the controlling. turn_port_->SetIceRole(ICEROLE_CONTROLLING); ConnectSignals(); diff --git a/p2p/client/relay_port_factory_interface.h b/p2p/client/relay_port_factory_interface.h index cb4eb97483..9417c4d313 100644 --- a/p2p/client/relay_port_factory_interface.h +++ b/p2p/client/relay_port_factory_interface.h @@ -36,7 +36,6 @@ struct RelayServerConfig; // A struct containing arguments to RelayPortFactory::Create() struct CreateRelayPortArgs { - CreateRelayPortArgs(); rtc::Thread* network_thread; rtc::PacketSocketFactory* socket_factory; rtc::Network* network; @@ -44,12 +43,10 @@ struct CreateRelayPortArgs { const RelayServerConfig* config; std::string username; std::string password; - webrtc::TurnCustomizer* turn_customizer; + webrtc::TurnCustomizer* turn_customizer = nullptr; const webrtc::WebRtcKeyValueConfig* field_trials = nullptr; }; -inline CreateRelayPortArgs::CreateRelayPortArgs() {} - // A factory for creating RelayPort's. class RelayPortFactoryInterface { public: diff --git a/p2p/client/turn_port_factory.cc b/p2p/client/turn_port_factory.cc index 07321b85d6..555387dbbf 100644 --- a/p2p/client/turn_port_factory.cc +++ b/p2p/client/turn_port_factory.cc @@ -23,11 +23,7 @@ TurnPortFactory::~TurnPortFactory() {} std::unique_ptr TurnPortFactory::Create( const CreateRelayPortArgs& args, rtc::AsyncPacketSocket* udp_socket) { - auto port = TurnPort::CreateUnique( - args.network_thread, args.socket_factory, args.network, udp_socket, - args.username, args.password, *args.server_address, - args.config->credentials, args.config->priority, args.turn_customizer, - args.field_trials); + auto port = TurnPort::Create(args, udp_socket); if (!port) return nullptr; port->SetTlsCertPolicy(args.config->tls_cert_policy); @@ -38,12 +34,7 @@ std::unique_ptr TurnPortFactory::Create( std::unique_ptr TurnPortFactory::Create(const CreateRelayPortArgs& args, int min_port, int max_port) { - auto port = TurnPort::CreateUnique( - args.network_thread, args.socket_factory, args.network, min_port, - max_port, args.username, args.password, *args.server_address, - args.config->credentials, args.config->priority, - args.config->tls_alpn_protocols, args.config->tls_elliptic_curves, - args.turn_customizer, args.config->tls_cert_verifier, args.field_trials); + auto port = TurnPort::Create(args, min_port, max_port); if (!port) return nullptr; port->SetTlsCertPolicy(args.config->tls_cert_policy); From a9fa92efdbabfdcd66d267cf5f576bfbf2b95904 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Mon, 21 Mar 2022 01:01:47 -0700 Subject: [PATCH 249/847] Roll chromium_revision b76e799ccc..3fdea4fb00 (983116:983226) Change log: https://chromium.googlesource.com/chromium/src/+log/b76e799ccc..3fdea4fb00 Full diff: https://chromium.googlesource.com/chromium/src/+/b76e799ccc..3fdea4fb00 Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/30c6152ced..62ab5ed470 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/2a9033b2ea..2432cc5556 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/d0ddd84c26..ae135d284f * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/0f9838ee47..47c212f7df * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/a3946cc010..f6fd5326b8 * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/fbb927599f..f0bc2d2404 * src/third_party/freetype/src: https://chromium.googlesource.com/chromium/src/third_party/freetype2.git/+log/d2c3bbcd8e..a960be9e5e * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/25fb123606..8ec39e2d1b * src/tools/resultdb: git_revision:735a8a662d3874d8b1d795a40e46ea0f57b52758..git_revision:6cc18e2763e180929d70c786b419c1f8e6bcc66c DEPS diff: https://chromium.googlesource.com/chromium/src/+/b76e799ccc..3fdea4fb00/DEPS No update to Clang. BUG=None Change-Id: Iaba181b0a0088e9e388c5371ab676ef294c23580 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256207 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36275} --- DEPS | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/DEPS b/DEPS index cad2bc08ba..ea45562e53 100644 --- a/DEPS +++ b/DEPS @@ -10,22 +10,22 @@ vars = { # chromium waterfalls. More info at: crbug.com/570091. 'checkout_configuration': 'default', 'checkout_instrumented_libraries': 'checkout_linux and checkout_configuration == "default"', - 'chromium_revision': 'b76e799ccc2e9daa9924bec5aa21d31734acb383', + 'chromium_revision': '3fdea4fb00f7ab0632a7f78d8f85cda361b704b7', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, # ResultDB version - 'resultdb_version': 'git_revision:735a8a662d3874d8b1d795a40e46ea0f57b52758', + 'resultdb_version': 'git_revision:6cc18e2763e180929d70c786b419c1f8e6bcc66c', } deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@30c6152ced1169144461c591a5e7c9f50e1a2ee2', + 'https://chromium.googlesource.com/chromium/src/base@62ab5ed470e35bc5b56fcf26b24667a2bded4998', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@2a9033b2ea4f190ebf0e682b19444a4bcabb1f33', + 'https://chromium.googlesource.com/chromium/src/build@2432cc55565916bd7b0686429b733ce3412675ea', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@d8c375426d8f7f4147f7d4109bb63c12655fb8d6', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@d0ddd84c26568b63aab1a032d3de217b12f91917', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@ae135d284f82bef1e4bb1837032b28ec96d80760', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@0f9838ee4754daaedbd0dd06f5845bcef140cec3', + 'https://chromium.googlesource.com/chromium/src/testing@47c212f7dfd0db682ad64a862ca5ba4efd7a4ae9', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@a3946cc010a87a539a63a5a731fc17690e4b26fd', + 'https://chromium.googlesource.com/chromium/src/third_party@f6fd5326b855956c71a07c6245c80da4c9d4342f', 'src/buildtools/linux64': { 'packages': [ @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@fbb927599f97cd1636493c40f0a87a18c8d335c4', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@f0bc2d24042bd70cc7b43d4d19d9eec3074e462c', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -165,7 +165,7 @@ deps = { 'condition': 'checkout_linux', }, 'src/third_party/freetype/src': - 'https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@d2c3bbcd8ec175a750d76f0bf50162ea9e3aaf85', + 'https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@a960be9e5e9846e1e4e8d2254e0b405fbf84346b', 'src/third_party/harfbuzz-ng/src': 'https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git@965cf1d66589b0db60e75961cc58f5a65521078e', 'src/third_party/google_benchmark/src': { @@ -288,7 +288,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@25fb123606aff37f2e3962df2be999176f01e37f', + 'https://chromium.googlesource.com/chromium/src/tools@8ec39e2d1ba06b7d292f2104ffc7a93ccddd8272', 'src/third_party/accessibility_test_framework': { 'packages': [ From b3517fea8358d6fc91601e5a15d408a8f3908784 Mon Sep 17 00:00:00 2001 From: Tomas Gunnarsson Date: Fri, 18 Mar 2022 19:32:38 +0100 Subject: [PATCH 250/847] Remove RefCountedObject dependency from FakeFrameDecryptor Bug: webrtc:12701 Change-Id: I705007948eed7b8300f02a61307e8f4b3410e666 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256108 Auto-Submit: Tomas Gunnarsson Reviewed-by: Niels Moller Commit-Queue: Tomas Gunnarsson Cr-Commit-Position: refs/heads/main@{#36276} --- api/test/fake_frame_decryptor.h | 3 +-- pc/rtp_sender_receiver_unittest.cc | 8 ++++---- video/end_to_end_tests/frame_encryption_tests.cc | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/api/test/fake_frame_decryptor.h b/api/test/fake_frame_decryptor.h index bfd0e6903b..cb58dd6c99 100644 --- a/api/test/fake_frame_decryptor.h +++ b/api/test/fake_frame_decryptor.h @@ -27,8 +27,7 @@ namespace webrtc { // FrameDecryptorInterface. It is constructed with a simple single digit key and // a fixed postfix byte. This is just to validate that the core code works // as expected. -class FakeFrameDecryptor final - : public rtc::RefCountedObject { +class FakeFrameDecryptor : public FrameDecryptorInterface { public: // Provide a key (0,255) and some postfix byte (0,255) this should match the // byte you expect from the FakeFrameEncryptor. diff --git a/pc/rtp_sender_receiver_unittest.cc b/pc/rtp_sender_receiver_unittest.cc index a7b9c9ab68..20621e44ae 100644 --- a/pc/rtp_sender_receiver_unittest.cc +++ b/pc/rtp_sender_receiver_unittest.cc @@ -1635,7 +1635,7 @@ TEST_F(RtpSenderReceiverTest, AudioSenderCannotSetFrameEncryptorAfterStop) { TEST_F(RtpSenderReceiverTest, AudioReceiverCanSetFrameDecryptor) { CreateAudioRtpReceiver(); rtc::scoped_refptr fake_frame_decryptor( - new FakeFrameDecryptor()); + rtc::make_ref_counted()); EXPECT_EQ(nullptr, audio_rtp_receiver_->GetFrameDecryptor()); audio_rtp_receiver_->SetFrameDecryptor(fake_frame_decryptor); EXPECT_EQ(fake_frame_decryptor.get(), @@ -1647,7 +1647,7 @@ TEST_F(RtpSenderReceiverTest, AudioReceiverCanSetFrameDecryptor) { TEST_F(RtpSenderReceiverTest, AudioReceiverCannotSetFrameDecryptorAfterStop) { CreateAudioRtpReceiver(); rtc::scoped_refptr fake_frame_decryptor( - new FakeFrameDecryptor()); + rtc::make_ref_counted()); EXPECT_EQ(nullptr, audio_rtp_receiver_->GetFrameDecryptor()); audio_rtp_receiver_->SetMediaChannel(nullptr); audio_rtp_receiver_->SetFrameDecryptor(fake_frame_decryptor); @@ -1682,7 +1682,7 @@ TEST_F(RtpSenderReceiverTest, VideoSenderCannotSetFrameEncryptorAfterStop) { TEST_F(RtpSenderReceiverTest, VideoReceiverCanSetFrameDecryptor) { CreateVideoRtpReceiver(); rtc::scoped_refptr fake_frame_decryptor( - new FakeFrameDecryptor()); + rtc::make_ref_counted()); EXPECT_EQ(nullptr, video_rtp_receiver_->GetFrameDecryptor()); video_rtp_receiver_->SetFrameDecryptor(fake_frame_decryptor); EXPECT_EQ(fake_frame_decryptor.get(), @@ -1694,7 +1694,7 @@ TEST_F(RtpSenderReceiverTest, VideoReceiverCanSetFrameDecryptor) { TEST_F(RtpSenderReceiverTest, VideoReceiverCannotSetFrameDecryptorAfterStop) { CreateVideoRtpReceiver(); rtc::scoped_refptr fake_frame_decryptor( - new FakeFrameDecryptor()); + rtc::make_ref_counted()); EXPECT_EQ(nullptr, video_rtp_receiver_->GetFrameDecryptor()); video_rtp_receiver_->SetMediaChannel(nullptr); video_rtp_receiver_->SetFrameDecryptor(fake_frame_decryptor); diff --git a/video/end_to_end_tests/frame_encryption_tests.cc b/video/end_to_end_tests/frame_encryption_tests.cc index df54337be5..30e65e8abd 100644 --- a/video/end_to_end_tests/frame_encryption_tests.cc +++ b/video/end_to_end_tests/frame_encryption_tests.cc @@ -51,7 +51,7 @@ class DecryptedFrameObserver : public test::EndToEndTest, recv_config.decoders.clear(); recv_config.decoders.push_back(decoder); recv_config.renderer = this; - recv_config.frame_decryptor = new FakeFrameDecryptor(); + recv_config.frame_decryptor = rtc::make_ref_counted(); recv_config.crypto_options.sframe.require_frame_encryption = true; } } From 769de49937ea1bae60cdb640c50373c1b39291d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Mon, 21 Mar 2022 10:40:09 +0100 Subject: [PATCH 251/847] Update VideoTrack::Create to use rtc::scoped_refptr. Bug: webrtc:13464 Change-Id: I6508fbede2f447f8c0c9b37556d37e7fc2ccb744 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252441 Reviewed-by: Harald Alvestrand Reviewed-by: Danil Chapovalov Reviewed-by: Tomas Gunnarsson Commit-Queue: Niels Moller Cr-Commit-Position: refs/heads/main@{#36277} --- pc/peer_connection_factory.cc | 9 +++++---- pc/video_track.cc | 5 ++--- pc/video_track.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pc/peer_connection_factory.cc b/pc/peer_connection_factory.cc index 262ca90cd9..c598440201 100644 --- a/pc/peer_connection_factory.cc +++ b/pc/peer_connection_factory.cc @@ -276,8 +276,9 @@ rtc::scoped_refptr PeerConnectionFactory::CreateVideoTrack( const std::string& id, VideoTrackSourceInterface* source) { RTC_DCHECK(signaling_thread()->IsCurrent()); - rtc::scoped_refptr track( - VideoTrack::Create(id, source, worker_thread())); + rtc::scoped_refptr track = VideoTrack::Create( + id, rtc::scoped_refptr(source), + worker_thread()); return VideoTrackProxy::Create(signaling_thread(), worker_thread(), track); } @@ -285,8 +286,8 @@ rtc::scoped_refptr PeerConnectionFactory::CreateAudioTrack( const std::string& id, AudioSourceInterface* source) { RTC_DCHECK(signaling_thread()->IsCurrent()); - rtc::scoped_refptr track( - AudioTrack::Create(id, rtc::scoped_refptr(source))); + rtc::scoped_refptr track = + AudioTrack::Create(id, rtc::scoped_refptr(source)); return AudioTrackProxy::Create(signaling_thread(), track); } diff --git a/pc/video_track.cc b/pc/video_track.cc index aa8e0df922..95e27a3c96 100644 --- a/pc/video_track.cc +++ b/pc/video_track.cc @@ -132,13 +132,12 @@ void VideoTrack::OnChanged() { rtc::scoped_refptr VideoTrack::Create( const std::string& id, - VideoTrackSourceInterface* source, + rtc::scoped_refptr source, rtc::Thread* worker_thread) { rtc::scoped_refptr< VideoTrackSourceProxyWithInternal> source_proxy = VideoTrackSourceProxy::Create( - rtc::Thread::Current(), worker_thread, - rtc::scoped_refptr(source)); + rtc::Thread::Current(), worker_thread, std::move(source)); return rtc::make_ref_counted(id, std::move(source_proxy), worker_thread); diff --git a/pc/video_track.h b/pc/video_track.h index f938b3362c..8934e96592 100644 --- a/pc/video_track.h +++ b/pc/video_track.h @@ -39,7 +39,7 @@ class VideoTrack : public MediaStreamTrack, public: static rtc::scoped_refptr Create( const std::string& label, - VideoTrackSourceInterface* source, + rtc::scoped_refptr source, rtc::Thread* worker_thread); void AddOrUpdateSink(rtc::VideoSinkInterface* sink, From 94029b812f741f0085608e5a76beb81a189b370c Mon Sep 17 00:00:00 2001 From: Jeremy Leconte Date: Mon, 21 Mar 2022 10:37:55 +0100 Subject: [PATCH 252/847] Remove unused script webrtc_dashboard_upload.py The script process_perf_results.py is used instead. Bug: webrtc:13806 Change-Id: I672da41d7264d5f996eef38f1178f486dad968ee Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256220 Reviewed-by: Mirko Bonadei Commit-Queue: Jeremy Leconte Cr-Commit-Position: refs/heads/main@{#36278} --- .vpython | 2 +- .vpython3 | 2 +- tools_webrtc/perf/BUILD.gn | 2 +- tools_webrtc/perf/webrtc_dashboard_upload.py | 135 ------------------- 4 files changed, 3 insertions(+), 138 deletions(-) delete mode 100644 tools_webrtc/perf/webrtc_dashboard_upload.py diff --git a/.vpython b/.vpython index a57f82ff3e..d226875f02 100644 --- a/.vpython +++ b/.vpython @@ -31,7 +31,7 @@ wheel: < version: "version:5.2.2" > -# Used by tools_webrtc/perf/webrtc_dashboard_upload.py. +# Used by tools_webrtc/perf/process_perf_results.py. wheel: < name: "infra/python/wheels/httplib2-py2_py3" version: "version:0.10.3" diff --git a/.vpython3 b/.vpython3 index 99b1a0d8e9..39d735dcd1 100644 --- a/.vpython3 +++ b/.vpython3 @@ -31,7 +31,7 @@ wheel: < version: "version:5.8.0.chromium.2" > -# Used by tools_webrtc/perf/webrtc_dashboard_upload.py. +# Used by tools_webrtc/perf/process_perf_results.py. wheel: < name: "infra/python/wheels/httplib2-py3" version: "version:0.19.1" diff --git a/tools_webrtc/perf/BUILD.gn b/tools_webrtc/perf/BUILD.gn index e45a170822..484f9565b5 100644 --- a/tools_webrtc/perf/BUILD.gn +++ b/tools_webrtc/perf/BUILD.gn @@ -10,7 +10,7 @@ import("../../webrtc.gni") if (rtc_enable_protobuf) { group("webrtc_dashboard_upload") { - data = [ "webrtc_dashboard_upload.py" ] + data = [ "process_perf_results.py" ] data_deps = [ "//third_party/catapult/tracing/tracing/proto:histogram_proto" ] } diff --git a/tools_webrtc/perf/webrtc_dashboard_upload.py b/tools_webrtc/perf/webrtc_dashboard_upload.py deleted file mode 100644 index e141b2803f..0000000000 --- a/tools_webrtc/perf/webrtc_dashboard_upload.py +++ /dev/null @@ -1,135 +0,0 @@ -#!/usr/bin/env vpython3 - -# Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. -"""Adds build info to perf results and uploads them. - -The tests don't know which bot executed the tests or at what revision, so we -need to take their output and enrich it with this information. We load the proto -from the tests, add the build information as shared diagnostics and then -upload it to the dashboard. - -This script can't be in recipes, because we can't access the catapult APIs from -there. It needs to be here source-side. -""" - -import argparse -import os -import sys - -# Even if protobuf is not used directly, this allows transitive imports -# of the protobuf library to use the vpython wheel specified in the root -# level .vpython (see bugs.webrtc.org/12211 for context). -import google.protobuf # pylint: disable=unused-import - - -def _CreateParser(): - parser = argparse.ArgumentParser() - parser.add_argument('--perf-dashboard-machine-group', - required=True, - help='The "machine_group" the bots are grouped under.' - 'This string is the group in the the perf dashboard ' - 'path group/bot/perf_id/metric/subtest.') - parser.add_argument('--bot', - required=True, - help='The bot running the test (e.g. ' - 'webrtc-win-large-tests).') - parser.add_argument('--test-suite', - required=True, - help='The key for the test in the dashboard (i.e. what ' - 'you select in the top-level test suite selector in ' - 'the dashboard') - parser.add_argument('--webrtc-git-hash', - required=True, - help='webrtc.googlesource.com commit hash.') - parser.add_argument('--commit-position', - type=int, - required=True, - help='Commit pos corresponding to the git hash.') - parser.add_argument('--build-page-url', - required=True, - help='URL to the build page for this build.') - parser.add_argument('--dashboard-url', - required=True, - help='Which dashboard to use.') - parser.add_argument('--input-results-file', - required=True, - help='A HistogramSet proto file with output from ' - 'WebRTC tests.') - parser.add_argument('--output-json-file', - help='Where to write the output (for debugging).') - parser.add_argument('--outdir', - required=True, - help='Path to the local out/ dir (usually out/Default)') - # TODO(crbug.com/webrtc/13806): Remove this argument. - parser.add_argument('--wait-for-upload', - action='store_true', - help='DEPRECATED: this option will soon be removed') - return parser - - -def _ConfigurePythonPath(outdir): - # We just yank the python scripts we require into the PYTHONPATH. You could - # also imagine a solution where we use for instance - # protobuf:py_proto_runtime to copy catapult and protobuf code to out/. - # This is the convention in Chromium and WebRTC python scripts. We do need - # to build histogram_pb2 however, so that's why we add out/ to sys.path - # below. - # - # It would be better if there was an equivalent to py_binary in GN, but - # there's not. - script_dir = os.path.dirname(os.path.realpath(__file__)) - checkout_root = os.path.abspath(os.path.join(script_dir, os.pardir, - os.pardir)) - - sys.path.insert( - 0, os.path.join(checkout_root, 'third_party', 'catapult', 'tracing')) - sys.path.insert( - 0, os.path.join(checkout_root, 'third_party', 'protobuf', 'python')) - - # The webrtc_dashboard_upload gn rule will build the protobuf stub for - # python, so put it in the path for this script before we attempt to import - # it. - histogram_proto_path = os.path.join(outdir, 'pyproto', 'tracing', 'tracing', - 'proto') - sys.path.insert(0, histogram_proto_path) - - # Fail early in case the proto hasn't been built. - from tracing.proto import histogram_proto - if not histogram_proto.HAS_PROTO: - raise ImportError('Could not find histogram_pb2. You need to build the ' - 'webrtc_dashboard_upload target before invoking this ' - 'script. Expected to find ' - 'histogram_pb2.py in %s.' % histogram_proto_path) - - -def main(args): - parser = _CreateParser() - options = parser.parse_args(args) - - _ConfigurePythonPath(options.outdir) - - import catapult_uploader - - uploader_options = catapult_uploader.UploaderOptions( - perf_dashboard_machine_group=options.perf_dashboard_machine_group, - bot=options.bot, - test_suite=options.test_suite, - webrtc_git_hash=options.webrtc_git_hash, - commit_position=options.commit_position, - build_page_url=options.build_page_url, - dashboard_url=options.dashboard_url, - input_results_file=options.input_results_file, - output_json_file=options.output_json_file, - ) - - return catapult_uploader.UploadToDashboard(uploader_options) - - -if __name__ == '__main__': - sys.exit(main(sys.argv[1:])) From 493718ea4738ec664ffbe8f09fb45c1b9b4eb3fa Mon Sep 17 00:00:00 2001 From: Tomas Gunnarsson Date: Fri, 18 Mar 2022 17:20:15 +0100 Subject: [PATCH 253/847] Make MockRtpTransceiver not inherit from RefCountedObject Bug: webrtc:12701 Change-Id: Ia43c943cbf96ef7d745dfea79ecca6e52e8bc3b6 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256104 Reviewed-by: Niels Moller Auto-Submit: Tomas Gunnarsson Commit-Queue: Tomas Gunnarsson Cr-Commit-Position: refs/heads/main@{#36279} --- api/test/mock_rtp_transceiver.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/api/test/mock_rtp_transceiver.h b/api/test/mock_rtp_transceiver.h index 5ea9028b77..1d21bce5eb 100644 --- a/api/test/mock_rtp_transceiver.h +++ b/api/test/mock_rtp_transceiver.h @@ -19,11 +19,12 @@ namespace webrtc { -class MockRtpTransceiver final - : public rtc::RefCountedObject { +class MockRtpTransceiver : public RtpTransceiverInterface { public: + MockRtpTransceiver() = default; + static rtc::scoped_refptr Create() { - return rtc::scoped_refptr(new MockRtpTransceiver()); + return rtc::make_ref_counted(); } MOCK_METHOD(cricket::MediaType, media_type, (), (const, override)); @@ -79,9 +80,6 @@ class MockRtpTransceiver final (rtc::ArrayView header_extensions_to_offer), (override)); - - private: - MockRtpTransceiver() = default; }; } // namespace webrtc From cf08d339449463e99de30b1dd577c1c714371760 Mon Sep 17 00:00:00 2001 From: Jonas Oreland Date: Mon, 21 Mar 2022 15:47:27 +0100 Subject: [PATCH 254/847] Remove deprecated TurnPort::Create() versions Bug: webrtc:10335 Change-Id: I62eb0534ade2de221bc90c2f6c4f3caa0ac2e91b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256266 Reviewed-by: Harald Alvestrand Commit-Queue: Jonas Oreland Cr-Commit-Position: refs/heads/main@{#36280} --- p2p/base/turn_port.h | 70 -------------------------------------------- 1 file changed, 70 deletions(-) diff --git a/p2p/base/turn_port.h b/p2p/base/turn_port.h index 7458871023..3328f2fcaa 100644 --- a/p2p/base/turn_port.h +++ b/p2p/base/turn_port.h @@ -104,76 +104,6 @@ class TurnPort : public Port { args.config->tls_cert_verifier, args.field_trials)); } - // Create a TURN port using the shared UDP socket, `socket`. - // TODO(jonaso) : remove in favor or CreateRelayPortArgs version. - static std::unique_ptr Create( - rtc::Thread* thread, - rtc::PacketSocketFactory* factory, - rtc::Network* network, - rtc::AsyncPacketSocket* socket, - const std::string& username, // ice username. - const std::string& password, // ice password. - const ProtocolAddress& server_address, - const RelayCredentials& credentials, - int server_priority, - webrtc::TurnCustomizer* customizer, - const webrtc::WebRtcKeyValueConfig* field_trials = nullptr) { - // Do basic parameter validation. - if (credentials.username.size() > kMaxTurnUsernameLength) { - RTC_LOG(LS_ERROR) << "Attempt to use TURN with a too long username " - << "of length " << credentials.username.size(); - return nullptr; - } - // Do not connect to low-numbered ports. The default STUN port is 3478. - if (!AllowedTurnPort(server_address.address.port(), field_trials)) { - RTC_LOG(LS_ERROR) << "Attempt to use TURN to connect to port " - << server_address.address.port(); - } - // Using `new` to access a non-public constructor. - return absl::WrapUnique(new TurnPort(thread, factory, network, socket, - username, password, server_address, - credentials, server_priority, {}, {}, - customizer, nullptr, field_trials)); - } - - // TODO(jonaso) : remove in favor or CreateRelayPortArgs version. - // Create a TURN port that will use a new socket, bound to `network` and - // using a port in the range between `min_port` and `max_port`. - static std::unique_ptr Create( - rtc::Thread* thread, - rtc::PacketSocketFactory* factory, - rtc::Network* network, - uint16_t min_port, - uint16_t max_port, - const std::string& username, // ice username. - const std::string& password, // ice password. - const ProtocolAddress& server_address, - const RelayCredentials& credentials, - int server_priority, - const std::vector& tls_alpn_protocols, - const std::vector& tls_elliptic_curves, - webrtc::TurnCustomizer* customizer, - rtc::SSLCertificateVerifier* tls_cert_verifier = nullptr, - const webrtc::WebRtcKeyValueConfig* field_trials = nullptr) { - // Do basic parameter validation. - if (credentials.username.size() > kMaxTurnUsernameLength) { - RTC_LOG(LS_ERROR) << "Attempt to use TURN with a too long username " - << "of length " << credentials.username.size(); - return nullptr; - } - // Do not connect to low-numbered ports. The default STUN port is 3478. - if (!AllowedTurnPort(server_address.address.port(), field_trials)) { - RTC_LOG(LS_ERROR) << "Attempt to use TURN to connect to port " - << server_address.address.port(); - return nullptr; - } - // Using `new` to access a non-public constructor. - return absl::WrapUnique(new TurnPort( - thread, factory, network, min_port, max_port, username, password, - server_address, credentials, server_priority, tls_alpn_protocols, - tls_elliptic_curves, customizer, tls_cert_verifier, field_trials)); - } - ~TurnPort() override; const ProtocolAddress& server_address() const { return server_address_; } From 9dde120d65de664442f4248a25addb98127e357b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Mon, 21 Mar 2022 10:36:32 +0100 Subject: [PATCH 255/847] Reject double RefCountedObject inheritance in rtc::make_ref_counted. Bug: webrtc:12701 Change-Id: Ie45707e3266e6a27cae073f824a1c77707d77000 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256240 Reviewed-by: Harald Alvestrand Reviewed-by: Tomas Gunnarsson Commit-Queue: Tomas Gunnarsson Cr-Commit-Position: refs/heads/main@{#36281} --- api/test/mock_peerconnectioninterface.h | 7 ++++--- pc/peer_connection_rtp_unittest.cc | 3 +-- pc/peer_connection_signaling_unittest.cc | 12 ++++-------- pc/test/mock_data_channel.h | 12 ++++++------ pc/test/mock_peer_connection_observers.h | 4 ++-- rtc_base/ref_counted_object.h | 16 +++++++++++----- 6 files changed, 28 insertions(+), 26 deletions(-) diff --git a/api/test/mock_peerconnectioninterface.h b/api/test/mock_peerconnectioninterface.h index effd24e294..97b2b7d7b1 100644 --- a/api/test/mock_peerconnectioninterface.h +++ b/api/test/mock_peerconnectioninterface.h @@ -25,8 +25,7 @@ namespace webrtc { -class MockPeerConnectionInterface - : public rtc::RefCountedObject { +class MockPeerConnectionInterface : public webrtc::PeerConnectionInterface { public: static rtc::scoped_refptr Create() { return rtc::make_ref_counted(); @@ -199,7 +198,9 @@ class MockPeerConnectionInterface MOCK_METHOD(void, Close, (), (override)); }; -static_assert(!std::is_abstract::value, ""); +static_assert( + !std::is_abstract_v>, + ""); } // namespace webrtc diff --git a/pc/peer_connection_rtp_unittest.cc b/pc/peer_connection_rtp_unittest.cc index 6c08ba47bc..98b14d268a 100644 --- a/pc/peer_connection_rtp_unittest.cc +++ b/pc/peer_connection_rtp_unittest.cc @@ -69,8 +69,7 @@ using ::testing::Values; const uint32_t kDefaultTimeout = 10000u; template -class OnSuccessObserver : public rtc::RefCountedObject< - webrtc::SetRemoteDescriptionObserverInterface> { +class OnSuccessObserver : public webrtc::SetRemoteDescriptionObserverInterface { public: explicit OnSuccessObserver(MethodFunctor on_success) : on_success_(std::move(on_success)) {} diff --git a/pc/peer_connection_signaling_unittest.cc b/pc/peer_connection_signaling_unittest.cc index 5923d2c47f..bf8b8099fb 100644 --- a/pc/peer_connection_signaling_unittest.cc +++ b/pc/peer_connection_signaling_unittest.cc @@ -610,8 +610,7 @@ TEST_P(PeerConnectionSignalingTest, TEST_P(PeerConnectionSignalingTest, ImplicitCreateOfferAndShutdown) { auto caller = CreatePeerConnection(); - rtc::scoped_refptr observer( - new FakeSetLocalDescriptionObserver()); + auto observer = rtc::make_ref_counted(); caller->pc()->SetLocalDescription(observer); caller.reset(nullptr); // The new observer gets invoked because it is called immediately. @@ -632,8 +631,7 @@ TEST_P(PeerConnectionSignalingTest, TEST_P(PeerConnectionSignalingTest, CloseBeforeImplicitCreateOfferAndShutdown) { auto caller = CreatePeerConnection(); - rtc::scoped_refptr observer( - new FakeSetLocalDescriptionObserver()); + auto observer = rtc::make_ref_counted(); caller->pc()->Close(); caller->pc()->SetLocalDescription(observer); caller.reset(nullptr); @@ -655,8 +653,7 @@ TEST_P(PeerConnectionSignalingTest, TEST_P(PeerConnectionSignalingTest, CloseAfterImplicitCreateOfferAndShutdown) { auto caller = CreatePeerConnection(); - rtc::scoped_refptr observer( - new FakeSetLocalDescriptionObserver()); + auto observer = rtc::make_ref_counted(); caller->pc()->SetLocalDescription(observer); caller->pc()->Close(); caller.reset(nullptr); @@ -670,8 +667,7 @@ TEST_P(PeerConnectionSignalingTest, auto caller = CreatePeerConnection(); auto offer = caller->CreateOffer(RTCOfferAnswerOptions()); - rtc::scoped_refptr observer( - new FakeSetLocalDescriptionObserver()); + auto observer = rtc::make_ref_counted(); caller->pc()->SetLocalDescription(std::move(offer), observer); // The new observer is invoked immediately. EXPECT_TRUE(observer->called()); diff --git a/pc/test/mock_data_channel.h b/pc/test/mock_data_channel.h index ab4b0073da..f1c5374d28 100644 --- a/pc/test/mock_data_channel.h +++ b/pc/test/mock_data_channel.h @@ -18,7 +18,7 @@ namespace webrtc { -class MockSctpDataChannel : public rtc::RefCountedObject { +class MockSctpDataChannel : public SctpDataChannel { public: MockSctpDataChannel(int id, DataState state) : MockSctpDataChannel(id, @@ -41,11 +41,11 @@ class MockSctpDataChannel : public rtc::RefCountedObject { const InternalDataChannelInit& config = InternalDataChannelInit(), rtc::Thread* signaling_thread = rtc::Thread::Current(), rtc::Thread* network_thread = rtc::Thread::Current()) - : rtc::RefCountedObject(config, - nullptr, - label, - signaling_thread, - network_thread) { + : SctpDataChannel(config, + nullptr, + label, + signaling_thread, + network_thread) { EXPECT_CALL(*this, id()).WillRepeatedly(::testing::Return(id)); EXPECT_CALL(*this, state()).WillRepeatedly(::testing::Return(state)); EXPECT_CALL(*this, protocol()).WillRepeatedly(::testing::Return(protocol)); diff --git a/pc/test/mock_peer_connection_observers.h b/pc/test/mock_peer_connection_observers.h index 2698d956af..51e24b7b30 100644 --- a/pc/test/mock_peer_connection_observers.h +++ b/pc/test/mock_peer_connection_observers.h @@ -336,7 +336,7 @@ class MockSetSessionDescriptionObserver }; class FakeSetLocalDescriptionObserver - : public rtc::RefCountedObject { + : public SetLocalDescriptionObserverInterface { public: bool called() const { return error_.has_value(); } RTCError& error() { @@ -355,7 +355,7 @@ class FakeSetLocalDescriptionObserver }; class FakeSetRemoteDescriptionObserver - : public rtc::RefCountedObject { + : public SetRemoteDescriptionObserverInterface { public: bool called() const { return error_.has_value(); } RTCError& error() { diff --git a/rtc_base/ref_counted_object.h b/rtc_base/ref_counted_object.h index 54aac952ce..8309ba40d5 100644 --- a/rtc_base/ref_counted_object.h +++ b/rtc_base/ref_counted_object.h @@ -142,11 +142,17 @@ class FinalRefCountedObject final : public T { // Note that in some cases, using RefCountedObject directly may still be what's // needed. -// `make_ref_counted` for classes that are convertible to RefCountInterface. -template , - T>::type* = nullptr> +// `make_ref_counted` for abstract classes that are convertible to +// RefCountInterface. The is_abstract requirement rejects classes that inherit +// both RefCountInterface and RefCounted object, which is a a discouraged +// pattern, and would result in double inheritance of RefCountedObject if this +// template was applied. +template < + typename T, + typename... Args, + typename std::enable_if && + std::is_abstract_v, + T>::type* = nullptr> scoped_refptr make_ref_counted(Args&&... args) { return scoped_refptr(new RefCountedObject(std::forward(args)...)); } From 98274ee9482c96cced765f53250068a97190ea61 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Mon, 21 Mar 2022 09:01:17 -0700 Subject: [PATCH 256/847] Roll chromium_revision 3fdea4fb00..cd60f7c147 (983226:983336) Change log: https://chromium.googlesource.com/chromium/src/+log/3fdea4fb00..cd60f7c147 Full diff: https://chromium.googlesource.com/chromium/src/+/3fdea4fb00..cd60f7c147 Changed dependencies * src/build: https://chromium.googlesource.com/chromium/src/build/+log/2432cc5556..0a7d5e2362 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/ae135d284f..f05ae3297c * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/47c212f7df..e6c44c92f4 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/f6fd5326b8..9581bbe809 * src/third_party/freetype/src: https://chromium.googlesource.com/chromium/src/third_party/freetype2.git/+log/a960be9e5e..fc15ebe0a6 * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/5f95e72333..723b273d39 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/8ec39e2d1b..a49530481c DEPS diff: https://chromium.googlesource.com/chromium/src/+/3fdea4fb00..cd60f7c147/DEPS No update to Clang. BUG=None Change-Id: I774058c6a6b9793e69fc66753d2f0209b911d82f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256211 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36282} --- DEPS | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/DEPS b/DEPS index ea45562e53..fbb1f061d7 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': '3fdea4fb00f7ab0632a7f78d8f85cda361b704b7', + 'chromium_revision': 'cd60f7c147648ecee2bdd7d8843b85dd35fe49d0', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -25,7 +25,7 @@ deps = { 'src/base': 'https://chromium.googlesource.com/chromium/src/base@62ab5ed470e35bc5b56fcf26b24667a2bded4998', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@2432cc55565916bd7b0686429b733ce3412675ea', + 'https://chromium.googlesource.com/chromium/src/build@0a7d5e2362681513a44b48185b80589a9b6e2f07', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@d8c375426d8f7f4147f7d4109bb63c12655fb8d6', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@ae135d284f82bef1e4bb1837032b28ec96d80760', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@f05ae3297ca17437161afa22ff5058f02907ae5b', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@47c212f7dfd0db682ad64a862ca5ba4efd7a4ae9', + 'https://chromium.googlesource.com/chromium/src/testing@e6c44c92f467e34425694b2db614d2f44ab9307f', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@f6fd5326b855956c71a07c6245c80da4c9d4342f', + 'https://chromium.googlesource.com/chromium/src/third_party@9581bbe80972e69286ac12cb5dd2eaca397c0fa0', 'src/buildtools/linux64': { 'packages': [ @@ -165,7 +165,7 @@ deps = { 'condition': 'checkout_linux', }, 'src/third_party/freetype/src': - 'https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@a960be9e5e9846e1e4e8d2254e0b405fbf84346b', + 'https://chromium.googlesource.com/chromium/src/third_party/freetype2.git@fc15ebe0a629acf769ed8976e3d5b84ee4e01236', 'src/third_party/harfbuzz-ng/src': 'https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git@965cf1d66589b0db60e75961cc58f5a65521078e', 'src/third_party/google_benchmark/src': { @@ -231,7 +231,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@5f95e723334de734243833fd44456be8951ff0a0', + 'https://android.googlesource.com/platform/external/perfetto.git@723b273d391e1b5330dba2cf2c3af6f7f4abea2c', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', 'src/third_party/libyuv': @@ -288,7 +288,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@8ec39e2d1ba06b7d292f2104ffc7a93ccddd8272', + 'https://chromium.googlesource.com/chromium/src/tools@a49530481cc3b53d653bcb4609e11c6e1dcaacdb', 'src/third_party/accessibility_test_framework': { 'packages': [ From df59e5381827113c3eda208a92ce97cce7022c17 Mon Sep 17 00:00:00 2001 From: Jianhui Dai Date: Sat, 19 Mar 2022 15:38:51 +0800 Subject: [PATCH 257/847] Reland "Pacer: Reduce TQ wake up and improve packet size estimation" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update `early_execute_margin` after process packets, and the test case. Original change's description: >Pacer: Reduce TQ wake up and improve packet size estimation > >The TQ Pacer schedules delayed task according to target time of >PacingController. It drains all valid ProcessPackets() in single loop, >denies retired scheduled tasks, and round up the timeout to 1ms. > >This CL also improves packet size estimation in TQ Pacer by removing >zero initialization, and introduces `include_overhead_` configuration. > >Tests: >1. webrtc_perf_tests: MaybeProcessPackets() calls > 2075147 -> 2007995 > >2. module_unittests: MaybeProcessPackets() calls > 203393 -> 183563 > >3. peerconnection_unittests: MaybeProcessPackets() calls > 66713-> 64333 > >Bug: webrtc:13417, webrtc:13437 >Change-Id: I18eb0a36dbe063c606b1f27014df74a65ebfc486 >Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242962 >Reviewed-by: Erik Språng >Reviewed-by: Henrik Boström >Commit-Queue: Erik Språng >Cr-Commit-Position: refs/heads/main@{#36179} Bug: webrtc:13417, webrtc:13437 Change-Id: I79f2554cf02364b67ce7073698611a3ae337a73b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256145 Reviewed-by: Erik Språng Reviewed-by: Henrik Boström Owners-Override: Erik Språng Commit-Queue: Erik Språng Cr-Commit-Position: refs/heads/main@{#36283} --- call/rtp_transport_controller_send.cc | 3 +- modules/pacing/pacing_controller.cc | 296 ++++++++---------- modules/pacing/pacing_controller.h | 13 +- modules/pacing/task_queue_paced_sender.cc | 122 ++++---- modules/pacing/task_queue_paced_sender.h | 6 +- .../task_queue_paced_sender_unittest.cc | 92 ++++-- 6 files changed, 278 insertions(+), 254 deletions(-) diff --git a/call/rtp_transport_controller_send.cc b/call/rtp_transport_controller_send.cc index 9b3f3cc0ab..f3663246ac 100644 --- a/call/rtp_transport_controller_send.cc +++ b/call/rtp_transport_controller_send.cc @@ -77,7 +77,8 @@ RtpTransportControllerSend::PacerSettings::PacerSettings( const WebRtcKeyValueConfig& trials) : tq_disabled("Disabled"), holdback_window("holdback_window", PacingController::kMinSleepTime), - holdback_packets("holdback_packets", -1) { + holdback_packets("holdback_packets", + TaskQueuePacedSender::kNoPacketHoldback) { ParseFieldTrial({&tq_disabled, &holdback_window, &holdback_packets}, trials.Lookup("WebRTC-TaskQueuePacer")); } diff --git a/modules/pacing/pacing_controller.cc b/modules/pacing/pacing_controller.cc index 93bfe7f7eb..7430adf027 100644 --- a/modules/pacing/pacing_controller.cc +++ b/modules/pacing/pacing_controller.cc @@ -38,11 +38,6 @@ constexpr TimeDelta kMaxElapsedTime = TimeDelta::Seconds(2); // time. Applies only to periodic mode. constexpr TimeDelta kMaxProcessingInterval = TimeDelta::Millis(30); -// Allow probes to be processed slightly ahead of inteded send time. Currently -// set to 1ms as this is intended to allow times be rounded down to the nearest -// millisecond. -constexpr TimeDelta kMaxEarlyProbeProcessing = TimeDelta::Millis(1); - constexpr int kFirstPriority = 0; bool IsDisabled(const WebRtcKeyValueConfig& field_trials, @@ -94,6 +89,8 @@ const float PacingController::kDefaultPaceMultiplier = 2.5f; const TimeDelta PacingController::kPausedProcessInterval = kCongestedPacketInterval; const TimeDelta PacingController::kMinSleepTime = TimeDelta::Millis(1); +const TimeDelta PacingController::kMaxEarlyProbeProcessing = + TimeDelta::Millis(1); PacingController::PacingController(Clock* clock, PacketSender* packet_sender, @@ -129,7 +126,7 @@ PacingController::PacingController(Clock* clock, packet_queue_(last_process_time_), packet_counter_(0), congested_(false), - queue_time_limit(kMaxExpectedQueueLength), + queue_time_limit_(kMaxExpectedQueueLength), account_for_audio_(false), include_overhead_(false) { if (!drain_large_queues_) { @@ -202,6 +199,7 @@ void PacingController::SetPacingRates(DataRate pacing_rate, media_rate_ = pacing_rate; padding_rate_ = padding_rate; pacing_bitrate_ = pacing_rate; + media_budget_.set_target_rate_kbps(pacing_rate.kbps()); padding_budget_.set_target_rate_kbps(padding_rate.kbps()); RTC_LOG(LS_VERBOSE) << "bwe:pacer_updated pacing_kbps=" @@ -280,10 +278,7 @@ void PacingController::EnqueuePacketInternal( // Use that as last process time only if it's prior to now. target_process_time = std::min(now, next_send_time); } - - TimeDelta elapsed_time = UpdateTimeAndGetElapsed(target_process_time); - UpdateBudgetWithElapsedTime(elapsed_time); - last_process_time_ = target_process_time; + UpdateBudgetWithElapsedTime(UpdateTimeAndGetElapsed(target_process_time)); } packet_queue_.Push(priority, now, packet_counter_++, std::move(packet)); } @@ -294,7 +289,6 @@ TimeDelta PacingController::UpdateTimeAndGetElapsed(Timestamp now) { if (last_process_time_.IsMinusInfinity() || now < last_process_time_) { return TimeDelta::Zero(); } - RTC_DCHECK_GE(now, last_process_time_); TimeDelta elapsed_time = now - last_process_time_; last_process_time_ = now; if (elapsed_time > kMaxElapsedTime) { @@ -311,8 +305,7 @@ bool PacingController::ShouldSendKeepalive(Timestamp now) const { packet_counter_ == 0) { // We send a padding packet every 500 ms to ensure we won't get stuck in // congested state due to no feedback being received. - TimeDelta elapsed_since_last_send = now - last_send_time_; - if (elapsed_since_last_send >= kCongestedPacketInterval) { + if (now - last_send_time_ >= kCongestedPacketInterval) { return true; } } @@ -321,17 +314,17 @@ bool PacingController::ShouldSendKeepalive(Timestamp now) const { Timestamp PacingController::NextSendTime() const { const Timestamp now = CurrentTime(); + Timestamp next_send_time = Timestamp::PlusInfinity(); if (paused_) { return last_send_time_ + kPausedProcessInterval; } // If probing is active, that always takes priority. - if (prober_.is_probing()) { + if (prober_.is_probing() && !probing_send_failure_) { Timestamp probe_time = prober_.NextProbeTime(now); - // `probe_time` == PlusInfinity indicates no probe scheduled. - if (probe_time != Timestamp::PlusInfinity() && !probing_send_failure_) { - return probe_time; + if (!probe_time.IsPlusInfinity()) { + return probe_time.IsMinusInfinity() ? now : probe_time; } } @@ -343,14 +336,13 @@ Timestamp PacingController::NextSendTime() const { // In dynamic mode, figure out when the next packet should be sent, // given the current conditions. - if (!pace_audio_) { - // Not pacing audio, if leading packet is audio its target send - // time is the time at which it was enqueued. - absl::optional audio_enqueue_time = - packet_queue_.LeadingAudioPacketEnqueueTime(); - if (audio_enqueue_time.has_value()) { - return *audio_enqueue_time; - } + // Not pacing audio, if leading packet is audio its target send + // time is the time at which it was enqueued. + absl::optional unpaced_audio_time = + pace_audio_ ? absl::nullopt + : packet_queue_.LeadingAudioPacketEnqueueTime(); + if (unpaced_audio_time) { + return *unpaced_audio_time; } if (congested_ || packet_counter_ == 0) { @@ -358,71 +350,39 @@ Timestamp PacingController::NextSendTime() const { return last_send_time_ + kCongestedPacketInterval; } - // Check how long until we can send the next media packet. if (media_rate_ > DataRate::Zero() && !packet_queue_.Empty()) { - return std::min(last_send_time_ + kPausedProcessInterval, - last_process_time_ + media_debt_ / media_rate_); - } - - // If we _don't_ have pending packets, check how long until we have - // bandwidth for padding packets. Both media and padding debts must - // have been drained to do this. - if (padding_rate_ > DataRate::Zero() && packet_queue_.Empty()) { + // Check how long until we can send the next media packet. + next_send_time = last_process_time_ + media_debt_ / media_rate_; + } else if (padding_rate_ > DataRate::Zero() && packet_queue_.Empty()) { + // If we _don't_ have pending packets, check how long until we have + // bandwidth for padding packets. Both media and padding debts must + // have been drained to do this. + RTC_DCHECK_GT(media_rate_, DataRate::Zero()); TimeDelta drain_time = std::max(media_debt_ / media_rate_, padding_debt_ / padding_rate_); - return std::min(last_send_time_ + kPausedProcessInterval, - last_process_time_ + drain_time); + next_send_time = last_process_time_ + drain_time; + } else { + // Nothing to do. + next_send_time = last_process_time_ + kPausedProcessInterval; } if (send_padding_if_silent_) { - return last_send_time_ + kPausedProcessInterval; + next_send_time = + std::min(next_send_time, last_send_time_ + kPausedProcessInterval); } - return last_process_time_ + kPausedProcessInterval; + + return next_send_time; } void PacingController::ProcessPackets() { Timestamp now = CurrentTime(); Timestamp target_send_time = now; - if (mode_ == ProcessMode::kDynamic) { - target_send_time = NextSendTime(); - TimeDelta early_execute_margin = - prober_.is_probing() ? kMaxEarlyProbeProcessing : TimeDelta::Zero(); - if (target_send_time.IsMinusInfinity()) { - target_send_time = now; - } else if (now < target_send_time - early_execute_margin) { - // We are too early, but if queue is empty still allow draining some debt. - // Probing is allowed to be sent up to kMinSleepTime early. - TimeDelta elapsed_time = UpdateTimeAndGetElapsed(now); - UpdateBudgetWithElapsedTime(elapsed_time); - return; - } - - if (target_send_time < last_process_time_) { - // After the last process call, at time X, the target send time - // shifted to be earlier than X. This should normally not happen - // but we want to make sure rounding errors or erratic behavior - // of NextSendTime() does not cause issue. In particular, if the - // buffer reduction of - // rate * (target_send_time - previous_process_time) - // in the main loop doesn't clean up the existing debt we may not - // be able to send again. We don't want to check this reordering - // there as it is the normal exit condtion when the buffer is - // exhausted and there are packets in the queue. - UpdateBudgetWithElapsedTime(last_process_time_ - target_send_time); - target_send_time = last_process_time_; - } - } - - Timestamp previous_process_time = last_process_time_; - TimeDelta elapsed_time = UpdateTimeAndGetElapsed(now); if (ShouldSendKeepalive(now)) { + DataSize keepalive_data_sent = DataSize::Zero(); // We can not send padding unless a normal packet has first been sent. If // we do, timestamps get messed up. - if (packet_counter_ == 0) { - last_send_time_ = now; - } else { - DataSize keepalive_data_sent = DataSize::Zero(); + if (packet_counter_ > 0) { std::vector> keepalive_packets = packet_sender_->GeneratePadding(DataSize::Bytes(1)); for (auto& packet : keepalive_packets) { @@ -433,14 +393,29 @@ void PacingController::ProcessPackets() { EnqueuePacket(std::move(packet)); } } - OnPaddingSent(keepalive_data_sent); } + OnPacketSent(RtpPacketMediaType::kPadding, keepalive_data_sent, now); } if (paused_) { return; } + if (mode_ == ProcessMode::kDynamic) { + TimeDelta early_execute_margin = + prober_.is_probing() ? kMaxEarlyProbeProcessing : TimeDelta::Zero(); + + target_send_time = NextSendTime(); + if (now + early_execute_margin < target_send_time) { + // We are too early, but if queue is empty still allow draining some debt. + // Probing is allowed to be sent up to kMinSleepTime early. + UpdateBudgetWithElapsedTime(UpdateTimeAndGetElapsed(now)); + return; + } + } + + TimeDelta elapsed_time = UpdateTimeAndGetElapsed(target_send_time); + if (elapsed_time > TimeDelta::Zero()) { DataRate target_rate = pacing_bitrate_; DataSize queue_size_data = packet_queue_.Size(); @@ -452,7 +427,7 @@ void PacingController::ProcessPackets() { if (drain_large_queues_) { TimeDelta avg_time_left = std::max(TimeDelta::Millis(1), - queue_time_limit - packet_queue_.AverageQueueTime()); + queue_time_limit_ - packet_queue_.AverageQueueTime()); DataRate min_rate_needed = queue_size_data / avg_time_left; if (min_rate_needed > target_rate) { target_rate = min_rate_needed; @@ -467,13 +442,12 @@ void PacingController::ProcessPackets() { // up to (process interval duration) * (target rate), so we only need to // update it once before the packet sending loop. media_budget_.set_target_rate_kbps(target_rate.kbps()); - UpdateBudgetWithElapsedTime(elapsed_time); } else { media_rate_ = target_rate; } + UpdateBudgetWithElapsedTime(elapsed_time); } - bool first_packet_in_probe = false; PacedPacketInfo pacing_info; DataSize recommended_probe_size = DataSize::Zero(); bool is_probing = prober_.is_probing(); @@ -482,9 +456,23 @@ void PacingController::ProcessPackets() { // use actual send time rather than target. pacing_info = prober_.CurrentCluster(now).value_or(PacedPacketInfo()); if (pacing_info.probe_cluster_id != PacedPacketInfo::kNotAProbe) { - first_packet_in_probe = pacing_info.probe_cluster_bytes_sent == 0; recommended_probe_size = prober_.RecommendedMinProbeSize(); RTC_DCHECK_GT(recommended_probe_size, DataSize::Zero()); + + // If first packet in probe, insert a small padding packet so we have a + // more reliable start window for the rate estimation. + if (pacing_info.probe_cluster_bytes_sent == 0) { + auto padding = packet_sender_->GeneratePadding(DataSize::Bytes(1)); + // If no RTP modules sending media are registered, we may not get a + // padding packet back. + if (!padding.empty()) { + // Insert with high priority so larger media packets don't preempt it. + EnqueuePacketInternal(std::move(padding[0]), kFirstPriority); + // We should never get more than one padding packets with a requested + // size of 1 byte. + RTC_DCHECK_EQ(padding.size(), 1u); + } + } } else { // No valid probe cluster returned, probe might have timed out. is_probing = false; @@ -492,102 +480,74 @@ void PacingController::ProcessPackets() { } DataSize data_sent = DataSize::Zero(); - - // The paused state is checked in the loop since it leaves the critical - // section allowing the paused state to be changed from other code. - while (!paused_) { - if (first_packet_in_probe) { - // If first packet in probe, insert a small padding packet so we have a - // more reliable start window for the rate estimation. - auto padding = packet_sender_->GeneratePadding(DataSize::Bytes(1)); - // If no RTP modules sending media are registered, we may not get a - // padding packet back. - if (!padding.empty()) { - // Insert with high priority so larger media packets don't preempt it. - EnqueuePacketInternal(std::move(padding[0]), kFirstPriority); - // We should never get more than one padding packets with a requested - // size of 1 byte. - RTC_DCHECK_EQ(padding.size(), 1u); - } - first_packet_in_probe = false; - } - - if (mode_ == ProcessMode::kDynamic && - previous_process_time < target_send_time) { - // Reduce buffer levels with amount corresponding to time between last - // process and target send time for the next packet. - // If the process call is late, that may be the time between the optimal - // send times for two packets we should already have sent. - UpdateBudgetWithElapsedTime(target_send_time - previous_process_time); - previous_process_time = target_send_time; - } - - // Fetch the next packet, so long as queue is not empty or budget is not + while (true) { + // Fetch packet, so long as queue is not empty or budget is not // exhausted. std::unique_ptr rtp_packet = GetPendingPacket(pacing_info, target_send_time, now); - if (rtp_packet == nullptr) { // No packet available to send, check if we should send padding. DataSize padding_to_add = PaddingToAdd(recommended_probe_size, data_sent); if (padding_to_add > DataSize::Zero()) { std::vector> padding_packets = packet_sender_->GeneratePadding(padding_to_add); - if (padding_packets.empty()) { - // No padding packets were generated, quite send loop. - break; - } - for (auto& packet : padding_packets) { - EnqueuePacket(std::move(packet)); + if (!padding_packets.empty()) { + for (auto& packet : padding_packets) { + EnqueuePacket(std::move(packet)); + } + // Continue loop to send the padding that was just added. + continue; + } else { + // Can't generate padding, still update padding budget for next send + // time. + UpdatePaddingBudgetWithSentData(padding_to_add); } - // Continue loop to send the padding that was just added. - continue; } - // Can't fetch new packet and no padding to send, exit send loop. break; - } - - RTC_DCHECK(rtp_packet); - RTC_DCHECK(rtp_packet->packet_type().has_value()); - const RtpPacketMediaType packet_type = *rtp_packet->packet_type(); - DataSize packet_size = DataSize::Bytes(rtp_packet->payload_size() + - rtp_packet->padding_size()); - - if (include_overhead_) { - packet_size += DataSize::Bytes(rtp_packet->headers_size()) + - transport_overhead_per_packet_; - } + } else { + RTC_DCHECK(rtp_packet); + RTC_DCHECK(rtp_packet->packet_type().has_value()); + const RtpPacketMediaType packet_type = *rtp_packet->packet_type(); + DataSize packet_size = DataSize::Bytes(rtp_packet->payload_size() + + rtp_packet->padding_size()); + + if (include_overhead_) { + packet_size += DataSize::Bytes(rtp_packet->headers_size()) + + transport_overhead_per_packet_; + } - packet_sender_->SendPacket(std::move(rtp_packet), pacing_info); - for (auto& packet : packet_sender_->FetchFec()) { - EnqueuePacket(std::move(packet)); - } - data_sent += packet_size; + packet_sender_->SendPacket(std::move(rtp_packet), pacing_info); + for (auto& packet : packet_sender_->FetchFec()) { + EnqueuePacket(std::move(packet)); + } + data_sent += packet_size; - // Send done, update send/process time to the target send time. - OnPacketSent(packet_type, packet_size, target_send_time); + // Send done, update send time. + OnPacketSent(packet_type, packet_size, now); - // If we are currently probing, we need to stop the send loop when we have - // reached the send target. - if (is_probing && data_sent >= recommended_probe_size) { - break; - } + // If we are currently probing, we need to stop the send loop when we + // have reached the send target. + if (is_probing && data_sent >= recommended_probe_size) { + break; + } - if (mode_ == ProcessMode::kDynamic) { // Update target send time in case that are more packets that we are late // in processing. - Timestamp next_send_time = NextSendTime(); - if (next_send_time.IsMinusInfinity()) { - target_send_time = now; - } else { - target_send_time = std::min(now, next_send_time); + if (mode_ == ProcessMode::kDynamic) { + target_send_time = NextSendTime(); + if (target_send_time > now) { + // Exit loop if not probing. + if (!is_probing) { + break; + } + target_send_time = now; + } + UpdateBudgetWithElapsedTime(UpdateTimeAndGetElapsed(target_send_time)); } } } - last_process_time_ = std::max(last_process_time_, previous_process_time); - if (is_probing) { probing_send_failure_ = data_sent == DataSize::Zero(); if (!probing_send_failure_) { @@ -609,8 +569,8 @@ DataSize PacingController::PaddingToAdd(DataSize recommended_probe_size, } if (packet_counter_ == 0) { - // We can not send padding unless a normal packet has first been sent. If we - // do, timestamps get messed up. + // We can not send padding unless a normal packet has first been sent. If + // we do, timestamps get messed up. return DataSize::Zero(); } @@ -675,25 +635,16 @@ std::unique_ptr PacingController::GetPendingPacket( void PacingController::OnPacketSent(RtpPacketMediaType packet_type, DataSize packet_size, Timestamp send_time) { - if (!first_sent_packet_time_) { + if (!first_sent_packet_time_ && packet_type != RtpPacketMediaType::kPadding) { first_sent_packet_time_ = send_time; } + bool audio_packet = packet_type == RtpPacketMediaType::kAudio; - if (!audio_packet || account_for_audio_) { - // Update media bytes sent. + if ((!audio_packet || account_for_audio_) && packet_size > DataSize::Zero()) { UpdateBudgetWithSentData(packet_size); } - last_send_time_ = send_time; - last_process_time_ = send_time; -} -void PacingController::OnPaddingSent(DataSize data_sent) { - if (data_sent > DataSize::Zero()) { - UpdateBudgetWithSentData(data_sent); - } - Timestamp now = CurrentTime(); - last_send_time_ = now; - last_process_time_ = now; + last_send_time_ = send_time; } void PacingController::UpdateBudgetWithElapsedTime(TimeDelta delta) { @@ -710,17 +661,24 @@ void PacingController::UpdateBudgetWithElapsedTime(TimeDelta delta) { void PacingController::UpdateBudgetWithSentData(DataSize size) { if (mode_ == ProcessMode::kPeriodic) { media_budget_.UseBudget(size.bytes()); - padding_budget_.UseBudget(size.bytes()); } else { media_debt_ += size; media_debt_ = std::min(media_debt_, media_rate_ * kMaxDebtInTime); + } + UpdatePaddingBudgetWithSentData(size); +} + +void PacingController::UpdatePaddingBudgetWithSentData(DataSize size) { + if (mode_ == ProcessMode::kPeriodic) { + padding_budget_.UseBudget(size.bytes()); + } else { padding_debt_ += size; padding_debt_ = std::min(padding_debt_, padding_rate_ * kMaxDebtInTime); } } void PacingController::SetQueueTimeLimit(TimeDelta limit) { - queue_time_limit = limit; + queue_time_limit_ = limit; } } // namespace webrtc diff --git a/modules/pacing/pacing_controller.h b/modules/pacing/pacing_controller.h index 4ec4efaa80..3947f03579 100644 --- a/modules/pacing/pacing_controller.h +++ b/modules/pacing/pacing_controller.h @@ -78,6 +78,11 @@ class PacingController { static const TimeDelta kMinSleepTime; + // Allow probes to be processed slightly ahead of inteded send time. Currently + // set to 1ms as this is intended to allow times be rounded down to the + // nearest millisecond. + static const TimeDelta kMaxEarlyProbeProcessing; + PacingController(Clock* clock, PacketSender* packet_sender, const WebRtcKeyValueConfig& field_trials, @@ -153,6 +158,7 @@ class PacingController { // Updates the number of bytes that can be sent for the next time interval. void UpdateBudgetWithElapsedTime(TimeDelta delta); void UpdateBudgetWithSentData(DataSize size); + void UpdatePaddingBudgetWithSentData(DataSize size); DataSize PaddingToAdd(DataSize recommended_probe_size, DataSize data_sent) const; @@ -164,7 +170,6 @@ class PacingController { void OnPacketSent(RtpPacketMediaType packet_type, DataSize packet_size, Timestamp send_time); - void OnPaddingSent(DataSize padding_sent); Timestamp CurrentTime() const; @@ -190,9 +195,9 @@ class PacingController { mutable Timestamp last_timestamp_; bool paused_; - // In dynamic mode, `media_budget_` and `padding_budget_` will be used to + // In periodic mode, `media_budget_` and `padding_budget_` will be used to // track when packets can be sent. - // In periodic mode, `media_debt_` and `padding_debt_` will be used together + // In dynamic mode, `media_debt_` and `padding_debt_` will be used together // with the target rates. // This is the media budget, keeping track of how many bits of media @@ -222,7 +227,7 @@ class PacingController { bool congested_; - TimeDelta queue_time_limit; + TimeDelta queue_time_limit_; bool account_for_audio_; bool include_overhead_; }; diff --git a/modules/pacing/task_queue_paced_sender.cc b/modules/pacing/task_queue_paced_sender.cc index f6591235b3..4849daf1af 100644 --- a/modules/pacing/task_queue_paced_sender.cc +++ b/modules/pacing/task_queue_paced_sender.cc @@ -15,9 +15,6 @@ #include "absl/memory/memory.h" #include "rtc_base/checks.h" -#include "rtc_base/event.h" -#include "rtc_base/logging.h" -#include "rtc_base/task_utils/to_queued_task.h" #include "rtc_base/trace_event.h" namespace webrtc { @@ -29,6 +26,8 @@ constexpr const char* kSlackedTaskQueuePacedSenderFieldTrial = } // namespace +const int TaskQueuePacedSender::kNoPacketHoldback = -1; + TaskQueuePacedSender::TaskQueuePacedSender( Clock* clock, PacingController::PacketSender* packet_sender, @@ -52,10 +51,11 @@ TaskQueuePacedSender::TaskQueuePacedSender( is_started_(false), is_shutdown_(false), packet_size_(/*alpha=*/0.95), + include_overhead_(false), task_queue_(task_queue_factory->CreateTaskQueue( "TaskQueuePacedSender", TaskQueueFactory::Priority::NORMAL)) { - packet_size_.Apply(1, 0); + RTC_DCHECK_GE(max_hold_back_window_, PacingController::kMinSleepTime); } TaskQueuePacedSender::~TaskQueuePacedSender() { @@ -133,7 +133,11 @@ void TaskQueuePacedSender::EnqueuePackets( task_queue_.PostTask([this, packets_ = std::move(packets)]() mutable { RTC_DCHECK_RUN_ON(&task_queue_); for (auto& packet : packets_) { - packet_size_.Apply(1, packet->size()); + size_t packet_size = packet->payload_size() + packet->padding_size(); + if (include_overhead_) { + packet_size += packet->headers_size(); + } + packet_size_.Apply(1, packet_size); RTC_DCHECK_GE(packet->capture_time(), Timestamp::Zero()); pacing_controller_.EnqueuePacket(std::move(packet)); } @@ -152,6 +156,7 @@ void TaskQueuePacedSender::SetAccountForAudioPackets(bool account_for_audio) { void TaskQueuePacedSender::SetIncludeOverhead() { task_queue_.PostTask([this]() { RTC_DCHECK_RUN_ON(&task_queue_); + include_overhead_ = true; pacing_controller_.SetIncludeOverhead(); MaybeProcessPackets(Timestamp::MinusInfinity()); }); @@ -187,13 +192,16 @@ absl::optional TaskQueuePacedSender::FirstSentPacketTime() const { TimeDelta TaskQueuePacedSender::OldestPacketWaitTime() const { Timestamp oldest_packet = GetStats().oldest_packet_enqueue_time; - if (oldest_packet.IsInfinite()) + if (oldest_packet.IsInfinite()) { return TimeDelta::Zero(); + } // (webrtc:9716): The clock is not always monotonic. Timestamp current = clock_->CurrentTime(); - if (current < oldest_packet) + if (current < oldest_packet) { return TimeDelta::Zero(); + } + return current - oldest_packet; } @@ -206,64 +214,69 @@ void TaskQueuePacedSender::MaybeProcessPackets( Timestamp scheduled_process_time) { RTC_DCHECK_RUN_ON(&task_queue_); +#if RTC_TRACE_EVENTS_ENABLED + TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("webrtc"), + "TaskQueuePacedSender::MaybeProcessPackets"); +#endif + if (is_shutdown_ || !is_started_) { return; } - // Normally, run ProcessPackets() only if this is the scheduled task. - // If it is not but it is already time to process and there either is - // no scheduled task or the schedule has shifted forward in time, run - // anyway and clear any schedule. - Timestamp next_process_time = pacing_controller_.NextSendTime(); + Timestamp next_send_time = pacing_controller_.NextSendTime(); + RTC_DCHECK(next_send_time.IsFinite()); const Timestamp now = clock_->CurrentTime(); - const bool is_scheduled_call = next_process_time_ == scheduled_process_time; - if (is_scheduled_call) { - // Indicate no pending scheduled call. - next_process_time_ = Timestamp::MinusInfinity(); - } - if (is_scheduled_call || - (now >= next_process_time && (next_process_time_.IsInfinite() || - next_process_time < next_process_time_))) { + TimeDelta early_execute_margin = + pacing_controller_.IsProbing() + ? PacingController::kMaxEarlyProbeProcessing + : TimeDelta::Zero(); + + // Process packets and update stats. + while (next_send_time <= now + early_execute_margin) { pacing_controller_.ProcessPackets(); - next_process_time = pacing_controller_.NextSendTime(); + next_send_time = pacing_controller_.NextSendTime(); + RTC_DCHECK(next_send_time.IsFinite()); + + // Probing state could change. Get margin after process packets. + early_execute_margin = pacing_controller_.IsProbing() + ? PacingController::kMaxEarlyProbeProcessing + : TimeDelta::Zero(); } + UpdateStats(); - TimeDelta hold_back_window = max_hold_back_window_; - DataRate pacing_rate = pacing_controller_.pacing_rate(); - DataSize avg_packet_size = DataSize::Bytes(packet_size_.filtered()); - if (max_hold_back_window_in_packets_ > 0 && !pacing_rate.IsZero() && - !avg_packet_size.IsZero()) { - TimeDelta avg_packet_send_time = avg_packet_size / pacing_rate; - hold_back_window = - std::min(hold_back_window, - avg_packet_send_time * max_hold_back_window_in_packets_); + // Ignore retired scheduled task, otherwise reset `next_process_time_`. + if (scheduled_process_time.IsFinite()) { + if (scheduled_process_time != next_process_time_) { + return; + } + next_process_time_ = Timestamp::MinusInfinity(); } - absl::optional time_to_next_process; - if (pacing_controller_.IsProbing() && - next_process_time != next_process_time_) { - // If we're probing and there isn't already a wakeup scheduled for the next - // process time, always post a task and just round sleep time down to - // nearest millisecond. - if (next_process_time.IsMinusInfinity()) { - time_to_next_process = TimeDelta::Zero(); - } else { - time_to_next_process = - std::max(TimeDelta::Zero(), - (next_process_time - now).RoundDownTo(TimeDelta::Millis(1))); + // Do not hold back in probing. + TimeDelta hold_back_window = TimeDelta::Zero(); + if (!pacing_controller_.IsProbing()) { + hold_back_window = max_hold_back_window_; + DataRate pacing_rate = pacing_controller_.pacing_rate(); + if (max_hold_back_window_in_packets_ != kNoPacketHoldback && + !pacing_rate.IsZero() && + packet_size_.filtered() != rtc::ExpFilter::kValueUndefined) { + TimeDelta avg_packet_send_time = + DataSize::Bytes(packet_size_.filtered()) / pacing_rate; + hold_back_window = + std::min(hold_back_window, + avg_packet_send_time * max_hold_back_window_in_packets_); } - } else if (next_process_time_.IsMinusInfinity() || - next_process_time <= next_process_time_ - hold_back_window) { - // Schedule a new task since there is none currently scheduled - // (`next_process_time_` is infinite), or the new process time is at least - // one holdback window earlier than whatever is currently scheduled. - time_to_next_process = std::max(next_process_time - now, hold_back_window); } - if (time_to_next_process) { - // Set a new scheduled process time and post a delayed task. - next_process_time_ = next_process_time; + // Calculate next process time. + TimeDelta time_to_next_process = + std::max(hold_back_window, next_send_time - now - early_execute_margin); + next_send_time = now + time_to_next_process; + // If no in flight task or in flight task is later than `next_send_time`, + // schedule a new one. Previous in flight task will be retired. + if (next_process_time_.IsMinusInfinity() || + next_process_time_ > next_send_time) { // Prefer low precision if allowed and not probing. TaskQueueBase::DelayPrecision precision = allow_low_precision_ && !pacing_controller_.IsProbing() @@ -272,11 +285,10 @@ void TaskQueuePacedSender::MaybeProcessPackets( task_queue_.PostDelayedTaskWithPrecision( precision, - [this, next_process_time]() { MaybeProcessPackets(next_process_time); }, - time_to_next_process->ms()); + [this, next_send_time]() { MaybeProcessPackets(next_send_time); }, + time_to_next_process.RoundUpTo(TimeDelta::Millis(1)).ms()); + next_process_time_ = next_send_time; } - - UpdateStats(); } void TaskQueuePacedSender::UpdateStats() { diff --git a/modules/pacing/task_queue_paced_sender.h b/modules/pacing/task_queue_paced_sender.h index 4df8aafbdb..10fdfd7763 100644 --- a/modules/pacing/task_queue_paced_sender.h +++ b/modules/pacing/task_queue_paced_sender.h @@ -14,9 +14,7 @@ #include #include -#include #include -#include #include #include "absl/base/attributes.h" @@ -31,7 +29,6 @@ #include "modules/pacing/rtp_packet_pacer.h" #include "modules/rtp_rtcp/source/rtp_packet_to_send.h" #include "rtc_base/numerics/exp_filter.h" -#include "rtc_base/synchronization/mutex.h" #include "rtc_base/task_queue.h" #include "rtc_base/thread_annotations.h" @@ -40,6 +37,8 @@ class Clock; class TaskQueuePacedSender : public RtpPacketPacer, public RtpPacketSender { public: + static const int kNoPacketHoldback; + // The `hold_back_window` parameter sets a lower bound on time to sleep if // there is currently a pacer queue and packets can't immediately be // processed. Increasing this reduces thread wakeups at the expense of higher @@ -163,6 +162,7 @@ class TaskQueuePacedSender : public RtpPacketPacer, public RtpPacketSender { // Filtered size of enqueued packets, in bytes. rtc::ExpFilter packet_size_ RTC_GUARDED_BY(task_queue_); + bool include_overhead_ RTC_GUARDED_BY(task_queue_); mutable Mutex stats_mutex_; Stats current_stats_ RTC_GUARDED_BY(stats_mutex_); diff --git a/modules/pacing/task_queue_paced_sender_unittest.cc b/modules/pacing/task_queue_paced_sender_unittest.cc index 420d4f47e5..7b05110822 100644 --- a/modules/pacing/task_queue_paced_sender_unittest.cc +++ b/modules/pacing/task_queue_paced_sender_unittest.cc @@ -41,7 +41,6 @@ constexpr uint32_t kVideoSsrc = 234565; constexpr uint32_t kVideoRtxSsrc = 34567; constexpr uint32_t kFlexFecSsrc = 45678; constexpr size_t kDefaultPacketSize = 1234; -constexpr int kNoPacketHoldback = -1; class MockPacketRouter : public PacketRouter { public: @@ -206,7 +205,7 @@ TEST(TaskQueuePacedSenderTest, PacesPackets) { TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, trials, time_controller.GetTaskQueueFactory(), PacingController::kMinSleepTime, - kNoPacketHoldback); + TaskQueuePacedSender::kNoPacketHoldback); // Insert a number of packets, covering one second. static constexpr size_t kPacketsToSend = 42; @@ -246,7 +245,7 @@ TEST(TaskQueuePacedSenderTest, ReschedulesProcessOnRateChange) { TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, trials, time_controller.GetTaskQueueFactory(), PacingController::kMinSleepTime, - kNoPacketHoldback); + TaskQueuePacedSender::kNoPacketHoldback); // Insert a number of packets to be sent 200ms apart. const size_t kPacketsPerSecond = 5; @@ -298,7 +297,7 @@ TEST(TaskQueuePacedSenderTest, SendsAudioImmediately) { TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, trials, time_controller.GetTaskQueueFactory(), PacingController::kMinSleepTime, - kNoPacketHoldback); + TaskQueuePacedSender::kNoPacketHoldback); const DataRate kPacingDataRate = DataRate::KilobitsPerSec(125); const DataSize kPacketSize = DataSize::Bytes(kDefaultPacketSize); @@ -330,7 +329,8 @@ TEST(TaskQueuePacedSenderTest, SleepsDuringCoalscingWindow) { ScopedKeyValueConfig trials; TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, trials, time_controller.GetTaskQueueFactory(), - kCoalescingWindow, kNoPacketHoldback); + kCoalescingWindow, + TaskQueuePacedSender::kNoPacketHoldback); // Set rates so one packet adds one ms of buffer level. const DataSize kPacketSize = DataSize::Bytes(kDefaultPacketSize); @@ -366,7 +366,8 @@ TEST(TaskQueuePacedSenderTest, ProbingOverridesCoalescingWindow) { ScopedKeyValueConfig trials; TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, trials, time_controller.GetTaskQueueFactory(), - kCoalescingWindow, kNoPacketHoldback); + kCoalescingWindow, + TaskQueuePacedSender::kNoPacketHoldback); // Set rates so one packet adds one ms of buffer level. const DataSize kPacketSize = DataSize::Bytes(kDefaultPacketSize); @@ -390,7 +391,7 @@ TEST(TaskQueuePacedSenderTest, ProbingOverridesCoalescingWindow) { time_controller.AdvanceTime(kCoalescingWindow - TimeDelta::Millis(1)); } -TEST(TaskQueuePacedSenderTest, SchedulesProbeAtSetTime) { +TEST(TaskQueuePacedSenderTest, SchedulesProbeAtSentTime) { ScopedKeyValueConfig trials( "WebRTC-Bwe-ProbingBehavior/min_probe_delta:1ms/"); GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); @@ -398,7 +399,7 @@ TEST(TaskQueuePacedSenderTest, SchedulesProbeAtSetTime) { TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, trials, time_controller.GetTaskQueueFactory(), PacingController::kMinSleepTime, - kNoPacketHoldback); + TaskQueuePacedSender::kNoPacketHoldback); // Set rates so one packet adds 4ms of buffer level. const DataSize kPacketSize = DataSize::Bytes(kDefaultPacketSize); @@ -423,15 +424,16 @@ TEST(TaskQueuePacedSenderTest, SchedulesProbeAtSetTime) { // Advance to less than 3ms before next packet send time. time_controller.AdvanceTime(TimeDelta::Micros(1001)); - // Trigger a probe at 4x the current pacing rate and insert the number of + // Trigger a probe at 2x the current pacing rate and insert the number of // packets the probe needs. const DataRate kProbeRate = 2 * kPacingDataRate; const int kProbeClusterId = 1; pacer.CreateProbeCluster(kProbeRate, kProbeClusterId); - // Expected size for each probe in a cluster is twice the expected bits - // sent during min_probe_delta. - // Expect one additional call since probe always starts with a small + // Expected size for each probe in a cluster is twice the expected bits sent + // during min_probe_delta. + // Expect one additional call since probe always starts with a small (1 byte) + // padding packet that's not counted into the probe rate here. const TimeDelta kProbeTimeDelta = TimeDelta::Millis(2); const DataSize kProbeSize = kProbeRate * kProbeTimeDelta; const size_t kNumPacketsInProbe = @@ -465,7 +467,7 @@ TEST(TaskQueuePacedSenderTest, NoMinSleepTimeWhenProbing) { TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, trials, time_controller.GetTaskQueueFactory(), PacingController::kMinSleepTime, - kNoPacketHoldback); + TaskQueuePacedSender::kNoPacketHoldback); // Set rates so one packet adds 4ms of buffer level. const DataSize kPacketSize = DataSize::Bytes(kDefaultPacketSize); @@ -507,8 +509,8 @@ TEST(TaskQueuePacedSenderTest, NoMinSleepTimeWhenProbing) { // Verify the amount of probing data sent. // Probe always starts with a small (1 byte) padding packet that's not // counted into the probe rate here. - EXPECT_EQ(data_sent, - kProbingRate * TimeDelta::Millis(1) + DataSize::Bytes(1)); + const DataSize kMinProbeSize = 2 * kMinProbeDelta * kProbingRate; + EXPECT_EQ(data_sent, DataSize::Bytes(1) + kPacketSize + 4 * kMinProbeSize); } TEST(TaskQueuePacedSenderTest, PacketBasedCoalescing) { @@ -608,6 +610,50 @@ TEST(TaskQueuePacedSenderTest, FixedHoldBackHasPriorityOverPackets) { time_controller.AdvanceTime(kFixedCoalescingWindow); } +TEST(TaskQueuePacedSenderTest, ProbingStopDuringSendLoop) { + // Set a low `min_probe_delta` to let probing finish during send loop. + ScopedKeyValueConfig trials( + "WebRTC-Bwe-ProbingBehavior/min_probe_delta:100us/"); + + GlobalSimulatedTimeController time_controller(Timestamp::Millis(1234)); + MockPacketRouter packet_router; + TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, trials, + time_controller.GetTaskQueueFactory(), + PacingController::kMinSleepTime, + TaskQueuePacedSender::kNoPacketHoldback); + + // Set rates so 2 packets adds 1ms of buffer level. + const DataSize kPacketSize = DataSize::Bytes(kDefaultPacketSize); + const TimeDelta kPacketPacingTime = TimeDelta::Millis(1); + const DataRate kPacingDataRate = 2 * kPacketSize / kPacketPacingTime; + + pacer.SetPacingRates(kPacingDataRate, DataRate::Zero()); + pacer.EnsureStarted(); + + EXPECT_CALL(packet_router, FetchFec).WillRepeatedly([]() { + return std::vector>(); + }); + EXPECT_CALL(packet_router, GeneratePadding(_)) + .WillRepeatedly( + [](DataSize target_size) { return GeneratePadding(target_size); }); + + // Set probe rate. + const int kProbeClusterId = 1; + const DataRate kProbingRate = kPacingDataRate; + pacer.CreateProbeCluster(kProbingRate, kProbeClusterId); + + const int kPacketsToSend = 100; + const TimeDelta kPacketsPacedTime = + std::max(kPacketsToSend * kPacketSize / kPacingDataRate, + kPacketsToSend * kPacketSize / kProbingRate); + + // Expect all packets and one padding packet sent. + EXPECT_CALL(packet_router, SendPacket).Times(kPacketsToSend + 1); + pacer.EnqueuePackets( + GeneratePackets(RtpPacketMediaType::kVideo, kPacketsToSend)); + time_controller.AdvanceTime(kPacketsPacedTime + TimeDelta::Millis(1)); +} + TEST(TaskQueuePacedSenderTest, Stats) { static constexpr Timestamp kStartTime = Timestamp::Millis(1234); GlobalSimulatedTimeController time_controller(kStartTime); @@ -616,7 +662,7 @@ TEST(TaskQueuePacedSenderTest, Stats) { TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, trials, time_controller.GetTaskQueueFactory(), PacingController::kMinSleepTime, - kNoPacketHoldback); + TaskQueuePacedSender::kNoPacketHoldback); // Simulate ~2mbps video stream, covering one second. static constexpr size_t kPacketsToSend = 200; @@ -688,9 +734,10 @@ TEST(TaskQueuePacedSenderTest, HighPrecisionPacingWhenSlackIsDisabled) { time_controller.GetTaskQueueFactory()); MockPacketRouter packet_router; - TaskQueuePacedSender pacer( - time_controller.GetClock(), &packet_router, experiments, - &task_queue_factory, PacingController::kMinSleepTime, kNoPacketHoldback); + TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, + experiments, &task_queue_factory, + PacingController::kMinSleepTime, + TaskQueuePacedSender::kNoPacketHoldback); // Send enough packets (covering one second) that pacing is triggered, i.e. // delayed tasks being scheduled. @@ -731,9 +778,10 @@ TEST(TaskQueuePacedSenderTest, LowPrecisionPacingWhenSlackIsEnabled) { time_controller.GetTaskQueueFactory()); MockPacketRouter packet_router; - TaskQueuePacedSender pacer( - time_controller.GetClock(), &packet_router, experiments, - &task_queue_factory, PacingController::kMinSleepTime, kNoPacketHoldback); + TaskQueuePacedSender pacer(time_controller.GetClock(), &packet_router, + experiments, &task_queue_factory, + PacingController::kMinSleepTime, + TaskQueuePacedSender::kNoPacketHoldback); // Send enough packets (covering one second) that pacing is triggered, i.e. // delayed tasks being scheduled. From 19a6e9438b12075a72663194d269dcfcdb7bb4fe Mon Sep 17 00:00:00 2001 From: Yury Yaroshevich Date: Fri, 11 Mar 2022 09:22:08 +0100 Subject: [PATCH 258/847] Expose RTCSSLCertificateVerifier from iOS SDK. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:11710 Change-Id: I825c6350a71b2ff180520f8643cbd4d6febdc883 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254821 Reviewed-by: Kári Helgason Reviewed-by: Harald Alvestrand Commit-Queue: Yura Yaroshevich Cr-Commit-Position: refs/heads/main@{#36284} --- sdk/BUILD.gn | 5 ++ .../RTCPeerConnection+Private.h | 13 +++-- .../api/peerconnection/RTCPeerConnection.mm | 6 +++ .../peerconnection/RTCPeerConnectionFactory.h | 9 ++++ .../RTCPeerConnectionFactory.mm | 16 +++++++ sdk/objc/base/RTCSSLCertificateVerifier.h | 25 ++++++++++ .../native/api/ssl_certificate_verifier.h | 26 ++++++++++ .../native/api/ssl_certificate_verifier.mm | 48 +++++++++++++++++++ 8 files changed, 143 insertions(+), 5 deletions(-) create mode 100644 sdk/objc/base/RTCSSLCertificateVerifier.h create mode 100644 sdk/objc/native/api/ssl_certificate_verifier.h create mode 100644 sdk/objc/native/api/ssl_certificate_verifier.mm diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn index a8e246d5f6..729a222564 100644 --- a/sdk/BUILD.gn +++ b/sdk/BUILD.gn @@ -101,6 +101,7 @@ if (is_ios || is_mac) { "objc/base/RTCMacros.h", "objc/base/RTCMutableI420Buffer.h", "objc/base/RTCMutableYUVPlanarBuffer.h", + "objc/base/RTCSSLCertificateVerifier.h", "objc/base/RTCVideoCapturer.h", "objc/base/RTCVideoCapturer.m", "objc/base/RTCVideoCodecInfo.h", @@ -1233,6 +1234,7 @@ if (is_ios || is_mac) { "objc/base/RTCMacros.h", "objc/base/RTCMutableI420Buffer.h", "objc/base/RTCMutableYUVPlanarBuffer.h", + "objc/base/RTCSSLCertificateVerifier.h", "objc/base/RTCVideoCapturer.h", "objc/base/RTCVideoCodecInfo.h", "objc/base/RTCVideoDecoder.h", @@ -1429,6 +1431,7 @@ if (is_ios || is_mac) { "objc/base/RTCMacros.h", "objc/base/RTCMutableI420Buffer.h", "objc/base/RTCMutableYUVPlanarBuffer.h", + "objc/base/RTCSSLCertificateVerifier.h", "objc/base/RTCVideoCapturer.h", "objc/base/RTCVideoCodecInfo.h", "objc/base/RTCVideoDecoder.h", @@ -1528,6 +1531,8 @@ if (is_ios || is_mac) { sources = [ "objc/native/api/network_monitor_factory.h", "objc/native/api/network_monitor_factory.mm", + "objc/native/api/ssl_certificate_verifier.h", + "objc/native/api/ssl_certificate_verifier.mm", "objc/native/api/video_capturer.h", "objc/native/api/video_capturer.mm", "objc/native/api/video_decoder_factory.h", diff --git a/sdk/objc/api/peerconnection/RTCPeerConnection+Private.h b/sdk/objc/api/peerconnection/RTCPeerConnection+Private.h index 43ee420ffe..00f2ef7834 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnection+Private.h +++ b/sdk/objc/api/peerconnection/RTCPeerConnection+Private.h @@ -68,6 +68,8 @@ class PeerConnectionDelegateAdapter : public PeerConnectionObserver { }; } // namespace webrtc +@protocol RTC_OBJC_TYPE +(RTCSSLCertificateVerifier); @interface RTC_OBJC_TYPE (RTCPeerConnection) () @@ -83,11 +85,12 @@ class PeerConnectionDelegateAdapter : public PeerConnectionObserver { /** Initialize an RTCPeerConnection with a configuration, constraints, and * delegate. */ -- (nullable instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory - configuration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration - constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints - delegate: - (nullable id)delegate; +- (nullable instancetype) + initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory + configuration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration + constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints + certificateVerifier:(nullable id)certificateVerifier + delegate:(nullable id)delegate; /** Initialize an RTCPeerConnection with a configuration, constraints, * delegate and PeerConnectionDependencies. diff --git a/sdk/objc/api/peerconnection/RTCPeerConnection.mm b/sdk/objc/api/peerconnection/RTCPeerConnection.mm index 7db986ce1d..203fa4a923 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnection.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnection.mm @@ -34,6 +34,7 @@ #include "api/set_remote_description_observer_interface.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_conversions.h" +#include "sdk/objc/native/api/ssl_certificate_verifier.h" NSString *const kRTCPeerConnectionErrorDomain = @"org.webrtc.RTC_OBJC_TYPE(RTCPeerConnection)"; int const kRTCPeerConnnectionSessionDescriptionError = -1; @@ -336,10 +337,15 @@ @implementation RTC_OBJC_TYPE (RTCPeerConnection) { - (nullable instancetype)initWithFactory:(RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)factory configuration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints + certificateVerifier: + (nullable id)certificateVerifier delegate:(id)delegate { NSParameterAssert(factory); std::unique_ptr dependencies = std::make_unique(nullptr); + if (certificateVerifier != nil) { + dependencies->tls_cert_verifier = webrtc::ObjCToNativeCertificateVerifier(certificateVerifier); + } return [self initWithDependencies:factory configuration:configuration constraints:constraints diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h index 78913527c0..88aac990f2 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h @@ -29,6 +29,8 @@ NS_ASSUME_NONNULL_BEGIN (RTCVideoDecoderFactory); @protocol RTC_OBJC_TYPE (RTCVideoEncoderFactory); +@protocol RTC_OBJC_TYPE +(RTCSSLCertificateVerifier); RTC_OBJC_EXPORT @interface RTC_OBJC_TYPE (RTCPeerConnectionFactory) : NSObject @@ -82,6 +84,13 @@ RTC_OBJC_EXPORT constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints delegate:(nullable id)delegate; +- (nullable RTC_OBJC_TYPE(RTCPeerConnection) *) + peerConnectionWithConfiguration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration + constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints + certificateVerifier: + (id)certificateVerifier + delegate:(nullable id)delegate; + /** Set the options to be used for subsequently created RTCPeerConnections */ - (void)setOptions:(nonnull RTC_OBJC_TYPE(RTCPeerConnectionFactoryOptions) *)options; diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm index 63ba934e3d..f7a17558f0 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm @@ -27,6 +27,7 @@ #import "helpers/NSString+StdString.h" #include "rtc_base/checks.h" #include "sdk/objc/native/api/network_monitor_factory.h" +#include "sdk/objc/native/api/ssl_certificate_verifier.h" #include "system_wrappers/include/field_trial.h" #ifndef HAVE_NO_MEDIA @@ -272,6 +273,21 @@ - (instancetype)initWithNativeAudioEncoderFactory: return [[RTC_OBJC_TYPE(RTCPeerConnection) alloc] initWithFactory:self configuration:configuration constraints:constraints + certificateVerifier:nil + delegate:delegate]; +} + +- (nullable RTC_OBJC_TYPE(RTCPeerConnection) *) + peerConnectionWithConfiguration:(RTC_OBJC_TYPE(RTCConfiguration) *)configuration + constraints:(RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints + certificateVerifier: + (id)certificateVerifier + delegate: + (nullable id)delegate { + return [[RTC_OBJC_TYPE(RTCPeerConnection) alloc] initWithFactory:self + configuration:configuration + constraints:constraints + certificateVerifier:certificateVerifier delegate:delegate]; } diff --git a/sdk/objc/base/RTCSSLCertificateVerifier.h b/sdk/objc/base/RTCSSLCertificateVerifier.h new file mode 100644 index 0000000000..53da0cceff --- /dev/null +++ b/sdk/objc/base/RTCSSLCertificateVerifier.h @@ -0,0 +1,25 @@ +/* + * Copyright 2022 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 + +#import "RTCMacros.h" + +NS_ASSUME_NONNULL_BEGIN + +RTC_OBJC_EXPORT @protocol RTC_OBJC_TYPE +(RTCSSLCertificateVerifier) + + /** The certificate to verify */ + - (BOOL)verify : (NSData *)derCertificate; + +@end + +NS_ASSUME_NONNULL_END diff --git a/sdk/objc/native/api/ssl_certificate_verifier.h b/sdk/objc/native/api/ssl_certificate_verifier.h new file mode 100644 index 0000000000..35ab1be9a8 --- /dev/null +++ b/sdk/objc/native/api/ssl_certificate_verifier.h @@ -0,0 +1,26 @@ +/* + * Copyright 2022 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 SDK_OBJC_NATIVE_API_SSL_CERTIFICATE_VERIFIER_H_ +#define SDK_OBJC_NATIVE_API_SSL_CERTIFICATE_VERIFIER_H_ + +#include + +#import "RTCSSLCertificateVerifier.h" +#include "rtc_base/ssl_certificate.h" + +namespace webrtc { + +std::unique_ptr ObjCToNativeCertificateVerifier( + id objc_certificate_verifier); + +} // namespace webrtc + +#endif // SDK_OBJC_NATIVE_API_SSL_CERTIFICATE_VERIFIER_H_ diff --git a/sdk/objc/native/api/ssl_certificate_verifier.mm b/sdk/objc/native/api/ssl_certificate_verifier.mm new file mode 100644 index 0000000000..4437402b9c --- /dev/null +++ b/sdk/objc/native/api/ssl_certificate_verifier.mm @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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 "ssl_certificate_verifier.h" + +#include "rtc_base/buffer.h" + +namespace { + +class SSLCertificateVerifierAdapter final : public rtc::SSLCertificateVerifier { + public: + SSLCertificateVerifierAdapter( + id objc_certificate_verifier) + : objc_certificate_verifier_(objc_certificate_verifier) { + RTC_DCHECK(objc_certificate_verifier_ != nil); + } + + bool Verify(const rtc::SSLCertificate& certificate) override { + @autoreleasepool { + rtc::Buffer der_buffer; + certificate.ToDER(&der_buffer); + NSData* serialized_certificate = [[NSData alloc] initWithBytes:der_buffer.data() + length:der_buffer.size()]; + return [objc_certificate_verifier_ verify:serialized_certificate]; + } + } + + private: + id objc_certificate_verifier_; +}; + +} + +namespace webrtc { + +std::unique_ptr ObjCToNativeCertificateVerifier( + id objc_certificate_verifier) { + return std::make_unique(objc_certificate_verifier); +} + +} // namespace webrtc From 608f9a54894a220ea5df720af002d2eb43c39c96 Mon Sep 17 00:00:00 2001 From: Salman Malik Date: Mon, 21 Mar 2022 20:16:29 +0000 Subject: [PATCH 259/847] screencast_portal: Allow hooks to adapt behavior for remote desktop Change adds callbacks to the class so that the remote desktop portal can still make use of this class for selecting sources but can provide its own implementation on what to do after the sources are selected. Furthermore, few getters are exposed in the class interface so as to allow the remote desktop portal class to leverage them when sending the captured pipewire frames onto the capture stream's consumer. Setters are added for session, pipewire stream node id and few interfaces are made public since remote desktop portal relies on them (e.g. `SelectSources`). The reason behind the change is that remote desktop portal depends on screen cast portal for selecting sources. Also the setup to select devices to control remotely as well as source selection should be handled as part of the same session (and session should be instantiated only once). Currently, starting the screencast portal calls into a callback chain that not only selects the sources but also starts the session but with this change a consumer, such as remote desktop portal, can hook into this callback chain by overriding the callbacks and provide a custom callback chain from there onwards, if need be. Bug: chromium:1291247 Change-Id: I983aff062ec2ddf52fdef5545fc58fede416e6ed Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/249862 Reviewed-by: Alexander Cooper Commit-Queue: Salman Malik Cr-Commit-Position: refs/heads/main@{#36285} --- .../linux/wayland/screencast_portal.cc | 48 +++++++++++++++++-- .../linux/wayland/screencast_portal.h | 33 ++++++++++++- .../linux/wayland/xdg_desktop_portal_utils.h | 7 +++ 3 files changed, 81 insertions(+), 7 deletions(-) diff --git a/modules/desktop_capture/linux/wayland/screencast_portal.cc b/modules/desktop_capture/linux/wayland/screencast_portal.cc index 0b9db6ffb0..bbf933966b 100644 --- a/modules/desktop_capture/linux/wayland/screencast_portal.cc +++ b/modules/desktop_capture/linux/wayland/screencast_portal.cc @@ -39,7 +39,24 @@ using xdg_portal::TearDownSession; ScreenCastPortal::ScreenCastPortal( ScreenCastPortal::CaptureSourceType source_type, PortalNotifier* notifier) - : notifier_(notifier), capture_source_type_(source_type) {} + : ScreenCastPortal(source_type, + notifier, + OnProxyRequested, + OnSourcesRequestResponseSignal, + this) {} + +ScreenCastPortal::ScreenCastPortal( + CaptureSourceType source_type, + PortalNotifier* notifier, + ProxyRequestResponseHandler proxy_request_response_handler, + SourcesRequestResponseSignalHandler sources_request_response_signal_handler, + gpointer user_data) + : notifier_(notifier), + capture_source_type_(source_type), + proxy_request_response_handler_(proxy_request_response_handler), + sources_request_response_signal_handler_( + sources_request_response_signal_handler), + user_data_(user_data) {} ScreenCastPortal::~ScreenCastPortal() { UnsubscribeSignalHandlers(); @@ -72,10 +89,27 @@ void ScreenCastPortal::UnsubscribeSignalHandlers() { } } +void ScreenCastPortal::SetSessionDetails( + const xdg_portal::SessionDetails& session_details) { + if (session_details.proxy) { + proxy_ = session_details.proxy; + connection_ = g_dbus_proxy_get_connection(proxy_); + } + if (session_details.cancellable) { + cancellable_ = session_details.cancellable; + } + if (!session_details.session_handle.empty()) { + session_handle_ = session_details.session_handle; + } + if (session_details.pipewire_stream_node_id) { + pw_stream_node_id_ = session_details.pipewire_stream_node_id; + } +} + void ScreenCastPortal::Start() { cancellable_ = g_cancellable_new(); - RequestSessionProxy(kScreenCastInterfaceName, OnProxyRequested, cancellable_, - this); + RequestSessionProxy(kScreenCastInterfaceName, proxy_request_response_handler_, + cancellable_, this); } void ScreenCastPortal::PortalFailed(RequestResponse result) { @@ -177,8 +211,8 @@ void ScreenCastPortal::SourcesRequest() { sources_handle_ = PrepareSignalHandle(variant_string.get(), connection_); sources_request_signal_id_ = SetupRequestResponseSignal( - sources_handle_.c_str(), OnSourcesRequestResponseSignal, this, - connection_); + sources_handle_.c_str(), sources_request_response_signal_handler_, + user_data_, connection_); RTC_LOG(LS_INFO) << "Requesting sources from the screen cast session."; g_dbus_proxy_call( @@ -316,6 +350,10 @@ void ScreenCastPortal::OnStartRequestResponseSignal(GDBusConnection* connection, that->OpenPipeWireRemote(); } +uint32_t ScreenCastPortal::pipewire_stream_node_id() { + return pw_stream_node_id_; +} + void ScreenCastPortal::OpenPipeWireRemote() { GVariantBuilder builder; g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT); diff --git a/modules/desktop_capture/linux/wayland/screencast_portal.h b/modules/desktop_capture/linux/wayland/screencast_portal.h index 75884450db..d29f773cb2 100644 --- a/modules/desktop_capture/linux/wayland/screencast_portal.h +++ b/modules/desktop_capture/linux/wayland/screencast_portal.h @@ -21,6 +21,19 @@ namespace webrtc { class ScreenCastPortal { public: + using ProxyRequestResponseHandler = void (*)(GObject* object, + GAsyncResult* result, + gpointer user_data); + + using SourcesRequestResponseSignalHandler = + void (*)(GDBusConnection* connection, + const char* sender_name, + const char* object_path, + const char* interface_name, + const char* signal_name, + GVariant* parameters, + gpointer user_data); + // Values are set based on source type property in // xdg-desktop-portal/screencast // https://github.com/flatpak/xdg-desktop-portal/blob/master/data/org.freedesktop.portal.ScreenCast.xml @@ -57,6 +70,13 @@ class ScreenCastPortal { explicit ScreenCastPortal(ScreenCastPortal::CaptureSourceType source_type, PortalNotifier* notifier); + explicit ScreenCastPortal( + CaptureSourceType source_type, + PortalNotifier* notifier, + ProxyRequestResponseHandler proxy_request_response_handler, + SourcesRequestResponseSignalHandler + sources_request_response_signal_handler, + gpointer user_data); ~ScreenCastPortal(); // Initialize ScreenCastPortal with series of DBus calls where we try to @@ -76,6 +96,13 @@ class ScreenCastPortal { void UnsubscribeSignalHandlers(); + // Set of methods leveraged by remote desktop portal to setup a common session + // with screen cast portal. + void SetSessionDetails(const xdg_portal::SessionDetails& session_details); + uint32_t pipewire_stream_node_id(); + void SourcesRequest(); + void OpenPipeWireRemote(); + private: PortalNotifier* notifier_; @@ -89,6 +116,10 @@ class ScreenCastPortal { CursorMode cursor_mode_ = ScreenCastPortal::CursorMode::kMetadata; + ProxyRequestResponseHandler proxy_request_response_handler_; + SourcesRequestResponseSignalHandler sources_request_response_signal_handler_; + gpointer user_data_; + GDBusConnection* connection_ = nullptr; GDBusProxy* proxy_ = nullptr; GCancellable* cancellable_ = nullptr; @@ -121,7 +152,6 @@ class ScreenCastPortal { const char* signal_name, GVariant* parameters, gpointer user_data); - void SourcesRequest(); static void OnSourcesRequested(GDBusProxy* proxy, GAsyncResult* result, gpointer user_data); @@ -145,7 +175,6 @@ class ScreenCastPortal { GVariant* parameters, gpointer user_data); - void OpenPipeWireRemote(); static void OnOpenPipeWireRemoteRequested(GDBusProxy* proxy, GAsyncResult* result, gpointer user_data); diff --git a/modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.h b/modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.h index 9b7953424d..4fb058c427 100644 --- a/modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.h +++ b/modules/desktop_capture/linux/wayland/xdg_desktop_portal_utils.h @@ -32,6 +32,13 @@ constexpr char kSessionInterfaceName[] = "org.freedesktop.portal.Session"; constexpr char kRequestInterfaceName[] = "org.freedesktop.portal.Request"; constexpr char kScreenCastInterfaceName[] = "org.freedesktop.portal.ScreenCast"; +struct SessionDetails { + GDBusProxy* proxy; + GCancellable* cancellable; + std::string session_handle; + uint32_t pipewire_stream_node_id; +}; + using ProxyRequestCallback = void (*)(GObject*, GAsyncResult*, gpointer); using SessionRequestCallback = void (*)(GDBusProxy*, GAsyncResult*, gpointer); using SessionRequestResponseSignalHandler = void (*)(GDBusConnection*, From 44ff88dd045dcd48e0195d40b058b5c2be6d5c2d Mon Sep 17 00:00:00 2001 From: Joe Downing Date: Mon, 21 Mar 2022 15:52:35 -0700 Subject: [PATCH 260/847] DXGI capturer hangs when changing resolution in detached sessions This CL addresses an issue where the desktop appears to freeze after resizing the desktop in a curtained CRD session when using the DXGI capturer. This problem does not reproduce when using the GDI capturer nor does it reproduce when the Windows session is attached to the local console. After digging in, it appears that the DXGI DuplicateOutput API stops providing updated frame data. No errors are returned but yet no data is produced. The problem is that when in this condition, there isn't a good way to discern between this problem and a case where the desktop is actually static. The DxgiDuplicatorController already contains logic to attempt to capture a frame prior to returning success after reinitialization. This logic works fine in the console case and occasionally works in the detached session case. What I noticed in my reproductions was that DXGI would produce a few frames before hanging (usually 1-2 but sometimes 3 or 4). My solution is to check the session state and adjust the number of frames we attempt to capture (I also simplified the wait logic as there was a bug in the time calc and it seemed more complicated than it needed to be). One option considered would be to introduced a new differ class higher up in the stack which would run the GDI and DXGI capturers in parallel (instead of in the fallback configuration as they are today) however that seemed like overkill for this specific issue. Bug: chromium:1307357 Change-Id: Idba4bb9b2aa7692040344d480be3f0d09b9ce9e9 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256214 Reviewed-by: Alexander Cooper Reviewed-by: Jamie Walch Commit-Queue: Joe Downing Cr-Commit-Position: refs/heads/main@{#36286} --- .../win/dxgi_duplicator_controller.cc | 66 ++++++++++++++----- 1 file changed, 48 insertions(+), 18 deletions(-) diff --git a/modules/desktop_capture/win/dxgi_duplicator_controller.cc b/modules/desktop_capture/win/dxgi_duplicator_controller.cc index 59ad4ebda4..a776896f6c 100644 --- a/modules/desktop_capture/win/dxgi_duplicator_controller.cc +++ b/modules/desktop_capture/win/dxgi_duplicator_controller.cc @@ -25,6 +25,26 @@ namespace webrtc { +namespace { + +constexpr DWORD kInvalidSessionId = 0xFFFFFFFF; + +DWORD GetCurrentSessionId() { + DWORD session_id = kInvalidSessionId; + if (!::ProcessIdToSessionId(::GetCurrentProcessId(), &session_id)) { + RTC_LOG(LS_WARNING) + << "Failed to retrieve current session Id, current binary " + "may not have required priviledge."; + } + return session_id; +} + +bool IsConsoleSession() { + return WTSGetActiveConsoleSessionId() == GetCurrentSessionId(); +} + +} // namespace + // static std::string DxgiDuplicatorController::ResultName( DxgiDuplicatorController::Result result) { @@ -57,14 +77,8 @@ DxgiDuplicatorController::Instance() { // static bool DxgiDuplicatorController::IsCurrentSessionSupported() { - DWORD session_id = 0; - if (!::ProcessIdToSessionId(::GetCurrentProcessId(), &session_id)) { - RTC_LOG(LS_WARNING) - << "Failed to retrieve current session Id, current binary " - "may not have required priviledge."; - return false; - } - return session_id != 0; + DWORD current_session_id = GetCurrentSessionId(); + return current_session_id != kInvalidSessionId && current_session_id != 0; } DxgiDuplicatorController::DxgiDuplicatorController() : refcount_(0) {} @@ -423,15 +437,28 @@ bool DxgiDuplicatorController::EnsureFrameCaptured(Context* context, // On a modern system, the FPS / monitor refresh rate is usually larger than // or equal to 60. So 17 milliseconds is enough to capture at least one frame. const int64_t ms_per_frame = 17; - // Skips the first frame to ensure a full frame refresh has happened before - // this function returns. - const int64_t frames_to_skip = 1; + // Skip frames to ensure a full frame refresh has occurred and the DXGI + // machinery is producing frames before this function returns. + int64_t frames_to_skip = 1; // The total time out milliseconds for this function. If we cannot get enough // frames during this time interval, this function returns false, and cause // the DXGI components to be reinitialized. This usually should not happen // unless the system is switching display mode when this function is being // called. 500 milliseconds should be enough for ~30 frames. const int64_t timeout_ms = 500; + + if (GetNumFramesCaptured() == 0 && !IsConsoleSession()) { + // When capturing a console session, waiting for a single frame is + // sufficient to ensure that DXGI output duplication is working. When the + // session is not attached to the console, it has been observed that DXGI + // may produce up to 4 frames (typically 1-2 though) before stopping. When + // this condition occurs, no errors are returned from the output duplication + // API, it simply appears that nothing is changing on the screen. Thus for + // detached sessions, we need to capture a few extra frames before we can be + // confident that output duplication was initialized properly. + frames_to_skip = 5; + } + if (GetNumFramesCaptured() >= frames_to_skip) { return true; } @@ -450,17 +477,16 @@ bool DxgiDuplicatorController::EnsureFrameCaptured(Context* context, } const int64_t start_ms = rtc::TimeMillis(); - int64_t last_frame_start_ms = 0; while (GetNumFramesCaptured() < frames_to_skip) { - if (GetNumFramesCaptured() > 0) { - // Sleep `ms_per_frame` before capturing next frame to ensure the screen - // has been updated by the video adapter. - webrtc::SleepMs(ms_per_frame - (rtc::TimeMillis() - last_frame_start_ms)); - } - last_frame_start_ms = rtc::TimeMillis(); if (!DoDuplicateAll(context, shared_frame)) { return false; } + + // Calling DoDuplicateAll() may change the number of frames captured. + if (GetNumFramesCaptured() >= frames_to_skip) { + break; + } + if (rtc::TimeMillis() - start_ms > timeout_ms) { RTC_LOG(LS_ERROR) << "Failed to capture " << frames_to_skip << " frames " @@ -468,6 +494,10 @@ bool DxgiDuplicatorController::EnsureFrameCaptured(Context* context, << timeout_ms << " milliseconds."; return false; } + + // Sleep `ms_per_frame` before attempting to capture the next frame to + // ensure the video adapter has time to update the screen. + webrtc::SleepMs(ms_per_frame); } return true; } From 2b168062d614245123bb5adee0957dbd89ef8b55 Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Mon, 21 Mar 2022 21:02:09 -0700 Subject: [PATCH 261/847] Update WebRTC code version (2022-03-22T04:02:08). Bug: None Change-Id: I5732b1ca0e5266952f5d33f9a7257236586c7c79 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256217 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36287} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index b3b6f8b753..15815e0c6d 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 2022-03-21T04:05:30"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-03-22T04:02:07"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From 04c881683d6dabb1ba92fffd0e25c389dc6cb6fa Mon Sep 17 00:00:00 2001 From: Ali Tofigh Date: Mon, 21 Mar 2022 14:47:35 +0100 Subject: [PATCH 262/847] Switch to absl::string_view in field_trial::FindFullName() Bug: webrtc:13579 Change-Id: Iaaea42957afb4af66ad5eea6447e75dddc13b5ea Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256263 Reviewed-by: Niels Moller Commit-Queue: Ali Tofigh Cr-Commit-Position: refs/heads/main@{#36288} --- system_wrappers/include/field_trial.h | 4 +++- system_wrappers/source/field_trial.cc | 14 +++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/system_wrappers/include/field_trial.h b/system_wrappers/include/field_trial.h index 48bad41d5c..5256142b70 100644 --- a/system_wrappers/include/field_trial.h +++ b/system_wrappers/include/field_trial.h @@ -13,6 +13,8 @@ #include +#include "absl/strings/string_view.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. // @@ -61,7 +63,7 @@ namespace field_trial { // if the trial does not exists. // // Note: To keep things tidy append all the trial names with WebRTC. -std::string FindFullName(const std::string& name); +std::string FindFullName(absl::string_view name); // Convenience method, returns true iff FindFullName(name) return a string that // starts with "Enabled". diff --git a/system_wrappers/source/field_trial.cc b/system_wrappers/source/field_trial.cc index 8e447907d7..1eac3ddaa2 100644 --- a/system_wrappers/source/field_trial.cc +++ b/system_wrappers/source/field_trial.cc @@ -102,11 +102,11 @@ std::string MergeFieldTrialsStrings(const char* first, const char* second) { } #ifndef WEBRTC_EXCLUDE_FIELD_TRIAL_DEFAULT -std::string FindFullName(const std::string& name) { +std::string FindFullName(absl::string_view name) { if (trials_init_string == NULL) return std::string(); - std::string trials_string(trials_init_string); + absl::string_view trials_string(trials_init_string); if (trials_string.empty()) return std::string(); @@ -122,14 +122,14 @@ std::string FindFullName(const std::string& name) { if (field_value_end == trials_string.npos || field_value_end == field_name_end + 1) break; - std::string field_name(trials_string, next_item, - field_name_end - next_item); - std::string field_value(trials_string, field_name_end + 1, - field_value_end - field_name_end - 1); + absl::string_view field_name = + trials_string.substr(next_item, field_name_end - next_item); + absl::string_view field_value = trials_string.substr( + field_name_end + 1, field_value_end - field_name_end - 1); next_item = field_value_end + 1; if (name == field_name) - return field_value; + return std::string(field_value); } return std::string(); } From 6dbc1723f1b42d5da68eda8840e09168272d3e11 Mon Sep 17 00:00:00 2001 From: Evan Shrubsole Date: Tue, 22 Mar 2022 12:20:11 +0100 Subject: [PATCH 263/847] [cleanup] Prefer VCMTiming unique_ptr in VideoReceiveStream2 c'tor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ifc2667ef9da38563266fb5ca7800ec757464035e Bug: None Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256363 Reviewed-by: Erik Språng Commit-Queue: Evan Shrubsole Cr-Commit-Position: refs/heads/main@{#36289} --- call/call.cc | 2 +- video/video_receive_stream2.cc | 4 +-- video/video_receive_stream2.h | 2 +- video/video_receive_stream2_unittest.cc | 39 +++++++++++++------------ 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/call/call.cc b/call/call.cc index f2101cfc6b..9db3adc0e1 100644 --- a/call/call.cc +++ b/call/call.cc @@ -1154,7 +1154,7 @@ webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( VideoReceiveStream2* receive_stream = new VideoReceiveStream2( task_queue_factory_, this, num_cpu_cores_, transport_send_->packet_router(), std::move(configuration), - call_stats_.get(), clock_, new VCMTiming(clock_), + call_stats_.get(), clock_, std::make_unique(clock_), &nack_periodic_processor_, decode_sync_.get()); // TODO(bugs.webrtc.org/11993): Set this up asynchronously on the network // thread. diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc index 8a452fa23a..572feaa546 100644 --- a/video/video_receive_stream2.cc +++ b/video/video_receive_stream2.cc @@ -209,7 +209,7 @@ VideoReceiveStream2::VideoReceiveStream2( VideoReceiveStream::Config config, CallStats* call_stats, Clock* clock, - VCMTiming* timing, + std::unique_ptr timing, NackPeriodicProcessor* nack_periodic_processor, DecodeSynchronizer* decode_sync) : task_queue_factory_(task_queue_factory), @@ -225,7 +225,7 @@ VideoReceiveStream2::VideoReceiveStream2( call->worker_thread(), call->trials()), rtp_receive_statistics_(ReceiveStatistics::Create(clock_)), - timing_(timing), + timing_(std::move(timing)), video_receiver_(clock_, timing_.get()), rtp_video_stream_receiver_(call->worker_thread(), clock_, diff --git a/video/video_receive_stream2.h b/video/video_receive_stream2.h index 2b65844c00..ffb1b81f68 100644 --- a/video/video_receive_stream2.h +++ b/video/video_receive_stream2.h @@ -100,7 +100,7 @@ class VideoReceiveStream2 VideoReceiveStream::Config config, CallStats* call_stats, Clock* clock, - VCMTiming* timing, + std::unique_ptr timing, NackPeriodicProcessor* nack_periodic_processor, DecodeSynchronizer* decode_sync); // Destruction happens on the worker thread. Prior to destruction the caller diff --git a/video/video_receive_stream2_unittest.cc b/video/video_receive_stream2_unittest.cc index c7718454fb..6a719e7d84 100644 --- a/video/video_receive_stream2_unittest.cc +++ b/video/video_receive_stream2_unittest.cc @@ -17,6 +17,7 @@ #include #include +#include "absl/memory/memory.h" #include "api/task_queue/default_task_queue_factory.h" #include "api/test/mock_video_decoder.h" #include "api/test/mock_video_decoder_factory.h" @@ -106,8 +107,8 @@ class VideoReceiveStream2Test : public ::testing::Test { video_receive_stream_ = std::make_unique( task_queue_factory_.get(), &fake_call_, kDefaultNumCpuCores, - &packet_router_, config_.Copy(), &call_stats_, clock_, timing_, - &nack_periodic_processor_, nullptr); + &packet_router_, config_.Copy(), &call_stats_, clock_, + absl::WrapUnique(timing_), &nack_periodic_processor_, nullptr); video_receive_stream_->RegisterWithTransport( &rtp_stream_receiver_controller_); } @@ -283,10 +284,11 @@ class VideoReceiveStream2TestWithFakeDecoder : public ::testing::Test { video_receive_stream_ = nullptr; } timing_ = new VCMTiming(clock_); - video_receive_stream_.reset(new webrtc::internal::VideoReceiveStream2( - task_queue_factory_.get(), &fake_call_, kDefaultNumCpuCores, - &packet_router_, config_.Copy(), &call_stats_, clock_, timing_, - &nack_periodic_processor_, nullptr)); + video_receive_stream_ = + std::make_unique( + task_queue_factory_.get(), &fake_call_, kDefaultNumCpuCores, + &packet_router_, config_.Copy(), &call_stats_, clock_, + absl::WrapUnique(timing_), &nack_periodic_processor_, nullptr); video_receive_stream_->RegisterWithTransport( &rtp_stream_receiver_controller_); video_receive_stream_->SetAndGetRecordingState(std::move(state), false); @@ -545,16 +547,17 @@ class VideoReceiveStream2TestWithSimulatedClock &fake_decoder_factory_, &fake_renderer_)), call_stats_(time_controller_.GetClock(), loop_.task_queue()), - video_receive_stream_(time_controller_.GetTaskQueueFactory(), - &fake_call_, - /*num_cores=*/2, - &packet_router_, - config_.Copy(), - &call_stats_, - time_controller_.GetClock(), - new VCMTiming(time_controller_.GetClock()), - &nack_periodic_processor_, - nullptr) { + video_receive_stream_( + time_controller_.GetTaskQueueFactory(), + &fake_call_, + /*num_cores=*/2, + &packet_router_, + config_.Copy(), + &call_stats_, + time_controller_.GetClock(), + std::make_unique(time_controller_.GetClock()), + &nack_periodic_processor_, + nullptr) { if (std::get<1>(GetParam())) { fake_call_.SetFieldTrial("WebRTC-FrameBuffer3/arm:FrameBuffer3/"); } else { @@ -741,8 +744,8 @@ class VideoReceiveStream2TestWithLazyDecoderCreation : public ::testing::Test { video_receive_stream_ = std::make_unique( task_queue_factory_.get(), &fake_call_, kDefaultNumCpuCores, - &packet_router_, config_.Copy(), &call_stats_, clock_, timing_, - &nack_periodic_processor_, nullptr); + &packet_router_, config_.Copy(), &call_stats_, clock_, + absl::WrapUnique(timing_), &nack_periodic_processor_, nullptr); video_receive_stream_->RegisterWithTransport( &rtp_stream_receiver_controller_); } From ed3832b89f50638ec27a7764f712ca019c2db0db Mon Sep 17 00:00:00 2001 From: Tommi Date: Tue, 22 Mar 2022 11:54:09 +0100 Subject: [PATCH 264/847] Make sure OnChanged() notifications are handled, post construction. If an instance of AudioRtpReceiver was initialized with a valid media channel pointer (i.e. SetMediaChannel() was not being called), then OnChanged() notification would not be handled correctly. This fixes the issue by making sure the safety flag is marked as 'alive' when [re]starting the media channel. Bug: webrtc:13854 Fixes: webrtc:13854 Change-Id: Iaa5cfeb4036bfc9dc2efbfa9e1319d508ab151a9 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256361 Reviewed-by: Harald Alvestrand Commit-Queue: Tomas Gunnarsson Cr-Commit-Position: refs/heads/main@{#36290} --- pc/audio_rtp_receiver.cc | 5 +++++ pc/audio_rtp_receiver_unittest.cc | 31 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/pc/audio_rtp_receiver.cc b/pc/audio_rtp_receiver.cc index 3a306720c7..58f4dfafe2 100644 --- a/pc/audio_rtp_receiver.cc +++ b/pc/audio_rtp_receiver.cc @@ -191,6 +191,11 @@ void AudioRtpReceiver::RestartMediaChannel_w( if (!media_channel_) return; // Can't restart. + // Make sure the safety flag is marked as `alive` for cases where the media + // channel was provided via the ctor and not an explicit call to + // SetMediaChannel. + worker_thread_safety_->SetAlive(); + if (state != MediaSourceInterface::kInitializing) { if (ssrc_ == ssrc) return; diff --git a/pc/audio_rtp_receiver_unittest.cc b/pc/audio_rtp_receiver_unittest.cc index ac843fe9c2..de72d3f9fb 100644 --- a/pc/audio_rtp_receiver_unittest.cc +++ b/pc/audio_rtp_receiver_unittest.cc @@ -18,6 +18,7 @@ #include "rtc_base/thread.h" #include "test/gmock.h" #include "test/gtest.h" +#include "test/run_loop.h" using ::testing::_; using ::testing::InvokeWithoutArgs; @@ -93,4 +94,34 @@ TEST_F(AudioRtpReceiverTest, VolumesSetBeforeStartingAreRespected) { receiver_->SetupMediaChannel(kSsrc); } + +// Tests that OnChanged notifications are processed correctly on the worker +// thread when a media channel pointer is passed to the receiver via the +// constructor. +TEST(AudioRtpReceiver, OnChangedNotificationsAfterConstruction) { + webrtc::test::RunLoop loop; + auto* thread = rtc::Thread::Current(); // Points to loop's thread. + cricket::MockVoiceMediaChannel media_channel(thread); + auto receiver = rtc::make_ref_counted( + thread, std::string(), std::vector(), true, &media_channel); + + EXPECT_CALL(media_channel, SetDefaultRawAudioSink(_)).Times(1); + EXPECT_CALL(media_channel, SetDefaultOutputVolume(kDefaultVolume)).Times(1); + receiver->SetupUnsignaledMediaChannel(); + loop.Flush(); + + // Mark the track as disabled. + receiver->track()->set_enabled(false); + + // When the track was marked as disabled, an async notification was queued + // for the worker thread. This notification should trigger the volume + // of the media channel to be set to kVolumeMuted. + // Flush the worker thread, but set the expectation first for the call. + EXPECT_CALL(media_channel, SetDefaultOutputVolume(kVolumeMuted)).Times(1); + loop.Flush(); + + EXPECT_CALL(media_channel, SetDefaultOutputVolume(kVolumeMuted)).Times(1); + receiver->SetMediaChannel(nullptr); +} + } // namespace webrtc From 6ceb81f62b5216f4378601483b423ec9de1a0355 Mon Sep 17 00:00:00 2001 From: Ali Tofigh Date: Mon, 21 Mar 2022 17:48:04 +0100 Subject: [PATCH 265/847] Clean up SimpleStringBuilder after absl::string_view adoption Bug: webrtc:13579 Change-Id: I8fdc65e19893c9a96b263bbc99c4f9139fa4b78f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256268 Reviewed-by: Mirko Bonadei Reviewed-by: Harald Alvestrand Commit-Queue: Ali Tofigh Cr-Commit-Position: refs/heads/main@{#36291} --- rtc_base/strings/string_builder.cc | 24 ++++++++++-------------- rtc_base/strings/string_builder.h | 4 ---- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/rtc_base/strings/string_builder.cc b/rtc_base/strings/string_builder.cc index e3e25e631b..a419b0b3cc 100644 --- a/rtc_base/strings/string_builder.cc +++ b/rtc_base/strings/string_builder.cc @@ -28,11 +28,19 @@ SimpleStringBuilder::SimpleStringBuilder(rtc::ArrayView buffer) } SimpleStringBuilder& SimpleStringBuilder::operator<<(char ch) { - return Append(&ch, 1); + return operator<<(absl::string_view(&ch, 1)); } SimpleStringBuilder& SimpleStringBuilder::operator<<(absl::string_view str) { - return Append(str.data(), str.length()); + RTC_DCHECK_LT(size_ + str.length(), buffer_.size()) + << "Buffer size was insufficient"; + const size_t chars_added = + rtc::SafeMin(str.length(), buffer_.size() - size_ - 1); + memcpy(&buffer_[size_], str.data(), chars_added); + size_ += chars_added; + buffer_[size_] = '\0'; + RTC_DCHECK(IsConsistent()); + return *this; } // Numeric conversion routines. @@ -103,18 +111,6 @@ SimpleStringBuilder& SimpleStringBuilder::AppendFormat(const char* fmt, ...) { return *this; } -SimpleStringBuilder& SimpleStringBuilder::Append(const char* str, - size_t length) { - RTC_DCHECK_LT(size_ + length, buffer_.size()) - << "Buffer size was insufficient"; - const size_t chars_added = rtc::SafeMin(length, buffer_.size() - size_ - 1); - memcpy(&buffer_[size_], str, chars_added); - size_ += chars_added; - buffer_[size_] = '\0'; - RTC_DCHECK(IsConsistent()); - return *this; -} - StringBuilder& StringBuilder::AppendFormat(const char* fmt, ...) { va_list args, copy; va_start(args, fmt); diff --git a/rtc_base/strings/string_builder.h b/rtc_base/strings/string_builder.h index b35b7f1867..00986371d3 100644 --- a/rtc_base/strings/string_builder.h +++ b/rtc_base/strings/string_builder.h @@ -60,10 +60,6 @@ class SimpleStringBuilder { SimpleStringBuilder& AppendFormat(const char* fmt, ...); - // An alternate way from operator<<() to append a string. This variant is - // slightly more efficient when the length of the string to append, is known. - SimpleStringBuilder& Append(const char* str, size_t length); - private: bool IsConsistent() const { return size_ <= buffer_.size() - 1 && buffer_[size_] == '\0'; From 92e89d7f77bf637538abb1f9f898de87d3c2edaa Mon Sep 17 00:00:00 2001 From: Evan Shrubsole Date: Tue, 22 Mar 2022 10:55:15 +0100 Subject: [PATCH 266/847] [cleanup] Return struct from VCMTiming::GetTimings Cleans callers having to initialize TimeDeltas. Change-Id: Ib00a59bedf05fb82c9fde1d9fdd1e341e2132cb8 Bug: None Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256360 Reviewed-by: Philip Eliasson Reviewed-by: Ilya Nikolaevskiy Commit-Queue: Evan Shrubsole Cr-Commit-Position: refs/heads/main@{#36292} --- modules/video_coding/frame_buffer2.cc | 15 +++++-------- .../video_coding/frame_buffer2_unittest.cc | 21 +++---------------- modules/video_coding/receiver_unittest.cc | 13 +++++------- modules/video_coding/timing.cc | 21 +++++++------------ modules/video_coding/timing.h | 16 ++++++++------ video/frame_buffer_proxy.cc | 16 +++++--------- 6 files changed, 36 insertions(+), 66 deletions(-) diff --git a/modules/video_coding/frame_buffer2.cc b/modules/video_coding/frame_buffer2.cc index de239817e6..b4b9c117b9 100644 --- a/modules/video_coding/frame_buffer2.cc +++ b/modules/video_coding/frame_buffer2.cc @@ -596,17 +596,12 @@ void FrameBuffer::UpdateJitterDelay() { if (!stats_callback_) return; - TimeDelta max_decode = TimeDelta::Zero(); - TimeDelta current_delay = TimeDelta::Zero(); - TimeDelta target_delay = TimeDelta::Zero(); - TimeDelta jitter_buffer = TimeDelta::Zero(); - TimeDelta min_playout_delay = TimeDelta::Zero(); - TimeDelta render_delay = TimeDelta::Zero(); - if (timing_->GetTimings(&max_decode, ¤t_delay, &target_delay, - &jitter_buffer, &min_playout_delay, &render_delay)) { + auto timings = timing_->GetTimings(); + if (timings.num_decoded_frames > 0) { stats_callback_->OnFrameBufferTimingsUpdated( - max_decode.ms(), current_delay.ms(), target_delay.ms(), - jitter_buffer.ms(), min_playout_delay.ms(), render_delay.ms()); + timings.max_decode_duration.ms(), timings.current_delay.ms(), + timings.target_delay.ms(), timings.jitter_buffer_delay.ms(), + timings.min_playout_delay.ms(), timings.render_delay.ms()); } } diff --git a/modules/video_coding/frame_buffer2_unittest.cc b/modules/video_coding/frame_buffer2_unittest.cc index 4811635d64..d8ba8633a5 100644 --- a/modules/video_coding/frame_buffer2_unittest.cc +++ b/modules/video_coding/frame_buffer2_unittest.cc @@ -65,25 +65,8 @@ class VCMTimingFake : public VCMTiming { return render_time - now - kDecodeTime; } - bool GetTimings(TimeDelta* max_decode, - TimeDelta* current_delay, - TimeDelta* target_delay, - TimeDelta* jitter_buffer, - TimeDelta* min_playout_delay, - TimeDelta* render_delay) const override { - return true; - } - TimeDelta GetCurrentJitter() { - TimeDelta max_decode = TimeDelta::Zero(); - TimeDelta current_delay = TimeDelta::Zero(); - TimeDelta target_delay = TimeDelta::Zero(); - TimeDelta jitter_buffer = TimeDelta::Zero(); - TimeDelta min_playout_delay = TimeDelta::Zero(); - TimeDelta render_delay = TimeDelta::Zero(); - VCMTiming::GetTimings(&max_decode, ¤t_delay, &target_delay, - &jitter_buffer, &min_playout_delay, &render_delay); - return jitter_buffer; + return VCMTiming::GetTimings().jitter_buffer_delay; } private: @@ -538,6 +521,8 @@ TEST_F(TestFrameBuffer2, StatsCallback) { EXPECT_CALL(stats_callback_, OnCompleteFrame(true, kFrameSize, VideoContentType::UNSPECIFIED)); EXPECT_CALL(stats_callback_, OnFrameBufferTimingsUpdated(_, _, _, _, _, _)); + // Stats callback requires a previously decoded frame. + timing_.StopDecodeTimer(TimeDelta::Millis(1), Timestamp::Zero()); { std::unique_ptr frame(new FrameObjectFake()); diff --git a/modules/video_coding/receiver_unittest.cc b/modules/video_coding/receiver_unittest.cc index 73c88a5800..e38f9c5d21 100644 --- a/modules/video_coding/receiver_unittest.cc +++ b/modules/video_coding/receiver_unittest.cc @@ -448,11 +448,9 @@ TEST_F(VCMReceiverTimingTest, FrameForDecodingPreferLateDecoding) { int64_t arrive_timestamps[kNumFrames]; int64_t render_timestamps[kNumFrames]; - TimeDelta render_delay_ms = TimeDelta::Zero(); - TimeDelta max_decode_ms = TimeDelta::Zero(); - TimeDelta dummy = TimeDelta::Zero(); - timing_.GetTimings(&max_decode_ms, &dummy, &dummy, &dummy, &dummy, - &render_delay_ms); + auto timings = timing_.GetTimings(); + TimeDelta render_delay = timings.render_delay; + TimeDelta max_decode = timings.max_decode_duration; // Construct test samples. // render_timestamps are the timestamps stored in the Frame; @@ -479,9 +477,8 @@ TEST_F(VCMReceiverTimingTest, FrameForDecodingPreferLateDecoding) { receiver_.FrameForDecoding(kMaxWaitTime, prefer_late_decoding); int64_t end_time = clock_.TimeInMilliseconds(); if (frame) { - EXPECT_EQ( - frame->RenderTimeMs() - max_decode_ms.ms() - render_delay_ms.ms(), - end_time); + EXPECT_EQ(frame->RenderTimeMs() - max_decode.ms() - render_delay.ms(), + end_time); receiver_.ReleaseFrame(frame); ++num_frames_return; } else { diff --git a/modules/video_coding/timing.cc b/modules/video_coding/timing.cc index 89159f6a3a..390a49939e 100644 --- a/modules/video_coding/timing.cc +++ b/modules/video_coding/timing.cc @@ -238,20 +238,15 @@ TimeDelta VCMTiming::TargetDelayInternal() const { jitter_delay_ + RequiredDecodeTime() + render_delay_); } -bool VCMTiming::GetTimings(TimeDelta* max_decode, - TimeDelta* current_delay, - TimeDelta* target_delay, - TimeDelta* jitter_buffer, - TimeDelta* min_playout_delay, - TimeDelta* render_delay) const { +VCMTiming::VideoDelayTimings VCMTiming::GetTimings() const { MutexLock lock(&mutex_); - *max_decode = RequiredDecodeTime(); - *current_delay = current_delay_; - *target_delay = TargetDelayInternal(); - *jitter_buffer = jitter_delay_; - *min_playout_delay = min_playout_delay_; - *render_delay = render_delay_; - return (num_decoded_frames_ > 0); + return VideoDelayTimings{.max_decode_duration = RequiredDecodeTime(), + .current_delay = current_delay_, + .target_delay = TargetDelayInternal(), + .jitter_buffer_delay = jitter_delay_, + .min_playout_delay = min_playout_delay_, + .render_delay = render_delay_, + .num_decoded_frames = num_decoded_frames_}; } void VCMTiming::SetTimingFrameInfo(const TimingFrameInfo& info) { diff --git a/modules/video_coding/timing.h b/modules/video_coding/timing.h index 8ab2f685ec..af3974a351 100644 --- a/modules/video_coding/timing.h +++ b/modules/video_coding/timing.h @@ -94,12 +94,16 @@ class VCMTiming { // Return current timing information. Returns true if the first frame has been // decoded, false otherwise. - virtual bool GetTimings(TimeDelta* max_decode, - TimeDelta* current_delay, - TimeDelta* target_delay, - TimeDelta* jitter_buffer, - TimeDelta* min_playout_delay, - TimeDelta* render_delay) const; + struct VideoDelayTimings { + TimeDelta max_decode_duration; + TimeDelta current_delay; + TimeDelta target_delay; + TimeDelta jitter_buffer_delay; + TimeDelta min_playout_delay; + TimeDelta render_delay; + size_t num_decoded_frames; + }; + VideoDelayTimings GetTimings() const; void SetTimingFrameInfo(const TimingFrameInfo& info); absl::optional GetTimingFrameInfo(); diff --git a/video/frame_buffer_proxy.cc b/video/frame_buffer_proxy.cc index 657ffe9286..c3d01c5414 100644 --- a/video/frame_buffer_proxy.cc +++ b/video/frame_buffer_proxy.cc @@ -405,18 +405,12 @@ class FrameBuffer3Proxy : public FrameBufferProxy { } void UpdateJitterDelay() { - TimeDelta max_decode = TimeDelta::Zero(); - TimeDelta current_delay = TimeDelta::Zero(); - TimeDelta target_delay = TimeDelta::Zero(); - TimeDelta jitter_buffer = TimeDelta::Zero(); - TimeDelta min_playout_delay = TimeDelta::Zero(); - TimeDelta render_delay = TimeDelta::Zero(); - if (timing_->GetTimings(&max_decode, ¤t_delay, &target_delay, - &jitter_buffer, &min_playout_delay, - &render_delay)) { + auto timings = timing_->GetTimings(); + if (timings.num_decoded_frames) { stats_proxy_->OnFrameBufferTimingsUpdated( - max_decode.ms(), current_delay.ms(), target_delay.ms(), - jitter_buffer.ms(), min_playout_delay.ms(), render_delay.ms()); + timings.max_decode_duration.ms(), timings.current_delay.ms(), + timings.target_delay.ms(), timings.jitter_buffer_delay.ms(), + timings.min_playout_delay.ms(), timings.render_delay.ms()); } } From 8f1159b51865fe6af6764ff93d575b5760ec7de8 Mon Sep 17 00:00:00 2001 From: Evan Shrubsole Date: Tue, 22 Mar 2022 12:12:17 +0100 Subject: [PATCH 267/847] [cleanup] Remove VCMTiming::get_min/max_playout_delay These methods were only used for testing. Change-Id: Icbb6a3cc59cbc0b5e1f42efcb86a7203704b92d8 Bug: None Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256362 Reviewed-by: Ilya Nikolaevskiy Commit-Queue: Evan Shrubsole Cr-Commit-Position: refs/heads/main@{#36293} --- modules/video_coding/timing.cc | 11 +------- modules/video_coding/timing.h | 3 +- video/video_receive_stream2_unittest.cc | 37 +++++++++++++++---------- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/modules/video_coding/timing.cc b/modules/video_coding/timing.cc index 390a49939e..72d1414b73 100644 --- a/modules/video_coding/timing.cc +++ b/modules/video_coding/timing.cc @@ -68,21 +68,11 @@ void VCMTiming::set_min_playout_delay(TimeDelta min_playout_delay) { min_playout_delay_ = min_playout_delay; } -TimeDelta VCMTiming::min_playout_delay() { - MutexLock lock(&mutex_); - return min_playout_delay_; -} - void VCMTiming::set_max_playout_delay(TimeDelta max_playout_delay) { MutexLock lock(&mutex_); max_playout_delay_ = max_playout_delay; } -TimeDelta VCMTiming::max_playout_delay() { - MutexLock lock(&mutex_); - return max_playout_delay_; -} - void VCMTiming::SetJitterDelay(TimeDelta jitter_delay) { MutexLock lock(&mutex_); if (jitter_delay != jitter_delay_) { @@ -245,6 +235,7 @@ VCMTiming::VideoDelayTimings VCMTiming::GetTimings() const { .target_delay = TargetDelayInternal(), .jitter_buffer_delay = jitter_delay_, .min_playout_delay = min_playout_delay_, + .max_playout_delay = max_playout_delay_, .render_delay = render_delay_, .num_decoded_frames = num_decoded_frames_}; } diff --git a/modules/video_coding/timing.h b/modules/video_coding/timing.h index af3974a351..c1f1c3a150 100644 --- a/modules/video_coding/timing.h +++ b/modules/video_coding/timing.h @@ -47,11 +47,9 @@ class VCMTiming { // Set/get the minimum playout delay from capture to render. void set_min_playout_delay(TimeDelta min_playout_delay); - TimeDelta min_playout_delay(); // Set/get the maximum playout delay from capture to render in ms. void set_max_playout_delay(TimeDelta max_playout_delay); - TimeDelta max_playout_delay(); // Increases or decreases the current delay to get closer to the target delay. // Calculates how long it has been since the previous call to this function, @@ -100,6 +98,7 @@ class VCMTiming { TimeDelta target_delay; TimeDelta jitter_buffer_delay; TimeDelta min_playout_delay; + TimeDelta max_playout_delay; TimeDelta render_delay; size_t num_decoded_frames; }; diff --git a/video/video_receive_stream2_unittest.cc b/video/video_receive_stream2_unittest.cc index 6a719e7d84..b90deaa278 100644 --- a/video/video_receive_stream2_unittest.cc +++ b/video/video_receive_stream2_unittest.cc @@ -164,30 +164,36 @@ TEST_F(VideoReceiveStream2Test, PlayoutDelay) { test_frame->SetPlayoutDelay(kPlayoutDelayMs); video_receive_stream_->OnCompleteFrame(std::move(test_frame)); - EXPECT_EQ(kPlayoutDelayMs.min_ms, timing_->min_playout_delay().ms()); - EXPECT_EQ(kPlayoutDelayMs.max_ms, timing_->max_playout_delay().ms()); + auto timings = timing_->GetTimings(); + EXPECT_EQ(kPlayoutDelayMs.min_ms, timings.min_playout_delay.ms()); + EXPECT_EQ(kPlayoutDelayMs.max_ms, timings.max_playout_delay.ms()); // Check that the biggest minimum delay is chosen. video_receive_stream_->SetMinimumPlayoutDelay(400); - EXPECT_EQ(400, timing_->min_playout_delay().ms()); + timings = timing_->GetTimings(); + EXPECT_EQ(400, timings.min_playout_delay.ms()); // Check base minimum delay validation. EXPECT_FALSE(video_receive_stream_->SetBaseMinimumPlayoutDelayMs(12345)); EXPECT_FALSE(video_receive_stream_->SetBaseMinimumPlayoutDelayMs(-1)); EXPECT_TRUE(video_receive_stream_->SetBaseMinimumPlayoutDelayMs(500)); - EXPECT_EQ(500, timing_->min_playout_delay().ms()); + timings = timing_->GetTimings(); + EXPECT_EQ(500, timings.min_playout_delay.ms()); // Check that intermidiate values are remembered and the biggest remembered // is chosen. video_receive_stream_->SetBaseMinimumPlayoutDelayMs(0); - EXPECT_EQ(400, timing_->min_playout_delay().ms()); + timings = timing_->GetTimings(); + EXPECT_EQ(400, timings.min_playout_delay.ms()); video_receive_stream_->SetMinimumPlayoutDelay(0); - EXPECT_EQ(123, timing_->min_playout_delay().ms()); + timings = timing_->GetTimings(); + EXPECT_EQ(123, timings.min_playout_delay.ms()); } TEST_F(VideoReceiveStream2Test, PlayoutDelayPreservesDefaultMaxValue) { - const TimeDelta default_max_playout_latency = timing_->max_playout_delay(); + const TimeDelta default_max_playout_latency = + timing_->GetTimings().max_playout_delay; const VideoPlayoutDelay kPlayoutDelayMs = {123, -1}; std::unique_ptr test_frame(new FrameObjectFake()); @@ -197,13 +203,15 @@ TEST_F(VideoReceiveStream2Test, PlayoutDelayPreservesDefaultMaxValue) { video_receive_stream_->OnCompleteFrame(std::move(test_frame)); // Ensure that -1 preserves default maximum value from `timing_`. - EXPECT_EQ(kPlayoutDelayMs.min_ms, timing_->min_playout_delay().ms()); - EXPECT_NE(kPlayoutDelayMs.max_ms, timing_->max_playout_delay().ms()); - EXPECT_EQ(default_max_playout_latency, timing_->max_playout_delay()); + auto timings = timing_->GetTimings(); + EXPECT_EQ(kPlayoutDelayMs.min_ms, timings.min_playout_delay.ms()); + EXPECT_NE(kPlayoutDelayMs.max_ms, timings.max_playout_delay.ms()); + EXPECT_EQ(default_max_playout_latency, timings.max_playout_delay); } TEST_F(VideoReceiveStream2Test, PlayoutDelayPreservesDefaultMinValue) { - const TimeDelta default_min_playout_latency = timing_->min_playout_delay(); + const TimeDelta default_min_playout_latency = + timing_->GetTimings().min_playout_delay; const VideoPlayoutDelay kPlayoutDelayMs = {-1, 321}; std::unique_ptr test_frame(new FrameObjectFake()); @@ -213,9 +221,10 @@ TEST_F(VideoReceiveStream2Test, PlayoutDelayPreservesDefaultMinValue) { video_receive_stream_->OnCompleteFrame(std::move(test_frame)); // Ensure that -1 preserves default minimum value from `timing_`. - EXPECT_NE(kPlayoutDelayMs.min_ms, timing_->min_playout_delay().ms()); - EXPECT_EQ(kPlayoutDelayMs.max_ms, timing_->max_playout_delay().ms()); - EXPECT_EQ(default_min_playout_latency, timing_->min_playout_delay()); + auto timings = timing_->GetTimings(); + EXPECT_NE(kPlayoutDelayMs.min_ms, timings.min_playout_delay.ms()); + EXPECT_EQ(kPlayoutDelayMs.max_ms, timings.max_playout_delay.ms()); + EXPECT_EQ(default_min_playout_latency, timings.min_playout_delay); } TEST_F(VideoReceiveStream2Test, MaxCompositionDelayNotSetByDefault) { From d7f9550647e4a6160408676eb210dd69ae91a402 Mon Sep 17 00:00:00 2001 From: Jonas Oreland Date: Tue, 22 Mar 2022 16:52:08 +0100 Subject: [PATCH 268/847] Fix interaction between ScopedkeyValueConfig and global field trials string This patch fixes a problem for test programs that mix usage of ScopedKeyValueConfig and the global field trial string. In this case, tests that were using CallTest. The solution is to check the global string when nothing has been explicitly added to a ScopedKeyValueConfig. Bug: webrtc:13828 Change-Id: Ib89735670cfe93340ca0a8bac53f8a64a600ad66 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256366 Reviewed-by: Mirko Bonadei Reviewed-by: Harald Alvestrand Commit-Queue: Jonas Oreland Cr-Commit-Position: refs/heads/main@{#36294} --- test/BUILD.gn | 1 + test/scoped_key_value_config.cc | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/test/BUILD.gn b/test/BUILD.gn index ae0f3ba8d3..e9d63ca42b 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -251,6 +251,7 @@ rtc_library("scoped_key_value_config") { ":field_trial", "../api:webrtc_key_value_config", "../rtc_base:checks", + "../system_wrappers:field_trial", ] absl_deps = [ "//third_party/abseil-cpp/absl/strings:strings" ] } diff --git a/test/scoped_key_value_config.cc b/test/scoped_key_value_config.cc index 723be22261..d6090b7f31 100644 --- a/test/scoped_key_value_config.cc +++ b/test/scoped_key_value_config.cc @@ -12,6 +12,7 @@ #include "api/webrtc_key_value_config.h" #include "rtc_base/checks.h" +#include "system_wrappers/include/field_trial.h" #include "test/field_trial.h" namespace { @@ -112,7 +113,9 @@ std::string ScopedKeyValueConfig::LookupRecurse(absl::string_view key) const { return parent_->LookupRecurse(key); } - return ""; + // When at the root, check the global string so that test programs using + // a mix between ScopedKeyValueConfig and the global string continue to work + return webrtc::field_trial::FindFullName(std::string(key)); } } // namespace test From 56b836d9581837ff146257d7b2453169b99db117 Mon Sep 17 00:00:00 2001 From: Alex Cooper Date: Mon, 21 Mar 2022 14:47:05 -0700 Subject: [PATCH 269/847] Ensure there is a unique FrameQueue for each DxgiOutputDuplicator DxgiOutputDuplicator objects hold a reference to the last frame that they succesfully captured by maintaining a reference to the SharedDesktopFrame that was passed as their target. This is done because the DirectX capture APIs may fail to provide an update if there has been no (or no substantial) change since the last capture call was made. However, the higher levels of this capture stack (DxgiDuplicatorController and ScreenCapturerWinDirectX), were unaware of this, and assumed that the caller of CaptureFrame is the only one who may have held a reference to the frame. Thus, when CaptureFrame is called, the DirectX screen capturer assumes that the oldest frame in its queue can be safely reused. In the steady state, where capture is not being switched between monitors, this is fine as there are no competing DxgiOutputDuplicators being run and this assumption mostly holds true (or the frame is being overwritten only when the DxgiOutputDuplicator is also done holding it). However, when capture is being rapidly switched between multiple targets (e.g. to show a preview of each of the available monitors), this can result in a frame being held by one DxgiOutputDuplicator being passed to another as a valid target and overwritten. In the common case of only a single monitor this is essentially the same as steady state capture, where there are no competing DxgiOutputDuplicator. In the other common case of two monitors being captured, the fact that the ScreenCaptureFrameQueue has two frames ends up masking this issue. Since each monitor is captured in the same order, the same frame ends up getting passed to each DxgiOutputDuplicator, so no data actually ends up getting overwritten. In the case of 3 monitors, the 1st and 3rd monitor end up sharing a frame, which when capture fails on one of them surfaces as the other monitor being duplicately shown. This change addresses the issue by ensuring that each screen that the ScreenCapturerWinDirectX *actually attempts* to capture, gets it's own FrameQueue, and thus essentially brings us back to the "steady state" case for each monitor. Note that this does increase memory usage of capturers that are switched between multiple targets by 2 frames/target used (and actually attempted to be captured). Alternatives considered: DxgiOutputDuplicator makes a copy of the frame, rather than holding a reference This was rejected because adding an additional copy for every capture upon getting a new frame, would expensive and could degrade performance. Allow the DxgiOutputDuplicators to "fail" when there has been no update This would result in either a breaking change to the API for consumers or would require the ScreenCapturerWinDirectX to track these last captured frames; which would result in essentially the same approach, but with less abstraction for re-using the frames. Bug: chromium:1296228 Change-Id: I5442ec40e9f234046010b562b258db63693ccc6b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256043 Reviewed-by: Mark Foltz Commit-Queue: Alexander Cooper Cr-Commit-Position: refs/heads/main@{#36295} --- .../win/dxgi_duplicator_controller.h | 10 ++++++++-- .../win/dxgi_output_duplicator.h | 5 +++++ .../win/screen_capturer_win_directx.cc | 18 ++++++++++++------ .../win/screen_capturer_win_directx.h | 10 +++++++++- 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/modules/desktop_capture/win/dxgi_duplicator_controller.h b/modules/desktop_capture/win/dxgi_duplicator_controller.h index 43c1a79874..88c2939187 100644 --- a/modules/desktop_capture/win/dxgi_duplicator_controller.h +++ b/modules/desktop_capture/win/dxgi_duplicator_controller.h @@ -41,6 +41,10 @@ namespace webrtc { // but a later Duplicate() returns false, this usually means the display mode is // changing. Consumers should retry after a while. (Typically 50 milliseconds, // but according to hardware performance, this time may vary.) +// The underyling DxgiOutputDuplicators may take an additional reference on the +// frame passed in to the Duplicate methods so that they can guarantee delivery +// of new frames when requested; since if there have been no updates to the +// surface, they may be unable to capture a frame. class RTC_EXPORT DxgiDuplicatorController { public: using Context = DxgiFrameContext; @@ -89,7 +93,8 @@ class RTC_EXPORT DxgiDuplicatorController { // function returns false, the information in `info` may not accurate. bool RetrieveD3dInfo(D3dInfo* info); - // Captures current screen and writes into `frame`. + // Captures current screen and writes into `frame`. May retain a reference to + // `frame`'s underlying |SharedDesktopFrame|. // TODO(zijiehe): Windows cannot guarantee the frames returned by each // IDXGIOutputDuplication are synchronized. But we are using a totally // different threading model than the way Windows suggested, it's hard to @@ -98,7 +103,8 @@ class RTC_EXPORT DxgiDuplicatorController { // Captures one monitor and writes into target. `monitor_id` should >= 0. If // `monitor_id` is greater than the total screen count of all the Duplicators, - // this function returns false. + // this function returns false. May retain a reference to `frame`'s underlying + // |SharedDesktopFrame|. Result DuplicateMonitor(DxgiFrame* frame, int monitor_id); // Returns dpi of current system. Returns an empty DesktopVector if system diff --git a/modules/desktop_capture/win/dxgi_output_duplicator.h b/modules/desktop_capture/win/dxgi_output_duplicator.h index 198b5a636b..df15fe566e 100644 --- a/modules/desktop_capture/win/dxgi_output_duplicator.h +++ b/modules/desktop_capture/win/dxgi_output_duplicator.h @@ -61,6 +61,11 @@ class DxgiOutputDuplicator { // function copies the content to the rectangle of (offset.x(), offset.y()) to // (offset.x() + desktop_rect_.width(), offset.y() + desktop_rect_.height()). // Returns false in case of a failure. + // May retain a reference to `target` so that a "captured" frame can be + // returned in the event that a new frame is not ready to be captured yet. + // (Or in other words, if the call to IDXGIOutputDuplication::AcquireNextFrame + // indicates that there is not yet a new frame, this is usually because no + // updates have occurred to the frame). bool Duplicate(Context* context, DesktopVector offset, SharedDesktopFrame* target); diff --git a/modules/desktop_capture/win/screen_capturer_win_directx.cc b/modules/desktop_capture/win/screen_capturer_win_directx.cc index 1556d7c787..efa763993a 100644 --- a/modules/desktop_capture/win/screen_capturer_win_directx.cc +++ b/modules/desktop_capture/win/screen_capturer_win_directx.cc @@ -125,17 +125,23 @@ void ScreenCapturerWinDirectx::CaptureFrame() { int64_t capture_start_time_nanos = rtc::TimeNanos(); - frames_.MoveToNextFrame(); - if (!frames_.current_frame()) { - frames_.ReplaceCurrentFrame( + // Note that the [] operator will create the ScreenCaptureFrameQueue if it + // doesn't exist, so this is safe. + ScreenCaptureFrameQueue& frames = + frame_queue_map_[current_screen_id_]; + + frames.MoveToNextFrame(); + + if (!frames.current_frame()) { + frames.ReplaceCurrentFrame( std::make_unique(shared_memory_factory_.get())); } DxgiDuplicatorController::Result result; if (current_screen_id_ == kFullDesktopScreenId) { - result = controller_->Duplicate(frames_.current_frame()); + result = controller_->Duplicate(frames.current_frame()); } else { - result = controller_->DuplicateMonitor(frames_.current_frame(), + result = controller_->DuplicateMonitor(frames.current_frame(), current_screen_id_); } @@ -172,7 +178,7 @@ void ScreenCapturerWinDirectx::CaptureFrame() { } case DuplicateResult::SUCCEEDED: { std::unique_ptr frame = - frames_.current_frame()->frame()->Share(); + frames.current_frame()->frame()->Share(); int capture_time_ms = (rtc::TimeNanos() - capture_start_time_nanos) / rtc::kNumNanosecsPerMillisec; diff --git a/modules/desktop_capture/win/screen_capturer_win_directx.h b/modules/desktop_capture/win/screen_capturer_win_directx.h index d64913ed10..801a0632fc 100644 --- a/modules/desktop_capture/win/screen_capturer_win_directx.h +++ b/modules/desktop_capture/win/screen_capturer_win_directx.h @@ -14,6 +14,7 @@ #include #include +#include #include #include "api/scoped_refptr.h" @@ -86,7 +87,14 @@ class RTC_EXPORT ScreenCapturerWinDirectx : public DesktopCapturer { private: const rtc::scoped_refptr controller_; - ScreenCaptureFrameQueue frames_; + + // The underlying DxgiDuplicators may retain a reference to the frames that + // we ask them to duplicate so that they can continue returning valid frames + // in the event that the target has not been updated. Thus, we need to ensure + // that we have a separate frame queue for each source id, so that these held + // frames don't get overwritten with the data from another Duplicator/monitor. + std::unordered_map> + frame_queue_map_; std::unique_ptr shared_memory_factory_; Callback* callback_ = nullptr; SourceId current_screen_id_ = kFullDesktopScreenId; From 445a750d38bf42bdd1d919032246291644805c19 Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Tue, 22 Mar 2022 21:05:32 -0700 Subject: [PATCH 270/847] Update WebRTC code version (2022-03-23T04:05:31). Bug: None Change-Id: I0bdb52494a01c82bcdc682807f37a4be1e69559b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256425 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36296} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index 15815e0c6d..934ff52522 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 2022-03-22T04:02:07"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-03-23T04:05:31"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From e7d7497e34bb385c330a6b43086014a35f19e776 Mon Sep 17 00:00:00 2001 From: Christoffer Jansson Date: Wed, 23 Mar 2022 09:36:13 +0100 Subject: [PATCH 271/847] Split Mac clang format + use py3 for all clang-format OS's No-Try: True Bug: b/226298805 Change-Id: Iebd074aac1b15feb740a6fdcab122fe66053b2e2 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256460 Reviewed-by: Mirko Bonadei Commit-Queue: Christoffer Jansson Cr-Commit-Position: refs/heads/main@{#36297} --- DEPS | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/DEPS b/DEPS index fbb1f061d7..a3e4cb57ec 100644 --- a/DEPS +++ b/DEPS @@ -2246,7 +2246,8 @@ hooks = [ 'name': 'clang_format_win', 'pattern': '.', 'condition': 'host_os == "win"', - 'action': [ 'download_from_google_storage', + 'action': [ 'python3', + 'src/third_party/depot_tools/download_from_google_storage.py', '--no_resume', '--platform=win32', '--no_auth', @@ -2255,22 +2256,38 @@ hooks = [ ], }, { - 'name': 'clang_format_mac', + 'name': 'clang_format_mac_x64', 'pattern': '.', - 'condition': 'host_os == "mac"', - 'action': [ 'download_from_google_storage', + 'condition': 'host_os == "mac" and host_cpu == "x64"', + 'action': [ 'python3', + 'src/third_party/depot_tools/download_from_google_storage.py', '--no_resume', '--platform=darwin', '--no_auth', '--bucket', 'chromium-clang-format', - '-s', 'src/buildtools/mac/clang-format.sha1', + '-s', 'src/buildtools/mac/clang-format.x64.sha1', + '-o', 'src/buildtools/mac/clang-format', ], }, + { + 'name': 'clang_format_mac_arm64', + 'pattern': '.', + 'condition': 'host_os == "mac" and host_cpu == "arm64"', + 'action': [ 'python3', + 'src/third_party/depot_tools/download_from_google_storage.py', + '--no_resume', + '--no_auth', + '--bucket', 'chromium-clang-format', + '-s', 'src/buildtools/mac/clang-format.arm64.sha1', + '-o', 'src/buildtools/mac/clang-format', + ], + }, { 'name': 'clang_format_linux', 'pattern': '.', 'condition': 'host_os == "linux"', - 'action': [ 'download_from_google_storage', + 'action': [ 'python3', + 'src/third_party/depot_tools/download_from_google_storage.py', '--no_resume', '--platform=linux*', '--no_auth', From a76ae851ad8519ea6500f2f439a897fbc6eced8e Mon Sep 17 00:00:00 2001 From: Xavier Lepaul Date: Wed, 23 Mar 2022 09:13:45 +0100 Subject: [PATCH 272/847] Run instrumentation tests with the default runner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This migrates all tests that work by just changing their runner. This excludes tests using `@RunWith(ParameterizedRunner.class)`, and a few other non-parameterized tests that fail with the default runner. Bug: webrtc:13662 Change-Id: Ia0b7c80e04a6a6b7a51348b3a7f587d10061b58e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256367 Reviewed-by: Björn Terelius Commit-Queue: Xavier Lepaul‎ Cr-Commit-Position: refs/heads/main@{#36298} --- .../org/webrtc/BuiltinAudioCodecsFactoryFactoryTest.java | 3 --- .../org/webrtc/Camera1CapturerUsingByteBufferTest.java | 3 --- .../src/org/webrtc/Camera1CapturerUsingTextureTest.java | 3 --- .../src/org/webrtc/Camera2CapturerTest.java | 3 --- .../src/org/webrtc/DefaultVideoEncoderFactoryTest.java | 3 --- .../src/org/webrtc/EglRendererTest.java | 3 --- .../src/org/webrtc/FileVideoCapturerTest.java | 3 --- .../src/org/webrtc/GlRectDrawerTest.java | 3 --- .../instrumentationtests/src/org/webrtc/LoggableTest.java | 3 --- .../src/org/webrtc/NetworkMonitorTest.java | 8 -------- .../src/org/webrtc/PeerConnectionEndToEndTest.java | 3 --- .../src/org/webrtc/PeerConnectionFactoryTest.java | 3 --- .../src/org/webrtc/PeerConnectionTest.java | 3 --- .../src/org/webrtc/RendererCommonTest.java | 3 --- .../src/org/webrtc/RtcCertificatePemTest.java | 3 --- .../src/org/webrtc/RtpSenderTest.java | 3 --- .../src/org/webrtc/RtpTransceiverTest.java | 3 --- .../src/org/webrtc/SurfaceTextureHelperTest.java | 3 --- .../src/org/webrtc/TimestampAlignerTest.java | 3 --- .../src/org/webrtc/VideoFileRendererTest.java | 3 --- .../src/org/webrtc/VideoTrackTest.java | 3 --- .../src/org/webrtc/WebRtcJniBootTest.java | 3 --- .../src/org/webrtc/YuvHelperTest.java | 3 --- 23 files changed, 74 deletions(-) diff --git a/sdk/android/instrumentationtests/src/org/webrtc/BuiltinAudioCodecsFactoryFactoryTest.java b/sdk/android/instrumentationtests/src/org/webrtc/BuiltinAudioCodecsFactoryFactoryTest.java index 976f7185ea..8c9119eb7b 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/BuiltinAudioCodecsFactoryFactoryTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/BuiltinAudioCodecsFactoryFactoryTest.java @@ -15,10 +15,7 @@ import androidx.test.filters.SmallTest; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) public final class BuiltinAudioCodecsFactoryFactoryTest { @Before public void setUp() { diff --git a/sdk/android/instrumentationtests/src/org/webrtc/Camera1CapturerUsingByteBufferTest.java b/sdk/android/instrumentationtests/src/org/webrtc/Camera1CapturerUsingByteBufferTest.java index 981eeeffaf..37d03d99d6 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/Camera1CapturerUsingByteBufferTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/Camera1CapturerUsingByteBufferTest.java @@ -15,13 +15,10 @@ import androidx.test.filters.LargeTest; import androidx.test.filters.MediumTest; import androidx.test.filters.SmallTest; -import org.chromium.base.test.BaseJUnit4ClassRunner; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -@RunWith(BaseJUnit4ClassRunner.class) public class Camera1CapturerUsingByteBufferTest { static final String TAG = "Camera1CapturerUsingByteBufferTest"; diff --git a/sdk/android/instrumentationtests/src/org/webrtc/Camera1CapturerUsingTextureTest.java b/sdk/android/instrumentationtests/src/org/webrtc/Camera1CapturerUsingTextureTest.java index 2c06935c13..e0419178c6 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/Camera1CapturerUsingTextureTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/Camera1CapturerUsingTextureTest.java @@ -15,13 +15,10 @@ import androidx.test.filters.LargeTest; import androidx.test.filters.MediumTest; import androidx.test.filters.SmallTest; -import org.chromium.base.test.BaseJUnit4ClassRunner; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -@RunWith(BaseJUnit4ClassRunner.class) public class Camera1CapturerUsingTextureTest { static final String TAG = "Camera1CapturerUsingTextureTest"; diff --git a/sdk/android/instrumentationtests/src/org/webrtc/Camera2CapturerTest.java b/sdk/android/instrumentationtests/src/org/webrtc/Camera2CapturerTest.java index ae84df0fde..b01737197a 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/Camera2CapturerTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/Camera2CapturerTest.java @@ -24,13 +24,10 @@ import androidx.test.filters.MediumTest; import androidx.test.filters.SmallTest; import java.util.concurrent.CountDownLatch; -import org.chromium.base.test.BaseJUnit4ClassRunner; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -@RunWith(BaseJUnit4ClassRunner.class) public class Camera2CapturerTest { static final String TAG = "Camera2CapturerTest"; diff --git a/sdk/android/instrumentationtests/src/org/webrtc/DefaultVideoEncoderFactoryTest.java b/sdk/android/instrumentationtests/src/org/webrtc/DefaultVideoEncoderFactoryTest.java index 197a5bc664..9721cbd818 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/DefaultVideoEncoderFactoryTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/DefaultVideoEncoderFactoryTest.java @@ -16,13 +16,10 @@ import androidx.test.filters.SmallTest; import java.util.ArrayList; import java.util.HashMap; -import org.chromium.base.test.BaseJUnit4ClassRunner; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; /** Unit tests for {@link DefaultVideoEncoderFactory}. */ -@RunWith(BaseJUnit4ClassRunner.class) public class DefaultVideoEncoderFactoryTest { static class CustomHardwareVideoEncoderFactory implements VideoEncoderFactory { private ArrayList codecs = new ArrayList<>(); diff --git a/sdk/android/instrumentationtests/src/org/webrtc/EglRendererTest.java b/sdk/android/instrumentationtests/src/org/webrtc/EglRendererTest.java index 2bd91905b7..8b5e95b855 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/EglRendererTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/EglRendererTest.java @@ -27,14 +27,11 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.concurrent.CountDownLatch; -import org.chromium.base.test.BaseJUnit4ClassRunner; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; // EmptyActivity is needed for the surface. -@RunWith(BaseJUnit4ClassRunner.class) public class EglRendererTest { private final static String TAG = "EglRendererTest"; private final static int RENDER_WAIT_MS = 1000; diff --git a/sdk/android/instrumentationtests/src/org/webrtc/FileVideoCapturerTest.java b/sdk/android/instrumentationtests/src/org/webrtc/FileVideoCapturerTest.java index c58d87b55c..8584ddf464 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/FileVideoCapturerTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/FileVideoCapturerTest.java @@ -19,12 +19,9 @@ import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.util.ArrayList; -import org.chromium.base.test.BaseJUnit4ClassRunner; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -@RunWith(BaseJUnit4ClassRunner.class) public class FileVideoCapturerTest { public static class MockCapturerObserver implements CapturerObserver { private final ArrayList frames = new ArrayList(); diff --git a/sdk/android/instrumentationtests/src/org/webrtc/GlRectDrawerTest.java b/sdk/android/instrumentationtests/src/org/webrtc/GlRectDrawerTest.java index 0760d64902..4cee3bdf71 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/GlRectDrawerTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/GlRectDrawerTest.java @@ -19,11 +19,8 @@ import androidx.test.filters.SmallTest; import java.nio.ByteBuffer; import java.util.Random; -import org.chromium.base.test.BaseJUnit4ClassRunner; import org.junit.Test; -import org.junit.runner.RunWith; -@RunWith(BaseJUnit4ClassRunner.class) public class GlRectDrawerTest { // Resolution of the test image. private static final int WIDTH = 16; diff --git a/sdk/android/instrumentationtests/src/org/webrtc/LoggableTest.java b/sdk/android/instrumentationtests/src/org/webrtc/LoggableTest.java index ff5cfee6dd..780eeb6197 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/LoggableTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/LoggableTest.java @@ -14,16 +14,13 @@ import static org.junit.Assert.assertTrue; import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; import androidx.test.filters.SmallTest; import java.util.ArrayList; import org.junit.Test; -import org.junit.runner.RunWith; import org.webrtc.Loggable; import org.webrtc.Logging.Severity; import org.webrtc.PeerConnectionFactory; -@RunWith(AndroidJUnit4.class) public class LoggableTest { private static String TAG = "LoggableTest"; private static String NATIVE_FILENAME_TAG = "loggable_test.cc"; diff --git a/sdk/android/instrumentationtests/src/org/webrtc/NetworkMonitorTest.java b/sdk/android/instrumentationtests/src/org/webrtc/NetworkMonitorTest.java index e045285efc..a0a86d5d78 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/NetworkMonitorTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/NetworkMonitorTest.java @@ -38,12 +38,9 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import org.chromium.base.test.BaseJUnit4ClassRunner; -import org.chromium.base.test.UiThreadTest; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import org.junit.runner.RunWith; import org.webrtc.NetworkChangeDetector.ConnectionType; import org.webrtc.NetworkChangeDetector.NetworkInformation; import org.webrtc.NetworkMonitorAutoDetect.ConnectivityManagerDelegate; @@ -58,7 +55,6 @@ * class is used in practice in WebRTC. */ @SuppressLint("NewApi") -@RunWith(BaseJUnit4ClassRunner.class) public class NetworkMonitorTest { private static final long INVALID_NET_ID = -1; private NetworkChangeDetector detector; @@ -226,7 +222,6 @@ public void setUp() { * Tests that the receiver registers for connectivity intents during construction. */ @Test - @UiThreadTest @SmallTest public void testNetworkMonitorRegistersInConstructor() throws InterruptedException { Context context = InstrumentationRegistry.getTargetContext(); @@ -243,7 +238,6 @@ public void testNetworkMonitorRegistersInConstructor() throws InterruptedExcepti * notification to Java observers. */ @Test - @UiThreadTest @MediumTest public void testNetworkMonitorJavaObservers() throws InterruptedException { // Initialize the NetworkMonitor with a connection. @@ -290,7 +284,6 @@ public void testNetworkMonitorJavaObservers() throws InterruptedException { * that the functions don't crash. */ @Test - @UiThreadTest @SmallTest public void testConnectivityManagerDelegateDoesNotCrash() { ConnectivityManagerDelegate delegate = new ConnectivityManagerDelegate( @@ -376,7 +369,6 @@ private NetworkRequest getNetworkRequestForFieldTrials(String fieldTrials) { * least check that the functions don't crash. */ @Test - @UiThreadTest @SmallTest public void testQueryableAPIsDoNotCrash() { NetworkMonitorAutoDetect.Observer observer = new TestNetworkMonitorAutoDetectObserver(); diff --git a/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionEndToEndTest.java b/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionEndToEndTest.java index 588e64700b..8efefb3903 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionEndToEndTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionEndToEndTest.java @@ -36,17 +36,14 @@ import java.util.TreeSet; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.chromium.base.test.BaseJUnit4ClassRunner; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; import org.webrtc.PeerConnection.IceConnectionState; import org.webrtc.PeerConnection.IceGatheringState; import org.webrtc.PeerConnection.PeerConnectionState; import org.webrtc.PeerConnection.SignalingState; /** End-to-end tests for {@link PeerConnection}. */ -@RunWith(BaseJUnit4ClassRunner.class) public class PeerConnectionEndToEndTest { private static final String TAG = "PeerConnectionEndToEndTest"; private static final int DEFAULT_TIMEOUT_SECONDS = 20; diff --git a/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionFactoryTest.java b/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionFactoryTest.java index 92d44698a8..8eebfb5878 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionFactoryTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionFactoryTest.java @@ -11,12 +11,9 @@ package org.webrtc; import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; import androidx.test.filters.SmallTest; import org.junit.Test; -import org.junit.runner.RunWith; -@RunWith(AndroidJUnit4.class) public class PeerConnectionFactoryTest { @SmallTest @Test diff --git a/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionTest.java b/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionTest.java index 7d19143166..7ced991859 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionTest.java @@ -22,14 +22,11 @@ import androidx.test.filters.SmallTest; import java.util.Arrays; import java.util.List; -import org.chromium.base.test.BaseJUnit4ClassRunner; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; import org.webrtc.PeerConnection.TlsCertPolicy; /** Unit tests for {@link PeerConnection}. */ -@RunWith(BaseJUnit4ClassRunner.class) public class PeerConnectionTest { @Before public void setUp() { diff --git a/sdk/android/instrumentationtests/src/org/webrtc/RendererCommonTest.java b/sdk/android/instrumentationtests/src/org/webrtc/RendererCommonTest.java index 01eb4c846d..8b1cd67051 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/RendererCommonTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/RendererCommonTest.java @@ -20,11 +20,8 @@ import android.graphics.Point; import androidx.test.filters.SmallTest; -import org.chromium.base.test.BaseJUnit4ClassRunner; import org.junit.Test; -import org.junit.runner.RunWith; -@RunWith(BaseJUnit4ClassRunner.class) public class RendererCommonTest { @Test @SmallTest diff --git a/sdk/android/instrumentationtests/src/org/webrtc/RtcCertificatePemTest.java b/sdk/android/instrumentationtests/src/org/webrtc/RtcCertificatePemTest.java index 70bceffd40..4127bb2d4f 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/RtcCertificatePemTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/RtcCertificatePemTest.java @@ -13,15 +13,12 @@ import static com.google.common.truth.Truth.assertThat; import androidx.test.filters.SmallTest; -import org.chromium.base.test.BaseJUnit4ClassRunner; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; import org.webrtc.PeerConnection; import org.webrtc.RtcCertificatePem; /** Tests for RtcCertificatePem.java. */ -@RunWith(BaseJUnit4ClassRunner.class) public class RtcCertificatePemTest { @Before public void setUp() { diff --git a/sdk/android/instrumentationtests/src/org/webrtc/RtpSenderTest.java b/sdk/android/instrumentationtests/src/org/webrtc/RtpSenderTest.java index 70bc43e36d..9f315d5dc3 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/RtpSenderTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/RtpSenderTest.java @@ -19,14 +19,11 @@ import android.support.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; import java.util.Arrays; -import org.chromium.base.test.BaseJUnit4ClassRunner; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; import org.webrtc.RtpParameters.DegradationPreference; /** Unit-tests for {@link RtpSender}. */ -@RunWith(BaseJUnit4ClassRunner.class) public class RtpSenderTest { private PeerConnectionFactory factory; private PeerConnection pc; diff --git a/sdk/android/instrumentationtests/src/org/webrtc/RtpTransceiverTest.java b/sdk/android/instrumentationtests/src/org/webrtc/RtpTransceiverTest.java index e97bd3d32b..a53ff20f1c 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/RtpTransceiverTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/RtpTransceiverTest.java @@ -19,15 +19,12 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.chromium.base.test.BaseJUnit4ClassRunner; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; import org.webrtc.RtpParameters.Encoding; import org.webrtc.RtpTransceiver.RtpTransceiverInit; /** Unit-tests for {@link RtpTransceiver}. */ -@RunWith(BaseJUnit4ClassRunner.class) public class RtpTransceiverTest { private PeerConnectionFactory factory; private PeerConnection pc; diff --git a/sdk/android/instrumentationtests/src/org/webrtc/SurfaceTextureHelperTest.java b/sdk/android/instrumentationtests/src/org/webrtc/SurfaceTextureHelperTest.java index 3964d222dc..9781d03999 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/SurfaceTextureHelperTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/SurfaceTextureHelperTest.java @@ -21,12 +21,9 @@ import androidx.test.filters.SmallTest; import java.nio.ByteBuffer; import java.util.concurrent.CountDownLatch; -import org.chromium.base.test.BaseJUnit4ClassRunner; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -@RunWith(BaseJUnit4ClassRunner.class) public class SurfaceTextureHelperTest { /** * Mock texture listener with blocking wait functionality. diff --git a/sdk/android/instrumentationtests/src/org/webrtc/TimestampAlignerTest.java b/sdk/android/instrumentationtests/src/org/webrtc/TimestampAlignerTest.java index 930a450af0..46cb37e5f1 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/TimestampAlignerTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/TimestampAlignerTest.java @@ -11,12 +11,9 @@ package org.webrtc; import androidx.test.filters.SmallTest; -import org.chromium.base.test.params.BaseJUnit4RunnerDelegate; -import org.chromium.base.test.params.ParameterAnnotations.UseRunnerDelegate; import org.junit.BeforeClass; import org.junit.Test; -@UseRunnerDelegate(BaseJUnit4RunnerDelegate.class) public class TimestampAlignerTest { @BeforeClass public static void setUp() { diff --git a/sdk/android/instrumentationtests/src/org/webrtc/VideoFileRendererTest.java b/sdk/android/instrumentationtests/src/org/webrtc/VideoFileRendererTest.java index 70950b9eb4..9c66edd8ef 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/VideoFileRendererTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/VideoFileRendererTest.java @@ -19,12 +19,9 @@ import java.io.RandomAccessFile; import java.nio.ByteBuffer; import java.nio.charset.Charset; -import org.chromium.base.test.BaseJUnit4ClassRunner; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -@RunWith(BaseJUnit4ClassRunner.class) public class VideoFileRendererTest { @Before public void setUp() { diff --git a/sdk/android/instrumentationtests/src/org/webrtc/VideoTrackTest.java b/sdk/android/instrumentationtests/src/org/webrtc/VideoTrackTest.java index 938f488efd..8d7894c048 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/VideoTrackTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/VideoTrackTest.java @@ -15,13 +15,10 @@ import android.support.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; -import org.chromium.base.test.BaseJUnit4ClassRunner; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; /** Unit tests for {@link VideoTrack}. */ -@RunWith(BaseJUnit4ClassRunner.class) public class VideoTrackTest { private PeerConnectionFactory factory; private VideoSource videoSource; diff --git a/sdk/android/instrumentationtests/src/org/webrtc/WebRtcJniBootTest.java b/sdk/android/instrumentationtests/src/org/webrtc/WebRtcJniBootTest.java index 5819900d94..b1badd5773 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/WebRtcJniBootTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/WebRtcJniBootTest.java @@ -11,16 +11,13 @@ package org.webrtc; import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; import androidx.test.filters.SmallTest; import org.junit.Test; -import org.junit.runner.RunWith; import org.webrtc.PeerConnectionFactory; // This test is intended to run on ARM and catch LoadLibrary errors when we load the WebRTC // JNI. It can't really be setting up calls since ARM emulators are too slow, but instantiating // a peer connection isn't timing-sensitive, so we can at least do that. -@RunWith(AndroidJUnit4.class) public class WebRtcJniBootTest { @Test @SmallTest diff --git a/sdk/android/instrumentationtests/src/org/webrtc/YuvHelperTest.java b/sdk/android/instrumentationtests/src/org/webrtc/YuvHelperTest.java index 0a63bd7634..7c58e9554f 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/YuvHelperTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/YuvHelperTest.java @@ -15,12 +15,9 @@ import androidx.test.filters.SmallTest; import java.nio.ByteBuffer; -import org.chromium.base.test.BaseJUnit4ClassRunner; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -@RunWith(BaseJUnit4ClassRunner.class) public class YuvHelperTest { private static final int TEST_WIDTH = 3; private static final int TEST_HEIGHT = 3; From 2756ace4ce4b9e6f78d9978780a194c7c88b7028 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Wed, 23 Mar 2022 01:01:43 -0700 Subject: [PATCH 273/847] Roll chromium_revision cd60f7c147..a697245f3d (983336:984227) Change log: https://chromium.googlesource.com/chromium/src/+log/cd60f7c147..a697245f3d Full diff: https://chromium.googlesource.com/chromium/src/+/cd60f7c147..a697245f3d Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/62ab5ed470..d07854bae7 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/0a7d5e2362..8ae687514c * src/buildtools: https://chromium.googlesource.com/chromium/src/buildtools/+log/d8c375426d..e1471b21ee * src/buildtools/third_party/libc++abi/trunk: https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git/+log/93b8dcd57b..edde7bbc40 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/f05ae3297c..af28cc6c8b * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/e6c44c92f4..46f39ff7fc * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/9581bbe809..5ad0921fc7 * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/54219055fc..180b8d540d * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/f0bc2d2404..e7eb3eb81a * src/third_party/googletest/src: https://chromium.googlesource.com/external/github.com/google/googletest.git/+log/b007c54f29..0affd45b62 * src/third_party/libvpx/source/libvpx: https://chromium.googlesource.com/webm/libvpx.git/+log/df0d06de6d..bf672f23a5 * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/723b273d39..5731615c4b * src/third_party/turbine: Go9J3Mz5ankZAgxmn5GxeXKdEDV73zaZp2ojNfGC1RQC..yMO-x5RrhSksWmdTW_uQczi0PrHWCEfIyOkqwdFLExoC * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/a49530481c..b5911e5f6e DEPS diff: https://chromium.googlesource.com/chromium/src/+/cd60f7c147..a697245f3d/DEPS No update to Clang. BUG=None Change-Id: If1b2148ca4fa04e96316b62f6921e2773352f3a0 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256440 Reviewed-by: Christoffer Jansson Owners-Override: Christoffer Jansson Reviewed-by: Jeremy Leconte Commit-Queue: Christoffer Jansson Cr-Commit-Position: refs/heads/main@{#36299} --- DEPS | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/DEPS b/DEPS index a3e4cb57ec..831d30c855 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': 'cd60f7c147648ecee2bdd7d8843b85dd35fe49d0', + 'chromium_revision': 'a697245f3dec8b1a02306b04d214dd3b94167ea0', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,24 +23,24 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@62ab5ed470e35bc5b56fcf26b24667a2bded4998', + 'https://chromium.googlesource.com/chromium/src/base@d07854bae776b5aac0b2753acb8a2c054fcc7c58', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@0a7d5e2362681513a44b48185b80589a9b6e2f07', + 'https://chromium.googlesource.com/chromium/src/build@8ae687514ca6dc093331e7afcbd9f93cc8d95a72', 'src/buildtools': - 'https://chromium.googlesource.com/chromium/src/buildtools@d8c375426d8f7f4147f7d4109bb63c12655fb8d6', + 'https://chromium.googlesource.com/chromium/src/buildtools@e1471b21ee9c6765ee95e9db0c76fe997ccad35c', # 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@f05ae3297ca17437161afa22ff5058f02907ae5b', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@af28cc6c8b4fb0b0aa352f83afe8597e508b7f5b', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@e6c44c92f467e34425694b2db614d2f44ab9307f', + 'https://chromium.googlesource.com/chromium/src/testing@46f39ff7fc51299f51ab60bb6d6ab2fe067b173c', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@9581bbe80972e69286ac12cb5dd2eaca397c0fa0', + 'https://chromium.googlesource.com/chromium/src/third_party@5ad0921fc791543a5422be8efdd52bd404394902', 'src/buildtools/linux64': { 'packages': [ @@ -78,7 +78,7 @@ deps = { 'src/buildtools/third_party/libc++/trunk': 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxx.git@79a2e924d96e2fc1e4b937c42efd08898fa472d7', 'src/buildtools/third_party/libc++abi/trunk': - 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git@93b8dcd57bd8ebe201ec24f7257339988ed2ef7c', + 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git@edde7bbc4049ae4a32257d9f16451312c763c601', 'src/buildtools/third_party/libunwind/trunk': 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git@d1c7f92b8b0bff8d9f710ca40e44563a63db376e', @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@54219055fcf8c7ace26e9095715dd1587ea3fbe6', + 'https://chromium.googlesource.com/catapult.git@180b8d540d9f9ae3e24cfe564f02044133c1c070', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@f0bc2d24042bd70cc7b43d4d19d9eec3074e462c', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@e7eb3eb81ab7a84f7d9fc422200b9ba09d95699f', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -185,7 +185,7 @@ deps = { 'dep_type': 'cipd', }, 'src/third_party/googletest/src': - 'https://chromium.googlesource.com/external/github.com/google/googletest.git@b007c54f2944e193ac44fba1bc997cb65826a0b9', + 'https://chromium.googlesource.com/external/github.com/google/googletest.git@0affd45b62371c1de44064a5a5f8817242208442', 'src/third_party/icu': { 'url': 'https://chromium.googlesource.com/chromium/deps/icu.git@a9359a84a3969b3019db7d62899afb19642eefcd', }, @@ -231,9 +231,9 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@723b273d391e1b5330dba2cf2c3af6f7f4abea2c', + 'https://android.googlesource.com/platform/external/perfetto.git@5731615c4b5bd9221d0808161595cd57593def23', 'src/third_party/libvpx/source/libvpx': - 'https://chromium.googlesource.com/webm/libvpx.git@df0d06de6d3b64e35b9e75ad72c571af061bc7b3', + 'https://chromium.googlesource.com/webm/libvpx.git@bf672f23a5336cb54dbcb2e4417142139f44cc3e', 'src/third_party/libyuv': 'https://chromium.googlesource.com/libyuv/libyuv.git@3aebf69d668177e7ee6dbbe0025e5c3dbb525ff2', 'src/third_party/lss': { @@ -288,7 +288,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@a49530481cc3b53d653bcb4609e11c6e1dcaacdb', + 'https://chromium.googlesource.com/chromium/src/tools@b5911e5f6e010e617867882722b740b152a3b9b8', 'src/third_party/accessibility_test_framework': { 'packages': [ @@ -470,7 +470,7 @@ deps = { 'packages': [ { 'package': 'chromium/third_party/turbine', - 'version': 'Go9J3Mz5ankZAgxmn5GxeXKdEDV73zaZp2ojNfGC1RQC', + 'version': 'yMO-x5RrhSksWmdTW_uQczi0PrHWCEfIyOkqwdFLExoC', }, ], 'condition': 'checkout_android', From d7fdb953468789b93c37b1a1be512f99a34639d3 Mon Sep 17 00:00:00 2001 From: Alessio Bazzica Date: Fri, 18 Mar 2022 14:21:00 +0100 Subject: [PATCH 274/847] Remove typing detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Motivation: never used. Follow-up CL of https://webrtc-review.googlesource.com/c/src/+/250680. Tested on a custom chromium build by making a video call and with keyboard activity. The expected logs from the APM transient suppressor sub-module were shown. Bug: webrtc:11226 Change-Id: I4186994412dd8ba2e71ed8f9dcc9cf8f8e40fbd3 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/250667 Reviewed-by: Niels Moller Reviewed-by: Per Kjellander Reviewed-by: Björn Terelius Reviewed-by: Gustaf Ullberg Commit-Queue: Alessio Bazzica Cr-Commit-Position: refs/heads/main@{#36300} --- api/audio_options.cc | 3 - api/audio_options.h | 4 - api/stats_types.cc | 3 - api/stats_types.h | 2 - audio/audio_send_stream.cc | 1 - audio/audio_send_stream_unittest.cc | 1 - audio/audio_state.cc | 5 -- audio/audio_state.h | 2 - audio/audio_transport_impl.h | 5 -- audio/test/audio_stats_test.cc | 1 - call/audio_send_stream.h | 1 - media/base/media_channel.h | 1 - media/engine/webrtc_voice_engine.cc | 12 --- media/engine/webrtc_voice_engine_unittest.cc | 3 - modules/audio_processing/BUILD.gn | 2 - modules/audio_processing/typing_detection.cc | 93 -------------------- modules/audio_processing/typing_detection.h | 92 ------------------- pc/stats_collector.cc | 9 +- pc/stats_collector_unittest.cc | 9 -- 19 files changed, 2 insertions(+), 247 deletions(-) delete mode 100644 modules/audio_processing/typing_detection.cc delete mode 100644 modules/audio_processing/typing_detection.h diff --git a/api/audio_options.cc b/api/audio_options.cc index fad35cb881..3a70bc6cc4 100644 --- a/api/audio_options.cc +++ b/api/audio_options.cc @@ -54,7 +54,6 @@ void AudioOptions::SetAll(const AudioOptions& change) { change.audio_jitter_buffer_min_delay_ms); SetFrom(&audio_jitter_buffer_enable_rtx_handling, change.audio_jitter_buffer_enable_rtx_handling); - SetFrom(&typing_detection, change.typing_detection); SetFrom(&residual_echo_detector, change.residual_echo_detector); SetFrom(&combined_audio_video_bwe, change.combined_audio_video_bwe); SetFrom(&audio_network_adaptor, change.audio_network_adaptor); @@ -78,7 +77,6 @@ bool AudioOptions::operator==(const AudioOptions& o) const { o.audio_jitter_buffer_min_delay_ms && audio_jitter_buffer_enable_rtx_handling == o.audio_jitter_buffer_enable_rtx_handling && - typing_detection == o.typing_detection && residual_echo_detector == o.residual_echo_detector && combined_audio_video_bwe == o.combined_audio_video_bwe && audio_network_adaptor == o.audio_network_adaptor && @@ -107,7 +105,6 @@ std::string AudioOptions::ToString() const { audio_jitter_buffer_min_delay_ms); ToStringIfSet(&result, "audio_jitter_buffer_enable_rtx_handling", audio_jitter_buffer_enable_rtx_handling); - ToStringIfSet(&result, "typing", typing_detection); ToStringIfSet(&result, "residual_echo_detector", residual_echo_detector); ToStringIfSet(&result, "combined_audio_video_bwe", combined_audio_video_bwe); ToStringIfSet(&result, "audio_network_adaptor", audio_network_adaptor); diff --git a/api/audio_options.h b/api/audio_options.h index 3fcc38d83f..b9f99df8da 100644 --- a/api/audio_options.h +++ b/api/audio_options.h @@ -60,10 +60,6 @@ struct RTC_EXPORT AudioOptions { absl::optional audio_jitter_buffer_min_delay_ms; // Audio receiver jitter buffer (NetEq) should handle retransmitted packets. absl::optional audio_jitter_buffer_enable_rtx_handling; - // Deprecated. - // TODO(bugs.webrtc.org/11226): Remove. - // Audio processing to detect typing. - absl::optional typing_detection; // TODO(bugs.webrtc.org/11539): Deprecated, replaced by // webrtc::CreateEchoDetector() and injection when creating the audio // processing module. diff --git a/api/stats_types.cc b/api/stats_types.cc index b044e4ab11..8f69e5f876 100644 --- a/api/stats_types.cc +++ b/api/stats_types.cc @@ -648,9 +648,6 @@ const char* StatsReport::Value::display_name() const { return "googTrackId"; case kStatsValueNameTimingFrameInfo: return "googTimingFrameInfo"; - // TODO(bugs.webrtc.org/11226): Remove. - case kStatsValueNameTypingNoiseState: - return "googTypingNoiseState"; case kStatsValueNameWritable: return "googWritable"; case kStatsValueNameAudioDeviceUnderrunCounter: diff --git a/api/stats_types.h b/api/stats_types.h index e7dd528e62..d75da46439 100644 --- a/api/stats_types.h +++ b/api/stats_types.h @@ -235,8 +235,6 @@ class RTC_EXPORT StatsReport { kStatsValueNameTrackId, kStatsValueNameTransmitBitrate, kStatsValueNameTransportType, - // TODO(bugs.webrtc.org/11226): Remove. - kStatsValueNameTypingNoiseState, kStatsValueNameWritable, kStatsValueNameAudioDeviceUnderrunCounter, kStatsValueNameLocalCandidateRelayProtocol, diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc index 6aa0ec940f..c291534b4d 100644 --- a/audio/audio_send_stream.cc +++ b/audio/audio_send_stream.cc @@ -475,7 +475,6 @@ webrtc::AudioSendStream::Stats AudioSendStream::GetStats( stats.total_input_duration = audio_level_.TotalDuration(); } - stats.typing_noise_detected = audio_state()->typing_noise_detected(); stats.ana_statistics = channel_send_->GetANAStatistics(); AudioProcessing* ap = audio_state_->audio_processing(); diff --git a/audio/audio_send_stream_unittest.cc b/audio/audio_send_stream_unittest.cc index 2d2e64c155..0ec9964694 100644 --- a/audio/audio_send_stream_unittest.cc +++ b/audio/audio_send_stream_unittest.cc @@ -472,7 +472,6 @@ TEST(AudioSendStreamTest, GetStats) { stats.apm_statistics.residual_echo_likelihood); EXPECT_EQ(kResidualEchoLikelihoodMax, stats.apm_statistics.residual_echo_likelihood_recent_max); - EXPECT_FALSE(stats.typing_noise_detected); } } } diff --git a/audio/audio_state.cc b/audio/audio_state.cc index 9e5b63b999..df8ce8a344 100644 --- a/audio/audio_state.cc +++ b/audio/audio_state.cc @@ -50,11 +50,6 @@ AudioTransport* AudioState::audio_transport() { return &audio_transport_; } -bool AudioState::typing_noise_detected() const { - RTC_DCHECK(thread_checker_.IsCurrent()); - return audio_transport_.typing_noise_detected(); -} - void AudioState::AddReceivingStream(webrtc::AudioReceiveStream* stream) { RTC_DCHECK(thread_checker_.IsCurrent()); RTC_DCHECK_EQ(0, receiving_streams_.count(stream)); diff --git a/audio/audio_state.h b/audio/audio_state.h index 55f35511bf..b8ef4fd978 100644 --- a/audio/audio_state.h +++ b/audio/audio_state.h @@ -51,8 +51,6 @@ class AudioState : public webrtc::AudioState { return config_.audio_device_module.get(); } - bool typing_noise_detected() const; - void AddReceivingStream(webrtc::AudioReceiveStream* stream); void RemoveReceivingStream(webrtc::AudioReceiveStream* stream); diff --git a/audio/audio_transport_impl.h b/audio/audio_transport_impl.h index 89999560c6..ba067de99d 100644 --- a/audio/audio_transport_impl.h +++ b/audio/audio_transport_impl.h @@ -20,7 +20,6 @@ #include "modules/async_audio_processing/async_audio_processing.h" #include "modules/audio_device/include/audio_device.h" #include "modules/audio_processing/include/audio_processing.h" -#include "modules/audio_processing/typing_detection.h" #include "rtc_base/synchronization/mutex.h" #include "rtc_base/thread_annotations.h" @@ -86,9 +85,6 @@ class AudioTransportImpl : public AudioTransport { int send_sample_rate_hz, size_t send_num_channels); void SetStereoChannelSwapping(bool enable); - // Deprecated. - // TODO(bugs.webrtc.org/11226): Remove. - bool typing_noise_detected() const { return false; } private: void SendProcessedData(std::unique_ptr audio_frame); @@ -107,7 +103,6 @@ class AudioTransportImpl : public AudioTransport { size_t send_num_channels_ RTC_GUARDED_BY(capture_lock_) = 1; bool swap_stereo_channels_ RTC_GUARDED_BY(capture_lock_) = false; PushResampler capture_resampler_; - TypingDetection typing_detection_; // Render side. diff --git a/audio/test/audio_stats_test.cc b/audio/test/audio_stats_test.cc index ea3327056b..8f599b0213 100644 --- a/audio/test/audio_stats_test.cc +++ b/audio/test/audio_stats_test.cc @@ -63,7 +63,6 @@ class NoLossTest : public AudioEndToEndTest { EXPECT_FALSE(send_stats.apm_statistics.echo_return_loss_enhancement); EXPECT_FALSE(send_stats.apm_statistics.residual_echo_likelihood); EXPECT_FALSE(send_stats.apm_statistics.residual_echo_likelihood_recent_max); - EXPECT_EQ(false, send_stats.typing_noise_detected); AudioReceiveStream::Stats recv_stats = receive_stream()->GetStats(/*get_and_clear_legacy_stats=*/true); diff --git a/call/audio_send_stream.h b/call/audio_send_stream.h index e38a47f871..25d086beaa 100644 --- a/call/audio_send_stream.h +++ b/call/audio_send_stream.h @@ -59,7 +59,6 @@ class AudioSendStream : public AudioSender { // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaudioenergy double total_input_energy = 0.0; double total_input_duration = 0.0; - bool typing_noise_detected = false; ANAStats ana_statistics; AudioProcessingStats apm_statistics; diff --git a/media/base/media_channel.h b/media/base/media_channel.h index 2b0ef81277..7da3fbe310 100644 --- a/media/base/media_channel.h +++ b/media/base/media_channel.h @@ -465,7 +465,6 @@ struct VoiceSenderInfo : public MediaSenderInfo { // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaudioenergy double total_input_energy = 0.0; double total_input_duration = 0.0; - bool typing_noise_detected = false; webrtc::ANAStats ana_statistics; webrtc::AudioProcessingStats apm_statistics; }; diff --git a/media/engine/webrtc_voice_engine.cc b/media/engine/webrtc_voice_engine.cc index a229658493..54d1963775 100644 --- a/media/engine/webrtc_voice_engine.cc +++ b/media/engine/webrtc_voice_engine.cc @@ -393,10 +393,8 @@ void WebRtcVoiceEngine::Init() { #if defined(WEBRTC_IOS) // On iOS, VPIO provides built-in NS. options.noise_suppression = false; - options.typing_detection = false; #else options.noise_suppression = true; - options.typing_detection = true; #endif options.highpass_filter = true; options.stereo_swapping = false; @@ -453,11 +451,6 @@ bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) { use_mobile_software_aec = true; #endif -// Override noise suppression options for Android. -#if defined(WEBRTC_ANDROID) - options.typing_detection = false; -#endif - // Set and adjust gain control options. #if defined(WEBRTC_IOS) // On iOS, VPIO provides built-in AGC. @@ -602,10 +595,6 @@ bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) { RTC_LOG(LS_INFO) << "NS set to " << enabled; } - if (options.typing_detection) { - RTC_LOG(LS_WARNING) << "Typing detection is requested, but unsupported."; - } - ap->ApplyConfig(apm_config); return true; } @@ -2339,7 +2328,6 @@ bool WebRtcVoiceMediaChannel::GetStats(VoiceMediaInfo* info, sinfo.audio_level = stats.audio_level; sinfo.total_input_energy = stats.total_input_energy; sinfo.total_input_duration = stats.total_input_duration; - sinfo.typing_noise_detected = (send_ ? stats.typing_noise_detected : false); sinfo.ana_statistics = stats.ana_statistics; sinfo.apm_statistics = stats.apm_statistics; sinfo.report_block_datas = std::move(stats.report_block_datas); diff --git a/media/engine/webrtc_voice_engine_unittest.cc b/media/engine/webrtc_voice_engine_unittest.cc index 6f938292bf..0bf35c75fb 100644 --- a/media/engine/webrtc_voice_engine_unittest.cc +++ b/media/engine/webrtc_voice_engine_unittest.cc @@ -606,7 +606,6 @@ class WebRtcVoiceEngineTestFake : public ::testing::TestWithParam { stats.ana_statistics.frame_length_increase_counter = 765; stats.ana_statistics.frame_length_decrease_counter = 876; stats.ana_statistics.uplink_packet_loss_fraction = 987.0; - stats.typing_noise_detected = true; return stats; } void SetAudioSendStreamStats() { @@ -655,8 +654,6 @@ class WebRtcVoiceEngineTestFake : public ::testing::TestWithParam { stats.ana_statistics.frame_length_decrease_counter); EXPECT_EQ(info.ana_statistics.uplink_packet_loss_fraction, stats.ana_statistics.uplink_packet_loss_fraction); - EXPECT_EQ(info.typing_noise_detected, - stats.typing_noise_detected && is_sending); } webrtc::AudioReceiveStream::Stats GetAudioReceiveStreamStats() const { diff --git a/modules/audio_processing/BUILD.gn b/modules/audio_processing/BUILD.gn index ee6b579617..91793837d2 100644 --- a/modules/audio_processing/BUILD.gn +++ b/modules/audio_processing/BUILD.gn @@ -151,8 +151,6 @@ rtc_library("audio_processing") { "gain_control_impl.cc", "gain_control_impl.h", "render_queue_item_verifier.h", - "typing_detection.cc", - "typing_detection.h", ] defines = [] diff --git a/modules/audio_processing/typing_detection.cc b/modules/audio_processing/typing_detection.cc deleted file mode 100644 index e725b264ee..0000000000 --- a/modules/audio_processing/typing_detection.cc +++ /dev/null @@ -1,93 +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_processing/typing_detection.h" - -namespace webrtc { - -TypingDetection::TypingDetection() - : time_active_(0), - time_since_last_typing_(0), - penalty_counter_(0), - counter_since_last_detection_update_(0), - detection_to_report_(false), - new_detection_to_report_(false), - time_window_(10), - cost_per_typing_(100), - reporting_threshold_(300), - penalty_decay_(1), - type_event_delay_(2), - report_detection_update_period_(1) {} - -TypingDetection::~TypingDetection() {} - -bool TypingDetection::Process(bool key_pressed, bool vad_activity) { - if (vad_activity) - time_active_++; - else - time_active_ = 0; - - // Keep track if time since last typing event - if (key_pressed) - time_since_last_typing_ = 0; - else - ++time_since_last_typing_; - - if (time_since_last_typing_ < type_event_delay_ && vad_activity && - time_active_ < time_window_) { - penalty_counter_ += cost_per_typing_; - if (penalty_counter_ > reporting_threshold_) - new_detection_to_report_ = true; - } - - if (penalty_counter_ > 0) - penalty_counter_ -= penalty_decay_; - - if (++counter_since_last_detection_update_ == - report_detection_update_period_) { - detection_to_report_ = new_detection_to_report_; - new_detection_to_report_ = false; - counter_since_last_detection_update_ = 0; - } - - return detection_to_report_; -} - -int TypingDetection::TimeSinceLastDetectionInSeconds() { - // Round to whole seconds. - return (time_since_last_typing_ + 50) / 100; -} - -void TypingDetection::SetParameters(int time_window, - int cost_per_typing, - int reporting_threshold, - int penalty_decay, - int type_event_delay, - int report_detection_update_period) { - if (time_window) - time_window_ = time_window; - - if (cost_per_typing) - cost_per_typing_ = cost_per_typing; - - if (reporting_threshold) - reporting_threshold_ = reporting_threshold; - - if (penalty_decay) - penalty_decay_ = penalty_decay; - - if (type_event_delay) - type_event_delay_ = type_event_delay; - - if (report_detection_update_period) - report_detection_update_period_ = report_detection_update_period; -} - -} // namespace webrtc diff --git a/modules/audio_processing/typing_detection.h b/modules/audio_processing/typing_detection.h deleted file mode 100644 index 9d96583b98..0000000000 --- a/modules/audio_processing/typing_detection.h +++ /dev/null @@ -1,92 +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_PROCESSING_TYPING_DETECTION_H_ -#define MODULES_AUDIO_PROCESSING_TYPING_DETECTION_H_ - -#include "rtc_base/system/rtc_export.h" - -namespace webrtc { - -class RTC_EXPORT TypingDetection { - public: - TypingDetection(); - virtual ~TypingDetection(); - - // Run the detection algortihm. Shall be called every 10 ms. Returns true if - // typing is detected, or false if not, based on the update period as set with - // SetParameters(). See `report_detection_update_period_` description below. - bool Process(bool key_pressed, bool vad_activity); - - // Gets the time in seconds since the last detection. - int TimeSinceLastDetectionInSeconds(); - - // Sets the algorithm parameters. A parameter value of 0 leaves it unchanged. - // See the correspondning member variables below for descriptions. - void SetParameters(int time_window, - int cost_per_typing, - int reporting_threshold, - int penalty_decay, - int type_event_delay, - int report_detection_update_period); - - private: - int time_active_; - int time_since_last_typing_; - int penalty_counter_; - - // Counter since last time the detection status reported by Process() was - // updated. See also `report_detection_update_period_`. - int counter_since_last_detection_update_; - - // The detection status to report. Updated every - // `report_detection_update_period_` call to Process(). - bool detection_to_report_; - - // What `detection_to_report_` should be set to next time it is updated. - bool new_detection_to_report_; - - // Settable threshold values. - - // Number of 10 ms slots accepted to count as a hit. - int time_window_; - - // Penalty added for a typing + activity coincide. - int cost_per_typing_; - - // Threshold for `penalty_counter_`. - int reporting_threshold_; - - // How much we reduce `penalty_counter_` every 10 ms. - int penalty_decay_; - - // How old typing events we allow. - int type_event_delay_; - - // Settable update period. - - // Number of 10 ms slots between each update of the detection status returned - // by Process(). This inertia added to the algorithm is usually desirable and - // provided so that consumers of the class don't have to implement that - // themselves if they don't wish. - // If set to 1, each call to Process() will return the detection status for - // that 10 ms slot. - // If set to N (where N > 1), the detection status returned from Process() - // will remain the same until Process() has been called N times. Then, if none - // of the last N calls to Process() has detected typing for each respective - // 10 ms slot, Process() will return false. If at least one of the last N - // calls has detected typing, Process() will return true. And that returned - // status will then remain the same until the next N calls have been done. - int report_detection_update_period_; -}; - -} // namespace webrtc - -#endif // #ifndef MODULES_AUDIO_PROCESSING_TYPING_DETECTION_H_ diff --git a/pc/stats_collector.cc b/pc/stats_collector.cc index 927e993203..44873faf29 100644 --- a/pc/stats_collector.cc +++ b/pc/stats_collector.cc @@ -143,10 +143,7 @@ void ExtractCommonReceiveProperties(const cricket::MediaReceiverInfo& info, } void SetAudioProcessingStats(StatsReport* report, - bool typing_noise_detected, const AudioProcessingStats& apm_stats) { - report->AddBoolean(StatsReport::kStatsValueNameTypingNoiseState, - typing_noise_detected); if (apm_stats.delay_median_ms) { report->AddInt(StatsReport::kStatsValueNameEchoDelayMedian, *apm_stats.delay_median_ms); @@ -245,8 +242,7 @@ void ExtractStats(const cricket::VoiceSenderInfo& info, bool use_standard_bytes_stats) { ExtractCommonSendProperties(info, report, use_standard_bytes_stats); - SetAudioProcessingStats(report, info.typing_noise_detected, - info.apm_statistics); + SetAudioProcessingStats(report, info.apm_statistics); const FloatForAdd floats[] = { {StatsReport::kStatsValueNameTotalAudioEnergy, info.total_input_energy}, @@ -1354,8 +1350,7 @@ void StatsCollector::UpdateReportFromAudioTrack(AudioTrackInterface* track, AudioProcessorInterface::AudioProcessorStatistics stats = audio_processor->GetStats(has_remote_tracks); - SetAudioProcessingStats(report, stats.typing_noise_detected, - stats.apm_statistics); + SetAudioProcessingStats(report, stats.apm_statistics); } } diff --git a/pc/stats_collector_unittest.cc b/pc/stats_collector_unittest.cc index 144ca34b55..61d09537c3 100644 --- a/pc/stats_collector_unittest.cc +++ b/pc/stats_collector_unittest.cc @@ -89,7 +89,6 @@ class FakeAudioProcessor : public AudioProcessorInterface { AudioProcessorInterface::AudioProcessorStatistics GetStats( bool has_recv_streams) override { AudioProcessorStatistics stats; - stats.typing_noise_detected = true; if (has_recv_streams) { stats.apm_statistics.echo_return_loss = 2.0; stats.apm_statistics.echo_return_loss_enhancement = 3.0; @@ -132,7 +131,6 @@ class FakeAudioProcessorWithInitValue : public AudioProcessorInterface { AudioProcessorInterface::AudioProcessorStatistics GetStats( bool /*has_recv_streams*/) override { AudioProcessorStatistics stats; - stats.typing_noise_detected = false; return stats; } }; @@ -488,10 +486,6 @@ void VerifyVoiceSenderInfoReport(const StatsReport* report, EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNameAudioInputLevel, &value_in_report)); EXPECT_EQ(rtc::ToString(sinfo.audio_level), value_in_report); - EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNameTypingNoiseState, - &value_in_report)); - std::string typing_detected = sinfo.typing_noise_detected ? "true" : "false"; - EXPECT_EQ(typing_detected, value_in_report); EXPECT_TRUE(GetValue(report, StatsReport::kStatsValueNameAnaBitrateActionCounter, &value_in_report)); @@ -551,7 +545,6 @@ void InitVoiceSenderInfo(cricket::VoiceSenderInfo* voice_sender_info, voice_sender_info->apm_statistics.echo_return_loss_enhancement = 109; voice_sender_info->apm_statistics.delay_median_ms = 110; voice_sender_info->apm_statistics.delay_standard_deviation_ms = 111; - voice_sender_info->typing_noise_detected = false; voice_sender_info->ana_statistics.bitrate_action_counter = 112; voice_sender_info->ana_statistics.channel_action_counter = 113; voice_sender_info->ana_statistics.dtx_action_counter = 114; @@ -568,8 +561,6 @@ void UpdateVoiceSenderInfoFromAudioTrack( audio_track->GetSignalLevel(&voice_sender_info->audio_level); AudioProcessorInterface::AudioProcessorStatistics audio_processor_stats = audio_track->GetAudioProcessor()->GetStats(has_remote_tracks); - voice_sender_info->typing_noise_detected = - audio_processor_stats.typing_noise_detected; voice_sender_info->apm_statistics = audio_processor_stats.apm_statistics; } From 0e5e647efba7a56a37cd0ffbe9d33bb31ac7f9a0 Mon Sep 17 00:00:00 2001 From: Jeremy Leconte Date: Wed, 23 Mar 2022 11:37:15 +0100 Subject: [PATCH 275/847] Upgrade xcode version to 13c100. This is a minor change to see if the config from the 'main' branch is used. Bug: chromium:1159728 Change-Id: Id9d1959b9c581712488e822e971f3c3667e0e06e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256480 Reviewed-by: Mirko Bonadei Commit-Queue: Jeremy Leconte Cr-Commit-Position: refs/heads/main@{#36301} --- infra/config/config.star | 2 +- infra/config/cr-buildbucket.cfg | 12 ++++++------ infra/config/project.cfg | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/infra/config/config.star b/infra/config/config.star index f089c656ba..af404c8c76 100755 --- a/infra/config/config.star +++ b/infra/config/config.star @@ -14,7 +14,7 @@ WEBRTC_GIT = "https://webrtc.googlesource.com/src" WEBRTC_GERRIT = "https://webrtc-review.googlesource.com/src" WEBRTC_TROOPER_EMAIL = "webrtc-troopers-robots@google.com" WEBRTC_IOS_XCODE_VERSION = "12a7209" -WEBRTC_XCODE13 = "13a233" +WEBRTC_XCODE13 = "13c100" DEFAULT_CPU = "x86-64" # Helpers: diff --git a/infra/config/cr-buildbucket.cfg b/infra/config/cr-buildbucket.cfg index 55aeece8db..af6fa26ae8 100644 --- a/infra/config/cr-buildbucket.cfg +++ b/infra/config/cr-buildbucket.cfg @@ -1877,13 +1877,13 @@ buckets { ' },' ' "builder_group": "client.webrtc",' ' "recipe": "webrtc/ios_api_framework",' - ' "xcode_build_version": "13a233"' + ' "xcode_build_version": "13c100"' '}' priority: 29 execution_timeout_secs: 7200 caches { - name: "xcode_ios_13a233" - path: "xcode_ios_13a233.app" + name: "xcode_ios_13c100" + path: "xcode_ios_13c100.app" } build_numbers: YES service_account: "webrtc-ci-builder@chops-service-accounts.iam.gserviceaccount.com" @@ -3520,13 +3520,13 @@ buckets { ' },' ' "builder_group": "tryserver.webrtc",' ' "recipe": "webrtc/ios_api_framework",' - ' "xcode_build_version": "13a233"' + ' "xcode_build_version": "13c100"' '}' priority: 30 execution_timeout_secs: 7200 caches { - name: "xcode_ios_13a233" - path: "xcode_ios_13a233.app" + name: "xcode_ios_13c100" + path: "xcode_ios_13c100.app" } build_numbers: YES service_account: "webrtc-try-builder@chops-service-accounts.iam.gserviceaccount.com" diff --git a/infra/config/project.cfg b/infra/config/project.cfg index 8f83365d86..3f14e8cd4c 100644 --- a/infra/config/project.cfg +++ b/infra/config/project.cfg @@ -7,7 +7,7 @@ name: "webrtc" access: "group:all" lucicfg { - version: "1.30.9" + version: "1.30.10" package_dir: "." config_dir: "." entry_point: "config.star" From c62dcc951dbf648ea2d16201b1de81dddc2ee9ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Wed, 2 Mar 2022 15:21:45 +0100 Subject: [PATCH 276/847] Reland "Avoid using lld when compiling iin iOS with bitcode" This is a reland of commit b7ba6027659913883af3d64ec0fdfcba96176816 Original change's description: > Avoid using lld when compiling iin iOS with bitcode > > The resulting framework's LLVM __bundle segment is empty otherwise. > > Bug: webrtc:13774 > Change-Id: I235a3005f8e0d68168f29108be0f7c5b7914182b > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253140 > Reviewed-by: Mirko Bonadei > Commit-Queue: Mirko Bonadei > Cr-Commit-Position: refs/heads/main@{#36178} Bug: webrtc:13774 Change-Id: Ia88b26d91bf1cf7323d04f024155ecf394498c41 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256481 Reviewed-by: Ilya Nikolaevskiy Commit-Queue: Mirko Bonadei Cr-Commit-Position: refs/heads/main@{#36302} --- tools_webrtc/ios/build_ios_libs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools_webrtc/ios/build_ios_libs.py b/tools_webrtc/ios/build_ios_libs.py index 15a912e4ba..9a4c3e32ad 100755 --- a/tools_webrtc/ios/build_ios_libs.py +++ b/tools_webrtc/ios/build_ios_libs.py @@ -180,6 +180,7 @@ def BuildWebRTC(output_dir, target_environment, target_arch, flavor, ('true' if libvpx_build_vp9 else 'false')) gn_args.append('enable_ios_bitcode=' + ('true' if use_bitcode else 'false')) + gn_args.append('use_lld=' + ('false' if use_bitcode else 'true')) gn_args.append('use_goma=' + ('true' if use_goma else 'false')) gn_args.append('rtc_enable_objc_symbol_export=true') From a2219e22d27b4a64524227af31f6bcc1e7d06149 Mon Sep 17 00:00:00 2001 From: Diep Bui Date: Wed, 23 Mar 2022 12:30:36 +0000 Subject: [PATCH 277/847] Use acked bitrate only when network is overusing. Bug: webrtc:12707 Change-Id: I9a263ec60f07cfd03eed0374c730c87e20014d65 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256113 Reviewed-by: Per Kjellander Commit-Queue: Diep Bui Cr-Commit-Position: refs/heads/main@{#36303} --- .../goog_cc/loss_based_bwe_v2.cc | 17 +++++- .../goog_cc/loss_based_bwe_v2.h | 3 + .../goog_cc/loss_based_bwe_v2_test.cc | 58 ++++++++++++++++++- 3 files changed, 76 insertions(+), 2 deletions(-) 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 03822e1710..7c72b99bda 100644 --- a/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc +++ b/modules/congestion_controller/goog_cc/loss_based_bwe_v2.cc @@ -578,7 +578,8 @@ std::vector LossBasedBweV2::GetCandidates( } if (acknowledged_bitrate_.has_value() && - config_->append_acknowledged_rate_candidate && can_decrease_bitrate) { + config_->append_acknowledged_rate_candidate && + TrendlineEsimateAllowEmergencyBackoff()) { bandwidths.push_back(*acknowledged_bitrate_ * config_->bandwidth_backoff_lower_bound_factor); } @@ -791,6 +792,20 @@ bool LossBasedBweV2::TrendlineEsimateAllowBitrateIncrease() const { return true; } +bool LossBasedBweV2::TrendlineEsimateAllowEmergencyBackoff() const { + if (!config_->trendline_integration_enabled) { + return true; + } + + for (const auto& detector_state : delay_detector_states_) { + if (detector_state == BandwidthUsage::kBwOverusing) { + return true; + } + } + + return false; +} + bool LossBasedBweV2::PushBackObservation( rtc::ArrayView packet_results, BandwidthUsage delay_detector_state) { diff --git a/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h b/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h index 7e42b3e827..cc33387c9e 100644 --- a/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h +++ b/modules/congestion_controller/goog_cc/loss_based_bwe_v2.h @@ -140,6 +140,9 @@ class LossBasedBweV2 { // Returns false if there exists an overusing state in the window. bool TrendlineEsimateAllowBitrateIncrease() const; + // Returns true if there exists an overusing state in the window. + bool TrendlineEsimateAllowEmergencyBackoff() const; + // Returns false if no observation was created. bool PushBackObservation(rtc::ArrayView packet_results, BandwidthUsage delay_detector_state); 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 bf0a7e492e..55de52d9c9 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 @@ -437,10 +437,14 @@ TEST(LossBasedBweV2Test, BandwidthEstimateIncreasesWhenUnderusing) { DataRate::KilobitsPerSec(600)); } +// When network is underusing, estimate can increase but never be higher than +// the delay based estimate. TEST(LossBasedBweV2Test, BandwidthEstimateCappedByDelayBasedEstimateWhenUnderusing) { PacketResult enough_feedback_1[2]; PacketResult enough_feedback_2[2]; + // Create two packet results, network is in normal state, 100% packets are + // received, and no delay increase. enough_feedback_1[0].sent_packet.size = DataSize::Bytes(15'000); enough_feedback_1[1].sent_packet.size = DataSize::Bytes(15'000); enough_feedback_2[0].sent_packet.size = DataSize::Bytes(15'000); @@ -470,16 +474,69 @@ TEST(LossBasedBweV2Test, loss_based_bandwidth_estimator.UpdateBandwidthEstimate( enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwUnderusing); + // If the delay based estimate is infinity, then loss based estimate increases + // and not bounded by delay based estimate. EXPECT_GT(loss_based_bandwidth_estimator.GetBandwidthEstimate( /*delay_based_limit=*/DataRate::PlusInfinity()), DataRate::KilobitsPerSec(600)); loss_based_bandwidth_estimator.UpdateBandwidthEstimate( enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal); + // If the delay based estimate is not infinity, then loss based estimate is + // bounded by delay based estimate. EXPECT_EQ(loss_based_bandwidth_estimator.GetBandwidthEstimate( /*delay_based_limit=*/DataRate::KilobitsPerSec(500)), DataRate::KilobitsPerSec(500)); } +// When loss based bwe receives a strong signal of overusing and an increase in +// loss rate, it should acked bitrate for emegency backoff. +TEST(LossBasedBweV2Test, UseAckedBitrateForEmegencyBackOff) { + PacketResult enough_feedback_1[2]; + PacketResult enough_feedback_2[2]; + // Create two packet results, first packet has 50% loss rate, second packet + // has 100% loss rate. + enough_feedback_1[0].sent_packet.size = DataSize::Bytes(15'000); + enough_feedback_1[1].sent_packet.size = DataSize::Bytes(15'000); + enough_feedback_2[0].sent_packet.size = DataSize::Bytes(15'000); + enough_feedback_2[1].sent_packet.size = DataSize::Bytes(15'000); + enough_feedback_1[0].sent_packet.send_time = Timestamp::Zero(); + enough_feedback_1[1].sent_packet.send_time = + Timestamp::Zero() + kObservationDurationLowerBound; + enough_feedback_2[0].sent_packet.send_time = + Timestamp::Zero() + 2 * kObservationDurationLowerBound; + enough_feedback_2[1].sent_packet.send_time = + Timestamp::Zero() + 3 * kObservationDurationLowerBound; + enough_feedback_1[0].receive_time = Timestamp::PlusInfinity(); + enough_feedback_1[1].receive_time = + Timestamp::Zero() + 2 * kObservationDurationLowerBound; + enough_feedback_2[0].receive_time = Timestamp::PlusInfinity(); + enough_feedback_2[1].receive_time = Timestamp::PlusInfinity(); + + ExplicitKeyValueConfig key_value_config( + Config(/*enabled=*/true, /*valid=*/true)); + LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config); + + loss_based_bandwidth_estimator.SetBandwidthEstimate( + DataRate::KilobitsPerSec(600)); + DataRate acked_bitrate = DataRate::KilobitsPerSec(300); + loss_based_bandwidth_estimator.SetAcknowledgedBitrate(acked_bitrate); + // Update estimate when network is overusing, and 50% loss rate. + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + enough_feedback_1, DataRate::PlusInfinity(), + BandwidthUsage::kBwOverusing); + // Update estimate again when network is continuously overusing, and 100% + // loss rate. + loss_based_bandwidth_estimator.UpdateBandwidthEstimate( + enough_feedback_2, DataRate::PlusInfinity(), + BandwidthUsage::kBwOverusing); + // The estimate bitrate now is backed off based on acked bitrate. + EXPECT_LE(loss_based_bandwidth_estimator.GetBandwidthEstimate( + /*delay_based_limit=*/DataRate::PlusInfinity()), + acked_bitrate); +} + +// When network is in normal state, and if the acked bitrate is small, then the +// loss based estimate is higher than the acked bitrate. TEST(LossBasedBweV2Test, NotUseAckedBitrateInNormalState) { PacketResult enough_feedback_1[2]; PacketResult enough_feedback_2[2]; @@ -525,5 +582,4 @@ TEST(LossBasedBweV2Test, NotUseAckedBitrateInNormalState) { } } // namespace - } // namespace webrtc From 50f4ae152298e961ee20d0ac586ff17ea1c31794 Mon Sep 17 00:00:00 2001 From: Diep Bui Date: Wed, 23 Mar 2022 12:44:13 +0000 Subject: [PATCH 278/847] Pace at max of BWE and lower link capacity only when loss based estimate is not less than delay based estimate. It is hard to add an unit test for this change, because OnTransportPacketsFeedback is the way to change the loss based estimate, and it also changes the lower link capacity. Thus we cannot track the two values without making changes in goog_cc, which seem to be unecessary. Bug: none Change-Id: I689ef52c4440c9bc2ff30f88b9cda96a90b0b64e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256368 Reviewed-by: Per Kjellander Commit-Queue: Diep Bui Cr-Commit-Position: refs/heads/main@{#36304} --- .../goog_cc/goog_cc_network_control.cc | 7 ++++++- .../goog_cc/goog_cc_network_control.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) 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 8ae7f40cb2..167203256c 100644 --- a/modules/congestion_controller/goog_cc/goog_cc_network_control.cc +++ b/modules/congestion_controller/goog_cc/goog_cc_network_control.cc @@ -92,6 +92,8 @@ GoogCcNetworkController::GoogCcNetworkController(NetworkControllerConfig config, pace_at_max_of_bwe_and_lower_link_capacity_( IsEnabled(key_value_config_, "WebRTC-Bwe-PaceAtMaxOfBweAndLowerLinkCapacity")), + pace_at_loss_based_bwe_when_loss_( + IsEnabled(key_value_config_, "WebRTC-Bwe-PaceAtLossBaseBweWhenLoss")), probe_controller_( new ProbeController(key_value_config_, config.event_log)), congestion_window_pushback_controller_( @@ -700,7 +702,10 @@ PacerConfig GoogCcNetworkController::GetPacingRates(Timestamp at_time) const { // Pacing rate is based on target rate before congestion window pushback, // because we don't want to build queues in the pacer when pushback occurs. DataRate pacing_rate = DataRate::Zero(); - if (pace_at_max_of_bwe_and_lower_link_capacity_ && estimate_) { + if ((pace_at_max_of_bwe_and_lower_link_capacity_ || + (pace_at_loss_based_bwe_when_loss_ && + last_loss_based_target_rate_ >= delay_based_bwe_->last_estimate())) && + estimate_) { pacing_rate = std::max({min_total_allocated_bitrate_, estimate_->link_capacity_lower, last_loss_based_target_rate_}) * 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 946c076939..048279fa56 100644 --- a/modules/congestion_controller/goog_cc/goog_cc_network_control.h +++ b/modules/congestion_controller/goog_cc/goog_cc_network_control.h @@ -95,6 +95,7 @@ class GoogCcNetworkController : public NetworkControllerInterface { const RateControlSettings rate_control_settings_; const bool loss_based_stable_rate_; const bool pace_at_max_of_bwe_and_lower_link_capacity_; + const bool pace_at_loss_based_bwe_when_loss_; const std::unique_ptr probe_controller_; const std::unique_ptr From e7985a491d249ade8deadd701c3bc2e1c0abcd09 Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Wed, 23 Mar 2022 09:02:20 -0700 Subject: [PATCH 279/847] Roll chromium_revision a697245f3d..e391064aa9 (984227:984363) Change log: https://chromium.googlesource.com/chromium/src/+log/a697245f3d..e391064aa9 Full diff: https://chromium.googlesource.com/chromium/src/+/a697245f3d..e391064aa9 Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/d07854bae7..2cb3acd739 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/8ae687514c..5aa939d269 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/af28cc6c8b..0ce3fc7530 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/46f39ff7fc..5f4d7cb097 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/5ad0921fc7..0f4367b186 * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/180b8d540d..96e1fe8c33 * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/5731615c4b..30a70afa95 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/b5911e5f6e..0c850287ed DEPS diff: https://chromium.googlesource.com/chromium/src/+/a697245f3d..e391064aa9/DEPS No update to Clang. BUG=None Change-Id: I1176cbe2357a815c657eae8165dc2f685ab7cb7a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256502 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36305} --- DEPS | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/DEPS b/DEPS index 831d30c855..258d2d8445 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': 'a697245f3dec8b1a02306b04d214dd3b94167ea0', + 'chromium_revision': 'e391064aa942b88a0bd4e2eac57c88330aa575c4', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@d07854bae776b5aac0b2753acb8a2c054fcc7c58', + 'https://chromium.googlesource.com/chromium/src/base@2cb3acd73957abcd6cd05b113ac1afcec69b5dd1', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@8ae687514ca6dc093331e7afcbd9f93cc8d95a72', + 'https://chromium.googlesource.com/chromium/src/build@5aa939d2691b2ee756068a8f474683c60c3551d0', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@e1471b21ee9c6765ee95e9db0c76fe997ccad35c', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@af28cc6c8b4fb0b0aa352f83afe8597e508b7f5b', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@0ce3fc7530c525cafc6232239bfb814a044ee606', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@46f39ff7fc51299f51ab60bb6d6ab2fe067b173c', + 'https://chromium.googlesource.com/chromium/src/testing@5f4d7cb0979e37d883809d84c80cf1331d8b258e', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@5ad0921fc791543a5422be8efdd52bd404394902', + 'https://chromium.googlesource.com/chromium/src/third_party@0f4367b186167dbd65206b4aa5cac398bed6c5f6', 'src/buildtools/linux64': { 'packages': [ @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@180b8d540d9f9ae3e24cfe564f02044133c1c070', + 'https://chromium.googlesource.com/catapult.git@96e1fe8c330900758f5d4ed0b849ccada66b3074', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -231,7 +231,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@5731615c4b5bd9221d0808161595cd57593def23', + 'https://android.googlesource.com/platform/external/perfetto.git@30a70afa95f9ec2b490cf83681649cc898d5dc08', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@bf672f23a5336cb54dbcb2e4417142139f44cc3e', 'src/third_party/libyuv': @@ -288,7 +288,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@b5911e5f6e010e617867882722b740b152a3b9b8', + 'https://chromium.googlesource.com/chromium/src/tools@0c850287ed8ba27a67e5a283eb7d18bc25dc176a', 'src/third_party/accessibility_test_framework': { 'packages': [ From 1bcdafca0e5193457600bbfbedb352814e4dad16 Mon Sep 17 00:00:00 2001 From: Ilya Nikolaevskiy Date: Wed, 9 Mar 2022 16:01:07 +0100 Subject: [PATCH 280/847] Reland of remove NV12 to I420 conversion in webrtc AV1 Encoder. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit libaom supports for NV12 inputs for encoding av1 stream. It will reduce unnecessary conversion from NV12 to I420 format. (https://bugs.chromium.org/p/aomedia/issues/detail?id=3232&q=3232&can=2) Original CL reviewed at https://webrtc-review.googlesource.com/c/src/+/251920 Bug: webrtc:13746 Change-Id: I96cc99674f315518d98355cb90566e78bead3e55 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254340 Reviewed-by: Erik Språng Reviewed-by: Ilya Nikolaevskiy Commit-Queue: Ilya Nikolaevskiy Cr-Commit-Position: refs/heads/main@{#36306} --- .../codecs/av1/libaom_av1_encoder.cc | 109 +++++++++++++----- video/video_stream_encoder_unittest.cc | 2 +- 2 files changed, 82 insertions(+), 29 deletions(-) diff --git a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc index 0e427be915..9f33acf24e 100644 --- a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc +++ b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc @@ -93,6 +93,8 @@ class LibaomAv1Encoder final : public VideoEncoder { // Configures the encoder which buffers next frame updates and can reference. void SetSvcRefFrameConfig( const ScalableVideoController::LayerFrameConfig& layer_frame); + // If pixel format doesn't match, then reallocate. + void MaybeRewrapImgWithFormat(const aom_img_fmt_t fmt); std::unique_ptr svc_controller_; bool inited_; @@ -216,11 +218,10 @@ int LibaomAv1Encoder::InitEncode(const VideoCodec* codec_settings, cfg_.g_pass = AOM_RC_ONE_PASS; // One-pass rate control cfg_.g_lag_in_frames = kLagInFrames; // No look ahead when lag equals 0. - // Creating a wrapper to the image - setting image data to nullptr. Actual - // pointer will be set in encode. Setting align to 1, as it is meaningless - // (actual memory is not allocated). - frame_for_encode_ = - aom_img_alloc(nullptr, AOM_IMG_FMT_I420, cfg_.g_w, cfg_.g_h, 1); + if (frame_for_encode_ != nullptr) { + aom_img_free(frame_for_encode_); + frame_for_encode_ = nullptr; + } // Flag options: AOM_CODEC_USE_PSNR and AOM_CODEC_USE_HIGHBITDEPTH aom_codec_flags_t flags = 0; @@ -578,6 +579,21 @@ int32_t LibaomAv1Encoder::Release() { return WEBRTC_VIDEO_CODEC_OK; } +void LibaomAv1Encoder::MaybeRewrapImgWithFormat(const aom_img_fmt_t fmt) { + if (!frame_for_encode_) { + frame_for_encode_ = + aom_img_wrap(nullptr, fmt, cfg_.g_w, cfg_.g_h, 1, nullptr); + + } else if (frame_for_encode_->fmt != fmt) { + RTC_LOG(LS_INFO) << "Switching AV1 encoder pixel format to " + << (fmt == AOM_IMG_FMT_NV12 ? "NV12" : "I420"); + aom_img_free(frame_for_encode_); + frame_for_encode_ = + aom_img_wrap(nullptr, fmt, cfg_.g_w, cfg_.g_h, 1, nullptr); + } + // else no-op since the image is already in the right format. +} + int32_t LibaomAv1Encoder::Encode( const VideoFrame& frame, const std::vector* frame_types) { @@ -597,38 +613,74 @@ int32_t LibaomAv1Encoder::Encode( return WEBRTC_VIDEO_CODEC_ERROR; } + rtc::scoped_refptr buffer = frame.video_frame_buffer(); + absl::InlinedVector + supported_formats = {VideoFrameBuffer::Type::kI420, + VideoFrameBuffer::Type::kNV12}; + rtc::scoped_refptr mapped_buffer; + if (buffer->type() != VideoFrameBuffer::Type::kNative) { + // `buffer` is already mapped. + mapped_buffer = buffer; + } else { + // Attempt to map to one of the supported formats. + mapped_buffer = buffer->GetMappedFrameBuffer(supported_formats); + } + // Convert input frame to I420, if needed. - VideoFrame prepped_input_frame = frame; - if (prepped_input_frame.video_frame_buffer()->type() != - VideoFrameBuffer::Type::kI420 && - prepped_input_frame.video_frame_buffer()->type() != - VideoFrameBuffer::Type::kI420A) { + if (!mapped_buffer || + (absl::c_find(supported_formats, mapped_buffer->type()) == + supported_formats.end() && + mapped_buffer->type() != VideoFrameBuffer::Type::kI420A)) { rtc::scoped_refptr converted_buffer( - prepped_input_frame.video_frame_buffer()->ToI420()); + mapped_buffer->ToI420()); if (!converted_buffer) { RTC_LOG(LS_ERROR) << "Failed to convert " << VideoFrameBufferTypeToString( - prepped_input_frame.video_frame_buffer()->type()) + frame.video_frame_buffer()->type()) << " image to I420. Can't encode frame."; return WEBRTC_VIDEO_CODEC_ENCODER_FAILURE; } RTC_CHECK(converted_buffer->type() == VideoFrameBuffer::Type::kI420 || converted_buffer->type() == VideoFrameBuffer::Type::kI420A); - prepped_input_frame = VideoFrame(converted_buffer, frame.timestamp(), - frame.render_time_ms(), frame.rotation()); - } - - // Set frame_for_encode_ data pointers and strides. - auto i420_buffer = prepped_input_frame.video_frame_buffer()->GetI420(); - frame_for_encode_->planes[AOM_PLANE_Y] = - const_cast(i420_buffer->DataY()); - frame_for_encode_->planes[AOM_PLANE_U] = - const_cast(i420_buffer->DataU()); - frame_for_encode_->planes[AOM_PLANE_V] = - const_cast(i420_buffer->DataV()); - frame_for_encode_->stride[AOM_PLANE_Y] = i420_buffer->StrideY(); - frame_for_encode_->stride[AOM_PLANE_U] = i420_buffer->StrideU(); - frame_for_encode_->stride[AOM_PLANE_V] = i420_buffer->StrideV(); + + mapped_buffer = converted_buffer; + } + + switch (mapped_buffer->type()) { + case VideoFrameBuffer::Type::kI420: + case VideoFrameBuffer::Type::kI420A: { + // Set frame_for_encode_ data pointers and strides. + MaybeRewrapImgWithFormat(AOM_IMG_FMT_I420); + auto i420_buffer = mapped_buffer->GetI420(); + RTC_DCHECK(i420_buffer); + frame_for_encode_->planes[AOM_PLANE_Y] = + const_cast(i420_buffer->DataY()); + frame_for_encode_->planes[AOM_PLANE_U] = + const_cast(i420_buffer->DataU()); + frame_for_encode_->planes[AOM_PLANE_V] = + const_cast(i420_buffer->DataV()); + frame_for_encode_->stride[AOM_PLANE_Y] = i420_buffer->StrideY(); + frame_for_encode_->stride[AOM_PLANE_U] = i420_buffer->StrideU(); + frame_for_encode_->stride[AOM_PLANE_V] = i420_buffer->StrideV(); + break; + } + case VideoFrameBuffer::Type::kNV12: { + MaybeRewrapImgWithFormat(AOM_IMG_FMT_NV12); + const NV12BufferInterface* nv12_buffer = mapped_buffer->GetNV12(); + RTC_DCHECK(nv12_buffer); + frame_for_encode_->planes[AOM_PLANE_Y] = + const_cast(nv12_buffer->DataY()); + frame_for_encode_->planes[AOM_PLANE_U] = + const_cast(nv12_buffer->DataUV()); + frame_for_encode_->planes[AOM_PLANE_V] = nullptr; + frame_for_encode_->stride[AOM_PLANE_Y] = nv12_buffer->StrideY(); + frame_for_encode_->stride[AOM_PLANE_U] = nv12_buffer->StrideUV(); + frame_for_encode_->stride[AOM_PLANE_V] = 0; + break; + } + default: + return WEBRTC_VIDEO_CODEC_ENCODER_FAILURE; + } const uint32_t duration = kRtpTicksPerSecond / static_cast(encoder_settings_.maxFramerate); @@ -828,7 +880,8 @@ VideoEncoder::EncoderInfo LibaomAv1Encoder::GetEncoderInfo() const { info.has_trusted_rate_controller = true; info.is_hardware_accelerated = false; info.scaling_settings = VideoEncoder::ScalingSettings(kMinQindex, kMaxQindex); - info.preferred_pixel_formats = {VideoFrameBuffer::Type::kI420}; + info.preferred_pixel_formats = {VideoFrameBuffer::Type::kI420, + VideoFrameBuffer::Type::kNV12}; if (SvcEnabled()) { for (int sid = 0; sid < svc_params_->number_spatial_layers; ++sid) { info.fps_allocation[sid].resize(svc_params_->number_temporal_layers); diff --git a/video/video_stream_encoder_unittest.cc b/video/video_stream_encoder_unittest.cc index d20b5ab891..09ca0b679d 100644 --- a/video/video_stream_encoder_unittest.cc +++ b/video/video_stream_encoder_unittest.cc @@ -8714,7 +8714,7 @@ constexpr std::pair kVP8DisallowConversion = constexpr std::pair kVP9DisallowConversion = std::make_pair(kVideoCodecVP9, /*allow_i420_conversion=*/false); constexpr std::pair kAV1AllowConversion = - std::make_pair(kVideoCodecAV1, /*allow_i420_conversion=*/true); + std::make_pair(kVideoCodecAV1, /*allow_i420_conversion=*/false); constexpr std::pair kMultiplexDisallowConversion = std::make_pair(kVideoCodecMultiplex, /*allow_i420_conversion=*/false); #if defined(WEBRTC_USE_H264) From 96544b72eb75a0d67eb5f4abd35cb6ca6f1c4edb Mon Sep 17 00:00:00 2001 From: Jan Grulich Date: Wed, 23 Mar 2022 09:34:51 +0100 Subject: [PATCH 281/847] PipeWire capturer: split some PipeWire code that can be reused This is code that will be used to write tests and that makes sense to be moved out and used somewhere else. Bug: webrtc:13429 Change-Id: I2dd8f3111fdc9e6fa121c1e18644cbcf340b584e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256009 Reviewed-by: Mark Foltz Reviewed-by: Alexander Cooper Commit-Queue: Alexander Cooper Cr-Commit-Position: refs/heads/main@{#36307} --- modules/desktop_capture/BUILD.gn | 2 + .../linux/wayland/screencast_stream_utils.cc | 133 +++++++++++++++ .../linux/wayland/screencast_stream_utils.h | 62 +++++++ .../linux/wayland/shared_screencast_stream.cc | 157 +++--------------- .../linux/wayland/shared_screencast_stream.h | 1 + 5 files changed, 220 insertions(+), 135 deletions(-) create mode 100644 modules/desktop_capture/linux/wayland/screencast_stream_utils.cc create mode 100644 modules/desktop_capture/linux/wayland/screencast_stream_utils.h diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn index 0faad43a1f..7499c16b09 100644 --- a/modules/desktop_capture/BUILD.gn +++ b/modules/desktop_capture/BUILD.gn @@ -572,6 +572,8 @@ rtc_library("desktop_capture_generic") { "linux/wayland/scoped_glib.h", "linux/wayland/screencast_portal.cc", "linux/wayland/screencast_portal.h", + "linux/wayland/screencast_stream_utils.cc", + "linux/wayland/screencast_stream_utils.h", "linux/wayland/shared_screencast_stream.cc", "linux/wayland/shared_screencast_stream.h", "linux/wayland/xdg_desktop_portal_utils.cc", diff --git a/modules/desktop_capture/linux/wayland/screencast_stream_utils.cc b/modules/desktop_capture/linux/wayland/screencast_stream_utils.cc new file mode 100644 index 0000000000..6d0df404f9 --- /dev/null +++ b/modules/desktop_capture/linux/wayland/screencast_stream_utils.cc @@ -0,0 +1,133 @@ +/* + * Copyright 2022 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "modules/desktop_capture/linux/wayland/screencast_stream_utils.h" + +#include +#include +#include + +#include + +#include "rtc_base/string_to_number.h" + +#if !PW_CHECK_VERSION(0, 3, 29) +#define SPA_POD_PROP_FLAG_MANDATORY (1u << 3) +#endif +#if !PW_CHECK_VERSION(0, 3, 33) +#define SPA_POD_PROP_FLAG_DONT_FIXATE (1u << 4) +#endif + +namespace webrtc { + +PipeWireThreadLoopLock::PipeWireThreadLoopLock(pw_thread_loop* loop) + : loop_(loop) { + pw_thread_loop_lock(loop_); +} + +PipeWireThreadLoopLock::~PipeWireThreadLoopLock() { + pw_thread_loop_unlock(loop_); +} + +PipeWireVersion PipeWireVersion::Parse(const absl::string_view& version) { + std::vector parsed_version; + rtc::split(version, '.', &parsed_version); + + if (parsed_version.size() != 3) { + return {}; + } + + absl::optional major = rtc::StringToNumber(parsed_version.at(0)); + absl::optional minor = rtc::StringToNumber(parsed_version.at(1)); + absl::optional micro = rtc::StringToNumber(parsed_version.at(2)); + + // Return invalid version if we failed to parse it + if (!major || !minor || !micro) { + return {}; + } + + return {major.value(), minor.value(), micro.value()}; +} + +bool PipeWireVersion::operator>=(const PipeWireVersion& other) { + if (!major && !minor && !micro) { + return false; + } + + return std::tie(major, minor, micro) >= + std::tie(other.major, other.minor, other.micro); +} + +bool PipeWireVersion::operator<=(const PipeWireVersion& other) { + if (!major && !minor && !micro) { + return false; + } + + return std::tie(major, minor, micro) <= + std::tie(other.major, other.minor, other.micro); +} + +spa_pod* BuildFormat(spa_pod_builder* builder, + uint32_t format, + const std::vector& modifiers, + const struct spa_rectangle* resolution) { + spa_pod_frame frames[2]; + spa_rectangle pw_min_screen_bounds = spa_rectangle{1, 1}; + spa_rectangle pw_max_screen_bounds = spa_rectangle{UINT32_MAX, UINT32_MAX}; + + spa_pod_builder_push_object(builder, &frames[0], SPA_TYPE_OBJECT_Format, + SPA_PARAM_EnumFormat); + spa_pod_builder_add(builder, SPA_FORMAT_mediaType, + SPA_POD_Id(SPA_MEDIA_TYPE_video), 0); + spa_pod_builder_add(builder, SPA_FORMAT_mediaSubtype, + SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw), 0); + spa_pod_builder_add(builder, SPA_FORMAT_VIDEO_format, SPA_POD_Id(format), 0); + + if (modifiers.size()) { + if (modifiers.size() == 1 && modifiers[0] == DRM_FORMAT_MOD_INVALID) { + spa_pod_builder_prop(builder, SPA_FORMAT_VIDEO_modifier, + SPA_POD_PROP_FLAG_MANDATORY); + spa_pod_builder_long(builder, modifiers[0]); + } else { + spa_pod_builder_prop( + builder, SPA_FORMAT_VIDEO_modifier, + SPA_POD_PROP_FLAG_MANDATORY | SPA_POD_PROP_FLAG_DONT_FIXATE); + spa_pod_builder_push_choice(builder, &frames[1], SPA_CHOICE_Enum, 0); + + // modifiers from the array + bool first = true; + for (int64_t val : modifiers) { + spa_pod_builder_long(builder, val); + // Add the first modifier twice as the very first value is the default + // option + if (first) { + spa_pod_builder_long(builder, val); + first = false; + } + } + spa_pod_builder_pop(builder, &frames[1]); + } + } + + if (resolution) { + spa_pod_builder_add(builder, SPA_FORMAT_VIDEO_size, + SPA_POD_Rectangle(resolution), 0); + } else { + spa_pod_builder_add(builder, SPA_FORMAT_VIDEO_size, + SPA_POD_CHOICE_RANGE_Rectangle(&pw_min_screen_bounds, + &pw_min_screen_bounds, + &pw_max_screen_bounds), + 0); + } + + return static_cast(spa_pod_builder_pop(builder, &frames[0])); +} + +} // namespace webrtc diff --git a/modules/desktop_capture/linux/wayland/screencast_stream_utils.h b/modules/desktop_capture/linux/wayland/screencast_stream_utils.h new file mode 100644 index 0000000000..70262c2e39 --- /dev/null +++ b/modules/desktop_capture/linux/wayland/screencast_stream_utils.h @@ -0,0 +1,62 @@ +/* + * Copyright 2022 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_DESKTOP_CAPTURE_LINUX_WAYLAND_SCREENCAST_STREAM_UTILS_H_ +#define MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_SCREENCAST_STREAM_UTILS_H_ + +#include + +#include +#include + +#include "rtc_base/string_encode.h" + +struct pw_thread_loop; +struct spa_pod; +struct spa_pod_builder; +struct spa_rectangle; + +namespace webrtc { + +// Locks pw_thread_loop in the current scope +class PipeWireThreadLoopLock { + public: + explicit PipeWireThreadLoopLock(pw_thread_loop* loop); + ~PipeWireThreadLoopLock(); + + private: + pw_thread_loop* const loop_; +}; + +struct PipeWireVersion { + static PipeWireVersion Parse(const absl::string_view& version); + + // Returns whether current version is newer or same as required version + bool operator>=(const PipeWireVersion& other); + // Returns whether current version is older or same as required version + bool operator<=(const PipeWireVersion& other); + + int major = 0; + int minor = 0; + int micro = 0; +}; + +// Returns a spa_pod used to build PipeWire stream format using given +// arguments. Modifiers are optional value and when present they will be +// used with SPA_POD_PROP_FLAG_MANDATORY and SPA_POD_PROP_FLAG_DONT_FIXATE +// flags. +spa_pod* BuildFormat(spa_pod_builder* builder, + uint32_t format, + const std::vector& modifiers, + const struct spa_rectangle* resolution); + +} // namespace webrtc + +#endif // MODULES_DESKTOP_CAPTURE_LINUX_WAYLAND_SCREENCAST_STREAM_UTILS_H_ diff --git a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc index 720234fba8..535d0923ef 100644 --- a/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc +++ b/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc @@ -12,25 +12,18 @@ #include #include -#include -#include #include -#include #include -#include -#include -#include #include #include "absl/memory/memory.h" #include "modules/desktop_capture/linux/wayland/egl_dmabuf.h" +#include "modules/desktop_capture/linux/wayland/screencast_stream_utils.h" #include "modules/desktop_capture/screen_capture_frame_queue.h" #include "rtc_base/checks.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" #if defined(WEBRTC_DLOPEN_PIPEWIRE) @@ -50,110 +43,16 @@ const char kPipeWireLib[] = "libpipewire-0.3.so.0"; const char kDrmLib[] = "libdrm.so.2"; #endif -#if !PW_CHECK_VERSION(0, 3, 29) -#define SPA_POD_PROP_FLAG_MANDATORY (1u << 3) -#endif -#if !PW_CHECK_VERSION(0, 3, 33) -#define SPA_POD_PROP_FLAG_DONT_FIXATE (1u << 4) -#endif - constexpr int kCursorBpp = 4; constexpr int CursorMetaSize(int w, int h) { return (sizeof(struct spa_meta_cursor) + sizeof(struct spa_meta_bitmap) + w * h * kCursorBpp); } -struct PipeWireVersion { - int major = 0; - int minor = 0; - int micro = 0; -}; - constexpr PipeWireVersion kDmaBufMinVersion = {0, 3, 24}; constexpr PipeWireVersion kDmaBufModifierMinVersion = {0, 3, 33}; constexpr PipeWireVersion kDropSingleModifierMinVersion = {0, 3, 40}; -PipeWireVersion ParsePipeWireVersion(const char* version) { - std::vector parsed_version; - rtc::split(version, '.', &parsed_version); - - if (parsed_version.size() != 3) { - return {}; - } - - absl::optional major = rtc::StringToNumber(parsed_version.at(0)); - absl::optional minor = rtc::StringToNumber(parsed_version.at(1)); - absl::optional micro = rtc::StringToNumber(parsed_version.at(2)); - - // Return invalid version if we failed to parse it - if (!major || !minor || !micro) { - return {0, 0, 0}; - } - - return {major.value(), micro.value(), micro.value()}; -} - -spa_pod* BuildFormat(spa_pod_builder* builder, - uint32_t format, - const std::vector& modifiers) { - bool first = true; - spa_pod_frame frames[2]; - spa_rectangle pw_min_screen_bounds = spa_rectangle{1, 1}; - spa_rectangle pw_max_screen_bounds = spa_rectangle{UINT32_MAX, UINT32_MAX}; - - spa_pod_builder_push_object(builder, &frames[0], SPA_TYPE_OBJECT_Format, - SPA_PARAM_EnumFormat); - spa_pod_builder_add(builder, SPA_FORMAT_mediaType, - SPA_POD_Id(SPA_MEDIA_TYPE_video), 0); - spa_pod_builder_add(builder, SPA_FORMAT_mediaSubtype, - SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw), 0); - spa_pod_builder_add(builder, SPA_FORMAT_VIDEO_format, SPA_POD_Id(format), 0); - - if (modifiers.size()) { - if (modifiers.size() == 1 && modifiers[0] == DRM_FORMAT_MOD_INVALID) { - spa_pod_builder_prop(builder, SPA_FORMAT_VIDEO_modifier, - SPA_POD_PROP_FLAG_MANDATORY); - spa_pod_builder_long(builder, modifiers[0]); - } else { - spa_pod_builder_prop( - builder, SPA_FORMAT_VIDEO_modifier, - SPA_POD_PROP_FLAG_MANDATORY | SPA_POD_PROP_FLAG_DONT_FIXATE); - spa_pod_builder_push_choice(builder, &frames[1], SPA_CHOICE_Enum, 0); - - // modifiers from the array - for (int64_t val : modifiers) { - spa_pod_builder_long(builder, val); - // Add the first modifier twice as the very first value is the default - // option - if (first) { - spa_pod_builder_long(builder, val); - first = false; - } - } - spa_pod_builder_pop(builder, &frames[1]); - } - } - - spa_pod_builder_add( - builder, SPA_FORMAT_VIDEO_size, - SPA_POD_CHOICE_RANGE_Rectangle( - &pw_min_screen_bounds, &pw_min_screen_bounds, &pw_max_screen_bounds), - 0); - - return static_cast(spa_pod_builder_pop(builder, &frames[0])); -} - -class PipeWireThreadLoopLock { - public: - explicit PipeWireThreadLoopLock(pw_thread_loop* loop) : loop_(loop) { - pw_thread_loop_lock(loop_); - } - ~PipeWireThreadLoopLock() { pw_thread_loop_unlock(loop_); } - - private: - pw_thread_loop* const loop_; -}; - class ScopedBuf { public: ScopedBuf() {} @@ -260,32 +159,6 @@ class SharedScreenCastStreamPrivate { static void OnRenegotiateFormat(void* data, uint64_t); }; -bool operator>=(const PipeWireVersion& current_pw_version, - const PipeWireVersion& required_pw_version) { - if (!current_pw_version.major && !current_pw_version.minor && - !current_pw_version.micro) { - return false; - } - - return std::tie(current_pw_version.major, current_pw_version.minor, - current_pw_version.micro) >= - std::tie(required_pw_version.major, required_pw_version.minor, - required_pw_version.micro); -} - -bool operator<=(const PipeWireVersion& current_pw_version, - const PipeWireVersion& required_pw_version) { - if (!current_pw_version.major && !current_pw_version.minor && - !current_pw_version.micro) { - return false; - } - - return std::tie(current_pw_version.major, current_pw_version.minor, - current_pw_version.micro) <= - std::tie(required_pw_version.major, required_pw_version.minor, - required_pw_version.micro); -} - void SharedScreenCastStreamPrivate::OnCoreError(void* data, uint32_t id, int seq, @@ -304,7 +177,7 @@ void SharedScreenCastStreamPrivate::OnCoreInfo(void* data, static_cast(data); RTC_DCHECK(stream); - stream->pw_server_version_ = ParsePipeWireVersion(info->version); + stream->pw_server_version_ = PipeWireVersion::Parse(info->version); } void SharedScreenCastStreamPrivate::OnCoreDone(void* data, @@ -457,9 +330,11 @@ void SharedScreenCastStreamPrivate::OnRenegotiateFormat(void* data, uint64_t) { for (uint32_t format : {SPA_VIDEO_FORMAT_BGRA, SPA_VIDEO_FORMAT_RGBA, SPA_VIDEO_FORMAT_BGRx, SPA_VIDEO_FORMAT_RGBx}) { if (!that->modifiers_.empty()) { - params.push_back(BuildFormat(&builder, format, that->modifiers_)); + params.push_back(BuildFormat(&builder, format, that->modifiers_, + /*resolution=*/nullptr)); } - params.push_back(BuildFormat(&builder, format, /*modifiers=*/{})); + params.push_back(BuildFormat(&builder, format, /*modifiers=*/{}, + /*resolution=*/nullptr)); } pw_stream_update_params(that->pw_stream_, params.data(), params.size()); @@ -530,7 +405,7 @@ bool SharedScreenCastStreamPrivate::StartScreenCastStream( return false; } - pw_client_version_ = ParsePipeWireVersion(pw_get_library_version()); + pw_client_version_ = PipeWireVersion::Parse(pw_get_library_version()); // Initialize event handlers, remote end and stream-related. pw_core_events_.version = PW_VERSION_CORE_EVENTS; @@ -546,7 +421,12 @@ bool SharedScreenCastStreamPrivate::StartScreenCastStream( { PipeWireThreadLoopLock thread_loop_lock(pw_main_loop_); - pw_core_ = pw_context_connect_fd(pw_context_, pw_fd_, nullptr, 0); + if (!pw_fd_) { + pw_core_ = pw_context_connect(pw_context_, nullptr, 0); + } else { + pw_core_ = pw_context_connect_fd(pw_context_, pw_fd_, nullptr, 0); + } + if (!pw_core_) { RTC_LOG(LS_ERROR) << "Failed to connect PipeWire context"; return false; @@ -590,11 +470,13 @@ bool SharedScreenCastStreamPrivate::StartScreenCastStream( modifiers_ = egl_dmabuf_->QueryDmaBufModifiers(format); if (!modifiers_.empty()) { - params.push_back(BuildFormat(&builder, format, modifiers_)); + params.push_back(BuildFormat(&builder, format, modifiers_, + /*resolution=*/nullptr)); } } - params.push_back(BuildFormat(&builder, format, /*modifiers=*/{})); + params.push_back(BuildFormat(&builder, format, /*modifiers=*/{}, + /*resolution=*/nullptr)); } if (pw_stream_connect(pw_stream_, PW_DIRECTION_INPUT, pw_stream_node_id_, @@ -735,6 +617,7 @@ void SharedScreenCastStreamPrivate::ProcessBuffer(pw_buffer* buffer) { if (!src) { return; } + struct spa_meta_region* video_metadata = static_cast(spa_buffer_find_meta_data( spa_buffer, SPA_META_VideoCrop, sizeof(*video_metadata))); @@ -845,6 +728,10 @@ SharedScreenCastStream::CreateDefault() { return rtc::scoped_refptr(new SharedScreenCastStream()); } +bool SharedScreenCastStream::StartScreenCastStream(uint32_t stream_node_id) { + return private_->StartScreenCastStream(stream_node_id, 0); +} + bool SharedScreenCastStream::StartScreenCastStream(uint32_t stream_node_id, int fd) { return private_->StartScreenCastStream(stream_node_id, fd); diff --git a/modules/desktop_capture/linux/wayland/shared_screencast_stream.h b/modules/desktop_capture/linux/wayland/shared_screencast_stream.h index 443ec745d5..1e9fbe5f70 100644 --- a/modules/desktop_capture/linux/wayland/shared_screencast_stream.h +++ b/modules/desktop_capture/linux/wayland/shared_screencast_stream.h @@ -29,6 +29,7 @@ class RTC_EXPORT SharedScreenCastStream public: static rtc::scoped_refptr CreateDefault(); + bool StartScreenCastStream(uint32_t stream_node_id); bool StartScreenCastStream(uint32_t stream_node_id, int fd); void StopScreenCastStream(); From b9c636506bbee5ca6b7494888dc1fe6cb92009ce Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Wed, 23 Mar 2022 13:01:41 -0700 Subject: [PATCH 282/847] Roll chromium_revision e391064aa9..351d363e43 (984363:984486) Change log: https://chromium.googlesource.com/chromium/src/+log/e391064aa9..351d363e43 Full diff: https://chromium.googlesource.com/chromium/src/+/e391064aa9..351d363e43 Changed dependencies * src/base: https://chromium.googlesource.com/chromium/src/base/+log/2cb3acd739..757ea78481 * src/build: https://chromium.googlesource.com/chromium/src/build/+log/5aa939d269..06d68454b6 * src/buildtools/third_party/libunwind/trunk: https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git/+log/d1c7f92b8b..0662c09a82 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/0ce3fc7530..96749f818a * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/5f4d7cb097..84761dcaa0 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/0f4367b186..ff3b8cfc75 * src/third_party/catapult: https://chromium.googlesource.com/catapult.git/+log/96e1fe8c33..72a759f779 * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/30a70afa95..ab32c07962 * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/0c850287ed..eea907b99a DEPS diff: https://chromium.googlesource.com/chromium/src/+/e391064aa9..351d363e43/DEPS No update to Clang. BUG=None Change-Id: Iaa70dc01b8bc18b26bb07f5d0f585f4039b4bb67 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256520 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36308} --- DEPS | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/DEPS b/DEPS index 258d2d8445..020af98ad9 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': 'e391064aa942b88a0bd4e2eac57c88330aa575c4', + 'chromium_revision': '351d363e43e8d3f1fc39b311177d3bf434e69c1c', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -23,9 +23,9 @@ deps = { # TODO(kjellander): Move this to be Android-only once the libevent dependency # in base/third_party/libevent is solved. 'src/base': - 'https://chromium.googlesource.com/chromium/src/base@2cb3acd73957abcd6cd05b113ac1afcec69b5dd1', + 'https://chromium.googlesource.com/chromium/src/base@757ea78481f86822cbe6b6582edef2d311bc1266', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@5aa939d2691b2ee756068a8f474683c60c3551d0', + 'https://chromium.googlesource.com/chromium/src/build@06d68454b6f22cd7b06369b4b97ce6014b108bb2', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@e1471b21ee9c6765ee95e9db0c76fe997ccad35c', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@0ce3fc7530c525cafc6232239bfb814a044ee606', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@96749f818af09766c9513871ad08d197d236c5a9', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@5f4d7cb0979e37d883809d84c80cf1331d8b258e', + 'https://chromium.googlesource.com/chromium/src/testing@84761dcaa0f14d0f7cb052c23fba8c9455423403', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@0f4367b186167dbd65206b4aa5cac398bed6c5f6', + 'https://chromium.googlesource.com/chromium/src/third_party@ff3b8cfc75916a15727731685890c77d8b66a02b', 'src/buildtools/linux64': { 'packages': [ @@ -80,7 +80,7 @@ deps = { 'src/buildtools/third_party/libc++abi/trunk': 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git@edde7bbc4049ae4a32257d9f16451312c763c601', 'src/buildtools/third_party/libunwind/trunk': - 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git@d1c7f92b8b0bff8d9f710ca40e44563a63db376e', + 'https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git@0662c09a82e8130c44770091bd435fc6211edd0f', 'src/tools/clang/dsymutil': { 'packages': [ @@ -140,7 +140,7 @@ deps = { 'src/third_party/breakpad/breakpad': 'https://chromium.googlesource.com/breakpad/breakpad.git@08bd844599bf04c71707e8f59a8013a941264695', 'src/third_party/catapult': - 'https://chromium.googlesource.com/catapult.git@96e1fe8c330900758f5d4ed0b849ccada66b3074', + 'https://chromium.googlesource.com/catapult.git@72a759f77919cfc8cad63a5c1f670eda3f94c3d1', 'src/third_party/ced/src': { 'url': 'https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git@ba412eaaacd3186085babcd901679a48863c7dd5', }, @@ -231,7 +231,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@30a70afa95f9ec2b490cf83681649cc898d5dc08', + 'https://android.googlesource.com/platform/external/perfetto.git@ab32c07962cf0a145b7906a97d0dabed35189286', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@bf672f23a5336cb54dbcb2e4417142139f44cc3e', 'src/third_party/libyuv': @@ -288,7 +288,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@0c850287ed8ba27a67e5a283eb7d18bc25dc176a', + 'https://chromium.googlesource.com/chromium/src/tools@eea907b99ae5f4311da0c9252a73f5eee587368c', 'src/third_party/accessibility_test_framework': { 'packages': [ From 5f1fd1b1377ee9d4e132cce9caf59c504d7f0fdb Mon Sep 17 00:00:00 2001 From: chromium-webrtc-autoroll Date: Wed, 23 Mar 2022 17:01:29 -0700 Subject: [PATCH 283/847] Roll chromium_revision 351d363e43..464bf1c171 (984486:984608) Change log: https://chromium.googlesource.com/chromium/src/+log/351d363e43..464bf1c171 Full diff: https://chromium.googlesource.com/chromium/src/+/351d363e43..464bf1c171 Changed dependencies * src/build: https://chromium.googlesource.com/chromium/src/build/+log/06d68454b6..57b3452d26 * src/ios: https://chromium.googlesource.com/chromium/src/ios/+log/96749f818a..d11e422ea6 * src/testing: https://chromium.googlesource.com/chromium/src/testing/+log/84761dcaa0..03bf7a8890 * src/third_party: https://chromium.googlesource.com/chromium/src/third_party/+log/ff3b8cfc75..c9246c6fc4 * src/third_party/depot_tools: https://chromium.googlesource.com/chromium/tools/depot_tools.git/+log/e7eb3eb81a..4de5deacd4 * src/third_party/perfetto: https://android.googlesource.com/platform/external/perfetto.git/+log/ab32c07962..ae44ad76bd * src/tools: https://chromium.googlesource.com/chromium/src/tools/+log/eea907b99a..772716903d DEPS diff: https://chromium.googlesource.com/chromium/src/+/351d363e43..464bf1c171/DEPS No update to Clang. BUG=None Change-Id: I20cb3b5e635b7615f439f3bc9d1707d931885562 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256541 Bot-Commit: Autoroller Commit-Queue: Autoroller Cr-Commit-Position: refs/heads/main@{#36309} --- DEPS | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/DEPS b/DEPS index 020af98ad9..50f9aa90b3 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': '351d363e43e8d3f1fc39b311177d3bf434e69c1c', + 'chromium_revision': '464bf1c1712b8f17c7a65cd7aec558f010e41436', # Keep the Chromium default of generating location tags. 'generate_location_tags': True, @@ -25,7 +25,7 @@ deps = { 'src/base': 'https://chromium.googlesource.com/chromium/src/base@757ea78481f86822cbe6b6582edef2d311bc1266', 'src/build': - 'https://chromium.googlesource.com/chromium/src/build@06d68454b6f22cd7b06369b4b97ce6014b108bb2', + 'https://chromium.googlesource.com/chromium/src/build@57b3452d26cdff545e668aa102525d10cfa6722e', 'src/buildtools': 'https://chromium.googlesource.com/chromium/src/buildtools@e1471b21ee9c6765ee95e9db0c76fe997ccad35c', # Gradle 6.6.1. Used for testing Android Studio project generation for WebRTC. @@ -34,13 +34,13 @@ deps = { 'condition': 'checkout_android', }, 'src/ios': { - 'url': 'https://chromium.googlesource.com/chromium/src/ios@96749f818af09766c9513871ad08d197d236c5a9', + 'url': 'https://chromium.googlesource.com/chromium/src/ios@d11e422ea65ba4b54c007a077b84ef4110cc6367', 'condition': 'checkout_ios', }, 'src/testing': - 'https://chromium.googlesource.com/chromium/src/testing@84761dcaa0f14d0f7cb052c23fba8c9455423403', + 'https://chromium.googlesource.com/chromium/src/testing@03bf7a889025ef8e930a679e22aae33e49b64b12', 'src/third_party': - 'https://chromium.googlesource.com/chromium/src/third_party@ff3b8cfc75916a15727731685890c77d8b66a02b', + 'https://chromium.googlesource.com/chromium/src/third_party@c9246c6fc4176a7a6a6fdf99194e4ff264552f84', 'src/buildtools/linux64': { 'packages': [ @@ -149,7 +149,7 @@ deps = { 'src/third_party/crc32c/src': 'https://chromium.googlesource.com/external/github.com/google/crc32c.git@fa5ade41ee480003d9c5af6f43567ba22e4e17e6', 'src/third_party/depot_tools': - 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@e7eb3eb81ab7a84f7d9fc422200b9ba09d95699f', + 'https://chromium.googlesource.com/chromium/tools/depot_tools.git@4de5deacd4a7cb46637a3d446b9c0dc258be1159', 'src/third_party/ffmpeg': 'https://chromium.googlesource.com/chromium/third_party/ffmpeg.git@574c39cce3231c69bc9a02ac475c27d944bdb113', 'src/third_party/findbugs': { @@ -231,7 +231,7 @@ deps = { 'condition': 'checkout_android', }, 'src/third_party/perfetto': - 'https://android.googlesource.com/platform/external/perfetto.git@ab32c07962cf0a145b7906a97d0dabed35189286', + 'https://android.googlesource.com/platform/external/perfetto.git@ae44ad76bdf06db6f4e11186dd30cfdbc7d852b0', 'src/third_party/libvpx/source/libvpx': 'https://chromium.googlesource.com/webm/libvpx.git@bf672f23a5336cb54dbcb2e4417142139f44cc3e', 'src/third_party/libyuv': @@ -288,7 +288,7 @@ deps = { 'condition': 'checkout_win', }, 'src/tools': - 'https://chromium.googlesource.com/chromium/src/tools@eea907b99ae5f4311da0c9252a73f5eee587368c', + 'https://chromium.googlesource.com/chromium/src/tools@772716903dee5528181073031e7cc7a75bdae2f5', 'src/third_party/accessibility_test_framework': { 'packages': [ From 6c61b904584394e17f47867ec43530686541acf0 Mon Sep 17 00:00:00 2001 From: webrtc-version-updater Date: Wed, 23 Mar 2022 21:09:56 -0700 Subject: [PATCH 284/847] Update WebRTC code version (2022-03-24T04:09:55). Bug: None Change-Id: Ie69631a4fe14b83c62971ecd7a2b1f4da27f7d10 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256544 Bot-Commit: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Commit-Queue: webrtc-version-updater@webrtc-ci.iam.gserviceaccount.com Cr-Commit-Position: refs/heads/main@{#36310} --- call/version.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/call/version.cc b/call/version.cc index 934ff52522..ce21d71d14 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 2022-03-23T04:05:31"; +const char* const kSourceTimestamp = "WebRTC source stamp 2022-03-24T04:09:55"; void LoadWebRTCVersionInRegister() { // Using volatile to instruct the compiler to not optimize `p` away even From b6b34fc213fd2b13f527037e4220df14b680e214 Mon Sep 17 00:00:00 2001 From: Rasmus Brandt Date: Wed, 23 Mar 2022 19:56:56 +0100 Subject: [PATCH 285/847] Add weighted PSNR-YUV from Ohm2012 to PC test framework. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This metric weights the PSNRs of luma and chroma planes in a slightly smarter way than our current PSNR metric. > J. Ohm, G. J. Sullivan, H. Schwarz, T. K. Tan and T. Wiegand, > "Comparison of the Coding Efficiency of Video Coding Standards—Including > High Efficiency Video Coding (HEVC)," in IEEE Transactions on Circuits and > Systems for Video Technology, vol. 22, no. 12, pp. 1669-1684, Dec. 2012 > doi: 10.1109/TCSVT.2012.2221192. Bug: None Change-Id: Iec105e0b491628fc0ad4be9155b991203846ad1b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256463 Reviewed-by: Stefan Holmer Reviewed-by: Artem Titov Commit-Queue: Rasmus Brandt Cr-Commit-Position: refs/heads/main@{#36311} --- common_video/libyuv/include/webrtc_libyuv.h | 15 ++++++- common_video/libyuv/libyuv_unittest.cc | 23 +++++++++-- common_video/libyuv/webrtc_libyuv.cc | 39 +++++++++++++++++++ ...ideo_quality_analyzer_frames_comparator.cc | 20 +++++++--- ...lt_video_quality_analyzer_shared_objects.h | 8 +++- 5 files changed, 92 insertions(+), 13 deletions(-) diff --git a/common_video/libyuv/include/webrtc_libyuv.h b/common_video/libyuv/include/webrtc_libyuv.h index 905219b6a6..d7939dcb2f 100644 --- a/common_video/libyuv/include/webrtc_libyuv.h +++ b/common_video/libyuv/include/webrtc_libyuv.h @@ -87,11 +87,24 @@ double I420SSE(const I420BufferInterface& ref_buffer, const I420BufferInterface& test_buffer); // Compute PSNR for an I420 frame (all planes). -// Returns the PSNR in decibel, to a maximum of kInfinitePSNR. +// Returns the PSNR in decibel, to a maximum of kPerfectPSNR. double I420PSNR(const VideoFrame* ref_frame, const VideoFrame* test_frame); double I420PSNR(const I420BufferInterface& ref_buffer, const I420BufferInterface& test_buffer); +// Computes the weighted PSNR-YUV for an I420 buffer. +// +// For the definition and motivation, see +// J. Ohm, G. J. Sullivan, H. Schwarz, T. K. Tan and T. Wiegand, +// "Comparison of the Coding Efficiency of Video Coding Standards—Including +// High Efficiency Video Coding (HEVC)," in IEEE Transactions on Circuits and +// Systems for Video Technology, vol. 22, no. 12, pp. 1669-1684, Dec. 2012 +// doi: 10.1109/TCSVT.2012.2221192. +// +// Returns the PSNR-YUV in decibel, to a maximum of kPerfectPSNR. +double I420WeightedPSNR(const I420BufferInterface& ref_buffer, + const I420BufferInterface& test_buffer); + // Compute SSIM for an I420 frame (all planes). double I420SSIM(const VideoFrame* ref_frame, const VideoFrame* test_frame); double I420SSIM(const I420BufferInterface& ref_buffer, diff --git a/common_video/libyuv/libyuv_unittest.cc b/common_video/libyuv/libyuv_unittest.cc index 62d9e87fa6..f9c82f6284 100644 --- a/common_video/libyuv/libyuv_unittest.cc +++ b/common_video/libyuv/libyuv_unittest.cc @@ -114,10 +114,6 @@ void TestLibYuv::TearDown() { source_file_ = NULL; } -TEST_F(TestLibYuv, ConvertSanityTest) { - // TODO(mikhal) -} - TEST_F(TestLibYuv, ConvertTest) { // Reading YUV frame - testing on the first frame of the foreman sequence int j = 0; @@ -368,4 +364,23 @@ TEST_F(TestLibYuv, NV12Scale4x4to2x2) { ::testing::ElementsAre(Average(0, 2, 4, 6), Average(1, 3, 5, 7))); } +TEST(I420WeightedPSNRTest, SmokeTest) { + uint8_t ref_y[] = {0, 0, 0, 0}; + uint8_t ref_uv[] = {0}; + rtc::scoped_refptr ref_buffer = + I420Buffer::Copy(/*width=*/2, /*height=*/2, ref_y, /*stride_y=*/2, ref_uv, + /*stride_u=*/1, ref_uv, /*stride_v=*/1); + + uint8_t test_y[] = {1, 1, 1, 1}; + uint8_t test_uv[] = {2}; + rtc::scoped_refptr test_buffer = I420Buffer::Copy( + /*width=*/2, /*height=*/2, test_y, /*stride_y=*/2, test_uv, + /*stride_u=*/1, test_uv, /*stride_v=*/1); + + auto psnr = [](double mse) { return 10.0 * log10(255.0 * 255.0 / mse); }; + EXPECT_NEAR(I420WeightedPSNR(*ref_buffer, *test_buffer), + (6.0 * psnr(1.0) + psnr(4.0) + psnr(4.0)) / 8.0, + /*abs_error=*/0.001); +} + } // namespace webrtc diff --git a/common_video/libyuv/webrtc_libyuv.cc b/common_video/libyuv/webrtc_libyuv.cc index 2e10a60776..51a766c1be 100644 --- a/common_video/libyuv/webrtc_libyuv.cc +++ b/common_video/libyuv/webrtc_libyuv.cc @@ -255,6 +255,45 @@ double I420PSNR(const VideoFrame* ref_frame, const VideoFrame* test_frame) { *test_frame->video_frame_buffer()->ToI420()); } +double I420WeightedPSNR(const I420BufferInterface& ref_buffer, + const I420BufferInterface& test_buffer) { + RTC_DCHECK_GE(ref_buffer.width(), test_buffer.width()); + RTC_DCHECK_GE(ref_buffer.height(), test_buffer.height()); + if ((ref_buffer.width() != test_buffer.width()) || + (ref_buffer.height() != test_buffer.height())) { + rtc::scoped_refptr scaled_ref_buffer = + I420Buffer::Create(test_buffer.width(), test_buffer.height()); + scaled_ref_buffer->ScaleFrom(ref_buffer); + return I420WeightedPSNR(*scaled_ref_buffer, test_buffer); + } + + // Luma. + int width_y = test_buffer.width(); + int height_y = test_buffer.height(); + uint64_t sse_y = libyuv::ComputeSumSquareErrorPlane( + ref_buffer.DataY(), ref_buffer.StrideY(), test_buffer.DataY(), + test_buffer.StrideY(), width_y, height_y); + uint64_t num_samples_y = (uint64_t)width_y * (uint64_t)height_y; + double psnr_y = libyuv::SumSquareErrorToPsnr(sse_y, num_samples_y); + + // Chroma. + int width_uv = (width_y + 1) >> 1; + int height_uv = (height_y + 1) >> 1; + uint64_t sse_u = libyuv::ComputeSumSquareErrorPlane( + ref_buffer.DataU(), ref_buffer.StrideU(), test_buffer.DataU(), + test_buffer.StrideU(), width_uv, height_uv); + uint64_t num_samples_uv = (uint64_t)width_uv * (uint64_t)height_uv; + double psnr_u = libyuv::SumSquareErrorToPsnr(sse_u, num_samples_uv); + uint64_t sse_v = libyuv::ComputeSumSquareErrorPlane( + ref_buffer.DataV(), ref_buffer.StrideV(), test_buffer.DataV(), + test_buffer.StrideV(), width_uv, height_uv); + double psnr_v = libyuv::SumSquareErrorToPsnr(sse_v, num_samples_uv); + + // Weights from Ohm et. al 2012. + double psnr_yuv = (6.0 * psnr_y + psnr_u + psnr_v) / 8.0; + return (psnr_yuv > kPerfectPSNR) ? kPerfectPSNR : psnr_yuv; +} + // Compute SSIM for an I420A frame (all planes). Can upscale test frame. double I420ASSIM(const I420ABufferInterface& ref_buffer, const I420ABufferInterface& test_buffer) { diff --git a/test/pc/e2e/analyzer/video/default_video_quality_analyzer_frames_comparator.cc b/test/pc/e2e/analyzer/video/default_video_quality_analyzer_frames_comparator.cc index ef9d32fa1a..a132cd4f3d 100644 --- a/test/pc/e2e/analyzer/video/default_video_quality_analyzer_frames_comparator.cc +++ b/test/pc/e2e/analyzer/video/default_video_quality_analyzer_frames_comparator.cc @@ -363,20 +363,28 @@ void DefaultVideoQualityAnalyzerFramesComparator::ProcessComparison( // Perform expensive psnr and ssim calculations while not holding lock. double psnr = -1.0; double ssim = -1.0; - if (options_.heavy_metrics_computation_enabled && + // TODO(brandtr): Remove `heavy_metrics_computation_enabled` when downstream + // has been updated. + if ((options_.heavy_metrics_computation_enabled || options_.compute_psnr || + options_.compute_ssim) && comparison.captured.has_value() && comparison.rendered.has_value()) { rtc::scoped_refptr reference_buffer = comparison.captured->video_frame_buffer()->ToI420(); rtc::scoped_refptr test_buffer = comparison.rendered->video_frame_buffer()->ToI420(); if (options_.adjust_cropping_before_comparing_frames) { - test_buffer = - ScaleVideoFrameBuffer(*test_buffer.get(), reference_buffer->width(), - reference_buffer->height()); + test_buffer = ScaleVideoFrameBuffer( + *test_buffer, reference_buffer->width(), reference_buffer->height()); reference_buffer = test::AdjustCropping(reference_buffer, test_buffer); } - psnr = I420PSNR(*reference_buffer.get(), *test_buffer.get()); - ssim = I420SSIM(*reference_buffer.get(), *test_buffer.get()); + if (options_.compute_psnr) { + psnr = options_.use_weighted_psnr + ? I420WeightedPSNR(*reference_buffer, *test_buffer) + : I420PSNR(*reference_buffer, *test_buffer); + } + if (options_.compute_ssim) { + ssim = I420SSIM(*reference_buffer, *test_buffer); + } } const FrameStats& frame_stats = comparison.frame_stats; diff --git a/test/pc/e2e/analyzer/video/default_video_quality_analyzer_shared_objects.h b/test/pc/e2e/analyzer/video/default_video_quality_analyzer_shared_objects.h index 8f75328443..7d9fd50cdc 100644 --- a/test/pc/e2e/analyzer/video/default_video_quality_analyzer_shared_objects.h +++ b/test/pc/e2e/analyzer/video/default_video_quality_analyzer_shared_objects.h @@ -209,8 +209,12 @@ class VideoStreamsInfo { }; struct DefaultVideoQualityAnalyzerOptions { - // Tells DefaultVideoQualityAnalyzer if heavy metrics like PSNR and SSIM have - // to be computed or not. + // Tells DefaultVideoQualityAnalyzer if heavy metrics have to be computed. + bool compute_psnr = true; + bool compute_ssim = true; + // If true, weights the luma plane more than the chroma planes in the PSNR. + bool use_weighted_psnr = false; + // DEPRECATED. bool heavy_metrics_computation_enabled = true; // If true DefaultVideoQualityAnalyzer will try to adjust frames before // computing PSNR and SSIM for them. In some cases picture may be shifted by From ccc9d979a5291e62096ac645c4ce9873afc40496 Mon Sep 17 00:00:00 2001 From: Tommi Date: Thu, 24 Mar 2022 08:12:36 +0100 Subject: [PATCH 286/847] Add checks for a null msg_queue_ to VirtualSocketServer. The Thread class internally (`Thread::DoDestroy`) makes this call: ss_->SetMessageQueue(nullptr); Which sets the `msg_queue_` member variable of VirtualSocketServer to nullptr. VSS checks for this in several places, but not all. In particular `CancelConnects()` does handle it, but Disconnect(), which is called from the same place (VirtualSocket::Close()), is missing this check. This CL adds some DCHECKs to catch when a pointer might be nullptr and also avoids dereferencing a potential nullptr deref during teardown if `Disconnect` is called, e.g. from within `VirtualSocket::Close()` which is called from the dtor of `VirtualSocket`. Bug: webrtc:13864 Change-Id: I717a0f033ebf70b1f59338680957723a77ccf4ca Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256600 Reviewed-by: Niels Moller Commit-Queue: Tomas Gunnarsson Cr-Commit-Position: refs/heads/main@{#36312} --- rtc_base/virtual_socket_server.cc | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/rtc_base/virtual_socket_server.cc b/rtc_base/virtual_socket_server.cc index 5d36e3e1de..edf9515711 100644 --- a/rtc_base/virtual_socket_server.cc +++ b/rtc_base/virtual_socket_server.cc @@ -612,7 +612,7 @@ void VirtualSocketServer::SetMessageQueue(Thread* msg_queue) { } bool VirtualSocketServer::Wait(int cmsWait, bool process_io) { - RTC_DCHECK(msg_queue_ == Thread::Current()); + RTC_DCHECK_RUN_ON(msg_queue_); if (stop_on_idle_ && Thread::Current()->empty()) { return false; } @@ -635,7 +635,7 @@ void VirtualSocketServer::SetAlternativeLocalAddress( } bool VirtualSocketServer::ProcessMessagesUntilIdle() { - RTC_DCHECK(msg_queue_ == Thread::Current()); + RTC_DCHECK_RUN_ON(msg_queue_); stop_on_idle_ = true; while (!msg_queue_->empty()) { if (fake_clock_) { @@ -785,6 +785,8 @@ static double Random() { int VirtualSocketServer::Connect(VirtualSocket* socket, const SocketAddress& remote_addr, bool use_delay) { + RTC_DCHECK(msg_queue_); + uint32_t delay = use_delay ? GetTransitDelay(socket) : 0; VirtualSocket* remote = LookupBinding(remote_addr); if (!CanInteractWith(socket, remote)) { @@ -805,15 +807,15 @@ int VirtualSocketServer::Connect(VirtualSocket* socket, } bool VirtualSocketServer::Disconnect(VirtualSocket* socket) { - if (socket) { - // If we simulate packets being delayed, we should simulate the - // equivalent of a FIN being delayed as well. - uint32_t delay = GetTransitDelay(socket); - // Remove the mapping. - msg_queue_->PostDelayed(RTC_FROM_HERE, delay, socket, MSG_ID_DISCONNECT); - return true; - } - return false; + if (!socket || !msg_queue_) + return false; + + // If we simulate packets being delayed, we should simulate the + // equivalent of a FIN being delayed as well. + uint32_t delay = GetTransitDelay(socket); + // Remove the mapping. + msg_queue_->PostDelayed(RTC_FROM_HERE, delay, socket, MSG_ID_DISCONNECT); + return true; } bool VirtualSocketServer::Disconnect(const SocketAddress& addr) { @@ -871,6 +873,9 @@ void VirtualSocketServer::Clear(VirtualSocket* socket) { } void VirtualSocketServer::PostSignalReadEvent(VirtualSocket* socket) { + if (!msg_queue_) + return; + // Clear the message so it doesn't end up posted multiple times. msg_queue_->Clear(socket, MSG_ID_SIGNALREADEVENT); msg_queue_->Post(RTC_FROM_HERE, socket, MSG_ID_SIGNALREADEVENT); @@ -1011,6 +1016,7 @@ void VirtualSocketServer::AddPacketToNetwork(VirtualSocket* sender, size_t data_size, size_t header_size, bool ordered) { + RTC_DCHECK(msg_queue_); uint32_t send_delay = sender->AddPacket(cur_time, data_size + header_size); // Find the delay for crossing the many virtual hops of the network. From 195b0a9849895b82f4bf92cdc9b5c505b5c29423 Mon Sep 17 00:00:00 2001 From: Evan Shrubsole Date: Mon, 21 Mar 2022 17:16:39 +0100 Subject: [PATCH 287/847] Modernize TimestampExtrapolator to use correct units * Add unit tests * Use TimestampUnwrapper * Follow style guide Change-Id: I057b05faba0aeafb2830a45007474be0eca1c6e0 Bug: webrtc:13756 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256261 Reviewed-by: Stefan Holmer Commit-Queue: Evan Shrubsole Cr-Commit-Position: refs/heads/main@{#36313} --- BUILD.gn | 1 + rtc_base/time/BUILD.gn | 22 +- rtc_base/time/timestamp_extrapolator.cc | 206 +++++++---------- rtc_base/time/timestamp_extrapolator.h | 33 ++- .../time/timestamp_extrapolator_unittest.cc | 208 ++++++++++++++++++ 5 files changed, 328 insertions(+), 142 deletions(-) create mode 100644 rtc_base/time/timestamp_extrapolator_unittest.cc diff --git a/BUILD.gn b/BUILD.gn index aaa1260088..52736b325a 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -574,6 +574,7 @@ if (rtc_include_tests && !build_with_chromium) { "rtc_base/task_utils:pending_task_safety_flag_unittests", "rtc_base/task_utils:repeating_task_unittests", "rtc_base/task_utils:to_queued_task_unittests", + "rtc_base/time:timestamp_extrapolator_unittests", "rtc_base/units:units_unittests", "sdk:sdk_tests", "test:rtp_test_utils", diff --git a/rtc_base/time/BUILD.gn b/rtc_base/time/BUILD.gn index 890695dfeb..092abd9a83 100644 --- a/rtc_base/time/BUILD.gn +++ b/rtc_base/time/BUILD.gn @@ -17,6 +17,26 @@ rtc_library("timestamp_extrapolator") { "timestamp_extrapolator.cc", "timestamp_extrapolator.h", ] - deps = [ "../../api/units:timestamp" ] + deps = [ + "../../api/units:frequency", + "../../api/units:timestamp", + "../../modules:module_api_public", + ] absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } + +if (rtc_include_tests) { + rtc_library("timestamp_extrapolator_unittests") { + testonly = true + sources = [ "timestamp_extrapolator_unittest.cc" ] + deps = [ + ":timestamp_extrapolator", + "../../api/units:frequency", + "../../api/units:time_delta", + "../../api/units:timestamp", + "../../system_wrappers", + "../../test:test_support", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] + } +} diff --git a/rtc_base/time/timestamp_extrapolator.cc b/rtc_base/time/timestamp_extrapolator.cc index 521b5ba4c4..910db8a390 100644 --- a/rtc_base/time/timestamp_extrapolator.cc +++ b/rtc_base/time/timestamp_extrapolator.cc @@ -13,87 +13,83 @@ #include #include "absl/types/optional.h" +#include "api/units/frequency.h" +#include "modules/include/module_common_types_public.h" namespace webrtc { +namespace { + +constexpr double kLambda = 1; +constexpr uint32_t kStartUpFilterDelayInPackets = 2; +constexpr double kAlarmThreshold = 60e3; +// in timestamp ticks, i.e. 15 ms +constexpr double kAccDrift = 6600; +constexpr double kAccMaxError = 7000; +constexpr double kP11 = 1e10; + +} // namespace + TimestampExtrapolator::TimestampExtrapolator(Timestamp start) - : _start(Timestamp::Zero()), - _prev(Timestamp::Zero()), - _firstTimestamp(0), - _wrapArounds(0), - _prevUnwrappedTimestamp(-1), - _prevWrapTimestamp(-1), - _lambda(1), - _firstAfterReset(true), - _packetCount(0), - _startUpFilterDelayInPackets(2), - _detectorAccumulatorPos(0), - _detectorAccumulatorNeg(0), - _alarmThreshold(60e3), - _accDrift(6600), // in timestamp ticks, i.e. 15 ms - _accMaxError(7000), - _pP11(1e10) { + : start_(Timestamp::Zero()), + prev_(Timestamp::Zero()), + packet_count_(0), + detector_accumulator_pos_(0), + detector_accumulator_neg_(0) { Reset(start); } void TimestampExtrapolator::Reset(Timestamp start) { - _start = start; - _prev = _start; - _firstTimestamp = 0; - _w[0] = 90.0; - _w[1] = 0; - _pP[0][0] = 1; - _pP[1][1] = _pP11; - _pP[0][1] = _pP[1][0] = 0; - _firstAfterReset = true; - _prevUnwrappedTimestamp = -1; - _prevWrapTimestamp = -1; - _wrapArounds = 0; - _packetCount = 0; - _detectorAccumulatorPos = 0; - _detectorAccumulatorNeg = 0; + start_ = start; + prev_ = start_; + first_unwrapped_timestamp_ = absl::nullopt; + w_[0] = 90.0; + w_[1] = 0; + p_[0][0] = 1; + p_[1][1] = kP11; + p_[0][1] = p_[1][0] = 0; + unwrapper_ = TimestampUnwrapper(); + packet_count_ = 0; + detector_accumulator_pos_ = 0; + detector_accumulator_neg_ = 0; } void TimestampExtrapolator::Update(Timestamp now, uint32_t ts90khz) { - if (now - _prev > TimeDelta::Seconds(10)) { + if (now - prev_ > TimeDelta::Seconds(10)) { // Ten seconds without a complete frame. // Reset the extrapolator Reset(now); } else { - _prev = now; + prev_ = now; } // Remove offset to prevent badly scaled matrices - const TimeDelta offset = now - _start; - double tMs = offset.ms(); + const TimeDelta offset = now - start_; + double t_ms = offset.ms(); - CheckForWrapArounds(ts90khz); + int64_t unwrapped_ts90khz = unwrapper_.Unwrap(ts90khz); - int64_t unwrapped_ts90khz = - static_cast(ts90khz) + - _wrapArounds * ((static_cast(1) << 32) - 1); - - if (_firstAfterReset) { + if (!first_unwrapped_timestamp_) { // Make an initial guess of the offset, - // should be almost correct since tMs - _startMs + // should be almost correct since t_ms - start // should about zero at this time. - _w[1] = -_w[0] * tMs; - _firstTimestamp = unwrapped_ts90khz; - _firstAfterReset = false; + w_[1] = -w_[0] * t_ms; + first_unwrapped_timestamp_ = unwrapped_ts90khz; } - double residual = (static_cast(unwrapped_ts90khz) - _firstTimestamp) - - tMs * _w[0] - _w[1]; + double residual = + (static_cast(unwrapped_ts90khz) - *first_unwrapped_timestamp_) - + t_ms * w_[0] - w_[1]; if (DelayChangeDetection(residual) && - _packetCount >= _startUpFilterDelayInPackets) { + packet_count_ >= kStartUpFilterDelayInPackets) { // A sudden change of average network delay has been detected. // Force the filter to adjust its offset parameter by changing // the offset uncertainty. Don't do this during startup. - _pP[1][1] = _pP11; + p_[1][1] = kP11; } - if (_prevUnwrappedTimestamp >= 0 && - unwrapped_ts90khz < _prevUnwrappedTimestamp) { + if (prev_unwrapped_timestamp_ && + unwrapped_ts90khz < prev_unwrapped_timestamp_) { // Drop reordered frames. return; } @@ -102,94 +98,62 @@ void TimestampExtrapolator::Update(Timestamp now, uint32_t ts90khz) { // that = T'*w; // K = P*T/(lambda + T'*P*T); double K[2]; - K[0] = _pP[0][0] * tMs + _pP[0][1]; - K[1] = _pP[1][0] * tMs + _pP[1][1]; - double TPT = _lambda + tMs * K[0] + K[1]; + K[0] = p_[0][0] * t_ms + p_[0][1]; + K[1] = p_[1][0] * t_ms + p_[1][1]; + double TPT = kLambda + t_ms * K[0] + K[1]; K[0] /= TPT; K[1] /= TPT; // w = w + K*(ts(k) - that); - _w[0] = _w[0] + K[0] * residual; - _w[1] = _w[1] + K[1] * residual; + w_[0] = w_[0] + K[0] * residual; + w_[1] = w_[1] + K[1] * residual; // P = 1/lambda*(P - K*T'*P); double p00 = - 1 / _lambda * (_pP[0][0] - (K[0] * tMs * _pP[0][0] + K[0] * _pP[1][0])); + 1 / kLambda * (p_[0][0] - (K[0] * t_ms * p_[0][0] + K[0] * p_[1][0])); double p01 = - 1 / _lambda * (_pP[0][1] - (K[0] * tMs * _pP[0][1] + K[0] * _pP[1][1])); - _pP[1][0] = - 1 / _lambda * (_pP[1][0] - (K[1] * tMs * _pP[0][0] + K[1] * _pP[1][0])); - _pP[1][1] = - 1 / _lambda * (_pP[1][1] - (K[1] * tMs * _pP[0][1] + K[1] * _pP[1][1])); - _pP[0][0] = p00; - _pP[0][1] = p01; - _prevUnwrappedTimestamp = unwrapped_ts90khz; - if (_packetCount < _startUpFilterDelayInPackets) { - _packetCount++; + 1 / kLambda * (p_[0][1] - (K[0] * t_ms * p_[0][1] + K[0] * p_[1][1])); + p_[1][0] = + 1 / kLambda * (p_[1][0] - (K[1] * t_ms * p_[0][0] + K[1] * p_[1][0])); + p_[1][1] = + 1 / kLambda * (p_[1][1] - (K[1] * t_ms * p_[0][1] + K[1] * p_[1][1])); + p_[0][0] = p00; + p_[0][1] = p01; + prev_unwrapped_timestamp_ = unwrapped_ts90khz; + if (packet_count_ < kStartUpFilterDelayInPackets) { + packet_count_++; } } absl::optional TimestampExtrapolator::ExtrapolateLocalTime( - uint32_t timestamp90khz) { - CheckForWrapArounds(timestamp90khz); - double unwrapped_ts90khz = - static_cast(timestamp90khz) + - _wrapArounds * ((static_cast(1) << 32) - 1); - if (_packetCount == 0) { - return absl::nullopt; - } else if (_packetCount < _startUpFilterDelayInPackets) { - auto diffMs = static_cast( - static_cast(unwrapped_ts90khz - _prevUnwrappedTimestamp) / - 90.0 + - 0.5); - return _prev + TimeDelta::Millis(diffMs); - } else if (_w[0] < 1e-3) { - return _start; - } else { - double timestampDiff = - unwrapped_ts90khz - static_cast(_firstTimestamp); - auto diffMs = static_cast((timestampDiff - _w[1]) / _w[0] + 0.5); - return _start + TimeDelta::Millis(diffMs); - } -} + uint32_t timestamp90khz) const { + int64_t unwrapped_ts90khz = unwrapper_.UnwrapWithoutUpdate(timestamp90khz); -// Investigates if the timestamp clock has overflowed since the last timestamp -// and keeps track of the number of wrap arounds since reset. -void TimestampExtrapolator::CheckForWrapArounds(uint32_t ts90khz) { - if (_prevWrapTimestamp == -1) { - _prevWrapTimestamp = ts90khz; - return; - } - if (ts90khz < _prevWrapTimestamp) { - // This difference will probably be less than -2^31 if we have had a wrap - // around (e.g. timestamp = 1, _previousTimestamp = 2^32 - 1). Since it is - // casted to a Word32, it should be positive. - if (static_cast(ts90khz - _prevWrapTimestamp) > 0) { - // Forward wrap around - _wrapArounds++; - } + if (!first_unwrapped_timestamp_) { + return absl::nullopt; + } else if (packet_count_ < kStartUpFilterDelayInPackets) { + constexpr Frequency k90KHz = Frequency::KiloHertz(90); + TimeDelta diff = (unwrapped_ts90khz - *prev_unwrapped_timestamp_) / k90KHz; + return prev_ + diff; + } else if (w_[0] < 1e-3) { + return start_; } else { - // This difference will probably be less than -2^31 if we have had a - // backward wrap around. Since it is casted to a Word32, it should be - // positive. - if (static_cast(_prevWrapTimestamp - ts90khz) > 0) { - // Backward wrap around - _wrapArounds--; - } + double timestampDiff = unwrapped_ts90khz - *first_unwrapped_timestamp_; + auto diff_ms = static_cast((timestampDiff - w_[1]) / w_[0] + 0.5); + return start_ + TimeDelta::Millis(diff_ms); } - _prevWrapTimestamp = ts90khz; } bool TimestampExtrapolator::DelayChangeDetection(double error) { // CUSUM detection of sudden delay changes - error = (error > 0) ? std::min(error, _accMaxError) - : std::max(error, -_accMaxError); - _detectorAccumulatorPos = - std::max(_detectorAccumulatorPos + error - _accDrift, double{0}); - _detectorAccumulatorNeg = - std::min(_detectorAccumulatorNeg + error + _accDrift, double{0}); - if (_detectorAccumulatorPos > _alarmThreshold || - _detectorAccumulatorNeg < -_alarmThreshold) { + error = (error > 0) ? std::min(error, kAccMaxError) + : std::max(error, -kAccMaxError); + detector_accumulator_pos_ = + std::max(detector_accumulator_pos_ + error - kAccDrift, double{0}); + detector_accumulator_neg_ = + std::min(detector_accumulator_neg_ + error + kAccDrift, double{0}); + if (detector_accumulator_pos_ > kAlarmThreshold || + detector_accumulator_neg_ < -kAlarmThreshold) { // Alarm - _detectorAccumulatorPos = _detectorAccumulatorNeg = 0; + detector_accumulator_pos_ = detector_accumulator_neg_ = 0; return true; } return false; diff --git a/rtc_base/time/timestamp_extrapolator.h b/rtc_base/time/timestamp_extrapolator.h index df56eea986..23e7975453 100644 --- a/rtc_base/time/timestamp_extrapolator.h +++ b/rtc_base/time/timestamp_extrapolator.h @@ -15,6 +15,7 @@ #include "absl/types/optional.h" #include "api/units/timestamp.h" +#include "modules/include/module_common_types_public.h" namespace webrtc { @@ -23,31 +24,23 @@ class TimestampExtrapolator { public: explicit TimestampExtrapolator(Timestamp start); void Update(Timestamp now, uint32_t ts90khz); - absl::optional ExtrapolateLocalTime(uint32_t timestamp90khz); + absl::optional ExtrapolateLocalTime(uint32_t timestamp90khz) const; void Reset(Timestamp start); private: void CheckForWrapArounds(uint32_t ts90khz); bool DelayChangeDetection(double error); - double _w[2]; - double _pP[2][2]; - Timestamp _start; - Timestamp _prev; - uint32_t _firstTimestamp; - int32_t _wrapArounds; - int64_t _prevUnwrappedTimestamp; - int64_t _prevWrapTimestamp; - const double _lambda; - bool _firstAfterReset; - uint32_t _packetCount; - const uint32_t _startUpFilterDelayInPackets; - - double _detectorAccumulatorPos; - double _detectorAccumulatorNeg; - const double _alarmThreshold; - const double _accDrift; - const double _accMaxError; - const double _pP11; + + double w_[2]; + double p_[2][2]; + Timestamp start_; + Timestamp prev_; + absl::optional first_unwrapped_timestamp_; + TimestampUnwrapper unwrapper_; + absl::optional prev_unwrapped_timestamp_; + uint32_t packet_count_; + double detector_accumulator_pos_; + double detector_accumulator_neg_; }; } // namespace webrtc diff --git a/rtc_base/time/timestamp_extrapolator_unittest.cc b/rtc_base/time/timestamp_extrapolator_unittest.cc new file mode 100644 index 0000000000..b153d7ae15 --- /dev/null +++ b/rtc_base/time/timestamp_extrapolator_unittest.cc @@ -0,0 +1,208 @@ +/* + * Copyright (c) 2022 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "rtc_base/time/timestamp_extrapolator.h" + +#include + +#include + +#include "absl/types/optional.h" +#include "api/units/frequency.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" +#include "system_wrappers/include/clock.h" +#include "test/gmock.h" +#include "test/gtest.h" + +namespace webrtc { + +using ::testing::Eq; +using ::testing::Optional; + +namespace { + +constexpr Frequency kRtpHz = Frequency::KiloHertz(90); +constexpr Frequency k25Fps = Frequency::Hertz(25); +constexpr TimeDelta k25FpsDelay = 1 / k25Fps; + +} // namespace + +TEST(TimestampExtrapolatorTest, ExtrapolationOccursAfter2Packets) { + SimulatedClock clock(Timestamp::Millis(1337)); + TimestampExtrapolator ts_extrapolator(clock.CurrentTime()); + + // No packets so no timestamp. + EXPECT_THAT(ts_extrapolator.ExtrapolateLocalTime(90000), Eq(absl::nullopt)); + + uint32_t rtp = 90000; + clock.AdvanceTime(k25FpsDelay); + // First result is a bit confusing since it is based off the "start" time, + // which is arbitrary. + ts_extrapolator.Update(clock.CurrentTime(), rtp); + EXPECT_THAT(ts_extrapolator.ExtrapolateLocalTime(rtp), + Optional(clock.CurrentTime())); + + rtp += kRtpHz / k25Fps; + clock.AdvanceTime(k25FpsDelay); + ts_extrapolator.Update(clock.CurrentTime(), rtp); + EXPECT_THAT(ts_extrapolator.ExtrapolateLocalTime(rtp), + Optional(clock.CurrentTime())); + EXPECT_THAT(ts_extrapolator.ExtrapolateLocalTime(rtp + 90000), + Optional(clock.CurrentTime() + TimeDelta::Seconds(1))); +} + +TEST(TimestampExtrapolatorTest, ResetsAfter10SecondPause) { + SimulatedClock clock(Timestamp::Millis(1337)); + TimestampExtrapolator ts_extrapolator(clock.CurrentTime()); + + uint32_t rtp = 90000; + ts_extrapolator.Update(clock.CurrentTime(), rtp); + EXPECT_THAT(ts_extrapolator.ExtrapolateLocalTime(rtp), + Optional(clock.CurrentTime())); + + rtp += kRtpHz / k25Fps; + clock.AdvanceTime(k25FpsDelay); + ts_extrapolator.Update(clock.CurrentTime(), rtp); + EXPECT_THAT(ts_extrapolator.ExtrapolateLocalTime(rtp), + Optional(clock.CurrentTime())); + + rtp += 10 * kRtpHz.hertz(); + clock.AdvanceTime(TimeDelta::Seconds(10) + TimeDelta::Micros(1)); + ts_extrapolator.Update(clock.CurrentTime(), rtp); + EXPECT_THAT(ts_extrapolator.ExtrapolateLocalTime(rtp), + Optional(clock.CurrentTime())); +} + +TEST(TimestampExtrapolatorTest, TimestampExtrapolatesMultipleRtpWrapArounds) { + SimulatedClock clock(Timestamp::Millis(1337)); + TimestampExtrapolator ts_extrapolator(clock.CurrentTime()); + + uint32_t rtp = std::numeric_limits::max(); + ts_extrapolator.Update(clock.CurrentTime(), rtp); + EXPECT_THAT(ts_extrapolator.ExtrapolateLocalTime(rtp), + Optional(clock.CurrentTime())); + + // One overflow. Static cast to avoid undefined behaviour with +=. + rtp += static_cast(kRtpHz / k25Fps); + clock.AdvanceTime(k25FpsDelay); + ts_extrapolator.Update(clock.CurrentTime(), rtp); + EXPECT_THAT(ts_extrapolator.ExtrapolateLocalTime(rtp), + Optional(clock.CurrentTime())); + + // Assert that extrapolation works across the boundary as expected. + EXPECT_THAT(ts_extrapolator.ExtrapolateLocalTime(rtp + 90000), + Optional(clock.CurrentTime() + TimeDelta::Seconds(1))); + // This is not quite 1s since the math always rounds up. + EXPECT_THAT(ts_extrapolator.ExtrapolateLocalTime(rtp - 90000), + Optional(clock.CurrentTime() - TimeDelta::Millis(999))); + + // In order to avoid a wrap arounds reset, add a packet every 10s until we + // overflow twice. + constexpr TimeDelta kRtpOverflowDelay = + std::numeric_limits::max() / kRtpHz; + const Timestamp overflow_time = clock.CurrentTime() + kRtpOverflowDelay * 2; + + while (clock.CurrentTime() < overflow_time) { + clock.AdvanceTime(TimeDelta::Seconds(10)); + // Static-cast before += to avoid undefined behaviour of overflow. + rtp += static_cast(kRtpHz * TimeDelta::Seconds(10)); + ts_extrapolator.Update(clock.CurrentTime(), rtp); + EXPECT_THAT(ts_extrapolator.ExtrapolateLocalTime(rtp), + Optional(clock.CurrentTime())); + } +} + +TEST(TimestampExtrapolatorTest, Slow90KHzClock) { + // This simulates a slow camera, which produces frames at 24Hz instead of + // 25Hz. The extrapolator should be able to resolve this with enough data. + SimulatedClock clock(Timestamp::Millis(1337)); + TimestampExtrapolator ts_extrapolator(clock.CurrentTime()); + + constexpr TimeDelta k24FpsDelay = 1 / Frequency::Hertz(24); + uint32_t rtp = 90000; + ts_extrapolator.Update(clock.CurrentTime(), rtp); + + // Slow camera will increment RTP at 25 FPS rate even though its producing at + // 24 FPS. After 25 frames the extrapolator should settle at this rate. + for (int i = 0; i < 25; ++i) { + rtp += kRtpHz / k25Fps; + clock.AdvanceTime(k24FpsDelay); + ts_extrapolator.Update(clock.CurrentTime(), rtp); + } + + // The camera would normally produce 25 frames in 90K ticks, but is slow + // so takes 1s + k24FpsDelay for 90K ticks. + constexpr Frequency kSlowRtpHz = 90000 / (25 * k24FpsDelay); + // The extrapolator will be predicting that time at millisecond precision. + auto ts = ts_extrapolator.ExtrapolateLocalTime(rtp + kSlowRtpHz.hertz()); + ASSERT_TRUE(ts.has_value()); + EXPECT_EQ(ts->ms(), clock.TimeInMilliseconds() + 1000); +} + +TEST(TimestampExtrapolatorTest, Fast90KHzClock) { + // This simulates a fast camera, which produces frames at 26Hz instead of + // 25Hz. The extrapolator should be able to resolve this with enough data. + SimulatedClock clock(Timestamp::Millis(1337)); + TimestampExtrapolator ts_extrapolator(clock.CurrentTime()); + + constexpr TimeDelta k26FpsDelay = 1 / Frequency::Hertz(26); + uint32_t rtp = 90000; + ts_extrapolator.Update(clock.CurrentTime(), rtp); + + // Fast camera will increment RTP at 25 FPS rate even though its producing at + // 26 FPS. After 25 frames the extrapolator should settle at this rate. + for (int i = 0; i < 25; ++i) { + rtp += kRtpHz / k25Fps; + clock.AdvanceTime(k26FpsDelay); + ts_extrapolator.Update(clock.CurrentTime(), rtp); + } + + // The camera would normally produce 25 frames in 90K ticks, but is slow + // so takes 1s + k24FpsDelay for 90K ticks. + constexpr Frequency kSlowRtpHz = 90000 / (25 * k26FpsDelay); + // The extrapolator will be predicting that time at millisecond precision. + auto ts = ts_extrapolator.ExtrapolateLocalTime(rtp + kSlowRtpHz.hertz()); + ASSERT_TRUE(ts.has_value()); + EXPECT_EQ(ts->ms(), clock.TimeInMilliseconds() + 1000); +} + +TEST(TimestampExtrapolatorTest, TimestampJump) { + // This simulates a jump in RTP timestamp, which could occur if a camera was + // swapped for example. + SimulatedClock clock(Timestamp::Millis(1337)); + TimestampExtrapolator ts_extrapolator(clock.CurrentTime()); + + uint32_t rtp = 90000; + clock.AdvanceTime(k25FpsDelay); + ts_extrapolator.Update(clock.CurrentTime(), rtp); + rtp += kRtpHz / k25Fps; + clock.AdvanceTime(k25FpsDelay); + ts_extrapolator.Update(clock.CurrentTime(), rtp); + rtp += kRtpHz / k25Fps; + clock.AdvanceTime(k25FpsDelay); + ts_extrapolator.Update(clock.CurrentTime(), rtp); + EXPECT_THAT(ts_extrapolator.ExtrapolateLocalTime(rtp), + Optional(clock.CurrentTime())); + EXPECT_THAT(ts_extrapolator.ExtrapolateLocalTime(rtp + 90000), + Optional(clock.CurrentTime() + TimeDelta::Seconds(1))); + + // Jump RTP. + uint32_t new_rtp = 1337 * 90000; + clock.AdvanceTime(k25FpsDelay); + ts_extrapolator.Update(clock.CurrentTime(), new_rtp); + new_rtp += kRtpHz / k25Fps; + clock.AdvanceTime(k25FpsDelay); + ts_extrapolator.Update(clock.CurrentTime(), new_rtp); + EXPECT_THAT(ts_extrapolator.ExtrapolateLocalTime(new_rtp), + Optional(clock.CurrentTime())); +} + +} // namespace webrtc From 6a15e3ba5c144ec7b265c5d87996121d60f0250e Mon Sep 17 00:00:00 2001 From: Rasmus Brandt Date: Thu, 24 Mar 2022 08:15:44 +0100 Subject: [PATCH 288/847] Remove deprecated `heavy_metrics_computation_enabled` Bug: None Change-Id: Ieaccca83559d0f17b394c2c9bbc8d52acbaebcdb Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256601 Reviewed-by: Artem Titov Commit-Queue: Rasmus Brandt Cr-Commit-Position: refs/heads/main@{#36314} --- .../default_video_quality_analyzer_frames_comparator.cc | 5 +---- ...ault_video_quality_analyzer_frames_comparator_test.cc | 3 ++- .../default_video_quality_analyzer_shared_objects.h | 2 -- .../video/default_video_quality_analyzer_test.cc | 9 ++++++--- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/test/pc/e2e/analyzer/video/default_video_quality_analyzer_frames_comparator.cc b/test/pc/e2e/analyzer/video/default_video_quality_analyzer_frames_comparator.cc index a132cd4f3d..904671001a 100644 --- a/test/pc/e2e/analyzer/video/default_video_quality_analyzer_frames_comparator.cc +++ b/test/pc/e2e/analyzer/video/default_video_quality_analyzer_frames_comparator.cc @@ -363,10 +363,7 @@ void DefaultVideoQualityAnalyzerFramesComparator::ProcessComparison( // Perform expensive psnr and ssim calculations while not holding lock. double psnr = -1.0; double ssim = -1.0; - // TODO(brandtr): Remove `heavy_metrics_computation_enabled` when downstream - // has been updated. - if ((options_.heavy_metrics_computation_enabled || options_.compute_psnr || - options_.compute_ssim) && + if ((options_.compute_psnr || options_.compute_ssim) && comparison.captured.has_value() && comparison.rendered.has_value()) { rtc::scoped_refptr reference_buffer = comparison.captured->video_frame_buffer()->ToI420(); diff --git a/test/pc/e2e/analyzer/video/default_video_quality_analyzer_frames_comparator_test.cc b/test/pc/e2e/analyzer/video/default_video_quality_analyzer_frames_comparator_test.cc index adbd97a876..56ac7894bc 100644 --- a/test/pc/e2e/analyzer/video/default_video_quality_analyzer_frames_comparator_test.cc +++ b/test/pc/e2e/analyzer/video/default_video_quality_analyzer_frames_comparator_test.cc @@ -31,7 +31,8 @@ constexpr int kMaxFramesInFlightPerStream = 10; DefaultVideoQualityAnalyzerOptions AnalyzerOptionsForTest() { DefaultVideoQualityAnalyzerOptions options; - options.heavy_metrics_computation_enabled = false; + options.compute_psnr = false; + options.compute_ssim = false; options.adjust_cropping_before_comparing_frames = false; options.max_frames_in_flight_per_stream_count = kMaxFramesInFlightPerStream; return options; diff --git a/test/pc/e2e/analyzer/video/default_video_quality_analyzer_shared_objects.h b/test/pc/e2e/analyzer/video/default_video_quality_analyzer_shared_objects.h index 7d9fd50cdc..3b52a80d35 100644 --- a/test/pc/e2e/analyzer/video/default_video_quality_analyzer_shared_objects.h +++ b/test/pc/e2e/analyzer/video/default_video_quality_analyzer_shared_objects.h @@ -214,8 +214,6 @@ struct DefaultVideoQualityAnalyzerOptions { bool compute_ssim = true; // If true, weights the luma plane more than the chroma planes in the PSNR. bool use_weighted_psnr = false; - // DEPRECATED. - bool heavy_metrics_computation_enabled = true; // If true DefaultVideoQualityAnalyzer will try to adjust frames before // computing PSNR and SSIM for them. In some cases picture may be shifted by // a few pixels after the encode/decode step. Those difference is invisible diff --git a/test/pc/e2e/analyzer/video/default_video_quality_analyzer_test.cc b/test/pc/e2e/analyzer/video/default_video_quality_analyzer_test.cc index ec2bf587ba..1d4d24a210 100644 --- a/test/pc/e2e/analyzer/video/default_video_quality_analyzer_test.cc +++ b/test/pc/e2e/analyzer/video/default_video_quality_analyzer_test.cc @@ -44,7 +44,8 @@ constexpr char kReceiverPeerName[] = "bob"; DefaultVideoQualityAnalyzerOptions AnalyzerOptionsForTest() { DefaultVideoQualityAnalyzerOptions options; - options.heavy_metrics_computation_enabled = false; + options.compute_psnr = false; + options.compute_ssim = false; options.adjust_cropping_before_comparing_frames = false; options.max_frames_in_flight_per_stream_count = kMaxFramesInFlightPerStream; return options; @@ -596,7 +597,8 @@ TEST(DefaultVideoQualityAnalyzerTest, HeavyQualityMetricsFromEqualFrames) { /*num_squares=*/absl::nullopt); DefaultVideoQualityAnalyzerOptions analyzer_options; - analyzer_options.heavy_metrics_computation_enabled = true; + analyzer_options.compute_psnr = true; + analyzer_options.compute_ssim = true; analyzer_options.adjust_cropping_before_comparing_frames = false; analyzer_options.max_frames_in_flight_per_stream_count = kMaxFramesInFlightPerStream; @@ -654,7 +656,8 @@ TEST(DefaultVideoQualityAnalyzerTest, /*num_squares=*/absl::nullopt); DefaultVideoQualityAnalyzerOptions analyzer_options; - analyzer_options.heavy_metrics_computation_enabled = true; + analyzer_options.compute_psnr = true; + analyzer_options.compute_ssim = true; analyzer_options.adjust_cropping_before_comparing_frames = true; analyzer_options.max_frames_in_flight_per_stream_count = kMaxFramesInFlightPerStream; From 0c28820dcde47398f98a5152694f68f6ae221960 Mon Sep 17 00:00:00 2001 From: Byoungchan Lee Date: Thu, 24 Mar 2022 17:40:03 +0900 Subject: [PATCH 289/847] Fix FRAME delimiter is not handled properly in yuv/y4m reader Note that sdk/android/api/org/webrtc/FileVideoCapturer.java is handling correctly. Bug: None Change-Id: I3a9783d75bd0a4b3a454b87a01039154200c4d29 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256581 Auto-Submit: Daniel.L (Byoungchan) Lee Reviewed-by: Mirko Bonadei Commit-Queue: Mirko Bonadei Cr-Commit-Position: refs/heads/main@{#36315} --- rtc_tools/video_file_reader.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rtc_tools/video_file_reader.cc b/rtc_tools/video_file_reader.cc index c6fa5870e8..6e722b1235 100644 --- a/rtc_tools/video_file_reader.cc +++ b/rtc_tools/video_file_reader.cc @@ -204,9 +204,10 @@ rtc::scoped_refptr