1*d9f75844SAndroid Build Coastguard Worker /* 2*d9f75844SAndroid Build Coastguard Worker * Copyright 2015 The WebRTC project authors. All Rights Reserved. 3*d9f75844SAndroid Build Coastguard Worker * 4*d9f75844SAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license 5*d9f75844SAndroid Build Coastguard Worker * that can be found in the LICENSE file in the root of the source 6*d9f75844SAndroid Build Coastguard Worker * tree. An additional intellectual property rights grant can be found 7*d9f75844SAndroid Build Coastguard Worker * in the file PATENTS. All contributing project authors may 8*d9f75844SAndroid Build Coastguard Worker * be found in the AUTHORS file in the root of the source tree. 9*d9f75844SAndroid Build Coastguard Worker */ 10*d9f75844SAndroid Build Coastguard Worker 11*d9f75844SAndroid Build Coastguard Worker #import <AVFoundation/AVFoundation.h> 12*d9f75844SAndroid Build Coastguard Worker #import <Foundation/Foundation.h> 13*d9f75844SAndroid Build Coastguard Worker 14*d9f75844SAndroid Build Coastguard Worker #import "RTCMacros.h" 15*d9f75844SAndroid Build Coastguard Worker 16*d9f75844SAndroid Build Coastguard Worker NS_ASSUME_NONNULL_BEGIN 17*d9f75844SAndroid Build Coastguard Worker 18*d9f75844SAndroid Build Coastguard Worker typedef NS_ENUM(NSInteger, RTCVideoRotation) { 19*d9f75844SAndroid Build Coastguard Worker RTCVideoRotation_0 = 0, 20*d9f75844SAndroid Build Coastguard Worker RTCVideoRotation_90 = 90, 21*d9f75844SAndroid Build Coastguard Worker RTCVideoRotation_180 = 180, 22*d9f75844SAndroid Build Coastguard Worker RTCVideoRotation_270 = 270, 23*d9f75844SAndroid Build Coastguard Worker }; 24*d9f75844SAndroid Build Coastguard Worker 25*d9f75844SAndroid Build Coastguard Worker @protocol RTC_OBJC_TYPE 26*d9f75844SAndroid Build Coastguard Worker (RTCVideoFrameBuffer); 27*d9f75844SAndroid Build Coastguard Worker 28*d9f75844SAndroid Build Coastguard Worker // RTCVideoFrame is an ObjectiveC version of webrtc::VideoFrame. 29*d9f75844SAndroid Build Coastguard Worker RTC_OBJC_EXPORT 30*d9f75844SAndroid Build Coastguard Worker @interface RTC_OBJC_TYPE (RTCVideoFrame) : NSObject 31*d9f75844SAndroid Build Coastguard Worker 32*d9f75844SAndroid Build Coastguard Worker /** Width without rotation applied. */ 33*d9f75844SAndroid Build Coastguard Worker @property(nonatomic, readonly) int width; 34*d9f75844SAndroid Build Coastguard Worker 35*d9f75844SAndroid Build Coastguard Worker /** Height without rotation applied. */ 36*d9f75844SAndroid Build Coastguard Worker @property(nonatomic, readonly) int height; 37*d9f75844SAndroid Build Coastguard Worker @property(nonatomic, readonly) RTCVideoRotation rotation; 38*d9f75844SAndroid Build Coastguard Worker 39*d9f75844SAndroid Build Coastguard Worker /** Timestamp in nanoseconds. */ 40*d9f75844SAndroid Build Coastguard Worker @property(nonatomic, readonly) int64_t timeStampNs; 41*d9f75844SAndroid Build Coastguard Worker 42*d9f75844SAndroid Build Coastguard Worker /** Timestamp 90 kHz. */ 43*d9f75844SAndroid Build Coastguard Worker @property(nonatomic, assign) int32_t timeStamp; 44*d9f75844SAndroid Build Coastguard Worker 45*d9f75844SAndroid Build Coastguard Worker @property(nonatomic, readonly) id<RTC_OBJC_TYPE(RTCVideoFrameBuffer)> buffer; 46*d9f75844SAndroid Build Coastguard Worker 47*d9f75844SAndroid Build Coastguard Worker - (instancetype)init NS_UNAVAILABLE; 48*d9f75844SAndroid Build Coastguard Worker - (instancetype) new NS_UNAVAILABLE; 49*d9f75844SAndroid Build Coastguard Worker 50*d9f75844SAndroid Build Coastguard Worker /** Initialize an RTCVideoFrame from a pixel buffer, rotation, and timestamp. 51*d9f75844SAndroid Build Coastguard Worker * Deprecated - initialize with a RTCCVPixelBuffer instead 52*d9f75844SAndroid Build Coastguard Worker */ 53*d9f75844SAndroid Build Coastguard Worker - (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer 54*d9f75844SAndroid Build Coastguard Worker rotation:(RTCVideoRotation)rotation 55*d9f75844SAndroid Build Coastguard Worker timeStampNs:(int64_t)timeStampNs 56*d9f75844SAndroid Build Coastguard Worker DEPRECATED_MSG_ATTRIBUTE("use initWithBuffer instead"); 57*d9f75844SAndroid Build Coastguard Worker 58*d9f75844SAndroid Build Coastguard Worker /** Initialize an RTCVideoFrame from a pixel buffer combined with cropping and 59*d9f75844SAndroid Build Coastguard Worker * scaling. Cropping will be applied first on the pixel buffer, followed by 60*d9f75844SAndroid Build Coastguard Worker * scaling to the final resolution of scaledWidth x scaledHeight. 61*d9f75844SAndroid Build Coastguard Worker */ 62*d9f75844SAndroid Build Coastguard Worker - (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer 63*d9f75844SAndroid Build Coastguard Worker scaledWidth:(int)scaledWidth 64*d9f75844SAndroid Build Coastguard Worker scaledHeight:(int)scaledHeight 65*d9f75844SAndroid Build Coastguard Worker cropWidth:(int)cropWidth 66*d9f75844SAndroid Build Coastguard Worker cropHeight:(int)cropHeight 67*d9f75844SAndroid Build Coastguard Worker cropX:(int)cropX 68*d9f75844SAndroid Build Coastguard Worker cropY:(int)cropY 69*d9f75844SAndroid Build Coastguard Worker rotation:(RTCVideoRotation)rotation 70*d9f75844SAndroid Build Coastguard Worker timeStampNs:(int64_t)timeStampNs 71*d9f75844SAndroid Build Coastguard Worker DEPRECATED_MSG_ATTRIBUTE("use initWithBuffer instead"); 72*d9f75844SAndroid Build Coastguard Worker 73*d9f75844SAndroid Build Coastguard Worker /** Initialize an RTCVideoFrame from a frame buffer, rotation, and timestamp. 74*d9f75844SAndroid Build Coastguard Worker */ 75*d9f75844SAndroid Build Coastguard Worker - (instancetype)initWithBuffer:(id<RTC_OBJC_TYPE(RTCVideoFrameBuffer)>)frameBuffer 76*d9f75844SAndroid Build Coastguard Worker rotation:(RTCVideoRotation)rotation 77*d9f75844SAndroid Build Coastguard Worker timeStampNs:(int64_t)timeStampNs; 78*d9f75844SAndroid Build Coastguard Worker 79*d9f75844SAndroid Build Coastguard Worker /** Return a frame that is guaranteed to be I420, i.e. it is possible to access 80*d9f75844SAndroid Build Coastguard Worker * the YUV data on it. 81*d9f75844SAndroid Build Coastguard Worker */ 82*d9f75844SAndroid Build Coastguard Worker - (RTC_OBJC_TYPE(RTCVideoFrame) *)newI420VideoFrame; 83*d9f75844SAndroid Build Coastguard Worker 84*d9f75844SAndroid Build Coastguard Worker @end 85*d9f75844SAndroid Build Coastguard Worker 86*d9f75844SAndroid Build Coastguard Worker NS_ASSUME_NONNULL_END 87