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

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

Issue 2978623002: Implement H264 codec in Objective-C classes. (Closed)
Patch Set: Fix test after rebase. Created 3 years, 5 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
(Empty)
1 /*
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
11 #import "webrtc/sdk/objc/Framework/Headers/WebRTC/RTCVideoFrame.h"
12 #import "webrtc/sdk/objc/Framework/Headers/WebRTC/RTCVideoFrameBuffer.h"
13
14 @implementation RTCVideoFrame {
15 RTCVideoRotation _rotation;
16 int64_t _timeStampNs;
17 }
18
19 @synthesize buffer = _buffer;
20 @synthesize timeStamp;
21
22 - (int)width {
23 return _buffer.width;
24 }
25
26 - (int)height {
27 return _buffer.height;
28 }
29
30 - (RTCVideoRotation)rotation {
31 return _rotation;
32 }
33
34 - (const uint8_t *)dataY {
35 if ([_buffer conformsToProtocol:@protocol(RTCI420Buffer)]) {
36 return ((id<RTCI420Buffer>)_buffer).dataY;
37 } else {
38 return nullptr;
39 }
40 }
41
42 - (const uint8_t *)dataU {
43 if ([_buffer conformsToProtocol:@protocol(RTCI420Buffer)]) {
44 return ((id<RTCI420Buffer>)_buffer).dataU;
45 } else {
46 return nullptr;
47 }
48 }
49
50 - (const uint8_t *)dataV {
51 if ([_buffer conformsToProtocol:@protocol(RTCI420Buffer)]) {
52 return ((id<RTCI420Buffer>)_buffer).dataV;
53 } else {
54 return nullptr;
55 }
56 }
57
58 - (int)strideY {
59 if ([_buffer conformsToProtocol:@protocol(RTCI420Buffer)]) {
60 return ((id<RTCI420Buffer>)_buffer).strideY;
61 } else {
62 return 0;
63 }
64 }
65
66 - (int)strideU {
67 if ([_buffer conformsToProtocol:@protocol(RTCI420Buffer)]) {
68 return ((id<RTCI420Buffer>)_buffer).strideU;
69 } else {
70 return 0;
71 }
72 }
73
74 - (int)strideV {
75 if ([_buffer conformsToProtocol:@protocol(RTCI420Buffer)]) {
76 return ((id<RTCI420Buffer>)_buffer).strideV;
77 } else {
78 return 0;
79 }
80 }
81
82 - (int64_t)timeStampNs {
83 return _timeStampNs;
84 }
85
86 - (CVPixelBufferRef)nativeHandle {
87 if ([_buffer isKindOfClass:[RTCCVPixelBuffer class]]) {
88 return ((RTCCVPixelBuffer *)_buffer).pixelBuffer;
89 } else {
90 return nullptr;
91 }
92 }
93
94 - (RTCVideoFrame *)newI420VideoFrame {
95 return [[RTCVideoFrame alloc] initWithBuffer:[_buffer toI420]
96 rotation:_rotation
97 timeStampNs:_timeStampNs];
98 }
99
100 - (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer
101 rotation:(RTCVideoRotation)rotation
102 timeStampNs:(int64_t)timeStampNs {
103 return [self initWithBuffer:[[RTCCVPixelBuffer alloc] initWithPixelBuffer:pixe lBuffer]
104 rotation:rotation
105 timeStampNs:timeStampNs];
106 }
107
108 - (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer
109 scaledWidth:(int)scaledWidth
110 scaledHeight:(int)scaledHeight
111 cropWidth:(int)cropWidth
112 cropHeight:(int)cropHeight
113 cropX:(int)cropX
114 cropY:(int)cropY
115 rotation:(RTCVideoRotation)rotation
116 timeStampNs:(int64_t)timeStampNs {
117 RTCCVPixelBuffer *rtcPixelBuffer = [[RTCCVPixelBuffer alloc] initWithPixelBuff er:pixelBuffer
118 adaptedWid th:scaledWidth
119 adaptedHeig ht:scaledHeight
120 cropWid th:cropWidth
121 cropHeig ht:cropHeight
122 cro pX:cropX
123 cro pY:cropY];
124 return [self initWithBuffer:rtcPixelBuffer rotation:rotation timeStampNs:timeS tampNs];
125 }
126
127 - (instancetype)initWithBuffer:(id<RTCVideoFrameBuffer>)buffer
128 rotation:(RTCVideoRotation)rotation
129 timeStampNs:(int64_t)timeStampNs {
130 if (self = [super init]) {
131 _buffer = buffer;
132 _rotation = rotation;
133 _timeStampNs = timeStampNs;
134 }
135
136 return self;
137 }
138
139 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698