Don't include duplicated and incomplete frames in stats.

The received frames statistics currently include also frames
that are dropped because they are duplicated, incomplete, or
the buffer being full. After this CL only frames that are
added to the decode queue are counted.

This CL is part of fixing the dropped frames statistics that
are currently also counting frames that are in the decode
queue.

Bug: chromium:990317
Change-Id: I7df31939ecb7b9e222086e1141a15420fa2819dc
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/150108
Commit-Queue: Johannes Kron <kron@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28939}
diff --git a/modules/video_coding/frame_buffer2.cc b/modules/video_coding/frame_buffer2.cc
index d969946..376cff3 100644
--- a/modules/video_coding/frame_buffer2.cc
+++ b/modules/video_coding/frame_buffer2.cc
@@ -453,12 +453,7 @@
 
   rtc::CritScope lock(&crit_);
 
-  if (stats_callback_ && IsCompleteSuperFrame(*frame)) {
-    stats_callback_->OnCompleteFrame(frame->is_keyframe(), frame->size(),
-                                     frame->contentType());
-  }
   const VideoLayerFrameId& id = frame->id;
-
   int64_t last_continuous_picture_id =
       !last_continuous_frame_ ? -1 : last_continuous_frame_->picture_id;
 
@@ -542,6 +537,11 @@
   if (!frame->delayed_by_retransmission())
     timing_->IncomingTimestamp(frame->Timestamp(), frame->ReceivedTime());
 
+  if (stats_callback_ && IsCompleteSuperFrame(*frame)) {
+    stats_callback_->OnCompleteFrame(frame->is_keyframe(), frame->size(),
+                                     frame->contentType());
+  }
+
   info->second.frame = std::move(frame);
 
   if (info->second.num_missing_continuous == 0) {