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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 << " codec freq = " << _codec.plfreq | 120 << " codec freq = " << _codec.plfreq |
121 << ", wanted freq = " << frequencyInHz; | 121 << ", wanted freq = " << frequencyInHz; |
122 return -1; | 122 return -1; |
123 } | 123 } |
124 | 124 |
125 AudioFrame unresampledAudioFrame; | 125 AudioFrame unresampledAudioFrame; |
126 if (STR_CASE_CMP(_codec.plname, "L16") == 0) { | 126 if (STR_CASE_CMP(_codec.plname, "L16") == 0) { |
127 unresampledAudioFrame.sample_rate_hz_ = _codec.plfreq; | 127 unresampledAudioFrame.sample_rate_hz_ = _codec.plfreq; |
128 | 128 |
129 // L16 is un-encoded data. Just pull 10 ms. | 129 // L16 is un-encoded data. Just pull 10 ms. |
130 size_t lengthInBytes = sizeof(unresampledAudioFrame.data_); | 130 size_t lengthInBytes = AudioFrame::kMaxDataSizeBytes; |
131 if (_fileModule.PlayoutAudioData( | 131 if (_fileModule.PlayoutAudioData( |
132 reinterpret_cast<int8_t*>(unresampledAudioFrame.data_), | 132 reinterpret_cast<int8_t*>(unresampledAudioFrame.mutable_data()), |
133 lengthInBytes) == -1) { | 133 lengthInBytes) == -1) { |
134 // End of file reached. | 134 // End of file reached. |
135 return -1; | 135 return -1; |
136 } | 136 } |
137 if (lengthInBytes == 0) { | 137 if (lengthInBytes == 0) { |
138 *lengthInSamples = 0; | 138 *lengthInSamples = 0; |
139 return 0; | 139 return 0; |
140 } | 140 } |
141 // One sample is two bytes. | 141 // One sample is two bytes. |
142 unresampledAudioFrame.samples_per_channel_ = lengthInBytes >> 1; | 142 unresampledAudioFrame.samples_per_channel_ = lengthInBytes >> 1; |
(...skipping 24 matching lines...) Expand all Loading... |
167 size_t outLen = 0; | 167 size_t outLen = 0; |
168 if (_resampler.ResetIfNeeded(unresampledAudioFrame.sample_rate_hz_, | 168 if (_resampler.ResetIfNeeded(unresampledAudioFrame.sample_rate_hz_, |
169 frequencyInHz, 1)) { | 169 frequencyInHz, 1)) { |
170 LOG(LS_WARNING) << "Get10msAudioFromFile() unexpected codec."; | 170 LOG(LS_WARNING) << "Get10msAudioFromFile() unexpected codec."; |
171 | 171 |
172 // New sampling frequency. Update state. | 172 // New sampling frequency. Update state. |
173 outLen = static_cast<size_t>(frequencyInHz / 100); | 173 outLen = static_cast<size_t>(frequencyInHz / 100); |
174 memset(outBuffer, 0, outLen * sizeof(int16_t)); | 174 memset(outBuffer, 0, outLen * sizeof(int16_t)); |
175 return 0; | 175 return 0; |
176 } | 176 } |
177 _resampler.Push(unresampledAudioFrame.data_, | 177 _resampler.Push(unresampledAudioFrame.data(), |
178 unresampledAudioFrame.samples_per_channel_, outBuffer, | 178 unresampledAudioFrame.samples_per_channel_, outBuffer, |
179 MAX_AUDIO_BUFFER_IN_SAMPLES, outLen); | 179 MAX_AUDIO_BUFFER_IN_SAMPLES, outLen); |
180 | 180 |
181 *lengthInSamples = outLen; | 181 *lengthInSamples = outLen; |
182 | 182 |
183 if (_scaling != 1.0) { | 183 if (_scaling != 1.0) { |
184 for (size_t i = 0; i < outLen; i++) { | 184 for (size_t i = 0; i < outLen; i++) { |
185 outBuffer[i] = (int16_t)(outBuffer[i] * _scaling); | 185 outBuffer[i] = (int16_t)(outBuffer[i] * _scaling); |
186 } | 186 } |
187 } | 187 } |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 // audio formats | 383 // audio formats |
384 return std::unique_ptr<FilePlayer>( | 384 return std::unique_ptr<FilePlayer>( |
385 new FilePlayerImpl(instanceID, fileFormat)); | 385 new FilePlayerImpl(instanceID, fileFormat)); |
386 default: | 386 default: |
387 assert(false); | 387 assert(false); |
388 return nullptr; | 388 return nullptr; |
389 } | 389 } |
390 } | 390 } |
391 | 391 |
392 } // namespace webrtc | 392 } // namespace webrtc |
OLD | NEW |