blob: 0a44b04e6b7425c616134931828e97153c42fe59 [file] [log] [blame]
Jon Hjelle78234952016-01-11 09:47:07 -08001/*
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
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020011#import "RTCVideoFrame.h"
Anders Carlsson9823ee42018-03-07 10:32:03 +010012
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020013#import "RTCI420Buffer.h"
14#import "RTCVideoFrameBuffer.h"
magjedc3c46242017-02-21 05:28:48 -080015
Jon Hjelle78234952016-01-11 09:47:07 -080016@implementation RTCVideoFrame {
magjed7ee51252017-02-21 04:19:46 -080017 RTCVideoRotation _rotation;
magjedfb372f02016-08-10 07:58:29 -070018 int64_t _timeStampNs;
Jon Hjelle78234952016-01-11 09:47:07 -080019}
20
Anders Carlssone5960ce2017-06-22 15:26:30 +020021@synthesize buffer = _buffer;
kthelgasonfb143122017-07-25 07:55:58 -070022@synthesize timeStamp;
Anders Carlssone5960ce2017-06-22 15:26:30 +020023
magjed7ee51252017-02-21 04:19:46 -080024- (int)width {
Anders Carlssone5960ce2017-06-22 15:26:30 +020025 return _buffer.width;
Jon Hjelle78234952016-01-11 09:47:07 -080026}
27
magjed7ee51252017-02-21 04:19:46 -080028- (int)height {
Anders Carlssone5960ce2017-06-22 15:26:30 +020029 return _buffer.height;
magjedfb372f02016-08-10 07:58:29 -070030}
31
magjed7ee51252017-02-21 04:19:46 -080032- (RTCVideoRotation)rotation {
33 return _rotation;
Jon Hjelle78234952016-01-11 09:47:07 -080034}
35
magjedfb372f02016-08-10 07:58:29 -070036- (int64_t)timeStampNs {
37 return _timeStampNs;
tkchin7d06a8c2016-04-04 14:10:43 -070038}
39
magjed7ee51252017-02-21 04:19:46 -080040- (RTCVideoFrame *)newI420VideoFrame {
Anders Carlssone5960ce2017-06-22 15:26:30 +020041 return [[RTCVideoFrame alloc] initWithBuffer:[_buffer toI420]
42 rotation:_rotation
43 timeStampNs:_timeStampNs];
Jon Hjelle78234952016-01-11 09:47:07 -080044}
45
magjedc3c46242017-02-21 05:28:48 -080046- (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer
47 rotation:(RTCVideoRotation)rotation
48 timeStampNs:(int64_t)timeStampNs {
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020049 // Deprecated.
50 return nil;
magjedc3c46242017-02-21 05:28:48 -080051}
52
53- (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer
54 scaledWidth:(int)scaledWidth
55 scaledHeight:(int)scaledHeight
56 cropWidth:(int)cropWidth
57 cropHeight:(int)cropHeight
58 cropX:(int)cropX
59 cropY:(int)cropY
60 rotation:(RTCVideoRotation)rotation
61 timeStampNs:(int64_t)timeStampNs {
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020062 // Deprecated.
63 return nil;
magjedc3c46242017-02-21 05:28:48 -080064}
65
Anders Carlssone5960ce2017-06-22 15:26:30 +020066- (instancetype)initWithBuffer:(id<RTCVideoFrameBuffer>)buffer
67 rotation:(RTCVideoRotation)rotation
68 timeStampNs:(int64_t)timeStampNs {
Jon Hjelle78234952016-01-11 09:47:07 -080069 if (self = [super init]) {
Anders Carlssone5960ce2017-06-22 15:26:30 +020070 _buffer = buffer;
magjedfb372f02016-08-10 07:58:29 -070071 _rotation = rotation;
72 _timeStampNs = timeStampNs;
Jon Hjelle78234952016-01-11 09:47:07 -080073 }
Anders Carlsson0789dab2017-06-21 08:41:26 +000074
Anders Carlssone5960ce2017-06-22 15:26:30 +020075 return self;
Anders Carlsson1cfeb432017-06-22 13:06:39 +000076}
77
Jon Hjelle78234952016-01-11 09:47:07 -080078@end