Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: content/browser/renderer_host/media/video_capture_controller_unittest.cc

Issue 2795663002: Change VideoFrameReceiverOnIOThread to VideoFrameReceiverOnTaskRunner (Closed)
Patch Set: Rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 new MockVideoCaptureControllerEventHandler(controller_.get())); 185 new MockVideoCaptureControllerEventHandler(controller_.get()));
185 } 186 }
186 187
187 void TearDown() override { base::RunLoop().RunUntilIdle(); } 188 void TearDown() override { base::RunLoop().RunUntilIdle(); }
188 189
189 void InitializeNewDeviceClientAndBufferPoolInstances() { 190 void InitializeNewDeviceClientAndBufferPoolInstances() {
190 buffer_pool_ = new media::VideoCaptureBufferPoolImpl( 191 buffer_pool_ = new media::VideoCaptureBufferPoolImpl(
191 base::MakeUnique<media::VideoCaptureBufferTrackerFactoryImpl>(), 192 base::MakeUnique<media::VideoCaptureBufferTrackerFactoryImpl>(),
192 kPoolSize); 193 kPoolSize);
193 device_client_.reset(new media::VideoCaptureDeviceClient( 194 device_client_.reset(new media::VideoCaptureDeviceClient(
194 base::MakeUnique<VideoFrameReceiverOnIOThread>( 195 base::MakeUnique<media::VideoFrameReceiverOnTaskRunner>(
195 controller_->GetWeakPtrForIOThread()), 196 controller_->GetWeakPtrForIOThread(),
197 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)),
196 buffer_pool_, 198 buffer_pool_,
197 base::Bind(&CreateGpuJpegDecoder, 199 base::Bind(&CreateGpuJpegDecoder,
198 base::Bind(&media::VideoFrameReceiver::OnFrameReadyInBuffer, 200 base::Bind(&media::VideoFrameReceiver::OnFrameReadyInBuffer,
199 controller_->GetWeakPtrForIOThread())))); 201 controller_->GetWeakPtrForIOThread()))));
200 } 202 }
201 203
202 void SendStubFrameToDeviceClient(const media::VideoCaptureFormat format) { 204 void SendStubFrameToDeviceClient(const media::VideoCaptureFormat format) {
203 auto stub_frame = media::VideoFrame::CreateZeroInitializedFrame( 205 auto stub_frame = media::VideoFrame::CreateZeroInitializedFrame(
204 format.pixel_format, format.frame_size, 206 format.pixel_format, format.frame_size,
205 gfx::Rect(format.frame_size.width(), format.frame_size.height()), 207 gfx::Rect(format.frame_size.width(), format.frame_size.height()),
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 EXPECT_CALL(*client_b_, OnStarted(_)); 863 EXPECT_CALL(*client_b_, OnStarted(_));
862 device_client_->OnStarted(); 864 device_client_->OnStarted();
863 865
864 // VideoCaptureController will take care of the OnStarted event for the 866 // VideoCaptureController will take care of the OnStarted event for the
865 // clients who join later. 867 // clients who join later.
866 EXPECT_CALL(*client_a_, OnStarted(_)); 868 EXPECT_CALL(*client_a_, OnStarted(_));
867 controller_->AddClient(client_a_route_2, client_a_.get(), 200, session_200); 869 controller_->AddClient(client_a_route_2, client_a_.get(), 200, session_200);
868 } 870 }
869 } 871 }
870 } // namespace content 872 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698