Chromium Code Reviews| Index: content/browser/media/media_internals.cc |
| diff --git a/content/browser/media/media_internals.cc b/content/browser/media/media_internals.cc |
| index 2a031c73eb01c4b5bca33ea69cbe7b9ff6470a52..3c9a41d9281d8d73c9812accbcf77a4d5ae9db65 100644 |
| --- a/content/browser/media/media_internals.cc |
| +++ b/content/browser/media/media_internals.cc |
| @@ -117,7 +117,7 @@ void AudioLogImpl::OnCreated(int component_id, |
| ChannelLayoutToString(params.channel_layout())); |
| dict.SetString("effects", EffectsToString(params.effects())); |
| - media_internals_->SendUpdateAndCache( |
| + media_internals_->SendUpdateAndCacheAudioStreamKey( |
| FormatCacheKey(component_id), kAudioLogUpdateFunction, &dict); |
| } |
| @@ -133,7 +133,7 @@ void AudioLogImpl::OnClosed(int component_id) { |
| base::DictionaryValue dict; |
| StoreComponentMetadata(component_id, &dict); |
| dict.SetString(kAudioLogStatusKey, "closed"); |
| - media_internals_->SendUpdateAndPurgeCache( |
| + media_internals_->SendUpdateAndPurgeAudioStreamCache( |
| FormatCacheKey(component_id), kAudioLogUpdateFunction, &dict); |
| } |
| @@ -145,7 +145,7 @@ void AudioLogImpl::OnSetVolume(int component_id, double volume) { |
| base::DictionaryValue dict; |
| StoreComponentMetadata(component_id, &dict); |
| dict.SetDouble("volume", volume); |
| - media_internals_->SendUpdateAndCache( |
| + media_internals_->SendUpdateAndCacheAudioStreamKey( |
| FormatCacheKey(component_id), kAudioLogUpdateFunction, &dict); |
| } |
| @@ -159,7 +159,7 @@ void AudioLogImpl::SendSingleStringUpdate(int component_id, |
| base::DictionaryValue dict; |
| StoreComponentMetadata(component_id, &dict); |
| dict.SetString(key, value); |
| - media_internals_->SendUpdateAndCache( |
| + media_internals_->SendUpdateAndCacheAudioStreamKey( |
| FormatCacheKey(component_id), kAudioLogUpdateFunction, &dict); |
| } |
| @@ -214,14 +214,46 @@ void MediaInternals::RemoveUpdateCallback(const UpdateCallback& callback) { |
| NOTREACHED(); |
| } |
| -void MediaInternals::SendEverything() { |
| - base::string16 everything_update; |
| +void MediaInternals::SendAudioStreamData() { |
| + base::string16 audio_stream_update; |
| { |
| base::AutoLock auto_lock(lock_); |
| - everything_update = SerializeUpdate( |
| - "media.onReceiveEverything", &cached_data_); |
| + audio_stream_update = SerializeUpdate( |
| + "media.onReceiveAudioStreamData", &audio_streams_cached_data_); |
| } |
| - SendUpdate(everything_update); |
| + SendUpdate(audio_stream_update); |
| +} |
| + |
| +void MediaInternals::UpdateVideoCaptureDeviceCapabilities( |
| + const media::VideoCaptureDeviceInfos& name_and_formats) { |
|
xhwang
2014/10/10 19:40:06
names_and_formats is ambiguous. It's really vector
mcasas
2014/10/11 21:12:37
Done.
|
| + base::DictionaryValue video_devices_info_dictionary; |
| + |
| + for (const auto& name_and_format : name_and_formats) { |
|
xhwang
2014/10/10 19:40:06
ditto, s/name_and_format/video_capture_device_info
mcasas
2014/10/11 21:12:37
Done.
|
| + base::DictionaryValue* formats_dict = new base::DictionaryValue(); |
| + formats_dict->SetString("Unique ID", name_and_format.name.id()); |
| +#if defined(OS_WIN) || defined(OS_MACOSX) |
| + formats_dict->SetInteger("Capture API: #", |
| + name_and_format.name.capture_api_type()); |
| +#endif |
| + int count = 0; |
| + for (const auto& format : name_and_format.supported_formats) { |
| + formats_dict->SetString(base::StringPrintf("[%3d]", count++), |
| + format.ToString()); |
| + } |
| + video_devices_info_dictionary.Set(name_and_format.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; |
| +} |
| + |
| +scoped_ptr<media::AudioLog> MediaInternals::CreateAudioLog( |
| + AudioComponent component) { |
| + base::AutoLock auto_lock(lock_); |
| + return scoped_ptr<media::AudioLog>(new AudioLogImpl( |
| + owner_ids_[component]++, component, this)); |
| } |
| void MediaInternals::SendUpdate(const base::string16& update) { |
| @@ -238,30 +270,24 @@ void MediaInternals::SendUpdate(const base::string16& update) { |
| update_callbacks_[i].Run(update); |
| } |
| -scoped_ptr<media::AudioLog> MediaInternals::CreateAudioLog( |
| - AudioComponent component) { |
| - base::AutoLock auto_lock(lock_); |
| - return scoped_ptr<media::AudioLog>(new AudioLogImpl( |
| - owner_ids_[component]++, component, this)); |
| -} |
| - |
| -void MediaInternals::SendUpdateAndCache(const std::string& cache_key, |
| - const std::string& function, |
| - const base::DictionaryValue* value) { |
| +void MediaInternals::SendUpdateAndCacheAudioStreamKey( |
| + const std::string& cache_key, |
| + const std::string& function, |
| + const base::DictionaryValue* value) { |
| SendUpdate(SerializeUpdate(function, value)); |
| base::AutoLock auto_lock(lock_); |
| - if (!cached_data_.HasKey(cache_key)) { |
| - cached_data_.Set(cache_key, value->DeepCopy()); |
| + if (!audio_streams_cached_data_.HasKey(cache_key)) { |
| + audio_streams_cached_data_.Set(cache_key, value->DeepCopy()); |
| return; |
| } |
| base::DictionaryValue* existing_dict = NULL; |
| - CHECK(cached_data_.GetDictionary(cache_key, &existing_dict)); |
| + CHECK(audio_streams_cached_data_.GetDictionary(cache_key, &existing_dict)); |
| existing_dict->MergeDictionary(value); |
| } |
| -void MediaInternals::SendUpdateAndPurgeCache( |
| +void MediaInternals::SendUpdateAndPurgeAudioStreamCache( |
| const std::string& cache_key, |
| const std::string& function, |
| const base::DictionaryValue* value) { |
| @@ -269,7 +295,7 @@ void MediaInternals::SendUpdateAndPurgeCache( |
| base::AutoLock auto_lock(lock_); |
| scoped_ptr<base::Value> out_value; |
| - CHECK(cached_data_.Remove(cache_key, &out_value)); |
| + CHECK(audio_streams_cached_data_.Remove(cache_key, &out_value)); |
| } |
| } // namespace content |