| 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 310c8f8ba844aacc3efad9da0009807ee13bd6b4..7ae2c6ba35e363267daee51848301e57cf4b4dcc 100644
|
| --- a/content/browser/renderer_host/media/video_capture_manager.cc
|
| +++ b/content/browser/renderer_host/media/video_capture_manager.cc
|
| @@ -281,7 +281,7 @@ void VideoCaptureManager::EnumerateDevices(MediaStreamType stream_type) {
|
| // Bind a callback to ConsolidateDevicesInfoOnDeviceThread() with an argument
|
| // for another callback to OnDevicesInfoEnumerated() to be run in the current
|
| // loop, i.e. IO loop. Pass a timer for UMA histogram collection.
|
| - base::Callback<void(std::unique_ptr<VideoCaptureDevice::Names>)>
|
| + base::Callback<void(std::unique_ptr<VideoCaptureDeviceDescriptors>)>
|
| devices_enumerated_callback = base::Bind(
|
| &VideoCaptureManager::ConsolidateDevicesInfoOnDeviceThread, this,
|
| media::BindToCurrentLoop(
|
| @@ -290,8 +290,9 @@ void VideoCaptureManager::EnumerateDevices(MediaStreamType stream_type) {
|
| stream_type, devices_info_cache_);
|
| // OK to use base::Unretained() since we own the VCDFactory and |this| is
|
| // bound in |devices_enumerated_callback|.
|
| - device_task_runner_->PostTask(FROM_HERE,
|
| - base::Bind(&media::VideoCaptureDeviceFactory::EnumerateDeviceNames,
|
| + device_task_runner_->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&media::VideoCaptureDeviceFactory::EnumerateDeviceDescriptors,
|
| base::Unretained(video_capture_device_factory_.get()),
|
| devices_enumerated_callback));
|
| }
|
| @@ -430,16 +431,17 @@ void VideoCaptureManager::HandleQueuedStartRequest() {
|
| // 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.
|
| - const media::VideoCaptureDeviceInfo* found = GetDeviceInfoById(entry->id);
|
| + const VideoCaptureDeviceInfo* found = GetDeviceInfoById(entry->id);
|
| if (found) {
|
| - entry->video_capture_controller()->DoLogOnIOThread(base::StringPrintf(
|
| - "Starting device: id: %s, name: %s, api: %s",
|
| - found->name.id().c_str(), found->name.GetNameAndModel().c_str(),
|
| - found->name.GetCaptureApiTypeString()));
|
| + entry->video_capture_controller()->DoLogOnIOThread(
|
| + base::StringPrintf("Starting device: id: %s, name: %s, api: %s",
|
| + found->descriptor.device_id.c_str(),
|
| + found->descriptor.GetNameAndModel().c_str(),
|
| + found->descriptor.GetCaptureApiTypeString()));
|
|
|
| start_capture_function = base::Bind(
|
| &VideoCaptureManager::DoStartDeviceCaptureOnDeviceThread, this,
|
| - found->name, request->params(),
|
| + found->descriptor, request->params(),
|
| base::Passed(entry->video_capture_controller()->NewDeviceClient()));
|
| } else {
|
| // Errors from DoStartDeviceCaptureOnDeviceThread go via
|
| @@ -524,14 +526,15 @@ void VideoCaptureManager::OnDeviceStarted(
|
|
|
| std::unique_ptr<media::VideoCaptureDevice>
|
| VideoCaptureManager::DoStartDeviceCaptureOnDeviceThread(
|
| - const VideoCaptureDevice::Name& name,
|
| + const VideoCaptureDeviceDescriptor& descriptor,
|
| const media::VideoCaptureParams& params,
|
| std::unique_ptr<VideoCaptureDevice::Client> device_client) {
|
| SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StartDeviceTime");
|
| DCHECK(IsOnDeviceThread());
|
|
|
| std::unique_ptr<VideoCaptureDevice> video_capture_device;
|
| - video_capture_device = video_capture_device_factory_->Create(name);
|
| + video_capture_device =
|
| + video_capture_device_factory_->CreateDevice(descriptor);
|
|
|
| if (!video_capture_device) {
|
| device_client->OnError(FROM_HERE, "Could not create capture device");
|
| @@ -749,8 +752,7 @@ bool VideoCaptureManager::GetDeviceSupportedFormats(
|
| DVLOG(1) << "GetDeviceSupportedFormats for device: " << it->second.name;
|
|
|
| // Return all available formats of the device, regardless its started state.
|
| - media::VideoCaptureDeviceInfo* existing_device =
|
| - GetDeviceInfoById(it->second.id);
|
| + VideoCaptureDeviceInfo* existing_device = GetDeviceInfoById(it->second.id);
|
| if (existing_device)
|
| *supported_formats = existing_device->supported_formats;
|
| return true;
|
| @@ -907,7 +909,7 @@ void VideoCaptureManager::OnClosed(
|
| void VideoCaptureManager::OnDevicesInfoEnumerated(
|
| MediaStreamType stream_type,
|
| base::ElapsedTimer* timer,
|
| - const media::VideoCaptureDeviceInfos& new_devices_info_cache) {
|
| + const VideoCaptureDeviceInfos& new_devices_info_cache) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| UMA_HISTOGRAM_TIMES(
|
| "Media.VideoCaptureManager.GetAvailableDevicesInfoOnDeviceThreadTime",
|
| @@ -925,8 +927,8 @@ void VideoCaptureManager::OnDevicesInfoEnumerated(
|
| // StreamDeviceInfo for return purposes.
|
| StreamDeviceInfoArray devices;
|
| for (const auto& it : devices_info_cache_) {
|
| - devices.push_back(StreamDeviceInfo(
|
| - stream_type, it.name.GetNameAndModel(), it.name.id()));
|
| + devices.emplace_back(stream_type, it.descriptor.GetNameAndModel(),
|
| + it.descriptor.device_id);
|
| }
|
| listener_->DevicesEnumerated(stream_type, devices);
|
| }
|
| @@ -936,32 +938,33 @@ bool VideoCaptureManager::IsOnDeviceThread() const {
|
| }
|
|
|
| void VideoCaptureManager::ConsolidateDevicesInfoOnDeviceThread(
|
| - base::Callback<void(const media::VideoCaptureDeviceInfos&)>
|
| + base::Callback<void(const VideoCaptureDeviceInfos&)>
|
| on_devices_enumerated_callback,
|
| MediaStreamType stream_type,
|
| - const media::VideoCaptureDeviceInfos& old_device_info_cache,
|
| - std::unique_ptr<VideoCaptureDevice::Names> names_snapshot) {
|
| + const VideoCaptureDeviceInfos& old_device_info_cache,
|
| + std::unique_ptr<VideoCaptureDeviceDescriptors> descriptors_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.
|
| - media::VideoCaptureDeviceInfos new_devices_info_cache;
|
| + VideoCaptureDeviceInfos new_devices_info_cache;
|
| for (const auto& device_info : old_device_info_cache) {
|
| - for (VideoCaptureDevice::Names::iterator it = names_snapshot->begin();
|
| - it != names_snapshot->end(); ++it) {
|
| - if (device_info.name.id() == it->id()) {
|
| + for (VideoCaptureDeviceDescriptors::iterator it =
|
| + descriptors_snapshot->begin();
|
| + it != descriptors_snapshot->end(); ++it) {
|
| + if (device_info.descriptor.device_id == it->device_id) {
|
| new_devices_info_cache.push_back(device_info);
|
| - names_snapshot->erase(it);
|
| + descriptors_snapshot->erase(it);
|
| break;
|
| }
|
| }
|
| }
|
|
|
| - // Get the supported capture formats for the new devices in |names_snapshot|.
|
| - for (const auto& it : *names_snapshot) {
|
| - media::VideoCaptureDeviceInfo device_info(it, media::VideoCaptureFormats());
|
| - video_capture_device_factory_->GetDeviceSupportedFormats(
|
| - it, &(device_info.supported_formats));
|
| + // Get the device info for the new devices in |names_snapshot|.
|
| + for (const auto& it : *descriptors_snapshot) {
|
| + VideoCaptureDeviceInfo device_info(it);
|
| + video_capture_device_factory_->GetSupportedFormats(
|
| + it, &device_info.supported_formats);
|
| ConsolidateCaptureFormats(&device_info.supported_formats);
|
| new_devices_info_cache.push_back(device_info);
|
| }
|
| @@ -1041,10 +1044,10 @@ VideoCaptureManager::DeviceEntry* VideoCaptureManager::GetDeviceEntryBySerialId(
|
| return nullptr;
|
| }
|
|
|
| -media::VideoCaptureDeviceInfo* VideoCaptureManager::GetDeviceInfoById(
|
| +VideoCaptureDeviceInfo* VideoCaptureManager::GetDeviceInfoById(
|
| const std::string& id) {
|
| for (auto& it : devices_info_cache_) {
|
| - if (it.name.id() == id)
|
| + if (it.descriptor.device_id == id)
|
| return ⁢
|
| }
|
| return nullptr;
|
|
|