Reland of Add QP sum stats for received streams. (patchset #2 id:300001 of https://codereview.webrtc.org/2680893002/ )

Reason for revert:
Fix the problem.

Original issue's description:
> Revert of Add QP sum stats for received streams. (patchset #10 id:180001 of https://codereview.webrtc.org/2649133005/ )
>
> Reason for revert:
> Breaks downstream build.
>
> Original issue's description:
> > Add QP sum stats for received streams.
> >
> > This is not implemented yet in any of the decoders.
> >
> > BUG=webrtc:6541
> >
> > Review-Url: https://codereview.webrtc.org/2649133005
> > Cr-Commit-Position: refs/heads/master@{#16475}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/ff0e72fd165facac27f0313aa178648782e63bc4
>
> TBR=hta@webrtc.org,hbos@webrtc.org,sprang@webrtc.org,magjed@webrtc.org,stefan@webrtc.org,sakal@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6541
>
> Review-Url: https://codereview.webrtc.org/2680893002 .
> Cr-Commit-Position: refs/heads/master@{#16480}
> Committed: https://chromium.googlesource.com/external/webrtc/+/69fb2cca4d54f3df7ceddcd1c3e9b0ad80fa849b

TBR=hta@webrtc.org,hbos@webrtc.org,sprang@webrtc.org,magjed@webrtc.org,stefan@webrtc.org,skvlad@webrtc.org
BUG=webrtc:6541

Review-Url: https://codereview.webrtc.org/2681663005
Cr-Commit-Position: refs/heads/master@{#16511}
diff --git a/webrtc/modules/video_coding/codecs/test/videoprocessor.h b/webrtc/modules/video_coding/codecs/test/videoprocessor.h
index a217b11..778cc1d 100644
--- a/webrtc/modules/video_coding/codecs/test/videoprocessor.h
+++ b/webrtc/modules/video_coding/codecs/test/videoprocessor.h
@@ -250,6 +250,11 @@
       RTC_NOTREACHED();
       return -1;
     }
+    void Decoded(VideoFrame& frame,
+                 rtc::Optional<int32_t> decode_time_ms,
+                 rtc::Optional<uint8_t> qp) override {
+      RTC_NOTREACHED();
+    }
 
    private:
     VideoProcessorImpl* video_processor_;
diff --git a/webrtc/modules/video_coding/codecs/vp8/simulcast_unittest.h b/webrtc/modules/video_coding/codecs/vp8/simulcast_unittest.h
index d140b0a..b7e3e7d 100644
--- a/webrtc/modules/video_coding/codecs/vp8/simulcast_unittest.h
+++ b/webrtc/modules/video_coding/codecs/vp8/simulcast_unittest.h
@@ -145,6 +145,11 @@
     RTC_NOTREACHED();
     return -1;
   }
+  void Decoded(VideoFrame& decoded_image,
+               rtc::Optional<int32_t> decode_time_ms,
+               rtc::Optional<uint8_t> qp) override {
+    RTC_NOTREACHED();
+  }
   int DecodedFrames() { return decoded_frames_; }
 
  private:
diff --git a/webrtc/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc b/webrtc/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc
index de612f0..a47c209 100644
--- a/webrtc/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc
+++ b/webrtc/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc
@@ -97,6 +97,11 @@
     RTC_NOTREACHED();
     return -1;
   }
+  void Decoded(VideoFrame& frame,
+               rtc::Optional<int32_t> decode_time_ms,
+               rtc::Optional<uint8_t> qp) override {
+    RTC_NOTREACHED();
+  }
   bool DecodeComplete();
 
  private:
diff --git a/webrtc/modules/video_coding/generic_decoder.cc b/webrtc/modules/video_coding/generic_decoder.cc
index b1059e8..34500c6 100644
--- a/webrtc/modules/video_coding/generic_decoder.cc
+++ b/webrtc/modules/video_coding/generic_decoder.cc
@@ -48,6 +48,16 @@
 
 int32_t VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage,
                                          int64_t decode_time_ms) {
+  Decoded(decodedImage,
+          decode_time_ms >= 0 ? rtc::Optional<int32_t>(decode_time_ms)
+                              : rtc::Optional<int32_t>(),
+          rtc::Optional<uint8_t>());
+  return WEBRTC_VIDEO_CODEC_OK;
+}
+
+void VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage,
+                                      rtc::Optional<int32_t> decode_time_ms,
+                                      rtc::Optional<uint8_t> qp) {
   TRACE_EVENT_INSTANT1("webrtc", "VCMDecodedFrameCallback::Decoded",
                        "timestamp", decodedImage.timestamp());
   // TODO(holmer): We should improve this so that we can handle multiple
@@ -63,15 +73,15 @@
   if (frameInfo == NULL) {
     LOG(LS_WARNING) << "Too many frames backed up in the decoder, dropping "
                        "this one.";
-    return WEBRTC_VIDEO_CODEC_OK;
+    return;
   }
 
   const int64_t now_ms = _clock->TimeInMilliseconds();
-  if (decode_time_ms < 0) {
+  if (!decode_time_ms) {
     decode_time_ms =
-        static_cast<int32_t>(now_ms - frameInfo->decodeStartTimeMs);
+        rtc::Optional<int32_t>(now_ms - frameInfo->decodeStartTimeMs);
   }
-  _timing->StopDecodeTimer(decodedImage.timestamp(), decode_time_ms, now_ms,
+  _timing->StopDecodeTimer(decodedImage.timestamp(), *decode_time_ms, now_ms,
                            frameInfo->renderTimeMs);
 
   decodedImage.set_timestamp_us(
@@ -80,11 +90,10 @@
   // TODO(sakal): Investigate why callback is NULL sometimes and replace if
   // statement with a DCHECK.
   if (callback) {
-    callback->FrameToRender(decodedImage);
+    callback->FrameToRender(decodedImage, qp);
   } else {
     LOG(LS_WARNING) << "No callback, dropping frame.";
   }
-  return WEBRTC_VIDEO_CODEC_OK;
 }
 
 int32_t VCMDecodedFrameCallback::ReceivedDecodedReferenceFrame(
diff --git a/webrtc/modules/video_coding/generic_decoder.h b/webrtc/modules/video_coding/generic_decoder.h
index 2d0007b..48e2519 100644
--- a/webrtc/modules/video_coding/generic_decoder.h
+++ b/webrtc/modules/video_coding/generic_decoder.h
@@ -37,11 +37,13 @@
     void SetUserReceiveCallback(VCMReceiveCallback* receiveCallback);
     VCMReceiveCallback* UserReceiveCallback();
 
-    virtual int32_t Decoded(VideoFrame& decodedImage);  // NOLINT
-    virtual int32_t Decoded(VideoFrame& decodedImage,   // NOLINT
-                            int64_t decode_time_ms);
-    virtual int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId);
-    virtual int32_t ReceivedDecodedFrame(const uint64_t pictureId);
+    int32_t Decoded(VideoFrame& decodedImage) override;
+    int32_t Decoded(VideoFrame& decodedImage, int64_t decode_time_ms) override;
+    void Decoded(VideoFrame& decodedImage,
+                 rtc::Optional<int32_t> decode_time_ms,
+                 rtc::Optional<uint8_t> qp) override;
+    int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId) override;
+    int32_t ReceivedDecodedFrame(const uint64_t pictureId) override;
 
     uint64_t LastReceivedPictureID() const;
     void OnDecoderImplementationName(const char* implementation_name);
diff --git a/webrtc/modules/video_coding/include/mock/mock_video_codec_interface.h b/webrtc/modules/video_coding/include/mock/mock_video_codec_interface.h
index 7e2076c..bbf3098 100644
--- a/webrtc/modules/video_coding/include/mock/mock_video_codec_interface.h
+++ b/webrtc/modules/video_coding/include/mock/mock_video_codec_interface.h
@@ -57,6 +57,10 @@
   MOCK_METHOD2(Decoded,
                int32_t(VideoFrame& decodedImage,  // NOLINT
                        int64_t decode_time_ms));
+  MOCK_METHOD3(Decoded,
+               void(VideoFrame& decodedImage,  // NOLINT
+                    rtc::Optional<int32_t> decode_time_ms,
+                    rtc::Optional<uint8_t> qp));
   MOCK_METHOD1(ReceivedDecodedReferenceFrame,
                int32_t(const uint64_t pictureId));
   MOCK_METHOD1(ReceivedDecodedFrame, int32_t(const uint64_t pictureId));
diff --git a/webrtc/modules/video_coding/include/video_coding_defines.h b/webrtc/modules/video_coding/include/video_coding_defines.h
index 122ddc6..2155461 100644
--- a/webrtc/modules/video_coding/include/video_coding_defines.h
+++ b/webrtc/modules/video_coding/include/video_coding_defines.h
@@ -63,7 +63,8 @@
 // rendered.
 class VCMReceiveCallback {
  public:
-  virtual int32_t FrameToRender(VideoFrame& videoFrame) = 0;  // NOLINT
+  virtual int32_t FrameToRender(VideoFrame& videoFrame,  // NOLINT
+                                rtc::Optional<uint8_t> qp) = 0;
   virtual int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId) {
     return -1;
   }
diff --git a/webrtc/modules/video_coding/test/test_util.cc b/webrtc/modules/video_coding/test/test_util.cc
index 8f5c55f..386b430 100644
--- a/webrtc/modules/video_coding/test/test_util.cc
+++ b/webrtc/modules/video_coding/test/test_util.cc
@@ -97,8 +97,8 @@
   }
 }
 
-int32_t FileOutputFrameReceiver::FrameToRender(
-    webrtc::VideoFrame& video_frame) {
+int32_t FileOutputFrameReceiver::FrameToRender(webrtc::VideoFrame& video_frame,
+                                               rtc::Optional<uint8_t> qp) {
   if (timing_file_ == NULL) {
     std::string basename;
     std::string extension;
diff --git a/webrtc/modules/video_coding/test/test_util.h b/webrtc/modules/video_coding/test/test_util.h
index 45b88b9..86d3ecf 100644
--- a/webrtc/modules/video_coding/test/test_util.h
+++ b/webrtc/modules/video_coding/test/test_util.h
@@ -29,26 +29,18 @@
  public:
   virtual ~NullEvent() {}
 
-  virtual bool Set() { return true; }
+  bool Set() override { return true; }
 
-  virtual bool Reset() { return true; }
-
-  virtual webrtc::EventTypeWrapper Wait(unsigned long max_time) {  // NOLINT
+  webrtc::EventTypeWrapper Wait(unsigned long max_time) override {  // NOLINT
     return webrtc::kEventTimeout;
   }
-
-  virtual bool StartTimer(bool periodic, unsigned long time) {  // NOLINT
-    return true;
-  }
-
-  virtual bool StopTimer() { return true; }
 };
 
 class NullEventFactory : public webrtc::EventFactory {
  public:
   virtual ~NullEventFactory() {}
 
-  virtual webrtc::EventWrapper* CreateEvent() { return new NullEvent; }
+  webrtc::EventWrapper* CreateEvent() override { return new NullEvent; }
 };
 
 class FileOutputFrameReceiver : public webrtc::VCMReceiveCallback {
@@ -57,7 +49,8 @@
   virtual ~FileOutputFrameReceiver();
 
   // VCMReceiveCallback
-  virtual int32_t FrameToRender(webrtc::VideoFrame& video_frame);  // NOLINT
+  int32_t FrameToRender(webrtc::VideoFrame& video_frame,
+                        rtc::Optional<uint8_t> qp) override;
 
  private:
   std::string out_filename_;