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/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
10 #include "base/threading/thread_checker.h" | 11 #include "base/threading/thread_checker.h" |
11 #include "base/time/time.h" | 12 #include "base/time/time.h" |
12 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
13 #include "content/renderer/media/webrtc_audio_device_impl.h" | 14 #include "content/renderer/media/webrtc_audio_device_impl.h" |
14 #include "media/base/audio_converter.h" | 15 #include "media/base/audio_converter.h" |
15 #include "third_party/webrtc/modules/audio_processing/include/audio_processing.h " | 16 #include "third_party/webrtc/modules/audio_processing/include/audio_processing.h " |
16 #include "third_party/webrtc/modules/interface/module_common_types.h" | 17 #include "third_party/webrtc/modules/interface/module_common_types.h" |
17 | 18 |
18 namespace blink { | 19 namespace blink { |
(...skipping 19 matching lines...) Expand all Loading... | |
38 // processing components like AGC, AEC and NS. It enables the components based | 39 // processing components like AGC, AEC and NS. It enables the components based |
39 // on the getUserMedia constraints, processes the data and outputs it in a unit | 40 // on the getUserMedia constraints, processes the data and outputs it in a unit |
40 // of 10 ms data chunk. | 41 // of 10 ms data chunk. |
41 class CONTENT_EXPORT MediaStreamAudioProcessor : | 42 class CONTENT_EXPORT MediaStreamAudioProcessor : |
42 public base::RefCountedThreadSafe<MediaStreamAudioProcessor>, | 43 public base::RefCountedThreadSafe<MediaStreamAudioProcessor>, |
43 NON_EXPORTED_BASE(public WebRtcPlayoutDataSource::Sink) { | 44 NON_EXPORTED_BASE(public WebRtcPlayoutDataSource::Sink) { |
44 public: | 45 public: |
45 // |playout_data_source| is used to register this class as a sink to the | 46 // |playout_data_source| is used to register this class as a sink to the |
46 // WebRtc playout data for processing AEC. If clients do not enable AEC, | 47 // WebRtc playout data for processing AEC. If clients do not enable AEC, |
47 // |playout_data_source| won't be used. | 48 // |playout_data_source| won't be used. |
48 MediaStreamAudioProcessor(const media::AudioParameters& source_params, | 49 MediaStreamAudioProcessor(const blink::WebMediaConstraints& constraints, |
49 const blink::WebMediaConstraints& constraints, | |
50 int effects, | 50 int effects, |
51 WebRtcPlayoutDataSource* playout_data_source); | 51 WebRtcPlayoutDataSource* playout_data_source); |
52 | 52 |
53 // Called when format of the capture data has changed. | |
54 // Called on the main render thread. The caller is responsible fo | |
Henrik Grunell
2014/03/07 09:14:57
Ooo, now I'm curious! :) Responsible for what? Wor
no longer working on chromium
2014/03/07 10:14:54
Done.
| |
55 void OnCaptureFormatChanged(const media::AudioParameters& source_params); | |
Henrik Grunell
2014/03/06 19:55:12
Why is this needed in this CL?
no longer working on chromium
2014/03/06 20:00:36
It is needed in order not to create a new processo
| |
56 | |
53 // Pushes capture data in |audio_source| to the internal FIFO. | 57 // Pushes capture data in |audio_source| to the internal FIFO. |
54 // Called on the capture audio thread. | 58 // Called on the capture audio thread. |
55 void PushCaptureData(media::AudioBus* audio_source); | 59 void PushCaptureData(media::AudioBus* audio_source); |
56 | 60 |
57 // 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 |
58 // |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 |
59 // 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 |
60 // 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. |
61 // 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. |
62 // |new_volume| receives the new microphone volume from the AGC. | 66 // |new_volume| receives the new microphone volume from the AGC. |
63 // The new microphoen volume range is [0, 255], and the value will be 0 if | 67 // The new microphoen volume range is [0, 255], and the value will be 0 if |
64 // the microphone volume should not be adjusted. | 68 // the microphone volume should not be adjusted. |
65 // Returns true if the internal FIFO has at least 10 ms data for processing, | 69 // Returns true if the internal FIFO has at least 10 ms data for processing, |
66 // otherwise false. | 70 // otherwise false. |
67 // |capture_delay|, |volume| and |key_pressed| will be passed to | 71 // |capture_delay|, |volume| and |key_pressed| will be passed to |
68 // webrtc::AudioProcessing to help processing the data. | 72 // webrtc::AudioProcessing to help processing the data. |
69 // Called on the capture audio thread. | 73 // Called on the capture audio thread. |
70 bool ProcessAndConsumeData(base::TimeDelta capture_delay, | 74 bool ProcessAndConsumeData(base::TimeDelta capture_delay, |
71 int volume, | 75 int volume, |
72 bool key_pressed, | 76 bool key_pressed, |
73 int* new_volume, | 77 int* new_volume, |
74 int16** out); | 78 int16** out); |
75 | 79 |
76 | |
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 |
89 // Starts/Stops the Aec dump on the |audio_processing_|. | |
90 // Called on the main render thread. | |
91 // This method takes the ownership of |aec_dump_file|. | |
92 void StartAecDump(const base::PlatformFile& aec_dump_file); | |
93 void StopAecDump(); | |
94 | |
86 protected: | 95 protected: |
87 friend class base::RefCountedThreadSafe<MediaStreamAudioProcessor>; | 96 friend class base::RefCountedThreadSafe<MediaStreamAudioProcessor>; |
88 virtual ~MediaStreamAudioProcessor(); | 97 virtual ~MediaStreamAudioProcessor(); |
89 | 98 |
90 private: | 99 private: |
91 friend class MediaStreamAudioProcessorTest; | 100 friend class MediaStreamAudioProcessorTest; |
92 | 101 |
93 class MediaStreamAudioConverter; | 102 class MediaStreamAudioConverter; |
94 | 103 |
95 // WebRtcPlayoutDataSource::Sink implementation. | 104 // WebRtcPlayoutDataSource::Sink implementation. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 // Used by the typing detection. | 173 // Used by the typing detection. |
165 scoped_ptr<webrtc::TypingDetection> typing_detector_; | 174 scoped_ptr<webrtc::TypingDetection> typing_detector_; |
166 | 175 |
167 // Result from the typing detection. | 176 // Result from the typing detection. |
168 bool typing_detected_; | 177 bool typing_detected_; |
169 }; | 178 }; |
170 | 179 |
171 } // namespace content | 180 } // namespace content |
172 | 181 |
173 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_H_ | 182 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_H_ |
OLD | NEW |