OLD | NEW |
---|---|
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" |
(...skipping 10 matching lines...) Expand all Loading... | |
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::CreateDevice( | 28 std::unique_ptr<VideoCaptureDevice> FileVideoCaptureDeviceFactory::CreateDevice( |
29 const VideoCaptureDeviceDescriptor& device_descriptor) { | 29 const VideoCaptureDeviceDescriptor& device_descriptor) { |
30 DCHECK(thread_checker_.CalledOnValidThread()); | 30 DCHECK(thread_checker_.CalledOnValidThread()); |
31 base::ThreadRestrictions::AssertIOAllowed(); | |
31 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
32 return std::unique_ptr<VideoCaptureDevice>(new FileVideoCaptureDevice( | 33 return std::unique_ptr<VideoCaptureDevice>(new FileVideoCaptureDevice( |
33 base::FilePath(base::SysUTF8ToWide(device_descriptor.display_name)))); | 34 base::FilePath(base::SysUTF8ToWide(device_descriptor.display_name)))); |
34 #else | 35 #else |
35 return std::unique_ptr<VideoCaptureDevice>(new FileVideoCaptureDevice( | 36 return std::unique_ptr<VideoCaptureDevice>(new FileVideoCaptureDevice( |
36 base::FilePath(device_descriptor.display_name))); | 37 base::FilePath(device_descriptor.display_name))); |
37 #endif | 38 #endif |
38 } | 39 } |
39 | 40 |
40 void FileVideoCaptureDeviceFactory::GetDeviceDescriptors( | 41 void FileVideoCaptureDeviceFactory::GetDeviceDescriptors( |
41 VideoCaptureDeviceDescriptors* device_descriptors) { | 42 VideoCaptureDeviceDescriptors* device_descriptors) { |
42 DCHECK(thread_checker_.CalledOnValidThread()); | 43 DCHECK(thread_checker_.CalledOnValidThread()); |
43 DCHECK(device_descriptors->empty()); | 44 DCHECK(device_descriptors->empty()); |
45 base::ThreadRestrictions::SetIOAllowed(true); | |
chfremer
2016/09/22 16:39:53
I believe this will work, but it feels a little ha
mcasas
2016/09/22 16:47:03
It is hacky, but the Video Capture thread is not o
| |
46 | |
44 const base::FilePath command_line_file_path = GetFilePathFromCommandLine(); | 47 const base::FilePath command_line_file_path = GetFilePathFromCommandLine(); |
45 device_descriptors->emplace_back( | 48 device_descriptors->emplace_back( |
46 #if defined(OS_WIN) | 49 #if defined(OS_WIN) |
47 base::SysWideToUTF8(command_line_file_path.value()), | 50 base::SysWideToUTF8(command_line_file_path.value()), |
48 kFileVideoCaptureDeviceName, VideoCaptureApi::WIN_DIRECT_SHOW | 51 kFileVideoCaptureDeviceName, VideoCaptureApi::WIN_DIRECT_SHOW |
49 #elif defined(OS_MACOSX) | 52 #elif defined(OS_MACOSX) |
50 command_line_file_path.value(), kFileVideoCaptureDeviceName, | 53 command_line_file_path.value(), kFileVideoCaptureDeviceName, |
51 VideoCaptureApi::MACOSX_AVFOUNDATION | 54 VideoCaptureApi::MACOSX_AVFOUNDATION |
52 #elif defined(OS_LINUX) | 55 #elif defined(OS_LINUX) |
53 command_line_file_path.value(), kFileVideoCaptureDeviceName, | 56 command_line_file_path.value(), kFileVideoCaptureDeviceName, |
54 VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE | 57 VideoCaptureApi::LINUX_V4L2_SINGLE_PLANE |
55 #else | 58 #else |
56 command_line_file_path.value(), kFileVideoCaptureDeviceName, | 59 command_line_file_path.value(), kFileVideoCaptureDeviceName, |
57 VideoCaptureApi::UNKNOWN | 60 VideoCaptureApi::UNKNOWN |
58 #endif | 61 #endif |
59 ); | 62 ); |
60 } | 63 } |
61 | 64 |
62 void FileVideoCaptureDeviceFactory::GetSupportedFormats( | 65 void FileVideoCaptureDeviceFactory::GetSupportedFormats( |
63 const VideoCaptureDeviceDescriptor& device_descriptor, | 66 const VideoCaptureDeviceDescriptor& device_descriptor, |
64 VideoCaptureFormats* supported_formats) { | 67 VideoCaptureFormats* supported_formats) { |
65 DCHECK(thread_checker_.CalledOnValidThread()); | 68 DCHECK(thread_checker_.CalledOnValidThread()); |
69 base::ThreadRestrictions::AssertIOAllowed(); | |
66 | 70 |
67 VideoCaptureFormat capture_format; | 71 VideoCaptureFormat capture_format; |
68 if (!FileVideoCaptureDevice::GetVideoCaptureFormat( | 72 if (!FileVideoCaptureDevice::GetVideoCaptureFormat( |
69 GetFilePathFromCommandLine(), &capture_format)) { | 73 GetFilePathFromCommandLine(), &capture_format)) { |
70 return; | 74 return; |
71 } | 75 } |
72 | 76 |
73 supported_formats->push_back(capture_format); | 77 supported_formats->push_back(capture_format); |
74 } | 78 } |
75 | 79 |
76 } // namespace media | 80 } // namespace media |
OLD | NEW |