Add qp counter for H264 in SendStatisticsProxy.

BUG=webrtc:6578

Review-Url: https://codereview.webrtc.org/2437323002
Cr-Commit-Position: refs/heads/master@{#14895}
diff --git a/webrtc/video/send_statistics_proxy.cc b/webrtc/video/send_statistics_proxy.cc
index 2da71eb..a996976 100644
--- a/webrtc/video/send_statistics_proxy.cc
+++ b/webrtc/video/send_statistics_proxy.cc
@@ -250,6 +250,13 @@
                         << spatial_idx;
       }
     }
+    int qp_h264 = it.second.h264.Avg(kMinRequiredMetricsSamples);
+    if (qp_h264 != -1) {
+      int spatial_idx = it.first;
+      RTC_DCHECK_EQ(-1, spatial_idx);
+      RTC_HISTOGRAMS_COUNTS_100(kIndex, uma_prefix_ + "Encoded.Qp.H264",
+                                qp_h264);
+    }
   }
 
   if (first_rtcp_stats_time_ms_ != -1) {
@@ -520,6 +527,9 @@
                 ? -1
                 : codec_info->codecSpecific.VP9.spatial_idx;
         uma_container_->qp_counters_[spatial_idx].vp9.Add(encoded_image.qp_);
+      } else if (codec_info->codecType == kVideoCodecH264) {
+        int spatial_idx = -1;
+        uma_container_->qp_counters_[spatial_idx].h264.Add(encoded_image.qp_);
       }
     }
   }
diff --git a/webrtc/video/send_statistics_proxy.h b/webrtc/video/send_statistics_proxy.h
index 89c4065..ec2fe4c 100644
--- a/webrtc/video/send_statistics_proxy.h
+++ b/webrtc/video/send_statistics_proxy.h
@@ -138,8 +138,9 @@
     int64_t bitrate_update_ms;
   };
   struct QpCounters {
-    SampleCounter vp8;  // QP range: 0-127
-    SampleCounter vp9;  // QP range: 0-255
+    SampleCounter vp8;   // QP range: 0-127
+    SampleCounter vp9;   // QP range: 0-255
+    SampleCounter h264;  // QP range: 0-51
   };
   void PurgeOldStats() EXCLUSIVE_LOCKS_REQUIRED(crit_);
   VideoSendStream::StreamStats* GetStatsEntry(uint32_t ssrc)
diff --git a/webrtc/video/send_statistics_proxy_unittest.cc b/webrtc/video/send_statistics_proxy_unittest.cc
index fcab7d1..a467f6c 100644
--- a/webrtc/video/send_statistics_proxy_unittest.cc
+++ b/webrtc/video/send_statistics_proxy_unittest.cc
@@ -467,6 +467,20 @@
   EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.Encoded.Qp.Vp9", kQpIdx0));
 }
 
+TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_H264) {
+  EncodedImage encoded_image;
+  CodecSpecificInfo codec_info;
+  codec_info.codecType = kVideoCodecH264;
+
+  for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) {
+    encoded_image.qp_ = kQpIdx0;
+    statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info);
+  }
+  statistics_proxy_.reset();
+  EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.Encoded.Qp.H264"));
+  EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.Encoded.Qp.H264", kQpIdx0));
+}
+
 TEST_F(SendStatisticsProxyTest,
        BandwidthLimitedHistogramsNotUpdatedWhenDisabled) {
   EncodedImage encoded_image;