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

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

Issue 2169013002: Change class VideoCaptureDevice::Name to struct VideoCaptureDeviceDescriptor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactoring of VideoCaptureDeviceFactory interface Created 4 years, 5 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
OLDNEW
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/capture/video/file_video_capture_device_factory.h" 5 #include "media/capture/video/file_video_capture_device_factory.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "media/base/media_switches.h" 11 #include "media/base/media_switches.h"
12 #include "media/capture/video/file_video_capture_device.h" 12 #include "media/capture/video/file_video_capture_device.h"
13 13
14 namespace media { 14 namespace media {
15 15
16 const char kFileVideoCaptureDeviceName[] = 16 const char kFileVideoCaptureDeviceName[] =
17 "/dev/placeholder-for-file-backed-fake-capture-device"; 17 "/dev/placeholder-for-file-backed-fake-capture-device";
18 18
19 // Inspects the command line and retrieves the file path parameter. 19 // Inspects the command line and retrieves the file path parameter.
20 base::FilePath GetFilePathFromCommandLine() { 20 base::FilePath GetFilePathFromCommandLine() {
21 base::FilePath command_line_file_path = 21 base::FilePath command_line_file_path =
22 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( 22 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
23 switches::kUseFileForFakeVideoCapture); 23 switches::kUseFileForFakeVideoCapture);
24 CHECK(!command_line_file_path.empty()); 24 CHECK(!command_line_file_path.empty());
25 return command_line_file_path; 25 return command_line_file_path;
26 } 26 }
27 27
28 std::unique_ptr<VideoCaptureDevice> FileVideoCaptureDeviceFactory::Create( 28 std::unique_ptr<VideoCaptureDevice> FileVideoCaptureDeviceFactory::Create(
29 const VideoCaptureDevice::Name& device_name) { 29 const VideoCaptureDeviceDescriptor& device_descriptor) {
30 DCHECK(thread_checker_.CalledOnValidThread()); 30 DCHECK(thread_checker_.CalledOnValidThread());
31 #if defined(OS_WIN) 31 #if defined(OS_WIN)
32 return std::unique_ptr<VideoCaptureDevice>(new FileVideoCaptureDevice( 32 return std::unique_ptr<VideoCaptureDevice>(new FileVideoCaptureDevice(
33 base::FilePath(base::SysUTF8ToWide(device_name.name())))); 33 base::FilePath(base::SysUTF8ToWide(device_descriptor.friendly_name))));
34 #else 34 #else
35 return std::unique_ptr<VideoCaptureDevice>( 35 return std::unique_ptr<VideoCaptureDevice>(new FileVideoCaptureDevice(
36 new FileVideoCaptureDevice(base::FilePath(device_name.name()))); 36 base::FilePath(device_descriptor.friendly_name)));
37 #endif 37 #endif
38 } 38 }
39 39
40 void FileVideoCaptureDeviceFactory::GetDeviceNames( 40 void FileVideoCaptureDeviceFactory::GetDeviceDescriptors(
41 VideoCaptureDevice::Names* const device_names) { 41 VideoCaptureDeviceDescriptors* device_descriptors) {
42 DCHECK(thread_checker_.CalledOnValidThread()); 42 DCHECK(thread_checker_.CalledOnValidThread());
43 DCHECK(device_names->empty()); 43 DCHECK(device_descriptors->empty());
44 const base::FilePath command_line_file_path = GetFilePathFromCommandLine(); 44 const base::FilePath command_line_file_path = GetFilePathFromCommandLine();
45 VideoCaptureDeviceDescriptor descriptor;
46 descriptor.device_id = kFileVideoCaptureDeviceName;
45 #if defined(OS_WIN) 47 #if defined(OS_WIN)
46 device_names->push_back(VideoCaptureDevice::Name( 48 descriptor.friendly_name =
47 base::SysWideToUTF8(command_line_file_path.value()), 49 base::SysWideToUTF8(command_line_file_path.value());
48 kFileVideoCaptureDeviceName, VideoCaptureDevice::Name::DIRECT_SHOW)); 50 descriptor.capture_api = VideoCaptureApiType::WINDOWS_DIRECT_SHOW;
49 #elif defined(OS_MACOSX) 51 #elif defined(OS_MACOSX)
50 device_names->push_back(VideoCaptureDevice::Name( 52 descriptor.friendly_name = command_line_file_path.value();
51 command_line_file_path.value(), kFileVideoCaptureDeviceName, 53 descriptor.capture_api = VideoCaptureApiType::MACOSX_AVFOUNDATION;
52 VideoCaptureDevice::Name::AVFOUNDATION));
53 #elif defined(OS_LINUX) 54 #elif defined(OS_LINUX)
54 device_names->push_back(VideoCaptureDevice::Name( 55 descriptor.friendly_name = command_line_file_path.value();
55 command_line_file_path.value(), kFileVideoCaptureDeviceName, 56 descriptor.capture_api = VideoCaptureApiType::LINUX_V4L2_SINGLE_PLANE;
56 VideoCaptureDevice::Name::V4L2_SINGLE_PLANE));
57 #else 57 #else
58 device_names->push_back(VideoCaptureDevice::Name( 58 descriptor.friendly_name = command_line_file_path.value();
59 command_line_file_path.value(), kFileVideoCaptureDeviceName)); 59 descriptor.capture_api = VideoCaptureApiType::API_TYPE_UNKNOWN;
60 #endif 60 #endif
61 device_descriptors->push_back(descriptor);
62 }
63
64 void FileVideoCaptureDeviceFactory::GetDeviceInfo(
65 const VideoCaptureDeviceDescriptor& device_descriptor,
66 VideoCaptureDeviceInfo* device_info) {
67 DCHECK(device_info);
68 device_info->descriptor = device_descriptor;
69 GetDeviceSupportedFormats(device_descriptor,
70 &(device_info->supported_formats));
61 } 71 }
62 72
63 void FileVideoCaptureDeviceFactory::GetDeviceSupportedFormats( 73 void FileVideoCaptureDeviceFactory::GetDeviceSupportedFormats(
64 const VideoCaptureDevice::Name& device, 74 const VideoCaptureDeviceDescriptor& device_descriptor,
65 VideoCaptureFormats* supported_formats) { 75 VideoCaptureFormats* supported_formats) {
66 DCHECK(thread_checker_.CalledOnValidThread()); 76 DCHECK(thread_checker_.CalledOnValidThread());
67 77
68 VideoCaptureFormat capture_format; 78 VideoCaptureFormat capture_format;
69 if (!FileVideoCaptureDevice::GetVideoCaptureFormat( 79 if (!FileVideoCaptureDevice::GetVideoCaptureFormat(
70 GetFilePathFromCommandLine(), &capture_format)) { 80 GetFilePathFromCommandLine(), &capture_format)) {
71 return; 81 return;
72 } 82 }
73 83
74 supported_formats->push_back(capture_format); 84 supported_formats->push_back(capture_format);
75 } 85 }
76 86
77 } // namespace media 87 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698