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

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: burnik@ comments. Rebased. Refactored capabilities update. 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 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 timer->Elapsed()); 557 timer->Elapsed());
557 if (!listener_) { 558 if (!listener_) {
558 // Listener has been removed. 559 // Listener has been removed.
559 return; 560 return;
560 } 561 }
561 devices_info_cache_ = new_devices_info_cache; 562 devices_info_cache_ = new_devices_info_cache;
562 563
563 // Walk the |devices_info_cache_| and transform from VCD::Name to 564 // Walk the |devices_info_cache_| and transform from VCD::Name to
564 // StreamDeviceInfo for return purposes. 565 // StreamDeviceInfo for return purposes.
565 StreamDeviceInfoArray devices; 566 StreamDeviceInfoArray devices;
566 for (DeviceInfos::const_iterator it = devices_info_cache_.begin(); 567 std::vector<Tuple2<media::VideoCaptureDevice::Name,
567 it != devices_info_cache_.end(); ++it) { 568 media::VideoCaptureFormats> > name_and_formats;
569 for (const auto &it : devices_info_cache_) {
perkj_chrome 2014/10/07 14:12:51 is this allowed or not? I was trying to figure it
mcasas 2014/10/07 14:54:44 I read that C++11 is being introduced all over [1]
568 devices.push_back(StreamDeviceInfo( 570 devices.push_back(StreamDeviceInfo(
569 stream_type, it->name.GetNameAndModel(), it->name.id())); 571 stream_type, it.name.GetNameAndModel(), it.name.id()));
572 name_and_formats.push_back(MakeTuple(it.name, it.supported_formats));
570 } 573 }
574 // Send an update to MediaInternals about enumerated capabilities.
575 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind(
576 &MediaInternals::UpdateVideoCaptureDeviceCapabilities,
577 base::Unretained(MediaInternals::GetInstance()),
perkj_chrome 2014/10/07 15:51:24 Should we use devices_info_cache_ instead of creat
578 name_and_formats));
579
571 listener_->DevicesEnumerated(stream_type, devices); 580 listener_->DevicesEnumerated(stream_type, devices);
572 } 581 }
573 582
574 bool VideoCaptureManager::IsOnDeviceThread() const { 583 bool VideoCaptureManager::IsOnDeviceThread() const {
575 return device_task_runner_->BelongsToCurrentThread(); 584 return device_task_runner_->BelongsToCurrentThread();
576 } 585 }
577 586
578 void VideoCaptureManager::ConsolidateDevicesInfoOnDeviceThread( 587 void VideoCaptureManager::ConsolidateDevicesInfoOnDeviceThread(
579 base::Callback<void(const DeviceInfos&)> on_devices_enumerated_callback, 588 base::Callback<void(const DeviceInfos&)> on_devices_enumerated_callback,
580 MediaStreamType stream_type, 589 MediaStreamType stream_type,
(...skipping 15 matching lines...) Expand all
596 names_snapshot->erase(it); 605 names_snapshot->erase(it);
597 break; 606 break;
598 } 607 }
599 } 608 }
600 } 609 }
601 610
602 // Get the supported capture formats for the new devices in |names_snapshot|. 611 // Get the supported capture formats for the new devices in |names_snapshot|.
603 for (media::VideoCaptureDevice::Names::const_iterator it = 612 for (media::VideoCaptureDevice::Names::const_iterator it =
604 names_snapshot->begin(); 613 names_snapshot->begin();
605 it != names_snapshot->end(); ++it) { 614 it != names_snapshot->end(); ++it) {
606 media::VideoCaptureFormats supported_formats;
607 DeviceInfo device_info(*it, media::VideoCaptureFormats()); 615 DeviceInfo device_info(*it, media::VideoCaptureFormats());
608 video_capture_device_factory_->GetDeviceSupportedFormats( 616 video_capture_device_factory_->GetDeviceSupportedFormats(
609 *it, &(device_info.supported_formats)); 617 *it, &(device_info.supported_formats));
610 ConsolidateCaptureFormats(&device_info.supported_formats); 618 ConsolidateCaptureFormats(&device_info.supported_formats);
611 new_devices_info_cache.push_back(device_info); 619 new_devices_info_cache.push_back(device_info);
612 } 620 }
613 621
614 on_devices_enumerated_callback.Run(new_devices_info_cache); 622 on_devices_enumerated_callback.Run(new_devices_info_cache);
615 } 623 }
616 624
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 gfx::NativeViewId window_id) { 730 gfx::NativeViewId window_id) {
723 DCHECK(IsOnDeviceThread()); 731 DCHECK(IsOnDeviceThread());
724 DCHECK(notification_window_ids_.find(session_id) == 732 DCHECK(notification_window_ids_.find(session_id) ==
725 notification_window_ids_.end()); 733 notification_window_ids_.end());
726 notification_window_ids_[session_id] = window_id; 734 notification_window_ids_[session_id] = window_id;
727 VLOG(2) << "Screen capture notification window saved for session " 735 VLOG(2) << "Screen capture notification window saved for session "
728 << session_id << " on device thread."; 736 << session_id << " on device thread.";
729 } 737 }
730 738
731 } // namespace content 739 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698