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

Side by Side Diff: content/browser/media/media_internals.cc

Issue 1122393004: Add support for switching the audio output device for HTMLMediaElements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes to MediaPlayers so that they invoke callbacks in the correct threads. First complete implem… Created 5 years, 6 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/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 ~AudioLogImpl() override; 97 ~AudioLogImpl() override;
98 98
99 void OnCreated(int component_id, 99 void OnCreated(int component_id,
100 const media::AudioParameters& params, 100 const media::AudioParameters& params,
101 const std::string& device_id) override; 101 const std::string& device_id) override;
102 void OnStarted(int component_id) override; 102 void OnStarted(int component_id) override;
103 void OnStopped(int component_id) override; 103 void OnStopped(int component_id) override;
104 void OnClosed(int component_id) override; 104 void OnClosed(int component_id) override;
105 void OnError(int component_id) override; 105 void OnError(int component_id) override;
106 void OnSetVolume(int component_id, double volume) override; 106 void OnSetVolume(int component_id, double volume) override;
107 void OnSwitchOutputDevice(int component_id,
108 const std::string& device_id) override;
107 109
108 // Called by MediaInternals to update the WebContents title for a stream. 110 // Called by MediaInternals to update the WebContents title for a stream.
109 void SendWebContentsTitle(int component_id, 111 void SendWebContentsTitle(int component_id,
110 int render_process_id, 112 int render_process_id,
111 int render_frame_id); 113 int render_frame_id);
112 114
113 private: 115 private:
114 void SendSingleStringUpdate(int component_id, 116 void SendSingleStringUpdate(int component_id,
115 const std::string& key, 117 const std::string& key,
116 const std::string& value); 118 const std::string& value);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 184
183 void AudioLogImpl::OnSetVolume(int component_id, double volume) { 185 void AudioLogImpl::OnSetVolume(int component_id, double volume) {
184 base::DictionaryValue dict; 186 base::DictionaryValue dict;
185 StoreComponentMetadata(component_id, &dict); 187 StoreComponentMetadata(component_id, &dict);
186 dict.SetDouble("volume", volume); 188 dict.SetDouble("volume", volume);
187 media_internals_->SendAudioLogUpdate(MediaInternals::UPDATE_IF_EXISTS, 189 media_internals_->SendAudioLogUpdate(MediaInternals::UPDATE_IF_EXISTS,
188 FormatCacheKey(component_id), 190 FormatCacheKey(component_id),
189 kAudioLogUpdateFunction, &dict); 191 kAudioLogUpdateFunction, &dict);
190 } 192 }
191 193
194 void AudioLogImpl::OnSwitchOutputDevice(int component_id,
195 const std::string& device_id) {
196 base::DictionaryValue dict;
197 StoreComponentMetadata(component_id, &dict);
198 dict.SetString("device_id", device_id);
199 media_internals_->SendAudioLogUpdate(MediaInternals::UPDATE_IF_EXISTS,
200 FormatCacheKey(component_id),
201 kAudioLogUpdateFunction, &dict);
202 }
203
192 void AudioLogImpl::SendWebContentsTitle(int component_id, 204 void AudioLogImpl::SendWebContentsTitle(int component_id,
193 int render_process_id, 205 int render_process_id,
194 int render_frame_id) { 206 int render_frame_id) {
195 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 207 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
196 StoreComponentMetadata(component_id, dict.get()); 208 StoreComponentMetadata(component_id, dict.get());
197 SendWebContentsTitleHelper(FormatCacheKey(component_id), dict.Pass(), 209 SendWebContentsTitleHelper(FormatCacheKey(component_id), dict.Pass(),
198 render_process_id, render_frame_id); 210 render_process_id, render_frame_id);
199 } 211 }
200 212
201 std::string AudioLogImpl::FormatCacheKey(int component_id) { 213 std::string AudioLogImpl::FormatCacheKey(int component_id) {
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 CHECK( 619 CHECK(
608 audio_streams_cached_data_.GetDictionary(cache_key, &existing_dict)); 620 audio_streams_cached_data_.GetDictionary(cache_key, &existing_dict));
609 existing_dict->MergeDictionary(value); 621 existing_dict->MergeDictionary(value);
610 } 622 }
611 } 623 }
612 624
613 SendUpdate(SerializeUpdate(function, value)); 625 SendUpdate(SerializeUpdate(function, value));
614 } 626 }
615 627
616 } // namespace content 628 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698