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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 virtual int32_t StereoRecordingIsAvailable(bool* available) const OVERRIDE; | 292 virtual int32_t StereoRecordingIsAvailable(bool* available) const OVERRIDE; |
293 virtual int32_t PlayoutDelay(uint16_t* delay_ms) const OVERRIDE; | 293 virtual int32_t PlayoutDelay(uint16_t* delay_ms) const OVERRIDE; |
294 virtual int32_t RecordingDelay(uint16_t* delay_ms) const OVERRIDE; | 294 virtual int32_t RecordingDelay(uint16_t* delay_ms) const OVERRIDE; |
295 virtual int32_t RecordingSampleRate(uint32_t* samples_per_sec) const OVERRIDE; | 295 virtual int32_t RecordingSampleRate(uint32_t* samples_per_sec) const OVERRIDE; |
296 virtual int32_t PlayoutSampleRate(uint32_t* samples_per_sec) const OVERRIDE; | 296 virtual int32_t PlayoutSampleRate(uint32_t* samples_per_sec) const OVERRIDE; |
297 | 297 |
298 // Sets the |renderer_|, returns false if |renderer_| already exists. | 298 // Sets the |renderer_|, returns false if |renderer_| already exists. |
299 // Called on the main renderer thread. | 299 // Called on the main renderer thread. |
300 bool SetAudioRenderer(WebRtcAudioRenderer* renderer); | 300 bool SetAudioRenderer(WebRtcAudioRenderer* renderer); |
301 | 301 |
302 // Adds the capturer to the ADM. | 302 // Adds/Removes the capturer to the ADM. |
| 303 // TODO(xians): Remove these two methods once the ADM does not need to pass |
| 304 // hardware information up to WebRtc. |
303 void AddAudioCapturer(const scoped_refptr<WebRtcAudioCapturer>& capturer); | 305 void AddAudioCapturer(const scoped_refptr<WebRtcAudioCapturer>& capturer); |
| 306 void RemoveAudioCapturer(const scoped_refptr<WebRtcAudioCapturer>& capturer); |
304 | 307 |
305 // Gets the default capturer, which is the capturer in the list with | 308 // Gets paired device information of the capture device for the audio |
306 // a valid |device_id|. Microphones are represented by capturers with a valid | 309 // renderer. This is used to pass on a session id, sample rate and buffer |
307 // |device_id|, since only one microphone is supported today, only one | 310 // size to a webrtc audio renderer (either local or remote), so that audio |
308 // capturer in the |capturers_| can have a valid |device_id|. | 311 // will be rendered to a matching output device. |
309 scoped_refptr<WebRtcAudioCapturer> GetDefaultCapturer() const; | 312 // Returns true if the capture device has a paired output device, otherwise |
| 313 // false. Note that if there are more than one open capture device the |
| 314 // function will not be able to pick an appropriate device and return false. |
| 315 bool GetAuthorizedDeviceInfoForAudioRenderer( |
| 316 int* session_id, int* output_sample_rate, int* output_buffer_size); |
310 | 317 |
311 const scoped_refptr<WebRtcAudioRenderer>& renderer() const { | 318 const scoped_refptr<WebRtcAudioRenderer>& renderer() const { |
312 return renderer_; | 319 return renderer_; |
313 } | 320 } |
314 int output_buffer_size() const { | 321 int output_buffer_size() const { |
315 return output_audio_parameters_.frames_per_buffer(); | 322 return output_audio_parameters_.frames_per_buffer(); |
316 } | 323 } |
317 int output_channels() const { | 324 int output_channels() const { |
318 return output_audio_parameters_.channels(); | 325 return output_audio_parameters_.channels(); |
319 } | 326 } |
(...skipping 28 matching lines...) Expand all Loading... |
348 // Called on the AudioInputDevice worker thread. | 355 // Called on the AudioInputDevice worker thread. |
349 virtual void RenderData(uint8* audio_data, | 356 virtual void RenderData(uint8* audio_data, |
350 int number_of_channels, | 357 int number_of_channels, |
351 int number_of_frames, | 358 int number_of_frames, |
352 int audio_delay_milliseconds) OVERRIDE; | 359 int audio_delay_milliseconds) OVERRIDE; |
353 | 360 |
354 // Called on the main render thread. | 361 // Called on the main render thread. |
355 virtual void SetRenderFormat(const media::AudioParameters& params) OVERRIDE; | 362 virtual void SetRenderFormat(const media::AudioParameters& params) OVERRIDE; |
356 virtual void RemoveAudioRenderer(WebRtcAudioRenderer* renderer) OVERRIDE; | 363 virtual void RemoveAudioRenderer(WebRtcAudioRenderer* renderer) OVERRIDE; |
357 | 364 |
| 365 // Helper to get the default capturer, which is the last capturer in |
| 366 // |capturers_|. |
| 367 scoped_refptr<WebRtcAudioCapturer> GetDefaultCapturer() const; |
| 368 |
358 // Used to DCHECK that we are called on the correct thread. | 369 // Used to DCHECK that we are called on the correct thread. |
359 base::ThreadChecker thread_checker_; | 370 base::ThreadChecker thread_checker_; |
360 | 371 |
361 int ref_count_; | 372 int ref_count_; |
362 | 373 |
363 // List of captures which provides access to the native audio input layer | 374 // List of captures which provides access to the native audio input layer |
364 // in the browser process. | 375 // in the browser process. |
365 CapturerList capturers_; | 376 CapturerList capturers_; |
366 | 377 |
367 // Provides access to the audio renderer in the browser process. | 378 // Provides access to the audio renderer in the browser process. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 // Stores latest microphone volume received in a CaptureData() callback. | 411 // Stores latest microphone volume received in a CaptureData() callback. |
401 // Range is [0, 255]. | 412 // Range is [0, 255]. |
402 uint32_t microphone_volume_; | 413 uint32_t microphone_volume_; |
403 | 414 |
404 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioDeviceImpl); | 415 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioDeviceImpl); |
405 }; | 416 }; |
406 | 417 |
407 } // namespace content | 418 } // namespace content |
408 | 419 |
409 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_ | 420 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_ |
OLD | NEW |