Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

125 lines
2.6 KiB
Plaintext
Raw Normal View History

/*
* 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.
*/
#import "RTCVideoFrame+Private.h"
#include <memory>
#include "webrtc/common_video/rotation.h"
@implementation RTCVideoFrame {
rtc::scoped_refptr<webrtc::VideoFrameBuffer> _videoBuffer;
webrtc::VideoRotation _rotation;
int64_t _timeStampNs;
rtc::scoped_refptr<webrtc::VideoFrameBuffer> _i420Buffer;
}
- (size_t)width {
return _videoBuffer->width();
}
- (size_t)height {
return _videoBuffer->height();
}
- (int)rotation {
return static_cast<int>(_rotation);
}
// TODO(nisse): chromaWidth and chromaHeight are used only in
// RTCOpenGLVideoRenderer.mm. Update, and then delete these
// properties.
- (size_t)chromaWidth {
return (self.width + 1) / 2;
}
- (size_t)chromaHeight {
return (self.height + 1) / 2;
}
- (const uint8_t *)yPlane {
if (!self.i420Buffer) {
return nullptr;
}
Partial reland of Delete unused and almost unused frame-related methods. (patchset #1 id:1 of https://codereview.webrtc.org/2076113002/ ) Reason for revert: Taking out the VideoFrameBuffer changes which broke downstream. Original issue's description: > Revert of Delete unused and almost unused frame-related methods. (patchset #12 id:220001 of https://codereview.webrtc.org/2065733003/ ) > > Reason for revert: > Breaks downstream applications which inherits webrtc::VideoFrameBuffer and tries to override deleted methods data(), stride() and MutableData(). > > Original issue's description: > > Delete unused and almost unused frame-related methods. > > > > webrtc::VideoFrame::set_video_frame_buffer > > webrtc::VideoFrame::ConvertNativeToI420Frame > > > > cricket::WebRtcVideoFrame::InitToBlack > > > > VideoFrameBuffer::data > > VideoFrameBuffer::stride > > VideoFrameBuffer::MutableData > > > > TBR=tkchin@webrtc.org # Refactoring affecting RTCVideoFrame > > BUG=webrtc:5682 > > > > Committed: https://crrev.com/76270de4bc2dac188f10f805e6e2fb86693ef864 > > Cr-Commit-Position: refs/heads/master@{#13183} > > TBR=perkj@webrtc.org,pbos@webrtc.org,marpan@webrtc.org,tkchin@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:5682 > > Committed: https://crrev.com/72e735d3867a0fd6ab7e4d0761c7ba5f6c068617 > Cr-Commit-Position: refs/heads/master@{#13184} TBR=perkj@webrtc.org,pbos@webrtc.org,marpan@webrtc.org,tkchin@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=webrtc:5682 Review-Url: https://codereview.webrtc.org/2076123002 Cr-Commit-Position: refs/heads/master@{#13189}
2016-06-17 05:03:04 -07:00
return self.i420Buffer->DataY();
}
- (const uint8_t *)uPlane {
if (!self.i420Buffer) {
return nullptr;
}
Partial reland of Delete unused and almost unused frame-related methods. (patchset #1 id:1 of https://codereview.webrtc.org/2076113002/ ) Reason for revert: Taking out the VideoFrameBuffer changes which broke downstream. Original issue's description: > Revert of Delete unused and almost unused frame-related methods. (patchset #12 id:220001 of https://codereview.webrtc.org/2065733003/ ) > > Reason for revert: > Breaks downstream applications which inherits webrtc::VideoFrameBuffer and tries to override deleted methods data(), stride() and MutableData(). > > Original issue's description: > > Delete unused and almost unused frame-related methods. > > > > webrtc::VideoFrame::set_video_frame_buffer > > webrtc::VideoFrame::ConvertNativeToI420Frame > > > > cricket::WebRtcVideoFrame::InitToBlack > > > > VideoFrameBuffer::data > > VideoFrameBuffer::stride > > VideoFrameBuffer::MutableData > > > > TBR=tkchin@webrtc.org # Refactoring affecting RTCVideoFrame > > BUG=webrtc:5682 > > > > Committed: https://crrev.com/76270de4bc2dac188f10f805e6e2fb86693ef864 > > Cr-Commit-Position: refs/heads/master@{#13183} > > TBR=perkj@webrtc.org,pbos@webrtc.org,marpan@webrtc.org,tkchin@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:5682 > > Committed: https://crrev.com/72e735d3867a0fd6ab7e4d0761c7ba5f6c068617 > Cr-Commit-Position: refs/heads/master@{#13184} TBR=perkj@webrtc.org,pbos@webrtc.org,marpan@webrtc.org,tkchin@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=webrtc:5682 Review-Url: https://codereview.webrtc.org/2076123002 Cr-Commit-Position: refs/heads/master@{#13189}
2016-06-17 05:03:04 -07:00
return self.i420Buffer->DataU();
}
- (const uint8_t *)vPlane {
if (!self.i420Buffer) {
return nullptr;
}
Partial reland of Delete unused and almost unused frame-related methods. (patchset #1 id:1 of https://codereview.webrtc.org/2076113002/ ) Reason for revert: Taking out the VideoFrameBuffer changes which broke downstream. Original issue's description: > Revert of Delete unused and almost unused frame-related methods. (patchset #12 id:220001 of https://codereview.webrtc.org/2065733003/ ) > > Reason for revert: > Breaks downstream applications which inherits webrtc::VideoFrameBuffer and tries to override deleted methods data(), stride() and MutableData(). > > Original issue's description: > > Delete unused and almost unused frame-related methods. > > > > webrtc::VideoFrame::set_video_frame_buffer > > webrtc::VideoFrame::ConvertNativeToI420Frame > > > > cricket::WebRtcVideoFrame::InitToBlack > > > > VideoFrameBuffer::data > > VideoFrameBuffer::stride > > VideoFrameBuffer::MutableData > > > > TBR=tkchin@webrtc.org # Refactoring affecting RTCVideoFrame > > BUG=webrtc:5682 > > > > Committed: https://crrev.com/76270de4bc2dac188f10f805e6e2fb86693ef864 > > Cr-Commit-Position: refs/heads/master@{#13183} > > TBR=perkj@webrtc.org,pbos@webrtc.org,marpan@webrtc.org,tkchin@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:5682 > > Committed: https://crrev.com/72e735d3867a0fd6ab7e4d0761c7ba5f6c068617 > Cr-Commit-Position: refs/heads/master@{#13184} TBR=perkj@webrtc.org,pbos@webrtc.org,marpan@webrtc.org,tkchin@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=webrtc:5682 Review-Url: https://codereview.webrtc.org/2076123002 Cr-Commit-Position: refs/heads/master@{#13189}
2016-06-17 05:03:04 -07:00
return self.i420Buffer->DataV();
}
- (int32_t)yPitch {
if (!self.i420Buffer) {
return 0;
}
Partial reland of Delete unused and almost unused frame-related methods. (patchset #1 id:1 of https://codereview.webrtc.org/2076113002/ ) Reason for revert: Taking out the VideoFrameBuffer changes which broke downstream. Original issue's description: > Revert of Delete unused and almost unused frame-related methods. (patchset #12 id:220001 of https://codereview.webrtc.org/2065733003/ ) > > Reason for revert: > Breaks downstream applications which inherits webrtc::VideoFrameBuffer and tries to override deleted methods data(), stride() and MutableData(). > > Original issue's description: > > Delete unused and almost unused frame-related methods. > > > > webrtc::VideoFrame::set_video_frame_buffer > > webrtc::VideoFrame::ConvertNativeToI420Frame > > > > cricket::WebRtcVideoFrame::InitToBlack > > > > VideoFrameBuffer::data > > VideoFrameBuffer::stride > > VideoFrameBuffer::MutableData > > > > TBR=tkchin@webrtc.org # Refactoring affecting RTCVideoFrame > > BUG=webrtc:5682 > > > > Committed: https://crrev.com/76270de4bc2dac188f10f805e6e2fb86693ef864 > > Cr-Commit-Position: refs/heads/master@{#13183} > > TBR=perkj@webrtc.org,pbos@webrtc.org,marpan@webrtc.org,tkchin@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:5682 > > Committed: https://crrev.com/72e735d3867a0fd6ab7e4d0761c7ba5f6c068617 > Cr-Commit-Position: refs/heads/master@{#13184} TBR=perkj@webrtc.org,pbos@webrtc.org,marpan@webrtc.org,tkchin@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=webrtc:5682 Review-Url: https://codereview.webrtc.org/2076123002 Cr-Commit-Position: refs/heads/master@{#13189}
2016-06-17 05:03:04 -07:00
return self.i420Buffer->StrideY();
}
- (int32_t)uPitch {
if (!self.i420Buffer) {
return 0;
}
Partial reland of Delete unused and almost unused frame-related methods. (patchset #1 id:1 of https://codereview.webrtc.org/2076113002/ ) Reason for revert: Taking out the VideoFrameBuffer changes which broke downstream. Original issue's description: > Revert of Delete unused and almost unused frame-related methods. (patchset #12 id:220001 of https://codereview.webrtc.org/2065733003/ ) > > Reason for revert: > Breaks downstream applications which inherits webrtc::VideoFrameBuffer and tries to override deleted methods data(), stride() and MutableData(). > > Original issue's description: > > Delete unused and almost unused frame-related methods. > > > > webrtc::VideoFrame::set_video_frame_buffer > > webrtc::VideoFrame::ConvertNativeToI420Frame > > > > cricket::WebRtcVideoFrame::InitToBlack > > > > VideoFrameBuffer::data > > VideoFrameBuffer::stride > > VideoFrameBuffer::MutableData > > > > TBR=tkchin@webrtc.org # Refactoring affecting RTCVideoFrame > > BUG=webrtc:5682 > > > > Committed: https://crrev.com/76270de4bc2dac188f10f805e6e2fb86693ef864 > > Cr-Commit-Position: refs/heads/master@{#13183} > > TBR=perkj@webrtc.org,pbos@webrtc.org,marpan@webrtc.org,tkchin@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:5682 > > Committed: https://crrev.com/72e735d3867a0fd6ab7e4d0761c7ba5f6c068617 > Cr-Commit-Position: refs/heads/master@{#13184} TBR=perkj@webrtc.org,pbos@webrtc.org,marpan@webrtc.org,tkchin@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=webrtc:5682 Review-Url: https://codereview.webrtc.org/2076123002 Cr-Commit-Position: refs/heads/master@{#13189}
2016-06-17 05:03:04 -07:00
return self.i420Buffer->StrideU();
}
- (int32_t)vPitch {
if (!self.i420Buffer) {
return 0;
}
Partial reland of Delete unused and almost unused frame-related methods. (patchset #1 id:1 of https://codereview.webrtc.org/2076113002/ ) Reason for revert: Taking out the VideoFrameBuffer changes which broke downstream. Original issue's description: > Revert of Delete unused and almost unused frame-related methods. (patchset #12 id:220001 of https://codereview.webrtc.org/2065733003/ ) > > Reason for revert: > Breaks downstream applications which inherits webrtc::VideoFrameBuffer and tries to override deleted methods data(), stride() and MutableData(). > > Original issue's description: > > Delete unused and almost unused frame-related methods. > > > > webrtc::VideoFrame::set_video_frame_buffer > > webrtc::VideoFrame::ConvertNativeToI420Frame > > > > cricket::WebRtcVideoFrame::InitToBlack > > > > VideoFrameBuffer::data > > VideoFrameBuffer::stride > > VideoFrameBuffer::MutableData > > > > TBR=tkchin@webrtc.org # Refactoring affecting RTCVideoFrame > > BUG=webrtc:5682 > > > > Committed: https://crrev.com/76270de4bc2dac188f10f805e6e2fb86693ef864 > > Cr-Commit-Position: refs/heads/master@{#13183} > > TBR=perkj@webrtc.org,pbos@webrtc.org,marpan@webrtc.org,tkchin@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:5682 > > Committed: https://crrev.com/72e735d3867a0fd6ab7e4d0761c7ba5f6c068617 > Cr-Commit-Position: refs/heads/master@{#13184} TBR=perkj@webrtc.org,pbos@webrtc.org,marpan@webrtc.org,tkchin@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=webrtc:5682 Review-Url: https://codereview.webrtc.org/2076123002 Cr-Commit-Position: refs/heads/master@{#13189}
2016-06-17 05:03:04 -07:00
return self.i420Buffer->StrideV();
}
- (int64_t)timeStampNs {
return _timeStampNs;
}
- (CVPixelBufferRef)nativeHandle {
return static_cast<CVPixelBufferRef>(_videoBuffer->native_handle());
}
- (void)convertBufferIfNeeded {
if (!_i420Buffer) {
_i420Buffer = _videoBuffer->native_handle()
? _videoBuffer->NativeToI420Buffer()
: _videoBuffer;
}
}
#pragma mark - Private
- (instancetype)initWithVideoBuffer:
(rtc::scoped_refptr<webrtc::VideoFrameBuffer>)videoBuffer
rotation:(webrtc::VideoRotation)rotation
timeStampNs:(int64_t)timeStampNs {
if (self = [super init]) {
_videoBuffer = videoBuffer;
_rotation = rotation;
_timeStampNs = timeStampNs;
}
return self;
}
- (rtc::scoped_refptr<webrtc::VideoFrameBuffer>)i420Buffer {
[self convertBufferIfNeeded];
return _i420Buffer;
}
@end