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" | |
8 #include "media/base/media_switches.h" | |
9 #include "media/video/capture/fake_video_capture_device_factory.h" | |
10 #include "media/video/capture/file_video_capture_device_factory.h" | |
11 | |
12 #if defined(OS_MACOSX) | |
13 #include "media/video/capture/mac/video_capture_device_factory_mac.h" | |
14 #endif | |
15 | |
16 namespace media { | 7 namespace media { |
17 | 8 |
18 // static | |
19 scoped_ptr<VideoCaptureDeviceFactory> | |
20 VideoCaptureDeviceFactory::CreateFactory() { | |
21 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
22 // Use a Fake or File Video Device Factory if the command line flags are | |
23 // present, otherwise use the normal, platform-dependent, device factory. | |
24 if (command_line->HasSwitch(switches::kUseFakeDeviceForMediaStream)) { | |
25 if (command_line->HasSwitch(switches::kUseFileForFakeVideoCapture)) { | |
26 return scoped_ptr<VideoCaptureDeviceFactory>(new | |
27 media::FileVideoCaptureDeviceFactory()); | |
28 } else { | |
29 return scoped_ptr<VideoCaptureDeviceFactory>(new | |
30 media::FakeVideoCaptureDeviceFactory()); | |
31 } | |
32 } else { | |
33 #if defined(OS_MACOSX) | |
34 return scoped_ptr<VideoCaptureDeviceFactory>(new | |
35 VideoCaptureDeviceFactoryMac()); | |
36 #else | |
37 return scoped_ptr<VideoCaptureDeviceFactory>(new | |
38 VideoCaptureDeviceFactory()); | |
39 #endif | |
40 } | |
41 } | |
42 | |
43 VideoCaptureDeviceFactory::VideoCaptureDeviceFactory() { | 9 VideoCaptureDeviceFactory::VideoCaptureDeviceFactory() { |
44 thread_checker_.DetachFromThread(); | 10 thread_checker_.DetachFromThread(); |
45 } | 11 }; |
46 | |
47 VideoCaptureDeviceFactory::~VideoCaptureDeviceFactory() {} | |
48 | 12 |
49 scoped_ptr<VideoCaptureDevice> VideoCaptureDeviceFactory::Create( | 13 scoped_ptr<VideoCaptureDevice> VideoCaptureDeviceFactory::Create( |
50 const VideoCaptureDevice::Name& device_name) { | 14 const VideoCaptureDevice::Name& device_name) { |
51 DCHECK(thread_checker_.CalledOnValidThread()); | 15 DCHECK(thread_checker_.CalledOnValidThread()); |
52 return scoped_ptr<VideoCaptureDevice>( | 16 return scoped_ptr<VideoCaptureDevice>( |
53 VideoCaptureDevice::Create(device_name)); | 17 VideoCaptureDevice::Create(device_name)); |
54 } | 18 } |
55 | 19 |
56 void VideoCaptureDeviceFactory::GetDeviceNames( | 20 void VideoCaptureDeviceFactory::GetDeviceNames( |
57 VideoCaptureDevice::Names* device_names) { | 21 VideoCaptureDevice::Names* device_names) { |
58 DCHECK(thread_checker_.CalledOnValidThread()); | 22 DCHECK(thread_checker_.CalledOnValidThread()); |
59 VideoCaptureDevice::GetDeviceNames(device_names); | 23 VideoCaptureDevice::GetDeviceNames(device_names); |
60 } | 24 } |
61 | 25 |
62 void VideoCaptureDeviceFactory::GetDeviceSupportedFormats( | 26 void VideoCaptureDeviceFactory::GetDeviceSupportedFormats( |
63 const VideoCaptureDevice::Name& device, | 27 const VideoCaptureDevice::Name& device, |
64 VideoCaptureFormats* supported_formats) { | 28 VideoCaptureFormats* supported_formats) { |
65 DCHECK(thread_checker_.CalledOnValidThread()); | 29 DCHECK(thread_checker_.CalledOnValidThread()); |
66 VideoCaptureDevice::GetDeviceSupportedFormats(device, supported_formats); | 30 VideoCaptureDevice::GetDeviceSupportedFormats(device, supported_formats); |
67 } | 31 } |
68 | 32 |
69 } // namespace media | 33 } // namespace media |
OLD | NEW |