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

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

Issue 294893006: VideoCaptureDeviceFactory: Change device enumeration to callback + QTKit enumerates in UI thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: QTKit/AVFoundation Factory create of inexistent device and associated unit tests Created 6 years, 6 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
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/video/capture/file_video_capture_device_factory.h" 5 #include "media/video/capture/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 "media/base/media_switches.h" 10 #include "media/base/media_switches.h"
11 #include "media/video/capture/file_video_capture_device.h" 11 #include "media/video/capture/file_video_capture_device.h"
12 12
13 namespace media { 13 namespace media {
14 14
15 const char kFileVideoCaptureDeviceName[] = 15 const char kFileVideoCaptureDeviceName[] =
16 "/dev/placeholder-for-file-backed-fake-capture-device"; 16 "/dev/placeholder-for-file-backed-fake-capture-device";
17 17
18 // Inspects the command line and retrieves the file path parameter. 18 // Inspects the command line and retrieves the file path parameter.
19 base::FilePath GetFilePathFromCommandLine() { 19 base::FilePath GetFilePathFromCommandLine() {
20 base::FilePath command_line_file_path = 20 base::FilePath command_line_file_path =
21 CommandLine::ForCurrentProcess()->GetSwitchValuePath( 21 CommandLine::ForCurrentProcess()->GetSwitchValuePath(
22 switches::kUseFileForFakeVideoCapture); 22 switches::kUseFileForFakeVideoCapture);
23 CHECK(!command_line_file_path.empty()); 23 CHECK(!command_line_file_path.empty());
24 return command_line_file_path; 24 return command_line_file_path;
25 } 25 }
26 26
27 scoped_ptr<VideoCaptureDevice> FileVideoCaptureDeviceFactory::Create( 27 scoped_ptr<VideoCaptureDevice> FileVideoCaptureDeviceFactory::Create(
28 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
29 const VideoCaptureDevice::Name& device_name) { 28 const VideoCaptureDevice::Name& device_name) {
29 DCHECK(thread_checker_.CalledOnValidThread());
30 #if defined(OS_WIN) 30 #if defined(OS_WIN)
31 return scoped_ptr<VideoCaptureDevice>(new FileVideoCaptureDevice( 31 return scoped_ptr<VideoCaptureDevice>(new FileVideoCaptureDevice(
32 base::FilePath(base::SysUTF8ToWide(device_name.name())))); 32 base::FilePath(base::SysUTF8ToWide(device_name.name()))));
33 #else 33 #else
34 return scoped_ptr<VideoCaptureDevice>(new FileVideoCaptureDevice( 34 return scoped_ptr<VideoCaptureDevice>(new FileVideoCaptureDevice(
35 base::FilePath(device_name.name()))); 35 base::FilePath(device_name.name())));
36 #endif 36 #endif
37 } 37 }
38 38
39 void FileVideoCaptureDeviceFactory::GetDeviceNames( 39 void FileVideoCaptureDeviceFactory::GetDeviceNames(
40 VideoCaptureDevice::Names* const device_names) { 40 VideoCaptureDevice::Names* const device_names) {
41 DCHECK(thread_checker_.CalledOnValidThread());
41 DCHECK(device_names->empty()); 42 DCHECK(device_names->empty());
42 base::FilePath command_line_file_path = GetFilePathFromCommandLine(); 43 base::FilePath command_line_file_path = GetFilePathFromCommandLine();
43 #if defined(OS_WIN) 44 #if defined(OS_WIN)
44 device_names->push_back(VideoCaptureDevice::Name( 45 device_names->push_back(VideoCaptureDevice::Name(
45 base::SysWideToUTF8(command_line_file_path.value()), 46 base::SysWideToUTF8(command_line_file_path.value()),
46 kFileVideoCaptureDeviceName)); 47 kFileVideoCaptureDeviceName));
47 #else 48 #else
48 device_names->push_back(VideoCaptureDevice::Name( 49 device_names->push_back(VideoCaptureDevice::Name(
49 command_line_file_path.value(), 50 command_line_file_path.value(),
50 kFileVideoCaptureDeviceName)); 51 kFileVideoCaptureDeviceName));
51 #endif 52 #endif
52 } 53 }
53 54
54 void FileVideoCaptureDeviceFactory::GetDeviceSupportedFormats( 55 void FileVideoCaptureDeviceFactory::GetDeviceSupportedFormats(
55 const VideoCaptureDevice::Name& device, 56 const VideoCaptureDevice::Name& device,
56 VideoCaptureFormats* supported_formats) { 57 VideoCaptureFormats* supported_formats) {
58 DCHECK(thread_checker_.CalledOnValidThread());
57 base::File file = 59 base::File file =
58 FileVideoCaptureDevice::OpenFileForRead(GetFilePathFromCommandLine()); 60 FileVideoCaptureDevice::OpenFileForRead(GetFilePathFromCommandLine());
59 VideoCaptureFormat capture_format; 61 VideoCaptureFormat capture_format;
60 FileVideoCaptureDevice::ParseFileAndExtractVideoFormat(&file, 62 FileVideoCaptureDevice::ParseFileAndExtractVideoFormat(&file,
61 &capture_format); 63 &capture_format);
62 supported_formats->push_back(capture_format); 64 supported_formats->push_back(capture_format);
63 } 65 }
64 66
65 } // namespace media 67 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698