Chromium Code Reviews| 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 |
| 11 #ifndef WEBRTC_MODULES_UTILITY_INCLUDE_FILE_PLAYER_H_ | 11 #ifndef WEBRTC_MODULES_UTILITY_INCLUDE_FILE_PLAYER_H_ |
| 12 #define WEBRTC_MODULES_UTILITY_INCLUDE_FILE_PLAYER_H_ | 12 #define WEBRTC_MODULES_UTILITY_INCLUDE_FILE_PLAYER_H_ |
| 13 | 13 |
| 14 #include <memory> | |
| 15 | |
| 14 #include "webrtc/common_types.h" | 16 #include "webrtc/common_types.h" |
| 15 #include "webrtc/engine_configurations.h" | 17 #include "webrtc/engine_configurations.h" |
| 16 #include "webrtc/modules/include/module_common_types.h" | 18 #include "webrtc/modules/include/module_common_types.h" |
| 17 #include "webrtc/typedefs.h" | 19 #include "webrtc/typedefs.h" |
| 18 | 20 |
| 19 namespace webrtc { | 21 namespace webrtc { |
| 22 | |
| 20 class FileCallback; | 23 class FileCallback; |
| 21 | 24 |
| 22 class FilePlayer { | 25 class FilePlayer { |
| 23 public: | 26 public: |
| 24 // The largest decoded frame size in samples (60ms with 32kHz sample rate). | 27 // The largest decoded frame size in samples (60ms with 32kHz sample rate). |
| 25 enum { MAX_AUDIO_BUFFER_IN_SAMPLES = 60 * 32 }; | 28 enum { MAX_AUDIO_BUFFER_IN_SAMPLES = 60 * 32 }; |
| 26 enum { MAX_AUDIO_BUFFER_IN_BYTES = MAX_AUDIO_BUFFER_IN_SAMPLES * 2 }; | 29 enum { MAX_AUDIO_BUFFER_IN_BYTES = MAX_AUDIO_BUFFER_IN_SAMPLES * 2 }; |
| 27 | 30 |
| 28 // Note: will return NULL for unsupported formats. | 31 // Note: will return NULL for unsupported formats. |
| 32 static std::unique_ptr<FilePlayer> NewFilePlayer( | |
|
ossu
2016/08/17 11:09:05
I've a slight issue with the naming here, though I
kwiberg-webrtc
2016/08/17 12:27:39
FilePlayer::CreatePlayer is probably just as rare
ossu
2016/08/17 13:49:13
Alright, I'm fine with that! Just didn't want us t
| |
| 33 const uint32_t instanceID, | |
| 34 const FileFormats fileFormat); | |
| 35 | |
| 36 // Deprecated creation/destruction functions. Use NewFilePlayer instead. | |
| 29 static FilePlayer* CreateFilePlayer(const uint32_t instanceID, | 37 static FilePlayer* CreateFilePlayer(const uint32_t instanceID, |
| 30 const FileFormats fileFormat); | 38 const FileFormats fileFormat); |
| 39 static void DestroyFilePlayer(FilePlayer* player); | |
| 31 | 40 |
| 32 static void DestroyFilePlayer(FilePlayer* player); | 41 virtual ~FilePlayer() = default; |
| 33 | 42 |
| 34 // Read 10 ms of audio at |frequencyInHz| to |outBuffer|. |lengthInSamples| | 43 // Read 10 ms of audio at |frequencyInHz| to |outBuffer|. |lengthInSamples| |
| 35 // will be set to the number of samples read (not the number of samples per | 44 // will be set to the number of samples read (not the number of samples per |
| 36 // channel). | 45 // channel). |
| 37 virtual int Get10msAudioFromFile(int16_t* outBuffer, | 46 virtual int Get10msAudioFromFile(int16_t* outBuffer, |
| 38 size_t& lengthInSamples, | 47 size_t& lengthInSamples, |
| 39 int frequencyInHz) = 0; | 48 int frequencyInHz) = 0; |
| 40 | 49 |
| 41 // Register callback for receiving file playing notifications. | 50 // Register callback for receiving file playing notifications. |
| 42 virtual int32_t RegisterModuleFileCallback(FileCallback* callback) = 0; | 51 virtual int32_t RegisterModuleFileCallback(FileCallback* callback) = 0; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 65 | 74 |
| 66 virtual int32_t GetPlayoutPosition(uint32_t& durationMs) = 0; | 75 virtual int32_t GetPlayoutPosition(uint32_t& durationMs) = 0; |
| 67 | 76 |
| 68 // Set audioCodec to the currently used audio codec. | 77 // Set audioCodec to the currently used audio codec. |
| 69 virtual int32_t AudioCodec(CodecInst& audioCodec) const = 0; | 78 virtual int32_t AudioCodec(CodecInst& audioCodec) const = 0; |
| 70 | 79 |
| 71 virtual int32_t Frequency() const = 0; | 80 virtual int32_t Frequency() const = 0; |
| 72 | 81 |
| 73 // Note: scaleFactor is in the range [0.0 - 2.0] | 82 // Note: scaleFactor is in the range [0.0 - 2.0] |
| 74 virtual int32_t SetAudioScaling(float scaleFactor) = 0; | 83 virtual int32_t SetAudioScaling(float scaleFactor) = 0; |
| 75 | |
| 76 protected: | |
| 77 virtual ~FilePlayer() {} | |
| 78 }; | 84 }; |
| 79 } // namespace webrtc | 85 } // namespace webrtc |
| 80 #endif // WEBRTC_MODULES_UTILITY_INCLUDE_FILE_PLAYER_H_ | 86 #endif // WEBRTC_MODULES_UTILITY_INCLUDE_FILE_PLAYER_H_ |
| OLD | NEW |