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

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: 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) {
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_);
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);
255
234 #if defined(OS_WIN) || defined(OS_MACOSX) 256 #if defined(OS_WIN) || defined(OS_MACOSX)
235 formats_dict->SetInteger("Capture API: #", 257 // TODO(burnik): Capture API should be a name/description.
236 video_capture_device_info.name.capture_api_type()); 258 device_dict->SetInteger(
259 "captureApi",
260 video_capture_device_info.name.capture_api_type());
237 #endif 261 #endif
238 int count = 0; 262
239 for (const auto& format : video_capture_device_info.supported_formats) { 263 video_capture_capabilities_cached_data_.Append(device_dict);
240 formats_dict->SetString(base::StringPrintf("[%3d]", count++), 264
241 format.ToString());
242 } 265 }
243 video_devices_info_dictionary.Set( 266
244 video_capture_device_info.name.GetNameAndModel(), formats_dict); 267 }
245 }
246 // TODO(mcasas): Remove the following printout when sending the capabilities 268 // TODO(mcasas): Remove the following printout when sending the capabilities
mcasas 2014/10/14 13:44:11 Remove TODO /rewrite comment
burnik 2014/10/15 13:45:57 Done.
247 // to JS is implemented in a similar way to how SendAudioStreamData() does. 269 // to JS is implemented in a similar way to how SendAudioStreamData() does.
248 // A lock might be needed if these capabilities are cached at this point. 270 // A lock might be needed if these capabilities are cached at this point.
249 DVLOG(1) << "Received: " << video_devices_info_dictionary; 271 DVLOG(1) << "Received: " << video_capture_capabilities_cached_data_;
272 SendVideoCaptureCapabilities();
250 } 273 }
251 274
275
mcasas 2014/10/14 13:44:11 Remove empty line.
burnik 2014/10/15 13:45:57 Done.
252 scoped_ptr<media::AudioLog> MediaInternals::CreateAudioLog( 276 scoped_ptr<media::AudioLog> MediaInternals::CreateAudioLog(
253 AudioComponent component) { 277 AudioComponent component) {
254 base::AutoLock auto_lock(lock_); 278 base::AutoLock auto_lock(lock_);
255 return scoped_ptr<media::AudioLog>(new AudioLogImpl( 279 return scoped_ptr<media::AudioLog>(new AudioLogImpl(
256 owner_ids_[component]++, component, this)); 280 owner_ids_[component]++, component, this));
257 } 281 }
258 282
259 void MediaInternals::SendUpdate(const base::string16& update) { 283 void MediaInternals::SendUpdate(const base::string16& update) {
260 // SendUpdate() may be called from any thread, but must run on the IO thread. 284 // SendUpdate() may be called from any thread, but must run on the IO thread.
261 // TODO(dalecurtis): This is pretty silly since the update callbacks simply 285 // TODO(dalecurtis): This is pretty silly since the update callbacks simply
(...skipping 30 matching lines...) Expand all
292 const std::string& function, 316 const std::string& function,
293 const base::DictionaryValue* value) { 317 const base::DictionaryValue* value) {
294 SendUpdate(SerializeUpdate(function, value)); 318 SendUpdate(SerializeUpdate(function, value));
295 319
296 base::AutoLock auto_lock(lock_); 320 base::AutoLock auto_lock(lock_);
297 scoped_ptr<base::Value> out_value; 321 scoped_ptr<base::Value> out_value;
298 CHECK(audio_streams_cached_data_.Remove(cache_key, &out_value)); 322 CHECK(audio_streams_cached_data_.Remove(cache_key, &out_value));
299 } 323 }
300 324
301 } // namespace content 325 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698