OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 145 |
146 void VideoFrame::Reset() { | 146 void VideoFrame::Reset() { |
147 video_frame_buffer_ = nullptr; | 147 video_frame_buffer_ = nullptr; |
148 timestamp_ = 0; | 148 timestamp_ = 0; |
149 ntp_time_ms_ = 0; | 149 ntp_time_ms_ = 0; |
150 render_time_ms_ = 0; | 150 render_time_ms_ = 0; |
151 rotation_ = kVideoRotation_0; | 151 rotation_ = kVideoRotation_0; |
152 } | 152 } |
153 | 153 |
154 uint8_t* VideoFrame::buffer(PlaneType type) { | 154 uint8_t* VideoFrame::buffer(PlaneType type) { |
| 155 return video_frame_buffer_ ? video_frame_buffer_->MutableData(type) |
| 156 : nullptr; |
| 157 } |
| 158 |
| 159 const uint8_t* VideoFrame::buffer(PlaneType type) const { |
155 return video_frame_buffer_ ? video_frame_buffer_->data(type) : nullptr; | 160 return video_frame_buffer_ ? video_frame_buffer_->data(type) : nullptr; |
156 } | 161 } |
157 | 162 |
158 const uint8_t* VideoFrame::buffer(PlaneType type) const { | |
159 // Const cast to call the correct const-version of data. | |
160 const VideoFrameBuffer* const_buffer = video_frame_buffer_.get(); | |
161 return const_buffer ? const_buffer->data(type) : nullptr; | |
162 } | |
163 | |
164 int VideoFrame::allocated_size(PlaneType type) const { | 163 int VideoFrame::allocated_size(PlaneType type) const { |
165 const int plane_height = (type == kYPlane) ? height() : (height() + 1) / 2; | 164 const int plane_height = (type == kYPlane) ? height() : (height() + 1) / 2; |
166 return plane_height * stride(type); | 165 return plane_height * stride(type); |
167 } | 166 } |
168 | 167 |
169 int VideoFrame::stride(PlaneType type) const { | 168 int VideoFrame::stride(PlaneType type) const { |
170 return video_frame_buffer_ ? video_frame_buffer_->stride(type) : 0; | 169 return video_frame_buffer_ ? video_frame_buffer_->stride(type) : 0; |
171 } | 170 } |
172 | 171 |
173 int VideoFrame::width() const { | 172 int VideoFrame::width() const { |
(...skipping 23 matching lines...) Expand all Loading... |
197 | 196 |
198 VideoFrame VideoFrame::ConvertNativeToI420Frame() const { | 197 VideoFrame VideoFrame::ConvertNativeToI420Frame() const { |
199 DCHECK(native_handle()); | 198 DCHECK(native_handle()); |
200 VideoFrame frame; | 199 VideoFrame frame; |
201 frame.ShallowCopy(*this); | 200 frame.ShallowCopy(*this); |
202 frame.set_video_frame_buffer(video_frame_buffer_->NativeToI420Buffer()); | 201 frame.set_video_frame_buffer(video_frame_buffer_->NativeToI420Buffer()); |
203 return frame; | 202 return frame; |
204 } | 203 } |
205 | 204 |
206 } // namespace webrtc | 205 } // namespace webrtc |
OLD | NEW |