OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_WEBRTC_AUDIO_CAPTURER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_CAPTURER_H_ |
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_CAPTURER_H_ | 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_CAPTURER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 98 |
99 const std::string& device_id() const { return device_info_.device.id; } | 99 const std::string& device_id() const { return device_info_.device.id; } |
100 int session_id() const { return device_info_.session_id; } | 100 int session_id() const { return device_info_.session_id; } |
101 | 101 |
102 // Stops recording audio. This method will empty its track lists since | 102 // Stops recording audio. This method will empty its track lists since |
103 // stopping the capturer will implicitly invalidate all its tracks. | 103 // stopping the capturer will implicitly invalidate all its tracks. |
104 // This method is exposed to the public because the MediaStreamAudioSource can | 104 // This method is exposed to the public because the MediaStreamAudioSource can |
105 // call Stop() | 105 // call Stop() |
106 void Stop(); | 106 void Stop(); |
107 | 107 |
108 // Called by the WebAudioCapturerSource to get the audio processing params. | |
109 // This function is triggered by provideInput() on the WebAudio audio thread, | |
110 // TODO(xians): Remove after moving APM from WebRtc to Chrome. | |
111 void GetAudioProcessingParams(base::TimeDelta* delay, int* volume, | |
112 bool* key_pressed); | |
113 | |
114 // Used by the unittests to inject their own source to the capturer. | 108 // Used by the unittests to inject their own source to the capturer. |
115 void SetCapturerSourceForTesting( | 109 void SetCapturerSourceForTesting( |
116 const scoped_refptr<media::AudioCapturerSource>& source, | 110 const scoped_refptr<media::AudioCapturerSource>& source, |
117 media::AudioParameters params); | 111 media::AudioParameters params); |
118 | 112 |
119 protected: | 113 protected: |
120 friend class base::RefCountedThreadSafe<WebRtcAudioCapturer>; | 114 friend class base::RefCountedThreadSafe<WebRtcAudioCapturer>; |
121 ~WebRtcAudioCapturer() override; | 115 ~WebRtcAudioCapturer() override; |
122 | 116 |
123 private: | 117 private: |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 // Cached information of the device used by the capturer. | 183 // Cached information of the device used by the capturer. |
190 const StreamDeviceInfo device_info_; | 184 const StreamDeviceInfo device_info_; |
191 | 185 |
192 // Stores latest microphone volume received in a CaptureData() callback. | 186 // Stores latest microphone volume received in a CaptureData() callback. |
193 // Range is [0, 255]. | 187 // Range is [0, 255]. |
194 int volume_; | 188 int volume_; |
195 | 189 |
196 // Flag which affects the buffer size used by the capturer. | 190 // Flag which affects the buffer size used by the capturer. |
197 bool peer_connection_mode_; | 191 bool peer_connection_mode_; |
198 | 192 |
199 // Cache value for the audio processing params. | |
200 base::TimeDelta audio_delay_; | |
201 bool key_pressed_; | |
202 | |
203 // Flag to help deciding if the data needs audio processing. | |
204 bool need_audio_processing_; | |
205 | |
206 // Raw pointer to the WebRtcAudioDeviceImpl, which is valid for the lifetime | 193 // Raw pointer to the WebRtcAudioDeviceImpl, which is valid for the lifetime |
207 // of RenderThread. | 194 // of RenderThread. |
208 WebRtcAudioDeviceImpl* audio_device_; | 195 WebRtcAudioDeviceImpl* audio_device_; |
209 | 196 |
210 // Raw pointer to the MediaStreamAudioSource object that holds a reference | 197 // Raw pointer to the MediaStreamAudioSource object that holds a reference |
211 // to this WebRtcAudioCapturer. | 198 // to this WebRtcAudioCapturer. |
212 // Since |audio_source_| is owned by a blink::WebMediaStreamSource object and | 199 // Since |audio_source_| is owned by a blink::WebMediaStreamSource object and |
213 // blink guarantees that the blink::WebMediaStreamSource outlives any | 200 // blink guarantees that the blink::WebMediaStreamSource outlives any |
214 // blink::WebMediaStreamTrack connected to the source, |audio_source_| is | 201 // blink::WebMediaStreamTrack connected to the source, |audio_source_| is |
215 // guaranteed to exist as long as a WebRtcLocalAudioTrack is connected to this | 202 // guaranteed to exist as long as a WebRtcLocalAudioTrack is connected to this |
216 // WebRtcAudioCapturer. | 203 // WebRtcAudioCapturer. |
217 MediaStreamAudioSource* const audio_source_; | 204 MediaStreamAudioSource* const audio_source_; |
218 | 205 |
219 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioCapturer); | 206 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioCapturer); |
220 }; | 207 }; |
221 | 208 |
222 } // namespace content | 209 } // namespace content |
223 | 210 |
224 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_CAPTURER_H_ | 211 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_CAPTURER_H_ |
OLD | NEW |