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

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

Issue 235353002: Extract VideoCaptureDeviceFactory out of VideoCaptureDevice and use for File and FakeVCD. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: perkj@s comments Created 6 years, 8 months 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
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 68dc9123e5dfedfbe7f83799b91ad3ce977f2b6d..eea273455389ba6a9a8f1fc2460678a4707b6d5f 100644
--- a/media/video/capture/fake_video_capture_device.cc
+++ b/media/video/capture/fake_video_capture_device.cc
@@ -17,77 +17,8 @@
namespace media {
-static const int kFakeCaptureTimeoutMs = 50;
static const int kFakeCaptureBeepCycle = 10; // Visual beep every 0.5s.
static const int kFakeCaptureCapabilityChangePeriod = 30;
-enum { kNumberOfFakeDevices = 2 };
-
-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(base::StringPrintf("fake_device_%d", n),
- base::StringPrintf("/dev/video%d", n));
- device_names->push_back(name);
- }
-}
-
-// static
-void FakeVideoCaptureDevice::GetDeviceSupportedFormats(
- const Name& device,
- VideoCaptureFormats* supported_formats) {
-
- const size_t supported_sizes_length = 3;
- const gfx::Size supported_sizes[] = {gfx::Size(320, 240),
- gfx::Size(640, 480),
- gfx::Size(1280, 720)};
- int frame_rate = 1000 / kFakeCaptureTimeoutMs;
- supported_formats->clear();
- for (size_t i=0; i < supported_sizes_length; ++i) {
- supported_formats->push_back(VideoCaptureFormat(supported_sizes[i],
- frame_rate,
- media::PIXEL_FORMAT_I420));
- }
-}
-
-// static
-VideoCaptureDevice* FakeVideoCaptureDevice::Create(const Name& device_name) {
- if (fail_next_create_) {
- fail_next_create_ = false;
- return NULL;
- }
- int number_of_devices = base::subtle::NoBarrier_Load(&number_of_devices_);
- for (int32 n = 0; n < number_of_devices; ++n) {
- std::string possible_id = base::StringPrintf("/dev/video%d", n);
- if (device_name.id().compare(possible_id) == 0) {
- return new FakeVideoCaptureDevice();
- }
- }
- 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);
-}
FakeVideoCaptureDevice::FakeVideoCaptureDevice()
: capture_thread_("CaptureThread"),

Powered by Google App Engine
This is Rietveld 408576698