blob: a12bd7a86db909ebcf99d16df1d3396cea8a4fea [file] [log] [blame]
Anders Carlsson7bca8ca2018-08-30 09:30:29 +02001/*
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
16NS_ASSUME_NONNULL_BEGIN
17
18/** RTCVideoFrameBuffer containing a CVPixelBufferRef */
19RTC_EXPORT
20@interface RTCCVPixelBuffer : NSObject <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
52NS_ASSUME_NONNULL_END