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

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 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/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::SendVideoCaptureCapabilities() {
228 base::string16 video_capture_capabilities_update;
229 {
230 base::AutoLock auto_lock(lock_);
231 video_capture_capabilities_update = SerializeUpdate(
232 "media.onReceiveVideoCaptureCapabilities",
233 &video_capture_capabilities_cached_data_);
234 }
235 SendUpdate(video_capture_capabilities_update);
236 }
237
227 void MediaInternals::UpdateVideoCaptureDeviceCapabilities( 238 void MediaInternals::UpdateVideoCaptureDeviceCapabilities(
228 const media::VideoCaptureDeviceInfos& video_capture_device_infos) { 239 const media::VideoCaptureDeviceInfos& video_capture_device_infos) {
perkj_chrome 2014/10/15 15:05:16 isn't this on io too. In that case- add DCHECKS fo
burnik 2014/10/15 15:43:13 Done.
229 base::DictionaryValue video_devices_info_dictionary;
230 240
231 for (const auto& video_capture_device_info : video_capture_device_infos) { 241 {
232 base::DictionaryValue* formats_dict = new base::DictionaryValue(); 242 base::AutoLock auto_lock(lock_);
perkj_chrome 2014/10/15 15:05:16 why is a lock needed? What thread is this and what
burnik 2014/10/15 15:43:13 You're right. I forgot the fact that both device e
233 formats_dict->SetString("Unique ID", video_capture_device_info.name.id()); 243 video_capture_capabilities_cached_data_.Clear();
244
245 for (const auto& video_capture_device_info : video_capture_device_infos) {
246 base::ListValue* format_list = new base::ListValue();
247 for (const auto& format : video_capture_device_info.supported_formats)
248 format_list->AppendString(format.ToString());
249
250 base::DictionaryValue* device_dict = new base::DictionaryValue();
251 device_dict->SetString("id", video_capture_device_info.name.id());
252 device_dict->SetString(
253 "name", video_capture_device_info.name.GetNameAndModel());
254 device_dict->Set("formats", format_list);
234 #if defined(OS_WIN) || defined(OS_MACOSX) 255 #if defined(OS_WIN) || defined(OS_MACOSX)
235 formats_dict->SetInteger("Capture API: #", 256 device_dict->SetInteger(
236 video_capture_device_info.name.capture_api_type()); 257 "captureApi",
258 video_capture_device_info.name.capture_api_type());
237 #endif 259 #endif
238 int count = 0; 260 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 } 261 }
243 video_devices_info_dictionary.Set(
244 video_capture_device_info.name.GetNameAndModel(), formats_dict);
245 } 262 }
246 // TODO(mcasas): Remove the following printout when sending the capabilities 263
247 // to JS is implemented in a similar way to how SendAudioStreamData() does. 264 SendVideoCaptureCapabilities();
248 // A lock might be needed if these capabilities are cached at this point.
249 DVLOG(1) << "Received: " << video_devices_info_dictionary;
250 } 265 }
251 266
252 scoped_ptr<media::AudioLog> MediaInternals::CreateAudioLog( 267 scoped_ptr<media::AudioLog> MediaInternals::CreateAudioLog(
253 AudioComponent component) { 268 AudioComponent component) {
254 base::AutoLock auto_lock(lock_); 269 base::AutoLock auto_lock(lock_);
255 return scoped_ptr<media::AudioLog>(new AudioLogImpl( 270 return scoped_ptr<media::AudioLog>(new AudioLogImpl(
256 owner_ids_[component]++, component, this)); 271 owner_ids_[component]++, component, this));
257 } 272 }
258 273
259 void MediaInternals::SendUpdate(const base::string16& update) { 274 void MediaInternals::SendUpdate(const base::string16& update) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 const std::string& function, 307 const std::string& function,
293 const base::DictionaryValue* value) { 308 const base::DictionaryValue* value) {
294 SendUpdate(SerializeUpdate(function, value)); 309 SendUpdate(SerializeUpdate(function, value));
295 310
296 base::AutoLock auto_lock(lock_); 311 base::AutoLock auto_lock(lock_);
297 scoped_ptr<base::Value> out_value; 312 scoped_ptr<base::Value> out_value;
298 CHECK(audio_streams_cached_data_.Remove(cache_key, &out_value)); 313 CHECK(audio_streams_cached_data_.Remove(cache_key, &out_value));
299 } 314 }
300 315
301 } // namespace content 316 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698