Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: webrtc/sdk/objc/Framework/Classes/RTCVideoFrame.mm

Issue 2700113003: Add RTCVideoFrame init function from CVPixelBufferRef (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #import "RTCVideoFrame+Private.h" 11 #import "RTCVideoFrame+Private.h"
12 12
13 #include "webrtc/common_video/include/corevideo_frame_buffer.h"
14
13 @implementation RTCVideoFrame { 15 @implementation RTCVideoFrame {
14 rtc::scoped_refptr<webrtc::VideoFrameBuffer> _videoBuffer; 16 rtc::scoped_refptr<webrtc::VideoFrameBuffer> _videoBuffer;
15 int _rotation; 17 int _rotation;
16 int64_t _timeStampNs; 18 int64_t _timeStampNs;
17 } 19 }
18 20
19 - (int)width { 21 - (int)width {
20 return _videoBuffer->width(); 22 return _videoBuffer->width();
21 } 23 }
22 24
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 64
63 - (RTCVideoFrame*)convertToI420 { 65 - (RTCVideoFrame*)convertToI420 {
64 if (!_videoBuffer->native_handle()) 66 if (!_videoBuffer->native_handle())
65 return self; 67 return self;
66 return [[RTCVideoFrame alloc] 68 return [[RTCVideoFrame alloc]
67 initWithVideoBuffer:_videoBuffer->NativeToI420Buffer() 69 initWithVideoBuffer:_videoBuffer->NativeToI420Buffer()
68 rotation:_rotation 70 rotation:_rotation
69 timeStampNs:_timeStampNs]; 71 timeStampNs:_timeStampNs];
70 } 72 }
71 73
74 - (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer
75 rotation:(int)rotation
76 timeStampNs:(int64_t)timeStampNs {
77 rtc::scoped_refptr<webrtc::VideoFrameBuffer> videoBuffer(
78 new rtc::RefCountedObject<webrtc::CoreVideoFrameBuffer>(pixelBuffer));
79 return [self initWithVideoBuffer:videoBuffer
80 rotation:rotation
81 timeStampNs:timeStampNs];
82 }
83
84 - (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer
85 scaledWidth:(int)scaledWidth
86 scaledHeight:(int)scaledHeight
87 cropWidth:(int)cropWidth
88 cropHeight:(int)cropHeight
89 cropX:(int)cropX
90 cropY:(int)cropY
91 rotation:(int)rotation
92 timeStampNs:(int64_t)timeStampNs {
93 rtc::scoped_refptr<webrtc::VideoFrameBuffer> videoBuffer(
94 new rtc::RefCountedObject<webrtc::CoreVideoFrameBuffer>(
95 pixelBuffer,
96 scaledWidth, scaledHeight,
97 cropWidth, cropHeight,
98 cropX, cropY));
99 return [self initWithVideoBuffer:videoBuffer
100 rotation:rotation
101 timeStampNs:timeStampNs];
102 }
103
72 #pragma mark - Private 104 #pragma mark - Private
73 105
74 - (instancetype)initWithVideoBuffer: 106 - (instancetype)initWithVideoBuffer:
75 (rtc::scoped_refptr<webrtc::VideoFrameBuffer>)videoBuffer 107 (rtc::scoped_refptr<webrtc::VideoFrameBuffer>)videoBuffer
76 rotation:(int)rotation 108 rotation:(int)rotation
77 timeStampNs:(int64_t)timeStampNs { 109 timeStampNs:(int64_t)timeStampNs {
78 if (self = [super init]) { 110 if (self = [super init]) {
79 _videoBuffer = videoBuffer; 111 _videoBuffer = videoBuffer;
80 _rotation = rotation; 112 _rotation = rotation;
81 _timeStampNs = timeStampNs; 113 _timeStampNs = timeStampNs;
82 } 114 }
83 return self; 115 return self;
84 } 116 }
85 117
86 @end 118 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698