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..ba2fff42cf2c48f2e7ed5a04f4ea1a6cb760b0ba 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,45 @@ 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.onReceiveEverything", &audio_streams_cached_data_); |
|
wolenetz
2014/10/09 20:51:43
s/onReceiveEverything/onReceiveAudioStreamData/ he
mcasas
2014/10/10 11:30:41
Done.
|
| } |
| - SendUpdate(everything_update); |
| + SendUpdate(audio_stream_update); |
| +} |
| + |
| +void MediaInternals::UpdateVideoCaptureDeviceCapabilities( |
| + const media::VideoCaptureDeviceInfos& name_and_formats) { |
| + base::DictionaryValue video_devices_info_dictionary; |
| + |
| + for (const auto &name_and_format : name_and_formats) { |
|
wolenetz
2014/10/09 20:51:43
nit: here and below, s/auto &/auto& /
mcasas
2014/10/10 11:30:41
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) { |
|
wolenetz
2014/10/09 20:51:43
nit: ditto.
mcasas
2014/10/10 11:30:41
Done.
|
| + 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. |
|
wolenetz
2014/10/09 20:55:05
One other nit: you might want to note here that |l
mcasas
2014/10/10 11:30:41
Done. We don't need to use the same |lock_| though
|
| + 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 +269,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 +294,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 |