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 25 @protocol RTC_OBJC_TYPE 26 (RTCVideoFrameBuffer); 27 28 // RTCVideoFrame is an ObjectiveC version of webrtc::VideoFrame. 29 RTC_OBJC_EXPORT 30 @interface RTC_OBJC_TYPE (RTCVideoFrame) : NSObject 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 45 @property(nonatomic, readonly) id<RTC_OBJC_TYPE(RTCVideoFrameBuffer)> buffer; 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 */ 75 - (instancetype)initWithBuffer:(id<RTC_OBJC_TYPE(RTCVideoFrameBuffer)>)frameBuffer 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 */ 82 - (RTC_OBJC_TYPE(RTCVideoFrame) *)newI420VideoFrame; 83 84 @end 85 86 NS_ASSUME_NONNULL_END 87