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 // AudioInputRendererHost serves audio related requests from audio capturer | 5 // AudioInputRendererHost serves audio related requests from audio capturer |
6 // which lives inside the render process and provide access to audio hardware. | 6 // which lives inside the render process and provide access to audio hardware. |
7 // | 7 // |
8 // OnCreateStream() request is only available in the low latency mode. It will | 8 // OnCreateStream() request is only available in the low latency mode. It will |
9 // creates a shared memory, a SyncWriter and a AudioInputController for the | 9 // creates a shared memory, a SyncWriter and a AudioInputController for the |
10 // input stream. | 10 // input stream. |
11 | 11 |
12 // OnCloseStream() will close the input stream. | 12 // OnCloseStream() will close the input stream. |
13 // | 13 // |
14 // Create stream sequence: | 14 // Create stream sequence: |
15 // | 15 // |
16 // OnCreateStream -> AudioInputController::CreateLowLatency() -> | 16 // OnCreateStream -> AudioInputController::CreateLowLatency() -> |
17 // DoCompleteCreation -> AudioInputMsg_NotifyLowLatencyStreamCreated | 17 // DoCompleteCreation -> AudioInputMsg_NotifyLowLatencyStreamCreated |
18 // | 18 // |
19 // Close stream sequence: | 19 // Close stream sequence: |
20 // OnCloseStream -> AudioInputController::Close | 20 // OnCloseStream -> AudioInputController::Close |
21 // | 21 // |
22 // For the OnStartDevice() request, AudioInputRendererHost starts the device | 22 // For the OnStartDevice() request, AudioInputRendererHost starts the device |
23 // referenced by the session id, and a OnDeviceStarted() callback with the | 23 // referenced by the session id, and an OnDeviceStarted() callback with the |
24 // index of the opened device will be received later. Then it will send a IPC | 24 // id of the opened device will be received later. Then it will send a |
25 // message to notify the renderer that the device is ready, so that renderer | 25 // IPC message to notify the renderer that the device is ready, so that |
26 // can continue with the OnCreateStream() request. | 26 // renderer can continue with the OnCreateStream() request. |
27 // | 27 // |
28 // OnDeviceStopped() is called when the user closes the device through | 28 // OnDeviceStopped() is called when the user closes the device through |
29 // AudioInputDeviceManager without calling Stop() before. What | 29 // AudioInputDeviceManager without calling Stop() before. What |
30 // AudioInputRenderHost::OnDeviceStopped() does is to send a IPC mesaage to | 30 // AudioInputRenderHost::OnDeviceStopped() does is to send a IPC mesaage to |
31 // notify the renderer in order to stop the stream. | 31 // notify the renderer in order to stop the stream. |
32 // | 32 // |
33 // Start device sequence: | 33 // Start device sequence: |
34 // | 34 // |
35 // OnStartDevice -> AudioInputDeviceManager::Start -> | 35 // OnStartDevice -> AudioInputDeviceManager::Start -> |
36 // AudioInputDeviceManagerEventHandler::OnDeviceStarted -> | 36 // AudioInputDeviceManagerEventHandler::OnDeviceStarted -> |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // AudioInputController::EventHandler implementation. | 115 // AudioInputController::EventHandler implementation. |
116 virtual void OnCreated(media::AudioInputController* controller) OVERRIDE; | 116 virtual void OnCreated(media::AudioInputController* controller) OVERRIDE; |
117 virtual void OnRecording(media::AudioInputController* controller) OVERRIDE; | 117 virtual void OnRecording(media::AudioInputController* controller) OVERRIDE; |
118 virtual void OnError(media::AudioInputController* controller, | 118 virtual void OnError(media::AudioInputController* controller, |
119 int error_code) OVERRIDE; | 119 int error_code) OVERRIDE; |
120 virtual void OnData(media::AudioInputController* controller, | 120 virtual void OnData(media::AudioInputController* controller, |
121 const uint8* data, | 121 const uint8* data, |
122 uint32 size) OVERRIDE; | 122 uint32 size) OVERRIDE; |
123 | 123 |
124 // media_stream::AudioInputDeviceManagerEventHandler implementation. | 124 // media_stream::AudioInputDeviceManagerEventHandler implementation. |
125 virtual void OnDeviceStarted(int session_id, int index) OVERRIDE; | 125 virtual void OnDeviceStarted(int session_id, const std::string& device_id); |
126 virtual void OnDeviceStopped(int session_id) OVERRIDE; | 126 virtual void OnDeviceStopped(int session_id); |
127 | 127 |
128 private: | 128 private: |
129 // TODO(henrika): extend test suite (compare AudioRenderHost) | 129 // TODO(henrika): extend test suite (compare AudioRenderHost) |
130 friend class content::BrowserThread; | 130 friend class content::BrowserThread; |
131 friend class DeleteTask<AudioInputRendererHost>; | 131 friend class DeleteTask<AudioInputRendererHost>; |
132 | 132 |
133 virtual ~AudioInputRendererHost(); | 133 virtual ~AudioInputRendererHost(); |
134 | 134 |
135 // Methods called on IO thread ---------------------------------------------- | 135 // Methods called on IO thread ---------------------------------------------- |
136 | 136 |
137 // Start the audio input device with the session id. If the device | 137 // Start the audio input device with the session id. If the device |
138 // starts successfully, it will trigger OnDeviceStarted() callback. | 138 // starts successfully, it will trigger OnDeviceStarted() callback. |
139 void OnStartDevice(int stream_id, int session_id); | 139 void OnStartDevice(int stream_id, int session_id); |
140 | 140 |
141 // Audio related IPC message handlers. | 141 // Audio related IPC message handlers. |
142 // Creates an audio input stream with the specified format. If this call is | 142 // Creates an audio input stream with the specified format. If this call is |
143 // successful this object would keep an internal entry of the stream for the | 143 // successful this object would keep an internal entry of the stream for the |
144 // required properties. | 144 // required properties. |
145 void OnCreateStream(int stream_id, | 145 void OnCreateStream(int stream_id, |
146 const AudioParameters& params, | 146 const AudioParameters& params, |
147 bool low_latency); | 147 bool low_latency, |
| 148 const std::string& device_id); |
148 | 149 |
149 // Record the audio input stream referenced by |stream_id|. | 150 // Record the audio input stream referenced by |stream_id|. |
150 void OnRecordStream(int stream_id); | 151 void OnRecordStream(int stream_id); |
151 | 152 |
152 // Close the audio stream referenced by |stream_id|. | 153 // Close the audio stream referenced by |stream_id|. |
153 void OnCloseStream(int stream_id); | 154 void OnCloseStream(int stream_id); |
154 | 155 |
155 // Set the volume of the audio stream referenced by |stream_id|. | 156 // Set the volume of the audio stream referenced by |stream_id|. |
156 void OnSetVolume(int stream_id, double volume); | 157 void OnSetVolume(int stream_id, double volume); |
157 | 158 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 AudioEntryMap audio_entries_; | 213 AudioEntryMap audio_entries_; |
213 | 214 |
214 // A map of session IDs to audio session sources. | 215 // A map of session IDs to audio session sources. |
215 typedef std::map<int, int> SessionEntryMap; | 216 typedef std::map<int, int> SessionEntryMap; |
216 SessionEntryMap session_entries_; | 217 SessionEntryMap session_entries_; |
217 | 218 |
218 DISALLOW_COPY_AND_ASSIGN(AudioInputRendererHost); | 219 DISALLOW_COPY_AND_ASSIGN(AudioInputRendererHost); |
219 }; | 220 }; |
220 | 221 |
221 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_RENDERER_HOST_H_ | 222 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_RENDERER_HOST_H_ |
OLD | NEW |