Delete method webrtc::VideoFrame::native_handle.

Instead, use the corresponding method on VideoFrameBuffer. In the process,
reduce code duplication in frame comparison functions used in
the test code.

Make FramesEqual use FrameBufsEqual. Make the latter support texture frames.

The cl also refactors VideoFrame::CopyFrame to use I420Buffer::Copy. This
has possibly undesired side effects of never reusing the frame buffer of
the destination frame, and producing a frame buffer which may use different
stride than the source frame.

BUG=webrtc:5682

Review URL: https://codereview.webrtc.org/1881953002

Cr-Commit-Position: refs/heads/master@{#12373}
diff --git a/webrtc/api/java/jni/androidmediaencoder_jni.cc b/webrtc/api/java/jni/androidmediaencoder_jni.cc
index d9d7a80..1530f00 100644
--- a/webrtc/api/java/jni/androidmediaencoder_jni.cc
+++ b/webrtc/api/java/jni/androidmediaencoder_jni.cc
@@ -666,7 +666,7 @@
         quality_scaler_.GetScaledResolution();
     if (scaled_resolution.width != frame.width() ||
         scaled_resolution.height != frame.height()) {
-      if (frame.native_handle() != nullptr) {
+      if (frame.video_frame_buffer()->native_handle() != nullptr) {
         rtc::scoped_refptr<webrtc::VideoFrameBuffer> scaled_buffer(
             static_cast<AndroidTextureBuffer*>(
                 frame.video_frame_buffer().get())->ScaleAndRotate(
@@ -691,7 +691,7 @@
   const bool key_frame =
       frame_types->front() != webrtc::kVideoFrameDelta || send_key_frame;
   bool encode_status = true;
-  if (!input_frame.native_handle()) {
+  if (!input_frame.video_frame_buffer()->native_handle()) {
     int j_input_buffer_index = jni->CallIntMethod(*j_media_codec_video_encoder_,
         j_dequeue_input_buffer_method_);
     CHECK_EXCEPTION(jni);
@@ -741,7 +741,8 @@
     const webrtc::VideoFrame& frame) {
   RTC_DCHECK(codec_thread_checker_.CalledOnValidThread());
 
-  const bool is_texture_frame = frame.native_handle() != nullptr;
+  const bool is_texture_frame =
+      frame.video_frame_buffer()->native_handle() != nullptr;
   const bool reconfigure_due_to_format = is_texture_frame != use_surface_;
   const bool reconfigure_due_to_size =
       frame.width() != width_ || frame.height() != height_;
@@ -802,8 +803,8 @@
     bool key_frame, const webrtc::VideoFrame& frame) {
   RTC_DCHECK(codec_thread_checker_.CalledOnValidThread());
   RTC_CHECK(use_surface_);
-  NativeHandleImpl* handle =
-      static_cast<NativeHandleImpl*>(frame.native_handle());
+  NativeHandleImpl* handle = static_cast<NativeHandleImpl*>(
+      frame.video_frame_buffer()->native_handle());
   jfloatArray sampling_matrix = jni->NewFloatArray(16);
   jni->SetFloatArrayRegion(sampling_matrix, 0, 16, handle->sampling_matrix);
 
@@ -1256,4 +1257,3 @@
 }
 
 }  // namespace webrtc_jni
-