Move calculation of target_encode_bitrate to DefaultVideoQualityAnalyzer

To migrate on new GetStats API and properly support target encode bitrate
for regular, simulcast and svc cases we need to calculate it inside video
quality analyzer getting values from SetRates in VideoEncoder.

Bug: webrtc:11381
Change-Id: Ia37acac764ed3c30f64cdbfda8906d543fa03ae2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/171501
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30881}
diff --git a/api/test/video_quality_analyzer_interface.h b/api/test/video_quality_analyzer_interface.h
index 990548a..0d3f441 100644
--- a/api/test/video_quality_analyzer_interface.h
+++ b/api/test/video_quality_analyzer_interface.h
@@ -53,6 +53,20 @@
 // The analyzer will be injected in all points from A to F.
 class VideoQualityAnalyzerInterface : public StatsObserverInterface {
  public:
+  // Contains extra statistic provided by video encoder.
+  struct EncoderStats {
+    // TODO(hbos) https://crbug.com/webrtc/9547,
+    // https://crbug.com/webrtc/11443: improve stats API to make available
+    // there.
+    uint32_t target_encode_bitrate;
+  };
+  // Contains extra statistic provided by video decoder.
+  struct DecoderStats {
+    // Decode time provided by decoder itself. If decoder doesn’t produce such
+    // information can be omitted.
+    absl::optional<int32_t> decode_time_ms;
+  };
+
   ~VideoQualityAnalyzerInterface() override = default;
 
   // Will be called by framework before test.
@@ -74,18 +88,16 @@
   // VideoFrame can produce multiple EncodedImages. Each encoded image will
   // have id from VideoFrame.
   virtual void OnFrameEncoded(uint16_t frame_id,
-                              const EncodedImage& encoded_image) {}
+                              const EncodedImage& encoded_image,
+                              const EncoderStats& stats) {}
   // Will be called for each frame dropped by encoder.
   virtual void OnFrameDropped(EncodedImageCallback::DropReason reason) {}
   // Will be called before calling the decoder.
   virtual void OnFramePreDecode(uint16_t frame_id,
                                 const EncodedImage& encoded_image) {}
-  // Will be called after decoding the frame. |decode_time_ms| is a decode
-  // time provided by decoder itself. If decoder doesn’t produce such
-  // information can be omitted.
+  // Will be called after decoding the frame.
   virtual void OnFrameDecoded(const VideoFrame& frame,
-                              absl::optional<int32_t> decode_time_ms,
-                              absl::optional<uint8_t> qp) {}
+                              const DecoderStats& stats) {}
   // Will be called when frame will be obtained from PeerConnection stack.
   virtual void OnFrameRendered(const VideoFrame& frame) {}
   // Will be called if encoder return not WEBRTC_VIDEO_CODEC_OK.