OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "media/video/capture/video_capture_device_factory.h" | 5 #include "media/video/capture/video_capture_device_factory.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "media/base/media_switches.h" | 8 #include "media/base/media_switches.h" |
9 #include "media/video/capture/fake_video_capture_device_factory.h" | 9 #include "media/video/capture/fake_video_capture_device_factory.h" |
10 #include "media/video/capture/file_video_capture_device_factory.h" | 10 #include "media/video/capture/file_video_capture_device_factory.h" |
11 | 11 |
12 #if defined(OS_MACOSX) | 12 #if defined(OS_MACOSX) |
13 #include "media/video/capture/mac/video_capture_device_factory_mac.h" | 13 #include "media/video/capture/mac/video_capture_device_factory_mac.h" |
14 #elif defined(OS_LINUX) | 14 #elif defined(OS_LINUX) |
15 #include "media/video/capture/linux/video_capture_device_factory_linux.h" | 15 #include "media/video/capture/linux/video_capture_device_factory_linux.h" |
16 #elif defined(OS_ANDROID) | 16 #elif defined(OS_ANDROID) |
17 #include "media/video/capture/android/video_capture_device_factory_android.h" | 17 #include "media/video/capture/android/video_capture_device_factory_android.h" |
18 #elif defined(OS_WIN) | 18 #elif defined(OS_WIN) |
19 #include "media/video/capture/win/video_capture_device_factory_win.h" | 19 #include "media/video/capture/win/video_capture_device_factory_win.h" |
20 #endif | 20 #endif |
21 | 21 |
22 namespace media { | 22 namespace media { |
23 | 23 |
24 // static | 24 // static |
25 scoped_ptr<VideoCaptureDeviceFactory> | 25 scoped_ptr<VideoCaptureDeviceFactory> VideoCaptureDeviceFactory::CreateFactory( |
26 VideoCaptureDeviceFactory::CreateFactory() { | 26 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
27 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 27 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
28 // Use a Fake or File Video Device Factory if the command line flags are | 28 // Use a Fake or File Video Device Factory if the command line flags are |
29 // present, otherwise use the normal, platform-dependent, device factory. | 29 // present, otherwise use the normal, platform-dependent, device factory. |
30 if (command_line->HasSwitch(switches::kUseFakeDeviceForMediaStream)) { | 30 if (command_line->HasSwitch(switches::kUseFakeDeviceForMediaStream)) { |
31 if (command_line->HasSwitch(switches::kUseFileForFakeVideoCapture)) { | 31 if (command_line->HasSwitch(switches::kUseFileForFakeVideoCapture)) { |
32 return scoped_ptr<VideoCaptureDeviceFactory>(new | 32 return scoped_ptr<VideoCaptureDeviceFactory>(new |
33 media::FileVideoCaptureDeviceFactory()); | 33 media::FileVideoCaptureDeviceFactory()); |
34 } else { | 34 } else { |
35 return scoped_ptr<VideoCaptureDeviceFactory>(new | 35 return scoped_ptr<VideoCaptureDeviceFactory>(new |
36 media::FakeVideoCaptureDeviceFactory()); | 36 media::FakeVideoCaptureDeviceFactory()); |
37 } | 37 } |
38 } else { | 38 } else { |
| 39 // |ui_task_runner| is needed for the Linux ChromeOS factory to retrieve |
| 40 // screen rotations and for the Mac factory to run QTKit device enumeration. |
39 #if defined(OS_MACOSX) | 41 #if defined(OS_MACOSX) |
40 return scoped_ptr<VideoCaptureDeviceFactory>(new | 42 return scoped_ptr<VideoCaptureDeviceFactory>(new |
41 VideoCaptureDeviceFactoryMac()); | 43 VideoCaptureDeviceFactoryMac(ui_task_runner)); |
42 #elif defined(OS_LINUX) | 44 #elif defined(OS_LINUX) |
43 return scoped_ptr<VideoCaptureDeviceFactory>(new | 45 return scoped_ptr<VideoCaptureDeviceFactory>(new |
44 VideoCaptureDeviceFactoryLinux()); | 46 VideoCaptureDeviceFactoryLinux(ui_task_runner)); |
45 #elif defined(OS_LINUX) | |
46 return scoped_ptr<VideoCaptureDeviceFactory>(new | |
47 VideoCaptureDeviceFactoryLinux()); | |
48 #elif defined(OS_ANDROID) | 47 #elif defined(OS_ANDROID) |
49 return scoped_ptr<VideoCaptureDeviceFactory>(new | 48 return scoped_ptr<VideoCaptureDeviceFactory>(new |
50 VideoCaptureDeviceFactoryAndroid()); | 49 VideoCaptureDeviceFactoryAndroid()); |
51 #elif defined(OS_WIN) | 50 #elif defined(OS_WIN) |
52 return scoped_ptr<VideoCaptureDeviceFactory>(new | 51 return scoped_ptr<VideoCaptureDeviceFactory>(new |
53 VideoCaptureDeviceFactoryWin()); | 52 VideoCaptureDeviceFactoryWin()); |
54 #else | 53 #else |
55 return scoped_ptr<VideoCaptureDeviceFactory>(new | 54 return scoped_ptr<VideoCaptureDeviceFactory>(new |
56 VideoCaptureDeviceFactory()); | 55 VideoCaptureDeviceFactory()); |
57 #endif | 56 #endif |
58 } | 57 } |
59 } | 58 } |
60 | 59 |
61 VideoCaptureDeviceFactory::VideoCaptureDeviceFactory() { | 60 VideoCaptureDeviceFactory::VideoCaptureDeviceFactory() { |
62 thread_checker_.DetachFromThread(); | 61 thread_checker_.DetachFromThread(); |
63 } | 62 } |
64 | 63 |
65 VideoCaptureDeviceFactory::~VideoCaptureDeviceFactory() {} | 64 VideoCaptureDeviceFactory::~VideoCaptureDeviceFactory() {} |
66 | 65 |
67 scoped_ptr<VideoCaptureDevice> VideoCaptureDeviceFactory::Create( | 66 void VideoCaptureDeviceFactory::EnumerateDeviceNames(const base::Callback< |
68 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 67 void(scoped_ptr<media::VideoCaptureDevice::Names>)>& callback) { |
69 const VideoCaptureDevice::Name& device_name) { | |
70 DCHECK(thread_checker_.CalledOnValidThread()); | 68 DCHECK(thread_checker_.CalledOnValidThread()); |
71 return scoped_ptr<VideoCaptureDevice>( | 69 DCHECK(!callback.is_null()); |
72 VideoCaptureDevice::Create(ui_task_runner, device_name)); | 70 scoped_ptr<VideoCaptureDevice::Names> device_names( |
73 } | 71 new VideoCaptureDevice::Names()); |
74 | 72 GetDeviceNames(device_names.get()); |
75 void VideoCaptureDeviceFactory::GetDeviceNames( | 73 callback.Run(device_names.Pass()); |
76 VideoCaptureDevice::Names* device_names) { | |
77 DCHECK(thread_checker_.CalledOnValidThread()); | |
78 VideoCaptureDevice::GetDeviceNames(device_names); | |
79 } | |
80 | |
81 void VideoCaptureDeviceFactory::GetDeviceSupportedFormats( | |
82 const VideoCaptureDevice::Name& device, | |
83 VideoCaptureFormats* supported_formats) { | |
84 DCHECK(thread_checker_.CalledOnValidThread()); | |
85 VideoCaptureDevice::GetDeviceSupportedFormats(device, supported_formats); | |
86 } | 74 } |
87 | 75 |
88 } // namespace media | 76 } // namespace media |
OLD | NEW |