blob: 664d9bb904fd9f7d242fd397541f30e6817fd37f [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 */
Mirko Bonadeie8d57242018-09-17 10:22:56 +020019RTC_OBJC_EXPORT
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020020@interface RTC_OBJC_TYPE (RTCCVPixelBuffer) : NSObject <RTC_OBJC_TYPE(RTCVideoFrameBuffer)>
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020021
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
Artem Titovd7ac5812021-07-27 12:23:39 +020043/** The minimum size of the `tmpBuffer` must be the number of bytes returned from the
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020044 * bufferSizeForCroppingAndScalingToWidth:height: method.
Artem Titovd7ac5812021-07-27 12:23:39 +020045 * If that size is 0, the `tmpBuffer` may be nil.
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020046 */
47- (BOOL)cropAndScaleTo:(CVPixelBufferRef)outputPixelBuffer
48 withTempBuffer:(nullable uint8_t *)tmpBuffer;
49
50@end
51
52NS_ASSUME_NONNULL_END