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 29 matching lines...) Expand all Loading... |
118 // Sequence of events is that we query the list of sinks on the | 105 // Sequence of events is that we query the list of sinks on the |
119 // AudioManager's thread, then calculate HMACs on the IO thread, | 106 // AudioManager's thread, then calculate HMACs on the IO thread, |
120 // then finish on the UI thread. | 107 // then finish on the UI thread. |
121 bool RunAsync() override; | 108 bool RunAsync() override; |
122 void DoQuery(); | 109 void DoQuery(); |
123 void OnOutputDeviceDescriptions( | 110 void OnOutputDeviceDescriptions( |
124 std::unique_ptr<media::AudioDeviceDescriptions> raw_ids) override; | 111 std::unique_ptr<media::AudioDeviceDescriptions> raw_ids) override; |
125 void DoneOnUIThread(); | 112 void DoneOnUIThread(); |
126 }; | 113 }; |
127 | 114 |
128 class WebrtcAudioPrivateGetActiveSinkFunction | |
129 : public WebrtcAudioPrivateFunction { | |
130 protected: | |
131 ~WebrtcAudioPrivateGetActiveSinkFunction() override {} | |
132 | |
133 private: | |
134 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.getActiveSink", | |
135 WEBRTC_AUDIO_PRIVATE_GET_ACTIVE_SINK); | |
136 | |
137 bool RunAsync() override; | |
138 void OnControllerList( | |
139 const content::RenderProcessHost::AudioOutputControllerList& controllers) | |
140 override; | |
141 void OnHMACCalculated(const std::string& hmac) override; | |
142 }; | |
143 | |
144 class WebrtcAudioPrivateSetActiveSinkFunction | |
145 : public WebrtcAudioPrivateFunction { | |
146 public: | |
147 WebrtcAudioPrivateSetActiveSinkFunction(); | |
148 | |
149 protected: | |
150 ~WebrtcAudioPrivateSetActiveSinkFunction() override; | |
151 | |
152 private: | |
153 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.setActiveSink", | |
154 WEBRTC_AUDIO_PRIVATE_SET_ACTIVE_SINK); | |
155 | |
156 bool RunAsync() override; | |
157 void OnControllerList( | |
158 const content::RenderProcessHost::AudioOutputControllerList& controllers) | |
159 override; | |
160 void OnOutputDeviceDescriptions( | |
161 std::unique_ptr<media::AudioDeviceDescriptions> device_descriptions) | |
162 override; | |
163 void SwitchDone(); | |
164 void DoneOnUIThread(); | |
165 | |
166 api::webrtc_audio_private::RequestInfo request_info_; | |
167 std::string sink_id_; | |
168 | |
169 // Filled in by OnControllerList. | |
170 content::RenderProcessHost::AudioOutputControllerList controllers_; | |
171 | |
172 // Number of sink IDs we are still waiting for. Can become greater | |
173 // than 0 in OnControllerList, decreases on every OnSinkId call. | |
174 size_t num_remaining_sink_ids_; | |
175 }; | |
176 | |
177 class WebrtcAudioPrivateGetAssociatedSinkFunction | 115 class WebrtcAudioPrivateGetAssociatedSinkFunction |
178 : public WebrtcAudioPrivateFunction { | 116 : public WebrtcAudioPrivateFunction { |
179 public: | 117 public: |
180 WebrtcAudioPrivateGetAssociatedSinkFunction(); | 118 WebrtcAudioPrivateGetAssociatedSinkFunction(); |
181 | 119 |
182 protected: | 120 protected: |
183 ~WebrtcAudioPrivateGetAssociatedSinkFunction() override; | 121 ~WebrtcAudioPrivateGetAssociatedSinkFunction() override; |
184 | 122 |
185 private: | 123 private: |
186 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.getAssociatedSink", | 124 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.getAssociatedSink", |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 // time, no locking needed. | 161 // time, no locking needed. |
224 std::unique_ptr<api::webrtc_audio_private::GetAssociatedSink::Params> params_; | 162 std::unique_ptr<api::webrtc_audio_private::GetAssociatedSink::Params> params_; |
225 | 163 |
226 // Audio sources (input devices). Filled in by DoWorkOnDeviceThread. | 164 // Audio sources (input devices). Filled in by DoWorkOnDeviceThread. |
227 media::AudioDeviceDescriptions source_devices_; | 165 media::AudioDeviceDescriptions source_devices_; |
228 }; | 166 }; |
229 | 167 |
230 } // namespace extensions | 168 } // namespace extensions |
231 | 169 |
232 #endif // CHROME_BROWSER_EXTENSIONS_API_WEBRTC_AUDIO_PRIVATE_WEBRTC_AUDIO_PRIVA
TE_API_H_ | 170 #endif // CHROME_BROWSER_EXTENSIONS_API_WEBRTC_AUDIO_PRIVATE_WEBRTC_AUDIO_PRIVA
TE_API_H_ |
OLD | NEW |