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