Add ToString method to AggregatedStats and log stats at the end of a call.

BUG=webrtc:5283

Review-Url: https://codereview.webrtc.org/2494423002
Cr-Commit-Position: refs/heads/master@{#15088}
diff --git a/webrtc/video/receive_statistics_proxy.cc b/webrtc/video/receive_statistics_proxy.cc
index ded510a..b15ef68 100644
--- a/webrtc/video/receive_statistics_proxy.cc
+++ b/webrtc/video/receive_statistics_proxy.cc
@@ -77,6 +77,8 @@
   if (freq_offset_stats.num_samples > 0) {
     RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.RtpToNtpFreqOffsetInKhz",
                                freq_offset_stats.average);
+    LOG(LS_INFO) << "WebRTC.Video.RtpToNtpFreqOffsetInKhz, "
+                 << freq_offset_stats.ToString();
   }
 
   int qp = qp_counters_.vp8.Avg(kMinRequiredSamples);
diff --git a/webrtc/video/send_delay_stats.cc b/webrtc/video/send_delay_stats.cc
index 8ae0615..1c3fd2a 100644
--- a/webrtc/video/send_delay_stats.cc
+++ b/webrtc/video/send_delay_stats.cc
@@ -45,6 +45,7 @@
     AggregatedStats stats = it.second->GetStats();
     if (stats.num_samples >= kMinRequiredPeriodicSamples) {
       RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.SendDelayInMs", stats.average);
+      LOG(LS_INFO) << "WebRTC.Video.SendDelayInMs, " << stats.ToString();
     }
   }
 }
diff --git a/webrtc/video/stats_counter.cc b/webrtc/video/stats_counter.cc
index 9923ed2..b1c24ee 100644
--- a/webrtc/video/stats_counter.cc
+++ b/webrtc/video/stats_counter.cc
@@ -25,6 +25,15 @@
 const uint32_t kStreamId0 = 0;
 }  // namespace
 
+std::string AggregatedStats::ToString() const {
+  std::stringstream ss;
+  ss << "periodic_samples:" << num_samples << ", {";
+  ss << "min:" << min << ", ";
+  ss << "avg:" << average << ", ";
+  ss << "max:" << max << "}";
+  return ss.str();
+}
+
 // Class holding periodically computed metrics.
 class AggregatedCounter {
  public:
diff --git a/webrtc/video/stats_counter.h b/webrtc/video/stats_counter.h
index 08663f8..e84d73b 100644
--- a/webrtc/video/stats_counter.h
+++ b/webrtc/video/stats_counter.h
@@ -12,6 +12,7 @@
 #define WEBRTC_VIDEO_STATS_COUNTER_H_
 
 #include <memory>
+#include <string>
 
 #include "webrtc/base/constructormagic.h"
 #include "webrtc/typedefs.h"
@@ -31,6 +32,8 @@
 };
 
 struct AggregatedStats {
+  std::string ToString() const;
+
   int64_t num_samples = 0;
   int min = -1;
   int max = -1;