Disable firewall check. It takes signifficant time, need to be on FILE thread.
[chromium-blink-merge.git] / media / video / capture / file_video_capture_device_factory.cc
blobdab9a5168de45f8a7aa1f3411fc356a6d2521324
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/video/capture/file_video_capture_device_factory.h"
7 #include "base/command_line.h"
8 #include "base/files/file_path.h"
9 #include "base/strings/sys_string_conversions.h"
10 #include "media/base/media_switches.h"
11 #include "media/video/capture/file_video_capture_device.h"
13 namespace media {
15 const char kFileVideoCaptureDeviceName[] =
16 "/dev/placeholder-for-file-backed-fake-capture-device";
18 // Inspects the command line and retrieves the file path parameter.
19 base::FilePath GetFilePathFromCommandLine() {
20 base::FilePath command_line_file_path =
21 CommandLine::ForCurrentProcess()->GetSwitchValuePath(
22 switches::kUseFileForFakeVideoCapture);
23 CHECK(!command_line_file_path.empty());
24 return command_line_file_path;
27 scoped_ptr<VideoCaptureDevice> FileVideoCaptureDeviceFactory::Create(
28 const VideoCaptureDevice::Name& device_name) {
29 #if defined(OS_WIN)
30 return scoped_ptr<VideoCaptureDevice>(new FileVideoCaptureDevice(
31 base::FilePath(base::SysUTF8ToWide(device_name.name()))));
32 #else
33 return scoped_ptr<VideoCaptureDevice>(new FileVideoCaptureDevice(
34 base::FilePath(device_name.name())));
35 #endif
38 void FileVideoCaptureDeviceFactory::GetDeviceNames(
39 VideoCaptureDevice::Names* const device_names) {
40 DCHECK(device_names->empty());
41 base::FilePath command_line_file_path = GetFilePathFromCommandLine();
42 #if defined(OS_WIN)
43 device_names->push_back(VideoCaptureDevice::Name(
44 base::SysWideToUTF8(command_line_file_path.value()),
45 kFileVideoCaptureDeviceName));
46 #else
47 device_names->push_back(VideoCaptureDevice::Name(
48 command_line_file_path.value(),
49 kFileVideoCaptureDeviceName));
50 #endif
53 void FileVideoCaptureDeviceFactory::GetDeviceSupportedFormats(
54 const VideoCaptureDevice::Name& device,
55 VideoCaptureFormats* supported_formats) {
56 base::File file =
57 FileVideoCaptureDevice::OpenFileForRead(GetFilePathFromCommandLine());
58 VideoCaptureFormat capture_format;
59 FileVideoCaptureDevice::ParseFileAndExtractVideoFormat(&file,
60 &capture_format);
61 supported_formats->push_back(capture_format);
64 } // namespace media