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
|
|
|
|
Revert of Split iOS sdk in to separate targets (patchset #1 id:1 of https://codereview.webrtc.org/2890733003/ )
Reason for revert:
Still problems with downstream projects
Original issue's description:
> Reland of Split iOS sdk in to separate targets (patchset #1 id:1 of https://codereview.webrtc.org/2890513002/ )
>
> Reason for revert:
> Fixing downstream breakages
>
> Original issue's description:
> > Revert of Split iOS sdk in to separate targets (patchset #13 id:280001 of https://codereview.webrtc.org/2862543002/ )
> >
> > Reason for revert:
> > Breaking downstream projects.
> >
> > Original issue's description:
> > > Split iOS sdk in to separate targets
> > >
> > > This CL splits the iOS sdk into separate static libraries for video,
> > > audio, ui, common, and peerconnection-related code. This will in the
> > > future make it easier to compile WebRTC without unneeded components.
> > >
> > > BUG=webrtc:4867
> > >
> > > Review-Url: https://codereview.webrtc.org/2862543002
> > > Cr-Commit-Position: refs/heads/master@{#18166}
> > > Committed: https://chromium.googlesource.com/external/webrtc/+/52c83fe7102f566cf35a7533092873d58b38f426
> >
> > TBR=magjed@webrtc.org,denicija@webrtc.org,tkchin@webrtc.org,henrika@webrtc.org,kthelgason@webrtc.org
> > # Skipping CQ checks because original CL landed less than 1 days ago.
> > NOPRESUBMIT=true
> > NOTREECHECKS=true
> > NOTRY=true
> > BUG=webrtc:4867
> >
> > Review-Url: https://codereview.webrtc.org/2890513002
> > Cr-Commit-Position: refs/heads/master@{#18170}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/9756238084707787f735e1294e896e462e459717
>
> TBR=magjed@webrtc.org,denicija@webrtc.org,tkchin@webrtc.org,henrika@webrtc.org,charujain@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:4867
>
> Review-Url: https://codereview.webrtc.org/2890733003
> Cr-Commit-Position: refs/heads/master@{#18174}
> Committed: https://chromium.googlesource.com/external/webrtc/+/d51e042492bedd057bc0cac7828979d5c7369cea
TBR=magjed@webrtc.org,denicija@webrtc.org,tkchin@webrtc.org,henrika@webrtc.org,charujain@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:4867
Review-Url: https://codereview.webrtc.org/2893593002
Cr-Commit-Position: refs/heads/master@{#18182}
2017-05-17 06:52:58 -07:00
|
|
|
#include "webrtc/sdk/objc/Framework/Classes/corevideo_frame_buffer.h"
|
2017-02-21 05:28:48 -08:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2017-02-21 05:28:48 -08:00
|
|
|
- (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer
|
|
|
|
|
rotation:(RTCVideoRotation)rotation
|
|
|
|
|
timeStampNs:(int64_t)timeStampNs {
|
|
|
|
|
rtc::scoped_refptr<webrtc::VideoFrameBuffer> videoBuffer(
|
|
|
|
|
new rtc::RefCountedObject<webrtc::CoreVideoFrameBuffer>(pixelBuffer));
|
|
|
|
|
return [self initWithVideoBuffer:videoBuffer
|
|
|
|
|
rotation:rotation
|
|
|
|
|
timeStampNs:timeStampNs];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer
|
|
|
|
|
scaledWidth:(int)scaledWidth
|
|
|
|
|
scaledHeight:(int)scaledHeight
|
|
|
|
|
cropWidth:(int)cropWidth
|
|
|
|
|
cropHeight:(int)cropHeight
|
|
|
|
|
cropX:(int)cropX
|
|
|
|
|
cropY:(int)cropY
|
|
|
|
|
rotation:(RTCVideoRotation)rotation
|
|
|
|
|
timeStampNs:(int64_t)timeStampNs {
|
|
|
|
|
rtc::scoped_refptr<webrtc::VideoFrameBuffer> videoBuffer(
|
|
|
|
|
new rtc::RefCountedObject<webrtc::CoreVideoFrameBuffer>(
|
|
|
|
|
pixelBuffer,
|
|
|
|
|
scaledWidth, scaledHeight,
|
|
|
|
|
cropWidth, cropHeight,
|
|
|
|
|
cropX, cropY));
|
|
|
|
|
return [self initWithVideoBuffer:videoBuffer
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-28 01:56:41 -07:00
|
|
|
- (rtc::scoped_refptr<webrtc::VideoFrameBuffer>)videoBuffer {
|
|
|
|
|
return _videoBuffer;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-11 09:47:07 -08:00
|
|
|
@end
|