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