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 "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 #include "content/public/browser/web_ui.h" | 10 #include "content/public/browser/web_ui.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 class AudioLogImpl : public media::AudioLog { | 33 class AudioLogImpl : public media::AudioLog { |
34 public: | 34 public: |
35 AudioLogImpl(int owner_id, | 35 AudioLogImpl(int owner_id, |
36 media::AudioLogFactory::AudioComponent component, | 36 media::AudioLogFactory::AudioComponent component, |
37 content::MediaInternals* media_internals); | 37 content::MediaInternals* media_internals); |
38 virtual ~AudioLogImpl(); | 38 virtual ~AudioLogImpl(); |
39 | 39 |
40 virtual void OnCreated(int component_id, | 40 virtual void OnCreated(int component_id, |
41 const media::AudioParameters& params, | 41 const media::AudioParameters& params, |
42 const std::string& input_device_id, | 42 const std::string& device_id) OVERRIDE; |
43 const std::string& output_device_id) OVERRIDE; | |
44 virtual void OnStarted(int component_id) OVERRIDE; | 43 virtual void OnStarted(int component_id) OVERRIDE; |
45 virtual void OnStopped(int component_id) OVERRIDE; | 44 virtual void OnStopped(int component_id) OVERRIDE; |
46 virtual void OnClosed(int component_id) OVERRIDE; | 45 virtual void OnClosed(int component_id) OVERRIDE; |
47 virtual void OnError(int component_id) OVERRIDE; | 46 virtual void OnError(int component_id) OVERRIDE; |
48 virtual void OnSetVolume(int component_id, double volume) OVERRIDE; | 47 virtual void OnSetVolume(int component_id, double volume) OVERRIDE; |
49 | 48 |
50 private: | 49 private: |
51 void SendSingleStringUpdate(int component_id, | 50 void SendSingleStringUpdate(int component_id, |
52 const std::string& key, | 51 const std::string& key, |
53 const std::string& value); | 52 const std::string& value); |
(...skipping 11 matching lines...) Expand all Loading... |
65 media::AudioLogFactory::AudioComponent component, | 64 media::AudioLogFactory::AudioComponent component, |
66 content::MediaInternals* media_internals) | 65 content::MediaInternals* media_internals) |
67 : owner_id_(owner_id), | 66 : owner_id_(owner_id), |
68 component_(component), | 67 component_(component), |
69 media_internals_(media_internals) {} | 68 media_internals_(media_internals) {} |
70 | 69 |
71 AudioLogImpl::~AudioLogImpl() {} | 70 AudioLogImpl::~AudioLogImpl() {} |
72 | 71 |
73 void AudioLogImpl::OnCreated(int component_id, | 72 void AudioLogImpl::OnCreated(int component_id, |
74 const media::AudioParameters& params, | 73 const media::AudioParameters& params, |
75 const std::string& input_device_id, | 74 const std::string& device_id) { |
76 const std::string& output_device_id) { | |
77 base::DictionaryValue dict; | 75 base::DictionaryValue dict; |
78 StoreComponentMetadata(component_id, &dict); | 76 StoreComponentMetadata(component_id, &dict); |
79 | 77 |
80 dict.SetString(kAudioLogStatusKey, "created"); | 78 dict.SetString(kAudioLogStatusKey, "created"); |
81 dict.SetString("input_device_id", input_device_id); | 79 dict.SetString("device_id", device_id); |
82 dict.SetInteger("input_channels", params.input_channels()); | 80 dict.SetInteger("input_channels", params.input_channels()); |
83 dict.SetInteger("frames_per_buffer", params.frames_per_buffer()); | 81 dict.SetInteger("frames_per_buffer", params.frames_per_buffer()); |
84 dict.SetInteger("sample_rate", params.sample_rate()); | 82 dict.SetInteger("sample_rate", params.sample_rate()); |
85 dict.SetString("output_device_id", output_device_id); | |
86 dict.SetInteger("channels", params.channels()); | 83 dict.SetInteger("channels", params.channels()); |
87 dict.SetString("channel_layout", | 84 dict.SetString("channel_layout", |
88 ChannelLayoutToString(params.channel_layout())); | 85 ChannelLayoutToString(params.channel_layout())); |
89 | 86 |
90 media_internals_->SendUpdateAndCache( | 87 media_internals_->SendUpdateAndCache( |
91 FormatCacheKey(component_id), kAudioLogUpdateFunction, &dict); | 88 FormatCacheKey(component_id), kAudioLogUpdateFunction, &dict); |
92 } | 89 } |
93 | 90 |
94 void AudioLogImpl::OnStarted(int component_id) { | 91 void AudioLogImpl::OnStarted(int component_id) { |
95 SendSingleStringUpdate(component_id, kAudioLogStatusKey, "started"); | 92 SendSingleStringUpdate(component_id, kAudioLogStatusKey, "started"); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 const std::string& function, | 233 const std::string& function, |
237 const base::DictionaryValue* value) { | 234 const base::DictionaryValue* value) { |
238 SendUpdate(SerializeUpdate(function, value)); | 235 SendUpdate(SerializeUpdate(function, value)); |
239 | 236 |
240 base::AutoLock auto_lock(lock_); | 237 base::AutoLock auto_lock(lock_); |
241 scoped_ptr<base::Value> out_value; | 238 scoped_ptr<base::Value> out_value; |
242 CHECK(cached_data_.Remove(cache_key, &out_value)); | 239 CHECK(cached_data_.Remove(cache_key, &out_value)); |
243 } | 240 } |
244 | 241 |
245 } // namespace content | 242 } // namespace content |
OLD | NEW |