Fixes the frameRate stats by grouping the frames by timestamp.

R=stefan@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@4138 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/modules/video_coding/main/source/media_optimization.cc b/modules/video_coding/main/source/media_optimization.cc
index 24cf316..0ba272d 100644
--- a/modules/video_coding/main/source/media_optimization.cc
+++ b/modules/video_coding/main/source/media_optimization.cc
@@ -382,8 +382,17 @@
 {
     const int64_t now_ms = _clock->TimeInMilliseconds();
     PurgeOldFrameSamples(now_ms);
-    _encodedFrameSamples.push_back(VCMEncodedFrameSample(
-        encodedLength, timestamp, now_ms));
+    if (_encodedFrameSamples.size() > 0 &&
+        _encodedFrameSamples.back().timestamp == timestamp) {
+        // Frames having the same timestamp are generated from the same input
+        // frame. We don't want to double count them, but only increment the
+        // size_bytes.
+        _encodedFrameSamples.back().size_bytes += encodedLength;
+        _encodedFrameSamples.back().time_complete_ms = now_ms;
+    } else {
+        _encodedFrameSamples.push_back(VCMEncodedFrameSample(
+            encodedLength, timestamp, now_ms));
+    }
     UpdateSentBitrate(now_ms);
     UpdateSentFramerate();
     if(encodedLength > 0)