Replace inconsistent log_segments() function in RTC event log parser

Bug: webrtc:11566
Change-Id: I739bbc29ae5423f3fedcc08e991e27fa0af840c5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/176081
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31371}
diff --git a/rtc_tools/rtc_event_log_visualizer/alerts.cc b/rtc_tools/rtc_event_log_visualizer/alerts.cc
index f2d9564..86372de 100644
--- a/rtc_tools/rtc_event_log_visualizer/alerts.cc
+++ b/rtc_tools/rtc_event_log_visualizer/alerts.cc
@@ -62,10 +62,7 @@
       direction == kIncomingPacket ? TriageAlertType::kIncomingCaptureTimeJump
                                    : TriageAlertType::kOutgoingCaptureTimeJump;
 
-  const int64_t segment_end_us =
-      parsed_log.log_segments().empty()
-          ? std::numeric_limits<int64_t>::max()
-          : parsed_log.log_segments().front().stop_time_us();
+  const int64_t segment_end_us = parsed_log.first_log_segment().stop_time_us();
 
   // Check for gaps in sequence numbers and capture timestamps.
   for (const auto& stream : parsed_log.rtp_packets_by_ssrc(direction)) {
@@ -133,10 +130,7 @@
                                    ? TriageAlertType::kIncomingRtcpGap
                                    : TriageAlertType::kOutgoingRtcpGap;
 
-  const int64_t segment_end_us =
-      parsed_log.log_segments().empty()
-          ? std::numeric_limits<int64_t>::max()
-          : parsed_log.log_segments().front().stop_time_us();
+  const int64_t segment_end_us = parsed_log.first_log_segment().stop_time_us();
 
   // TODO(terelius): The parser could provide a list of all packets, ordered
   // by time, for each direction.
@@ -202,10 +196,7 @@
   AnalyzeTransmissionGaps(parsed_log, kIncomingPacket);
   AnalyzeTransmissionGaps(parsed_log, kOutgoingPacket);
 
-  const int64_t segment_end_us =
-      parsed_log.log_segments().empty()
-          ? std::numeric_limits<int64_t>::max()
-          : parsed_log.log_segments().front().stop_time_us();
+  const int64_t segment_end_us = parsed_log.first_log_segment().stop_time_us();
 
   int64_t first_occurrence = parsed_log.last_timestamp();
   constexpr double kMaxLossFraction = 0.05;
diff --git a/rtc_tools/rtc_event_log_visualizer/analyzer.cc b/rtc_tools/rtc_event_log_visualizer/analyzer.cc
index 9a9a455..a0e441c 100644
--- a/rtc_tools/rtc_event_log_visualizer/analyzer.cc
+++ b/rtc_tools/rtc_event_log_visualizer/analyzer.cc
@@ -465,15 +465,21 @@
     config_.begin_time_ = config_.end_time_ = 0;
   }
 
-  RTC_LOG(LS_INFO) << "Found " << parsed_log_.log_segments().size()
-                   << " (LOG_START, LOG_END) segments in log.";
+  RTC_LOG(LS_INFO) << "Log is "
+                   << (parsed_log_.last_timestamp() -
+                       parsed_log_.first_timestamp()) /
+                          1000000
+                   << " seconds long.";
 }
 
 EventLogAnalyzer::EventLogAnalyzer(const ParsedRtcEventLog& log,
                                    const AnalyzerConfig& config)
     : parsed_log_(log), config_(config) {
-  RTC_LOG(LS_INFO) << "Found " << parsed_log_.log_segments().size()
-                   << " (LOG_START, LOG_END) segments in log.";
+  RTC_LOG(LS_INFO) << "Log is "
+                   << (parsed_log_.last_timestamp() -
+                       parsed_log_.first_timestamp()) /
+                          1000000
+                   << " seconds long.";
 }
 
 class BitrateObserver : public RemoteBitrateObserver {
@@ -852,10 +858,7 @@
                           << packets.size() << " packets in the stream.";
       continue;
     }
-    int64_t segment_end_us =
-        parsed_log_.log_segments().empty()
-            ? std::numeric_limits<int64_t>::max()
-            : parsed_log_.log_segments().front().stop_time_us();
+    int64_t segment_end_us = parsed_log_.first_log_segment().stop_time_us();
     absl::optional<uint32_t> estimated_frequency =
         EstimateRtpClockFrequency(packets, segment_end_us);
     if (!estimated_frequency)
@@ -1586,10 +1589,7 @@
              "pacer delay with less than 2 packets in the stream";
       continue;
     }
-    int64_t segment_end_us =
-        parsed_log_.log_segments().empty()
-            ? std::numeric_limits<int64_t>::max()
-            : parsed_log_.log_segments().front().stop_time_us();
+    int64_t segment_end_us = parsed_log_.first_log_segment().stop_time_us();
     absl::optional<uint32_t> estimated_frequency =
         EstimateRtpClockFrequency(packets, segment_end_us);
     if (!estimated_frequency)
@@ -2050,11 +2050,7 @@
       output_events_it = parsed_log_.audio_playout_events().cbegin();
     }
 
-    absl::optional<int64_t> end_time_ms =
-        parsed_log_.log_segments().empty()
-            ? absl::nullopt
-            : absl::optional<int64_t>(
-                  parsed_log_.log_segments().front().stop_time_ms());
+    int64_t end_time_ms = parsed_log_.first_log_segment().stop_time_ms();
 
     neteq_stats[ssrc] = CreateNetEqTestAndRun(
         audio_packets, &output_events_it->second, end_time_ms,