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