Report send codec name in GetStats().

BUG=4461
R=stefan@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/51439004

Cr-Commit-Position: refs/heads/master@{#8869}
diff --git a/talk/media/webrtc/webrtcvideoengine2.cc b/talk/media/webrtc/webrtcvideoengine2.cc
index fec8067..4950e1d 100644
--- a/talk/media/webrtc/webrtcvideoengine2.cc
+++ b/talk/media/webrtc/webrtcvideoengine2.cc
@@ -1816,6 +1816,9 @@
     for (uint32_t ssrc : parameters_.config.rtp.ssrcs)
       info.add_ssrc(ssrc);
 
+    VideoCodecSettings codec_settings;
+    if (parameters_.codec_settings.Get(&codec_settings))
+      info.codec_name = codec_settings.codec.name;
     for (size_t i = 0; i < parameters_.encoder_config.streams.size(); ++i) {
       if (i == parameters_.encoder_config.streams.size() - 1) {
         info.preferred_bitrate +=
diff --git a/talk/media/webrtc/webrtcvideoengine2_unittest.cc b/talk/media/webrtc/webrtcvideoengine2_unittest.cc
index 7322879..1cf015e 100644
--- a/talk/media/webrtc/webrtcvideoengine2_unittest.cc
+++ b/talk/media/webrtc/webrtcvideoengine2_unittest.cc
@@ -2101,6 +2101,18 @@
   EXPECT_EQ(webrtc::Call::kNetworkUp, fake_call_->GetNetworkState());
 }
 
+TEST_F(WebRtcVideoChannel2Test, GetStatsReportsSentCodecName) {
+  std::vector<cricket::VideoCodec> codecs;
+  codecs.push_back(kVp8Codec);
+  EXPECT_TRUE(channel_->SetSendCodecs(codecs));
+
+  AddSendStream();
+
+  cricket::VideoMediaInfo info;
+  ASSERT_TRUE(channel_->GetStats(&info));
+  EXPECT_EQ(kVp8Codec.name, info.senders[0].codec_name);
+}
+
 TEST_F(WebRtcVideoChannel2Test, GetStatsReportsCpuOveruseMetrics) {
   FakeVideoSendStream* stream = AddSendStream();
   webrtc::VideoSendStream::Stats stats;