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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 if (is_audio_track_processing_enabled_) { | 153 if (is_audio_track_processing_enabled_) { |
154 // When audio processing is enabled in the audio track, we use | 154 // When audio processing is enabled in the audio track, we use |
155 // PullRenderData() instead of NeedMorePlayData() to avoid passing the | 155 // PullRenderData() instead of NeedMorePlayData() to avoid passing the |
156 // render data to the APM in WebRTC as reference signal for echo | 156 // render data to the APM in WebRTC as reference signal for echo |
157 // cancellation. | 157 // cancellation. |
158 static const int kBitsPerByte = 8; | 158 static const int kBitsPerByte = 8; |
159 uint32_t rtp_ts = 0; | |
160 int64_t ntp_ts = 0; | |
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. |
172 uint32_t rtp_ts = 0; | |
173 int64_t ntp_ts = 0; | |
wjia(left Chromium)
2014/05/19 17:56:26
How about moving these 2 lines above "if" line to
Ronghua Wu (Left Chromium)
2014/05/19 17:58:11
Good idea. Done
| |
168 audio_transport_callback_->NeedMorePlayData(frames_per_10_ms, | 174 audio_transport_callback_->NeedMorePlayData(frames_per_10_ms, |
169 bytes_per_sample, | 175 bytes_per_sample, |
170 audio_bus->channels(), | 176 audio_bus->channels(), |
171 sample_rate, | 177 sample_rate, |
172 audio_data, | 178 audio_data, |
173 num_audio_frames); | 179 num_audio_frames, |
180 &rtp_ts, | |
181 &ntp_ts); | |
174 accumulated_audio_frames += num_audio_frames; | 182 accumulated_audio_frames += num_audio_frames; |
175 } | 183 } |
176 | 184 |
177 audio_data += bytes_per_10_ms; | 185 audio_data += bytes_per_10_ms; |
178 } | 186 } |
179 | 187 |
180 // De-interleave each channel and convert to 32-bit floating-point | 188 // De-interleave each channel and convert to 32-bit floating-point |
181 // with nominal range -1.0 -> +1.0 to match the callback format. | 189 // with nominal range -1.0 -> +1.0 to match the callback format. |
182 audio_bus->FromInterleaved(&render_buffer_[0], | 190 audio_bus->FromInterleaved(&render_buffer_[0], |
183 audio_bus->frames(), | 191 audio_bus->frames(), |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
546 | 554 |
547 // Start the Aec dump on the current default capturer. | 555 // Start the Aec dump on the current default capturer. |
548 scoped_refptr<WebRtcAudioCapturer> default_capturer(GetDefaultCapturer()); | 556 scoped_refptr<WebRtcAudioCapturer> default_capturer(GetDefaultCapturer()); |
549 if (!default_capturer) | 557 if (!default_capturer) |
550 return; | 558 return; |
551 | 559 |
552 default_capturer->StartAecDump(aec_dump_file_.Pass()); | 560 default_capturer->StartAecDump(aec_dump_file_.Pass()); |
553 } | 561 } |
554 | 562 |
555 } // namespace content | 563 } // namespace content |
OLD | NEW |