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 "RTCVideoFrame.h" 12*d9f75844SAndroid Build Coastguard Worker 13*d9f75844SAndroid Build Coastguard Worker#import "RTCI420Buffer.h" 14*d9f75844SAndroid Build Coastguard Worker#import "RTCVideoFrameBuffer.h" 15*d9f75844SAndroid Build Coastguard Worker 16*d9f75844SAndroid Build Coastguard Worker@implementation RTC_OBJC_TYPE (RTCVideoFrame) { 17*d9f75844SAndroid Build Coastguard Worker RTCVideoRotation _rotation; 18*d9f75844SAndroid Build Coastguard Worker int64_t _timeStampNs; 19*d9f75844SAndroid Build Coastguard Worker} 20*d9f75844SAndroid Build Coastguard Worker 21*d9f75844SAndroid Build Coastguard Worker@synthesize buffer = _buffer; 22*d9f75844SAndroid Build Coastguard Worker@synthesize timeStamp; 23*d9f75844SAndroid Build Coastguard Worker 24*d9f75844SAndroid Build Coastguard Worker- (int)width { 25*d9f75844SAndroid Build Coastguard Worker return _buffer.width; 26*d9f75844SAndroid Build Coastguard Worker} 27*d9f75844SAndroid Build Coastguard Worker 28*d9f75844SAndroid Build Coastguard Worker- (int)height { 29*d9f75844SAndroid Build Coastguard Worker return _buffer.height; 30*d9f75844SAndroid Build Coastguard Worker} 31*d9f75844SAndroid Build Coastguard Worker 32*d9f75844SAndroid Build Coastguard Worker- (RTCVideoRotation)rotation { 33*d9f75844SAndroid Build Coastguard Worker return _rotation; 34*d9f75844SAndroid Build Coastguard Worker} 35*d9f75844SAndroid Build Coastguard Worker 36*d9f75844SAndroid Build Coastguard Worker- (int64_t)timeStampNs { 37*d9f75844SAndroid Build Coastguard Worker return _timeStampNs; 38*d9f75844SAndroid Build Coastguard Worker} 39*d9f75844SAndroid Build Coastguard Worker 40*d9f75844SAndroid Build Coastguard Worker- (RTC_OBJC_TYPE(RTCVideoFrame) *)newI420VideoFrame { 41*d9f75844SAndroid Build Coastguard Worker return [[RTC_OBJC_TYPE(RTCVideoFrame) alloc] initWithBuffer:[_buffer toI420] 42*d9f75844SAndroid Build Coastguard Worker rotation:_rotation 43*d9f75844SAndroid Build Coastguard Worker timeStampNs:_timeStampNs]; 44*d9f75844SAndroid Build Coastguard Worker} 45*d9f75844SAndroid Build Coastguard Worker 46*d9f75844SAndroid Build Coastguard Worker- (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer 47*d9f75844SAndroid Build Coastguard Worker rotation:(RTCVideoRotation)rotation 48*d9f75844SAndroid Build Coastguard Worker timeStampNs:(int64_t)timeStampNs { 49*d9f75844SAndroid Build Coastguard Worker // Deprecated. 50*d9f75844SAndroid Build Coastguard Worker return nil; 51*d9f75844SAndroid Build Coastguard Worker} 52*d9f75844SAndroid Build Coastguard Worker 53*d9f75844SAndroid Build Coastguard Worker- (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer 54*d9f75844SAndroid Build Coastguard Worker scaledWidth:(int)scaledWidth 55*d9f75844SAndroid Build Coastguard Worker scaledHeight:(int)scaledHeight 56*d9f75844SAndroid Build Coastguard Worker cropWidth:(int)cropWidth 57*d9f75844SAndroid Build Coastguard Worker cropHeight:(int)cropHeight 58*d9f75844SAndroid Build Coastguard Worker cropX:(int)cropX 59*d9f75844SAndroid Build Coastguard Worker cropY:(int)cropY 60*d9f75844SAndroid Build Coastguard Worker rotation:(RTCVideoRotation)rotation 61*d9f75844SAndroid Build Coastguard Worker timeStampNs:(int64_t)timeStampNs { 62*d9f75844SAndroid Build Coastguard Worker // Deprecated. 63*d9f75844SAndroid Build Coastguard Worker return nil; 64*d9f75844SAndroid Build Coastguard Worker} 65*d9f75844SAndroid Build Coastguard Worker 66*d9f75844SAndroid Build Coastguard Worker- (instancetype)initWithBuffer:(id<RTC_OBJC_TYPE(RTCVideoFrameBuffer)>)buffer 67*d9f75844SAndroid Build Coastguard Worker rotation:(RTCVideoRotation)rotation 68*d9f75844SAndroid Build Coastguard Worker timeStampNs:(int64_t)timeStampNs { 69*d9f75844SAndroid Build Coastguard Worker if (self = [super init]) { 70*d9f75844SAndroid Build Coastguard Worker _buffer = buffer; 71*d9f75844SAndroid Build Coastguard Worker _rotation = rotation; 72*d9f75844SAndroid Build Coastguard Worker _timeStampNs = timeStampNs; 73*d9f75844SAndroid Build Coastguard Worker } 74*d9f75844SAndroid Build Coastguard Worker 75*d9f75844SAndroid Build Coastguard Worker return self; 76*d9f75844SAndroid Build Coastguard Worker} 77*d9f75844SAndroid Build Coastguard Worker 78*d9f75844SAndroid Build Coastguard Worker@end 79