blob: 0403557f75128996f122cd6b802708ca2f7ec929 [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
tkchin9eeb6242016-04-27 01:54:20 -070011#import "RTCVideoFrame+Private.h"
Jon Hjelle78234952016-01-11 09:47:07 -080012
Jon Hjelle78234952016-01-11 09:47:07 -080013@implementation RTCVideoFrame {
magjedfb372f02016-08-10 07:58:29 -070014 rtc::scoped_refptr<webrtc::VideoFrameBuffer> _videoBuffer;
magjed7ee51252017-02-21 04:19:46 -080015 RTCVideoRotation _rotation;
magjedfb372f02016-08-10 07:58:29 -070016 int64_t _timeStampNs;
Jon Hjelle78234952016-01-11 09:47:07 -080017}
18
magjed7ee51252017-02-21 04:19:46 -080019- (int)width {
magjedfb372f02016-08-10 07:58:29 -070020 return _videoBuffer->width();
Jon Hjelle78234952016-01-11 09:47:07 -080021}
22
magjed7ee51252017-02-21 04:19:46 -080023- (int)height {
magjedfb372f02016-08-10 07:58:29 -070024 return _videoBuffer->height();
25}
26
magjed7ee51252017-02-21 04:19:46 -080027- (RTCVideoRotation)rotation {
28 return _rotation;
Jon Hjelle78234952016-01-11 09:47:07 -080029}
30
magjed7ee51252017-02-21 04:19:46 -080031- (const uint8_t *)dataY {
32 return _videoBuffer->DataY();
Jon Hjelle78234952016-01-11 09:47:07 -080033}
34
magjed7ee51252017-02-21 04:19:46 -080035- (const uint8_t *)dataU {
36 return _videoBuffer->DataU();
Jon Hjelle78234952016-01-11 09:47:07 -080037}
38
magjed7ee51252017-02-21 04:19:46 -080039- (const uint8_t *)dataV {
40 return _videoBuffer->DataV();
Jon Hjelle78234952016-01-11 09:47:07 -080041}
42
magjed7ee51252017-02-21 04:19:46 -080043- (int)strideY {
44 return _videoBuffer->StrideY();
Jon Hjelle78234952016-01-11 09:47:07 -080045}
46
magjed7ee51252017-02-21 04:19:46 -080047- (int)strideU {
48 return _videoBuffer->StrideU();
Jon Hjelle78234952016-01-11 09:47:07 -080049}
50
magjed7ee51252017-02-21 04:19:46 -080051- (int)strideV {
52 return _videoBuffer->StrideV();
tkchin7d06a8c2016-04-04 14:10:43 -070053}
54
magjedfb372f02016-08-10 07:58:29 -070055- (int64_t)timeStampNs {
56 return _timeStampNs;
tkchin7d06a8c2016-04-04 14:10:43 -070057}
58
59- (CVPixelBufferRef)nativeHandle {
magjedfb372f02016-08-10 07:58:29 -070060 return static_cast<CVPixelBufferRef>(_videoBuffer->native_handle());
tkchin7d06a8c2016-04-04 14:10:43 -070061}
62
magjed7ee51252017-02-21 04:19:46 -080063- (RTCVideoFrame *)newI420VideoFrame {
64 return [[RTCVideoFrame alloc]
65 initWithVideoBuffer:_videoBuffer->NativeToI420Buffer()
66 rotation:_rotation
67 timeStampNs:_timeStampNs];
Jon Hjelle78234952016-01-11 09:47:07 -080068}
69
70#pragma mark - Private
71
magjedfb372f02016-08-10 07:58:29 -070072- (instancetype)initWithVideoBuffer:
73 (rtc::scoped_refptr<webrtc::VideoFrameBuffer>)videoBuffer
magjed7ee51252017-02-21 04:19:46 -080074 rotation:(RTCVideoRotation)rotation
magjedfb372f02016-08-10 07:58:29 -070075 timeStampNs:(int64_t)timeStampNs {
Jon Hjelle78234952016-01-11 09:47:07 -080076 if (self = [super init]) {
magjedfb372f02016-08-10 07:58:29 -070077 _videoBuffer = videoBuffer;
78 _rotation = rotation;
79 _timeStampNs = timeStampNs;
Jon Hjelle78234952016-01-11 09:47:07 -080080 }
81 return self;
82}
83
Jon Hjelle78234952016-01-11 09:47:07 -080084@end