Chromium Code Reviews| 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_MEDIA_STREAM_AUDIO_PROCESSOR_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_H_ | 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_H_ |
| 7 | 7 |
| 8 #include "base/atomicops.h" | 8 #include "base/atomicops.h" |
| 9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
| 10 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 int sample_rate, | 56 int sample_rate, |
| 57 int number_of_channels, | 57 int number_of_channels, |
| 58 int number_of_frames, | 58 int number_of_frames, |
| 59 base::TimeDelta render_delay); | 59 base::TimeDelta render_delay); |
| 60 | 60 |
| 61 // Processes a block of 10 ms data from the internal FIFO and outputs it via | 61 // Processes a block of 10 ms data from the internal FIFO and outputs it via |
| 62 // |out|. |out| is the address of the pointer that will be pointed to | 62 // |out|. |out| is the address of the pointer that will be pointed to |
| 63 // the post-processed data if the method is returning a true. The lifetime | 63 // the post-processed data if the method is returning a true. The lifetime |
| 64 // of the data represeted by |out| is guaranteed to outlive the method call. | 64 // of the data represeted by |out| is guaranteed to outlive the method call. |
| 65 // That also says *|out| won't change until this method is called again. | 65 // That also says *|out| won't change until this method is called again. |
| 66 // |new_volume| contains the new microphone volume from the AGC, the value | |
| 67 // will be 0 if the microphone volume is not adjusted. | |
|
tommi (sloooow) - chröme
2014/01/21 15:06:20
nit:
// |new_volume| receives the new microphone v
no longer working on chromium
2014/01/23 12:46:08
Done.
| |
| 66 // Returns true if the internal FIFO has at least 10 ms data for processing, | 68 // Returns true if the internal FIFO has at least 10 ms data for processing, |
| 67 // otherwise false. | 69 // otherwise false. |
| 68 // |capture_delay|, |volume| and |key_pressed| will be passed to | 70 // |capture_delay|, |volume| and |key_pressed| will be passed to |
| 69 // webrtc::AudioProcessing to help processing the data. | 71 // webrtc::AudioProcessing to help processing the data. |
| 70 // Called on the capture audio thread. | 72 // Called on the capture audio thread. |
| 71 bool ProcessAndConsumeData(base::TimeDelta capture_delay, | 73 bool ProcessAndConsumeData(base::TimeDelta capture_delay, |
| 72 int volume, | 74 int volume, |
| 73 bool key_pressed, | 75 bool key_pressed, |
| 76 int* new_volume, | |
| 74 int16** out); | 77 int16** out); |
| 75 | 78 |
| 76 | 79 |
| 77 // The audio format of the input to the processor. | 80 // The audio format of the input to the processor. |
| 78 const media::AudioParameters& InputFormat() const; | 81 const media::AudioParameters& InputFormat() const; |
| 79 | 82 |
| 80 // The audio format of the output from the processor. | 83 // The audio format of the output from the processor. |
| 81 const media::AudioParameters& OutputFormat() const; | 84 const media::AudioParameters& OutputFormat() const; |
| 82 | 85 |
| 83 // Accessor to check if the audio processing is enabled or not. | 86 // Accessor to check if the audio processing is enabled or not. |
| 84 bool has_audio_processing() const { return audio_processing_ != NULL; } | 87 bool has_audio_processing() const { return audio_processing_ != NULL; } |
| 85 | 88 |
| 86 protected: | 89 protected: |
| 87 friend class base::RefCountedThreadSafe<MediaStreamAudioProcessor>; | 90 friend class base::RefCountedThreadSafe<MediaStreamAudioProcessor>; |
| 88 virtual ~MediaStreamAudioProcessor(); | 91 virtual ~MediaStreamAudioProcessor(); |
| 89 | 92 |
| 90 private: | 93 private: |
| 94 friend class MediaStreamAudioProcessorTest; | |
| 95 | |
| 91 class MediaStreamAudioConverter; | 96 class MediaStreamAudioConverter; |
| 92 | 97 |
| 93 // Helper to initialize the WebRtc AudioProcessing. | 98 // Helper to initialize the WebRtc AudioProcessing. |
| 94 void InitializeAudioProcessingModule( | 99 void InitializeAudioProcessingModule( |
| 95 const blink::WebMediaConstraints& constraints, int effects); | 100 const blink::WebMediaConstraints& constraints, int effects); |
| 96 | 101 |
| 97 // Helper to initialize the capture converter. | 102 // Helper to initialize the capture converter. |
| 98 void InitializeCaptureConverter(const media::AudioParameters& source_params); | 103 void InitializeCaptureConverter(const media::AudioParameters& source_params); |
| 99 | 104 |
| 100 // Helper to initialize the render converter. | 105 // Helper to initialize the render converter. |
| 101 void InitializeRenderConverterIfNeeded(int sample_rate, | 106 void InitializeRenderConverterIfNeeded(int sample_rate, |
| 102 int number_of_channels, | 107 int number_of_channels, |
| 103 int frames_per_buffer); | 108 int frames_per_buffer); |
| 104 | 109 |
| 105 // Called by ProcessAndConsumeData(). | 110 // Called by ProcessAndConsumeData(). |
| 106 void ProcessData(webrtc::AudioFrame* audio_frame, | 111 // Returns the new microphone volume in the range of |0, 255]. |
| 107 base::TimeDelta capture_delay, | 112 // When the volume does not need to be updated, it returns 0. |
| 108 int volume, | 113 int ProcessData(webrtc::AudioFrame* audio_frame, |
| 109 bool key_pressed); | 114 base::TimeDelta capture_delay, |
| 115 int volume, | |
| 116 bool key_pressed); | |
| 110 | 117 |
| 111 // Called when the processor is going away. | 118 // Called when the processor is going away. |
| 112 void StopAudioProcessing(); | 119 void StopAudioProcessing(); |
| 113 | 120 |
| 114 // Cached value for the render delay latency. This member is accessed by | 121 // Cached value for the render delay latency. This member is accessed by |
| 115 // both the capture audio thread and the render audio thread. | 122 // both the capture audio thread and the render audio thread. |
| 116 base::subtle::Atomic32 render_delay_ms_; | 123 base::subtle::Atomic32 render_delay_ms_; |
| 117 | 124 |
| 118 // webrtc::AudioProcessing module which does AEC, AGC, NS, HighPass filter, | 125 // webrtc::AudioProcessing module which does AEC, AGC, NS, HighPass filter, |
| 119 // ..etc. | 126 // ..etc. |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 136 scoped_ptr<media::AudioBus> render_data_bus_; | 143 scoped_ptr<media::AudioBus> render_data_bus_; |
| 137 | 144 |
| 138 // Used to DCHECK that some methods are called on the main render thread. | 145 // Used to DCHECK that some methods are called on the main render thread. |
| 139 base::ThreadChecker main_thread_checker_; | 146 base::ThreadChecker main_thread_checker_; |
| 140 | 147 |
| 141 // Used to DCHECK that some methods are called on the capture audio thread. | 148 // Used to DCHECK that some methods are called on the capture audio thread. |
| 142 base::ThreadChecker capture_thread_checker_; | 149 base::ThreadChecker capture_thread_checker_; |
| 143 | 150 |
| 144 // Used to DCHECK that PushRenderData() is called on the render audio thread. | 151 // Used to DCHECK that PushRenderData() is called on the render audio thread. |
| 145 base::ThreadChecker render_thread_checker_; | 152 base::ThreadChecker render_thread_checker_; |
| 153 | |
| 154 // Flag to enable the stereo channels swapping. | |
| 155 bool stereo_channels_swapping_; | |
|
tommi (sloooow) - chröme
2014/01/21 15:06:20
nit: audio_mirroring_
no longer working on chromium
2014/01/23 12:46:08
Done.
| |
| 146 }; | 156 }; |
| 147 | 157 |
| 148 } // namespace content | 158 } // namespace content |
| 149 | 159 |
| 150 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_H_ | 160 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_H_ |
| OLD | NEW |