Chromium Code Reviews| Index: media/capture/video/fake_video_capture_device_factory.cc |
| diff --git a/media/capture/video/fake_video_capture_device_factory.cc b/media/capture/video/fake_video_capture_device_factory.cc |
| index 3886f48daea5b1e05fadf6c107e3166ae9255dc8..d599bc79c5c5791f32494efb8e0255c6e68d12d9 100644 |
| --- a/media/capture/video/fake_video_capture_device_factory.cc |
| +++ b/media/capture/video/fake_video_capture_device_factory.cc |
| @@ -5,6 +5,7 @@ |
| #include "media/capture/video/fake_video_capture_device_factory.h" |
| #include "base/command_line.h" |
| +#include "base/macros.h" |
| #include "base/strings/string_number_conversions.h" |
| #include "base/strings/string_split.h" |
| #include "base/strings/string_tokenizer.h" |
| @@ -36,9 +37,11 @@ static const float kFakeCaptureDefaultFrameRate = 20.0f; |
| // Cap the device count command line input to reasonable values. |
| static const int kFakeCaptureMinDeviceCount = 1; |
| static const int kFakeCaptureMaxDeviceCount = 10; |
| +static const int kFakeCaptureMinFormatCount = 0; |
| FakeVideoCaptureDeviceFactory::FakeVideoCaptureDeviceFactory() |
| : number_of_devices_(1), |
| + number_of_formats_per_device_(5), |
| fake_vcd_ownership_(FakeVideoCaptureDevice::BufferOwnership::OWN_BUFFERS), |
| frame_rate_(kFakeCaptureDefaultFrameRate) {} |
| @@ -107,9 +110,13 @@ void FakeVideoCaptureDeviceFactory::GetSupportedFormats( |
| gfx::Size(96, 96), gfx::Size(320, 240), gfx::Size(640, 480), |
| gfx::Size(1280, 720), gfx::Size(1920, 1080)}; |
| supported_formats->clear(); |
| - for (const auto& size : supported_sizes) { |
| - supported_formats->push_back(VideoCaptureFormat( |
| - size, frame_rate_, GetPixelFormat(device_descriptor.device_id))); |
| + size_t num_formats = |
| + std::min(arraysize(supported_sizes), |
| + static_cast<size_t>(number_of_formats_per_device_)); |
| + for (size_t i = 0; i < num_formats; ++i) { |
| + supported_formats->push_back( |
| + VideoCaptureFormat(supported_sizes[i], frame_rate_, |
| + GetPixelFormat(device_descriptor.device_id))); |
| } |
| } |
| @@ -153,6 +160,13 @@ void FakeVideoCaptureDeviceFactory::ParseCommandLine() { |
| kFakeCaptureMaxDeviceCount, |
| std::max(kFakeCaptureMinDeviceCount, static_cast<int>(count))); |
| } |
| + } else if (base::EqualsCaseInsensitiveASCII(param.front(), |
| + "format-count")) { |
| + unsigned int count = 0; |
| + if (base::StringToUint(param.back(), &count)) { |
| + number_of_formats_per_device_ = |
| + std::max(kFakeCaptureMinFormatCount, static_cast<int>(count)); |
| + } |
|
mcasas
2017/02/14 17:01:01
I think adding a new command line flag and member
|
| } |
| } |
| } |