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 owns an object of webrtc::AudioProcessing which contains signal | |
| 28 // processing components like AGC, AEC and NS. It enables the components based | |
| 29 // on the constraints, processes the data and outputs it in a unit of 10 ms | |
| 30 // data chunk. | |
| 31 class CONTENT_EXPORT WebRtcAudioProcessor { | |
| 32 public: | |
| 33 explicit WebRtcAudioProcessor( | |
| 34 const webrtc::MediaConstraintsInterface* constraints); | |
|
DaleCurtis
2013/11/06 00:21:18
Should this be a const& instead?
no longer working on chromium
2013/11/06 16:45:14
It is following the caller WebRtcLocalAudioTrack,
DaleCurtis
2013/11/07 01:36:00
sgtm
| |
| 35 ~WebRtcAudioProcessor(); | |
| 36 | |
| 37 // Pushes capture data in |audio_source| to the internal FIFO. | |
| 38 // Called on the capture audio thread. | |
| 39 void PushCaptureData(media::AudioBus* audio_source); | |
| 40 | |
| 41 // Processes a block of 10 ms data from the internal FIFO and outputs it via | |
| 42 // |out|. | |
| 43 // Returns true if the internal FIFO has at least 10ms data for processing, | |
| 44 // otherwise false. | |
| 45 // Called on the capture audio thread. | |
| 46 bool ProcessAndConsume10MsData(int capture_audio_delay_ms, | |
|
DaleCurtis
2013/11/06 00:21:18
Are you sure you want 10ms in the name. Kind of a
no longer working on chromium
2013/11/06 16:45:14
I am glad to remove 10ms. Done
| |
| 47 int volume, | |
| 48 bool key_pressed, | |
| 49 int16** out); | |
| 50 | |
| 51 // Called when the format of the capture data has changed. | |
| 52 // Called on the main render thread. | |
| 53 void SetCaptureFormat(const media::AudioParameters& source_params); | |
| 54 | |
| 55 // Push the render audio to WebRtc::AudioProcessing for analysis. This is | |
| 56 // needed iff echo processing is enabled. | |
| 57 // Called on the render audio thread. | |
| 58 void PushRenderData(const int16* render_audio, | |
| 59 int sample_rate, | |
| 60 int number_of_channels, | |
| 61 int number_of_frames, | |
| 62 int render_delay_ms); | |
|
DaleCurtis
2013/11/06 00:21:18
How about using base::TimeDelta everywhere instead
no longer working on chromium
2013/11/06 16:45:14
May I ask why base::TimeDelta is preferred?
I thin
DaleCurtis
2013/11/07 01:36:00
As time goes forward we want to replace all _ms va
no longer working on chromium
2013/11/07 14:43:12
Could you please explain why you think base::TimeD
DaleCurtis
2013/11/07 20:44:08
You should be using base::TimeDelta (or Time, Time
| |
| 63 | |
| 64 // The audio format of the output from the processor. | |
| 65 const media::AudioParameters& OutputFormat() const; | |
| 66 | |
| 67 // Accessor to check if the audio processing is enabled or not. | |
| 68 bool has_audio_processing() const { return audio_processing_.get() != NULL; } | |
| 69 | |
| 70 private: | |
| 71 class WebRtcAudioConverter; | |
| 72 | |
| 73 // Helper to initialize the WebRtc AudioProcessing. | |
| 74 void InitializeAudioProcessingModule( | |
| 75 const webrtc::MediaConstraintsInterface* constraints); | |
|
DaleCurtis
2013/11/06 00:21:18
const&?
no longer working on chromium
2013/11/06 16:45:14
a separate refactor CL?
| |
| 76 | |
| 77 // Helper to initialize the render converter. | |
| 78 void InitializeRenderConverterIfNeeded(int sample_rate, | |
| 79 int number_of_channels, | |
| 80 int frames_per_buffer); | |
| 81 | |
| 82 // Called by ProcessAndConsume10MsData(). | |
| 83 void ProcessData(int audio_delay_milliseconds, | |
| 84 int volume, | |
| 85 bool key_pressed); | |
| 86 | |
| 87 // Called when the processor is going away. | |
| 88 void StopAudioProcessing(); | |
| 89 | |
| 90 // Cached value for the render delay latency. | |
| 91 int render_delay_ms_; | |
| 92 | |
| 93 // Protects |render_delay_ms_|. | |
| 94 // TODO(xians): Can we get rid of the lock? | |
| 95 mutable base::Lock lock_; | |
| 96 | |
| 97 // WebRtc AudioProcessing module which does AEC, AGC, NS, HighPass filter, | |
| 98 // ..etc. | |
| 99 scoped_ptr<webrtc::AudioProcessing> audio_processing_; | |
| 100 | |
| 101 // Converter used for the down-mixing and resampling of the capture data. | |
| 102 scoped_ptr<WebRtcAudioConverter> capture_converter_; | |
| 103 | |
| 104 // Converter used for the down-mixing and resampling of the render data when | |
| 105 // the AEC is enabled. | |
| 106 scoped_ptr<WebRtcAudioConverter> render_converter_; | |
| 107 }; | |
| 108 | |
| 109 } // namespace content | |
| 110 | |
| 111 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_PROCESSOR_H_ | |
| OLD | NEW |