| 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/video_capture_controller.h" | 5 #include "content/browser/renderer_host/media/video_capture_controller.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <utility> | 12 #include <utility> |
| 13 | 13 |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/bind_helpers.h" | 15 #include "base/bind_helpers.h" |
| 16 #include "base/location.h" | 16 #include "base/location.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/ptr_util.h" | 18 #include "base/memory/ptr_util.h" |
| 19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
| 20 #include "base/run_loop.h" | 20 #include "base/run_loop.h" |
| 21 #include "base/single_thread_task_runner.h" | 21 #include "base/single_thread_task_runner.h" |
| 22 #include "base/threading/thread_task_runner_handle.h" | 22 #include "base/threading/thread_task_runner_handle.h" |
| 23 #include "content/browser/renderer_host/media/media_stream_provider.h" | 23 #include "content/browser/renderer_host/media/media_stream_provider.h" |
| 24 #include "content/browser/renderer_host/media/video_capture_controller_event_han
dler.h" | 24 #include "content/browser/renderer_host/media/video_capture_controller_event_han
dler.h" |
| 25 #include "content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.h" | 25 #include "content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.h" |
| 26 #include "content/browser/renderer_host/media/video_capture_manager.h" | 26 #include "content/browser/renderer_host/media/video_capture_manager.h" |
| 27 #include "content/browser/renderer_host/media/video_frame_receiver_on_io_thread.
h" | |
| 28 #include "content/common/media/media_stream_options.h" | 27 #include "content/common/media/media_stream_options.h" |
| 28 #include "content/public/browser/browser_thread.h" |
| 29 #include "content/public/test/test_browser_thread_bundle.h" | 29 #include "content/public/test/test_browser_thread_bundle.h" |
| 30 #include "media/base/video_frame_metadata.h" | 30 #include "media/base/video_frame_metadata.h" |
| 31 #include "media/base/video_util.h" | 31 #include "media/base/video_util.h" |
| 32 #include "media/capture/video/video_capture_buffer_pool_impl.h" | 32 #include "media/capture/video/video_capture_buffer_pool_impl.h" |
| 33 #include "media/capture/video/video_capture_buffer_tracker_factory_impl.h" | 33 #include "media/capture/video/video_capture_buffer_tracker_factory_impl.h" |
| 34 #include "media/capture/video/video_capture_device_client.h" | 34 #include "media/capture/video/video_capture_device_client.h" |
| 35 #include "media/capture/video/video_frame_receiver_on_task_runner.h" |
| 35 #include "media/capture/video_capture_types.h" | 36 #include "media/capture/video_capture_types.h" |
| 36 #include "testing/gmock/include/gmock/gmock.h" | 37 #include "testing/gmock/include/gmock/gmock.h" |
| 37 #include "testing/gtest/include/gtest/gtest.h" | 38 #include "testing/gtest/include/gtest/gtest.h" |
| 38 | 39 |
| 39 using ::testing::_; | 40 using ::testing::_; |
| 40 using ::testing::AnyNumber; | 41 using ::testing::AnyNumber; |
| 41 using ::testing::InSequence; | 42 using ::testing::InSequence; |
| 42 using ::testing::Mock; | 43 using ::testing::Mock; |
| 43 using ::testing::SaveArg; | 44 using ::testing::SaveArg; |
| 44 | 45 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 new MockVideoCaptureControllerEventHandler(controller_.get())); | 152 new MockVideoCaptureControllerEventHandler(controller_.get())); |
| 152 } | 153 } |
| 153 | 154 |
| 154 void TearDown() override { base::RunLoop().RunUntilIdle(); } | 155 void TearDown() override { base::RunLoop().RunUntilIdle(); } |
| 155 | 156 |
| 156 void InitializeNewDeviceClientAndBufferPoolInstances() { | 157 void InitializeNewDeviceClientAndBufferPoolInstances() { |
| 157 buffer_pool_ = new media::VideoCaptureBufferPoolImpl( | 158 buffer_pool_ = new media::VideoCaptureBufferPoolImpl( |
| 158 base::MakeUnique<media::VideoCaptureBufferTrackerFactoryImpl>(), | 159 base::MakeUnique<media::VideoCaptureBufferTrackerFactoryImpl>(), |
| 159 kPoolSize); | 160 kPoolSize); |
| 160 device_client_.reset(new media::VideoCaptureDeviceClient( | 161 device_client_.reset(new media::VideoCaptureDeviceClient( |
| 161 base::MakeUnique<VideoFrameReceiverOnIOThread>( | 162 base::MakeUnique<media::VideoFrameReceiverOnTaskRunner>( |
| 162 controller_->GetWeakPtrForIOThread()), | 163 controller_->GetWeakPtrForIOThread(), |
| 164 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)), |
| 163 buffer_pool_, | 165 buffer_pool_, |
| 164 base::Bind(&CreateGpuJpegDecoder, | 166 base::Bind(&CreateGpuJpegDecoder, |
| 165 base::Bind(&media::VideoFrameReceiver::OnFrameReadyInBuffer, | 167 base::Bind(&media::VideoFrameReceiver::OnFrameReadyInBuffer, |
| 166 controller_->GetWeakPtrForIOThread())))); | 168 controller_->GetWeakPtrForIOThread())))); |
| 167 } | 169 } |
| 168 | 170 |
| 169 void SendStubFrameToDeviceClient(const media::VideoCaptureFormat format) { | 171 void SendStubFrameToDeviceClient(const media::VideoCaptureFormat format) { |
| 170 auto stub_frame = media::VideoFrame::CreateZeroInitializedFrame( | 172 auto stub_frame = media::VideoFrame::CreateZeroInitializedFrame( |
| 171 format.pixel_format, format.frame_size, | 173 format.pixel_format, format.frame_size, |
| 172 gfx::Rect(format.frame_size.width(), format.frame_size.height()), | 174 gfx::Rect(format.frame_size.width(), format.frame_size.height()), |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 EXPECT_CALL(*client_b_, OnStarted(_)); | 830 EXPECT_CALL(*client_b_, OnStarted(_)); |
| 829 device_client_->OnStarted(); | 831 device_client_->OnStarted(); |
| 830 | 832 |
| 831 // VideoCaptureController will take care of the OnStarted event for the | 833 // VideoCaptureController will take care of the OnStarted event for the |
| 832 // clients who join later. | 834 // clients who join later. |
| 833 EXPECT_CALL(*client_a_, OnStarted(_)); | 835 EXPECT_CALL(*client_a_, OnStarted(_)); |
| 834 controller_->AddClient(client_a_route_2, client_a_.get(), 200, session_200); | 836 controller_->AddClient(client_a_route_2, client_a_.get(), 200, session_200); |
| 835 } | 837 } |
| 836 } | 838 } |
| 837 } // namespace content | 839 } // namespace content |
| OLD | NEW |