| 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 "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/debug/debugger.h" | 8 #include "base/debug/debugger.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 return NULL; | 336 return NULL; |
| 337 void* data; | 337 void* data; |
| 338 size_t size; | 338 size_t size; |
| 339 buffer_pool_->GetBufferInfo(buffer_id, &data, &size); | 339 buffer_pool_->GetBufferInfo(buffer_id, &data, &size); |
| 340 return scoped_refptr<media::VideoCaptureDevice::Client::Buffer>( | 340 return scoped_refptr<media::VideoCaptureDevice::Client::Buffer>( |
| 341 new AutoReleaseBuffer(buffer_pool_, buffer_id, data, size)); | 341 new AutoReleaseBuffer(buffer_pool_, buffer_id, data, size)); |
| 342 } | 342 } |
| 343 | 343 |
| 344 void OnIncomingCapturedVideoFrame( | 344 void OnIncomingCapturedVideoFrame( |
| 345 const scoped_refptr<Buffer>& buffer, | 345 const scoped_refptr<Buffer>& buffer, |
| 346 const media::VideoCaptureFormat& buffer_format, | |
| 347 const scoped_refptr<media::VideoFrame>& frame, | 346 const scoped_refptr<media::VideoFrame>& frame, |
| 348 const base::TimeTicks& timestamp) override { | 347 const base::TimeTicks& timestamp) override { |
| 349 EXPECT_EQ(gfx::Size(kTestWidth, kTestHeight), buffer_format.frame_size); | 348 EXPECT_EQ(gfx::Size(kTestWidth, kTestHeight), frame->visible_rect().size()); |
| 350 EXPECT_EQ(media::PIXEL_FORMAT_I420, buffer_format.pixel_format); | |
| 351 EXPECT_EQ(media::VideoFrame::I420, frame->format()); | 349 EXPECT_EQ(media::VideoFrame::I420, frame->format()); |
| 350 double frame_rate = 0; |
| 351 EXPECT_TRUE( |
| 352 frame->metadata()->GetDouble(media::VideoFrameMetadata::FRAME_RATE, |
| 353 &frame_rate)); |
| 354 EXPECT_EQ(kTestFramesPerSecond, frame_rate); |
| 352 uint8 yuv[3]; | 355 uint8 yuv[3]; |
| 353 for (int plane = 0; plane < 3; ++plane) | 356 for (int plane = 0; plane < 3; ++plane) |
| 354 yuv[plane] = frame->data(plane)[0]; | 357 yuv[plane] = frame->visible_data(plane)[0]; |
| 355 // TODO(nick): We just look at the first pixel presently, because if | 358 // TODO(nick): We just look at the first pixel presently, because if |
| 356 // the analysis is too slow, the backlog of frames will grow without bound | 359 // the analysis is too slow, the backlog of frames will grow without bound |
| 357 // and trouble erupts. http://crbug.com/174519 | 360 // and trouble erupts. http://crbug.com/174519 |
| 358 color_callback_.Run((SkColorSetRGB(yuv[0], yuv[1], yuv[2]))); | 361 color_callback_.Run((SkColorSetRGB(yuv[0], yuv[1], yuv[2]))); |
| 359 } | 362 } |
| 360 | 363 |
| 361 void OnError(const std::string& reason) override { error_callback_.Run(); } | 364 void OnError(const std::string& reason) override { error_callback_.Run(); } |
| 362 | 365 |
| 363 private: | 366 private: |
| 364 class AutoReleaseBuffer : public media::VideoCaptureDevice::Client::Buffer { | 367 class AutoReleaseBuffer : public media::VideoCaptureDevice::Client::Buffer { |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 source()->SetSolidColor(SK_ColorGREEN); | 857 source()->SetSolidColor(SK_ColorGREEN); |
| 855 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN)); | 858 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN)); |
| 856 source()->SetSolidColor(SK_ColorRED); | 859 source()->SetSolidColor(SK_ColorRED); |
| 857 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorRED)); | 860 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorRED)); |
| 858 | 861 |
| 859 device()->StopAndDeAllocate(); | 862 device()->StopAndDeAllocate(); |
| 860 } | 863 } |
| 861 | 864 |
| 862 } // namespace | 865 } // namespace |
| 863 } // namespace content | 866 } // namespace content |
| OLD | NEW |