| 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/local_video_capture.h" | 5 #include "content/renderer/media/local_video_capture.h" |
| 6 | 6 |
| 7 #include "content/renderer/media/video_capture_impl_manager.h" | 7 #include "content/renderer/media/video_capture_impl_manager.h" |
| 8 #include "media/base/video_util.h" | 8 #include "media/base/video_util.h" |
| 9 #include "media/video/capture/video_capture_proxy.h" | 9 #include "media/video/capture/video_capture_proxy.h" |
| 10 | 10 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); | 119 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); |
| 120 DCHECK(buf); | 120 DCHECK(buf); |
| 121 | 121 |
| 122 if (state_ != video_capture::kStarted) { | 122 if (state_ != video_capture::kStarted) { |
| 123 capture->FeedBuffer(buf); | 123 capture->FeedBuffer(buf); |
| 124 return; | 124 return; |
| 125 } | 125 } |
| 126 | 126 |
| 127 gfx::Size natural_size(buf->width, buf->height); | 127 gfx::Size natural_size(buf->width, buf->height); |
| 128 scoped_refptr<media::VideoFrame> current_frame = | 128 scoped_refptr<media::VideoFrame> current_frame = |
| 129 media::VideoFrame::CreateFrame(media::VideoFrame::YV12, | 129 media::VideoFrame::CreateFrame(media::VideoFrame::YV12, natural_size, |
| 130 natural_size, natural_size, | 130 gfx::Rect(natural_size), natural_size, |
| 131 buf->timestamp - base::Time()); | 131 buf->timestamp - base::Time()); |
| 132 uint8* buffer = buf->memory_pointer; | 132 uint8* buffer = buf->memory_pointer; |
| 133 | 133 |
| 134 // Assume YV12 format. | 134 // Assume YV12 format. |
| 135 DCHECK_EQ(capability_.color, media::VideoCaptureCapability::kI420); | 135 DCHECK_EQ(capability_.color, media::VideoCaptureCapability::kI420); |
| 136 if (capability_.color != media::VideoCaptureCapability::kI420) | 136 if (capability_.color != media::VideoCaptureCapability::kI420) |
| 137 return; | 137 return; |
| 138 | 138 |
| 139 int y_width = buf->width; | 139 int y_width = buf->width; |
| 140 int y_height = buf->height; | 140 int y_height = buf->height; |
| 141 int uv_width = buf->width / 2; | 141 int uv_width = buf->width / 2; |
| 142 int uv_height = buf->height / 2; | 142 int uv_height = buf->height / 2; |
| 143 CopyYPlane(buffer, y_width, y_height, current_frame); | 143 CopyYPlane(buffer, y_width, y_height, current_frame); |
| 144 buffer += y_width * y_height; | 144 buffer += y_width * y_height; |
| 145 CopyUPlane(buffer, uv_width, uv_height, current_frame); | 145 CopyUPlane(buffer, uv_width, uv_height, current_frame); |
| 146 buffer += uv_width * uv_height; | 146 buffer += uv_width * uv_height; |
| 147 CopyVPlane(buffer, uv_width, uv_height, current_frame); | 147 CopyVPlane(buffer, uv_width, uv_height, current_frame); |
| 148 | 148 |
| 149 capture->FeedBuffer(buf); | 149 capture->FeedBuffer(buf); |
| 150 repaint_cb_.Run(current_frame); | 150 repaint_cb_.Run(current_frame); |
| 151 } | 151 } |
| 152 | 152 |
| 153 } // namespace content | 153 } // namespace content |
| OLD | NEW |