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 CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_ |
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_ | 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 // Set the format for the capture audio parameters. | 195 // Set the format for the capture audio parameters. |
196 virtual void SetRenderFormat(const media::AudioParameters& params) = 0; | 196 virtual void SetRenderFormat(const media::AudioParameters& params) = 0; |
197 | 197 |
198 // Callback to notify the client that the renderer is going away. | 198 // Callback to notify the client that the renderer is going away. |
199 virtual void RemoveAudioRenderer(WebRtcAudioRenderer* renderer) = 0; | 199 virtual void RemoveAudioRenderer(WebRtcAudioRenderer* renderer) = 0; |
200 | 200 |
201 protected: | 201 protected: |
202 virtual ~WebRtcAudioRendererSource() {} | 202 virtual ~WebRtcAudioRendererSource() {} |
203 }; | 203 }; |
204 | 204 |
205 class WebRtcAudioCapturerSink { | 205 class PeerConnectionAudioSink { |
206 public: | 206 public: |
207 // Callback to deliver the captured interleaved data. | 207 // Callback to deliver the captured interleaved data. |
208 // |channels| contains a vector of WebRtc VoE channels. | 208 // |channels| contains a vector of WebRtc VoE channels. |
209 // |audio_data| is the pointer to the audio data. | 209 // |audio_data| is the pointer to the audio data. |
210 // |sample_rate| is the sample frequency of audio data. | 210 // |sample_rate| is the sample frequency of audio data. |
211 // |number_of_channels| is the number of channels reflecting the order of | 211 // |number_of_channels| is the number of channels reflecting the order of |
212 // surround sound channels. | 212 // surround sound channels. |
213 // |audio_delay_milliseconds| is recording delay value. | 213 // |audio_delay_milliseconds| is recording delay value. |
214 // |current_volume| is current microphone volume, in range of |0, 255]. | 214 // |current_volume| is current microphone volume, in range of |0, 255]. |
215 // |need_audio_processing| indicates if the audio needs WebRtc AEC/NS/AGC | 215 // |need_audio_processing| indicates if the audio needs WebRtc AEC/NS/AGC |
216 // audio processing. | 216 // audio processing. |
217 // The return value is the new microphone volume, in the range of |0, 255]. | 217 // The return value is the new microphone volume, in the range of |0, 255]. |
218 // When the volume does not need to be updated, it returns 0. | 218 // When the volume does not need to be updated, it returns 0. |
219 virtual int CaptureData(const std::vector<int>& channels, | 219 virtual int OnData(const int16* audio_data, |
220 const int16* audio_data, | 220 int sample_rate, |
221 int sample_rate, | 221 int number_of_channels, |
222 int number_of_channels, | 222 int number_of_frames, |
223 int number_of_frames, | 223 const std::vector<int>& channels, |
224 int audio_delay_milliseconds, | 224 int audio_delay_milliseconds, |
225 int current_volume, | 225 int current_volume, |
226 bool need_audio_processing, | 226 bool need_audio_processing, |
227 bool key_pressed) = 0; | 227 bool key_pressed) = 0; |
228 | 228 |
229 // Set the format for the capture audio parameters. | 229 // Set the format for the capture audio parameters. |
230 // This is called when the capture format has changed, and it must be called | 230 // This is called when the capture format has changed, and it must be called |
231 // on the same thread as calling CaptureData(). | 231 // on the same thread as calling CaptureData(). |
232 virtual void SetCaptureFormat(const media::AudioParameters& params) = 0; | 232 virtual void OnSetFormat(const media::AudioParameters& params) = 0; |
233 | 233 |
234 protected: | 234 protected: |
235 virtual ~WebRtcAudioCapturerSink() {} | 235 virtual ~PeerConnectionAudioSink() {} |
236 }; | 236 }; |
237 | 237 |
238 // Note that this class inherits from webrtc::AudioDeviceModule but due to | 238 // Note that this class inherits from webrtc::AudioDeviceModule but due to |
239 // the high number of non-implemented methods, we move the cruft over to the | 239 // the high number of non-implemented methods, we move the cruft over to the |
240 // WebRtcAudioDeviceNotImpl. | 240 // WebRtcAudioDeviceNotImpl. |
241 class CONTENT_EXPORT WebRtcAudioDeviceImpl | 241 class CONTENT_EXPORT WebRtcAudioDeviceImpl |
242 : NON_EXPORTED_BASE(public WebRtcAudioDeviceNotImpl), | 242 : NON_EXPORTED_BASE(public PeerConnectionAudioSink), |
243 NON_EXPORTED_BASE(public WebRtcAudioCapturerSink), | 243 NON_EXPORTED_BASE(public WebRtcAudioDeviceNotImpl), |
244 NON_EXPORTED_BASE(public WebRtcAudioRendererSource) { | 244 NON_EXPORTED_BASE(public WebRtcAudioRendererSource) { |
245 public: | 245 public: |
246 // The maximum volume value WebRtc uses. | 246 // The maximum volume value WebRtc uses. |
247 static const int kMaxVolumeLevel = 255; | 247 static const int kMaxVolumeLevel = 255; |
248 | 248 |
249 // Instances of this object are created on the main render thread. | 249 // Instances of this object are created on the main render thread. |
250 WebRtcAudioDeviceImpl(); | 250 WebRtcAudioDeviceImpl(); |
251 | 251 |
252 // webrtc::RefCountedModule implementation. | 252 // webrtc::RefCountedModule implementation. |
253 // The creator must call AddRef() after construction and use Release() | 253 // The creator must call AddRef() after construction and use Release() |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 int output_sample_rate() const { | 320 int output_sample_rate() const { |
321 return output_audio_parameters_.sample_rate(); | 321 return output_audio_parameters_.sample_rate(); |
322 } | 322 } |
323 | 323 |
324 private: | 324 private: |
325 typedef std::list<scoped_refptr<WebRtcAudioCapturer> > CapturerList; | 325 typedef std::list<scoped_refptr<WebRtcAudioCapturer> > CapturerList; |
326 | 326 |
327 // Make destructor private to ensure that we can only be deleted by Release(). | 327 // Make destructor private to ensure that we can only be deleted by Release(). |
328 virtual ~WebRtcAudioDeviceImpl(); | 328 virtual ~WebRtcAudioDeviceImpl(); |
329 | 329 |
330 // WebRtcAudioCapturerSink implementation. | 330 // PeerConnectionAudioSink implementation. |
331 | 331 |
332 // Called on the AudioInputDevice worker thread. | 332 // Called on the AudioInputDevice worker thread. |
333 virtual int CaptureData(const std::vector<int>& channels, | 333 virtual int OnData(const int16* audio_data, |
334 const int16* audio_data, | 334 int sample_rate, |
335 int sample_rate, | 335 int number_of_channels, |
336 int number_of_channels, | 336 int number_of_frames, |
337 int number_of_frames, | 337 const std::vector<int>& channels, |
338 int audio_delay_milliseconds, | 338 int audio_delay_milliseconds, |
339 int current_volume, | 339 int current_volume, |
340 bool need_audio_processing, | 340 bool need_audio_processing, |
341 bool key_pressed) OVERRIDE; | 341 bool key_pressed) OVERRIDE; |
342 | 342 |
343 // Called on the main render thread. | 343 // Called on the AudioInputDevice worker thread. |
344 virtual void SetCaptureFormat(const media::AudioParameters& params) OVERRIDE; | 344 virtual void OnSetFormat(const media::AudioParameters& params) OVERRIDE; |
345 | 345 |
346 // WebRtcAudioRendererSource implementation. | 346 // WebRtcAudioRendererSource implementation. |
347 | 347 |
348 // Called on the AudioInputDevice worker thread. | 348 // Called on the AudioInputDevice worker thread. |
349 virtual void RenderData(uint8* audio_data, | 349 virtual void RenderData(uint8* audio_data, |
350 int number_of_channels, | 350 int number_of_channels, |
351 int number_of_frames, | 351 int number_of_frames, |
352 int audio_delay_milliseconds) OVERRIDE; | 352 int audio_delay_milliseconds) OVERRIDE; |
353 | 353 |
354 // Called on the main render thread. | 354 // Called on the main render thread. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 // Stores latest microphone volume received in a CaptureData() callback. | 396 // Stores latest microphone volume received in a CaptureData() callback. |
397 // Range is [0, 255]. | 397 // Range is [0, 255]. |
398 uint32_t microphone_volume_; | 398 uint32_t microphone_volume_; |
399 | 399 |
400 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioDeviceImpl); | 400 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioDeviceImpl); |
401 }; | 401 }; |
402 | 402 |
403 } // namespace content | 403 } // namespace content |
404 | 404 |
405 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_ | 405 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_ |
OLD | NEW |