Chromium Code Reviews| 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 <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 14 #include "base/task_runner_util.h" | 14 #include "base/task_runner_util.h" |
| 15 #include "base/threading/sequenced_worker_pool.h" | 15 #include "base/threading/sequenced_worker_pool.h" |
| 16 #include "content/browser/media/capture/web_contents_video_capture_device.h" | 16 #include "content/browser/media/capture/web_contents_video_capture_device.h" |
| 17 #include "content/browser/media/media_internals.h" | |
| 17 #include "content/browser/renderer_host/media/video_capture_controller.h" | 18 #include "content/browser/renderer_host/media/video_capture_controller.h" |
| 18 #include "content/browser/renderer_host/media/video_capture_controller_event_han dler.h" | 19 #include "content/browser/renderer_host/media/video_capture_controller_event_han dler.h" |
| 19 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/browser/desktop_media_id.h" | 21 #include "content/public/browser/desktop_media_id.h" |
| 21 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" |
| 22 #include "content/public/common/media_stream_request.h" | 23 #include "content/public/common/media_stream_request.h" |
| 23 #include "media/base/bind_to_current_loop.h" | 24 #include "media/base/bind_to_current_loop.h" |
| 24 #include "media/base/scoped_histogram_timer.h" | 25 #include "media/base/scoped_histogram_timer.h" |
| 25 #include "media/video/capture/video_capture_device.h" | 26 #include "media/video/capture/video_capture_device.h" |
| 26 #include "media/video/capture/video_capture_device_factory.h" | 27 #include "media/video/capture/video_capture_device_factory.h" |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 490 "Media.VideoCaptureManager.GetAvailableDevicesInfoOnDeviceThreadTime", | 491 "Media.VideoCaptureManager.GetAvailableDevicesInfoOnDeviceThreadTime", |
| 491 timer->Elapsed()); | 492 timer->Elapsed()); |
| 492 if (!listener_) { | 493 if (!listener_) { |
| 493 // Listener has been removed. | 494 // Listener has been removed. |
| 494 return; | 495 return; |
| 495 } | 496 } |
| 496 devices_info_cache_ = new_devices_info_cache; | 497 devices_info_cache_ = new_devices_info_cache; |
| 497 | 498 |
| 498 // Walk the |devices_info_cache_| and transform from VCD::Name to | 499 // Walk the |devices_info_cache_| and transform from VCD::Name to |
| 499 // StreamDeviceInfo for return purposes. | 500 // StreamDeviceInfo for return purposes. |
| 501 MediaInternals::GetInstance()->PurgeVideoCaptureDeviceCapabilities(); | |
|
burnik
2014/10/05 23:08:55
Maybe we can avoid this if we start of with an emp
mcasas
2014/10/07 11:25:40
Done.
| |
| 500 StreamDeviceInfoArray devices; | 502 StreamDeviceInfoArray devices; |
| 501 for (DeviceInfos::const_iterator it = devices_info_cache_.begin(); | 503 for (const auto &it : devices_info_cache_) { |
| 502 it != devices_info_cache_.end(); ++it) { | |
| 503 devices.push_back(StreamDeviceInfo( | 504 devices.push_back(StreamDeviceInfo( |
| 504 stream_type, it->name.GetNameAndModel(), it->name.id())); | 505 stream_type, it.name.GetNameAndModel(), it.name.id())); |
| 506 // Send an update to MediaInternals later on. | |
|
burnik
2014/10/03 11:15:41
Nit: add empty line before comment.
mcasas
2014/10/07 11:25:40
Done.
| |
| 507 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( | |
| 508 &MediaInternals::UpdateVideoCaptureDeviceCapabilities, | |
| 509 base::Unretained(MediaInternals::GetInstance()), | |
| 510 it.name, | |
| 511 it.supported_formats)); | |
|
burnik
2014/10/05 23:08:55
add
devices_info_cache_.size()
as last argument.
mcasas
2014/10/07 11:25:40
Done.
| |
| 505 } | 512 } |
| 506 listener_->DevicesEnumerated(stream_type, devices); | 513 listener_->DevicesEnumerated(stream_type, devices); |
| 507 } | 514 } |
| 508 | 515 |
| 509 bool VideoCaptureManager::IsOnDeviceThread() const { | 516 bool VideoCaptureManager::IsOnDeviceThread() const { |
| 510 return device_task_runner_->BelongsToCurrentThread(); | 517 return device_task_runner_->BelongsToCurrentThread(); |
| 511 } | 518 } |
| 512 | 519 |
| 513 void VideoCaptureManager::ConsolidateDevicesInfoOnDeviceThread( | 520 void VideoCaptureManager::ConsolidateDevicesInfoOnDeviceThread( |
| 514 base::Callback<void(const DeviceInfos&)> on_devices_enumerated_callback, | 521 base::Callback<void(const DeviceInfos&)> on_devices_enumerated_callback, |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 531 names_snapshot->erase(it); | 538 names_snapshot->erase(it); |
| 532 break; | 539 break; |
| 533 } | 540 } |
| 534 } | 541 } |
| 535 } | 542 } |
| 536 | 543 |
| 537 // Get the supported capture formats for the new devices in |names_snapshot|. | 544 // Get the supported capture formats for the new devices in |names_snapshot|. |
| 538 for (media::VideoCaptureDevice::Names::const_iterator it = | 545 for (media::VideoCaptureDevice::Names::const_iterator it = |
| 539 names_snapshot->begin(); | 546 names_snapshot->begin(); |
| 540 it != names_snapshot->end(); ++it) { | 547 it != names_snapshot->end(); ++it) { |
| 541 media::VideoCaptureFormats supported_formats; | |
| 542 DeviceInfo device_info(*it, media::VideoCaptureFormats()); | 548 DeviceInfo device_info(*it, media::VideoCaptureFormats()); |
| 543 video_capture_device_factory_->GetDeviceSupportedFormats( | 549 video_capture_device_factory_->GetDeviceSupportedFormats( |
| 544 *it, &(device_info.supported_formats)); | 550 *it, &(device_info.supported_formats)); |
| 545 ConsolidateCaptureFormats(&device_info.supported_formats); | 551 ConsolidateCaptureFormats(&device_info.supported_formats); |
| 546 new_devices_info_cache.push_back(device_info); | 552 new_devices_info_cache.push_back(device_info); |
| 547 } | 553 } |
| 548 | 554 |
| 549 on_devices_enumerated_callback.Run(new_devices_info_cache); | 555 on_devices_enumerated_callback.Run(new_devices_info_cache); |
| 550 } | 556 } |
| 551 | 557 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 657 gfx::NativeViewId window_id) { | 663 gfx::NativeViewId window_id) { |
| 658 DCHECK(IsOnDeviceThread()); | 664 DCHECK(IsOnDeviceThread()); |
| 659 DCHECK(notification_window_ids_.find(session_id) == | 665 DCHECK(notification_window_ids_.find(session_id) == |
| 660 notification_window_ids_.end()); | 666 notification_window_ids_.end()); |
| 661 notification_window_ids_[session_id] = window_id; | 667 notification_window_ids_[session_id] = window_id; |
| 662 VLOG(2) << "Screen capture notification window saved for session " | 668 VLOG(2) << "Screen capture notification window saved for session " |
| 663 << session_id << " on device thread."; | 669 << session_id << " on device thread."; |
| 664 } | 670 } |
| 665 | 671 |
| 666 } // namespace content | 672 } // namespace content |
| OLD | NEW |