| 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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 // The maximum volume value WebRtc uses. | 276 // The maximum volume value WebRtc uses. |
| 277 static const int kMaxVolumeLevel = 255; | 277 static const int kMaxVolumeLevel = 255; |
| 278 | 278 |
| 279 // Instances of this object are created on the main render thread. | 279 // Instances of this object are created on the main render thread. |
| 280 WebRtcAudioDeviceImpl(); | 280 WebRtcAudioDeviceImpl(); |
| 281 | 281 |
| 282 // webrtc::RefCountedModule implementation. | 282 // webrtc::RefCountedModule implementation. |
| 283 // The creator must call AddRef() after construction and use Release() | 283 // The creator must call AddRef() after construction and use Release() |
| 284 // to release the reference and delete this object. | 284 // to release the reference and delete this object. |
| 285 // Called on the main render thread. | 285 // Called on the main render thread. |
| 286 virtual int32_t AddRef() override; | 286 int32_t AddRef() override; |
| 287 virtual int32_t Release() override; | 287 int32_t Release() override; |
| 288 | 288 |
| 289 // webrtc::AudioDeviceModule implementation. | 289 // webrtc::AudioDeviceModule implementation. |
| 290 // All implemented methods are called on the main render thread unless | 290 // All implemented methods are called on the main render thread unless |
| 291 // anything else is stated. | 291 // anything else is stated. |
| 292 | 292 |
| 293 virtual int32_t RegisterAudioCallback(webrtc::AudioTransport* audio_callback) | 293 int32_t RegisterAudioCallback( |
| 294 override; | 294 webrtc::AudioTransport* audio_callback) override; |
| 295 | 295 |
| 296 virtual int32_t Init() override; | 296 int32_t Init() override; |
| 297 virtual int32_t Terminate() override; | 297 int32_t Terminate() override; |
| 298 virtual bool Initialized() const override; | 298 bool Initialized() const override; |
| 299 | 299 |
| 300 virtual int32_t PlayoutIsAvailable(bool* available) override; | 300 int32_t PlayoutIsAvailable(bool* available) override; |
| 301 virtual bool PlayoutIsInitialized() const override; | 301 bool PlayoutIsInitialized() const override; |
| 302 virtual int32_t RecordingIsAvailable(bool* available) override; | 302 int32_t RecordingIsAvailable(bool* available) override; |
| 303 virtual bool RecordingIsInitialized() const override; | 303 bool RecordingIsInitialized() const override; |
| 304 | 304 |
| 305 // All Start/Stop methods are called on a libJingle worker thread. | 305 // All Start/Stop methods are called on a libJingle worker thread. |
| 306 virtual int32_t StartPlayout() override; | 306 int32_t StartPlayout() override; |
| 307 virtual int32_t StopPlayout() override; | 307 int32_t StopPlayout() override; |
| 308 virtual bool Playing() const override; | 308 bool Playing() const override; |
| 309 virtual int32_t StartRecording() override; | 309 int32_t StartRecording() override; |
| 310 virtual int32_t StopRecording() override; | 310 int32_t StopRecording() override; |
| 311 virtual bool Recording() const override; | 311 bool Recording() const override; |
| 312 | 312 |
| 313 // Called on the AudioInputDevice worker thread. | 313 // Called on the AudioInputDevice worker thread. |
| 314 virtual int32_t SetMicrophoneVolume(uint32_t volume) override; | 314 int32_t SetMicrophoneVolume(uint32_t volume) override; |
| 315 | 315 |
| 316 // TODO(henrika): sort out calling thread once we start using this API. | 316 // TODO(henrika): sort out calling thread once we start using this API. |
| 317 virtual int32_t MicrophoneVolume(uint32_t* volume) const override; | 317 int32_t MicrophoneVolume(uint32_t* volume) const override; |
| 318 | 318 |
| 319 virtual int32_t MaxMicrophoneVolume(uint32_t* max_volume) const override; | 319 int32_t MaxMicrophoneVolume(uint32_t* max_volume) const override; |
| 320 virtual int32_t MinMicrophoneVolume(uint32_t* min_volume) const override; | 320 int32_t MinMicrophoneVolume(uint32_t* min_volume) const override; |
| 321 virtual int32_t StereoPlayoutIsAvailable(bool* available) const override; | 321 int32_t StereoPlayoutIsAvailable(bool* available) const override; |
| 322 virtual int32_t StereoRecordingIsAvailable(bool* available) const override; | 322 int32_t StereoRecordingIsAvailable(bool* available) const override; |
| 323 virtual int32_t PlayoutDelay(uint16_t* delay_ms) const override; | 323 int32_t PlayoutDelay(uint16_t* delay_ms) const override; |
| 324 virtual int32_t RecordingDelay(uint16_t* delay_ms) const override; | 324 int32_t RecordingDelay(uint16_t* delay_ms) const override; |
| 325 virtual int32_t RecordingSampleRate(uint32_t* sample_rate) const override; | 325 int32_t RecordingSampleRate(uint32_t* sample_rate) const override; |
| 326 virtual int32_t PlayoutSampleRate(uint32_t* sample_rate) const override; | 326 int32_t PlayoutSampleRate(uint32_t* sample_rate) const override; |
| 327 | 327 |
| 328 // Sets the |renderer_|, returns false if |renderer_| already exists. | 328 // Sets the |renderer_|, returns false if |renderer_| already exists. |
| 329 // Called on the main renderer thread. | 329 // Called on the main renderer thread. |
| 330 bool SetAudioRenderer(WebRtcAudioRenderer* renderer); | 330 bool SetAudioRenderer(WebRtcAudioRenderer* renderer); |
| 331 | 331 |
| 332 // Adds/Removes the capturer to the ADM. | 332 // Adds/Removes the capturer to the ADM. |
| 333 // TODO(xians): Remove these two methods once the ADM does not need to pass | 333 // TODO(xians): Remove these two methods once the ADM does not need to pass |
| 334 // hardware information up to WebRtc. | 334 // hardware information up to WebRtc. |
| 335 void AddAudioCapturer(const scoped_refptr<WebRtcAudioCapturer>& capturer); | 335 void AddAudioCapturer(const scoped_refptr<WebRtcAudioCapturer>& capturer); |
| 336 void RemoveAudioCapturer(const scoped_refptr<WebRtcAudioCapturer>& capturer); | 336 void RemoveAudioCapturer(const scoped_refptr<WebRtcAudioCapturer>& capturer); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 352 const scoped_refptr<WebRtcAudioRenderer>& renderer() const { | 352 const scoped_refptr<WebRtcAudioRenderer>& renderer() const { |
| 353 return renderer_; | 353 return renderer_; |
| 354 } | 354 } |
| 355 | 355 |
| 356 private: | 356 private: |
| 357 typedef std::list<scoped_refptr<WebRtcAudioCapturer> > CapturerList; | 357 typedef std::list<scoped_refptr<WebRtcAudioCapturer> > CapturerList; |
| 358 typedef std::list<WebRtcPlayoutDataSource::Sink*> PlayoutDataSinkList; | 358 typedef std::list<WebRtcPlayoutDataSource::Sink*> PlayoutDataSinkList; |
| 359 class RenderBuffer; | 359 class RenderBuffer; |
| 360 | 360 |
| 361 // Make destructor private to ensure that we can only be deleted by Release(). | 361 // Make destructor private to ensure that we can only be deleted by Release(). |
| 362 virtual ~WebRtcAudioDeviceImpl(); | 362 ~WebRtcAudioDeviceImpl() override; |
| 363 | 363 |
| 364 // PeerConnectionAudioSink implementation. | 364 // PeerConnectionAudioSink implementation. |
| 365 | 365 |
| 366 // Called on the AudioInputDevice worker thread. | 366 // Called on the AudioInputDevice worker thread. |
| 367 virtual int OnData(const int16* audio_data, | 367 int OnData(const int16* audio_data, |
| 368 int sample_rate, | 368 int sample_rate, |
| 369 int number_of_channels, | 369 int number_of_channels, |
| 370 int number_of_frames, | 370 int number_of_frames, |
| 371 const std::vector<int>& channels, | 371 const std::vector<int>& channels, |
| 372 int audio_delay_milliseconds, | 372 int audio_delay_milliseconds, |
| 373 int current_volume, | 373 int current_volume, |
| 374 bool need_audio_processing, | 374 bool need_audio_processing, |
| 375 bool key_pressed) override; | 375 bool key_pressed) override; |
| 376 | 376 |
| 377 // Called on the AudioInputDevice worker thread. | 377 // Called on the AudioInputDevice worker thread. |
| 378 virtual void OnSetFormat(const media::AudioParameters& params) override; | 378 void OnSetFormat(const media::AudioParameters& params) override; |
| 379 | 379 |
| 380 // WebRtcAudioRendererSource implementation. | 380 // WebRtcAudioRendererSource implementation. |
| 381 | 381 |
| 382 // Called on the AudioOutputDevice worker thread. | 382 // Called on the AudioOutputDevice worker thread. |
| 383 virtual void RenderData(media::AudioBus* audio_bus, | 383 void RenderData(media::AudioBus* audio_bus, |
| 384 int sample_rate, | 384 int sample_rate, |
| 385 int audio_delay_milliseconds, | 385 int audio_delay_milliseconds, |
| 386 base::TimeDelta* current_time) override; | 386 base::TimeDelta* current_time) override; |
| 387 | 387 |
| 388 // Called on the main render thread. | 388 // Called on the main render thread. |
| 389 virtual void RemoveAudioRenderer(WebRtcAudioRenderer* renderer) override; | 389 void RemoveAudioRenderer(WebRtcAudioRenderer* renderer) override; |
| 390 | 390 |
| 391 // WebRtcPlayoutDataSource implementation. | 391 // WebRtcPlayoutDataSource implementation. |
| 392 virtual void AddPlayoutSink(WebRtcPlayoutDataSource::Sink* sink) override; | 392 void AddPlayoutSink(WebRtcPlayoutDataSource::Sink* sink) override; |
| 393 virtual void RemovePlayoutSink(WebRtcPlayoutDataSource::Sink* sink) override; | 393 void RemovePlayoutSink(WebRtcPlayoutDataSource::Sink* sink) override; |
| 394 | 394 |
| 395 // Used to DCHECK that we are called on the correct thread. | 395 // Used to DCHECK that we are called on the correct thread. |
| 396 base::ThreadChecker thread_checker_; | 396 base::ThreadChecker thread_checker_; |
| 397 | 397 |
| 398 int ref_count_; | 398 int ref_count_; |
| 399 | 399 |
| 400 // List of captures which provides access to the native audio input layer | 400 // List of captures which provides access to the native audio input layer |
| 401 // in the browser process. | 401 // in the browser process. |
| 402 CapturerList capturers_; | 402 CapturerList capturers_; |
| 403 | 403 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 | 442 |
| 443 // Flag to tell if audio processing is enabled in MediaStreamAudioProcessor. | 443 // Flag to tell if audio processing is enabled in MediaStreamAudioProcessor. |
| 444 const bool is_audio_track_processing_enabled_; | 444 const bool is_audio_track_processing_enabled_; |
| 445 | 445 |
| 446 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioDeviceImpl); | 446 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioDeviceImpl); |
| 447 }; | 447 }; |
| 448 | 448 |
| 449 } // namespace content | 449 } // namespace content |
| 450 | 450 |
| 451 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_ | 451 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_ |
| OLD | NEW |