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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 StubClient( | 331 StubClient( |
332 const base::Callback<void(SkColor, const gfx::Size&)>& report_callback, | 332 const base::Callback<void(SkColor, const gfx::Size&)>& report_callback, |
333 const base::Closure& error_callback) | 333 const base::Closure& error_callback) |
334 : report_callback_(report_callback), | 334 : report_callback_(report_callback), |
335 error_callback_(error_callback) { | 335 error_callback_(error_callback) { |
336 buffer_pool_ = new media::VideoCaptureBufferPoolImpl( | 336 buffer_pool_ = new media::VideoCaptureBufferPoolImpl( |
337 base::MakeUnique<media::VideoCaptureBufferTrackerFactoryImpl>(), 2); | 337 base::MakeUnique<media::VideoCaptureBufferTrackerFactoryImpl>(), 2); |
338 } | 338 } |
339 ~StubClient() override {} | 339 ~StubClient() override {} |
340 | 340 |
341 MOCK_METHOD6(OnIncomingCapturedData, | 341 MOCK_METHOD7(OnIncomingCapturedData, |
342 void(const uint8_t* data, | 342 void(const uint8_t* data, |
343 int length, | 343 int length, |
344 const media::VideoCaptureFormat& frame_format, | 344 const media::VideoCaptureFormat& frame_format, |
345 int rotation, | 345 int rotation, |
346 base::TimeTicks reference_time, | 346 base::TimeTicks reference_time, |
347 base::TimeDelta timestamp)); | 347 base::TimeDelta timestamp, |
| 348 int frame_id)); |
348 | 349 |
349 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void)); | 350 MOCK_METHOD0(DoOnIncomingCapturedBuffer, void(void)); |
350 | 351 |
351 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> | 352 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> |
352 ReserveOutputBuffer(const gfx::Size& dimensions, | 353 ReserveOutputBuffer(const gfx::Size& dimensions, |
353 media::VideoPixelFormat format, | 354 media::VideoPixelFormat format, |
354 media::VideoPixelStorage storage) override { | 355 media::VideoPixelStorage storage) override { |
355 CHECK_EQ(format, media::PIXEL_FORMAT_I420); | 356 CHECK_EQ(format, media::PIXEL_FORMAT_I420); |
356 int buffer_id_to_drop = | 357 int buffer_id_to_drop = |
357 media::VideoCaptureBufferPool::kInvalidId; // Ignored. | 358 media::VideoCaptureBufferPool::kInvalidId; // Ignored. |
358 const int buffer_id = buffer_pool_->ReserveForProducer( | 359 const int buffer_id = buffer_pool_->ReserveForProducer( |
359 dimensions, format, storage, &buffer_id_to_drop); | 360 dimensions, format, storage, &buffer_id_to_drop); |
360 if (buffer_id == media::VideoCaptureBufferPool::kInvalidId) | 361 if (buffer_id == media::VideoCaptureBufferPool::kInvalidId) |
361 return NULL; | 362 return NULL; |
362 | 363 |
363 return std::unique_ptr<media::VideoCaptureDevice::Client::Buffer>( | 364 return std::unique_ptr<media::VideoCaptureDevice::Client::Buffer>( |
364 new AutoReleaseBuffer( | 365 new AutoReleaseBuffer( |
365 buffer_pool_, buffer_pool_->GetBufferHandle(buffer_id), buffer_id)); | 366 buffer_pool_, buffer_pool_->GetBufferHandle(buffer_id), buffer_id)); |
366 } | 367 } |
367 | 368 |
368 // Trampoline method to workaround GMOCK problems with std::unique_ptr<>. | 369 // Trampoline method to workaround GMOCK problems with std::unique_ptr<>. |
369 void OnIncomingCapturedBuffer(std::unique_ptr<Buffer> buffer, | 370 void OnIncomingCapturedBuffer(std::unique_ptr<Buffer> buffer, |
370 const media::VideoCaptureFormat& frame_format, | 371 const media::VideoCaptureFormat& format, |
371 base::TimeTicks reference_time, | 372 base::TimeTicks reference_time, |
372 base::TimeDelta timestamp) override { | 373 base::TimeDelta timestamp, |
| 374 int frame_id) override { |
373 DoOnIncomingCapturedBuffer(); | 375 DoOnIncomingCapturedBuffer(); |
374 } | 376 } |
375 | 377 |
376 void OnIncomingCapturedVideoFrame( | 378 void OnIncomingCapturedVideoFrame( |
377 std::unique_ptr<Buffer> buffer, | 379 std::unique_ptr<Buffer> buffer, |
378 scoped_refptr<media::VideoFrame> frame) override { | 380 scoped_refptr<media::VideoFrame> frame, |
| 381 int frame_id) override { |
379 EXPECT_FALSE(frame->visible_rect().IsEmpty()); | 382 EXPECT_FALSE(frame->visible_rect().IsEmpty()); |
380 EXPECT_EQ(media::PIXEL_FORMAT_I420, frame->format()); | 383 EXPECT_EQ(media::PIXEL_FORMAT_I420, frame->format()); |
381 double frame_rate = 0; | 384 double frame_rate = 0; |
382 EXPECT_TRUE( | 385 EXPECT_TRUE( |
383 frame->metadata()->GetDouble(media::VideoFrameMetadata::FRAME_RATE, | 386 frame->metadata()->GetDouble(media::VideoFrameMetadata::FRAME_RATE, |
384 &frame_rate)); | 387 &frame_rate)); |
385 EXPECT_EQ(kTestFramesPerSecond, frame_rate); | 388 EXPECT_EQ(kTestFramesPerSecond, frame_rate); |
386 | 389 |
387 // TODO(miu): We just look at the center pixel presently, because if the | 390 // TODO(miu): We just look at the center pixel presently, because if the |
388 // analysis is too slow, the backlog of frames will grow without bound and | 391 // analysis is too slow, the backlog of frames will grow without bound and |
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1263 for (int i = 0; i < 3; ++i) { | 1266 for (int i = 0; i < 3; ++i) { |
1264 SimulateRefreshFrameRequest(); | 1267 SimulateRefreshFrameRequest(); |
1265 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN)); | 1268 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN)); |
1266 } | 1269 } |
1267 | 1270 |
1268 device()->StopAndDeAllocate(); | 1271 device()->StopAndDeAllocate(); |
1269 } | 1272 } |
1270 | 1273 |
1271 } // namespace | 1274 } // namespace |
1272 } // namespace content | 1275 } // namespace content |
OLD | NEW |