2016-01-11 09:47:07 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright 2015 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2016-04-27 01:54:20 -07:00
|
|
|
#import "RTCVideoFrame+Private.h"
|
2016-01-11 09:47:07 -08:00
|
|
|
|
|
|
|
|
@implementation RTCVideoFrame {
|
2016-08-10 07:58:29 -07:00
|
|
|
rtc::scoped_refptr<webrtc::VideoFrameBuffer> _videoBuffer;
|
2017-02-21 04:19:46 -08:00
|
|
|
RTCVideoRotation _rotation;
|
2016-08-10 07:58:29 -07:00
|
|
|
int64_t _timeStampNs;
|
2016-01-11 09:47:07 -08:00
|
|
|
}
|
|
|
|
|
|
2017-02-21 04:19:46 -08:00
|
|
|
- (int)width {
|
2016-08-10 07:58:29 -07:00
|
|
|
return _videoBuffer->width();
|
2016-01-11 09:47:07 -08:00
|
|
|
}
|
|
|
|
|
|
2017-02-21 04:19:46 -08:00
|
|
|
- (int)height {
|
2016-08-10 07:58:29 -07:00
|
|
|
return _videoBuffer->height();
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-21 04:19:46 -08:00
|
|
|
- (RTCVideoRotation)rotation {
|
|
|
|
|
return _rotation;
|
2016-01-11 09:47:07 -08:00
|
|
|
}
|
|
|
|
|
|
2017-02-21 04:19:46 -08:00
|
|
|
- (const uint8_t *)dataY {
|
|
|
|
|
return _videoBuffer->DataY();
|
2016-01-11 09:47:07 -08:00
|
|
|
}
|
|
|
|
|
|
2017-02-21 04:19:46 -08:00
|
|
|
- (const uint8_t *)dataU {
|
|
|
|
|
return _videoBuffer->DataU();
|
2016-01-11 09:47:07 -08:00
|
|
|
}
|
|
|
|
|
|
2017-02-21 04:19:46 -08:00
|
|
|
- (const uint8_t *)dataV {
|
|
|
|
|
return _videoBuffer->DataV();
|
2016-01-11 09:47:07 -08:00
|
|
|
}
|
|
|
|
|
|
2017-02-21 04:19:46 -08:00
|
|
|
- (int)strideY {
|
|
|
|
|
return _videoBuffer->StrideY();
|
2016-01-11 09:47:07 -08:00
|
|
|
}
|
|
|
|
|
|
2017-02-21 04:19:46 -08:00
|
|
|
- (int)strideU {
|
|
|
|
|
return _videoBuffer->StrideU();
|
2016-01-11 09:47:07 -08:00
|
|
|
}
|
|
|
|
|
|
2017-02-21 04:19:46 -08:00
|
|
|
- (int)strideV {
|
|
|
|
|
return _videoBuffer->StrideV();
|
2016-04-04 14:10:43 -07:00
|
|
|
}
|
|
|
|
|
|
2016-08-10 07:58:29 -07:00
|
|
|
- (int64_t)timeStampNs {
|
|
|
|
|
return _timeStampNs;
|
2016-04-04 14:10:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (CVPixelBufferRef)nativeHandle {
|
2016-08-10 07:58:29 -07:00
|
|
|
return static_cast<CVPixelBufferRef>(_videoBuffer->native_handle());
|
2016-04-04 14:10:43 -07:00
|
|
|
}
|
|
|
|
|
|
2017-02-21 04:19:46 -08:00
|
|
|
- (RTCVideoFrame *)newI420VideoFrame {
|
|
|
|
|
return [[RTCVideoFrame alloc]
|
|
|
|
|
initWithVideoBuffer:_videoBuffer->NativeToI420Buffer()
|
|
|
|
|
rotation:_rotation
|
|
|
|
|
timeStampNs:_timeStampNs];
|
2016-01-11 09:47:07 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - Private
|
|
|
|
|
|
2016-08-10 07:58:29 -07:00
|
|
|
- (instancetype)initWithVideoBuffer:
|
|
|
|
|
(rtc::scoped_refptr<webrtc::VideoFrameBuffer>)videoBuffer
|
2017-02-21 04:19:46 -08:00
|
|
|
rotation:(RTCVideoRotation)rotation
|
2016-08-10 07:58:29 -07:00
|
|
|
timeStampNs:(int64_t)timeStampNs {
|
2016-01-11 09:47:07 -08:00
|
|
|
if (self = [super init]) {
|
2016-08-10 07:58:29 -07:00
|
|
|
_videoBuffer = videoBuffer;
|
|
|
|
|
_rotation = rotation;
|
|
|
|
|
_timeStampNs = timeStampNs;
|
2016-01-11 09:47:07 -08:00
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|