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/video/capture/fake_video_capture_device_factory.h" | 5 #include "media/video/capture/fake_video_capture_device_factory.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "media/base/media_switches.h" | 10 #include "media/base/media_switches.h" |
11 #include "media/video/capture/fake_video_capture_device.h" | 11 #include "media/video/capture/fake_video_capture_device.h" |
12 | 12 |
13 namespace media { | 13 namespace media { |
14 | 14 |
15 FakeVideoCaptureDeviceFactory::FakeVideoCaptureDeviceFactory() | 15 FakeVideoCaptureDeviceFactory::FakeVideoCaptureDeviceFactory() |
16 : number_of_devices_(1) { | 16 : number_of_devices_(1) { |
17 } | 17 } |
18 | 18 |
19 scoped_ptr<VideoCaptureDevice> FakeVideoCaptureDeviceFactory::Create( | 19 scoped_ptr<VideoCaptureDevice> FakeVideoCaptureDeviceFactory::Create( |
20 const VideoCaptureDevice::Name& device_name) { | 20 const VideoCaptureDevice::Name& device_name) { |
21 DCHECK(thread_checker_.CalledOnValidThread()); | 21 DCHECK(thread_checker_.CalledOnValidThread()); |
22 | 22 |
23 const std::string option = base::CommandLine::ForCurrentProcess()-> | 23 const std::string option = base::CommandLine::ForCurrentProcess()-> |
24 GetSwitchValueASCII(switches::kUseFakeDeviceForMediaStream); | 24 GetSwitchValueASCII(switches::kUseFakeDeviceForMediaStream); |
25 | 25 |
26 FakeVideoCaptureDevice::FakeVideoCaptureDeviceType fake_vcd_type; | 26 FakeVideoCaptureDevice::FakeVideoCaptureDeviceType fake_vcd_type; |
27 if (option.empty()) | 27 if (option.empty()) |
28 fake_vcd_type = FakeVideoCaptureDevice::USING_OWN_BUFFERS; | 28 fake_vcd_type = FakeVideoCaptureDevice::USING_OWN_BUFFERS; |
29 else if (base:: strcasecmp(option.c_str(), "triplanar") == 0) | 29 else if (base::EqualsCaseInsensitiveASCII(option, "triplanar")) |
30 fake_vcd_type = FakeVideoCaptureDevice::USING_OWN_BUFFERS_TRIPLANAR; | 30 fake_vcd_type = FakeVideoCaptureDevice::USING_OWN_BUFFERS_TRIPLANAR; |
31 else | 31 else |
32 fake_vcd_type = FakeVideoCaptureDevice::USING_CLIENT_BUFFERS; | 32 fake_vcd_type = FakeVideoCaptureDevice::USING_CLIENT_BUFFERS; |
33 | 33 |
34 for (int n = 0; n < number_of_devices_; ++n) { | 34 for (int n = 0; n < number_of_devices_; ++n) { |
35 std::string possible_id = base::StringPrintf("/dev/video%d", n); | 35 std::string possible_id = base::StringPrintf("/dev/video%d", n); |
36 if (device_name.id().compare(possible_id) == 0) { | 36 if (device_name.id().compare(possible_id) == 0) { |
37 return scoped_ptr<VideoCaptureDevice>( | 37 return scoped_ptr<VideoCaptureDevice>( |
38 new FakeVideoCaptureDevice(fake_vcd_type)); | 38 new FakeVideoCaptureDevice(fake_vcd_type)); |
39 } | 39 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 gfx::Size(1280, 720), | 72 gfx::Size(1280, 720), |
73 gfx::Size(1920, 1080)}; | 73 gfx::Size(1920, 1080)}; |
74 supported_formats->clear(); | 74 supported_formats->clear(); |
75 for (const auto& size : supported_sizes) { | 75 for (const auto& size : supported_sizes) { |
76 supported_formats->push_back( | 76 supported_formats->push_back( |
77 VideoCaptureFormat(size, frame_rate, media::PIXEL_FORMAT_I420)); | 77 VideoCaptureFormat(size, frame_rate, media::PIXEL_FORMAT_I420)); |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 } // namespace media | 81 } // namespace media |
OLD | NEW |