Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "media/video/capture/fake_video_capture_device_factory.h" | |
| 6 | |
| 7 #include "base/strings/stringprintf.h" | |
| 8 #include "media/video/capture/fake_video_capture_device.h" | |
| 9 | |
| 10 namespace media { | |
| 11 | |
| 12 const int32 kNumberOfFakeDevices = 2; | |
|
tommi (sloooow) - chröme
2014/04/23 14:33:59
nit: I think we don't really need this constant
mcasas
2014/04/23 15:13:30
The value itself is needed for some unittests, but
| |
| 13 | |
| 14 FakeVideoCaptureDeviceFactory::FakeVideoCaptureDeviceFactory() | |
| 15 : number_of_devices_(kNumberOfFakeDevices) { | |
| 16 } | |
| 17 | |
| 18 scoped_ptr<VideoCaptureDevice> FakeVideoCaptureDeviceFactory::Create( | |
| 19 const VideoCaptureDevice::Name& device_name) { | |
| 20 for (int32 n = 0; n < number_of_devices_; ++n) { | |
| 21 std::string possible_id = base::StringPrintf("/dev/video%d", n); | |
| 22 if (device_name.id().compare(possible_id) == 0) { | |
|
tommi (sloooow) - chröme
2014/04/23 14:33:59
nit: no {}
mcasas
2014/04/23 15:13:30
Done.
| |
| 23 return scoped_ptr<VideoCaptureDevice>(new FakeVideoCaptureDevice()); | |
| 24 } | |
| 25 } | |
| 26 return scoped_ptr<VideoCaptureDevice>(); | |
| 27 } | |
| 28 | |
| 29 void FakeVideoCaptureDeviceFactory::GetDeviceNames( | |
| 30 VideoCaptureDevice::Names* const device_names) { | |
| 31 DCHECK(device_names->empty()); | |
| 32 for (int32 n = 0; n < number_of_devices_; ++n) { | |
| 33 VideoCaptureDevice::Name name(base::StringPrintf("fake_device_%d", n), | |
| 34 base::StringPrintf("/dev/video%d", n)); | |
| 35 device_names->push_back(name); | |
| 36 } | |
| 37 } | |
| 38 | |
| 39 void FakeVideoCaptureDeviceFactory::GetDeviceSupportedFormats( | |
| 40 const VideoCaptureDevice::Name& device, | |
| 41 VideoCaptureFormats* supported_formats) { | |
| 42 const int frame_rate = 1000 / FakeVideoCaptureDevice::kFakeCaptureTimeoutMs; | |
| 43 const gfx::Size supported_sizes[] = {gfx::Size(320, 240), | |
| 44 gfx::Size(640, 480), | |
| 45 gfx::Size(1280, 720)}; | |
| 46 supported_formats->clear(); | |
| 47 for (size_t i=0; i < arraysize(supported_sizes); ++i) { | |
|
tommi (sloooow) - chröme
2014/04/23 14:33:59
spaces around =
mcasas
2014/04/23 15:13:30
Done.
| |
| 48 supported_formats->push_back(VideoCaptureFormat(supported_sizes[i], | |
| 49 frame_rate, | |
| 50 media::PIXEL_FORMAT_I420)); | |
| 51 } | |
| 52 } | |
| 53 | |
| 54 } // namespace media | |
| OLD | NEW |