Introduce VideoFrame::id to keep track of frames inside application.

Also switch webrtc code from deprecated constructors to the builder API.

Change-Id: Ie325bf1e9b4ff1e413fef3431ced8ed9ff725107
Bug: webrtc:10138
Reviewed-on: https://webrtc-review.googlesource.com/c/114422
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26132}
diff --git a/test/fake_decoder.cc b/test/fake_decoder.cc
index c0a2ed6..2114c64 100644
--- a/test/fake_decoder.cc
+++ b/test/fake_decoder.cc
@@ -46,9 +46,12 @@
     height_ = input._encodedHeight;
   }
 
-  VideoFrame frame(I420Buffer::Create(width_, height_),
-                   webrtc::kVideoRotation_0,
-                   render_time_ms * rtc::kNumMicrosecsPerMillisec);
+  VideoFrame frame =
+      VideoFrame::Builder()
+          .set_video_frame_buffer(I420Buffer::Create(width_, height_))
+          .set_rotation(webrtc::kVideoRotation_0)
+          .set_timestamp_ms(render_time_ms)
+          .build();
   frame.set_timestamp(input.Timestamp());
   frame.set_ntp_time_ms(input.ntp_time_ms_);
 
diff --git a/test/fake_texture_frame.cc b/test/fake_texture_frame.cc
index 68d76dc..45d6130 100644
--- a/test/fake_texture_frame.cc
+++ b/test/fake_texture_frame.cc
@@ -21,8 +21,13 @@
                                          uint32_t timestamp,
                                          int64_t render_time_ms,
                                          VideoRotation rotation) {
-  return VideoFrame(new rtc::RefCountedObject<FakeNativeBuffer>(width, height),
-                    timestamp, render_time_ms, rotation);
+  return VideoFrame::Builder()
+      .set_video_frame_buffer(
+          new rtc::RefCountedObject<FakeNativeBuffer>(width, height))
+      .set_timestamp_rtp(timestamp)
+      .set_timestamp_ms(render_time_ms)
+      .set_rotation(rotation)
+      .build();
 }
 
 VideoFrameBuffer::Type FakeNativeBuffer::type() const {
diff --git a/test/fake_vp8_decoder.cc b/test/fake_vp8_decoder.cc
index 1cf6f29..c5ece83 100644
--- a/test/fake_vp8_decoder.cc
+++ b/test/fake_vp8_decoder.cc
@@ -54,9 +54,12 @@
   }
   ParseFakeVp8(input._buffer, &width_, &height_);
 
-  VideoFrame frame(I420Buffer::Create(width_, height_),
-                   webrtc::kVideoRotation_0,
-                   render_time_ms * rtc::kNumMicrosecsPerMillisec);
+  VideoFrame frame =
+      VideoFrame::Builder()
+          .set_video_frame_buffer(I420Buffer::Create(width_, height_))
+          .set_rotation(webrtc::kVideoRotation_0)
+          .set_timestamp_ms(render_time_ms)
+          .build();
   frame.set_timestamp(input.Timestamp());
   frame.set_ntp_time_ms(input.ntp_time_ms_);
 
diff --git a/test/frame_generator.cc b/test/frame_generator.cc
index e400504..9acffb1 100644
--- a/test/frame_generator.cc
+++ b/test/frame_generator.cc
@@ -14,6 +14,7 @@
 #include <cstdio>
 #include <memory>
 
+#include "absl/memory/memory.h"
 #include "api/video/i010_buffer.h"
 #include "api/video/i420_buffer.h"
 #include "api/video/video_frame_buffer.h"
@@ -100,8 +101,12 @@
       buffer = I010Buffer::Copy(*buffer->ToI420());
     }
 
-    frame_.reset(
-        new VideoFrame(buffer, webrtc::kVideoRotation_0, 0 /* timestamp_us */));
+    frame_ = absl::make_unique<VideoFrame>(
+        VideoFrame::Builder()
+            .set_video_frame_buffer(buffer)
+            .set_rotation(webrtc::kVideoRotation_0)
+            .set_timestamp_us(0)
+            .build());
     return frame_.get();
   }
 
@@ -203,8 +208,12 @@
     if (++current_display_count_ >= frame_display_count_)
       current_display_count_ = 0;
 
-    temp_frame_.reset(new VideoFrame(
-        last_read_buffer_, webrtc::kVideoRotation_0, 0 /* timestamp_us */));
+    temp_frame_ = absl::make_unique<VideoFrame>(
+        VideoFrame::Builder()
+            .set_video_frame_buffer(last_read_buffer_)
+            .set_rotation(webrtc::kVideoRotation_0)
+            .set_timestamp_us(0)
+            .build());
     return temp_frame_.get();
   }
 
@@ -260,8 +269,12 @@
     if (++current_display_count_ >= frame_display_count_)
       current_display_count_ = 0;
 
-    frame_.reset(new VideoFrame(buffer_, webrtc::kVideoRotation_0,
-                                0 /* timestamp_us */));
+    frame_ = absl::make_unique<VideoFrame>(
+        VideoFrame::Builder()
+            .set_video_frame_buffer(buffer_)
+            .set_rotation(webrtc::kVideoRotation_0)
+            .set_timestamp_us(0)
+            .build());
     return frame_.get();
   }
 
@@ -393,13 +406,16 @@
     int offset_v = (i420_buffer->StrideV() * (pixels_scrolled_y / 2)) +
                    (pixels_scrolled_x / 2);
 
-    current_frame_ = webrtc::VideoFrame(
-        WrapI420Buffer(target_width_, target_height_,
-                       &i420_buffer->DataY()[offset_y], i420_buffer->StrideY(),
-                       &i420_buffer->DataU()[offset_u], i420_buffer->StrideU(),
-                       &i420_buffer->DataV()[offset_v], i420_buffer->StrideV(),
-                       KeepRefUntilDone(i420_buffer)),
-        kVideoRotation_0, 0);
+    current_frame_ =
+        VideoFrame::Builder()
+            .set_video_frame_buffer(WrapI420Buffer(
+                target_width_, target_height_, &i420_buffer->DataY()[offset_y],
+                i420_buffer->StrideY(), &i420_buffer->DataU()[offset_u],
+                i420_buffer->StrideU(), &i420_buffer->DataV()[offset_v],
+                i420_buffer->StrideV(), KeepRefUntilDone(i420_buffer)))
+            .set_rotation(kVideoRotation_0)
+            .set_timestamp_us(0)
+            .build();
   }
 
   Clock* const clock_;
diff --git a/test/test_video_capturer.cc b/test/test_video_capturer.cc
index 0d57715..ef3d858 100644
--- a/test/test_video_capturer.cc
+++ b/test/test_video_capturer.cc
@@ -41,8 +41,12 @@
     rtc::scoped_refptr<I420Buffer> scaled_buffer =
         I420Buffer::Create(out_width, out_height);
     scaled_buffer->ScaleFrom(*frame.video_frame_buffer()->ToI420());
-    broadcaster_.OnFrame(
-        VideoFrame(scaled_buffer, kVideoRotation_0, frame.timestamp_us()));
+    broadcaster_.OnFrame(VideoFrame::Builder()
+                             .set_video_frame_buffer(scaled_buffer)
+                             .set_rotation(kVideoRotation_0)
+                             .set_timestamp_us(frame.timestamp_us())
+                             .set_id(frame.id())
+                             .build());
   } else {
     // No adaptations needed, just return the frame as is.
     broadcaster_.OnFrame(frame);