Force copy video frame entirely in OnFrameRendered in DVQA

Force copy video frame including video buffer in
DefaultVideoQualityAnalyzer to ensure that analyzer won't hold any
internal WebRTC buffers.

Bug: webrtc:10138
Change-Id: Ib195233f8b01c855220be1b9743c4f54fc62a22b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168643
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30535}
diff --git a/test/pc/e2e/BUILD.gn b/test/pc/e2e/BUILD.gn
index 9aef78a..9a23527 100644
--- a/test/pc/e2e/BUILD.gn
+++ b/test/pc/e2e/BUILD.gn
@@ -463,6 +463,7 @@
     "../../../api/units:timestamp",
     "../../../api/video:encoded_image",
     "../../../api/video:video_frame",
+    "../../../api/video:video_frame_i420",
     "../../../api/video:video_rtp_headers",
     "../../../common_video",
     "../../../rtc_base:criticalsection",
diff --git a/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc b/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc
index d2b25a8..c20650c 100644
--- a/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc
+++ b/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc
@@ -15,6 +15,7 @@
 #include <utility>
 
 #include "api/units/time_delta.h"
+#include "api/video/i420_buffer.h"
 #include "common_video/libyuv/include/webrtc_libyuv.h"
 #include "rtc_base/logging.h"
 
@@ -224,7 +225,13 @@
 }
 
 void DefaultVideoQualityAnalyzer::OnFrameRendered(
-    const webrtc::VideoFrame& frame) {
+    const webrtc::VideoFrame& raw_frame) {
+  // Copy entire video frame including video buffer to ensure that analyzer
+  // won't hold any WebRTC internal buffers.
+  VideoFrame frame = raw_frame;
+  frame.set_video_frame_buffer(
+      I420Buffer::Copy(*raw_frame.video_frame_buffer()->ToI420()));
+
   rtc::CritScope crit(&lock_);
   auto stats_it = frame_stats_.find(frame.id());
   RTC_DCHECK(stats_it != frame_stats_.end());