| 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 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
| 17 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
| 18 #include "content/renderer/media/webrtc_audio_capturer.h" | 18 #include "content/renderer/media/webrtc_audio_capturer.h" |
| 19 #include "content/renderer/media/webrtc_audio_device_not_impl.h" | 19 #include "content/renderer/media/webrtc_audio_device_not_impl.h" |
| 20 #include "content/renderer/media/webrtc_audio_renderer.h" | 20 #include "content/renderer/media/webrtc_audio_renderer.h" |
| 21 #include "ipc/ipc_platform_file.h" |
| 21 #include "media/base/audio_capturer_source.h" | 22 #include "media/base/audio_capturer_source.h" |
| 22 #include "media/base/audio_renderer_sink.h" | 23 #include "media/base/audio_renderer_sink.h" |
| 23 | 24 |
| 24 // A WebRtcAudioDeviceImpl instance implements the abstract interface | 25 // A WebRtcAudioDeviceImpl instance implements the abstract interface |
| 25 // webrtc::AudioDeviceModule which makes it possible for a user (e.g. webrtc:: | 26 // webrtc::AudioDeviceModule which makes it possible for a user (e.g. webrtc:: |
| 26 // VoiceEngine) to register this class as an external AudioDeviceModule (ADM). | 27 // VoiceEngine) to register this class as an external AudioDeviceModule (ADM). |
| 27 // Then WebRtcAudioDeviceImpl::SetSessionId() needs to be called to set the | 28 // Then WebRtcAudioDeviceImpl::SetSessionId() needs to be called to set the |
| 28 // session id that tells which device to use. The user can then call | 29 // session id that tells which device to use. The user can then call |
| 29 // WebRtcAudioDeviceImpl::StartPlayout() and | 30 // WebRtcAudioDeviceImpl::StartPlayout() and |
| 30 // WebRtcAudioDeviceImpl::StartRecording() from the render process to initiate | 31 // WebRtcAudioDeviceImpl::StartRecording() from the render process to initiate |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 // Returns true if the capture device has a paired output device, otherwise | 345 // Returns true if the capture device has a paired output device, otherwise |
| 345 // false. Note that if there are more than one open capture device the | 346 // false. Note that if there are more than one open capture device the |
| 346 // function will not be able to pick an appropriate device and return false. | 347 // function will not be able to pick an appropriate device and return false. |
| 347 bool GetAuthorizedDeviceInfoForAudioRenderer( | 348 bool GetAuthorizedDeviceInfoForAudioRenderer( |
| 348 int* session_id, int* output_sample_rate, int* output_buffer_size); | 349 int* session_id, int* output_sample_rate, int* output_buffer_size); |
| 349 | 350 |
| 350 const scoped_refptr<WebRtcAudioRenderer>& renderer() const { | 351 const scoped_refptr<WebRtcAudioRenderer>& renderer() const { |
| 351 return renderer_; | 352 return renderer_; |
| 352 } | 353 } |
| 353 | 354 |
| 355 // Enables the Aec dump. If the default capturer exists, it will call |
| 356 // StartAecDump() on the capturer and pass the ownership of the file to |
| 357 // WebRtc. Otherwise it will hold the file until a capturer is added. |
| 358 void EnableAecDump(const base::PlatformFile& aec_dump_file); |
| 359 |
| 360 // Disables the Aec dump. When this method is called, the ongoing Aec dump |
| 361 // on WebRtc will be stopped. |
| 362 void DisableAecDump(); |
| 363 |
| 354 private: | 364 private: |
| 355 typedef std::list<scoped_refptr<WebRtcAudioCapturer> > CapturerList; | 365 typedef std::list<scoped_refptr<WebRtcAudioCapturer> > CapturerList; |
| 356 typedef std::list<WebRtcPlayoutDataSource::Sink*> PlayoutDataSinkList; | 366 typedef std::list<WebRtcPlayoutDataSource::Sink*> PlayoutDataSinkList; |
| 357 class RenderBuffer; | 367 class RenderBuffer; |
| 358 | 368 |
| 359 // Make destructor private to ensure that we can only be deleted by Release(). | 369 // Make destructor private to ensure that we can only be deleted by Release(). |
| 360 virtual ~WebRtcAudioDeviceImpl(); | 370 virtual ~WebRtcAudioDeviceImpl(); |
| 361 | 371 |
| 362 // PeerConnectionAudioSink implementation. | 372 // PeerConnectionAudioSink implementation. |
| 363 | 373 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 382 int sample_rate, | 392 int sample_rate, |
| 383 int audio_delay_milliseconds) OVERRIDE; | 393 int audio_delay_milliseconds) OVERRIDE; |
| 384 | 394 |
| 385 // Called on the main render thread. | 395 // Called on the main render thread. |
| 386 virtual void RemoveAudioRenderer(WebRtcAudioRenderer* renderer) OVERRIDE; | 396 virtual void RemoveAudioRenderer(WebRtcAudioRenderer* renderer) OVERRIDE; |
| 387 | 397 |
| 388 // WebRtcPlayoutDataSource implementation. | 398 // WebRtcPlayoutDataSource implementation. |
| 389 virtual void AddPlayoutSink(WebRtcPlayoutDataSource::Sink* sink) OVERRIDE; | 399 virtual void AddPlayoutSink(WebRtcPlayoutDataSource::Sink* sink) OVERRIDE; |
| 390 virtual void RemovePlayoutSink(WebRtcPlayoutDataSource::Sink* sink) OVERRIDE; | 400 virtual void RemovePlayoutSink(WebRtcPlayoutDataSource::Sink* sink) OVERRIDE; |
| 391 | 401 |
| 402 // Helper to start the Aec dump if the default capturer exists. |
| 403 void MaybeStartAecDump(); |
| 404 |
| 392 // Used to DCHECK that we are called on the correct thread. | 405 // Used to DCHECK that we are called on the correct thread. |
| 393 base::ThreadChecker thread_checker_; | 406 base::ThreadChecker thread_checker_; |
| 394 | 407 |
| 395 int ref_count_; | 408 int ref_count_; |
| 396 | 409 |
| 397 // List of captures which provides access to the native audio input layer | 410 // List of captures which provides access to the native audio input layer |
| 398 // in the browser process. | 411 // in the browser process. |
| 399 CapturerList capturers_; | 412 CapturerList capturers_; |
| 400 | 413 |
| 401 // Provides access to the audio renderer in the browser process. | 414 // Provides access to the audio renderer in the browser process. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 430 bool recording_; | 443 bool recording_; |
| 431 | 444 |
| 432 // Stores latest microphone volume received in a CaptureData() callback. | 445 // Stores latest microphone volume received in a CaptureData() callback. |
| 433 // Range is [0, 255]. | 446 // Range is [0, 255]. |
| 434 uint32_t microphone_volume_; | 447 uint32_t microphone_volume_; |
| 435 | 448 |
| 436 // Buffer used for temporary storage during render callback. | 449 // Buffer used for temporary storage during render callback. |
| 437 // It is only accessed by the audio render thread. | 450 // It is only accessed by the audio render thread. |
| 438 std::vector<int16> render_buffer_; | 451 std::vector<int16> render_buffer_; |
| 439 | 452 |
| 453 // Used for start the Aec dump on the default capturer. |
| 454 base::PlatformFile aec_dump_file_; |
| 455 |
| 440 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioDeviceImpl); | 456 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioDeviceImpl); |
| 441 }; | 457 }; |
| 442 | 458 |
| 443 } // namespace content | 459 } // namespace content |
| 444 | 460 |
| 445 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_ | 461 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_ |
| OLD | NEW |