| 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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 | 325 |
| 326 // A stub consumer of captured video frames, which checks the output of | 326 // A stub consumer of captured video frames, which checks the output of |
| 327 // WebContentsVideoCaptureDevice. | 327 // WebContentsVideoCaptureDevice. |
| 328 class StubClient : public media::VideoCaptureDevice::Client { | 328 class StubClient : public media::VideoCaptureDevice::Client { |
| 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 VideoCaptureBufferPoolImpl(2); |
| 336 } | 336 } |
| 337 ~StubClient() override {} | 337 ~StubClient() override {} |
| 338 | 338 |
| 339 MOCK_METHOD6(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 base::TimeTicks reference_time, | 344 base::TimeTicks reference_time, |
| 345 base::TimeDelta timestamp)); | 345 base::TimeDelta timestamp)); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 error_callback_.Run(); | 417 error_callback_.Run(); |
| 418 } | 418 } |
| 419 | 419 |
| 420 double GetBufferPoolUtilization() const override { return 0.0; } | 420 double GetBufferPoolUtilization() const override { return 0.0; } |
| 421 | 421 |
| 422 private: | 422 private: |
| 423 class AutoReleaseBuffer : public media::VideoCaptureDevice::Client::Buffer { | 423 class AutoReleaseBuffer : public media::VideoCaptureDevice::Client::Buffer { |
| 424 public: | 424 public: |
| 425 AutoReleaseBuffer( | 425 AutoReleaseBuffer( |
| 426 const scoped_refptr<VideoCaptureBufferPool>& pool, | 426 const scoped_refptr<VideoCaptureBufferPool>& pool, |
| 427 std::unique_ptr<VideoCaptureBufferPool::BufferHandle> buffer_handle, | 427 std::unique_ptr<VideoCaptureBufferPoolBufferHandle> buffer_handle, |
| 428 int buffer_id) | 428 int buffer_id) |
| 429 : id_(buffer_id), | 429 : id_(buffer_id), |
| 430 pool_(pool), | 430 pool_(pool), |
| 431 buffer_handle_(std::move(buffer_handle)) { | 431 buffer_handle_(std::move(buffer_handle)) { |
| 432 DCHECK(pool_); | 432 DCHECK(pool_); |
| 433 } | 433 } |
| 434 int id() const override { return id_; } | 434 int id() const override { return id_; } |
| 435 gfx::Size dimensions() const override { | 435 gfx::Size dimensions() const override { |
| 436 return buffer_handle_->dimensions(); | 436 return buffer_handle_->dimensions(); |
| 437 } | 437 } |
| 438 size_t mapped_size() const override { | 438 size_t mapped_size() const override { |
| 439 return buffer_handle_->mapped_size(); | 439 return buffer_handle_->mapped_size(); |
| 440 } | 440 } |
| 441 void* data(int plane) override { return buffer_handle_->data(plane); } | 441 void* data(int plane) override { return buffer_handle_->data(plane); } |
| 442 ClientBuffer AsClientBuffer(int plane) override { return nullptr; } | 442 ClientBuffer AsClientBuffer(int plane) override { return nullptr; } |
| 443 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 443 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 444 base::FileDescriptor AsPlatformFile() override { | 444 base::FileDescriptor AsPlatformFile() override { |
| 445 return base::FileDescriptor(); | 445 return base::FileDescriptor(); |
| 446 } | 446 } |
| 447 #endif | 447 #endif |
| 448 | 448 |
| 449 private: | 449 private: |
| 450 ~AutoReleaseBuffer() override { pool_->RelinquishProducerReservation(id_); } | 450 ~AutoReleaseBuffer() override { pool_->RelinquishProducerReservation(id_); } |
| 451 | 451 |
| 452 const int id_; | 452 const int id_; |
| 453 const scoped_refptr<VideoCaptureBufferPool> pool_; | 453 const scoped_refptr<VideoCaptureBufferPool> pool_; |
| 454 const std::unique_ptr<VideoCaptureBufferPool::BufferHandle> buffer_handle_; | 454 const std::unique_ptr<VideoCaptureBufferPoolBufferHandle> buffer_handle_; |
| 455 }; | 455 }; |
| 456 | 456 |
| 457 scoped_refptr<VideoCaptureBufferPool> buffer_pool_; | 457 scoped_refptr<VideoCaptureBufferPool> buffer_pool_; |
| 458 base::Callback<void(SkColor, const gfx::Size&)> report_callback_; | 458 base::Callback<void(SkColor, const gfx::Size&)> report_callback_; |
| 459 base::Closure error_callback_; | 459 base::Closure error_callback_; |
| 460 | 460 |
| 461 DISALLOW_COPY_AND_ASSIGN(StubClient); | 461 DISALLOW_COPY_AND_ASSIGN(StubClient); |
| 462 }; | 462 }; |
| 463 | 463 |
| 464 class StubClientObserver { | 464 class StubClientObserver { |
| (...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1209 for (int i = 0; i < 3; ++i) { | 1209 for (int i = 0; i < 3; ++i) { |
| 1210 SimulateRefreshFrameRequest(); | 1210 SimulateRefreshFrameRequest(); |
| 1211 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN)); | 1211 ASSERT_NO_FATAL_FAILURE(client_observer()->WaitForNextColor(SK_ColorGREEN)); |
| 1212 } | 1212 } |
| 1213 | 1213 |
| 1214 device()->StopAndDeAllocate(); | 1214 device()->StopAndDeAllocate(); |
| 1215 } | 1215 } |
| 1216 | 1216 |
| 1217 } // namespace | 1217 } // namespace |
| 1218 } // namespace content | 1218 } // namespace content |
| OLD | NEW |