Move VideoFrame and related declarations to webrtc/api/video.

Moves webrtc/common_video/rotation.h and parts of
webrtc/common_video/include/video_frame_buffer.h and
webrtc/video_frame.h, and adds to a new GN target api:video_frame_api.

BUG=webrtc:5880

Review-Url: https://codereview.webrtc.org/2517173004
Cr-Commit-Position: refs/heads/master@{#15993}
diff --git a/webrtc/sdk/objc/Framework/Classes/RTCI420Shader.mm b/webrtc/sdk/objc/Framework/Classes/RTCI420Shader.mm
index e0c9642..d325840 100644
--- a/webrtc/sdk/objc/Framework/Classes/RTCI420Shader.mm
+++ b/webrtc/sdk/objc/Framework/Classes/RTCI420Shader.mm
@@ -15,8 +15,8 @@
 #import "RTCShader+Private.h"
 #import "WebRTC/RTCVideoFrame.h"
 
+#include "webrtc/api/video/video_rotation.h"
 #include "webrtc/base/optional.h"
-#include "webrtc/common_video/rotation.h"
 
 // |kNumTextures| must not exceed 8, which is the limit in OpenGLES2. Two sets
 // of 3 textures are used here, one for each of the Y, U and V planes. Having
diff --git a/webrtc/sdk/objc/Framework/Classes/RTCNativeNV12Shader.mm b/webrtc/sdk/objc/Framework/Classes/RTCNativeNV12Shader.mm
index 75a575b..5000dbc 100644
--- a/webrtc/sdk/objc/Framework/Classes/RTCNativeNV12Shader.mm
+++ b/webrtc/sdk/objc/Framework/Classes/RTCNativeNV12Shader.mm
@@ -19,9 +19,9 @@
 #import "RTCShader+Private.h"
 #import "WebRTC/RTCVideoFrame.h"
 
+#include "webrtc/api/video/video_rotation.h"
 #include "webrtc/base/checks.h"
 #include "webrtc/base/optional.h"
-#include "webrtc/common_video/rotation.h"
 
 static const char kNV12FragmentShaderSource[] =
   SHADER_VERSION
diff --git a/webrtc/sdk/objc/Framework/Classes/RTCShader+Private.h b/webrtc/sdk/objc/Framework/Classes/RTCShader+Private.h
index 547d262..ea0f787 100644
--- a/webrtc/sdk/objc/Framework/Classes/RTCShader+Private.h
+++ b/webrtc/sdk/objc/Framework/Classes/RTCShader+Private.h
@@ -18,7 +18,7 @@
 #import <OpenGL/gl3.h>
 #endif
 
-#include "webrtc/common_video/rotation.h"
+#include "webrtc/api/video/video_rotation.h"
 
 RTC_EXTERN const char kRTCVertexShaderSource[];
 
diff --git a/webrtc/sdk/objc/Framework/Classes/RTCVideoFrame+Private.h b/webrtc/sdk/objc/Framework/Classes/RTCVideoFrame+Private.h
index b47ee4b..e844d64 100644
--- a/webrtc/sdk/objc/Framework/Classes/RTCVideoFrame+Private.h
+++ b/webrtc/sdk/objc/Framework/Classes/RTCVideoFrame+Private.h
@@ -10,8 +10,8 @@
 
 #import "WebRTC/RTCVideoFrame.h"
 
-#include "webrtc/common_video/include/video_frame_buffer.h"
-#include "webrtc/common_video/rotation.h"
+#include "webrtc/api/video/video_frame_buffer.h"
+#include "webrtc/api/video/video_rotation.h"
 
 NS_ASSUME_NONNULL_BEGIN
 
diff --git a/webrtc/sdk/objc/Framework/Classes/RTCVideoFrame.mm b/webrtc/sdk/objc/Framework/Classes/RTCVideoFrame.mm
index 4b2b754..5805e30 100644
--- a/webrtc/sdk/objc/Framework/Classes/RTCVideoFrame.mm
+++ b/webrtc/sdk/objc/Framework/Classes/RTCVideoFrame.mm
@@ -12,7 +12,7 @@
 
 #include <memory>
 
-#include "webrtc/common_video/rotation.h"
+#include "webrtc/api/video/video_rotation.h"
 
 @implementation RTCVideoFrame {
   rtc::scoped_refptr<webrtc::VideoFrameBuffer> _videoBuffer;
diff --git a/webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.h b/webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.h
index 8bf949b..6253405 100644
--- a/webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.h
+++ b/webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.h
@@ -13,9 +13,9 @@
 
 #import <AVFoundation/AVFoundation.h>
 
+#include "webrtc/api/video/video_frame.h"
 #include "webrtc/common_video/include/i420_buffer_pool.h"
 #include "webrtc/media/base/videocapturer.h"
-#include "webrtc/video_frame.h"
 
 @class RTCAVFoundationVideoCapturerInternal;
 
diff --git a/webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.mm b/webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.mm
index cecb13c..526cdbe 100644
--- a/webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.mm
+++ b/webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.mm
@@ -17,13 +17,13 @@
 #import "WebRTC/RTCLogging.h"
 
 #include "avfoundationformatmapper.h"
-#include "libyuv/rotate.h"
+
+#include "webrtc/api/video/video_rotation.h"
 #include "webrtc/base/bind.h"
 #include "webrtc/base/checks.h"
 #include "webrtc/base/logging.h"
 #include "webrtc/base/thread.h"
 #include "webrtc/common_video/include/corevideo_frame_buffer.h"
-#include "webrtc/common_video/rotation.h"
 
 namespace webrtc {
 
@@ -160,25 +160,12 @@
   // Applying rotation is only supported for legacy reasons and performance is
   // not critical here.
   if (apply_rotation() && rotation != kVideoRotation_0) {
-    buffer = buffer->NativeToI420Buffer();
-    rtc::scoped_refptr<I420Buffer> rotated_buffer;
-    if (rotation == kVideoRotation_0 || rotation == kVideoRotation_180) {
-      rotated_buffer = I420Buffer::Create(adapted_width, adapted_height);
-    } else {
-      // Swap width and height.
-      rotated_buffer = I420Buffer::Create(adapted_height, adapted_width);
+    buffer = I420Buffer::Rotate(buffer->NativeToI420Buffer(),
+                                rotation);
+    if (rotation == kVideoRotation_90 || rotation == kVideoRotation_270) {
       std::swap(captured_width, captured_height);
     }
-    libyuv::I420Rotate(
-        buffer->DataY(), buffer->StrideY(),
-        buffer->DataU(), buffer->StrideU(),
-        buffer->DataV(), buffer->StrideV(),
-        rotated_buffer->MutableDataY(), rotated_buffer->StrideY(),
-        rotated_buffer->MutableDataU(), rotated_buffer->StrideU(),
-        rotated_buffer->MutableDataV(), rotated_buffer->StrideV(),
-        buffer->width(), buffer->height(),
-        static_cast<libyuv::RotationMode>(rotation));
-    buffer = rotated_buffer;
+
     rotation = kVideoRotation_0;
   }
 
diff --git a/webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_decoder.cc b/webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_decoder.cc
index 31c8baf..2507027 100644
--- a/webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_decoder.cc
+++ b/webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_decoder.cc
@@ -17,6 +17,7 @@
 #include "RTCUIApplication.h"
 #endif
 #include "libyuv/convert.h"
+#include "webrtc/api/video/video_frame.h"
 #include "webrtc/base/checks.h"
 #include "webrtc/base/logging.h"
 #include "webrtc/common_video/include/corevideo_frame_buffer.h"
diff --git a/webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_encoder.h b/webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_encoder.h
index 1cfad21..5de9a24 100644
--- a/webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_encoder.h
+++ b/webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_encoder.h
@@ -12,10 +12,10 @@
 #ifndef WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_H264_VIDEO_TOOLBOX_ENCODER_H_
 #define WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_H264_VIDEO_TOOLBOX_ENCODER_H_
 
+#include "webrtc/api/video/video_rotation.h"
 #include "webrtc/base/criticalsection.h"
 #include "webrtc/common_video/h264/h264_bitstream_parser.h"
 #include "webrtc/common_video/include/bitrate_adjuster.h"
-#include "webrtc/common_video/rotation.h"
 #include "webrtc/media/base/codec.h"
 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
 #include "webrtc/modules/video_coding/utility/quality_scaler.h"