OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_WEBRTC_AUDIO_PRIVATE_WEBRTC_AUDIO_PRIVATE_
API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_WEBRTC_AUDIO_PRIVATE_WEBRTC_AUDIO_PRIVATE_
API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_WEBRTC_AUDIO_PRIVATE_WEBRTC_AUDIO_PRIVATE_
API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_WEBRTC_AUDIO_PRIVATE_WEBRTC_AUDIO_PRIVATE_
API_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/system_monitor/system_monitor.h" | 9 #include "base/system_monitor/system_monitor.h" |
10 #include "chrome/browser/extensions/chrome_extension_function.h" | 10 #include "chrome/browser/extensions/chrome_extension_function.h" |
11 #include "chrome/common/extensions/api/webrtc_audio_private.h" | 11 #include "chrome/common/extensions/api/webrtc_audio_private.h" |
12 #include "content/public/browser/render_view_host.h" | 12 #include "content/public/browser/render_process_host.h" |
13 #include "extensions/browser/browser_context_keyed_api_factory.h" | 13 #include "extensions/browser/browser_context_keyed_api_factory.h" |
14 #include "media/audio/audio_device_name.h" | 14 #include "media/audio/audio_device_name.h" |
15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 class ResourceContext; | 18 class ResourceContext; |
19 } | 19 } |
20 | 20 |
21 namespace extensions { | 21 namespace extensions { |
22 | 22 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 virtual void OnOutputDeviceNames( | 61 virtual void OnOutputDeviceNames( |
62 scoped_ptr<media::AudioDeviceNames> device_names); | 62 scoped_ptr<media::AudioDeviceNames> device_names); |
63 | 63 |
64 // Retrieve the list of AudioOutputController objects. Calls back | 64 // Retrieve the list of AudioOutputController objects. Calls back |
65 // via OnControllerList. | 65 // via OnControllerList. |
66 // | 66 // |
67 // Returns false on error, in which case it has set |error_| and the | 67 // Returns false on error, in which case it has set |error_| and the |
68 // entire function should fail. | 68 // entire function should fail. |
69 // | 69 // |
70 // Call from any thread. Callback will occur on originating thread. | 70 // Call from any thread. Callback will occur on originating thread. |
71 bool GetControllerList(int tab_id); | 71 bool GetControllerList(const api::webrtc_audio_private::RequestInfo& request); |
72 | 72 |
73 // Must override this if you call GetControllerList. | 73 // Must override this if you call GetControllerList. |
74 virtual void OnControllerList( | 74 virtual void OnControllerList( |
75 const content::RenderViewHost::AudioOutputControllerList& list); | 75 const content::RenderProcessHost::AudioOutputControllerList& list); |
76 | 76 |
77 // Calculates a single HMAC. Call from any thread. Calls back via | 77 // Calculates a single HMAC. Call from any thread. Calls back via |
78 // OnHMACCalculated on UI thread. | 78 // OnHMACCalculated on UI thread. |
79 // | 79 // |
80 // This function, and device ID HMACs in this API in general use the | 80 // This function, and device ID HMACs in this API in general use the |
81 // calling extension's ID as the security origin. The only exception | 81 // calling extension's ID as the security origin. The only exception |
82 // to this rule is when calculating the input device ID HMAC in | 82 // to this rule is when calculating the input device ID HMAC in |
83 // getAssociatedSink, where we use the provided |securityOrigin|. | 83 // getAssociatedSink, where we use the provided |securityOrigin|. |
84 void CalculateHMAC(const std::string& raw_id); | 84 void CalculateHMAC(const std::string& raw_id); |
85 | 85 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 : public WebrtcAudioPrivateFunction { | 127 : public WebrtcAudioPrivateFunction { |
128 protected: | 128 protected: |
129 ~WebrtcAudioPrivateGetActiveSinkFunction() override {} | 129 ~WebrtcAudioPrivateGetActiveSinkFunction() override {} |
130 | 130 |
131 private: | 131 private: |
132 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.getActiveSink", | 132 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.getActiveSink", |
133 WEBRTC_AUDIO_PRIVATE_GET_ACTIVE_SINK); | 133 WEBRTC_AUDIO_PRIVATE_GET_ACTIVE_SINK); |
134 | 134 |
135 bool RunAsync() override; | 135 bool RunAsync() override; |
136 void OnControllerList( | 136 void OnControllerList( |
137 const content::RenderViewHost::AudioOutputControllerList& controllers) | 137 const content::RenderProcessHost::AudioOutputControllerList& controllers) |
138 override; | 138 override; |
139 void OnHMACCalculated(const std::string& hmac) override; | 139 void OnHMACCalculated(const std::string& hmac) override; |
140 }; | 140 }; |
141 | 141 |
142 class WebrtcAudioPrivateSetActiveSinkFunction | 142 class WebrtcAudioPrivateSetActiveSinkFunction |
143 : public WebrtcAudioPrivateFunction { | 143 : public WebrtcAudioPrivateFunction { |
144 public: | 144 public: |
145 WebrtcAudioPrivateSetActiveSinkFunction(); | 145 WebrtcAudioPrivateSetActiveSinkFunction(); |
146 | 146 |
147 protected: | 147 protected: |
148 ~WebrtcAudioPrivateSetActiveSinkFunction() override; | 148 ~WebrtcAudioPrivateSetActiveSinkFunction() override; |
149 | 149 |
150 private: | 150 private: |
151 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.setActiveSink", | 151 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.setActiveSink", |
152 WEBRTC_AUDIO_PRIVATE_SET_ACTIVE_SINK); | 152 WEBRTC_AUDIO_PRIVATE_SET_ACTIVE_SINK); |
153 | 153 |
154 bool RunAsync() override; | 154 bool RunAsync() override; |
155 void OnControllerList( | 155 void OnControllerList( |
156 const content::RenderViewHost::AudioOutputControllerList& controllers) | 156 const content::RenderProcessHost::AudioOutputControllerList& controllers) |
157 override; | 157 override; |
158 void OnOutputDeviceNames( | 158 void OnOutputDeviceNames( |
159 scoped_ptr<media::AudioDeviceNames> device_names) override; | 159 scoped_ptr<media::AudioDeviceNames> device_names) override; |
160 void SwitchDone(); | 160 void SwitchDone(); |
161 void DoneOnUIThread(); | 161 void DoneOnUIThread(); |
162 | 162 |
163 int tab_id_; | 163 api::webrtc_audio_private::RequestInfo request_info_; |
164 std::string sink_id_; | 164 std::string sink_id_; |
165 | 165 |
166 // Filled in by OnControllerList. | 166 // Filled in by OnControllerList. |
167 content::RenderViewHost::AudioOutputControllerList controllers_; | 167 content::RenderProcessHost::AudioOutputControllerList controllers_; |
168 | 168 |
169 // Number of sink IDs we are still waiting for. Can become greater | 169 // Number of sink IDs we are still waiting for. Can become greater |
170 // than 0 in OnControllerList, decreases on every OnSinkId call. | 170 // than 0 in OnControllerList, decreases on every OnSinkId call. |
171 size_t num_remaining_sink_ids_; | 171 size_t num_remaining_sink_ids_; |
172 }; | 172 }; |
173 | 173 |
174 class WebrtcAudioPrivateGetAssociatedSinkFunction | 174 class WebrtcAudioPrivateGetAssociatedSinkFunction |
175 : public WebrtcAudioPrivateFunction { | 175 : public WebrtcAudioPrivateFunction { |
176 public: | 176 public: |
177 WebrtcAudioPrivateGetAssociatedSinkFunction(); | 177 WebrtcAudioPrivateGetAssociatedSinkFunction(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 // time, no locking needed. | 220 // time, no locking needed. |
221 scoped_ptr<api::webrtc_audio_private::GetAssociatedSink::Params> params_; | 221 scoped_ptr<api::webrtc_audio_private::GetAssociatedSink::Params> params_; |
222 | 222 |
223 // Audio sources (input devices). Filled in by DoWorkOnDeviceThread. | 223 // Audio sources (input devices). Filled in by DoWorkOnDeviceThread. |
224 media::AudioDeviceNames source_devices_; | 224 media::AudioDeviceNames source_devices_; |
225 }; | 225 }; |
226 | 226 |
227 } // namespace extensions | 227 } // namespace extensions |
228 | 228 |
229 #endif // CHROME_BROWSER_EXTENSIONS_API_WEBRTC_AUDIO_PRIVATE_WEBRTC_AUDIO_PRIVA
TE_API_H_ | 229 #endif // CHROME_BROWSER_EXTENSIONS_API_WEBRTC_AUDIO_PRIVATE_WEBRTC_AUDIO_PRIVA
TE_API_H_ |
OLD | NEW |