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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 uint32_t notification, | 46 uint32_t notification, |
47 uint32_t stopPosition = 0, | 47 uint32_t stopPosition = 0, |
48 const CodecInst* codecInst = NULL); | 48 const CodecInst* codecInst = NULL); |
49 virtual int32_t StopPlayingFile(); | 49 virtual int32_t StopPlayingFile(); |
50 virtual bool IsPlayingFile() const; | 50 virtual bool IsPlayingFile() const; |
51 virtual int32_t GetPlayoutPosition(uint32_t& durationMs); | 51 virtual int32_t GetPlayoutPosition(uint32_t& durationMs); |
52 virtual int32_t AudioCodec(CodecInst& audioCodec) const; | 52 virtual int32_t AudioCodec(CodecInst& audioCodec) const; |
53 virtual int32_t Frequency() const; | 53 virtual int32_t Frequency() const; |
54 virtual int32_t SetAudioScaling(float scaleFactor); | 54 virtual int32_t SetAudioScaling(float scaleFactor); |
55 | 55 |
56 protected: | 56 private: |
57 int32_t SetUpAudioDecoder(); | 57 int32_t SetUpAudioDecoder(); |
58 | 58 |
59 uint32_t _instanceID; | |
60 const FileFormats _fileFormat; | 59 const FileFormats _fileFormat; |
61 MediaFile& _fileModule; | 60 MediaFile& _fileModule; |
62 | 61 |
63 uint32_t _decodedLengthInMS; | 62 uint32_t _decodedLengthInMS; |
64 | 63 |
65 private: | |
66 AudioCoder _audioDecoder; | 64 AudioCoder _audioDecoder; |
67 | 65 |
68 CodecInst _codec; | 66 CodecInst _codec; |
69 int32_t _numberOf10MsPerFrame; | 67 int32_t _numberOf10MsPerFrame; |
70 int32_t _numberOf10MsInDecoder; | 68 int32_t _numberOf10MsInDecoder; |
71 | 69 |
72 Resampler _resampler; | 70 Resampler _resampler; |
73 float _scaling; | 71 float _scaling; |
74 }; | 72 }; |
75 | 73 |
76 FilePlayerImpl::FilePlayerImpl(const uint32_t instanceID, | 74 FilePlayerImpl::FilePlayerImpl(const uint32_t instanceID, |
77 const FileFormats fileFormat) | 75 const FileFormats fileFormat) |
78 : _instanceID(instanceID), | 76 : _fileFormat(fileFormat), |
79 _fileFormat(fileFormat), | |
80 _fileModule(*MediaFile::CreateMediaFile(instanceID)), | 77 _fileModule(*MediaFile::CreateMediaFile(instanceID)), |
81 _decodedLengthInMS(0), | 78 _decodedLengthInMS(0), |
82 _audioDecoder(instanceID), | 79 _audioDecoder(instanceID), |
83 _codec(), | 80 _codec(), |
84 _numberOf10MsPerFrame(0), | 81 _numberOf10MsPerFrame(0), |
85 _numberOf10MsInDecoder(0), | 82 _numberOf10MsInDecoder(0), |
86 _resampler(), | 83 _resampler(), |
87 _scaling(1.0) { | 84 _scaling(1.0) { |
88 _codec.plfreq = 0; | 85 _codec.plfreq = 0; |
89 } | 86 } |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 << " not supported."; | 363 << " not supported."; |
367 return -1; | 364 return -1; |
368 } | 365 } |
369 _numberOf10MsPerFrame = _codec.pacsize / (_codec.plfreq / 100); | 366 _numberOf10MsPerFrame = _codec.pacsize / (_codec.plfreq / 100); |
370 _numberOf10MsInDecoder = 0; | 367 _numberOf10MsInDecoder = 0; |
371 return 0; | 368 return 0; |
372 } | 369 } |
373 | 370 |
374 } // namespace | 371 } // namespace |
375 | 372 |
376 FilePlayer* FilePlayer::CreateFilePlayer(uint32_t instanceID, | 373 std::unique_ptr<FilePlayer> FilePlayer::NewFilePlayer( |
377 FileFormats fileFormat) { | 374 uint32_t instanceID, |
| 375 FileFormats fileFormat) { |
378 switch (fileFormat) { | 376 switch (fileFormat) { |
379 case kFileFormatWavFile: | 377 case kFileFormatWavFile: |
380 case kFileFormatCompressedFile: | 378 case kFileFormatCompressedFile: |
381 case kFileFormatPreencodedFile: | 379 case kFileFormatPreencodedFile: |
382 case kFileFormatPcm16kHzFile: | 380 case kFileFormatPcm16kHzFile: |
383 case kFileFormatPcm8kHzFile: | 381 case kFileFormatPcm8kHzFile: |
384 case kFileFormatPcm32kHzFile: | 382 case kFileFormatPcm32kHzFile: |
385 // audio formats | 383 // audio formats |
386 return new FilePlayerImpl(instanceID, fileFormat); | 384 return std::unique_ptr<FilePlayer>( |
| 385 new FilePlayerImpl(instanceID, fileFormat)); |
387 default: | 386 default: |
388 assert(false); | 387 assert(false); |
389 return NULL; | 388 return nullptr; |
390 } | 389 } |
391 } | 390 } |
392 | 391 |
| 392 FilePlayer* FilePlayer::CreateFilePlayer(uint32_t instanceID, |
| 393 FileFormats fileFormat) { |
| 394 return FilePlayer::NewFilePlayer(instanceID, fileFormat).release(); |
| 395 } |
| 396 |
393 void FilePlayer::DestroyFilePlayer(FilePlayer* player) { | 397 void FilePlayer::DestroyFilePlayer(FilePlayer* player) { |
394 delete player; | 398 delete player; |
395 } | 399 } |
396 | 400 |
397 } // namespace webrtc | 401 } // namespace webrtc |
OLD | NEW |