| 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> |
| 11 | 11 |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/debug/debugger.h" | 13 #include "base/debug/debugger.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 17 #include "base/test/test_timeouts.h" | 17 #include "base/test/test_timeouts.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "base/timer/timer.h" | 19 #include "base/timer/timer.h" |
| 20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
| 21 #include "content/browser/browser_thread_impl.h" | 21 #include "content/browser/browser_thread_impl.h" |
| 22 #include "content/browser/frame_host/render_frame_host_impl.h" | 22 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 23 #include "content/browser/renderer_host/media/video_capture_buffer_handle.h" |
| 23 #include "content/browser/renderer_host/media/video_capture_buffer_pool.h" | 24 #include "content/browser/renderer_host/media/video_capture_buffer_pool.h" |
| 24 #include "content/browser/renderer_host/render_view_host_factory.h" | 25 #include "content/browser/renderer_host/render_view_host_factory.h" |
| 25 #include "content/browser/renderer_host/render_widget_host_impl.h" | 26 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 26 #include "content/browser/web_contents/web_contents_impl.h" | 27 #include "content/browser/web_contents/web_contents_impl.h" |
| 27 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" | 28 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
| 28 #include "content/public/browser/web_contents_media_capture_id.h" | 29 #include "content/public/browser/web_contents_media_capture_id.h" |
| 29 #include "content/public/test/mock_render_process_host.h" | 30 #include "content/public/test/mock_render_process_host.h" |
| 30 #include "content/public/test/test_browser_context.h" | 31 #include "content/public/test/test_browser_context.h" |
| 31 #include "content/public/test/test_browser_thread_bundle.h" | 32 #include "content/public/test/test_browser_thread_bundle.h" |
| 32 #include "content/public/test/test_utils.h" | 33 #include "content/public/test/test_utils.h" |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 void OnError(const tracked_objects::Location& from_here, | 416 void OnError(const tracked_objects::Location& from_here, |
| 416 const std::string& reason) override { | 417 const std::string& reason) override { |
| 417 error_callback_.Run(); | 418 error_callback_.Run(); |
| 418 } | 419 } |
| 419 | 420 |
| 420 double GetBufferPoolUtilization() const override { return 0.0; } | 421 double GetBufferPoolUtilization() const override { return 0.0; } |
| 421 | 422 |
| 422 private: | 423 private: |
| 423 class AutoReleaseBuffer : public media::VideoCaptureDevice::Client::Buffer { | 424 class AutoReleaseBuffer : public media::VideoCaptureDevice::Client::Buffer { |
| 424 public: | 425 public: |
| 425 AutoReleaseBuffer( | 426 AutoReleaseBuffer(const scoped_refptr<VideoCaptureBufferPool>& pool, |
| 426 const scoped_refptr<VideoCaptureBufferPool>& pool, | 427 std::unique_ptr<VideoCaptureBufferHandle> 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<VideoCaptureBufferPoolBufferHandle> buffer_handle_; | 454 const std::unique_ptr<VideoCaptureBufferHandle> 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 |