| 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 81bc9b8931b46ebcb4233bd15d3783a7eac5b4ee..1a238e3376b31714cfdcdb65cd48276c99afa48a 100644
|
| --- a/media/video/capture/fake_video_capture_device.cc
|
| +++ b/media/video/capture/fake_video_capture_device.cc
|
| @@ -26,30 +26,43 @@ bool FakeVideoCaptureDevice::fail_next_create_ = false;
|
| base::subtle::Atomic32 FakeVideoCaptureDevice::number_of_devices_ =
|
| kNumberOfFakeDevices;
|
|
|
| +// static
|
| +int FakeVideoCaptureDevice::NumberOfFakeDevices(void) {
|
| + return number_of_devices_;
|
| +}
|
| +
|
| +// static
|
| void FakeVideoCaptureDevice::GetDeviceNames(Names* const device_names) {
|
| // Empty the name list.
|
| device_names->erase(device_names->begin(), device_names->end());
|
|
|
| int number_of_devices = base::subtle::NoBarrier_Load(&number_of_devices_);
|
| for (int32 n = 0; n < number_of_devices; n++) {
|
| - Name name("fake_device_" + base::IntToString(n),
|
| - "/dev/video" + base::IntToString(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;
|
| @@ -57,7 +70,7 @@ VideoCaptureDevice* FakeVideoCaptureDevice::Create(const Name& device_name) {
|
| }
|
| int number_of_devices = base::subtle::NoBarrier_Load(&number_of_devices_);
|
| for (int32 n = 0; n < number_of_devices; ++n) {
|
| - std::string possible_id = "/dev/video" + base::IntToString(n);
|
| + std::string possible_id = base::StringPrintf("/dev/video%d", n);
|
| if (device_name.id().compare(possible_id) == 0) {
|
| return new FakeVideoCaptureDevice();
|
| }
|
| @@ -65,10 +78,12 @@ VideoCaptureDevice* FakeVideoCaptureDevice::Create(const Name& device_name) {
|
| return NULL;
|
| }
|
|
|
| +// static
|
| void FakeVideoCaptureDevice::SetFailNextCreate() {
|
| fail_next_create_ = true;
|
| }
|
|
|
| +// static
|
| void FakeVideoCaptureDevice::SetNumberOfFakeDevices(size_t number_of_devices) {
|
| base::subtle::NoBarrier_AtomicExchange(&number_of_devices_,
|
| number_of_devices);
|
|
|