Updating XTBs based on .GRDs from branch master
[chromium-blink-merge.git] / media / capture / video / video_capture_device_factory.cc
blobaa6be6f5ee752ad99a46d5225ecb6836a57171cc
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
3 // found in the LICENSE file.
5 #include "media/capture/video/video_capture_device_factory.h"
7 #include "base/command_line.h"
8 #include "media/base/media_switches.h"
9 #include "media/capture/video/fake_video_capture_device_factory.h"
10 #include "media/capture/video/file_video_capture_device_factory.h"
12 namespace media {
14 // static
15 scoped_ptr<VideoCaptureDeviceFactory> VideoCaptureDeviceFactory::CreateFactory(
16 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
17 const base::CommandLine* command_line =
18 base::CommandLine::ForCurrentProcess();
19 // Use a Fake or File Video Device Factory if the command line flags are
20 // present, otherwise use the normal, platform-dependent, device factory.
21 if (command_line->HasSwitch(switches::kUseFakeDeviceForMediaStream)) {
22 if (command_line->HasSwitch(switches::kUseFileForFakeVideoCapture)) {
23 return scoped_ptr<VideoCaptureDeviceFactory>(
24 new media::FileVideoCaptureDeviceFactory());
25 } else {
26 return scoped_ptr<VideoCaptureDeviceFactory>(
27 new media::FakeVideoCaptureDeviceFactory());
29 } else {
30 // |ui_task_runner| is needed for the Linux ChromeOS factory to retrieve
31 // screen rotations and for the Mac factory to run QTKit device enumeration.
32 return scoped_ptr<VideoCaptureDeviceFactory>(
33 CreateVideoCaptureDeviceFactory(ui_task_runner));
37 VideoCaptureDeviceFactory::VideoCaptureDeviceFactory() {
38 thread_checker_.DetachFromThread();
41 VideoCaptureDeviceFactory::~VideoCaptureDeviceFactory() {
44 void VideoCaptureDeviceFactory::EnumerateDeviceNames(const base::Callback<
45 void(scoped_ptr<media::VideoCaptureDevice::Names>)>& callback) {
46 DCHECK(thread_checker_.CalledOnValidThread());
47 DCHECK(!callback.is_null());
48 scoped_ptr<VideoCaptureDevice::Names> device_names(
49 new VideoCaptureDevice::Names());
50 GetDeviceNames(device_names.get());
51 callback.Run(device_names.Pass());
54 #if !defined(OS_MACOSX) && !defined(OS_LINUX) && !defined(OS_ANDROID) && \
55 !defined(OS_WIN)
56 // static
57 VideoCaptureDeviceFactory*
58 VideoCaptureDeviceFactory::CreateVideoCaptureDeviceFactory(
59 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
60 NOTIMPLEMENTED();
61 return NULL;
63 #endif
65 } // namespace media