From 173658968e80cc25e98038feb05efd750bdb8e9d Mon Sep 17 00:00:00 2001 From: magjed Date: Thu, 4 May 2017 03:41:33 -0700 Subject: [PATCH] Reland of Move CoreVideoFrameBuffer from webrtc/common_video/ to webrtc/sdk/objc/ (patchset #1 id:1 of https://codereview.webrtc.org/2862663003/ ) Reason for revert: Keep header file for backwards compatibility Original issue's description: > Revert of Move CoreVideoFrameBuffer from webrtc/common_video/ to webrtc/sdk/objc/ (patchset #2 id:60001 of https://codereview.webrtc.org/2851563003/ ) > > Reason for revert: > Breaks downstream targets. > > Original issue's description: > > Move CoreVideoFrameBuffer from webrtc/common_video/ to webrtc/sdk/objc/ > > > > CoreVideoFrameBuffer is Mac/iPhone specific and should be moved into > > the webrtc/sdk/objc/ folder. > > > > BUG=None > > > > Review-Url: https://codereview.webrtc.org/2851563003 > > Cr-Commit-Position: refs/heads/master@{#17998} > > Committed: https://chromium.googlesource.com/external/webrtc/+/d41631aa274e926c4fba1600cbcfbc18020eb35a > > TBR=kthelgason@webrtc.org,magjed@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=None > > Review-Url: https://codereview.webrtc.org/2862663003 > Cr-Commit-Position: refs/heads/master@{#18004} > Committed: https://chromium.googlesource.com/external/webrtc/+/c34e730896032ae730b5917306bb4f79e62d03dd TBR=kthelgason@webrtc.org,ehmaldonado@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=None Review-Url: https://codereview.webrtc.org/2860033002 Cr-Commit-Position: refs/heads/master@{#18011} --- webrtc/common_video/DEPS | 2 + .../include/corevideo_frame_buffer.h | 48 +-------------- .../Classes/corevideo_frame_buffer.h | 59 +++++++++++++++++++ 3 files changed, 64 insertions(+), 45 deletions(-) create mode 100644 webrtc/sdk/objc/Framework/Classes/corevideo_frame_buffer.h diff --git a/webrtc/common_video/DEPS b/webrtc/common_video/DEPS index ad03e66169..7dbbdb4f95 100644 --- a/webrtc/common_video/DEPS +++ b/webrtc/common_video/DEPS @@ -2,4 +2,6 @@ include_rules = [ "+webrtc/base", "+webrtc/media/base", "+webrtc/system_wrappers", + # TODO(magjed): This is temporary, remove once external clients are updated. + "+webrtc/sdk/objc", ] diff --git a/webrtc/common_video/include/corevideo_frame_buffer.h b/webrtc/common_video/include/corevideo_frame_buffer.h index a00b6770ff..44ef1db0c5 100644 --- a/webrtc/common_video/include/corevideo_frame_buffer.h +++ b/webrtc/common_video/include/corevideo_frame_buffer.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 The WebRTC project authors. All Rights Reserved. + * Copyright 2017 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -8,52 +8,10 @@ * be found in the AUTHORS file in the root of the source tree. */ +// TODO(magjed): Remove this file once external clients are updated. #ifndef WEBRTC_COMMON_VIDEO_INCLUDE_COREVIDEO_FRAME_BUFFER_H_ #define WEBRTC_COMMON_VIDEO_INCLUDE_COREVIDEO_FRAME_BUFFER_H_ -#include - -#include - -#include "webrtc/common_video/include/video_frame_buffer.h" - -namespace webrtc { - -class CoreVideoFrameBuffer : public NativeHandleBuffer { - public: - explicit CoreVideoFrameBuffer(CVPixelBufferRef pixel_buffer); - CoreVideoFrameBuffer(CVPixelBufferRef pixel_buffer, - int adapted_width, - int adapted_height, - int crop_width, - int crop_height, - int crop_x, - int crop_y); - ~CoreVideoFrameBuffer() override; - - rtc::scoped_refptr NativeToI420Buffer() override; - // Returns true if the internal pixel buffer needs to be cropped. - bool RequiresCropping() const; - // Crop and scales the internal pixel buffer to the output pixel buffer. The - // tmp buffer is used for intermediary splitting the UV channels. This - // function returns true if successful. - bool CropAndScaleTo(std::vector* tmp_buffer, - CVPixelBufferRef output_pixel_buffer) const; - - private: - CVPixelBufferRef pixel_buffer_; - // buffer_width/height is the actual pixel buffer resolution. The width/height - // in NativeHandleBuffer, i.e. width()/height(), is the resolution we will - // scale to in NativeToI420Buffer(). Cropping happens before scaling, so: - // buffer_width >= crop_width >= width(). - const int buffer_width_; - const int buffer_height_; - const int crop_width_; - const int crop_height_; - const int crop_x_; - const int crop_y_; -}; - -} // namespace webrtc +#include "webrtc/sdk/objc/Framework/Classes/corevideo_frame_buffer.h" #endif // WEBRTC_COMMON_VIDEO_INCLUDE_COREVIDEO_FRAME_BUFFER_H_ diff --git a/webrtc/sdk/objc/Framework/Classes/corevideo_frame_buffer.h b/webrtc/sdk/objc/Framework/Classes/corevideo_frame_buffer.h new file mode 100644 index 0000000000..3bf6498f32 --- /dev/null +++ b/webrtc/sdk/objc/Framework/Classes/corevideo_frame_buffer.h @@ -0,0 +1,59 @@ +/* + * Copyright 2016 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_COREVIDEO_FRAME_BUFFER_H_ +#define WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_COREVIDEO_FRAME_BUFFER_H_ + +#include + +#include + +#include "webrtc/common_video/include/video_frame_buffer.h" + +namespace webrtc { + +class CoreVideoFrameBuffer : public NativeHandleBuffer { + public: + explicit CoreVideoFrameBuffer(CVPixelBufferRef pixel_buffer); + CoreVideoFrameBuffer(CVPixelBufferRef pixel_buffer, + int adapted_width, + int adapted_height, + int crop_width, + int crop_height, + int crop_x, + int crop_y); + ~CoreVideoFrameBuffer() override; + + rtc::scoped_refptr NativeToI420Buffer() override; + // Returns true if the internal pixel buffer needs to be cropped. + bool RequiresCropping() const; + // Crop and scales the internal pixel buffer to the output pixel buffer. The + // tmp buffer is used for intermediary splitting the UV channels. This + // function returns true if successful. + bool CropAndScaleTo(std::vector* tmp_buffer, + CVPixelBufferRef output_pixel_buffer) const; + + private: + CVPixelBufferRef pixel_buffer_; + // buffer_width/height is the actual pixel buffer resolution. The width/height + // in NativeHandleBuffer, i.e. width()/height(), is the resolution we will + // scale to in NativeToI420Buffer(). Cropping happens before scaling, so: + // buffer_width >= crop_width >= width(). + const int buffer_width_; + const int buffer_height_; + const int crop_width_; + const int crop_height_; + const int crop_x_; + const int crop_y_; +}; + +} // namespace webrtc + +#endif // WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_COREVIDEO_FRAME_BUFFER_H_