• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 //
38 #ifndef WEBRTC_VOICE_ENGINE_VOE_FILE_H
39 #define WEBRTC_VOICE_ENGINE_VOE_FILE_H
40 
41 #include "webrtc/common_types.h"
42 
43 namespace webrtc {
44 
45 class VoiceEngine;
46 
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);
53 
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;
59 
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;
70 
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;
80 
81   // Stops playback of a file on a specific |channel|.
82   virtual int StopPlayingFileLocally(int channel) = 0;
83 
84   // Returns the current file playing state for a specific |channel|.
85   virtual int IsPlayingFileLocally(int channel) = 0;
86 
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;
96 
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;
105 
106   // Stops playing of a file as microphone signal for a specific |channel|.
107   virtual int StopPlayingFileAsMicrophone(int channel) = 0;
108 
109   // Returns whether the |channel| is currently playing a file as microphone.
110   virtual int IsPlayingFileAsMicrophone(int channel) = 0;
111 
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;
117 
118   // Stops recording the mixed playout audio.
119   virtual int StopRecordingPlayout(int channel) = 0;
120 
121   virtual int StartRecordingPlayout(int channel,
122                                     OutStream* stream,
123                                     CodecInst* compression = NULL) = 0;
124 
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;
129 
130   // Starts recording the microphone signal to a stream.
131   virtual int StartRecordingMicrophone(OutStream* stream,
132                                        CodecInst* compression = NULL) = 0;
133 
134   // Stops recording the microphone signal.
135   virtual int StopRecordingMicrophone() = 0;
136 
137  protected:
VoEFile()138   VoEFile() {}
~VoEFile()139   virtual ~VoEFile() {}
140 };
141 
142 }  // namespace webrtc
143 
144 #endif  // WEBRTC_VOICE_ENGINE_VOE_FILE_H
145