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 <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 protected: | 56 protected: |
57 // Retrieves the list of output device descriptions 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 GetOutputDeviceDescriptions(); | 59 void GetOutputDeviceDescriptions(); |
60 | 60 |
61 // Must override this if you call GetOutputDeviceDescriptions. Called on IO | 61 // Must override this if you call GetOutputDeviceDescriptions. Called on IO |
62 // thread. | 62 // thread. |
63 virtual void OnOutputDeviceDescriptions( | 63 virtual void OnOutputDeviceDescriptions( |
64 std::unique_ptr<media::AudioDeviceDescriptions> device_descriptions); | 64 std::unique_ptr<media::AudioDeviceDescriptions> device_descriptions); |
65 | 65 |
66 // Retrieve the list of AudioOutputController objects. Calls back | |
67 // via OnControllerList. | |
68 // | |
69 // Returns false on error, in which case it has set |error_| and the | |
70 // entire function should fail. | |
71 // | |
72 // Call from any thread. Callback will occur on originating thread. | |
73 bool GetControllerList(const api::webrtc_audio_private::RequestInfo& request); | |
74 | |
75 // Must override this if you call GetControllerList. | |
76 virtual void OnControllerList( | |
77 const content::RenderProcessHost::AudioOutputControllerList& list); | |
78 | |
79 // Calculates a single HMAC. Call from any thread. Calls back via | 66 // Calculates a single HMAC. Call from any thread. Calls back via |
80 // OnHMACCalculated on UI thread. | 67 // OnHMACCalculated on UI thread. |
81 // | 68 // |
82 // This function, and device ID HMACs in this API in general use the | 69 // This function, and device ID HMACs in this API in general use the |
83 // calling extension's ID as the security origin. The only exception | 70 // calling extension's ID as the security origin. The only exception |
84 // to this rule is when calculating the input device ID HMAC in | 71 // to this rule is when calculating the input device ID HMAC in |
85 // getAssociatedSink, where we use the provided |securityOrigin|. | 72 // getAssociatedSink, where we use the provided |securityOrigin|. |
86 void CalculateHMAC(const std::string& raw_id); | 73 void CalculateHMAC(const std::string& raw_id); |
87 | 74 |
88 // Must override this if you call CalculateHMAC. | 75 // Must override this if you call CalculateHMAC. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 // Sequence of events is that we query the list of sinks on the | 112 // Sequence of events is that we query the list of sinks on the |
126 // AudioManager's thread, then calculate HMACs on the IO thread, | 113 // AudioManager's thread, then calculate HMACs on the IO thread, |
127 // then finish on the UI thread. | 114 // then finish on the UI thread. |
128 bool RunAsync() override; | 115 bool RunAsync() override; |
129 void DoQuery(); | 116 void DoQuery(); |
130 void OnOutputDeviceDescriptions( | 117 void OnOutputDeviceDescriptions( |
131 std::unique_ptr<media::AudioDeviceDescriptions> raw_ids) override; | 118 std::unique_ptr<media::AudioDeviceDescriptions> raw_ids) override; |
132 void DoneOnUIThread(); | 119 void DoneOnUIThread(); |
133 }; | 120 }; |
134 | 121 |
135 class WebrtcAudioPrivateGetActiveSinkFunction | |
136 : public WebrtcAudioPrivateFunction { | |
137 protected: | |
138 ~WebrtcAudioPrivateGetActiveSinkFunction() override {} | |
139 | |
140 private: | |
141 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.getActiveSink", | |
142 WEBRTC_AUDIO_PRIVATE_GET_ACTIVE_SINK); | |
143 | |
144 bool RunAsync() override; | |
145 void OnControllerList( | |
146 const content::RenderProcessHost::AudioOutputControllerList& controllers) | |
147 override; | |
148 void OnHMACCalculated(const std::string& hmac) override; | |
149 }; | |
150 | |
151 class WebrtcAudioPrivateSetActiveSinkFunction | |
152 : public WebrtcAudioPrivateFunction { | |
153 public: | |
154 WebrtcAudioPrivateSetActiveSinkFunction(); | |
155 | |
156 protected: | |
157 ~WebrtcAudioPrivateSetActiveSinkFunction() override; | |
158 | |
159 private: | |
160 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.setActiveSink", | |
161 WEBRTC_AUDIO_PRIVATE_SET_ACTIVE_SINK); | |
162 | |
163 bool RunAsync() override; | |
164 void OnControllerList( | |
165 const content::RenderProcessHost::AudioOutputControllerList& controllers) | |
166 override; | |
167 void OnOutputDeviceDescriptions( | |
168 std::unique_ptr<media::AudioDeviceDescriptions> device_descriptions) | |
169 override; | |
170 void SwitchDone(); | |
171 void DoneOnUIThread(); | |
172 | |
173 api::webrtc_audio_private::RequestInfo request_info_; | |
174 std::string sink_id_; | |
175 | |
176 // Filled in by OnControllerList. | |
177 content::RenderProcessHost::AudioOutputControllerList controllers_; | |
178 | |
179 // Number of sink IDs we are still waiting for. Can become greater | |
180 // than 0 in OnControllerList, decreases on every OnSinkId call. | |
181 size_t num_remaining_sink_ids_; | |
182 }; | |
183 | |
184 class WebrtcAudioPrivateGetAssociatedSinkFunction | 122 class WebrtcAudioPrivateGetAssociatedSinkFunction |
185 : public WebrtcAudioPrivateFunction { | 123 : public WebrtcAudioPrivateFunction { |
186 public: | 124 public: |
187 WebrtcAudioPrivateGetAssociatedSinkFunction(); | 125 WebrtcAudioPrivateGetAssociatedSinkFunction(); |
188 | 126 |
189 protected: | 127 protected: |
190 ~WebrtcAudioPrivateGetAssociatedSinkFunction() override; | 128 ~WebrtcAudioPrivateGetAssociatedSinkFunction() override; |
191 | 129 |
192 private: | 130 private: |
193 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.getAssociatedSink", | 131 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.getAssociatedSink", |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 private: | 183 private: |
246 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.setAudioExperiments", | 184 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.setAudioExperiments", |
247 WEBRTC_AUDIO_PRIVATE_SET_AUDIO_EXPERIMENTS); | 185 WEBRTC_AUDIO_PRIVATE_SET_AUDIO_EXPERIMENTS); |
248 | 186 |
249 bool RunAsync() override; | 187 bool RunAsync() override; |
250 }; | 188 }; |
251 | 189 |
252 } // namespace extensions | 190 } // namespace extensions |
253 | 191 |
254 #endif // CHROME_BROWSER_EXTENSIONS_API_WEBRTC_AUDIO_PRIVATE_WEBRTC_AUDIO_PRIVA
TE_API_H_ | 192 #endif // CHROME_BROWSER_EXTENSIONS_API_WEBRTC_AUDIO_PRIVATE_WEBRTC_AUDIO_PRIVA
TE_API_H_ |
OLD | NEW |