OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "content/browser/renderer_host/media/media_stream_manager.h" |
16 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
17 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
18 #include "content/public/browser/notification_types.h" | 19 #include "content/public/browser/notification_types.h" |
19 #include "content/public/browser/render_frame_host.h" | 20 #include "content/public/browser/render_frame_host.h" |
20 #include "content/public/browser/render_process_host.h" | 21 #include "content/public/browser/render_process_host.h" |
21 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
22 #include "content/public/browser/web_ui.h" | 23 #include "content/public/browser/web_ui.h" |
23 #include "media/base/audio_parameters.h" | 24 #include "media/base/audio_parameters.h" |
24 #include "media/base/media_log_event.h" | 25 #include "media/base/media_log_event.h" |
25 #include "media/filters/gpu_video_decoder.h" | 26 #include "media/filters/gpu_video_decoder.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 void OnCreated(int component_id, | 104 void OnCreated(int component_id, |
104 const media::AudioParameters& params, | 105 const media::AudioParameters& params, |
105 const std::string& device_id) override; | 106 const std::string& device_id) override; |
106 void OnStarted(int component_id) override; | 107 void OnStarted(int component_id) override; |
107 void OnStopped(int component_id) override; | 108 void OnStopped(int component_id) override; |
108 void OnClosed(int component_id) override; | 109 void OnClosed(int component_id) override; |
109 void OnError(int component_id) override; | 110 void OnError(int component_id) override; |
110 void OnSetVolume(int component_id, double volume) override; | 111 void OnSetVolume(int component_id, double volume) override; |
111 void OnSwitchOutputDevice(int component_id, | 112 void OnSwitchOutputDevice(int component_id, |
112 const std::string& device_id) override; | 113 const std::string& device_id) override; |
| 114 void OnLogMessage(int component_id, const std::string& message) override; |
113 | 115 |
114 // Called by MediaInternals to update the WebContents title for a stream. | 116 // Called by MediaInternals to update the WebContents title for a stream. |
115 void SendWebContentsTitle(int component_id, | 117 void SendWebContentsTitle(int component_id, |
116 int render_process_id, | 118 int render_process_id, |
117 int render_frame_id); | 119 int render_frame_id); |
118 | 120 |
119 private: | 121 private: |
120 void SendSingleStringUpdate(int component_id, | 122 void SendSingleStringUpdate(int component_id, |
121 const std::string& key, | 123 const std::string& key, |
122 const std::string& value); | 124 const std::string& value); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 void AudioLogImpl::OnSwitchOutputDevice(int component_id, | 201 void AudioLogImpl::OnSwitchOutputDevice(int component_id, |
200 const std::string& device_id) { | 202 const std::string& device_id) { |
201 base::DictionaryValue dict; | 203 base::DictionaryValue dict; |
202 StoreComponentMetadata(component_id, &dict); | 204 StoreComponentMetadata(component_id, &dict); |
203 dict.SetString("device_id", device_id); | 205 dict.SetString("device_id", device_id); |
204 media_internals_->UpdateAudioLog(MediaInternals::UPDATE_IF_EXISTS, | 206 media_internals_->UpdateAudioLog(MediaInternals::UPDATE_IF_EXISTS, |
205 FormatCacheKey(component_id), | 207 FormatCacheKey(component_id), |
206 kAudioLogUpdateFunction, &dict); | 208 kAudioLogUpdateFunction, &dict); |
207 } | 209 } |
208 | 210 |
| 211 void AudioLogImpl::OnLogMessage(int component_id, const std::string& message) { |
| 212 MediaStreamManager::SendMessageToNativeLog(message); |
| 213 } |
| 214 |
209 void AudioLogImpl::SendWebContentsTitle(int component_id, | 215 void AudioLogImpl::SendWebContentsTitle(int component_id, |
210 int render_process_id, | 216 int render_process_id, |
211 int render_frame_id) { | 217 int render_frame_id) { |
212 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 218 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
213 StoreComponentMetadata(component_id, dict.get()); | 219 StoreComponentMetadata(component_id, dict.get()); |
214 SendWebContentsTitleHelper(FormatCacheKey(component_id), std::move(dict), | 220 SendWebContentsTitleHelper(FormatCacheKey(component_id), std::move(dict), |
215 render_process_id, render_frame_id); | 221 render_process_id, render_frame_id); |
216 } | 222 } |
217 | 223 |
218 std::string AudioLogImpl::FormatCacheKey(int component_id) { | 224 std::string AudioLogImpl::FormatCacheKey(int component_id) { |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 audio_streams_cached_data_.GetDictionary(cache_key, &existing_dict)); | 698 audio_streams_cached_data_.GetDictionary(cache_key, &existing_dict)); |
693 existing_dict->MergeDictionary(value); | 699 existing_dict->MergeDictionary(value); |
694 } | 700 } |
695 } | 701 } |
696 | 702 |
697 if (CanUpdate()) | 703 if (CanUpdate()) |
698 SendUpdate(SerializeUpdate(function, value)); | 704 SendUpdate(SerializeUpdate(function, value)); |
699 } | 705 } |
700 | 706 |
701 } // namespace content | 707 } // namespace content |
OLD | NEW |