| 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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 public: | 329 public: |
| 330 StubClient( | 330 StubClient( |
| 331 const base::Callback<void(SkColor, const gfx::Size&)>& report_callback, | 331 const base::Callback<void(SkColor, const gfx::Size&)>& report_callback, |
| 332 const base::Closure& error_callback) | 332 const base::Closure& error_callback) |
| 333 : report_callback_(report_callback), | 333 : report_callback_(report_callback), |
| 334 error_callback_(error_callback) { | 334 error_callback_(error_callback) { |
| 335 buffer_pool_ = new VideoCaptureBufferPool(2); | 335 buffer_pool_ = new VideoCaptureBufferPool(2); |
| 336 } | 336 } |
| 337 ~StubClient() override {} | 337 ~StubClient() override {} |
| 338 | 338 |
| 339 MOCK_METHOD5(OnIncomingCapturedData, | 339 MOCK_METHOD6(OnIncomingCapturedData, |
| 340 void(const uint8_t* data, | 340 void(const uint8_t* data, |
| 341 int length, | 341 int length, |
| 342 const media::VideoCaptureFormat& frame_format, | 342 const media::VideoCaptureFormat& frame_format, |
| 343 int rotation, | 343 int rotation, |
| 344 const base::TimeTicks& timestamp)); | 344 base::TimeTicks reference_time, |
| 345 MOCK_METHOD9(OnIncomingCapturedYuvData, | 345 base::TimeDelta timestamp)); |
| 346 void(const uint8_t* y_data, | |
| 347 const uint8_t* u_data, | |
| 348 const uint8_t* v_data, | |
| 349 size_t y_stride, | |
| 350 size_t u_stride, | |
| 351 size_t v_stride, | |
| 352 const media::VideoCaptureFormat& frame_format, | |
| 353 int clockwise_rotation, | |
| 354 const base::TimeTicks& timestamp)); | |
| 355 | 346 |
| 356 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void)); | 347 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void)); |
| 357 | 348 |
| 358 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> | 349 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> |
| 359 ReserveOutputBuffer(const gfx::Size& dimensions, | 350 ReserveOutputBuffer(const gfx::Size& dimensions, |
| 360 media::VideoPixelFormat format, | 351 media::VideoPixelFormat format, |
| 361 media::VideoPixelStorage storage) override { | 352 media::VideoPixelStorage storage) override { |
| 362 CHECK_EQ(format, media::PIXEL_FORMAT_I420); | 353 CHECK_EQ(format, media::PIXEL_FORMAT_I420); |
| 363 int buffer_id_to_drop = VideoCaptureBufferPool::kInvalidId; // Ignored. | 354 int buffer_id_to_drop = VideoCaptureBufferPool::kInvalidId; // Ignored. |
| 364 const int buffer_id = buffer_pool_->ReserveForProducer( | 355 const int buffer_id = buffer_pool_->ReserveForProducer( |
| 365 dimensions, format, storage, &buffer_id_to_drop); | 356 dimensions, format, storage, &buffer_id_to_drop); |
| 366 if (buffer_id == VideoCaptureBufferPool::kInvalidId) | 357 if (buffer_id == VideoCaptureBufferPool::kInvalidId) |
| 367 return NULL; | 358 return NULL; |
| 368 | 359 |
| 369 return std::unique_ptr<media::VideoCaptureDevice::Client::Buffer>( | 360 return std::unique_ptr<media::VideoCaptureDevice::Client::Buffer>( |
| 370 new AutoReleaseBuffer( | 361 new AutoReleaseBuffer( |
| 371 buffer_pool_, buffer_pool_->GetBufferHandle(buffer_id), buffer_id)); | 362 buffer_pool_, buffer_pool_->GetBufferHandle(buffer_id), buffer_id)); |
| 372 } | 363 } |
| 373 | 364 |
| 374 // Trampoline method to workaround GMOCK problems with std::unique_ptr<>. | 365 // Trampoline method to workaround GMOCK problems with std::unique_ptr<>. |
| 375 void OnIncomingCapturedBuffer(std::unique_ptr<Buffer> buffer, | 366 void OnIncomingCapturedBuffer(std::unique_ptr<Buffer> buffer, |
| 376 const media::VideoCaptureFormat& frame_format, | 367 const media::VideoCaptureFormat& frame_format, |
| 377 const base::TimeTicks& timestamp) override { | 368 base::TimeTicks reference_time, |
| 369 base::TimeDelta timestamp) override { |
| 378 DoOnIncomingCapturedBuffer(); | 370 DoOnIncomingCapturedBuffer(); |
| 379 } | 371 } |
| 380 | 372 |
| 381 void OnIncomingCapturedVideoFrame( | 373 void OnIncomingCapturedVideoFrame( |
| 382 std::unique_ptr<Buffer> buffer, | 374 std::unique_ptr<Buffer> buffer, |
| 383 const scoped_refptr<media::VideoFrame>& frame, | 375 const scoped_refptr<media::VideoFrame>& frame, |
| 384 const base::TimeTicks& timestamp) override { | 376 base::TimeTicks reference_time) override { |
| 385 EXPECT_FALSE(frame->visible_rect().IsEmpty()); | 377 EXPECT_FALSE(frame->visible_rect().IsEmpty()); |
| 386 EXPECT_EQ(media::PIXEL_FORMAT_I420, frame->format()); | 378 EXPECT_EQ(media::PIXEL_FORMAT_I420, frame->format()); |
| 387 double frame_rate = 0; | 379 double frame_rate = 0; |
| 388 EXPECT_TRUE( | 380 EXPECT_TRUE( |
| 389 frame->metadata()->GetDouble(media::VideoFrameMetadata::FRAME_RATE, | 381 frame->metadata()->GetDouble(media::VideoFrameMetadata::FRAME_RATE, |
| 390 &frame_rate)); | 382 &frame_rate)); |
| 391 EXPECT_EQ(kTestFramesPerSecond, frame_rate); | 383 EXPECT_EQ(kTestFramesPerSecond, frame_rate); |
| 392 | 384 |
| 393 // TODO(miu): We just look at the center pixel presently, because if the | 385 // TODO(miu): We just look at the center pixel presently, because if the |
| 394 // analysis is too slow, the backlog of frames will grow without bound and | 386 // analysis is too slow, the backlog of frames will grow without bound and |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1218 for (int i = 0; i < 3; ++i) { | 1210 for (int i = 0; i < 3; ++i) { |
| 1219 SimulateRefreshFrameRequest(); | 1211 SimulateRefreshFrameRequest(); |
| 1220 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN)); | 1212 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN)); |
| 1221 } | 1213 } |
| 1222 | 1214 |
| 1223 device()->StopAndDeAllocate(); | 1215 device()->StopAndDeAllocate(); |
| 1224 } | 1216 } |
| 1225 | 1217 |
| 1226 } // namespace | 1218 } // namespace |
| 1227 } // namespace content | 1219 } // namespace content |
| OLD | NEW |