Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: media/video/capture/file_video_capture_device_factory.cc

Issue 235353002: Extract VideoCaptureDeviceFactory out of VideoCaptureDevice and use for File and FakeVCD. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #include "media/video/capture/file_video_capture_device_factory.h"
6
7 #include "base/command_line.h"
8 #include "base/files/file_path.h"
9 #include "media/base/media_switches.h"
10 #include "media/video/capture/file_video_capture_device.h"
11
12 namespace media {
13
14 const char* kFileVideoCaptureDeviceName =
15 "/dev/placeholder-for-file-backed-fake-capture-device";
16
17 // Inspects the command line and retrieves the file path parameter.
18 base::FilePath GetFilePathFromCommandLine() {
19 base::FilePath command_line_file_path =
20 CommandLine::ForCurrentProcess()->GetSwitchValuePath(
21 switches::kUseFileForFakeVideoCapture);
22 CHECK(!command_line_file_path.empty());
23 return command_line_file_path;
24 }
25
26 VideoCaptureDevice* FileVideoCaptureDeviceFactory::Create(
27 const VideoCaptureDevice::Name& device_name) {
28 #if defined(OS_WIN)
29 return new FileVideoCaptureDevice(
30 base::FilePath(base::SysUTF8ToWide(device_name.name())));
31 #else
32 return new FileVideoCaptureDevice(base::FilePath(device_name.name()));
33 #endif
34 }
35
36 void FileVideoCaptureDeviceFactory::GetDeviceNames(
37 VideoCaptureDevice::Names* const device_names) {
38 DCHECK(device_names->empty());
39 base::FilePath command_line_file_path = GetFilePathFromCommandLine();
40 #if defined(OS_WIN)
41 device_names->push_back(VideoCaptureDevice::Name(
42 base::SysWideToUTF8(command_line_file_path.value()),
43 kFileVideoCaptureDeviceName));
44 #else
45 device_names->push_back(VideoCaptureDevice::Name(
46 command_line_file_path.value(),
47 kFileVideoCaptureDeviceName));
48 #endif
49 }
50
51 void FileVideoCaptureDeviceFactory::GetDeviceSupportedFormats(
52 const VideoCaptureDevice::Name& device,
53 VideoCaptureFormats* supported_formats) {
54 base::File file =
55 FileVideoCaptureDevice::OpenFileForRead(GetFilePathFromCommandLine());
56 VideoCaptureFormat capture_format;
57 FileVideoCaptureDevice::ParseFileAndExtractVideoFormat(&file,
58 &capture_format);
59 supported_formats->push_back(capture_format);
60 }
61
62 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698