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