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 #include "content/renderer/media/webrtc_audio_device_impl.h" | 5 #include "content/renderer/media/webrtc_audio_device_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 DCHECK_EQ(audio_bus->frames() % frames_per_10_ms, 0); | 143 DCHECK_EQ(audio_bus->frames() % frames_per_10_ms, 0); |
144 | 144 |
145 // Get audio frames in blocks of 10 milliseconds from the registered | 145 // Get audio frames in blocks of 10 milliseconds from the registered |
146 // webrtc::AudioTransport source. Keep reading until our internal buffer | 146 // webrtc::AudioTransport source. Keep reading until our internal buffer |
147 // is full. | 147 // is full. |
148 uint32_t num_audio_frames = 0; | 148 uint32_t num_audio_frames = 0; |
149 int accumulated_audio_frames = 0; | 149 int accumulated_audio_frames = 0; |
150 int16* audio_data = &render_buffer_[0]; | 150 int16* audio_data = &render_buffer_[0]; |
151 while (accumulated_audio_frames < audio_bus->frames()) { | 151 while (accumulated_audio_frames < audio_bus->frames()) { |
152 // Get 10ms and append output to temporary byte buffer. | 152 // Get 10ms and append output to temporary byte buffer. |
| 153 uint32_t rtp_ts = 0; |
| 154 int64_t ntp_ts = 0; |
153 if (is_audio_track_processing_enabled_) { | 155 if (is_audio_track_processing_enabled_) { |
154 // When audio processing is enabled in the audio track, we use | 156 // When audio processing is enabled in the audio track, we use |
155 // PullRenderData() instead of NeedMorePlayData() to avoid passing the | 157 // PullRenderData() instead of NeedMorePlayData() to avoid passing the |
156 // render data to the APM in WebRTC as reference signal for echo | 158 // render data to the APM in WebRTC as reference signal for echo |
157 // cancellation. | 159 // cancellation. |
158 static const int kBitsPerByte = 8; | 160 static const int kBitsPerByte = 8; |
159 audio_transport_callback_->PullRenderData(bytes_per_sample * kBitsPerByte, | 161 audio_transport_callback_->PullRenderData(bytes_per_sample * kBitsPerByte, |
160 sample_rate, | 162 sample_rate, |
161 audio_bus->channels(), | 163 audio_bus->channels(), |
162 frames_per_10_ms, | 164 frames_per_10_ms, |
163 audio_data); | 165 audio_data, |
| 166 &rtp_ts, |
| 167 &ntp_ts); |
164 accumulated_audio_frames += frames_per_10_ms; | 168 accumulated_audio_frames += frames_per_10_ms; |
165 } else { | 169 } else { |
166 // TODO(xians): Remove the following code after the APM in WebRTC is | 170 // TODO(xians): Remove the following code after the APM in WebRTC is |
167 // deprecated. | 171 // deprecated. |
168 audio_transport_callback_->NeedMorePlayData(frames_per_10_ms, | 172 audio_transport_callback_->NeedMorePlayData(frames_per_10_ms, |
169 bytes_per_sample, | 173 bytes_per_sample, |
170 audio_bus->channels(), | 174 audio_bus->channels(), |
171 sample_rate, | 175 sample_rate, |
172 audio_data, | 176 audio_data, |
173 num_audio_frames); | 177 num_audio_frames, |
| 178 &rtp_ts, |
| 179 &ntp_ts); |
174 accumulated_audio_frames += num_audio_frames; | 180 accumulated_audio_frames += num_audio_frames; |
175 } | 181 } |
176 | 182 |
177 audio_data += bytes_per_10_ms; | 183 audio_data += bytes_per_10_ms; |
178 } | 184 } |
179 | 185 |
180 // De-interleave each channel and convert to 32-bit floating-point | 186 // De-interleave each channel and convert to 32-bit floating-point |
181 // with nominal range -1.0 -> +1.0 to match the callback format. | 187 // with nominal range -1.0 -> +1.0 to match the callback format. |
182 audio_bus->FromInterleaved(&render_buffer_[0], | 188 audio_bus->FromInterleaved(&render_buffer_[0], |
183 audio_bus->frames(), | 189 audio_bus->frames(), |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 | 552 |
547 // Start the Aec dump on the current default capturer. | 553 // Start the Aec dump on the current default capturer. |
548 scoped_refptr<WebRtcAudioCapturer> default_capturer(GetDefaultCapturer()); | 554 scoped_refptr<WebRtcAudioCapturer> default_capturer(GetDefaultCapturer()); |
549 if (!default_capturer) | 555 if (!default_capturer) |
550 return; | 556 return; |
551 | 557 |
552 default_capturer->StartAecDump(aec_dump_file_.Pass()); | 558 default_capturer->StartAecDump(aec_dump_file_.Pass()); |
553 } | 559 } |
554 | 560 |
555 } // namespace content | 561 } // namespace content |
OLD | NEW |