niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 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 | // This sub-API supports the following functionalities: |
| 12 | // |
| 13 | // - File playback. |
| 14 | // - File recording. |
| 15 | // - File conversion. |
| 16 | // |
| 17 | // Usage example, omitting error checking: |
| 18 | // |
| 19 | // using namespace webrtc; |
| 20 | // VoiceEngine* voe = VoiceEngine::Create(); |
| 21 | // VoEBase* base = VoEBase::GetInterface(voe); |
| 22 | // VoEFile* file = VoEFile::GetInterface(voe); |
| 23 | // base->Init(); |
| 24 | // int ch = base->CreateChannel(); |
| 25 | // ... |
| 26 | // base->StartPlayout(ch); |
| 27 | // file->StartPlayingFileAsMicrophone(ch, "data_file_16kHz.pcm", true); |
| 28 | // ... |
| 29 | // file->StopPlayingFileAsMicrophone(ch); |
| 30 | // base->StopPlayout(ch); |
| 31 | // ... |
| 32 | // base->DeleteChannel(ch); |
| 33 | // base->Terminate(); |
| 34 | // base->Release(); |
| 35 | // file->Release(); |
| 36 | // VoiceEngine::Delete(voe); |
| 37 | // |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 38 | #ifndef VOICE_ENGINE_VOE_FILE_H_ |
| 39 | #define VOICE_ENGINE_VOE_FILE_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 40 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 41 | #include "common_types.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 42 | |
| 43 | namespace webrtc { |
| 44 | |
| 45 | class VoiceEngine; |
| 46 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 47 | class WEBRTC_DLLEXPORT VoEFile { |
| 48 | public: |
| 49 | // Factory for the VoEFile sub-API. Increases an internal |
| 50 | // reference counter if successful. Returns NULL if the API is not |
| 51 | // supported or if construction fails. |
| 52 | static VoEFile* GetInterface(VoiceEngine* voiceEngine); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 53 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 54 | // Releases the VoEFile sub-API and decreases an internal |
| 55 | // reference counter. Returns the new reference count. This value should |
| 56 | // be zero for all sub-API:s before the VoiceEngine object can be safely |
| 57 | // deleted. |
| 58 | virtual int Release() = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 59 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 60 | // Starts playing and mixing files with the local speaker signal for |
| 61 | // playout. |
| 62 | virtual int StartPlayingFileLocally( |
| 63 | int channel, |
| 64 | const char fileNameUTF8[1024], |
| 65 | bool loop = false, |
| 66 | FileFormats format = kFileFormatPcm16kHzFile, |
| 67 | float volumeScaling = 1.0, |
| 68 | int startPointMs = 0, |
| 69 | int stopPointMs = 0) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 70 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 71 | // Starts playing and mixing streams with the local speaker signal for |
| 72 | // playout. |
| 73 | virtual int StartPlayingFileLocally( |
| 74 | int channel, |
| 75 | InStream* stream, |
| 76 | FileFormats format = kFileFormatPcm16kHzFile, |
| 77 | float volumeScaling = 1.0, |
| 78 | int startPointMs = 0, |
| 79 | int stopPointMs = 0) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 80 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 81 | // Stops playback of a file on a specific |channel|. |
| 82 | virtual int StopPlayingFileLocally(int channel) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 83 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 84 | // Returns the current file playing state for a specific |channel|. |
| 85 | virtual int IsPlayingFileLocally(int channel) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 86 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 87 | // Starts reading data from a file and transmits the data either |
| 88 | // mixed with or instead of the microphone signal. |
| 89 | virtual int StartPlayingFileAsMicrophone( |
| 90 | int channel, |
| 91 | const char fileNameUTF8[1024], |
| 92 | bool loop = false, |
| 93 | bool mixWithMicrophone = false, |
| 94 | FileFormats format = kFileFormatPcm16kHzFile, |
| 95 | float volumeScaling = 1.0) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 96 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 97 | // Starts reading data from a stream and transmits the data either |
| 98 | // mixed with or instead of the microphone signal. |
| 99 | virtual int StartPlayingFileAsMicrophone( |
| 100 | int channel, |
| 101 | InStream* stream, |
| 102 | bool mixWithMicrophone = false, |
| 103 | FileFormats format = kFileFormatPcm16kHzFile, |
| 104 | float volumeScaling = 1.0) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 105 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 106 | // Stops playing of a file as microphone signal for a specific |channel|. |
| 107 | virtual int StopPlayingFileAsMicrophone(int channel) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 108 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 109 | // Returns whether the |channel| is currently playing a file as microphone. |
| 110 | virtual int IsPlayingFileAsMicrophone(int channel) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 111 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 112 | // Starts recording the mixed playout audio. |
| 113 | virtual int StartRecordingPlayout(int channel, |
| 114 | const char* fileNameUTF8, |
| 115 | CodecInst* compression = NULL, |
| 116 | int maxSizeBytes = -1) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 117 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 118 | // Stops recording the mixed playout audio. |
| 119 | virtual int StopRecordingPlayout(int channel) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 120 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 121 | virtual int StartRecordingPlayout(int channel, |
| 122 | OutStream* stream, |
| 123 | CodecInst* compression = NULL) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 124 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 125 | // Starts recording the microphone signal to a file. |
| 126 | virtual int StartRecordingMicrophone(const char* fileNameUTF8, |
| 127 | CodecInst* compression = NULL, |
| 128 | int maxSizeBytes = -1) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 129 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 130 | // Starts recording the microphone signal to a stream. |
| 131 | virtual int StartRecordingMicrophone(OutStream* stream, |
| 132 | CodecInst* compression = NULL) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 133 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 134 | // Stops recording the microphone signal. |
| 135 | virtual int StopRecordingMicrophone() = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 136 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 137 | protected: |
| 138 | VoEFile() {} |
| 139 | virtual ~VoEFile() {} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 140 | }; |
| 141 | |
| 142 | } // namespace webrtc |
| 143 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 144 | #endif // VOICE_ENGINE_VOE_FILE_H_ |