Chromium Code Reviews| Index: content/browser/renderer_host/media/video_capture_manager.cc |
| diff --git a/content/browser/renderer_host/media/video_capture_manager.cc b/content/browser/renderer_host/media/video_capture_manager.cc |
| index a7cca9c22665fb08cd80f97f94c23d3908098d92..482beea622268fa7815aeae56679400fd857225d 100644 |
| --- a/content/browser/renderer_host/media/video_capture_manager.cc |
| +++ b/content/browser/renderer_host/media/video_capture_manager.cc |
| @@ -7,7 +7,6 @@ |
| #include <set> |
| #include "base/bind.h" |
| -#include "base/command_line.h" |
| #include "base/logging.h" |
| #include "base/message_loop/message_loop.h" |
| #include "base/stl_util.h" |
| @@ -20,10 +19,9 @@ |
| #include "content/public/browser/desktop_media_id.h" |
| #include "content/public/common/content_switches.h" |
| #include "content/public/common/media_stream_request.h" |
| -#include "media/base/media_switches.h" |
| #include "media/base/scoped_histogram_timer.h" |
| -#include "media/video/capture/fake_video_capture_device.h" |
| -#include "media/video/capture/file_video_capture_device.h" |
| +#include "media/video/capture/fake_video_capture_device_factory.h" |
|
perkj_chrome
2014/04/15 09:34:01
You should not need these includes here.
mcasas
2014/04/15 13:47:09
Done.
|
| +#include "media/video/capture/file_video_capture_device_factory.h" |
| #include "media/video/capture/video_capture_device.h" |
| #if defined(ENABLE_SCREEN_CAPTURE) |
| @@ -98,7 +96,7 @@ VideoCaptureManager::DeviceInfo::~DeviceInfo() {} |
| VideoCaptureManager::VideoCaptureManager() |
| : listener_(NULL), |
| new_capture_session_id_(1), |
| - artificial_device_source_for_testing_(DISABLED) { |
| + use_testing_device_source_(false) { |
| } |
| VideoCaptureManager::~VideoCaptureManager() { |
| @@ -186,13 +184,10 @@ void VideoCaptureManager::Close(int capture_session_id) { |
| sessions_.erase(session_it); |
| } |
| -void VideoCaptureManager::UseFakeDevice() { |
| - if (CommandLine::ForCurrentProcess()->HasSwitch( |
| - switches::kUseFileForFakeVideoCapture)) { |
| - artificial_device_source_for_testing_ = Y4M_FILE; |
| - } else { |
| - artificial_device_source_for_testing_ = TEST_PATTERN; |
| - } |
| +void VideoCaptureManager::UseFakeDevice( |
| + scoped_ptr<media::VideoCaptureDeviceFactory> factory) { |
| + use_testing_device_source_ = true; |
| + video_capture_device_factory_ = factory.Pass(); |
| } |
| void VideoCaptureManager::DoStartDeviceOnDeviceThread( |
| @@ -211,19 +206,12 @@ void VideoCaptureManager::DoStartDeviceOnDeviceThread( |
| // held in the browser-side VideoCaptureDevice::Name structure. |
| DeviceInfo* found = FindDeviceInfoById(entry->id, devices_info_cache_); |
| if (found) { |
| - switch (artificial_device_source_for_testing_) { |
| - case DISABLED: |
| - video_capture_device.reset( |
| - media::VideoCaptureDevice::Create(found->name)); |
| - break; |
| - case TEST_PATTERN: |
| - video_capture_device.reset( |
| - media::FakeVideoCaptureDevice::Create(found->name)); |
| - break; |
| - case Y4M_FILE: |
| - video_capture_device.reset( |
| - media::FileVideoCaptureDevice::Create(found->name)); |
| - break; |
| + if (!use_testing_device_source_) { |
|
perkj_chrome
2014/04/15 09:34:01
This is ugly. Always use a device factory but have
mcasas
2014/04/15 13:47:09
Done.
|
| + video_capture_device.reset( |
| + media::VideoCaptureDevice::Create(found->name)); |
| + } else { |
| + video_capture_device.reset( |
| + video_capture_device_factory_->Create(found->name)); |
| } |
| } |
| break; |
| @@ -483,17 +471,10 @@ VideoCaptureManager::GetAvailableDevicesInfoOnDeviceThread( |
| // Cache the latest enumeration of video capture devices. |
| // We'll refer to this list again in OnOpen to avoid having to |
| // enumerate the devices again. |
| - switch (artificial_device_source_for_testing_) { |
| - case DISABLED: |
| - media::VideoCaptureDevice::GetDeviceNames(&names_snapshot); |
| - break; |
| - case TEST_PATTERN: |
| - media::FakeVideoCaptureDevice::GetDeviceNames(&names_snapshot); |
| - break; |
| - case Y4M_FILE: |
| - media::FileVideoCaptureDevice::GetDeviceNames(&names_snapshot); |
| - break; |
| - } |
| + if (!use_testing_device_source_) |
|
perkj_chrome
2014/04/15 09:34:01
dito
mcasas
2014/04/15 13:47:09
Done.
|
| + media::VideoCaptureDevice::GetDeviceNames(&names_snapshot); |
| + else |
| + video_capture_device_factory_->GetDeviceNames(&names_snapshot); |
| break; |
| case MEDIA_DESKTOP_VIDEO_CAPTURE: |
| @@ -529,19 +510,13 @@ VideoCaptureManager::GetAvailableDevicesInfoOnDeviceThread( |
| it != names_snapshot.end(); ++it) { |
| media::VideoCaptureFormats supported_formats; |
| DeviceInfo device_info(*it, media::VideoCaptureFormats()); |
| - switch (artificial_device_source_for_testing_) { |
| - case DISABLED: |
| - media::VideoCaptureDevice::GetDeviceSupportedFormats( |
| - *it, &(device_info.supported_formats)); |
| - break; |
| - case TEST_PATTERN: |
| - media::FakeVideoCaptureDevice::GetDeviceSupportedFormats( |
| - *it, &(device_info.supported_formats)); |
| - break; |
| - case Y4M_FILE: |
| - media::FileVideoCaptureDevice::GetDeviceSupportedFormats( |
| - *it, &(device_info.supported_formats)); |
| - break; |
| + |
| + if (!use_testing_device_source_) { |
| + media::VideoCaptureDevice::GetDeviceSupportedFormats( |
| + *it, &(device_info.supported_formats)); |
| + } else { |
| + video_capture_device_factory_->GetDeviceSupportedFormats( |
| + *it, &(device_info.supported_formats)); |
| } |
| ConsolidateCaptureFormats(&device_info.supported_formats); |
| new_devices_info_cache.push_back(device_info); |