Chromium Code Reviews| 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 }; | 203 }; |
| 204 | 204 |
| 205 class WebRtcAudioCapturerSink { | 205 class WebRtcAudioCapturerSink { |
| 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. | |
| 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 | |
| 216 // audio processing. | |
| 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. | |
| 219 virtual int CaptureData(const std::vector<int>& channels, | 213 virtual int CaptureData(const std::vector<int>& channels, |
|
Henrik Grunell
2013/10/31 11:56:12
Why remove the description of some input parameter
| |
| 220 const int16* audio_data, | 214 const int16* audio_data, |
| 221 int sample_rate, | 215 int sample_rate, |
| 222 int number_of_channels, | 216 int number_of_channels, |
| 223 int number_of_frames, | 217 int number_of_frames, |
| 224 int audio_delay_milliseconds, | 218 int audio_delay_milliseconds, |
| 225 int current_volume, | 219 int current_volume, |
| 226 bool need_audio_processing, | 220 bool need_audio_processing, |
| 227 bool key_pressed) = 0; | 221 bool key_pressed) = 0; |
| 228 | 222 |
| 229 // Set the format for the capture audio parameters. | 223 // Set the format for the capture audio parameters. |
| 230 virtual void SetCaptureFormat(const media::AudioParameters& params) = 0; | 224 virtual void SetCaptureFormat(const media::AudioParameters& params) = 0; |
| 231 | 225 |
| 232 protected: | 226 protected: |
| 233 virtual ~WebRtcAudioCapturerSink() {} | 227 virtual ~WebRtcAudioCapturerSink() {} |
| 234 }; | 228 }; |
| 235 | 229 |
| 230 class WebRtcAudioRenderDataObserver { | |
|
Henrik Grunell
2013/10/31 11:56:12
Add comment. See also next comment.
| |
| 231 public: | |
| 232 // Callback to get the mixed rendered data. | |
| 233 virtual void OnRenderData(const int16* render_audio, | |
| 234 int sample_rate, | |
| 235 int number_of_channels, | |
| 236 int number_of_frames, | |
| 237 int render_delay_ms) = 0; | |
| 238 | |
| 239 // Callback to notify the observer the webrtc render object is closing. | |
| 240 virtual void OnRenderClosing() = 0; | |
| 241 | |
| 242 protected: | |
| 243 virtual ~WebRtcAudioRenderDataObserver() {} | |
| 244 }; | |
| 245 | |
| 236 // Note that this class inherits from webrtc::AudioDeviceModule but due to | 246 // Note that this class inherits from webrtc::AudioDeviceModule but due to |
| 237 // the high number of non-implemented methods, we move the cruft over to the | 247 // the high number of non-implemented methods, we move the cruft over to the |
| 238 // WebRtcAudioDeviceNotImpl. | 248 // WebRtcAudioDeviceNotImpl. |
| 239 class CONTENT_EXPORT WebRtcAudioDeviceImpl | 249 class CONTENT_EXPORT WebRtcAudioDeviceImpl |
| 240 : NON_EXPORTED_BASE(public WebRtcAudioDeviceNotImpl), | 250 : NON_EXPORTED_BASE(public WebRtcAudioDeviceNotImpl), |
| 241 NON_EXPORTED_BASE(public WebRtcAudioCapturerSink), | 251 NON_EXPORTED_BASE(public WebRtcAudioCapturerSink), |
| 242 NON_EXPORTED_BASE(public WebRtcAudioRendererSource) { | 252 NON_EXPORTED_BASE(public WebRtcAudioRendererSource) { |
| 243 public: | 253 public: |
| 244 // The maximum volume value WebRtc uses. | 254 // The maximum volume value WebRtc uses. |
| 245 static const int kMaxVolumeLevel = 255; | 255 static const int kMaxVolumeLevel = 255; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 virtual int32_t RecordingSampleRate(uint32_t* samples_per_sec) const OVERRIDE; | 308 virtual int32_t RecordingSampleRate(uint32_t* samples_per_sec) const OVERRIDE; |
| 299 virtual int32_t PlayoutSampleRate(uint32_t* samples_per_sec) const OVERRIDE; | 309 virtual int32_t PlayoutSampleRate(uint32_t* samples_per_sec) const OVERRIDE; |
| 300 | 310 |
| 301 // Sets the |renderer_|, returns false if |renderer_| already exists. | 311 // Sets the |renderer_|, returns false if |renderer_| already exists. |
| 302 // Called on the main renderer thread. | 312 // Called on the main renderer thread. |
| 303 bool SetAudioRenderer(WebRtcAudioRenderer* renderer); | 313 bool SetAudioRenderer(WebRtcAudioRenderer* renderer); |
| 304 | 314 |
| 305 // Adds the capturer to the ADM. | 315 // Adds the capturer to the ADM. |
| 306 void AddAudioCapturer(const scoped_refptr<WebRtcAudioCapturer>& capturer); | 316 void AddAudioCapturer(const scoped_refptr<WebRtcAudioCapturer>& capturer); |
| 307 | 317 |
| 318 // Add/Remove the observer to get the mixed render data for AEC. | |
|
Henrik Grunell
2013/10/31 11:56:12
I think the description "to get the mixed render d
| |
| 319 void AddRenderDataObserver(WebRtcAudioRenderDataObserver* observer); | |
| 320 void RemoveRenderDataObserver(WebRtcAudioRenderDataObserver* observer); | |
| 321 | |
| 308 // Gets the default capturer, which is the capturer in the list with | 322 // Gets the default capturer, which is the capturer in the list with |
| 309 // a valid |device_id|. Microphones are represented by capturers with a valid | 323 // a valid |device_id|. Microphones are represented by capturers with a valid |
| 310 // |device_id|, since only one microphone is supported today, only one | 324 // |device_id|, since only one microphone is supported today, only one |
| 311 // capturer in the |capturers_| can have a valid |device_id|. | 325 // capturer in the |capturers_| can have a valid |device_id|. |
| 312 scoped_refptr<WebRtcAudioCapturer> GetDefaultCapturer() const; | 326 scoped_refptr<WebRtcAudioCapturer> GetDefaultCapturer() const; |
| 313 | 327 |
| 314 const scoped_refptr<WebRtcAudioRenderer>& renderer() const { | 328 const scoped_refptr<WebRtcAudioRenderer>& renderer() const { |
| 315 return renderer_; | 329 return renderer_; |
| 316 } | 330 } |
| 317 int output_buffer_size() const { | 331 int output_buffer_size() const { |
| 318 return output_audio_parameters_.frames_per_buffer(); | 332 return output_audio_parameters_.frames_per_buffer(); |
| 319 } | 333 } |
| 320 int output_channels() const { | 334 int output_channels() const { |
| 321 return output_audio_parameters_.channels(); | 335 return output_audio_parameters_.channels(); |
| 322 } | 336 } |
| 323 int output_sample_rate() const { | 337 int output_sample_rate() const { |
| 324 return output_audio_parameters_.sample_rate(); | 338 return output_audio_parameters_.sample_rate(); |
| 325 } | 339 } |
| 326 | 340 |
| 327 private: | 341 private: |
| 328 typedef std::list<scoped_refptr<WebRtcAudioCapturer> > CapturerList; | 342 typedef std::list<scoped_refptr<WebRtcAudioCapturer> > CapturerList; |
| 343 typedef std::list<WebRtcAudioRenderDataObserver* > RenderDataObservers; | |
| 329 | 344 |
| 330 // Make destructor private to ensure that we can only be deleted by Release(). | 345 // Make destructor private to ensure that we can only be deleted by Release(). |
| 331 virtual ~WebRtcAudioDeviceImpl(); | 346 virtual ~WebRtcAudioDeviceImpl(); |
| 332 | 347 |
| 333 // WebRtcAudioCapturerSink implementation. | 348 // WebRtcAudioCapturerSink implementation. |
| 334 | 349 |
| 335 // Called on the AudioInputDevice worker thread. | 350 // Called on the AudioInputDevice worker thread. |
| 336 virtual int CaptureData(const std::vector<int>& channels, | 351 virtual int CaptureData(const std::vector<int>& channels, |
| 337 const int16* audio_data, | 352 const int16* audio_data, |
| 338 int sample_rate, | 353 int sample_rate, |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 363 | 378 |
| 364 int ref_count_; | 379 int ref_count_; |
| 365 | 380 |
| 366 // List of captures which provides access to the native audio input layer | 381 // List of captures which provides access to the native audio input layer |
| 367 // in the browser process. | 382 // in the browser process. |
| 368 CapturerList capturers_; | 383 CapturerList capturers_; |
| 369 | 384 |
| 370 // Provides access to the audio renderer in the browser process. | 385 // Provides access to the audio renderer in the browser process. |
| 371 scoped_refptr<WebRtcAudioRenderer> renderer_; | 386 scoped_refptr<WebRtcAudioRenderer> renderer_; |
| 372 | 387 |
| 388 RenderDataObservers render_data_observers_; | |
| 389 | |
| 373 // Weak reference to the audio callback. | 390 // Weak reference to the audio callback. |
| 374 // The webrtc client defines |audio_transport_callback_| by calling | 391 // The webrtc client defines |audio_transport_callback_| by calling |
| 375 // RegisterAudioCallback(). | 392 // RegisterAudioCallback(). |
| 376 webrtc::AudioTransport* audio_transport_callback_; | 393 webrtc::AudioTransport* audio_transport_callback_; |
| 377 | 394 |
| 378 // Cached values of used output audio parameters. Platform dependent. | 395 // Cached values of used output audio parameters. Platform dependent. |
| 379 media::AudioParameters output_audio_parameters_; | 396 media::AudioParameters output_audio_parameters_; |
| 380 | 397 |
| 381 // Cached value of the current audio delay on the input/capture side. | 398 // Cached value of the current audio delay on the input/capture side. |
| 382 int input_delay_ms_; | 399 int input_delay_ms_; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 402 // Stores latest microphone volume received in a CaptureData() callback. | 419 // Stores latest microphone volume received in a CaptureData() callback. |
| 403 // Range is [0, 255]. | 420 // Range is [0, 255]. |
| 404 uint32_t microphone_volume_; | 421 uint32_t microphone_volume_; |
| 405 | 422 |
| 406 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioDeviceImpl); | 423 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioDeviceImpl); |
| 407 }; | 424 }; |
| 408 | 425 |
| 409 } // namespace content | 426 } // namespace content |
| 410 | 427 |
| 411 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_ | 428 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_ |
| OLD | NEW |