niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
leozwang@webrtc.org | 2559cbf | 2012-02-27 19:18:25 +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 | |
| 11 | #ifndef WEBRTC_MODULES_UTILITY_SOURCE_FILE_PLAYER_IMPL_H_ |
| 12 | #define WEBRTC_MODULES_UTILITY_SOURCE_FILE_PLAYER_IMPL_H_ |
| 13 | |
pbos@webrtc.org | 8b06200 | 2013-07-12 08:28:10 +0000 | [diff] [blame] | 14 | #include "webrtc/common_audio/resampler/include/resampler.h" |
| 15 | #include "webrtc/common_types.h" |
| 16 | #include "webrtc/engine_configurations.h" |
| 17 | #include "webrtc/modules/media_file/interface/media_file.h" |
| 18 | #include "webrtc/modules/media_file/interface/media_file_defines.h" |
| 19 | #include "webrtc/modules/utility/interface/file_player.h" |
| 20 | #include "webrtc/modules/utility/source/coder.h" |
| 21 | #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" |
| 22 | #include "webrtc/system_wrappers/interface/tick_util.h" |
| 23 | #include "webrtc/typedefs.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 24 | |
| 25 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 26 | class FilePlayerImpl : public FilePlayer |
| 27 | { |
| 28 | public: |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 29 | FilePlayerImpl(uint32_t instanceID, FileFormats fileFormat); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 30 | ~FilePlayerImpl(); |
| 31 | |
andrew@webrtc.org | e59a0ac | 2012-05-08 17:12:40 +0000 | [diff] [blame] | 32 | virtual int Get10msAudioFromFile( |
| 33 | int16_t* outBuffer, |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame^] | 34 | size_t& lengthInSamples, |
andrew@webrtc.org | e59a0ac | 2012-05-08 17:12:40 +0000 | [diff] [blame] | 35 | int frequencyInHz); |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 36 | virtual int32_t RegisterModuleFileCallback(FileCallback* callback); |
| 37 | virtual int32_t StartPlayingFile( |
leozwang@webrtc.org | 2559cbf | 2012-02-27 19:18:25 +0000 | [diff] [blame] | 38 | const char* fileName, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 39 | bool loop, |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 40 | uint32_t startPosition, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 41 | float volumeScaling, |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 42 | uint32_t notification, |
| 43 | uint32_t stopPosition = 0, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 44 | const CodecInst* codecInst = NULL); |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 45 | virtual int32_t StartPlayingFile( |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 46 | InStream& sourceStream, |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 47 | uint32_t startPosition, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 48 | float volumeScaling, |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 49 | uint32_t notification, |
| 50 | uint32_t stopPosition = 0, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 51 | const CodecInst* codecInst = NULL); |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 52 | virtual int32_t StopPlayingFile(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 53 | virtual bool IsPlayingFile() const; |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 54 | virtual int32_t GetPlayoutPosition(uint32_t& durationMs); |
| 55 | virtual int32_t AudioCodec(CodecInst& audioCodec) const; |
| 56 | virtual int32_t Frequency() const; |
| 57 | virtual int32_t SetAudioScaling(float scaleFactor); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 58 | |
| 59 | protected: |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 60 | int32_t SetUpAudioDecoder(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 61 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 62 | uint32_t _instanceID; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 63 | const FileFormats _fileFormat; |
| 64 | MediaFile& _fileModule; |
| 65 | |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 66 | uint32_t _decodedLengthInMS; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 67 | |
| 68 | private: |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 69 | AudioCoder _audioDecoder; |
| 70 | |
| 71 | CodecInst _codec; |
pbos@webrtc.org | c75102e | 2013-04-09 13:32:55 +0000 | [diff] [blame] | 72 | int32_t _numberOf10MsPerFrame; |
| 73 | int32_t _numberOf10MsInDecoder; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 74 | |
| 75 | Resampler _resampler; |
| 76 | float _scaling; |
| 77 | }; |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 78 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 79 | #endif // WEBRTC_MODULES_UTILITY_SOURCE_FILE_PLAYER_IMPL_H_ |