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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/media/media_internals.cc
diff --git a/content/browser/media/media_internals.cc b/content/browser/media/media_internals.cc
index 7d6c78a40b59ae764a8da9051223fdac5678763d..2f4bc63da498cce489aaf8887e761cf1593a0747 100644
--- a/content/browser/media/media_internals.cc
+++ b/content/browser/media/media_internals.cc
@@ -224,29 +224,44 @@ void MediaInternals::SendAudioStreamData() {
SendUpdate(audio_stream_update);
}
+void MediaInternals::SendVideoCaptureCapabilities() {
+ base::string16 video_capture_capabilities_update;
+ {
+ base::AutoLock auto_lock(lock_);
+ video_capture_capabilities_update = SerializeUpdate(
+ "media.onReceiveVideoCaptureCapabilities",
+ &video_capture_capabilities_cached_data_);
+ }
+ SendUpdate(video_capture_capabilities_update);
+}
+
void MediaInternals::UpdateVideoCaptureDeviceCapabilities(
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.
- base::DictionaryValue video_devices_info_dictionary;
- for (const auto& video_capture_device_info : video_capture_device_infos) {
- base::DictionaryValue* formats_dict = new base::DictionaryValue();
- formats_dict->SetString("Unique ID", video_capture_device_info.name.id());
+ {
+ 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
+ video_capture_capabilities_cached_data_.Clear();
+
+ for (const auto& video_capture_device_info : video_capture_device_infos) {
+ base::ListValue* format_list = new base::ListValue();
+ for (const auto& format : video_capture_device_info.supported_formats)
+ format_list->AppendString(format.ToString());
+
+ base::DictionaryValue* device_dict = new base::DictionaryValue();
+ device_dict->SetString("id", video_capture_device_info.name.id());
+ device_dict->SetString(
+ "name", video_capture_device_info.name.GetNameAndModel());
+ device_dict->Set("formats", format_list);
#if defined(OS_WIN) || defined(OS_MACOSX)
- formats_dict->SetInteger("Capture API: #",
- video_capture_device_info.name.capture_api_type());
+ device_dict->SetInteger(
+ "captureApi",
+ video_capture_device_info.name.capture_api_type());
#endif
- int count = 0;
- for (const auto& format : video_capture_device_info.supported_formats) {
- formats_dict->SetString(base::StringPrintf("[%3d]", count++),
- format.ToString());
+ video_capture_capabilities_cached_data_.Append(device_dict);
}
- video_devices_info_dictionary.Set(
- video_capture_device_info.name.GetNameAndModel(), formats_dict);
}
- // TODO(mcasas): Remove the following printout when sending the capabilities
- // to JS is implemented in a similar way to how SendAudioStreamData() does.
- // A lock might be needed if these capabilities are cached at this point.
- DVLOG(1) << "Received: " << video_devices_info_dictionary;
+
+ SendVideoCaptureCapabilities();
}
scoped_ptr<media::AudioLog> MediaInternals::CreateAudioLog(

Powered by Google App Engine
This is Rietveld 408576698