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 7a28856273673092a84a4d761b278ab9dec96c7e..0f22ac9bd4f1819ba0f222f5cd436ea057681d3d 100644 |
| --- a/content/browser/renderer_host/media/video_capture_manager.cc |
| +++ b/content/browser/renderer_host/media/video_capture_manager.cc |
| @@ -14,6 +14,7 @@ |
| #include "base/task_runner_util.h" |
| #include "base/threading/sequenced_worker_pool.h" |
| #include "content/browser/media/capture/web_contents_video_capture_device.h" |
| +#include "content/browser/media/media_internals.h" |
| #include "content/browser/renderer_host/media/video_capture_controller.h" |
| #include "content/browser/renderer_host/media/video_capture_controller_event_handler.h" |
| #include "content/public/browser/browser_thread.h" |
| @@ -105,15 +106,6 @@ VideoCaptureManager::DeviceEntry::DeviceEntry( |
| VideoCaptureManager::DeviceEntry::~DeviceEntry() {} |
| -VideoCaptureManager::DeviceInfo::DeviceInfo() {} |
| - |
| -VideoCaptureManager::DeviceInfo::DeviceInfo( |
| - const media::VideoCaptureDevice::Name& name, |
| - const media::VideoCaptureFormats& supported_formats) |
| - : name(name), |
| - supported_formats(supported_formats) {} |
| - |
| -VideoCaptureManager::DeviceInfo::~DeviceInfo() {} |
| VideoCaptureManager::VideoCaptureManager( |
| scoped_ptr<media::VideoCaptureDeviceFactory> factory) |
| @@ -236,7 +228,8 @@ void VideoCaptureManager::DoStartDeviceOnDeviceThread( |
| // We look up the device id from the renderer in our local enumeration |
| // since the renderer does not have all the information that might be |
| // held in the browser-side VideoCaptureDevice::Name structure. |
| - DeviceInfo* found = FindDeviceInfoById(entry->id, devices_info_cache_); |
| + media::VideoCaptureDeviceInfo* found = |
| + FindDeviceInfoById(entry->id, devices_info_cache_); |
| if (found) { |
| video_capture_device = |
| video_capture_device_factory_->Create(found->name); |
| @@ -444,7 +437,7 @@ bool VideoCaptureManager::GetDeviceSupportedFormats( |
| DVLOG(1) << "GetDeviceSupportedFormats for device: " << it->second.name; |
| // Return all available formats of the device, regardless its started state. |
| - DeviceInfo* existing_device = |
| + media::VideoCaptureDeviceInfo* existing_device = |
| FindDeviceInfoById(it->second.id, devices_info_cache_); |
| if (existing_device) |
| *supported_formats = existing_device->supported_formats; |
| @@ -549,7 +542,7 @@ void VideoCaptureManager::OnClosed( |
| void VideoCaptureManager::OnDevicesInfoEnumerated( |
| MediaStreamType stream_type, |
| base::ElapsedTimer* timer, |
| - const DeviceInfos& new_devices_info_cache) { |
| + const media::VideoCaptureDeviceInfos& new_devices_info_cache) { |
| DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| UMA_HISTOGRAM_TIMES( |
| "Media.VideoCaptureManager.GetAvailableDevicesInfoOnDeviceThreadTime", |
| @@ -560,13 +553,15 @@ void VideoCaptureManager::OnDevicesInfoEnumerated( |
| } |
| devices_info_cache_ = new_devices_info_cache; |
| + MediaInternals::GetInstance()->UpdateVideoCaptureDeviceCapabilities( |
| + devices_info_cache_); |
| + |
| // Walk the |devices_info_cache_| and transform from VCD::Name to |
| // StreamDeviceInfo for return purposes. |
| StreamDeviceInfoArray devices; |
| - for (DeviceInfos::const_iterator it = devices_info_cache_.begin(); |
| - it != devices_info_cache_.end(); ++it) { |
| + for (const auto &it : devices_info_cache_) { |
|
wolenetz
2014/10/09 20:51:43
nit: ditto auto&
mcasas
2014/10/10 11:30:42
Done.
|
| devices.push_back(StreamDeviceInfo( |
| - stream_type, it->name.GetNameAndModel(), it->name.id())); |
| + stream_type, it.name.GetNameAndModel(), it.name.id())); |
| } |
| listener_->DevicesEnumerated(stream_type, devices); |
| } |
| @@ -576,16 +571,17 @@ bool VideoCaptureManager::IsOnDeviceThread() const { |
| } |
| void VideoCaptureManager::ConsolidateDevicesInfoOnDeviceThread( |
| - base::Callback<void(const DeviceInfos&)> on_devices_enumerated_callback, |
| + base::Callback<void(const media::VideoCaptureDeviceInfos&)> |
| + on_devices_enumerated_callback, |
| MediaStreamType stream_type, |
| - const DeviceInfos& old_device_info_cache, |
| + const media::VideoCaptureDeviceInfos& old_device_info_cache, |
| scoped_ptr<media::VideoCaptureDevice::Names> names_snapshot) { |
| DCHECK(IsOnDeviceThread()); |
| // Construct |new_devices_info_cache| with the cached devices that are still |
| // present in the system, and remove their names from |names_snapshot|, so we |
| // keep there the truly new devices. |
| - DeviceInfos new_devices_info_cache; |
| - for (DeviceInfos::const_iterator it_device_info = |
| + media::VideoCaptureDeviceInfos new_devices_info_cache; |
| + for (media::VideoCaptureDeviceInfos::const_iterator it_device_info = |
|
wolenetz
2014/10/09 20:51:43
nit: is this outer for-loop a candidate for const
mcasas
2014/10/10 11:30:42
Done.
|
| old_device_info_cache.begin(); |
| it_device_info != old_device_info_cache.end(); ++it_device_info) { |
| for (media::VideoCaptureDevice::Names::iterator it = |
| @@ -603,8 +599,8 @@ void VideoCaptureManager::ConsolidateDevicesInfoOnDeviceThread( |
| for (media::VideoCaptureDevice::Names::const_iterator it = |
| names_snapshot->begin(); |
| it != names_snapshot->end(); ++it) { |
| - media::VideoCaptureFormats supported_formats; |
| - DeviceInfo device_info(*it, media::VideoCaptureFormats()); |
| + media::VideoCaptureDeviceInfo device_info(*it, |
| + media::VideoCaptureFormats()); |
| video_capture_device_factory_->GetDeviceSupportedFormats( |
| *it, &(device_info.supported_formats)); |
| ConsolidateCaptureFormats(&device_info.supported_formats); |
| @@ -693,10 +689,10 @@ VideoCaptureManager::DeviceEntry* VideoCaptureManager::GetOrCreateDeviceEntry( |
| return new_device; |
| } |
| -VideoCaptureManager::DeviceInfo* VideoCaptureManager::FindDeviceInfoById( |
| +media::VideoCaptureDeviceInfo* VideoCaptureManager::FindDeviceInfoById( |
| const std::string& id, |
| - DeviceInfos& device_vector) { |
| - for (DeviceInfos::iterator it = device_vector.begin(); |
| + media::VideoCaptureDeviceInfos& device_vector) { |
| + for (media::VideoCaptureDeviceInfos::iterator it = device_vector.begin(); |
| it != device_vector.end(); ++it) { |
| if (it->name.id() == id) |
| return &(*it); |