OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 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_INCLUDE_FILE_PLAYER_H_ |
| 12 #define WEBRTC_MODULES_UTILITY_INCLUDE_FILE_PLAYER_H_ |
| 13 |
| 14 #include "webrtc/common_types.h" |
| 15 #include "webrtc/engine_configurations.h" |
| 16 #include "webrtc/modules/include/module_common_types.h" |
| 17 #include "webrtc/typedefs.h" |
| 18 |
| 19 namespace webrtc { |
| 20 class FileCallback; |
| 21 |
| 22 class FilePlayer |
| 23 { |
| 24 public: |
| 25 // The largest decoded frame size in samples (60ms with 32kHz sample rate). |
| 26 enum {MAX_AUDIO_BUFFER_IN_SAMPLES = 60*32}; |
| 27 enum {MAX_AUDIO_BUFFER_IN_BYTES = MAX_AUDIO_BUFFER_IN_SAMPLES*2}; |
| 28 |
| 29 // Note: will return NULL for unsupported formats. |
| 30 static FilePlayer* CreateFilePlayer(const uint32_t instanceID, |
| 31 const FileFormats fileFormat); |
| 32 |
| 33 static void DestroyFilePlayer(FilePlayer* player); |
| 34 |
| 35 // Read 10 ms of audio at |frequencyInHz| to |outBuffer|. |lengthInSamples| |
| 36 // will be set to the number of samples read (not the number of samples per |
| 37 // channel). |
| 38 virtual int Get10msAudioFromFile( |
| 39 int16_t* outBuffer, |
| 40 size_t& lengthInSamples, |
| 41 int frequencyInHz) = 0; |
| 42 |
| 43 // Register callback for receiving file playing notifications. |
| 44 virtual int32_t RegisterModuleFileCallback( |
| 45 FileCallback* callback) = 0; |
| 46 |
| 47 // API for playing audio from fileName to channel. |
| 48 // Note: codecInst is used for pre-encoded files. |
| 49 virtual int32_t StartPlayingFile( |
| 50 const char* fileName, |
| 51 bool loop, |
| 52 uint32_t startPosition, |
| 53 float volumeScaling, |
| 54 uint32_t notification, |
| 55 uint32_t stopPosition = 0, |
| 56 const CodecInst* codecInst = NULL) = 0; |
| 57 |
| 58 // Note: codecInst is used for pre-encoded files. |
| 59 virtual int32_t StartPlayingFile( |
| 60 InStream& sourceStream, |
| 61 uint32_t startPosition, |
| 62 float volumeScaling, |
| 63 uint32_t notification, |
| 64 uint32_t stopPosition = 0, |
| 65 const CodecInst* codecInst = NULL) = 0; |
| 66 |
| 67 virtual int32_t StopPlayingFile() = 0; |
| 68 |
| 69 virtual bool IsPlayingFile() const = 0; |
| 70 |
| 71 virtual int32_t GetPlayoutPosition(uint32_t& durationMs) = 0; |
| 72 |
| 73 // Set audioCodec to the currently used audio codec. |
| 74 virtual int32_t AudioCodec(CodecInst& audioCodec) const = 0; |
| 75 |
| 76 virtual int32_t Frequency() const = 0; |
| 77 |
| 78 // Note: scaleFactor is in the range [0.0 - 2.0] |
| 79 virtual int32_t SetAudioScaling(float scaleFactor) = 0; |
| 80 |
| 81 protected: |
| 82 virtual ~FilePlayer() {} |
| 83 |
| 84 }; |
| 85 } // namespace webrtc |
| 86 #endif // WEBRTC_MODULES_UTILITY_INCLUDE_FILE_PLAYER_H_ |
OLD | NEW |