OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/media/capture_video_decoder.h" | 5 #include "content/renderer/media/capture_video_decoder.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "content/renderer/media/video_capture_impl_manager.h" | 9 #include "content/renderer/media/video_capture_impl_manager.h" |
10 #include "media/base/filter_host.h" | 10 #include "media/base/filter_host.h" |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 natural_size_.width(), | 254 natural_size_.width(), |
255 natural_size_.height(), | 255 natural_size_.height(), |
256 buf->timestamp - start_time_, | 256 buf->timestamp - start_time_, |
257 base::TimeDelta::FromMilliseconds(0)); | 257 base::TimeDelta::FromMilliseconds(0)); |
258 | 258 |
259 last_frame_timestamp_ = buf->timestamp; | 259 last_frame_timestamp_ = buf->timestamp; |
260 uint8* buffer = buf->memory_pointer; | 260 uint8* buffer = buf->memory_pointer; |
261 | 261 |
262 // Assume YV12 format. Note that camera gives YUV and media pipeline video | 262 // Assume YV12 format. Note that camera gives YUV and media pipeline video |
263 // renderer asks for YVU. The following code did the conversion. | 263 // renderer asks for YVU. The following code did the conversion. |
264 DCHECK_EQ(capability_.color, media::VideoFrame::I420); | 264 DCHECK_EQ(capability_.color, media::VideoCaptureCapability::kI420); |
265 int y_width = buf->width; | 265 int y_width = buf->width; |
266 int y_height = buf->height; | 266 int y_height = buf->height; |
267 int uv_width = buf->width / 2; | 267 int uv_width = buf->width / 2; |
268 int uv_height = buf->height / 2; // YV12 format. | 268 int uv_height = buf->height / 2; // YV12 format. |
269 CopyYPlane(buffer, y_width, y_height, video_frame); | 269 CopyYPlane(buffer, y_width, y_height, video_frame); |
270 buffer += y_width * y_height; | 270 buffer += y_width * y_height; |
271 CopyUPlane(buffer, uv_width, uv_height, video_frame); | 271 CopyUPlane(buffer, uv_width, uv_height, video_frame); |
272 buffer += uv_width * uv_height; | 272 buffer += uv_width * uv_height; |
273 CopyVPlane(buffer, uv_width, uv_height, video_frame); | 273 CopyVPlane(buffer, uv_width, uv_height, video_frame); |
274 | 274 |
275 DeliverFrame(video_frame); | 275 DeliverFrame(video_frame); |
276 capture->FeedBuffer(buf); | 276 capture->FeedBuffer(buf); |
277 } | 277 } |
278 | 278 |
279 void CaptureVideoDecoder::DeliverFrame( | 279 void CaptureVideoDecoder::DeliverFrame( |
280 const scoped_refptr<media::VideoFrame>& video_frame) { | 280 const scoped_refptr<media::VideoFrame>& video_frame) { |
281 // Reset the callback before running to protect against reentrancy. | 281 // Reset the callback before running to protect against reentrancy. |
282 ReadCB read_cb = read_cb_; | 282 ReadCB read_cb = read_cb_; |
283 read_cb_.Reset(); | 283 read_cb_.Reset(); |
284 read_cb.Run(video_frame); | 284 read_cb.Run(video_frame); |
285 } | 285 } |
OLD | NEW |