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 FakeVideoCaptureDeviceFactory::FakeVideoCaptureDeviceFactory() {} | |
| 13 | |
| 14 scoped_ptr<VideoCaptureDevice> FakeVideoCaptureDeviceFactory::Create( | |
| 15 const VideoCaptureDevice::Name& device_name) { | |
| 16 for (int32 n = 0; n < number_of_devices_; ++n) { | |
|
perkj_chrome
2014/04/24 14:43:32
size_t instead of int32 or just int.
mcasas
2014/04/24 20:20:26
int.
size_t has troubles in Windows.
perkj_chrome
2014/04/25 08:43:31
ok but you use size_t in GetDeviceSupportedFormats
| |
| 17 std::string possible_id = base::StringPrintf("/dev/video%d", n); | |
| 18 if (device_name.id().compare(possible_id) == 0) | |
| 19 return scoped_ptr<VideoCaptureDevice>(new FakeVideoCaptureDevice()); | |
| 20 } | |
| 21 return scoped_ptr<VideoCaptureDevice>(); | |
| 22 } | |
| 23 | |
| 24 void FakeVideoCaptureDeviceFactory::GetDeviceNames( | |
| 25 VideoCaptureDevice::Names* const device_names) { | |
| 26 DCHECK(device_names->empty()); | |
| 27 for (int32 n = 0; n < number_of_devices_; ++n) { | |
|
perkj_chrome
2014/04/24 14:43:32
dito
mcasas
2014/04/24 20:20:26
Done.
| |
| 28 VideoCaptureDevice::Name name(base::StringPrintf("fake_device_%d", n), | |
| 29 base::StringPrintf("/dev/video%d", n)); | |
| 30 device_names->push_back(name); | |
| 31 } | |
| 32 } | |
| 33 | |
| 34 void FakeVideoCaptureDeviceFactory::GetDeviceSupportedFormats( | |
| 35 const VideoCaptureDevice::Name& device, | |
| 36 VideoCaptureFormats* supported_formats) { | |
| 37 const int frame_rate = 1000 / FakeVideoCaptureDevice::kFakeCaptureTimeoutMs; | |
| 38 const gfx::Size supported_sizes[] = {gfx::Size(320, 240), | |
| 39 gfx::Size(640, 480), | |
| 40 gfx::Size(1280, 720)}; | |
| 41 supported_formats->clear(); | |
| 42 for (size_t i = 0; i < arraysize(supported_sizes); ++i) { | |
| 43 supported_formats->push_back(VideoCaptureFormat(supported_sizes[i], | |
| 44 frame_rate, | |
| 45 media::PIXEL_FORMAT_I420)); | |
| 46 } | |
| 47 } | |
| 48 | |
| 49 } // namespace media | |
| OLD | NEW |