Chromium Code Reviews| Index: media/video/capture/file_video_capture_device_factory.cc |
| diff --git a/media/video/capture/file_video_capture_device_factory.cc b/media/video/capture/file_video_capture_device_factory.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e177dcc2ea7d35b60f4bdc43002afe34aed3b0ec |
| --- /dev/null |
| +++ b/media/video/capture/file_video_capture_device_factory.cc |
| @@ -0,0 +1,64 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "media/video/capture/file_video_capture_device_factory.h" |
| + |
| +#include "base/command_line.h" |
| +#include "base/files/file_path.h" |
| +#include "base/strings/sys_string_conversions.h" |
| +#include "media/base/media_switches.h" |
| +#include "media/video/capture/file_video_capture_device.h" |
| + |
| +namespace media { |
| + |
| +const char* kFileVideoCaptureDeviceName = |
|
tommi (sloooow) - chröme
2014/04/23 14:33:59
const char kFileVideoCaptureDeviceName[]
mcasas
2014/04/23 15:13:30
Done.
|
| + "/dev/placeholder-for-file-backed-fake-capture-device"; |
| + |
| +// Inspects the command line and retrieves the file path parameter. |
| +base::FilePath GetFilePathFromCommandLine() { |
| + base::FilePath command_line_file_path = |
| + CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
| + switches::kUseFileForFakeVideoCapture); |
| + CHECK(!command_line_file_path.empty()); |
| + return command_line_file_path; |
| +} |
| + |
| +scoped_ptr<VideoCaptureDevice> FileVideoCaptureDeviceFactory::Create( |
| + const VideoCaptureDevice::Name& device_name) { |
| +#if defined(OS_WIN) |
| + return scoped_ptr<VideoCaptureDevice>(new FileVideoCaptureDevice( |
| + base::FilePath(base::SysUTF8ToWide(device_name.name())))); |
| +#else |
| + return scoped_ptr<VideoCaptureDevice>(new FileVideoCaptureDevice( |
| + base::FilePath(device_name.name()))); |
| +#endif |
| +} |
| + |
| +void FileVideoCaptureDeviceFactory::GetDeviceNames( |
| + VideoCaptureDevice::Names* const device_names) { |
| + DCHECK(device_names->empty()); |
| + base::FilePath command_line_file_path = GetFilePathFromCommandLine(); |
| +#if defined(OS_WIN) |
| + device_names->push_back(VideoCaptureDevice::Name( |
| + base::SysWideToUTF8(command_line_file_path.value()), |
| + kFileVideoCaptureDeviceName)); |
| +#else |
| + device_names->push_back(VideoCaptureDevice::Name( |
| + command_line_file_path.value(), |
| + kFileVideoCaptureDeviceName)); |
| +#endif |
| +} |
| + |
| +void FileVideoCaptureDeviceFactory::GetDeviceSupportedFormats( |
| + const VideoCaptureDevice::Name& device, |
| + VideoCaptureFormats* supported_formats) { |
| + base::File file = |
| + FileVideoCaptureDevice::OpenFileForRead(GetFilePathFromCommandLine()); |
| + VideoCaptureFormat capture_format; |
| + FileVideoCaptureDevice::ParseFileAndExtractVideoFormat(&file, |
| + &capture_format); |
| + supported_formats->push_back(capture_format); |
| +} |
| + |
| +} // namespace media |