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

Side by Side Diff: chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_api.h

Issue 2563653002: Replace AudioManager::GetAudio*DeviceNames with AudioManager::GetAudio*DeviceDescriptions (Closed)
Patch Set: nit fixes Created 4 years 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/system_monitor/system_monitor.h" 14 #include "base/system_monitor/system_monitor.h"
15 #include "chrome/browser/extensions/chrome_extension_function.h" 15 #include "chrome/browser/extensions/chrome_extension_function.h"
16 #include "chrome/common/extensions/api/webrtc_audio_private.h" 16 #include "chrome/common/extensions/api/webrtc_audio_private.h"
17 #include "content/public/browser/render_process_host.h" 17 #include "content/public/browser/render_process_host.h"
18 #include "content/public/browser/resource_context.h" 18 #include "content/public/browser/resource_context.h"
19 #include "extensions/browser/browser_context_keyed_api_factory.h" 19 #include "extensions/browser/browser_context_keyed_api_factory.h"
20 #include "media/audio/audio_device_name.h" 20 #include "media/audio/audio_device_description.h"
21 21
22 namespace extensions { 22 namespace extensions {
23 23
24 // Listens for device changes and forwards as an extension event. 24 // Listens for device changes and forwards as an extension event.
25 class WebrtcAudioPrivateEventService 25 class WebrtcAudioPrivateEventService
26 : public BrowserContextKeyedAPI, 26 : public BrowserContextKeyedAPI,
27 public base::SystemMonitor::DevicesChangedObserver { 27 public base::SystemMonitor::DevicesChangedObserver {
28 public: 28 public:
29 explicit WebrtcAudioPrivateEventService(content::BrowserContext* context); 29 explicit WebrtcAudioPrivateEventService(content::BrowserContext* context);
30 ~WebrtcAudioPrivateEventService() override; 30 ~WebrtcAudioPrivateEventService() override;
(...skipping 16 matching lines...) Expand all
47 }; 47 };
48 48
49 // Common base for WebrtcAudioPrivate functions, that provides a 49 // Common base for WebrtcAudioPrivate functions, that provides a
50 // couple of optionally-used common implementations. 50 // couple of optionally-used common implementations.
51 class WebrtcAudioPrivateFunction : public ChromeAsyncExtensionFunction { 51 class WebrtcAudioPrivateFunction : public ChromeAsyncExtensionFunction {
52 protected: 52 protected:
53 WebrtcAudioPrivateFunction(); 53 WebrtcAudioPrivateFunction();
54 ~WebrtcAudioPrivateFunction() override; 54 ~WebrtcAudioPrivateFunction() override;
55 55
56 protected: 56 protected:
57 // Retrieves the list of output device names on the appropriate 57 // Retrieves the list of output device descriptions on the appropriate
58 // thread. Call from UI thread, callback will occur on IO thread. 58 // thread. Call from UI thread, callback will occur on IO thread.
59 void GetOutputDeviceNames(); 59 void GetOutputDeviceDescriptions();
60 60
61 // Must override this if you call GetOutputDeviceNames. Called on IO thread. 61 // Must override this if you call GetOutputDeviceDescriptions. Called on IO
62 virtual void OnOutputDeviceNames( 62 // thread.
63 std::unique_ptr<media::AudioDeviceNames> device_names); 63 virtual void OnOutputDeviceDescriptions(
64 std::unique_ptr<media::AudioDeviceDescriptions> device_descriptions);
64 65
65 // Retrieve the list of AudioOutputController objects. Calls back 66 // Retrieve the list of AudioOutputController objects. Calls back
66 // via OnControllerList. 67 // via OnControllerList.
67 // 68 //
68 // Returns false on error, in which case it has set |error_| and the 69 // Returns false on error, in which case it has set |error_| and the
69 // entire function should fail. 70 // entire function should fail.
70 // 71 //
71 // Call from any thread. Callback will occur on originating thread. 72 // Call from any thread. Callback will occur on originating thread.
72 bool GetControllerList(const api::webrtc_audio_private::RequestInfo& request); 73 bool GetControllerList(const api::webrtc_audio_private::RequestInfo& request);
73 74
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 113
113 private: 114 private:
114 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.getSinks", 115 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.getSinks",
115 WEBRTC_AUDIO_PRIVATE_GET_SINKS); 116 WEBRTC_AUDIO_PRIVATE_GET_SINKS);
116 117
117 // Sequence of events is that we query the list of sinks on the 118 // Sequence of events is that we query the list of sinks on the
118 // AudioManager's thread, then calculate HMACs on the IO thread, 119 // AudioManager's thread, then calculate HMACs on the IO thread,
119 // then finish on the UI thread. 120 // then finish on the UI thread.
120 bool RunAsync() override; 121 bool RunAsync() override;
121 void DoQuery(); 122 void DoQuery();
122 void OnOutputDeviceNames( 123 void OnOutputDeviceDescriptions(
123 std::unique_ptr<media::AudioDeviceNames> raw_ids) override; 124 std::unique_ptr<media::AudioDeviceDescriptions> raw_ids) override;
124 void DoneOnUIThread(); 125 void DoneOnUIThread();
125 }; 126 };
126 127
127 class WebrtcAudioPrivateGetActiveSinkFunction 128 class WebrtcAudioPrivateGetActiveSinkFunction
128 : public WebrtcAudioPrivateFunction { 129 : public WebrtcAudioPrivateFunction {
129 protected: 130 protected:
130 ~WebrtcAudioPrivateGetActiveSinkFunction() override {} 131 ~WebrtcAudioPrivateGetActiveSinkFunction() override {}
131 132
132 private: 133 private:
133 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.getActiveSink", 134 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.getActiveSink",
(...skipping 15 matching lines...) Expand all
149 ~WebrtcAudioPrivateSetActiveSinkFunction() override; 150 ~WebrtcAudioPrivateSetActiveSinkFunction() override;
150 151
151 private: 152 private:
152 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.setActiveSink", 153 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.setActiveSink",
153 WEBRTC_AUDIO_PRIVATE_SET_ACTIVE_SINK); 154 WEBRTC_AUDIO_PRIVATE_SET_ACTIVE_SINK);
154 155
155 bool RunAsync() override; 156 bool RunAsync() override;
156 void OnControllerList( 157 void OnControllerList(
157 const content::RenderProcessHost::AudioOutputControllerList& controllers) 158 const content::RenderProcessHost::AudioOutputControllerList& controllers)
158 override; 159 override;
159 void OnOutputDeviceNames( 160 void OnOutputDeviceDescriptions(
160 std::unique_ptr<media::AudioDeviceNames> device_names) override; 161 std::unique_ptr<media::AudioDeviceDescriptions> device_descriptions)
162 override;
161 void SwitchDone(); 163 void SwitchDone();
162 void DoneOnUIThread(); 164 void DoneOnUIThread();
163 165
164 api::webrtc_audio_private::RequestInfo request_info_; 166 api::webrtc_audio_private::RequestInfo request_info_;
165 std::string sink_id_; 167 std::string sink_id_;
166 168
167 // Filled in by OnControllerList. 169 // Filled in by OnControllerList.
168 content::RenderProcessHost::AudioOutputControllerList controllers_; 170 content::RenderProcessHost::AudioOutputControllerList controllers_;
169 171
170 // Number of sink IDs we are still waiting for. Can become greater 172 // Number of sink IDs we are still waiting for. Can become greater
(...skipping 26 matching lines...) Expand all
197 // 2. Given a source ID for an origin and that security origin, find 199 // 2. Given a source ID for an origin and that security origin, find
198 // the raw source ID. This needs to happen on the IO thread since 200 // the raw source ID. This needs to happen on the IO thread since
199 // we will be using the ResourceContext. 201 // we will be using the ResourceContext.
200 // 3. Given a raw source ID, get the raw associated sink ID on the 202 // 3. Given a raw source ID, get the raw associated sink ID on the
201 // device thread. 203 // device thread.
202 // 4. Given the raw associated sink ID, get its HMAC on the IO thread. 204 // 4. Given the raw associated sink ID, get its HMAC on the IO thread.
203 // 5. Respond with the HMAC of the associated sink ID on the UI thread. 205 // 5. Respond with the HMAC of the associated sink ID on the UI thread.
204 206
205 // Fills in |source_devices_|. Note that these are input devices, 207 // Fills in |source_devices_|. Note that these are input devices,
206 // not output devices, so don't use 208 // not output devices, so don't use
207 // |WebrtcAudioPrivateFunction::GetOutputDeviceNames|. 209 // |WebrtcAudioPrivateFunction::GetOutputDeviceDescriptions|.
208 void GetDevicesOnDeviceThread(); 210 void GetDevicesOnDeviceThread();
209 211
210 // Takes the parameters of the function, retrieves the raw source 212 // Takes the parameters of the function, retrieves the raw source
211 // device ID, or the empty string if none. 213 // device ID, or the empty string if none.
212 void GetRawSourceIDOnIOThread(); 214 void GetRawSourceIDOnIOThread();
213 215
214 // Gets the raw sink ID for a raw source ID. Sends it to |CalculateHMAC|. 216 // Gets the raw sink ID for a raw source ID. Sends it to |CalculateHMAC|.
215 void GetAssociatedSinkOnDeviceThread(const std::string& raw_source_id); 217 void GetAssociatedSinkOnDeviceThread(const std::string& raw_source_id);
216 218
217 // Receives the associated sink ID after its HMAC is calculated. 219 // Receives the associated sink ID after its HMAC is calculated.
218 void OnHMACCalculated(const std::string& hmac) override; 220 void OnHMACCalculated(const std::string& hmac) override;
219 221
220 // Accessed from UI thread and device thread, but only on one at a 222 // Accessed from UI thread and device thread, but only on one at a
221 // time, no locking needed. 223 // time, no locking needed.
222 std::unique_ptr<api::webrtc_audio_private::GetAssociatedSink::Params> params_; 224 std::unique_ptr<api::webrtc_audio_private::GetAssociatedSink::Params> params_;
223 225
224 // Audio sources (input devices). Filled in by DoWorkOnDeviceThread. 226 // Audio sources (input devices). Filled in by DoWorkOnDeviceThread.
225 media::AudioDeviceNames source_devices_; 227 media::AudioDeviceDescriptions source_devices_;
226 }; 228 };
227 229
228 } // namespace extensions 230 } // namespace extensions
229 231
230 #endif // CHROME_BROWSER_EXTENSIONS_API_WEBRTC_AUDIO_PRIVATE_WEBRTC_AUDIO_PRIVA TE_API_H_ 232 #endif // CHROME_BROWSER_EXTENSIONS_API_WEBRTC_AUDIO_PRIVATE_WEBRTC_AUDIO_PRIVA TE_API_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698