Reland "Add fine grained dropped video frames counters on sending side"

Add fine grained dropped video frames counters on sending side

4 new counters added to SendStatisticsProxy and reported to UMA and logs.

Bug: webrtc:8355
Change-Id: I1f9bdfea9cbf17cf38b3cb2f55d406ffdb06614f
Reviewed-on: https://webrtc-review.googlesource.com/14580
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20421}
diff --git a/modules/video_coding/generic_encoder.h b/modules/video_coding/generic_encoder.h
index 9b003d6..878588d 100644
--- a/modules/video_coding/generic_encoder.h
+++ b/modules/video_coding/generic_encoder.h
@@ -12,7 +12,7 @@
 #define MODULES_VIDEO_CODING_GENERIC_ENCODER_H_
 
 #include <stdio.h>
-#include <map>
+#include <list>
 #include <vector>
 
 #include "modules/video_coding/include/video_codec_interface.h"
@@ -65,15 +65,29 @@
     timing_frames_thresholds_ = thresholds;
   }
 
+  // Clears all data stored by OnEncodeStarted().
+  void Reset() {
+    rtc::CritScope crit(&timing_params_lock_);
+    timing_frames_info_.clear();
+    last_timing_frame_time_ms_ = -1;
+  }
+
  private:
   rtc::CriticalSection timing_params_lock_;
   bool internal_source_;
   EncodedImageCallback* const post_encode_callback_;
   media_optimization::MediaOptimization* const media_opt_;
 
+  struct EncodeStartTimeRecord {
+    EncodeStartTimeRecord(int64_t capture_time, int64_t encode_start_time)
+        : capture_time_ms(capture_time),
+          encode_start_time_ms(encode_start_time) {}
+    int64_t capture_time_ms;
+    int64_t encode_start_time_ms;
+  };
   struct TimingFramesLayerInfo {
     size_t target_bitrate_bytes_per_sec = 0;
-    std::map<int64_t, int64_t> encode_start_time_ms;
+    std::list<EncodeStartTimeRecord> encode_start_list;
   };
   // Separate instance for each simulcast stream or spatial layer.
   std::vector<TimingFramesLayerInfo> timing_frames_info_
@@ -111,7 +125,6 @@
   int32_t SetPeriodicKeyFrames(bool enable);
   int32_t RequestFrame(const std::vector<FrameType>& frame_types);
   bool InternalSource() const;
-  void OnDroppedFrame();
   bool SupportsNativeHandle() const;
 
  private: