OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/in_process_video_capture_provider. h" | 5 #include "content/browser/renderer_host/media/in_process_video_capture_provider. h" |
6 | 6 |
7 #include "content/browser/renderer_host/media/in_process_video_capture_device_la uncher.h" | 7 #include "content/browser/renderer_host/media/in_process_video_capture_device_la uncher.h" |
8 | 8 |
9 namespace content { | 9 namespace content { |
10 | 10 |
11 InProcessVideoCaptureProvider::InProcessVideoCaptureProvider( | 11 InProcessVideoCaptureProvider::InProcessVideoCaptureProvider( |
12 std::unique_ptr<media::VideoCaptureSystem> video_capture_system, | 12 std::unique_ptr<media::VideoCaptureSystem> optional_video_capture_system, |
13 scoped_refptr<base::SingleThreadTaskRunner> device_task_runner) | 13 scoped_refptr<base::SingleThreadTaskRunner> device_task_runner) |
14 : video_capture_system_(std::move(video_capture_system)), | 14 : optional_video_capture_system_(std::move(optional_video_capture_system)), |
15 device_task_runner_(std::move(device_task_runner)) {} | 15 device_task_runner_(std::move(device_task_runner)) {} |
16 | 16 |
17 InProcessVideoCaptureProvider::~InProcessVideoCaptureProvider() = default; | 17 InProcessVideoCaptureProvider::~InProcessVideoCaptureProvider() = default; |
18 | 18 |
19 // static | |
20 std::unique_ptr<VideoCaptureProvider> | |
21 InProcessVideoCaptureProvider::CreateInstanceForNonDeviceCapture( | |
22 scoped_refptr<base::SingleThreadTaskRunner> device_task_runner) { | |
23 return base::MakeUnique<InProcessVideoCaptureProvider>( | |
24 nullptr, std::move(device_task_runner)); | |
25 } | |
26 | |
27 // static | |
28 std::unique_ptr<VideoCaptureProvider> | |
29 InProcessVideoCaptureProvider::CreateInstance( | |
30 std::unique_ptr<media::VideoCaptureSystem> optional_video_capture_system, | |
mcasas
2017/05/18 17:42:12
in l.29 of the .h, this parameter is called |video
chfremer
2017/05/18 18:28:31
Correct, thanks for catching this! I forgot to rem
| |
31 scoped_refptr<base::SingleThreadTaskRunner> device_task_runner) { | |
32 return base::MakeUnique<InProcessVideoCaptureProvider>( | |
33 std::move(optional_video_capture_system), std::move(device_task_runner)); | |
34 } | |
35 | |
19 void InProcessVideoCaptureProvider::Uninitialize() {} | 36 void InProcessVideoCaptureProvider::Uninitialize() {} |
20 | 37 |
21 void InProcessVideoCaptureProvider::GetDeviceInfosAsync( | 38 void InProcessVideoCaptureProvider::GetDeviceInfosAsync( |
22 const base::Callback<void( | 39 const GetDeviceInfosCallback& result_callback) { |
23 const std::vector<media::VideoCaptureDeviceInfo>&)>& result_callback) { | 40 if (!optional_video_capture_system_) { |
24 // Using Unretained() is safe because |this| owns |video_capture_system_| and | 41 std::vector<media::VideoCaptureDeviceInfo> empty_result; |
25 // |result_callback| has ownership of |this|. | 42 result_callback.Run(empty_result); |
43 return; | |
44 } | |
45 // Using Unretained() is safe because |this| owns | |
46 // |optional_video_capture_system_| and |result_callback| has ownership of | |
47 // |this|. | |
26 device_task_runner_->PostTask( | 48 device_task_runner_->PostTask( |
27 FROM_HERE, base::Bind(&media::VideoCaptureSystem::GetDeviceInfosAsync, | 49 FROM_HERE, |
28 base::Unretained(video_capture_system_.get()), | 50 base::Bind(&media::VideoCaptureSystem::GetDeviceInfosAsync, |
29 result_callback)); | 51 base::Unretained(optional_video_capture_system_.get()), |
52 result_callback)); | |
30 } | 53 } |
31 | 54 |
32 std::unique_ptr<VideoCaptureDeviceLauncher> | 55 std::unique_ptr<VideoCaptureDeviceLauncher> |
33 InProcessVideoCaptureProvider::CreateDeviceLauncher() { | 56 InProcessVideoCaptureProvider::CreateDeviceLauncher() { |
34 return base::MakeUnique<InProcessVideoCaptureDeviceLauncher>( | 57 return base::MakeUnique<InProcessVideoCaptureDeviceLauncher>( |
35 device_task_runner_, video_capture_system_.get()); | 58 device_task_runner_, optional_video_capture_system_.get()); |
36 } | 59 } |
37 | 60 |
38 } // namespace content | 61 } // namespace content |
OLD | NEW |