| 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/files/file.h" | 9 #include "base/files/file.h" |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| 11 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
| 12 #include "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
| 15 #include "content/public/common/media_stream_request.h" | 15 #include "content/public/common/media_stream_request.h" |
| 16 #include "content/renderer/media/aec_dump_message_filter.h" | 16 #include "content/renderer/media/audio_debug_recorder.h" |
| 17 #include "content/renderer/media/webrtc_audio_device_impl.h" | 17 #include "content/renderer/media/webrtc_audio_device_impl.h" |
| 18 #include "media/base/audio_converter.h" | 18 #include "media/base/audio_converter.h" |
| 19 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" | 19 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" |
| 20 #include "third_party/webrtc/modules/audio_processing/include/audio_processing.h
" | 20 #include "third_party/webrtc/modules/audio_processing/include/audio_processing.h
" |
| 21 | 21 |
| 22 namespace blink { | 22 namespace blink { |
| 23 class WebMediaConstraints; | 23 class WebMediaConstraints; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace media { | 26 namespace media { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 39 class MediaStreamAudioBus; | 39 class MediaStreamAudioBus; |
| 40 class MediaStreamAudioFifo; | 40 class MediaStreamAudioFifo; |
| 41 class RTCMediaConstraints; | 41 class RTCMediaConstraints; |
| 42 | 42 |
| 43 using webrtc::AudioProcessorInterface; | 43 using webrtc::AudioProcessorInterface; |
| 44 | 44 |
| 45 // This class owns an object of webrtc::AudioProcessing which contains signal | 45 // This class owns an object of webrtc::AudioProcessing which contains signal |
| 46 // processing components like AGC, AEC and NS. It enables the components based | 46 // processing components like AGC, AEC and NS. It enables the components based |
| 47 // on the getUserMedia constraints, processes the data and outputs it in a unit | 47 // on the getUserMedia constraints, processes the data and outputs it in a unit |
| 48 // of 10 ms data chunk. | 48 // of 10 ms data chunk. |
| 49 class CONTENT_EXPORT MediaStreamAudioProcessor : | 49 class CONTENT_EXPORT MediaStreamAudioProcessor |
| 50 NON_EXPORTED_BASE(public WebRtcPlayoutDataSource::Sink), | 50 : NON_EXPORTED_BASE(public WebRtcPlayoutDataSource::Sink), |
| 51 NON_EXPORTED_BASE(public AudioProcessorInterface), | 51 NON_EXPORTED_BASE(public AudioProcessorInterface), |
| 52 NON_EXPORTED_BASE(public AecDumpMessageFilter::AecDumpDelegate) { | 52 NON_EXPORTED_BASE(public AudioDebugRecorder::AecDumpDelegate) { |
| 53 public: | 53 public: |
| 54 // |playout_data_source| is used to register this class as a sink to the | 54 // |playout_data_source| is used to register this class as a sink to the |
| 55 // WebRtc playout data for processing AEC. If clients do not enable AEC, | 55 // WebRtc playout data for processing AEC. If clients do not enable AEC, |
| 56 // |playout_data_source| won't be used. | 56 // |playout_data_source| won't be used. |
| 57 MediaStreamAudioProcessor( | 57 MediaStreamAudioProcessor( |
| 58 const blink::WebMediaConstraints& constraints, | 58 const blink::WebMediaConstraints& constraints, |
| 59 const MediaStreamDevice::AudioDeviceParameters& input_params, | 59 const MediaStreamDevice::AudioDeviceParameters& input_params, |
| 60 WebRtcPlayoutDataSource* playout_data_source); | 60 WebRtcPlayoutDataSource* playout_data_source); |
| 61 | 61 |
| 62 // Called when the format of the capture data has changed. | 62 // Called when the format of the capture data has changed. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // The audio formats of the capture input to and output from the processor. | 97 // The audio formats of the capture input to and output from the processor. |
| 98 // Must only be called on the main render or audio capture threads. | 98 // Must only be called on the main render or audio capture threads. |
| 99 const media::AudioParameters& InputFormat() const; | 99 const media::AudioParameters& InputFormat() const; |
| 100 const media::AudioParameters& OutputFormat() const; | 100 const media::AudioParameters& OutputFormat() const; |
| 101 | 101 |
| 102 // Accessor to check if the audio processing is enabled or not. | 102 // Accessor to check if the audio processing is enabled or not. |
| 103 bool has_audio_processing() const { return audio_processing_ != NULL; } | 103 bool has_audio_processing() const { return audio_processing_ != NULL; } |
| 104 | 104 |
| 105 // AecDumpMessageFilter::AecDumpDelegate implementation. | 105 // AecDumpMessageFilter::AecDumpDelegate implementation. |
| 106 // Called on the main render thread. | 106 // Called on the main render thread. |
| 107 void OnAecDumpFile(const IPC::PlatformFileForTransit& file_handle) override; | 107 void OnAecDumpFile(base::PlatformFile file_handle) override; |
| 108 void OnDisableAecDump() override; | 108 void OnDisableAecDump() override; |
| 109 void OnIpcClosing() override; | 109 void OnIpcClosing() override; |
| 110 | 110 |
| 111 protected: | 111 protected: |
| 112 ~MediaStreamAudioProcessor() override; | 112 ~MediaStreamAudioProcessor() override; |
| 113 | 113 |
| 114 private: | 114 private: |
| 115 friend class MediaStreamAudioProcessorTest; | 115 friend class MediaStreamAudioProcessorTest; |
| 116 FRIEND_TEST_ALL_PREFIXES(MediaStreamAudioProcessorTest, | 116 FRIEND_TEST_ALL_PREFIXES(MediaStreamAudioProcessorTest, |
| 117 GetAecDumpMessageFilter); | 117 GetAudioDebugRecorder); |
| 118 | 118 |
| 119 // WebRtcPlayoutDataSource::Sink implementation. | 119 // WebRtcPlayoutDataSource::Sink implementation. |
| 120 void OnPlayoutData(media::AudioBus* audio_bus, | 120 void OnPlayoutData(media::AudioBus* audio_bus, |
| 121 int sample_rate, | 121 int sample_rate, |
| 122 int audio_delay_milliseconds) override; | 122 int audio_delay_milliseconds) override; |
| 123 void OnPlayoutDataSourceChanged() override; | 123 void OnPlayoutDataSourceChanged() override; |
| 124 | 124 |
| 125 // webrtc::AudioProcessorInterface implementation. | 125 // webrtc::AudioProcessorInterface implementation. |
| 126 // This method is called on the libjingle thread. | 126 // This method is called on the libjingle thread. |
| 127 void GetStats(AudioProcessorStats* stats) override; | 127 void GetStats(AudioProcessorStats* stats) override; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 // Flag to enable stereo channel mirroring. | 186 // Flag to enable stereo channel mirroring. |
| 187 bool audio_mirroring_; | 187 bool audio_mirroring_; |
| 188 | 188 |
| 189 scoped_ptr<webrtc::TypingDetection> typing_detector_; | 189 scoped_ptr<webrtc::TypingDetection> typing_detector_; |
| 190 // This flag is used to show the result of typing detection. | 190 // This flag is used to show the result of typing detection. |
| 191 // It can be accessed by the capture audio thread and by the libjingle thread | 191 // It can be accessed by the capture audio thread and by the libjingle thread |
| 192 // which calls GetStats(). | 192 // which calls GetStats(). |
| 193 base::subtle::Atomic32 typing_detected_; | 193 base::subtle::Atomic32 typing_detected_; |
| 194 | 194 |
| 195 // Communication with browser for AEC dump. | 195 // Communication with browser for AEC dump. |
| 196 scoped_refptr<AecDumpMessageFilter> aec_dump_message_filter_; | 196 scoped_refptr<AudioDebugRecorder> audio_debug_recorder_; |
| 197 | 197 |
| 198 // Flag to avoid executing Stop() more than once. | 198 // Flag to avoid executing Stop() more than once. |
| 199 bool stopped_; | 199 bool stopped_; |
| 200 | 200 |
| 201 // Object for logging echo information when the AEC is enabled. Accessible by | 201 // Object for logging echo information when the AEC is enabled. Accessible by |
| 202 // the libjingle thread through GetStats(). | 202 // the libjingle thread through GetStats(). |
| 203 scoped_ptr<EchoInformation> echo_information_; | 203 scoped_ptr<EchoInformation> echo_information_; |
| 204 | 204 |
| 205 DISALLOW_COPY_AND_ASSIGN(MediaStreamAudioProcessor); | 205 DISALLOW_COPY_AND_ASSIGN(MediaStreamAudioProcessor); |
| 206 }; | 206 }; |
| 207 | 207 |
| 208 } // namespace content | 208 } // namespace content |
| 209 | 209 |
| 210 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_H_ | 210 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_H_ |
| OLD | NEW |