| Index: media/video/capture/fake_video_capture_device_factory.cc
|
| diff --git a/media/video/capture/fake_video_capture_device_factory.cc b/media/video/capture/fake_video_capture_device_factory.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..160464c2c20cfb6841376cfe4c7f620c5a6632dc
|
| --- /dev/null
|
| +++ b/media/video/capture/fake_video_capture_device_factory.cc
|
| @@ -0,0 +1,54 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "media/video/capture/fake_video_capture_device_factory.h"
|
| +
|
| +#include "base/strings/stringprintf.h"
|
| +#include "media/video/capture/fake_video_capture_device.h"
|
| +
|
| +namespace media {
|
| +
|
| +const size_t kNumberOfFakeDevices = 2;
|
| +
|
| +FakeVideoCaptureDeviceFactory::FakeVideoCaptureDeviceFactory()
|
| + : number_of_devices_(kNumberOfFakeDevices) {
|
| +}
|
| +
|
| +VideoCaptureDevice* FakeVideoCaptureDeviceFactory::Create(
|
| + const VideoCaptureDevice::Name& device_name) {
|
| + for (size_t n = 0; n < number_of_devices_; ++n) {
|
| + std::string possible_id = base::StringPrintf("/dev/video%zu", n);
|
| + if (device_name.id().compare(possible_id) == 0) {
|
| + return new FakeVideoCaptureDevice();
|
| + }
|
| + }
|
| + return NULL;
|
| +}
|
| +
|
| +void FakeVideoCaptureDeviceFactory::GetDeviceNames(
|
| + VideoCaptureDevice::Names* const device_names) {
|
| + DCHECK(device_names->empty());
|
| + for (size_t n = 0; n < number_of_devices_; ++n) {
|
| + VideoCaptureDevice::Name name(base::StringPrintf("fake_device_%zu", n),
|
| + base::StringPrintf("/dev/video%zu", n));
|
| + device_names->push_back(name);
|
| + }
|
| +}
|
| +
|
| +void FakeVideoCaptureDeviceFactory::GetDeviceSupportedFormats(
|
| + const VideoCaptureDevice::Name& device,
|
| + VideoCaptureFormats* supported_formats) {
|
| + const int frame_rate = 1000 / FakeVideoCaptureDevice::kFakeCaptureTimeoutMs;
|
| + const gfx::Size supported_sizes[] = {gfx::Size(320, 240),
|
| + gfx::Size(640, 480),
|
| + gfx::Size(1280, 720)};
|
| + supported_formats->clear();
|
| + for (size_t i=0; i < arraysize(supported_sizes); ++i) {
|
| + supported_formats->push_back(VideoCaptureFormat(supported_sizes[i],
|
| + frame_rate,
|
| + media::PIXEL_FORMAT_I420));
|
| + }
|
| +}
|
| +
|
| +} // namespace media
|
|
|