| 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) | |
| 30 fake_vcd_type = FakeVideoCaptureDevice::USING_OWN_BUFFERS_TRIPLANAR; | |
| 31 else if (base:: strcasecmp(option.c_str(), "gpu") == 0) | 29 else if (base:: strcasecmp(option.c_str(), "gpu") == 0) |
| 32 fake_vcd_type = FakeVideoCaptureDevice::USING_CLIENT_BUFFERS_GPU; | 30 fake_vcd_type = FakeVideoCaptureDevice::USING_GPU_MEMORY_BUFFERS; |
| 33 else | 31 else |
| 34 fake_vcd_type = FakeVideoCaptureDevice::USING_CLIENT_BUFFERS_I420; | 32 fake_vcd_type = FakeVideoCaptureDevice::USING_CLIENT_BUFFERS; |
| 35 | 33 |
| 36 for (int n = 0; n < number_of_devices_; ++n) { | 34 for (int n = 0; n < number_of_devices_; ++n) { |
| 37 std::string possible_id = base::StringPrintf("/dev/video%d", n); | 35 std::string possible_id = base::StringPrintf("/dev/video%d", n); |
| 38 if (device_name.id().compare(possible_id) == 0) { | 36 if (device_name.id().compare(possible_id) == 0) { |
| 39 return scoped_ptr<VideoCaptureDevice>( | 37 return scoped_ptr<VideoCaptureDevice>( |
| 40 new FakeVideoCaptureDevice(fake_vcd_type)); | 38 new FakeVideoCaptureDevice(fake_vcd_type)); |
| 41 } | 39 } |
| 42 } | 40 } |
| 43 return scoped_ptr<VideoCaptureDevice>(); | 41 return scoped_ptr<VideoCaptureDevice>(); |
| 44 } | 42 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 68 const VideoCaptureDevice::Name& device, | 66 const VideoCaptureDevice::Name& device, |
| 69 VideoCaptureFormats* supported_formats) { | 67 VideoCaptureFormats* supported_formats) { |
| 70 DCHECK(thread_checker_.CalledOnValidThread()); | 68 DCHECK(thread_checker_.CalledOnValidThread()); |
| 71 const int frame_rate = 1000 / FakeVideoCaptureDevice::FakeCapturePeriodMs(); | 69 const int frame_rate = 1000 / FakeVideoCaptureDevice::FakeCapturePeriodMs(); |
| 72 const gfx::Size supported_sizes[] = {gfx::Size(320, 240), | 70 const gfx::Size supported_sizes[] = {gfx::Size(320, 240), |
| 73 gfx::Size(640, 480), | 71 gfx::Size(640, 480), |
| 74 gfx::Size(1280, 720), | 72 gfx::Size(1280, 720), |
| 75 gfx::Size(1920, 1080)}; | 73 gfx::Size(1920, 1080)}; |
| 76 supported_formats->clear(); | 74 supported_formats->clear(); |
| 77 for (const auto& size : supported_sizes) { | 75 for (const auto& size : supported_sizes) { |
| 78 supported_formats->push_back( | 76 supported_formats->push_back(VideoCaptureFormat(size, |
| 79 VideoCaptureFormat(size, frame_rate, media::PIXEL_FORMAT_I420)); | 77 frame_rate, |
| 78 media::PIXEL_FORMAT_I420)); |
| 80 } | 79 } |
| 81 } | 80 } |
| 82 | 81 |
| 83 } // namespace media | 82 } // namespace media |
| OLD | NEW |