Chromium Code Reviews| 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_PROCESSOR_H_ | |
| 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_PROCESSOR_H_ | |
| 7 | |
| 8 #include "base/synchronization/lock.h" | |
| 9 #include "content/common/content_export.h" | |
| 10 #include "media/base/audio_converter.h" | |
| 11 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface .h" | |
| 12 #include "third_party/webrtc/modules/audio_processing/include/audio_processing.h " | |
| 13 #include "third_party/webrtc/modules/interface/module_common_types.h" | |
| 14 | |
| 15 namespace media { | |
| 16 class AudioBus; | |
| 17 class AudioFifo; | |
| 18 class AudioParameters; | |
| 19 } // namespace media | |
| 20 | |
| 21 namespace webrtc { | |
| 22 class AudioFrame; | |
| 23 } | |
| 24 | |
| 25 namespace content { | |
| 26 | |
| 27 // This class is a wrapper class of webrtc::AudioProcessing. | |
| 28 class CONTENT_EXPORT WebRtcAudioProcessor { | |
| 29 public: | |
| 30 explicit WebRtcAudioProcessor( | |
| 31 const webrtc::MediaConstraintsInterface* constraints); | |
| 32 ~WebRtcAudioProcessor(); | |
| 33 | |
| 34 // TODO(xians): Add comment. | |
| 35 void SetFormat(const media::AudioParameters& source_params); | |
| 36 | |
| 37 void Push(media::AudioBus* audio_source); | |
|
Henrik Grunell
2013/10/31 11:56:12
Add comment.
| |
| 38 | |
| 39 // Returns true if it has 10ms data for processing, otherwise false. | |
| 40 bool ProcessAndConsume10MsData(int capture_audio_delay_ms, | |
| 41 int volume, | |
| 42 bool key_pressed); | |
| 43 | |
| 44 const int16* OutputBuffer() const; | |
| 45 const media::AudioParameters& OutputFormat() const; | |
| 46 | |
| 47 // Feed render audio to AudioProcessing for analysis. This is needed | |
| 48 // if and only if echo processing is enabled. | |
| 49 void FeedRenderDataToAudioProcessing(const int16* render_audio, | |
| 50 int sample_rate, | |
| 51 int number_of_channels, | |
| 52 int number_of_frames, | |
| 53 int render_delay_ms); | |
| 54 | |
| 55 bool has_audio_processing() const { return audio_processing_.get() != NULL; } | |
| 56 | |
| 57 private: | |
| 58 class WebRtcAudioConverter; | |
| 59 | |
| 60 void InitializeAudioProcessingModule( | |
| 61 const webrtc::MediaConstraintsInterface* constraints); | |
| 62 void InitializeRenderConverterIfNeeded(int sample_rate, | |
| 63 int number_of_channels, | |
| 64 int frames_per_buffer); | |
| 65 // Processes 10ms data. | |
| 66 void Process10MsData(int audio_delay_milliseconds, | |
| 67 int volume, | |
| 68 bool key_pressed); | |
| 69 | |
| 70 void StopAudioProcessing(); | |
| 71 | |
| 72 // Cached value for the render delay latency. | |
| 73 int render_delay_ms_; | |
| 74 | |
| 75 // Protects |render_delay_ms_|. | |
| 76 // TODO(xians): Can we get rid of the lock? | |
| 77 mutable base::Lock lock_; | |
| 78 | |
| 79 // Hanles processing the audio data. | |
| 80 scoped_ptr<webrtc::AudioProcessing> audio_processing_; | |
| 81 | |
| 82 scoped_ptr<WebRtcAudioConverter> capture_converter_; | |
| 83 scoped_ptr<WebRtcAudioConverter> render_converter_; | |
| 84 }; | |
| 85 | |
| 86 } // namespace content | |
| 87 | |
| 88 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_PROCESSOR_H_ | |
| OLD | NEW |