| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <list> |
| 10 #include <string> | 11 #include <string> |
| 11 #include <vector> | 12 #include <vector> |
| 12 | 13 |
| 13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 14 #include "base/files/file.h" | 15 #include "base/files/file.h" |
| 15 #include "base/logging.h" | 16 #include "base/logging.h" |
| 16 #include "base/macros.h" | 17 #include "base/macros.h" |
| 17 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 18 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
| 19 #include "base/threading/thread_checker.h" | 20 #include "base/threading/thread_checker.h" |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 int32_t PlayoutDelay(uint16_t* delay_ms) const override; | 300 int32_t PlayoutDelay(uint16_t* delay_ms) const override; |
| 300 int32_t RecordingDelay(uint16_t* delay_ms) const override; | 301 int32_t RecordingDelay(uint16_t* delay_ms) const override; |
| 301 int32_t RecordingSampleRate(uint32_t* sample_rate) const override; | 302 int32_t RecordingSampleRate(uint32_t* sample_rate) const override; |
| 302 int32_t PlayoutSampleRate(uint32_t* sample_rate) const override; | 303 int32_t PlayoutSampleRate(uint32_t* sample_rate) const override; |
| 303 | 304 |
| 304 public: | 305 public: |
| 305 // Sets the |renderer_|, returns false if |renderer_| already exists. | 306 // Sets the |renderer_|, returns false if |renderer_| already exists. |
| 306 // Called on the main renderer thread. | 307 // Called on the main renderer thread. |
| 307 bool SetAudioRenderer(WebRtcAudioRenderer* renderer); | 308 bool SetAudioRenderer(WebRtcAudioRenderer* renderer); |
| 308 | 309 |
| 309 // Adds/Removes the capturer to the ADM. | 310 // Adds/Removes the |capturer| to the ADM. Does NOT take ownership. |
| 311 // Capturers must remain valid until RemoveAudioCapturer() is called. |
| 310 // TODO(xians): Remove these two methods once the ADM does not need to pass | 312 // TODO(xians): Remove these two methods once the ADM does not need to pass |
| 311 // hardware information up to WebRtc. | 313 // hardware information up to WebRtc. |
| 312 void AddAudioCapturer(const scoped_refptr<WebRtcAudioCapturer>& capturer); | 314 void AddAudioCapturer(WebRtcAudioCapturer* capturer); |
| 313 void RemoveAudioCapturer(const scoped_refptr<WebRtcAudioCapturer>& capturer); | 315 void RemoveAudioCapturer(WebRtcAudioCapturer* capturer); |
| 314 | |
| 315 // Gets the default capturer, which is the last capturer in |capturers_|. | |
| 316 // The method can be called by both Libjingle thread and main render thread. | |
| 317 scoped_refptr<WebRtcAudioCapturer> GetDefaultCapturer() const; | |
| 318 | 316 |
| 319 // Gets paired device information of the capture device for the audio | 317 // Gets paired device information of the capture device for the audio |
| 320 // renderer. This is used to pass on a session id, sample rate and buffer | 318 // renderer. This is used to pass on a session id, sample rate and buffer |
| 321 // size to a webrtc audio renderer (either local or remote), so that audio | 319 // size to a webrtc audio renderer (either local or remote), so that audio |
| 322 // will be rendered to a matching output device. | 320 // will be rendered to a matching output device. |
| 323 // Returns true if the capture device has a paired output device, otherwise | 321 // Returns true if the capture device has a paired output device, otherwise |
| 324 // false. Note that if there are more than one open capture device the | 322 // false. Note that if there are more than one open capture device the |
| 325 // function will not be able to pick an appropriate device and return false. | 323 // function will not be able to pick an appropriate device and return false. |
| 326 bool GetAuthorizedDeviceInfoForAudioRenderer( | 324 bool GetAuthorizedDeviceInfoForAudioRenderer( |
| 327 int* session_id, int* output_sample_rate, int* output_buffer_size); | 325 int* session_id, int* output_sample_rate, int* output_buffer_size); |
| 328 | 326 |
| 329 const scoped_refptr<WebRtcAudioRenderer>& renderer() const { | 327 const scoped_refptr<WebRtcAudioRenderer>& renderer() const { |
| 330 return renderer_; | 328 return renderer_; |
| 331 } | 329 } |
| 332 | 330 |
| 333 private: | 331 private: |
| 334 typedef std::list<scoped_refptr<WebRtcAudioCapturer> > CapturerList; | 332 typedef std::list<WebRtcAudioCapturer*> CapturerList; |
| 335 typedef std::list<WebRtcPlayoutDataSource::Sink*> PlayoutDataSinkList; | 333 typedef std::list<WebRtcPlayoutDataSource::Sink*> PlayoutDataSinkList; |
| 336 class RenderBuffer; | 334 class RenderBuffer; |
| 337 | 335 |
| 338 // Make destructor private to ensure that we can only be deleted by Release(). | 336 // Make destructor private to ensure that we can only be deleted by Release(). |
| 339 ~WebRtcAudioDeviceImpl() override; | 337 ~WebRtcAudioDeviceImpl() override; |
| 340 | 338 |
| 341 // WebRtcAudioRendererSource implementation. | 339 // WebRtcAudioRendererSource implementation. |
| 342 | 340 |
| 343 // Called on the AudioOutputDevice worker thread. | 341 // Called on the AudioOutputDevice worker thread. |
| 344 void RenderData(media::AudioBus* audio_bus, | 342 void RenderData(media::AudioBus* audio_bus, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 357 // Used to check methods that run on the main render thread. | 355 // Used to check methods that run on the main render thread. |
| 358 base::ThreadChecker main_thread_checker_; | 356 base::ThreadChecker main_thread_checker_; |
| 359 // Used to check methods that are called on libjingle's signaling thread. | 357 // Used to check methods that are called on libjingle's signaling thread. |
| 360 base::ThreadChecker signaling_thread_checker_; | 358 base::ThreadChecker signaling_thread_checker_; |
| 361 base::ThreadChecker worker_thread_checker_; | 359 base::ThreadChecker worker_thread_checker_; |
| 362 base::ThreadChecker audio_renderer_thread_checker_; | 360 base::ThreadChecker audio_renderer_thread_checker_; |
| 363 | 361 |
| 364 mutable int ref_count_; | 362 mutable int ref_count_; |
| 365 | 363 |
| 366 // List of captures which provides access to the native audio input layer | 364 // List of captures which provides access to the native audio input layer |
| 367 // in the browser process. | 365 // in the browser process. The last capturer in this list is considered the |
| 366 // "default capturer" by the methods implementing the |
| 367 // webrtc::AudioDeviceModule interface. |
| 368 CapturerList capturers_; | 368 CapturerList capturers_; |
| 369 | 369 |
| 370 // Provides access to the audio renderer in the browser process. | 370 // Provides access to the audio renderer in the browser process. |
| 371 scoped_refptr<WebRtcAudioRenderer> renderer_; | 371 scoped_refptr<WebRtcAudioRenderer> renderer_; |
| 372 | 372 |
| 373 // A list of raw pointer of WebRtcPlayoutDataSource::Sink objects which want | 373 // A list of raw pointer of WebRtcPlayoutDataSource::Sink objects which want |
| 374 // to get the playout data, the sink need to call RemovePlayoutSink() | 374 // to get the playout data, the sink need to call RemovePlayoutSink() |
| 375 // before it goes away. | 375 // before it goes away. |
| 376 PlayoutDataSinkList playout_sinks_; | 376 PlayoutDataSinkList playout_sinks_; |
| 377 | 377 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 405 // Buffer used for temporary storage during render callback. | 405 // Buffer used for temporary storage during render callback. |
| 406 // It is only accessed by the audio render thread. | 406 // It is only accessed by the audio render thread. |
| 407 std::vector<int16_t> render_buffer_; | 407 std::vector<int16_t> render_buffer_; |
| 408 | 408 |
| 409 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioDeviceImpl); | 409 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioDeviceImpl); |
| 410 }; | 410 }; |
| 411 | 411 |
| 412 } // namespace content | 412 } // namespace content |
| 413 | 413 |
| 414 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_ | 414 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_ |
| OLD | NEW |