OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_PROCESSING_WRAPPER_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_PROCESSING_WRAPPER_H_ |
| 7 |
| 8 #include "content/common/content_export.h" |
| 9 #include "media/base/audio_converter.h" |
| 10 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface
.h" |
| 11 #include "third_party/webrtc/modules/audio_processing/include/audio_processing.h
" |
| 12 #include "third_party/webrtc/modules/interface/module_common_types.h" |
| 13 |
| 14 namespace media { |
| 15 class AudioBus; |
| 16 class AudioFifo; |
| 17 class AudioParameters; |
| 18 } // namespace media |
| 19 |
| 20 namespace webrtc { |
| 21 class AudioFrame; |
| 22 } |
| 23 |
| 24 namespace content { |
| 25 |
| 26 // This class is a wrapper class of webrtc::AudioProcessing. |
| 27 class CONTENT_EXPORT WebRtcAudioProcessingWrapper { |
| 28 public: |
| 29 WebRtcAudioProcessingWrapper(); |
| 30 ~WebRtcAudioProcessingWrapper(); |
| 31 |
| 32 // TODO(xians): Add comment. |
| 33 void Configure(const media::AudioParameters& source_params, |
| 34 const webrtc::MediaConstraintsInterface* constraints); |
| 35 |
| 36 void Push(media::AudioBus* audio_source); |
| 37 |
| 38 // Returns true if it has 10ms data for processing, otherwise false. |
| 39 bool ProcessAndConsume10MsData(int capture_audio_delay_ms, |
| 40 int volume, |
| 41 bool key_pressed); |
| 42 |
| 43 const int16* OutputBuffer() const; |
| 44 const media::AudioParameters& OutputFormat() const; |
| 45 |
| 46 // Feed render audio to AudioProcessing for analysis. This is needed |
| 47 // if and only if echo processing is enabled. |
| 48 void FeedRenderDataToAudioProcessing(const int16* render_audio, |
| 49 int sample_rate, |
| 50 int number_of_channels, |
| 51 int number_of_frames, |
| 52 int render_delay_ms); |
| 53 |
| 54 private: |
| 55 class WebRtcAudioConverter; |
| 56 |
| 57 void InitializeCaptureConverter(const media::AudioParameters& source_params); |
| 58 void InitializeRenderConverterIfNeeded(int sample_rate, |
| 59 int number_of_channels, |
| 60 int frames_per_buffer); |
| 61 // Processes 10ms data. |
| 62 void Process10MsData(int audio_delay_milliseconds, |
| 63 int volume, |
| 64 bool key_pressed); |
| 65 |
| 66 void StopAudioProcessing(); |
| 67 |
| 68 // Hanles processing the audio data. |
| 69 scoped_ptr<webrtc::AudioProcessing> audio_processing_; |
| 70 |
| 71 scoped_ptr<WebRtcAudioConverter> capture_converter_; |
| 72 scoped_ptr<WebRtcAudioConverter> render_converter_; |
| 73 }; |
| 74 |
| 75 } // namespace content |
| 76 |
| 77 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_PROCESSING_WRAPPER_H_ |
OLD | NEW |