| 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/browser/media/capture/web_contents_video_capture_device.h" | 5 #include "content/browser/media/capture/web_contents_video_capture_device.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 // TODO(miu): We just look at the center pixel presently, because if the | 293 // TODO(miu): We just look at the center pixel presently, because if the |
| 294 // analysis is too slow, the backlog of frames will grow without bound and | 294 // analysis is too slow, the backlog of frames will grow without bound and |
| 295 // trouble erupts. http://crbug.com/174519 | 295 // trouble erupts. http://crbug.com/174519 |
| 296 using media::VideoFrame; | 296 using media::VideoFrame; |
| 297 std::unique_ptr<media::VideoCaptureBufferHandle> buffer_access = | 297 std::unique_ptr<media::VideoCaptureBufferHandle> buffer_access = |
| 298 buffer.handle_provider->GetHandleForInProcessAccess(); | 298 buffer.handle_provider->GetHandleForInProcessAccess(); |
| 299 scoped_refptr<media::VideoFrame> frame = | 299 scoped_refptr<media::VideoFrame> frame = |
| 300 VideoFrame::WrapExternalSharedMemory( | 300 VideoFrame::WrapExternalSharedMemory( |
| 301 media::PIXEL_FORMAT_I420, format.frame_size, visible_rect, | 301 media::PIXEL_FORMAT_I420, format.frame_size, visible_rect, |
| 302 format.frame_size, buffer_access->data(), | 302 format.frame_size, buffer_access->data(), |
| 303 buffer_access->mapped_size(), base::SharedMemory::NULLHandle(), 0u, | 303 buffer_access->mapped_size(), base::SharedMemoryHandle(), 0u, |
| 304 base::TimeDelta()); | 304 base::TimeDelta()); |
| 305 const gfx::Point center = visible_rect.CenterPoint(); | 305 const gfx::Point center = visible_rect.CenterPoint(); |
| 306 const int center_offset_y = | 306 const int center_offset_y = |
| 307 (frame->stride(VideoFrame::kYPlane) * center.y()) + center.x(); | 307 (frame->stride(VideoFrame::kYPlane) * center.y()) + center.x(); |
| 308 const int center_offset_uv = | 308 const int center_offset_uv = |
| 309 (frame->stride(VideoFrame::kUPlane) * (center.y() / 2)) + | 309 (frame->stride(VideoFrame::kUPlane) * (center.y() / 2)) + |
| 310 (center.x() / 2); | 310 (center.x() / 2); |
| 311 report_callback_.Run( | 311 report_callback_.Run( |
| 312 SkColorSetRGB(frame->data(VideoFrame::kYPlane)[center_offset_y], | 312 SkColorSetRGB(frame->data(VideoFrame::kYPlane)[center_offset_y], |
| 313 frame->data(VideoFrame::kUPlane)[center_offset_uv], | 313 frame->data(VideoFrame::kUPlane)[center_offset_uv], |
| (...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1034 for (int i = 0; i < 3; ++i) { | 1034 for (int i = 0; i < 3; ++i) { |
| 1035 SimulateRefreshFrameRequest(); | 1035 SimulateRefreshFrameRequest(); |
| 1036 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN)); | 1036 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN)); |
| 1037 } | 1037 } |
| 1038 | 1038 |
| 1039 device()->StopAndDeAllocate(); | 1039 device()->StopAndDeAllocate(); |
| 1040 } | 1040 } |
| 1041 | 1041 |
| 1042 } // namespace | 1042 } // namespace |
| 1043 } // namespace content | 1043 } // namespace content |
| OLD | NEW |