OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 << " codec freq = " << _codec.plfreq | 119 << " codec freq = " << _codec.plfreq |
120 << ", wanted freq = " << frequencyInHz; | 120 << ", wanted freq = " << frequencyInHz; |
121 return -1; | 121 return -1; |
122 } | 122 } |
123 | 123 |
124 AudioFrame unresampledAudioFrame; | 124 AudioFrame unresampledAudioFrame; |
125 if (STR_CASE_CMP(_codec.plname, "L16") == 0) { | 125 if (STR_CASE_CMP(_codec.plname, "L16") == 0) { |
126 unresampledAudioFrame.sample_rate_hz_ = _codec.plfreq; | 126 unresampledAudioFrame.sample_rate_hz_ = _codec.plfreq; |
127 | 127 |
128 // L16 is un-encoded data. Just pull 10 ms. | 128 // L16 is un-encoded data. Just pull 10 ms. |
129 size_t lengthInBytes = sizeof(unresampledAudioFrame.data_); | 129 size_t lengthInBytes = AudioFrame::kMaxDataSizeBytes; |
130 if (_fileModule.PlayoutAudioData( | 130 if (_fileModule.PlayoutAudioData( |
131 reinterpret_cast<int8_t*>(unresampledAudioFrame.data_), | 131 reinterpret_cast<int8_t*>(unresampledAudioFrame.mutable_data()), |
132 lengthInBytes) == -1) { | 132 lengthInBytes) == -1) { |
133 // End of file reached. | 133 // End of file reached. |
134 return -1; | 134 return -1; |
135 } | 135 } |
136 if (lengthInBytes == 0) { | 136 if (lengthInBytes == 0) { |
137 *lengthInSamples = 0; | 137 *lengthInSamples = 0; |
138 return 0; | 138 return 0; |
139 } | 139 } |
140 // One sample is two bytes. | 140 // One sample is two bytes. |
141 unresampledAudioFrame.samples_per_channel_ = lengthInBytes >> 1; | 141 unresampledAudioFrame.samples_per_channel_ = lengthInBytes >> 1; |
(...skipping 24 matching lines...) Expand all Loading... |
166 size_t outLen = 0; | 166 size_t outLen = 0; |
167 if (_resampler.ResetIfNeeded(unresampledAudioFrame.sample_rate_hz_, | 167 if (_resampler.ResetIfNeeded(unresampledAudioFrame.sample_rate_hz_, |
168 frequencyInHz, 1)) { | 168 frequencyInHz, 1)) { |
169 LOG(LS_WARNING) << "Get10msAudioFromFile() unexpected codec."; | 169 LOG(LS_WARNING) << "Get10msAudioFromFile() unexpected codec."; |
170 | 170 |
171 // New sampling frequency. Update state. | 171 // New sampling frequency. Update state. |
172 outLen = static_cast<size_t>(frequencyInHz / 100); | 172 outLen = static_cast<size_t>(frequencyInHz / 100); |
173 memset(outBuffer, 0, outLen * sizeof(int16_t)); | 173 memset(outBuffer, 0, outLen * sizeof(int16_t)); |
174 return 0; | 174 return 0; |
175 } | 175 } |
176 _resampler.Push(unresampledAudioFrame.data_, | 176 _resampler.Push(unresampledAudioFrame.data(), |
177 unresampledAudioFrame.samples_per_channel_, outBuffer, | 177 unresampledAudioFrame.samples_per_channel_, outBuffer, |
178 MAX_AUDIO_BUFFER_IN_SAMPLES, outLen); | 178 MAX_AUDIO_BUFFER_IN_SAMPLES, outLen); |
179 | 179 |
180 *lengthInSamples = outLen; | 180 *lengthInSamples = outLen; |
181 | 181 |
182 if (_scaling != 1.0) { | 182 if (_scaling != 1.0) { |
183 for (size_t i = 0; i < outLen; i++) { | 183 for (size_t i = 0; i < outLen; i++) { |
184 outBuffer[i] = (int16_t)(outBuffer[i] * _scaling); | 184 outBuffer[i] = (int16_t)(outBuffer[i] * _scaling); |
185 } | 185 } |
186 } | 186 } |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 // audio formats | 382 // audio formats |
383 return std::unique_ptr<FilePlayer>( | 383 return std::unique_ptr<FilePlayer>( |
384 new FilePlayerImpl(instanceID, fileFormat)); | 384 new FilePlayerImpl(instanceID, fileFormat)); |
385 default: | 385 default: |
386 assert(false); | 386 assert(false); |
387 return nullptr; | 387 return nullptr; |
388 } | 388 } |
389 } | 389 } |
390 | 390 |
391 } // namespace webrtc | 391 } // namespace webrtc |
OLD | NEW |