Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 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 | #import <Foundation/Foundation.h> |
| 13 | |
| 14 | #import "RTCMacros.h" |
| 15 | |
| 16 | NS_ASSUME_NONNULL_BEGIN |
| 17 | |
| 18 | typedef NS_ENUM(NSInteger, RTCVideoRotation) { |
| 19 | RTCVideoRotation_0 = 0, |
| 20 | RTCVideoRotation_90 = 90, |
| 21 | RTCVideoRotation_180 = 180, |
| 22 | RTCVideoRotation_270 = 270, |
| 23 | }; |
| 24 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 25 | @protocol RTC_OBJC_TYPE |
| 26 | (RTCVideoFrameBuffer); |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 27 | |
| 28 | // RTCVideoFrame is an ObjectiveC version of webrtc::VideoFrame. |
Mirko Bonadei | e8d5724 | 2018-09-17 10:22:56 +0200 | [diff] [blame] | 29 | RTC_OBJC_EXPORT |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 30 | @interface RTC_OBJC_TYPE (RTCVideoFrame) : NSObject |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 31 | |
| 32 | /** Width without rotation applied. */ |
| 33 | @property(nonatomic, readonly) int width; |
| 34 | |
| 35 | /** Height without rotation applied. */ |
| 36 | @property(nonatomic, readonly) int height; |
| 37 | @property(nonatomic, readonly) RTCVideoRotation rotation; |
| 38 | |
| 39 | /** Timestamp in nanoseconds. */ |
| 40 | @property(nonatomic, readonly) int64_t timeStampNs; |
| 41 | |
| 42 | /** Timestamp 90 kHz. */ |
| 43 | @property(nonatomic, assign) int32_t timeStamp; |
| 44 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 45 | @property(nonatomic, readonly) id<RTC_OBJC_TYPE(RTCVideoFrameBuffer)> buffer; |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 46 | |
| 47 | - (instancetype)init NS_UNAVAILABLE; |
| 48 | - (instancetype) new NS_UNAVAILABLE; |
| 49 | |
| 50 | /** Initialize an RTCVideoFrame from a pixel buffer, rotation, and timestamp. |
| 51 | * Deprecated - initialize with a RTCCVPixelBuffer instead |
| 52 | */ |
| 53 | - (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer |
| 54 | rotation:(RTCVideoRotation)rotation |
| 55 | timeStampNs:(int64_t)timeStampNs |
| 56 | DEPRECATED_MSG_ATTRIBUTE("use initWithBuffer instead"); |
| 57 | |
| 58 | /** Initialize an RTCVideoFrame from a pixel buffer combined with cropping and |
| 59 | * scaling. Cropping will be applied first on the pixel buffer, followed by |
| 60 | * scaling to the final resolution of scaledWidth x scaledHeight. |
| 61 | */ |
| 62 | - (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer |
| 63 | scaledWidth:(int)scaledWidth |
| 64 | scaledHeight:(int)scaledHeight |
| 65 | cropWidth:(int)cropWidth |
| 66 | cropHeight:(int)cropHeight |
| 67 | cropX:(int)cropX |
| 68 | cropY:(int)cropY |
| 69 | rotation:(RTCVideoRotation)rotation |
| 70 | timeStampNs:(int64_t)timeStampNs |
| 71 | DEPRECATED_MSG_ATTRIBUTE("use initWithBuffer instead"); |
| 72 | |
| 73 | /** Initialize an RTCVideoFrame from a frame buffer, rotation, and timestamp. |
| 74 | */ |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 75 | - (instancetype)initWithBuffer:(id<RTC_OBJC_TYPE(RTCVideoFrameBuffer)>)frameBuffer |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 76 | rotation:(RTCVideoRotation)rotation |
| 77 | timeStampNs:(int64_t)timeStampNs; |
| 78 | |
| 79 | /** Return a frame that is guaranteed to be I420, i.e. it is possible to access |
| 80 | * the YUV data on it. |
| 81 | */ |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 82 | - (RTC_OBJC_TYPE(RTCVideoFrame) *)newI420VideoFrame; |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 83 | |
| 84 | @end |
| 85 | |
| 86 | NS_ASSUME_NONNULL_END |