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

Side by Side Diff: content/browser/media/media_internals.cc

Issue 643343004: Video Capture Capabilities available on chrome://media-internals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits @ xhwang 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
« no previous file with comments | « content/browser/media/media_internals.h ('k') | content/browser/media/media_internals_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/media/media_internals.h" 5 #include "content/browser/media/media_internals.h"
6 6
7 #include "base/strings/string16.h" 7 #include "base/strings/string16.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 void MediaInternals::SendAudioStreamData() { 217 void MediaInternals::SendAudioStreamData() {
218 base::string16 audio_stream_update; 218 base::string16 audio_stream_update;
219 { 219 {
220 base::AutoLock auto_lock(lock_); 220 base::AutoLock auto_lock(lock_);
221 audio_stream_update = SerializeUpdate( 221 audio_stream_update = SerializeUpdate(
222 "media.onReceiveAudioStreamData", &audio_streams_cached_data_); 222 "media.onReceiveAudioStreamData", &audio_streams_cached_data_);
223 } 223 }
224 SendUpdate(audio_stream_update); 224 SendUpdate(audio_stream_update);
225 } 225 }
226 226
227 void MediaInternals::SendVideoCaptureDeviceCapabilities() {
228 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
229 SendUpdate(SerializeUpdate("media.onReceiveVideoCaptureCapabilities",
230 &video_capture_capabilities_cached_data_));
231 }
232
227 void MediaInternals::UpdateVideoCaptureDeviceCapabilities( 233 void MediaInternals::UpdateVideoCaptureDeviceCapabilities(
228 const media::VideoCaptureDeviceInfos& video_capture_device_infos) { 234 const media::VideoCaptureDeviceInfos& video_capture_device_infos) {
229 base::DictionaryValue video_devices_info_dictionary; 235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
236 video_capture_capabilities_cached_data_.Clear();
230 237
231 for (const auto& video_capture_device_info : video_capture_device_infos) { 238 for (const auto& video_capture_device_info : video_capture_device_infos) {
232 base::DictionaryValue* formats_dict = new base::DictionaryValue(); 239 base::ListValue* format_list = new base::ListValue();
233 formats_dict->SetString("Unique ID", video_capture_device_info.name.id()); 240 for (const auto& format : video_capture_device_info.supported_formats)
241 format_list->AppendString(format.ToString());
242
243 base::DictionaryValue* device_dict = new base::DictionaryValue();
244 device_dict->SetString("id", video_capture_device_info.name.id());
245 device_dict->SetString(
246 "name", video_capture_device_info.name.GetNameAndModel());
247 device_dict->Set("formats", format_list);
234 #if defined(OS_WIN) || defined(OS_MACOSX) 248 #if defined(OS_WIN) || defined(OS_MACOSX)
235 formats_dict->SetInteger("Capture API: #", 249 device_dict->SetInteger(
236 video_capture_device_info.name.capture_api_type()); 250 "captureApi",
251 video_capture_device_info.name.capture_api_type());
237 #endif 252 #endif
238 int count = 0; 253 video_capture_capabilities_cached_data_.Append(device_dict);
239 for (const auto& format : video_capture_device_info.supported_formats) {
240 formats_dict->SetString(base::StringPrintf("[%3d]", count++),
241 format.ToString());
242 }
243 video_devices_info_dictionary.Set(
244 video_capture_device_info.name.GetNameAndModel(), formats_dict);
245 } 254 }
246 // TODO(mcasas): Remove the following printout when sending the capabilities 255
247 // to JS is implemented in a similar way to how SendAudioStreamData() does. 256 if (update_callbacks_.size() > 0)
248 // A lock might be needed if these capabilities are cached at this point. 257 SendVideoCaptureDeviceCapabilities();
249 DVLOG(1) << "Received: " << video_devices_info_dictionary;
250 } 258 }
251 259
252 scoped_ptr<media::AudioLog> MediaInternals::CreateAudioLog( 260 scoped_ptr<media::AudioLog> MediaInternals::CreateAudioLog(
253 AudioComponent component) { 261 AudioComponent component) {
254 base::AutoLock auto_lock(lock_); 262 base::AutoLock auto_lock(lock_);
255 return scoped_ptr<media::AudioLog>(new AudioLogImpl( 263 return scoped_ptr<media::AudioLog>(new AudioLogImpl(
256 owner_ids_[component]++, component, this)); 264 owner_ids_[component]++, component, this));
257 } 265 }
258 266
259 void MediaInternals::SendUpdate(const base::string16& update) { 267 void MediaInternals::SendUpdate(const base::string16& update) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 const std::string& function, 300 const std::string& function,
293 const base::DictionaryValue* value) { 301 const base::DictionaryValue* value) {
294 SendUpdate(SerializeUpdate(function, value)); 302 SendUpdate(SerializeUpdate(function, value));
295 303
296 base::AutoLock auto_lock(lock_); 304 base::AutoLock auto_lock(lock_);
297 scoped_ptr<base::Value> out_value; 305 scoped_ptr<base::Value> out_value;
298 CHECK(audio_streams_cached_data_.Remove(cache_key, &out_value)); 306 CHECK(audio_streams_cached_data_.Remove(cache_key, &out_value));
299 } 307 }
300 308
301 } // namespace content 309 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/media/media_internals.h ('k') | content/browser/media/media_internals_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698