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/platform_file.h" | 9 #include "base/platform_file.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
11 #include "base/threading/thread_checker.h" | 11 #include "base/threading/thread_checker.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
14 #include "content/public/common/media_stream_request.h" | |
15 #include "content/renderer/media/webrtc_audio_device_impl.h" | 14 #include "content/renderer/media/webrtc_audio_device_impl.h" |
16 #include "media/base/audio_converter.h" | 15 #include "media/base/audio_converter.h" |
17 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" | 16 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" |
18 #include "third_party/webrtc/modules/audio_processing/include/audio_processing.h
" | 17 #include "third_party/webrtc/modules/audio_processing/include/audio_processing.h
" |
19 #include "third_party/webrtc/modules/interface/module_common_types.h" | 18 #include "third_party/webrtc/modules/interface/module_common_types.h" |
20 | 19 |
21 namespace blink { | 20 namespace blink { |
22 class WebMediaConstraints; | 21 class WebMediaConstraints; |
23 } | 22 } |
24 | 23 |
(...skipping 20 matching lines...) Expand all Loading... |
45 // of 10 ms data chunk. | 44 // of 10 ms data chunk. |
46 class CONTENT_EXPORT MediaStreamAudioProcessor : | 45 class CONTENT_EXPORT MediaStreamAudioProcessor : |
47 NON_EXPORTED_BASE(public WebRtcPlayoutDataSource::Sink), | 46 NON_EXPORTED_BASE(public WebRtcPlayoutDataSource::Sink), |
48 NON_EXPORTED_BASE(public AudioProcessorInterface) { | 47 NON_EXPORTED_BASE(public AudioProcessorInterface) { |
49 public: | 48 public: |
50 // |playout_data_source| is used to register this class as a sink to the | 49 // |playout_data_source| is used to register this class as a sink to the |
51 // WebRtc playout data for processing AEC. If clients do not enable AEC, | 50 // WebRtc playout data for processing AEC. If clients do not enable AEC, |
52 // |playout_data_source| won't be used. | 51 // |playout_data_source| won't be used. |
53 MediaStreamAudioProcessor(const blink::WebMediaConstraints& constraints, | 52 MediaStreamAudioProcessor(const blink::WebMediaConstraints& constraints, |
54 int effects, | 53 int effects, |
55 MediaStreamType type, | |
56 WebRtcPlayoutDataSource* playout_data_source); | 54 WebRtcPlayoutDataSource* playout_data_source); |
57 | 55 |
58 // Called when format of the capture data has changed. | 56 // Called when format of the capture data has changed. |
59 // Called on the main render thread. The caller is responsible for stopping | 57 // Called on the main render thread. The caller is responsible for stopping |
60 // the capture thread before calling this method. | 58 // the capture thread before calling this method. |
61 // After this method, the capture thread will be changed to a new capture | 59 // After this method, the capture thread will be changed to a new capture |
62 // thread. | 60 // thread. |
63 void OnCaptureFormatChanged(const media::AudioParameters& source_params); | 61 void OnCaptureFormatChanged(const media::AudioParameters& source_params); |
64 | 62 |
65 // Pushes capture data in |audio_source| to the internal FIFO. | 63 // Pushes capture data in |audio_source| to the internal FIFO. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 int sample_rate, | 114 int sample_rate, |
117 int audio_delay_milliseconds) OVERRIDE; | 115 int audio_delay_milliseconds) OVERRIDE; |
118 virtual void OnPlayoutDataSourceChanged() OVERRIDE; | 116 virtual void OnPlayoutDataSourceChanged() OVERRIDE; |
119 | 117 |
120 // webrtc::AudioProcessorInterface implementation. | 118 // webrtc::AudioProcessorInterface implementation. |
121 // This method is called on the libjingle thread. | 119 // This method is called on the libjingle thread. |
122 virtual void GetStats(AudioProcessorStats* stats) OVERRIDE; | 120 virtual void GetStats(AudioProcessorStats* stats) OVERRIDE; |
123 | 121 |
124 // Helper to initialize the WebRtc AudioProcessing. | 122 // Helper to initialize the WebRtc AudioProcessing. |
125 void InitializeAudioProcessingModule( | 123 void InitializeAudioProcessingModule( |
126 const blink::WebMediaConstraints& constraints, int effects, | 124 const blink::WebMediaConstraints& constraints, int effects); |
127 MediaStreamType type); | |
128 | 125 |
129 // Helper to initialize the capture converter. | 126 // Helper to initialize the capture converter. |
130 void InitializeCaptureConverter(const media::AudioParameters& source_params); | 127 void InitializeCaptureConverter(const media::AudioParameters& source_params); |
131 | 128 |
132 // Helper to initialize the render converter. | 129 // Helper to initialize the render converter. |
133 void InitializeRenderConverterIfNeeded(int sample_rate, | 130 void InitializeRenderConverterIfNeeded(int sample_rate, |
134 int number_of_channels, | 131 int number_of_channels, |
135 int frames_per_buffer); | 132 int frames_per_buffer); |
136 | 133 |
137 // Called by ProcessAndConsumeData(). | 134 // Called by ProcessAndConsumeData(). |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // Used to DCHECK that the destructor is called on the main render thread. | 173 // Used to DCHECK that the destructor is called on the main render thread. |
177 base::ThreadChecker main_thread_checker_; | 174 base::ThreadChecker main_thread_checker_; |
178 | 175 |
179 // Used to DCHECK that some methods are called on the capture audio thread. | 176 // Used to DCHECK that some methods are called on the capture audio thread. |
180 base::ThreadChecker capture_thread_checker_; | 177 base::ThreadChecker capture_thread_checker_; |
181 | 178 |
182 // Used to DCHECK that PushRenderData() is called on the render audio thread. | 179 // Used to DCHECK that PushRenderData() is called on the render audio thread. |
183 base::ThreadChecker render_thread_checker_; | 180 base::ThreadChecker render_thread_checker_; |
184 | 181 |
185 // Flag to enable the stereo channels mirroring. | 182 // Flag to enable the stereo channels mirroring. |
186 bool audio_mirroring_; | 183 bool goog_audio_mirroring_; |
187 | 184 |
188 // Used by the typing detection. | 185 // Used by the typing detection. |
189 scoped_ptr<webrtc::TypingDetection> typing_detector_; | 186 scoped_ptr<webrtc::TypingDetection> typing_detector_; |
190 | 187 |
191 // This flag is used to show the result of typing detection. | 188 // This flag is used to show the result of typing detection. |
192 // It can be accessed by the capture audio thread and by the libjingle thread | 189 // It can be accessed by the capture audio thread and by the libjingle thread |
193 // which calls GetStats(). | 190 // which calls GetStats(). |
194 base::subtle::Atomic32 typing_detected_; | 191 base::subtle::Atomic32 goog_typing_detected_; |
195 }; | 192 }; |
196 | 193 |
197 } // namespace content | 194 } // namespace content |
198 | 195 |
199 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_H_ | 196 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_H_ |
OLD | NEW |