Index: media/video/capture/fake_video_capture_device.cc |
diff --git a/media/video/capture/fake_video_capture_device.cc b/media/video/capture/fake_video_capture_device.cc |
index ef44d86488497ef9d7d452f38bc2a8521d6c0863..6bb2af774102e08daaa0cceb349af3a0e2f56343 100644 |
--- a/media/video/capture/fake_video_capture_device.cc |
+++ b/media/video/capture/fake_video_capture_device.cc |
@@ -19,39 +19,57 @@ namespace media { |
static const int kFakeCaptureTimeoutMs = 50; |
static const int kFakeCaptureBeepCycle = 20; // Visual beep every 1s. |
static const int kFakeCaptureCapabilityChangePeriod = 30; |
-enum { kNumberOfFakeDevices = 2 }; |
+int FakeVideoCaptureDevice::number_of_fake_devices_ = 2; |
bool FakeVideoCaptureDevice::fail_next_create_ = false; |
+// static |
+void FakeVideoCaptureDevice::SetNumberOfFakeDevices(int num) { |
+ number_of_fake_devices_ = num; |
+} |
+ |
+// static |
+int FakeVideoCaptureDevice::NumberOfFakeDevices(void) { |
+ return number_of_fake_devices_; |
+} |
+ |
+// static |
void FakeVideoCaptureDevice::GetDeviceNames(Names* const device_names) { |
// Empty the name list. |
device_names->erase(device_names->begin(), device_names->end()); |
- for (int n = 0; n < kNumberOfFakeDevices; n++) { |
+ for (int n = 0; n < number_of_fake_devices_; n++) { |
Name name(base::StringPrintf("fake_device_%d", n), |
base::StringPrintf("/dev/video%d", n)); |
device_names->push_back(name); |
} |
} |
+// static |
void FakeVideoCaptureDevice::GetDeviceSupportedFormats( |
const Name& device, |
- VideoCaptureCapabilities* formats) { |
- VideoCaptureCapability capture_format_640x480; |
- capture_format_640x480.supported_format.frame_size.SetSize(640, 480); |
- capture_format_640x480.supported_format.frame_rate = |
- 1000 / kFakeCaptureTimeoutMs; |
- capture_format_640x480.supported_format.pixel_format = |
- media::PIXEL_FORMAT_I420; |
- formats->push_back(capture_format_640x480); |
+ VideoCaptureFormats* supported_formats) { |
+ |
+ supported_formats->clear(); |
+ VideoCaptureFormat capture_format_640x480; |
+ capture_format_640x480.pixel_format = media::PIXEL_FORMAT_I420; |
+ capture_format_640x480.frame_size.SetSize(640, 480); |
+ capture_format_640x480.frame_rate = 1000 / kFakeCaptureTimeoutMs; |
+ supported_formats->push_back(capture_format_640x480); |
+ VideoCaptureFormat capture_format_320x240; |
+ capture_format_320x240.pixel_format = media::PIXEL_FORMAT_I420; |
+ capture_format_320x240.frame_size.SetSize(320, 240); |
+ capture_format_320x240.frame_rate = 1000 / kFakeCaptureTimeoutMs; |
+ supported_formats->push_back(capture_format_320x240); |
} |
+// static |
VideoCaptureDevice* FakeVideoCaptureDevice::Create(const Name& device_name) { |
if (fail_next_create_) { |
fail_next_create_ = false; |
return NULL; |
} |
- for (int n = 0; n < kNumberOfFakeDevices; ++n) { |
+ for (int n = 0; n < number_of_fake_devices_; ++n) { |
std::string possible_id = base::StringPrintf("/dev/video%d", n); |
if (device_name.id().compare(possible_id) == 0) { |
return new FakeVideoCaptureDevice(); |
@@ -60,6 +78,7 @@ VideoCaptureDevice* FakeVideoCaptureDevice::Create(const Name& device_name) { |
return NULL; |
} |
+// static |
void FakeVideoCaptureDevice::SetFailNextCreate() { |
fail_next_create_ = true; |
} |