niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
mflodman@webrtc.org | 1f99280 | 2012-01-27 13:42:53 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
pbos@webrtc.org | 8b06200 | 2013-07-12 08:28:10 +0000 | [diff] [blame] | 11 | #include "webrtc/modules/utility/source/file_player_impl.h" |
asapersson@webrtc.org | 8b2ec15 | 2014-04-11 07:59:43 +0000 | [diff] [blame] | 12 | #include "webrtc/system_wrappers/interface/logging.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 14 | namespace webrtc { |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 15 | FilePlayer* FilePlayer::CreateFilePlayer(uint32_t instanceID, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 16 | FileFormats fileFormat) |
| 17 | { |
| 18 | switch(fileFormat) |
| 19 | { |
| 20 | case kFileFormatWavFile: |
| 21 | case kFileFormatCompressedFile: |
| 22 | case kFileFormatPreencodedFile: |
| 23 | case kFileFormatPcm16kHzFile: |
| 24 | case kFileFormatPcm8kHzFile: |
| 25 | case kFileFormatPcm32kHzFile: |
| 26 | // audio formats |
| 27 | return new FilePlayerImpl(instanceID, fileFormat); |
andresp@webrtc.org | e8f50df | 2015-03-02 13:07:02 +0000 | [diff] [blame] | 28 | default: |
mflodman@webrtc.org | c80d9d9 | 2012-02-06 10:11:25 +0000 | [diff] [blame] | 29 | assert(false); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 30 | return NULL; |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | void FilePlayer::DestroyFilePlayer(FilePlayer* player) |
| 35 | { |
| 36 | delete player; |
| 37 | } |
| 38 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 39 | FilePlayerImpl::FilePlayerImpl(const uint32_t instanceID, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 40 | const FileFormats fileFormat) |
| 41 | : _instanceID(instanceID), |
| 42 | _fileFormat(fileFormat), |
| 43 | _fileModule(*MediaFile::CreateMediaFile(instanceID)), |
| 44 | _decodedLengthInMS(0), |
| 45 | _audioDecoder(instanceID), |
| 46 | _codec(), |
| 47 | _numberOf10MsPerFrame(0), |
| 48 | _numberOf10MsInDecoder(0), |
henrike@webrtc.org | 6b9253e | 2012-02-15 18:48:16 +0000 | [diff] [blame] | 49 | _resampler(), |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 50 | _scaling(1.0) |
| 51 | { |
| 52 | _codec.plfreq = 0; |
| 53 | } |
| 54 | |
| 55 | FilePlayerImpl::~FilePlayerImpl() |
| 56 | { |
| 57 | MediaFile::DestroyMediaFile(&_fileModule); |
| 58 | } |
| 59 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 60 | int32_t FilePlayerImpl::Frequency() const |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 61 | { |
| 62 | if(_codec.plfreq == 0) |
| 63 | { |
| 64 | return -1; |
| 65 | } |
| 66 | // Make sure that sample rate is 8,16 or 32 kHz. E.g. WAVE files may have |
| 67 | // other sampling rates. |
| 68 | if(_codec.plfreq == 11000) |
| 69 | { |
| 70 | return 16000; |
| 71 | } |
| 72 | else if(_codec.plfreq == 22000) |
| 73 | { |
| 74 | return 32000; |
| 75 | } |
| 76 | else if(_codec.plfreq == 44000) |
| 77 | { |
| 78 | return 32000; |
| 79 | } |
| 80 | else if(_codec.plfreq == 48000) |
| 81 | { |
| 82 | return 32000; |
| 83 | } |
| 84 | else |
| 85 | { |
| 86 | return _codec.plfreq; |
| 87 | } |
| 88 | } |
| 89 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 90 | int32_t FilePlayerImpl::AudioCodec(CodecInst& audioCodec) const |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 91 | { |
| 92 | audioCodec = _codec; |
| 93 | return 0; |
| 94 | } |
| 95 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 96 | int32_t FilePlayerImpl::Get10msAudioFromFile( |
andrew@webrtc.org | e59a0ac | 2012-05-08 17:12:40 +0000 | [diff] [blame] | 97 | int16_t* outBuffer, |
| 98 | int& lengthInSamples, |
| 99 | int frequencyInHz) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 100 | { |
| 101 | if(_codec.plfreq == 0) |
| 102 | { |
asapersson@webrtc.org | 8b2ec15 | 2014-04-11 07:59:43 +0000 | [diff] [blame] | 103 | LOG(LS_WARNING) << "Get10msAudioFromFile() playing not started!" |
| 104 | << " codec freq = " << _codec.plfreq |
| 105 | << ", wanted freq = " << frequencyInHz; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 106 | return -1; |
| 107 | } |
| 108 | |
| 109 | AudioFrame unresampledAudioFrame; |
| 110 | if(STR_CASE_CMP(_codec.plname, "L16") == 0) |
| 111 | { |
andrew@webrtc.org | 63a5098 | 2012-05-02 23:56:37 +0000 | [diff] [blame] | 112 | unresampledAudioFrame.sample_rate_hz_ = _codec.plfreq; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 113 | |
| 114 | // L16 is un-encoded data. Just pull 10 ms. |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 115 | size_t lengthInBytes = |
andrew@webrtc.org | 63a5098 | 2012-05-02 23:56:37 +0000 | [diff] [blame] | 116 | sizeof(unresampledAudioFrame.data_); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 117 | if (_fileModule.PlayoutAudioData( |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 118 | (int8_t*)unresampledAudioFrame.data_, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 119 | lengthInBytes) == -1) |
| 120 | { |
| 121 | // End of file reached. |
| 122 | return -1; |
| 123 | } |
| 124 | if(lengthInBytes == 0) |
| 125 | { |
| 126 | lengthInSamples = 0; |
| 127 | return 0; |
| 128 | } |
| 129 | // One sample is two bytes. |
andrew@webrtc.org | 63a5098 | 2012-05-02 23:56:37 +0000 | [diff] [blame] | 130 | unresampledAudioFrame.samples_per_channel_ = |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 131 | (uint16_t)lengthInBytes >> 1; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 132 | |
| 133 | }else { |
| 134 | // Decode will generate 10 ms of audio data. PlayoutAudioData(..) |
| 135 | // expects a full frame. If the frame size is larger than 10 ms, |
| 136 | // PlayoutAudioData(..) data should be called proportionally less often. |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 137 | int16_t encodedBuffer[MAX_AUDIO_BUFFER_IN_SAMPLES]; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 138 | size_t encodedLengthInBytes = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 139 | if(++_numberOf10MsInDecoder >= _numberOf10MsPerFrame) |
| 140 | { |
| 141 | _numberOf10MsInDecoder = 0; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 142 | size_t bytesFromFile = sizeof(encodedBuffer); |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 143 | if (_fileModule.PlayoutAudioData((int8_t*)encodedBuffer, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 144 | bytesFromFile) == -1) |
| 145 | { |
| 146 | // End of file reached. |
| 147 | return -1; |
| 148 | } |
| 149 | encodedLengthInBytes = bytesFromFile; |
| 150 | } |
| 151 | if(_audioDecoder.Decode(unresampledAudioFrame,frequencyInHz, |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 152 | (int8_t*)encodedBuffer, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 153 | encodedLengthInBytes) == -1) |
| 154 | { |
| 155 | return -1; |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | int outLen = 0; |
andrew@webrtc.org | 63a5098 | 2012-05-02 23:56:37 +0000 | [diff] [blame] | 160 | if(_resampler.ResetIfNeeded(unresampledAudioFrame.sample_rate_hz_, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 161 | frequencyInHz, kResamplerSynchronous)) |
| 162 | { |
asapersson@webrtc.org | 8b2ec15 | 2014-04-11 07:59:43 +0000 | [diff] [blame] | 163 | LOG(LS_WARNING) << "Get10msAudioFromFile() unexpected codec."; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 164 | |
| 165 | // New sampling frequency. Update state. |
| 166 | outLen = frequencyInHz / 100; |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 167 | memset(outBuffer, 0, outLen * sizeof(int16_t)); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 168 | return 0; |
| 169 | } |
andrew@webrtc.org | 63a5098 | 2012-05-02 23:56:37 +0000 | [diff] [blame] | 170 | _resampler.Push(unresampledAudioFrame.data_, |
| 171 | unresampledAudioFrame.samples_per_channel_, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 172 | outBuffer, |
| 173 | MAX_AUDIO_BUFFER_IN_SAMPLES, |
| 174 | outLen); |
| 175 | |
| 176 | lengthInSamples = outLen; |
| 177 | |
| 178 | if(_scaling != 1.0) |
| 179 | { |
| 180 | for (int i = 0;i < outLen; i++) |
| 181 | { |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 182 | outBuffer[i] = (int16_t)(outBuffer[i] * _scaling); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 183 | } |
| 184 | } |
| 185 | _decodedLengthInMS += 10; |
| 186 | return 0; |
| 187 | } |
| 188 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 189 | int32_t FilePlayerImpl::RegisterModuleFileCallback(FileCallback* callback) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 190 | { |
| 191 | return _fileModule.SetModuleFileCallback(callback); |
| 192 | } |
| 193 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 194 | int32_t FilePlayerImpl::SetAudioScaling(float scaleFactor) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 195 | { |
| 196 | if((scaleFactor >= 0)&&(scaleFactor <= 2.0)) |
| 197 | { |
| 198 | _scaling = scaleFactor; |
| 199 | return 0; |
| 200 | } |
asapersson@webrtc.org | 8b2ec15 | 2014-04-11 07:59:43 +0000 | [diff] [blame] | 201 | LOG(LS_WARNING) << "SetAudioScaling() non-allowed scale factor."; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 202 | return -1; |
| 203 | } |
| 204 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 205 | int32_t FilePlayerImpl::StartPlayingFile(const char* fileName, |
| 206 | bool loop, |
| 207 | uint32_t startPosition, |
| 208 | float volumeScaling, |
| 209 | uint32_t notification, |
| 210 | uint32_t stopPosition, |
| 211 | const CodecInst* codecInst) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 212 | { |
| 213 | if (_fileFormat == kFileFormatPcm16kHzFile || |
| 214 | _fileFormat == kFileFormatPcm8kHzFile|| |
| 215 | _fileFormat == kFileFormatPcm32kHzFile ) |
| 216 | { |
| 217 | CodecInst codecInstL16; |
| 218 | strncpy(codecInstL16.plname,"L16",32); |
| 219 | codecInstL16.pltype = 93; |
| 220 | codecInstL16.channels = 1; |
| 221 | |
| 222 | if (_fileFormat == kFileFormatPcm8kHzFile) |
| 223 | { |
| 224 | codecInstL16.rate = 128000; |
| 225 | codecInstL16.plfreq = 8000; |
| 226 | codecInstL16.pacsize = 80; |
| 227 | |
| 228 | } else if(_fileFormat == kFileFormatPcm16kHzFile) |
| 229 | { |
| 230 | codecInstL16.rate = 256000; |
| 231 | codecInstL16.plfreq = 16000; |
| 232 | codecInstL16.pacsize = 160; |
| 233 | |
| 234 | }else if(_fileFormat == kFileFormatPcm32kHzFile) |
| 235 | { |
| 236 | codecInstL16.rate = 512000; |
| 237 | codecInstL16.plfreq = 32000; |
| 238 | codecInstL16.pacsize = 160; |
| 239 | } else |
| 240 | { |
asapersson@webrtc.org | 8b2ec15 | 2014-04-11 07:59:43 +0000 | [diff] [blame] | 241 | LOG(LS_ERROR) << "StartPlayingFile() sample frequency not " |
| 242 | << "supported for PCM format."; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 243 | return -1; |
| 244 | } |
| 245 | |
| 246 | if (_fileModule.StartPlayingAudioFile(fileName, notification, loop, |
| 247 | _fileFormat, &codecInstL16, |
| 248 | startPosition, |
| 249 | stopPosition) == -1) |
| 250 | { |
asapersson@webrtc.org | 8b2ec15 | 2014-04-11 07:59:43 +0000 | [diff] [blame] | 251 | LOG(LS_WARNING) << "StartPlayingFile() failed to initialize " |
| 252 | << "pcm file " << fileName; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 253 | return -1; |
| 254 | } |
| 255 | SetAudioScaling(volumeScaling); |
| 256 | }else if(_fileFormat == kFileFormatPreencodedFile) |
| 257 | { |
| 258 | if (_fileModule.StartPlayingAudioFile(fileName, notification, loop, |
| 259 | _fileFormat, codecInst) == -1) |
| 260 | { |
asapersson@webrtc.org | 8b2ec15 | 2014-04-11 07:59:43 +0000 | [diff] [blame] | 261 | LOG(LS_WARNING) << "StartPlayingFile() failed to initialize " |
| 262 | << "pre-encoded file " << fileName; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 263 | return -1; |
| 264 | } |
| 265 | } else |
| 266 | { |
| 267 | CodecInst* no_inst = NULL; |
| 268 | if (_fileModule.StartPlayingAudioFile(fileName, notification, loop, |
| 269 | _fileFormat, no_inst, |
| 270 | startPosition, |
| 271 | stopPosition) == -1) |
| 272 | { |
asapersson@webrtc.org | 8b2ec15 | 2014-04-11 07:59:43 +0000 | [diff] [blame] | 273 | LOG(LS_WARNING) << "StartPlayingFile() failed to initialize file " |
| 274 | << fileName; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 275 | return -1; |
| 276 | } |
| 277 | SetAudioScaling(volumeScaling); |
| 278 | } |
| 279 | if (SetUpAudioDecoder() == -1) |
| 280 | { |
| 281 | StopPlayingFile(); |
| 282 | return -1; |
| 283 | } |
| 284 | return 0; |
| 285 | } |
| 286 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 287 | int32_t FilePlayerImpl::StartPlayingFile(InStream& sourceStream, |
| 288 | uint32_t startPosition, |
| 289 | float volumeScaling, |
| 290 | uint32_t notification, |
| 291 | uint32_t stopPosition, |
| 292 | const CodecInst* codecInst) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 293 | { |
| 294 | if (_fileFormat == kFileFormatPcm16kHzFile || |
| 295 | _fileFormat == kFileFormatPcm32kHzFile || |
| 296 | _fileFormat == kFileFormatPcm8kHzFile) |
| 297 | { |
| 298 | CodecInst codecInstL16; |
| 299 | strncpy(codecInstL16.plname,"L16",32); |
| 300 | codecInstL16.pltype = 93; |
| 301 | codecInstL16.channels = 1; |
| 302 | |
| 303 | if (_fileFormat == kFileFormatPcm8kHzFile) |
| 304 | { |
| 305 | codecInstL16.rate = 128000; |
| 306 | codecInstL16.plfreq = 8000; |
| 307 | codecInstL16.pacsize = 80; |
| 308 | |
| 309 | }else if (_fileFormat == kFileFormatPcm16kHzFile) |
| 310 | { |
| 311 | codecInstL16.rate = 256000; |
| 312 | codecInstL16.plfreq = 16000; |
| 313 | codecInstL16.pacsize = 160; |
| 314 | |
| 315 | }else if (_fileFormat == kFileFormatPcm32kHzFile) |
| 316 | { |
| 317 | codecInstL16.rate = 512000; |
| 318 | codecInstL16.plfreq = 32000; |
| 319 | codecInstL16.pacsize = 160; |
| 320 | }else |
| 321 | { |
asapersson@webrtc.org | 8b2ec15 | 2014-04-11 07:59:43 +0000 | [diff] [blame] | 322 | LOG(LS_ERROR) << "StartPlayingFile() sample frequency not " |
| 323 | << "supported for PCM format."; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 324 | return -1; |
| 325 | } |
| 326 | if (_fileModule.StartPlayingAudioStream(sourceStream, notification, |
| 327 | _fileFormat, &codecInstL16, |
| 328 | startPosition, |
| 329 | stopPosition) == -1) |
| 330 | { |
asapersson@webrtc.org | 8b2ec15 | 2014-04-11 07:59:43 +0000 | [diff] [blame] | 331 | LOG(LS_ERROR) << "StartPlayingFile() failed to initialize stream " |
| 332 | << "playout."; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 333 | return -1; |
| 334 | } |
| 335 | |
| 336 | }else if(_fileFormat == kFileFormatPreencodedFile) |
| 337 | { |
| 338 | if (_fileModule.StartPlayingAudioStream(sourceStream, notification, |
| 339 | _fileFormat, codecInst) == -1) |
| 340 | { |
asapersson@webrtc.org | 8b2ec15 | 2014-04-11 07:59:43 +0000 | [diff] [blame] | 341 | LOG(LS_ERROR) << "StartPlayingFile() failed to initialize stream " |
| 342 | << "playout."; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 343 | return -1; |
| 344 | } |
| 345 | } else { |
| 346 | CodecInst* no_inst = NULL; |
| 347 | if (_fileModule.StartPlayingAudioStream(sourceStream, notification, |
| 348 | _fileFormat, no_inst, |
| 349 | startPosition, |
| 350 | stopPosition) == -1) |
| 351 | { |
asapersson@webrtc.org | 8b2ec15 | 2014-04-11 07:59:43 +0000 | [diff] [blame] | 352 | LOG(LS_ERROR) << "StartPlayingFile() failed to initialize stream " |
| 353 | << "playout."; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 354 | return -1; |
| 355 | } |
| 356 | } |
| 357 | SetAudioScaling(volumeScaling); |
| 358 | |
| 359 | if (SetUpAudioDecoder() == -1) |
| 360 | { |
| 361 | StopPlayingFile(); |
| 362 | return -1; |
| 363 | } |
| 364 | return 0; |
| 365 | } |
| 366 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 367 | int32_t FilePlayerImpl::StopPlayingFile() |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 368 | { |
| 369 | memset(&_codec, 0, sizeof(CodecInst)); |
| 370 | _numberOf10MsPerFrame = 0; |
| 371 | _numberOf10MsInDecoder = 0; |
| 372 | return _fileModule.StopPlaying(); |
| 373 | } |
| 374 | |
| 375 | bool FilePlayerImpl::IsPlayingFile() const |
| 376 | { |
| 377 | return _fileModule.IsPlaying(); |
| 378 | } |
| 379 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 380 | int32_t FilePlayerImpl::GetPlayoutPosition(uint32_t& durationMs) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 381 | { |
| 382 | return _fileModule.PlayoutPositionMs(durationMs); |
| 383 | } |
| 384 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 385 | int32_t FilePlayerImpl::SetUpAudioDecoder() |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 386 | { |
| 387 | if ((_fileModule.codec_info(_codec) == -1)) |
| 388 | { |
asapersson@webrtc.org | 8b2ec15 | 2014-04-11 07:59:43 +0000 | [diff] [blame] | 389 | LOG(LS_WARNING) << "Failed to retrieve codec info of file data."; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 390 | return -1; |
| 391 | } |
| 392 | if( STR_CASE_CMP(_codec.plname, "L16") != 0 && |
| 393 | _audioDecoder.SetDecodeCodec(_codec,AMRFileStorage) == -1) |
| 394 | { |
asapersson@webrtc.org | 8b2ec15 | 2014-04-11 07:59:43 +0000 | [diff] [blame] | 395 | LOG(LS_WARNING) << "SetUpAudioDecoder() codec " << _codec.plname |
| 396 | << " not supported."; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 397 | return -1; |
| 398 | } |
| 399 | _numberOf10MsPerFrame = _codec.pacsize / (_codec.plfreq / 100); |
| 400 | _numberOf10MsInDecoder = 0; |
| 401 | return 0; |
| 402 | } |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 403 | } // namespace webrtc |