Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(481)

Unified Diff: media/video/capture/fake_video_capture_device.cc

Issue 91343002: Added supported formats caching to VideoCaptureManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: perkj@ nits Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/video/capture/fake_video_capture_device.h ('k') | media/video/capture/file_video_capture_device.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c6f5f61fa51c6b52c4c3537170fce23063ea0e75..5a789ce2e70a52f0c1fbc3506857425bd082c1d7 100644
--- a/media/video/capture/fake_video_capture_device.cc
+++ b/media/video/capture/fake_video_capture_device.cc
@@ -8,7 +8,6 @@
#include "base/bind.h"
#include "base/memory/scoped_ptr.h"
-#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "media/audio/fake_audio_input_stream.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -26,30 +25,43 @@ bool FakeVideoCaptureDevice::fail_next_create_ = false;
base::subtle::Atomic32 FakeVideoCaptureDevice::number_of_devices_ =
kNumberOfFakeDevices;
+// static
+size_t 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 +69,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 +77,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);
« no previous file with comments | « media/video/capture/fake_video_capture_device.h ('k') | media/video/capture/file_video_capture_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698