• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2018 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #import <AVFoundation/AVFoundation.h>
12 
13 #import "RTCMacros.h"
14 #import "RTCVideoFrameBuffer.h"
15 
16 NS_ASSUME_NONNULL_BEGIN
17 
18 /** RTCVideoFrameBuffer containing a CVPixelBufferRef */
19 RTC_OBJC_EXPORT
20 @interface RTC_OBJC_TYPE (RTCCVPixelBuffer) : NSObject <RTC_OBJC_TYPE(RTCVideoFrameBuffer)>
21 
22 @property(nonatomic, readonly) CVPixelBufferRef pixelBuffer;
23 @property(nonatomic, readonly) int cropX;
24 @property(nonatomic, readonly) int cropY;
25 @property(nonatomic, readonly) int cropWidth;
26 @property(nonatomic, readonly) int cropHeight;
27 
28 + (NSSet<NSNumber *> *)supportedPixelFormats;
29 
30 - (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer;
31 - (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer
32                        adaptedWidth:(int)adaptedWidth
33                       adaptedHeight:(int)adaptedHeight
34                           cropWidth:(int)cropWidth
35                          cropHeight:(int)cropHeight
36                               cropX:(int)cropX
37                               cropY:(int)cropY;
38 
39 - (BOOL)requiresCropping;
40 - (BOOL)requiresScalingToWidth:(int)width height:(int)height;
41 - (int)bufferSizeForCroppingAndScalingToWidth:(int)width height:(int)height;
42 
43 /** The minimum size of the |tmpBuffer| must be the number of bytes returned from the
44  * bufferSizeForCroppingAndScalingToWidth:height: method.
45  * If that size is 0, the |tmpBuffer| may be nil.
46  */
47 - (BOOL)cropAndScaleTo:(CVPixelBufferRef)outputPixelBuffer
48         withTempBuffer:(nullable uint8_t *)tmpBuffer;
49 
50 @end
51 
52 NS_ASSUME_NONNULL_END
53