| 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/renderer_host/media/web_contents_video_capture_device.
h" | 5 #include "content/browser/renderer_host/media/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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 }; | 304 }; |
| 305 | 305 |
| 306 // A stub consumer of captured video frames, which checks the output of | 306 // A stub consumer of captured video frames, which checks the output of |
| 307 // WebContentsVideoCaptureDevice. | 307 // WebContentsVideoCaptureDevice. |
| 308 class StubClient : public media::VideoCaptureDevice::Client { | 308 class StubClient : public media::VideoCaptureDevice::Client { |
| 309 public: | 309 public: |
| 310 StubClient(const base::Callback<void(SkColor)>& color_callback, | 310 StubClient(const base::Callback<void(SkColor)>& color_callback, |
| 311 const base::Closure& error_callback) | 311 const base::Closure& error_callback) |
| 312 : color_callback_(color_callback), | 312 : color_callback_(color_callback), |
| 313 error_callback_(error_callback) { | 313 error_callback_(error_callback) { |
| 314 buffer_pool_ = new VideoCaptureBufferPool( | 314 buffer_pool_ = new VideoCaptureBufferPool(2); |
| 315 media::VideoFrame::AllocationSize(media::VideoFrame::I420, | |
| 316 gfx::Size(kTestWidth, kTestHeight)), | |
| 317 2); | |
| 318 EXPECT_TRUE(buffer_pool_->Allocate()); | |
| 319 } | 315 } |
| 320 virtual ~StubClient() {} | 316 virtual ~StubClient() {} |
| 321 | 317 |
| 322 virtual scoped_refptr<media::VideoFrame> ReserveOutputBuffer() OVERRIDE { | 318 virtual scoped_refptr<media::VideoFrame> ReserveOutputBuffer( |
| 323 return buffer_pool_->ReserveI420VideoFrame(gfx::Size(kTestWidth, | 319 const gfx::Size& size) OVERRIDE { |
| 324 kTestHeight), | 320 int buffer_id_to_drop = VideoCaptureBufferPool::kInvalidId; |
| 325 0); | 321 return buffer_pool_->ReserveI420VideoFrame(size, 0, &buffer_id_to_drop); |
| 326 } | 322 } |
| 327 | 323 |
| 328 virtual void OnIncomingCapturedFrame( | 324 virtual void OnIncomingCapturedFrame( |
| 329 const uint8* data, | 325 const uint8* data, |
| 330 int length, | 326 int length, |
| 331 base::Time timestamp, | 327 base::Time timestamp, |
| 332 int rotation, | 328 int rotation, |
| 333 bool flip_vert, | 329 bool flip_vert, |
| 334 bool flip_horiz) OVERRIDE { | 330 bool flip_horiz) OVERRIDE { |
| 335 FAIL(); | 331 FAIL(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 351 // the analysis is too slow, the backlog of frames will grow without bound | 347 // the analysis is too slow, the backlog of frames will grow without bound |
| 352 // and trouble erupts. http://crbug.com/174519 | 348 // and trouble erupts. http://crbug.com/174519 |
| 353 color_callback_.Run((SkColorSetRGB(yuv[0], yuv[1], yuv[2]))); | 349 color_callback_.Run((SkColorSetRGB(yuv[0], yuv[1], yuv[2]))); |
| 354 } | 350 } |
| 355 | 351 |
| 356 virtual void OnError() OVERRIDE { | 352 virtual void OnError() OVERRIDE { |
| 357 error_callback_.Run(); | 353 error_callback_.Run(); |
| 358 } | 354 } |
| 359 | 355 |
| 360 virtual void OnFrameInfo(const media::VideoCaptureCapability& info) OVERRIDE { | 356 virtual void OnFrameInfo(const media::VideoCaptureCapability& info) OVERRIDE { |
| 361 EXPECT_EQ(kTestWidth, info.width); | |
| 362 EXPECT_EQ(kTestHeight, info.height); | |
| 363 EXPECT_EQ(kTestFramesPerSecond, info.frame_rate); | 357 EXPECT_EQ(kTestFramesPerSecond, info.frame_rate); |
| 364 EXPECT_EQ(media::PIXEL_FORMAT_I420, info.color); | |
| 365 } | 358 } |
| 366 | 359 |
| 367 private: | 360 private: |
| 368 scoped_refptr<VideoCaptureBufferPool> buffer_pool_; | 361 scoped_refptr<VideoCaptureBufferPool> buffer_pool_; |
| 369 base::Callback<void(SkColor)> color_callback_; | 362 base::Callback<void(SkColor)> color_callback_; |
| 370 base::Closure error_callback_; | 363 base::Closure error_callback_; |
| 371 | 364 |
| 372 DISALLOW_COPY_AND_ASSIGN(StubClient); | 365 DISALLOW_COPY_AND_ASSIGN(StubClient); |
| 373 }; | 366 }; |
| 374 | 367 |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 source()->SetSolidColor(SK_ColorGREEN); | 816 source()->SetSolidColor(SK_ColorGREEN); |
| 824 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN)); | 817 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN)); |
| 825 source()->SetSolidColor(SK_ColorRED); | 818 source()->SetSolidColor(SK_ColorRED); |
| 826 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorRED)); | 819 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorRED)); |
| 827 | 820 |
| 828 device()->StopAndDeAllocate(); | 821 device()->StopAndDeAllocate(); |
| 829 } | 822 } |
| 830 | 823 |
| 831 } // namespace | 824 } // namespace |
| 832 } // namespace content | 825 } // namespace content |
| OLD | NEW |