Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: content/browser/renderer_host/media/video_capture_manager.cc

Issue 616833004: chrome://media-internals: update MediaInternals when devices capabilities are enumerated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved DeviceInfo to media::VideoCaptureDevice and used from VCM and MediaInternals. Other perkj@ co… Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 VideoCaptureManager::DeviceEntry::DeviceEntry( 99 VideoCaptureManager::DeviceEntry::DeviceEntry(
99 MediaStreamType stream_type, 100 MediaStreamType stream_type,
100 const std::string& id, 101 const std::string& id,
101 scoped_ptr<VideoCaptureController> controller) 102 scoped_ptr<VideoCaptureController> controller)
102 : stream_type(stream_type), 103 : stream_type(stream_type),
103 id(id), 104 id(id),
104 video_capture_controller(controller.Pass()) {} 105 video_capture_controller(controller.Pass()) {}
105 106
106 VideoCaptureManager::DeviceEntry::~DeviceEntry() {} 107 VideoCaptureManager::DeviceEntry::~DeviceEntry() {}
107 108
108 VideoCaptureManager::DeviceInfo::DeviceInfo() {}
109
110 VideoCaptureManager::DeviceInfo::DeviceInfo(
111 const media::VideoCaptureDevice::Name& name,
112 const media::VideoCaptureFormats& supported_formats)
113 : name(name),
114 supported_formats(supported_formats) {}
115
116 VideoCaptureManager::DeviceInfo::~DeviceInfo() {}
117 109
118 VideoCaptureManager::VideoCaptureManager( 110 VideoCaptureManager::VideoCaptureManager(
119 scoped_ptr<media::VideoCaptureDeviceFactory> factory) 111 scoped_ptr<media::VideoCaptureDeviceFactory> factory)
120 : listener_(NULL), 112 : listener_(NULL),
121 new_capture_session_id_(1), 113 new_capture_session_id_(1),
122 video_capture_device_factory_(factory.Pass()) { 114 video_capture_device_factory_(factory.Pass()) {
123 } 115 }
124 116
125 VideoCaptureManager::~VideoCaptureManager() { 117 VideoCaptureManager::~VideoCaptureManager() {
126 DCHECK(devices_.empty()); 118 DCHECK(devices_.empty());
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 DCHECK_CURRENTLY_ON(BrowserThread::IO); 545 DCHECK_CURRENTLY_ON(BrowserThread::IO);
554 UMA_HISTOGRAM_TIMES( 546 UMA_HISTOGRAM_TIMES(
555 "Media.VideoCaptureManager.GetAvailableDevicesInfoOnDeviceThreadTime", 547 "Media.VideoCaptureManager.GetAvailableDevicesInfoOnDeviceThreadTime",
556 timer->Elapsed()); 548 timer->Elapsed());
557 if (!listener_) { 549 if (!listener_) {
558 // Listener has been removed. 550 // Listener has been removed.
559 return; 551 return;
560 } 552 }
561 devices_info_cache_ = new_devices_info_cache; 553 devices_info_cache_ = new_devices_info_cache;
562 554
555 // Send an update to MediaInternals about enumerated capabilities later.
556 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind(
557 &MediaInternals::UpdateVideoCaptureDeviceCapabilities,
558 base::Unretained(MediaInternals::GetInstance()),
559 devices_info_cache_));
560
563 // Walk the |devices_info_cache_| and transform from VCD::Name to 561 // Walk the |devices_info_cache_| and transform from VCD::Name to
564 // StreamDeviceInfo for return purposes. 562 // StreamDeviceInfo for return purposes.
565 StreamDeviceInfoArray devices; 563 StreamDeviceInfoArray devices;
566 for (DeviceInfos::const_iterator it = devices_info_cache_.begin(); 564 for (const auto &it : devices_info_cache_) {
567 it != devices_info_cache_.end(); ++it) {
568 devices.push_back(StreamDeviceInfo( 565 devices.push_back(StreamDeviceInfo(
569 stream_type, it->name.GetNameAndModel(), it->name.id())); 566 stream_type, it.name.GetNameAndModel(), it.name.id()));
570 } 567 }
568
571 listener_->DevicesEnumerated(stream_type, devices); 569 listener_->DevicesEnumerated(stream_type, devices);
572 } 570 }
573 571
574 bool VideoCaptureManager::IsOnDeviceThread() const { 572 bool VideoCaptureManager::IsOnDeviceThread() const {
575 return device_task_runner_->BelongsToCurrentThread(); 573 return device_task_runner_->BelongsToCurrentThread();
576 } 574 }
577 575
578 void VideoCaptureManager::ConsolidateDevicesInfoOnDeviceThread( 576 void VideoCaptureManager::ConsolidateDevicesInfoOnDeviceThread(
579 base::Callback<void(const DeviceInfos&)> on_devices_enumerated_callback, 577 base::Callback<void(const DeviceInfos&)> on_devices_enumerated_callback,
580 MediaStreamType stream_type, 578 MediaStreamType stream_type,
(...skipping 15 matching lines...) Expand all
596 names_snapshot->erase(it); 594 names_snapshot->erase(it);
597 break; 595 break;
598 } 596 }
599 } 597 }
600 } 598 }
601 599
602 // Get the supported capture formats for the new devices in |names_snapshot|. 600 // Get the supported capture formats for the new devices in |names_snapshot|.
603 for (media::VideoCaptureDevice::Names::const_iterator it = 601 for (media::VideoCaptureDevice::Names::const_iterator it =
604 names_snapshot->begin(); 602 names_snapshot->begin();
605 it != names_snapshot->end(); ++it) { 603 it != names_snapshot->end(); ++it) {
606 media::VideoCaptureFormats supported_formats;
607 DeviceInfo device_info(*it, media::VideoCaptureFormats()); 604 DeviceInfo device_info(*it, media::VideoCaptureFormats());
608 video_capture_device_factory_->GetDeviceSupportedFormats( 605 video_capture_device_factory_->GetDeviceSupportedFormats(
609 *it, &(device_info.supported_formats)); 606 *it, &(device_info.supported_formats));
610 ConsolidateCaptureFormats(&device_info.supported_formats); 607 ConsolidateCaptureFormats(&device_info.supported_formats);
611 new_devices_info_cache.push_back(device_info); 608 new_devices_info_cache.push_back(device_info);
612 } 609 }
613 610
614 on_devices_enumerated_callback.Run(new_devices_info_cache); 611 on_devices_enumerated_callback.Run(new_devices_info_cache);
615 } 612 }
616 613
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 gfx::NativeViewId window_id) { 719 gfx::NativeViewId window_id) {
723 DCHECK(IsOnDeviceThread()); 720 DCHECK(IsOnDeviceThread());
724 DCHECK(notification_window_ids_.find(session_id) == 721 DCHECK(notification_window_ids_.find(session_id) ==
725 notification_window_ids_.end()); 722 notification_window_ids_.end());
726 notification_window_ids_[session_id] = window_id; 723 notification_window_ids_[session_id] = window_id;
727 VLOG(2) << "Screen capture notification window saved for session " 724 VLOG(2) << "Screen capture notification window saved for session "
728 << session_id << " on device thread."; 725 << session_id << " on device thread.";
729 } 726 }
730 727
731 } // namespace content 728 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698