Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 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 */ |
Mirko Bonadei | e8d5724 | 2018-09-17 10:22:56 +0200 | [diff] [blame] | 19 | RTC_OBJC_EXPORT |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 20 | @interface RTC_OBJC_TYPE (RTCCVPixelBuffer) : NSObject <RTC_OBJC_TYPE(RTCVideoFrameBuffer)> |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 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 | |
Artem Titov | d7ac581 | 2021-07-27 12:23:39 +0200 | [diff] [blame] | 43 | /** The minimum size of the `tmpBuffer` must be the number of bytes returned from the |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 44 | * bufferSizeForCroppingAndScalingToWidth:height: method. |
Artem Titov | d7ac581 | 2021-07-27 12:23:39 +0200 | [diff] [blame] | 45 | * If that size is 0, the `tmpBuffer` may be nil. |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 46 | */ |
| 47 | - (BOOL)cropAndScaleTo:(CVPixelBufferRef)outputPixelBuffer |
| 48 | withTempBuffer:(nullable uint8_t *)tmpBuffer; |
| 49 | |
| 50 | @end |
| 51 | |
| 52 | NS_ASSUME_NONNULL_END |