OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/renderer_host/media/video_capture_manager.h" | 5 #include "content/browser/renderer_host/media/video_capture_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 std::unique_ptr<VideoCaptureDevice> ReleaseVideoCaptureDevice(); | 148 std::unique_ptr<VideoCaptureDevice> ReleaseVideoCaptureDevice(); |
149 | 149 |
150 private: | 150 private: |
151 const std::unique_ptr<VideoCaptureController> video_capture_controller_; | 151 const std::unique_ptr<VideoCaptureController> video_capture_controller_; |
152 | 152 |
153 std::unique_ptr<VideoCaptureDevice> video_capture_device_; | 153 std::unique_ptr<VideoCaptureDevice> video_capture_device_; |
154 | 154 |
155 base::ThreadChecker thread_checker_; | 155 base::ThreadChecker thread_checker_; |
156 }; | 156 }; |
157 | 157 |
| 158 // Bundles a media::VideoCaptureDeviceDescriptor with corresponding supported |
| 159 // video formats. |
| 160 struct VideoCaptureManager::DeviceInfo { |
| 161 DeviceInfo(); |
| 162 DeviceInfo(media::VideoCaptureDeviceDescriptor descriptor); |
| 163 DeviceInfo(const DeviceInfo& other); |
| 164 ~DeviceInfo(); |
| 165 DeviceInfo& operator=(const DeviceInfo& other); |
| 166 |
| 167 media::VideoCaptureDeviceDescriptor descriptor; |
| 168 media::VideoCaptureFormats supported_formats; |
| 169 }; |
| 170 |
158 // Class used for queuing request for starting a device. | 171 // Class used for queuing request for starting a device. |
159 class VideoCaptureManager::CaptureDeviceStartRequest { | 172 class VideoCaptureManager::CaptureDeviceStartRequest { |
160 public: | 173 public: |
161 CaptureDeviceStartRequest(int serial_id, | 174 CaptureDeviceStartRequest(int serial_id, |
162 media::VideoCaptureSessionId session_id, | 175 media::VideoCaptureSessionId session_id, |
163 const media::VideoCaptureParams& params); | 176 const media::VideoCaptureParams& params); |
164 int serial_id() const { return serial_id_; } | 177 int serial_id() const { return serial_id_; } |
165 media::VideoCaptureSessionId session_id() const { return session_id_; } | 178 media::VideoCaptureSessionId session_id() const { return session_id_; } |
166 media::VideoCaptureParams params() const { return params_; } | 179 media::VideoCaptureParams params() const { return params_; } |
167 | 180 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 DCHECK(thread_checker_.CalledOnValidThread()); | 228 DCHECK(thread_checker_.CalledOnValidThread()); |
216 return video_capture_controller_.get(); | 229 return video_capture_controller_.get(); |
217 } | 230 } |
218 | 231 |
219 media::VideoCaptureDevice* | 232 media::VideoCaptureDevice* |
220 VideoCaptureManager::DeviceEntry::video_capture_device() const { | 233 VideoCaptureManager::DeviceEntry::video_capture_device() const { |
221 DCHECK(thread_checker_.CalledOnValidThread()); | 234 DCHECK(thread_checker_.CalledOnValidThread()); |
222 return video_capture_device_.get(); | 235 return video_capture_device_.get(); |
223 } | 236 } |
224 | 237 |
| 238 VideoCaptureManager::DeviceInfo::DeviceInfo() = default; |
| 239 |
| 240 VideoCaptureManager::DeviceInfo::DeviceInfo( |
| 241 media::VideoCaptureDeviceDescriptor descriptor) |
| 242 : descriptor(descriptor) {} |
| 243 |
| 244 VideoCaptureManager::DeviceInfo::DeviceInfo( |
| 245 const VideoCaptureManager::DeviceInfo& other) = default; |
| 246 |
| 247 VideoCaptureManager::DeviceInfo::~DeviceInfo() = default; |
| 248 |
| 249 VideoCaptureManager::DeviceInfo& VideoCaptureManager::DeviceInfo::operator=( |
| 250 const VideoCaptureManager::DeviceInfo& other) = default; |
| 251 |
225 VideoCaptureManager::CaptureDeviceStartRequest::CaptureDeviceStartRequest( | 252 VideoCaptureManager::CaptureDeviceStartRequest::CaptureDeviceStartRequest( |
226 int serial_id, | 253 int serial_id, |
227 media::VideoCaptureSessionId session_id, | 254 media::VideoCaptureSessionId session_id, |
228 const media::VideoCaptureParams& params) | 255 const media::VideoCaptureParams& params) |
229 : serial_id_(serial_id), | 256 : serial_id_(serial_id), |
230 session_id_(session_id), | 257 session_id_(session_id), |
231 params_(params), | 258 params_(params), |
232 abort_start_(false) { | 259 abort_start_(false) { |
233 } | 260 } |
234 | 261 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 if (NeedToInitializeCaptureDeviceApi(stream_type)) { | 301 if (NeedToInitializeCaptureDeviceApi(stream_type)) { |
275 InitializeCaptureDeviceApiOnUIThread( | 302 InitializeCaptureDeviceApiOnUIThread( |
276 base::Bind(&VideoCaptureManager::EnumerateDevices, this, stream_type)); | 303 base::Bind(&VideoCaptureManager::EnumerateDevices, this, stream_type)); |
277 return; | 304 return; |
278 } | 305 } |
279 #endif | 306 #endif |
280 | 307 |
281 // Bind a callback to ConsolidateDevicesInfoOnDeviceThread() with an argument | 308 // Bind a callback to ConsolidateDevicesInfoOnDeviceThread() with an argument |
282 // for another callback to OnDevicesInfoEnumerated() to be run in the current | 309 // for another callback to OnDevicesInfoEnumerated() to be run in the current |
283 // loop, i.e. IO loop. Pass a timer for UMA histogram collection. | 310 // loop, i.e. IO loop. Pass a timer for UMA histogram collection. |
284 base::Callback<void(std::unique_ptr<VideoCaptureDevice::Names>)> | 311 base::Callback<void(std::unique_ptr<VideoCaptureDeviceDescriptors>)> |
285 devices_enumerated_callback = base::Bind( | 312 devices_enumerated_callback = base::Bind( |
286 &VideoCaptureManager::ConsolidateDevicesInfoOnDeviceThread, this, | 313 &VideoCaptureManager::ConsolidateDevicesInfoOnDeviceThread, this, |
287 media::BindToCurrentLoop( | 314 media::BindToCurrentLoop( |
288 base::Bind(&VideoCaptureManager::OnDevicesInfoEnumerated, this, | 315 base::Bind(&VideoCaptureManager::OnDevicesInfoEnumerated, this, |
289 stream_type, base::Owned(new base::ElapsedTimer()))), | 316 stream_type, base::Owned(new base::ElapsedTimer()))), |
290 stream_type, devices_info_cache_); | 317 stream_type, devices_info_cache_); |
291 // OK to use base::Unretained() since we own the VCDFactory and |this| is | 318 // OK to use base::Unretained() since we own the VCDFactory and |this| is |
292 // bound in |devices_enumerated_callback|. | 319 // bound in |devices_enumerated_callback|. |
293 device_task_runner_->PostTask(FROM_HERE, | 320 device_task_runner_->PostTask( |
294 base::Bind(&media::VideoCaptureDeviceFactory::EnumerateDeviceNames, | 321 FROM_HERE, |
| 322 base::Bind(&media::VideoCaptureDeviceFactory::EnumerateDeviceDescriptors, |
295 base::Unretained(video_capture_device_factory_.get()), | 323 base::Unretained(video_capture_device_factory_.get()), |
296 devices_enumerated_callback)); | 324 devices_enumerated_callback)); |
297 } | 325 } |
298 | 326 |
299 int VideoCaptureManager::Open(const StreamDeviceInfo& device_info) { | 327 int VideoCaptureManager::Open(const StreamDeviceInfo& device_info) { |
300 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 328 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
301 DCHECK(listener_); | 329 DCHECK(listener_); |
302 | 330 |
303 // Generate a new id for the session being opened. | 331 // Generate a new id for the session being opened. |
304 const media::VideoCaptureSessionId capture_session_id = | 332 const media::VideoCaptureSessionId capture_session_id = |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 << entry->id << " start id = " << entry->serial_id; | 451 << entry->id << " start id = " << entry->serial_id; |
424 | 452 |
425 base::Callback<std::unique_ptr<VideoCaptureDevice>(void)> | 453 base::Callback<std::unique_ptr<VideoCaptureDevice>(void)> |
426 start_capture_function; | 454 start_capture_function; |
427 | 455 |
428 switch (entry->stream_type) { | 456 switch (entry->stream_type) { |
429 case MEDIA_DEVICE_VIDEO_CAPTURE: { | 457 case MEDIA_DEVICE_VIDEO_CAPTURE: { |
430 // We look up the device id from the renderer in our local enumeration | 458 // We look up the device id from the renderer in our local enumeration |
431 // since the renderer does not have all the information that might be | 459 // since the renderer does not have all the information that might be |
432 // held in the browser-side VideoCaptureDevice::Name structure. | 460 // held in the browser-side VideoCaptureDevice::Name structure. |
433 const media::VideoCaptureDeviceInfo* found = GetDeviceInfoById(entry->id); | 461 const DeviceInfo* found = GetDeviceInfoById(entry->id); |
434 if (found) { | 462 if (found) { |
435 entry->video_capture_controller()->DoLogOnIOThread(base::StringPrintf( | 463 entry->video_capture_controller()->DoLogOnIOThread( |
436 "Starting device: id: %s, name: %s, api: %s", | 464 base::StringPrintf("Starting device: id: %s, name: %s, api: %s", |
437 found->name.id().c_str(), found->name.GetNameAndModel().c_str(), | 465 found->descriptor.device_id.c_str(), |
438 found->name.GetCaptureApiTypeString())); | 466 found->descriptor.GetNameAndModel().c_str(), |
| 467 found->descriptor.GetCaptureApiTypeString())); |
439 | 468 |
440 start_capture_function = base::Bind( | 469 start_capture_function = base::Bind( |
441 &VideoCaptureManager::DoStartDeviceCaptureOnDeviceThread, this, | 470 &VideoCaptureManager::DoStartDeviceCaptureOnDeviceThread, this, |
442 found->name, request->params(), | 471 found->descriptor, request->params(), |
443 base::Passed(entry->video_capture_controller()->NewDeviceClient())); | 472 base::Passed(entry->video_capture_controller()->NewDeviceClient())); |
444 } else { | 473 } else { |
445 // Errors from DoStartDeviceCaptureOnDeviceThread go via | 474 // Errors from DoStartDeviceCaptureOnDeviceThread go via |
446 // VideoCaptureDeviceClient::OnError, which needs some thread | 475 // VideoCaptureDeviceClient::OnError, which needs some thread |
447 // dancing to get errors processed on the IO thread. But since | 476 // dancing to get errors processed on the IO thread. But since |
448 // we're on that thread, we call VideoCaptureController | 477 // we're on that thread, we call VideoCaptureController |
449 // methods directly. | 478 // methods directly. |
450 const std::string log_message = base::StringPrintf( | 479 const std::string log_message = base::StringPrintf( |
451 "Error on %s:%d: device %s unknown. Maybe recently disconnected?", | 480 "Error on %s:%d: device %s unknown. Maybe recently disconnected?", |
452 __FILE__, __LINE__, entry->id.c_str()); | 481 __FILE__, __LINE__, entry->id.c_str()); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 MaybePostDesktopCaptureWindowId(session_id); | 546 MaybePostDesktopCaptureWindowId(session_id); |
518 } | 547 } |
519 } | 548 } |
520 | 549 |
521 device_start_queue_.pop_front(); | 550 device_start_queue_.pop_front(); |
522 HandleQueuedStartRequest(); | 551 HandleQueuedStartRequest(); |
523 } | 552 } |
524 | 553 |
525 std::unique_ptr<media::VideoCaptureDevice> | 554 std::unique_ptr<media::VideoCaptureDevice> |
526 VideoCaptureManager::DoStartDeviceCaptureOnDeviceThread( | 555 VideoCaptureManager::DoStartDeviceCaptureOnDeviceThread( |
527 const VideoCaptureDevice::Name& name, | 556 const VideoCaptureDeviceDescriptor& descriptor, |
528 const media::VideoCaptureParams& params, | 557 const media::VideoCaptureParams& params, |
529 std::unique_ptr<VideoCaptureDevice::Client> device_client) { | 558 std::unique_ptr<VideoCaptureDevice::Client> device_client) { |
530 SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StartDeviceTime"); | 559 SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StartDeviceTime"); |
531 DCHECK(IsOnDeviceThread()); | 560 DCHECK(IsOnDeviceThread()); |
532 | 561 |
533 std::unique_ptr<VideoCaptureDevice> video_capture_device; | 562 std::unique_ptr<VideoCaptureDevice> video_capture_device; |
534 video_capture_device = video_capture_device_factory_->Create(name); | 563 video_capture_device = |
| 564 video_capture_device_factory_->CreateDevice(descriptor); |
535 | 565 |
536 if (!video_capture_device) { | 566 if (!video_capture_device) { |
537 device_client->OnError(FROM_HERE, "Could not create capture device"); | 567 device_client->OnError(FROM_HERE, "Could not create capture device"); |
538 return nullptr; | 568 return nullptr; |
539 } | 569 } |
540 | 570 |
541 video_capture_device->AllocateAndStart(params, std::move(device_client)); | 571 video_capture_device->AllocateAndStart(params, std::move(device_client)); |
542 return video_capture_device; | 572 return video_capture_device; |
543 } | 573 } |
544 | 574 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 media::VideoCaptureFormats* supported_formats) { | 772 media::VideoCaptureFormats* supported_formats) { |
743 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 773 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
744 DCHECK(supported_formats->empty()); | 774 DCHECK(supported_formats->empty()); |
745 | 775 |
746 SessionMap::iterator it = sessions_.find(capture_session_id); | 776 SessionMap::iterator it = sessions_.find(capture_session_id); |
747 if (it == sessions_.end()) | 777 if (it == sessions_.end()) |
748 return false; | 778 return false; |
749 DVLOG(1) << "GetDeviceSupportedFormats for device: " << it->second.name; | 779 DVLOG(1) << "GetDeviceSupportedFormats for device: " << it->second.name; |
750 | 780 |
751 // Return all available formats of the device, regardless its started state. | 781 // Return all available formats of the device, regardless its started state. |
752 media::VideoCaptureDeviceInfo* existing_device = | 782 DeviceInfo* existing_device = GetDeviceInfoById(it->second.id); |
753 GetDeviceInfoById(it->second.id); | |
754 if (existing_device) | 783 if (existing_device) |
755 *supported_formats = existing_device->supported_formats; | 784 *supported_formats = existing_device->supported_formats; |
756 return true; | 785 return true; |
757 } | 786 } |
758 | 787 |
759 bool VideoCaptureManager::GetDeviceFormatsInUse( | 788 bool VideoCaptureManager::GetDeviceFormatsInUse( |
760 media::VideoCaptureSessionId capture_session_id, | 789 media::VideoCaptureSessionId capture_session_id, |
761 media::VideoCaptureFormats* formats_in_use) { | 790 media::VideoCaptureFormats* formats_in_use) { |
762 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 791 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
763 DCHECK(formats_in_use->empty()); | 792 DCHECK(formats_in_use->empty()); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 if (!listener_) { | 929 if (!listener_) { |
901 // Listener has been removed. | 930 // Listener has been removed. |
902 return; | 931 return; |
903 } | 932 } |
904 listener_->Closed(stream_type, capture_session_id); | 933 listener_->Closed(stream_type, capture_session_id); |
905 } | 934 } |
906 | 935 |
907 void VideoCaptureManager::OnDevicesInfoEnumerated( | 936 void VideoCaptureManager::OnDevicesInfoEnumerated( |
908 MediaStreamType stream_type, | 937 MediaStreamType stream_type, |
909 base::ElapsedTimer* timer, | 938 base::ElapsedTimer* timer, |
910 const media::VideoCaptureDeviceInfos& new_devices_info_cache) { | 939 const VideoCaptureManager::DeviceInfos& new_devices_info_cache) { |
911 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 940 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
912 UMA_HISTOGRAM_TIMES( | 941 UMA_HISTOGRAM_TIMES( |
913 "Media.VideoCaptureManager.GetAvailableDevicesInfoOnDeviceThreadTime", | 942 "Media.VideoCaptureManager.GetAvailableDevicesInfoOnDeviceThreadTime", |
914 timer->Elapsed()); | 943 timer->Elapsed()); |
915 if (!listener_) { | 944 if (!listener_) { |
916 // Listener has been removed. | 945 // Listener has been removed. |
917 return; | 946 return; |
918 } | 947 } |
919 devices_info_cache_ = new_devices_info_cache; | 948 devices_info_cache_ = new_devices_info_cache; |
920 | 949 |
921 MediaInternals::GetInstance()->UpdateVideoCaptureDeviceCapabilities( | 950 // Walk the |devices_info_cache_| and transform from |
922 devices_info_cache_); | 951 // VideoCaptureDeviceDescriptor to StreamDeviceInfo for return purposes. |
923 | |
924 // Walk the |devices_info_cache_| and transform from VCD::Name to | |
925 // StreamDeviceInfo for return purposes. | |
926 StreamDeviceInfoArray devices; | 952 StreamDeviceInfoArray devices; |
| 953 std::vector<std::tuple<media::VideoCaptureDeviceDescriptor, |
| 954 media::VideoCaptureFormats>> |
| 955 descriptors_and_formats; |
927 for (const auto& it : devices_info_cache_) { | 956 for (const auto& it : devices_info_cache_) { |
928 devices.push_back(StreamDeviceInfo( | 957 devices.emplace_back(stream_type, it.descriptor.GetNameAndModel(), |
929 stream_type, it.name.GetNameAndModel(), it.name.id())); | 958 it.descriptor.device_id); |
| 959 descriptors_and_formats.emplace_back(it.descriptor, it.supported_formats); |
| 960 MediaInternals::GetInstance()->UpdateVideoCaptureDeviceCapabilities( |
| 961 descriptors_and_formats); |
930 } | 962 } |
931 listener_->DevicesEnumerated(stream_type, devices); | 963 listener_->DevicesEnumerated(stream_type, devices); |
932 } | 964 } |
933 | 965 |
934 bool VideoCaptureManager::IsOnDeviceThread() const { | 966 bool VideoCaptureManager::IsOnDeviceThread() const { |
935 return device_task_runner_->BelongsToCurrentThread(); | 967 return device_task_runner_->BelongsToCurrentThread(); |
936 } | 968 } |
937 | 969 |
938 void VideoCaptureManager::ConsolidateDevicesInfoOnDeviceThread( | 970 void VideoCaptureManager::ConsolidateDevicesInfoOnDeviceThread( |
939 base::Callback<void(const media::VideoCaptureDeviceInfos&)> | 971 base::Callback<void(const VideoCaptureManager::DeviceInfos&)> |
940 on_devices_enumerated_callback, | 972 on_devices_enumerated_callback, |
941 MediaStreamType stream_type, | 973 MediaStreamType stream_type, |
942 const media::VideoCaptureDeviceInfos& old_device_info_cache, | 974 const VideoCaptureManager::DeviceInfos& old_device_info_cache, |
943 std::unique_ptr<VideoCaptureDevice::Names> names_snapshot) { | 975 std::unique_ptr<VideoCaptureDeviceDescriptors> descriptors_snapshot) { |
944 DCHECK(IsOnDeviceThread()); | 976 DCHECK(IsOnDeviceThread()); |
945 // Construct |new_devices_info_cache| with the cached devices that are still | 977 // Construct |new_devices_info_cache| with the cached devices that are still |
946 // present in the system, and remove their names from |names_snapshot|, so we | 978 // present in the system, and remove their names from |names_snapshot|, so we |
947 // keep there the truly new devices. | 979 // keep there the truly new devices. |
948 media::VideoCaptureDeviceInfos new_devices_info_cache; | 980 VideoCaptureManager::DeviceInfos new_devices_info_cache; |
949 for (const auto& device_info : old_device_info_cache) { | 981 for (const auto& device_info : old_device_info_cache) { |
950 for (VideoCaptureDevice::Names::iterator it = names_snapshot->begin(); | 982 for (VideoCaptureDeviceDescriptors::iterator it = |
951 it != names_snapshot->end(); ++it) { | 983 descriptors_snapshot->begin(); |
952 if (device_info.name.id() == it->id()) { | 984 it != descriptors_snapshot->end(); ++it) { |
| 985 if (device_info.descriptor.device_id == it->device_id) { |
953 new_devices_info_cache.push_back(device_info); | 986 new_devices_info_cache.push_back(device_info); |
954 names_snapshot->erase(it); | 987 descriptors_snapshot->erase(it); |
955 break; | 988 break; |
956 } | 989 } |
957 } | 990 } |
958 } | 991 } |
959 | 992 |
960 // Get the supported capture formats for the new devices in |names_snapshot|. | 993 // Get the device info for the new devices in |names_snapshot|. |
961 for (const auto& it : *names_snapshot) { | 994 for (const auto& it : *descriptors_snapshot) { |
962 media::VideoCaptureDeviceInfo device_info(it, media::VideoCaptureFormats()); | 995 DeviceInfo device_info(it); |
963 video_capture_device_factory_->GetDeviceSupportedFormats( | 996 video_capture_device_factory_->GetSupportedFormats( |
964 it, &(device_info.supported_formats)); | 997 it, &device_info.supported_formats); |
965 ConsolidateCaptureFormats(&device_info.supported_formats); | 998 ConsolidateCaptureFormats(&device_info.supported_formats); |
966 new_devices_info_cache.push_back(device_info); | 999 new_devices_info_cache.push_back(device_info); |
967 } | 1000 } |
968 | 1001 |
969 on_devices_enumerated_callback.Run(new_devices_info_cache); | 1002 on_devices_enumerated_callback.Run(new_devices_info_cache); |
970 } | 1003 } |
971 | 1004 |
972 void VideoCaptureManager::DestroyDeviceEntryIfNoClients(DeviceEntry* entry) { | 1005 void VideoCaptureManager::DestroyDeviceEntryIfNoClients(DeviceEntry* entry) { |
973 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1006 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
974 // Removal of the last client stops the device. | 1007 // Removal of the last client stops the device. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 int serial_id) const { | 1067 int serial_id) const { |
1035 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1068 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
1036 | 1069 |
1037 for (const std::unique_ptr<DeviceEntry>& device : devices_) { | 1070 for (const std::unique_ptr<DeviceEntry>& device : devices_) { |
1038 if (device->serial_id == serial_id) | 1071 if (device->serial_id == serial_id) |
1039 return device.get(); | 1072 return device.get(); |
1040 } | 1073 } |
1041 return nullptr; | 1074 return nullptr; |
1042 } | 1075 } |
1043 | 1076 |
1044 media::VideoCaptureDeviceInfo* VideoCaptureManager::GetDeviceInfoById( | 1077 VideoCaptureManager::DeviceInfo* VideoCaptureManager::GetDeviceInfoById( |
1045 const std::string& id) { | 1078 const std::string& id) { |
1046 for (auto& it : devices_info_cache_) { | 1079 for (auto& it : devices_info_cache_) { |
1047 if (it.name.id() == id) | 1080 if (it.descriptor.device_id == id) |
1048 return ⁢ | 1081 return ⁢ |
1049 } | 1082 } |
1050 return nullptr; | 1083 return nullptr; |
1051 } | 1084 } |
1052 | 1085 |
1053 VideoCaptureManager::DeviceEntry* VideoCaptureManager::GetOrCreateDeviceEntry( | 1086 VideoCaptureManager::DeviceEntry* VideoCaptureManager::GetOrCreateDeviceEntry( |
1054 media::VideoCaptureSessionId capture_session_id, | 1087 media::VideoCaptureSessionId capture_session_id, |
1055 const media::VideoCaptureParams& params) { | 1088 const media::VideoCaptureParams& params) { |
1056 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1089 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
1057 | 1090 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 if (!device_in_queue) { | 1202 if (!device_in_queue) { |
1170 // Session ID is only valid for Screen capture. So we can fake it to | 1203 // Session ID is only valid for Screen capture. So we can fake it to |
1171 // resume video capture devices here. | 1204 // resume video capture devices here. |
1172 QueueStartDevice(kFakeSessionId, entry.get(), entry->parameters); | 1205 QueueStartDevice(kFakeSessionId, entry.get(), entry->parameters); |
1173 } | 1206 } |
1174 } | 1207 } |
1175 } | 1208 } |
1176 #endif // defined(OS_ANDROID) | 1209 #endif // defined(OS_ANDROID) |
1177 | 1210 |
1178 } // namespace content | 1211 } // namespace content |
OLD | NEW |