blob: 7ecdf700f49cbdfe5605ace290416cccea80c450 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020038#ifndef VOICE_ENGINE_VOE_FILE_H_
39#define VOICE_ENGINE_VOE_FILE_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000040
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020041#include "common_types.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000042
43namespace webrtc {
44
45class VoiceEngine;
46
Jelena Marusic0d266052015-05-04 14:15:32 +020047class 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.com470e71d2011-07-07 08:21:25 +000053
Jelena Marusic0d266052015-05-04 14:15:32 +020054 // 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.com470e71d2011-07-07 08:21:25 +000059
Jelena Marusic0d266052015-05-04 14:15:32 +020060 // 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.com470e71d2011-07-07 08:21:25 +000070
Jelena Marusic0d266052015-05-04 14:15:32 +020071 // 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.com470e71d2011-07-07 08:21:25 +000080
Jelena Marusic0d266052015-05-04 14:15:32 +020081 // Stops playback of a file on a specific |channel|.
82 virtual int StopPlayingFileLocally(int channel) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000083
Jelena Marusic0d266052015-05-04 14:15:32 +020084 // Returns the current file playing state for a specific |channel|.
85 virtual int IsPlayingFileLocally(int channel) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000086
Jelena Marusic0d266052015-05-04 14:15:32 +020087 // 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.com470e71d2011-07-07 08:21:25 +000096
Jelena Marusic0d266052015-05-04 14:15:32 +020097 // 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.com470e71d2011-07-07 08:21:25 +0000105
Jelena Marusic0d266052015-05-04 14:15:32 +0200106 // Stops playing of a file as microphone signal for a specific |channel|.
107 virtual int StopPlayingFileAsMicrophone(int channel) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000108
Jelena Marusic0d266052015-05-04 14:15:32 +0200109 // Returns whether the |channel| is currently playing a file as microphone.
110 virtual int IsPlayingFileAsMicrophone(int channel) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000111
Jelena Marusic0d266052015-05-04 14:15:32 +0200112 // 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.com470e71d2011-07-07 08:21:25 +0000117
Jelena Marusic0d266052015-05-04 14:15:32 +0200118 // Stops recording the mixed playout audio.
119 virtual int StopRecordingPlayout(int channel) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000120
Jelena Marusic0d266052015-05-04 14:15:32 +0200121 virtual int StartRecordingPlayout(int channel,
122 OutStream* stream,
123 CodecInst* compression = NULL) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000124
Jelena Marusic0d266052015-05-04 14:15:32 +0200125 // 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.com470e71d2011-07-07 08:21:25 +0000129
Jelena Marusic0d266052015-05-04 14:15:32 +0200130 // Starts recording the microphone signal to a stream.
131 virtual int StartRecordingMicrophone(OutStream* stream,
132 CodecInst* compression = NULL) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000133
Jelena Marusic0d266052015-05-04 14:15:32 +0200134 // Stops recording the microphone signal.
135 virtual int StopRecordingMicrophone() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000136
Jelena Marusic0d266052015-05-04 14:15:32 +0200137 protected:
138 VoEFile() {}
139 virtual ~VoEFile() {}
niklase@google.com470e71d2011-07-07 08:21:25 +0000140};
141
142} // namespace webrtc
143
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200144#endif // VOICE_ENGINE_VOE_FILE_H_