OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Low-latency audio capturing unit utilizing audio input stream provided | 5 // Low-latency audio capturing unit utilizing audio input stream provided |
6 // by browser process through IPC. | 6 // by browser process through IPC. |
7 // | 7 // |
8 // Relationship of classes: | 8 // Relationship of classes: |
9 // | 9 // |
10 // AudioInputController AudioInputDevice | 10 // AudioInputController AudioInputDevice |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 void InitializeOnIOThread(); | 163 void InitializeOnIOThread(); |
164 void SetSessionIdOnIOThread(int session_id); | 164 void SetSessionIdOnIOThread(int session_id); |
165 void StartOnIOThread(); | 165 void StartOnIOThread(); |
166 void ShutDownOnIOThread(base::WaitableEvent* completion); | 166 void ShutDownOnIOThread(base::WaitableEvent* completion); |
167 void SetVolumeOnIOThread(double volume); | 167 void SetVolumeOnIOThread(double volume); |
168 | 168 |
169 void Send(IPC::Message* message); | 169 void Send(IPC::Message* message); |
170 | 170 |
171 // Method called on the audio thread ---------------------------------------- | 171 // Method called on the audio thread ---------------------------------------- |
172 // Calls the client's callback for capturing audio. | 172 // Calls the client's callback for capturing audio. |
173 void FireCaptureCallback(); | 173 void FireCaptureCallback(int16* input_audio); |
174 | 174 |
175 // DelegateSimpleThread::Delegate implementation. | 175 // DelegateSimpleThread::Delegate implementation. |
176 virtual void Run() OVERRIDE; | 176 virtual void Run() OVERRIDE; |
177 | 177 |
178 // Format | 178 // Format |
179 AudioParameters audio_parameters_; | 179 AudioParameters audio_parameters_; |
180 | 180 |
181 CaptureCallback* callback_; | 181 CaptureCallback* callback_; |
182 CaptureEventHandler* event_handler_; | 182 CaptureEventHandler* event_handler_; |
183 | 183 |
184 // The client callback receives captured audio here. | 184 // The client callback receives captured audio here. |
185 std::vector<float*> audio_data_; | 185 std::vector<float*> audio_data_; |
186 | 186 |
187 // The client stores the last reported audio delay in this member. | 187 // The client stores the last reported audio delay in this member. |
188 // The delay shall reflect the amount of audio which still resides in | 188 // The delay shall reflect the amount of audio which still resides in |
189 // the input buffer, i.e., the expected audio input delay. | 189 // the input buffer, i.e., the expected audio input delay. |
190 int audio_delay_milliseconds_; | 190 int audio_delay_milliseconds_; |
191 | 191 |
192 // The current volume scaling [0.0, 1.0] of the audio stream. | 192 // The current volume scaling [0.0, 1.0] of the audio stream. |
193 double volume_; | 193 double volume_; |
194 | 194 |
195 // Callbacks for capturing audio occur on this thread. | 195 // Callbacks for capturing audio occur on this thread. |
196 scoped_ptr<base::DelegateSimpleThread> audio_thread_; | 196 scoped_ptr<base::DelegateSimpleThread> audio_thread_; |
197 | 197 |
198 // IPC message stuff. | |
199 base::SharedMemory* shared_memory() { return shared_memory_.get(); } | |
200 base::SyncSocket* socket() { return socket_.get(); } | |
201 void* shared_memory_data() { return shared_memory()->memory(); } | |
202 | |
203 // Cached audio input message filter (lives on the main render thread). | 198 // Cached audio input message filter (lives on the main render thread). |
204 scoped_refptr<AudioInputMessageFilter> filter_; | 199 scoped_refptr<AudioInputMessageFilter> filter_; |
205 | 200 |
206 // Our stream ID on the message filter. Only modified on the IO thread. | 201 // Our stream ID on the message filter. Only modified on the IO thread. |
207 int32 stream_id_; | 202 int32 stream_id_; |
208 | 203 |
209 // The media session ID used to identify which input device to be started. | 204 // The media session ID used to identify which input device to be started. |
210 // Only modified on the IO thread. | 205 // Only modified on the IO thread. |
211 int session_id_; | 206 int session_id_; |
212 | 207 |
213 // State variable used to indicate it is waiting for a OnDeviceReady() | 208 // State variable used to indicate it is waiting for a OnDeviceReady() |
214 // callback. Only modified on the IO thread. | 209 // callback. Only modified on the IO thread. |
215 bool pending_device_ready_; | 210 bool pending_device_ready_; |
216 | 211 |
217 scoped_ptr<base::SharedMemory> shared_memory_; | 212 base::SharedMemoryHandle shared_memory_handle_; |
218 scoped_ptr<base::SyncSocket> socket_; | 213 base::SyncSocket::Handle socket_handle_; |
| 214 int memory_length_; |
219 | 215 |
220 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputDevice); | 216 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputDevice); |
221 }; | 217 }; |
222 | 218 |
223 #endif // CONTENT_RENDERER_MEDIA_AUDIO_INPUT_DEVICE_H_ | 219 #endif // CONTENT_RENDERER_MEDIA_AUDIO_INPUT_DEVICE_H_ |
OLD | NEW |