diff options
Diffstat (limited to 'chromium/third_party/webrtc/logging')
7 files changed, 94 insertions, 19 deletions
diff --git a/chromium/third_party/webrtc/logging/BUILD.gn b/chromium/third_party/webrtc/logging/BUILD.gn index 28176d2583a..c1edd69680c 100644 --- a/chromium/third_party/webrtc/logging/BUILD.gn +++ b/chromium/third_party/webrtc/logging/BUILD.gn @@ -53,8 +53,8 @@ rtc_library("rtc_event_pacing") { deps = [ "../api:scoped_refptr", "../api/rtc_event_log", - "//third_party/abseil-cpp/absl/memory", ] + absl_deps = [ "//third_party/abseil-cpp/absl/memory" ] } rtc_library("rtc_event_audio") { @@ -75,8 +75,8 @@ rtc_library("rtc_event_audio") { "../api/rtc_event_log", "../modules/audio_coding:audio_network_adaptor_config", "../rtc_base:checks", - "//third_party/abseil-cpp/absl/memory", ] + absl_deps = [ "//third_party/abseil-cpp/absl/memory" ] } rtc_library("rtc_event_bwe") { @@ -101,6 +101,8 @@ rtc_library("rtc_event_bwe") { "../api/rtc_event_log", "../api/units:data_rate", "../modules/remote_bitrate_estimator", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/types:optional", ] @@ -119,6 +121,8 @@ rtc_library("rtc_event_generic_packet_events") { deps = [ "../api/rtc_event_log", "../rtc_base:timeutils", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/types:optional", ] @@ -143,8 +147,8 @@ rtc_library("rtc_event_rtp_rtcp") { "../modules/rtp_rtcp:rtp_rtcp_format", "../rtc_base:checks", "../rtc_base:rtc_base_approved", - "//third_party/abseil-cpp/absl/memory", ] + absl_deps = [ "//third_party/abseil-cpp/absl/memory" ] } rtc_library("rtc_event_video") { @@ -160,8 +164,8 @@ rtc_library("rtc_event_video") { "../api:scoped_refptr", "../api/rtc_event_log", "../rtc_base:checks", - "//third_party/abseil-cpp/absl/memory", ] + absl_deps = [ "//third_party/abseil-cpp/absl/memory" ] } # TODO(eladalon): Break down into (1) encoder and (2) decoder; we don't need @@ -187,6 +191,8 @@ rtc_library("rtc_event_log_impl_encoder") { "../rtc_base:checks", "../rtc_base:ignore_wundef", "../rtc_base:rtc_base_approved", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", @@ -245,8 +251,8 @@ if (rtc_enable_protobuf) { "../rtc_base:rtc_task_queue", "../rtc_base:safe_minmax", "../rtc_base/synchronization:sequence_checker", - "//third_party/abseil-cpp/absl/types:optional", ] + absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] } } @@ -318,6 +324,8 @@ if (rtc_enable_protobuf) { "../rtc_base:protobuf_utils", "../rtc_base:rtc_base_approved", "../rtc_base:rtc_numerics", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/types:optional", ] @@ -369,6 +377,8 @@ if (rtc_enable_protobuf) { "../test:fileutils", "../test:test_support", "//testing/gtest", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/types:optional", ] @@ -417,8 +427,8 @@ rtc_library("ice_log") { "../api:libjingle_peerconnection_api", # For api/dtls_transport_interface.h "../api/rtc_event_log", "../rtc_base:rtc_base_approved", - "//third_party/abseil-cpp/absl/memory", ] + absl_deps = [ "//third_party/abseil-cpp/absl/memory" ] } if (rtc_include_tests) { diff --git a/chromium/third_party/webrtc/logging/rtc_event_log/encoder/blob_encoding.h b/chromium/third_party/webrtc/logging/rtc_event_log/encoder/blob_encoding.h index 4a38dc5d0b6..b5b589aaf6a 100644 --- a/chromium/third_party/webrtc/logging/rtc_event_log/encoder/blob_encoding.h +++ b/chromium/third_party/webrtc/logging/rtc_event_log/encoder/blob_encoding.h @@ -43,7 +43,7 @@ namespace webrtc { // // Note that the returned std::string might have been reserved for significantly // more memory than it ends up using. If the caller to EncodeBlobs() intends -// to store the result long-term, he should consider shrink_to_fit()-ing it. +// to store the result long-term, they should consider shrink_to_fit()-ing it. std::string EncodeBlobs(const std::vector<std::string>& blobs); std::vector<absl::string_view> DecodeBlobs(absl::string_view encoded_blobs, size_t num_of_blobs); diff --git a/chromium/third_party/webrtc/logging/rtc_event_log/encoder/rtc_event_log_encoder_unittest.cc b/chromium/third_party/webrtc/logging/rtc_event_log/encoder/rtc_event_log_encoder_unittest.cc index 30596216907..cf85775f527 100644 --- a/chromium/third_party/webrtc/logging/rtc_event_log/encoder/rtc_event_log_encoder_unittest.cc +++ b/chromium/third_party/webrtc/logging/rtc_event_log/encoder/rtc_event_log_encoder_unittest.cc @@ -675,13 +675,18 @@ TEST_P(RtcEventLogEncoderTest, RtcEventLoggingStarted) { } TEST_P(RtcEventLogEncoderTest, RtcEventLoggingStopped) { - const int64_t timestamp_us = rtc::TimeMicros(); - std::string encoded = encoder_->EncodeLogEnd(timestamp_us); + const int64_t start_timestamp_us = rtc::TimeMicros(); + const int64_t start_utc_time_us = rtc::TimeUTCMicros(); + std::string encoded = + encoder_->EncodeLogStart(start_timestamp_us, start_utc_time_us); + + const int64_t stop_timestamp_us = rtc::TimeMicros(); + encoded += encoder_->EncodeLogEnd(stop_timestamp_us); ASSERT_TRUE(parsed_log_.ParseString(encoded).ok()); const auto& stop_log_events = parsed_log_.stop_log_events(); ASSERT_EQ(stop_log_events.size(), 1u); - verifier_.VerifyLoggedStopEvent(timestamp_us, stop_log_events[0]); + verifier_.VerifyLoggedStopEvent(stop_timestamp_us, stop_log_events[0]); } // TODO(eladalon/terelius): Test with multiple events in the batch. diff --git a/chromium/third_party/webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h b/chromium/third_party/webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h index 66a2065ed47..646831de272 100644 --- a/chromium/third_party/webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h +++ b/chromium/third_party/webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h @@ -21,20 +21,20 @@ namespace webrtc { class MockRtcEventLog : public RtcEventLog { public: MockRtcEventLog(); - ~MockRtcEventLog(); + ~MockRtcEventLog() override; - virtual bool StartLogging(std::unique_ptr<RtcEventLogOutput> output, - int64_t output_period_ms) { - return StartLoggingProxy(output.get(), output_period_ms); - } - MOCK_METHOD2(StartLoggingProxy, bool(RtcEventLogOutput*, int64_t)); + MOCK_METHOD(bool, + StartLogging, + (std::unique_ptr<RtcEventLogOutput> output, + int64_t output_period_ms), + (override)); - MOCK_METHOD0(StopLogging, void()); + MOCK_METHOD(void, StopLogging, (), (override)); - virtual void Log(std::unique_ptr<RtcEvent> event) { + void Log(std::unique_ptr<RtcEvent> event) override { return LogProxy(event.get()); } - MOCK_METHOD1(LogProxy, void(RtcEvent*)); + MOCK_METHOD(void, LogProxy, (RtcEvent*)); }; } // namespace webrtc diff --git a/chromium/third_party/webrtc/logging/rtc_event_log/rtc_event_log_parser.cc b/chromium/third_party/webrtc/logging/rtc_event_log/rtc_event_log_parser.cc index 4016f84339a..c88207607cb 100644 --- a/chromium/third_party/webrtc/logging/rtc_event_log/rtc_event_log_parser.cc +++ b/chromium/third_party/webrtc/logging/rtc_event_log/rtc_event_log_parser.cc @@ -1076,6 +1076,7 @@ void ParsedRtcEventLog::Clear() { first_timestamp_ = std::numeric_limits<int64_t>::max(); last_timestamp_ = std::numeric_limits<int64_t>::min(); + first_log_segment_ = LogSegment(0, std::numeric_limits<int64_t>::max()); incoming_rtp_extensions_maps_.clear(); outgoing_rtp_extensions_maps_.clear(); @@ -1214,6 +1215,38 @@ ParsedRtcEventLog::ParseStatus ParsedRtcEventLog::ParseStream( StoreFirstAndLastTimestamp(generic_packets_sent_); StoreFirstAndLastTimestamp(generic_packets_received_); StoreFirstAndLastTimestamp(generic_acks_received_); + StoreFirstAndLastTimestamp(remote_estimate_events_); + + // Stop events could be missing due to file size limits. If so, use the + // last event, or the next start timestamp if available. + // TODO(terelius): This could be improved. Instead of using the next start + // 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 next_start_us = std::numeric_limits<int64_t>::max(); + int64_t stop_us = std::numeric_limits<int64_t>::max(); + if (start_iter != start_log_events().end()) { + start_us = std::min(start_us, start_iter->log_time_us()); + ++start_iter; + if (start_iter != start_log_events().end()) + next_start_us = start_iter->log_time_us(); + } + if (stop_iter != stop_log_events().end()) { + stop_us = stop_iter->log_time_us(); + } + stop_us = std::min(stop_us, next_start_us); + if (stop_us == std::numeric_limits<int64_t>::max() && + last_timestamp() != std::numeric_limits<int64_t>::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_ == std::numeric_limits<int64_t>::max() && + last_timestamp_ == std::numeric_limits<int64_t>::min()) { + first_timestamp_ = last_timestamp_ = 0; + } return status; } diff --git a/chromium/third_party/webrtc/logging/rtc_event_log/rtc_event_log_parser.h b/chromium/third_party/webrtc/logging/rtc_event_log/rtc_event_log_parser.h index 7a162af897e..8d3351e815f 100644 --- a/chromium/third_party/webrtc/logging/rtc_event_log/rtc_event_log_parser.h +++ b/chromium/third_party/webrtc/logging/rtc_event_log/rtc_event_log_parser.h @@ -11,6 +11,7 @@ #define LOGGING_RTC_EVENT_LOG_RTC_EVENT_LOG_PARSER_H_ #include <iterator> +#include <limits> #include <map> #include <set> #include <sstream> // no-presubmit-check TODO(webrtc:8982) @@ -193,6 +194,8 @@ class PacketView { size_t size() const { return num_elements_; } + bool empty() const { return num_elements_ == 0; } + T& operator[](size_t i) { auto elem_ptr = data_ + i * element_size_; return *reinterpret_cast<T*>(elem_ptr); @@ -330,6 +333,20 @@ class ParsedRtcEventLog { PacketView<const LoggedRtpPacket> packet_view; }; + class LogSegment { + public: + LogSegment(int64_t start_time_us, int64_t stop_time_us) + : start_time_us_(start_time_us), stop_time_us_(stop_time_us) {} + int64_t start_time_ms() const { return start_time_us_ / 1000; } + int64_t start_time_us() const { return start_time_us_; } + int64_t stop_time_ms() const { return stop_time_us_ / 1000; } + int64_t stop_time_us() const { return stop_time_us_; } + + private: + int64_t start_time_us_; + int64_t stop_time_us_; + }; + static webrtc::RtpHeaderExtensionMap GetDefaultHeaderExtensionMap(); explicit ParsedRtcEventLog( @@ -597,6 +614,8 @@ class ParsedRtcEventLog { 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_; } + std::vector<LoggedPacketInfo> GetPacketInfos(PacketDirection direction) const; std::vector<LoggedPacketInfo> GetIncomingPacketInfos() const { return GetPacketInfos(kIncomingPacket); @@ -850,6 +869,9 @@ class ParsedRtcEventLog { int64_t first_timestamp_; int64_t last_timestamp_; + LogSegment first_log_segment_ = + LogSegment(0, std::numeric_limits<int64_t>::max()); + // The extension maps are mutable to allow us to insert the default // configuration when parsing an RTP header for an unconfigured stream. // TODO(terelius): This is only used for the legacy format. Remove once we've diff --git a/chromium/third_party/webrtc/logging/rtc_event_log/rtc_event_log_unittest.cc b/chromium/third_party/webrtc/logging/rtc_event_log/rtc_event_log_unittest.cc index 579c6528804..e785d6160a0 100644 --- a/chromium/third_party/webrtc/logging/rtc_event_log/rtc_event_log_unittest.cc +++ b/chromium/third_party/webrtc/logging/rtc_event_log/rtc_event_log_unittest.cc @@ -739,6 +739,11 @@ void RtcEventLogSession::ReadAndVerifyLog() { 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_)); + EXPECT_EQ(parsed_log.first_log_segment().stop_time_ms(), + stop_time_us_ / 1000); + // Clean up temporary file - can be pretty slow. remove(temp_filename_.c_str()); } |