This repository has been archived by the owner on Dec 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathwebrtc_voe.h
232 lines (185 loc) · 6.34 KB
/
webrtc_voe.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/*
* Copyright (c) 2013 Gary Yu. All Rights Reserved.
*
* URL: https://github.com/garyyu/WebRTC_VoiceEngine
*
* Use of this source code is governed by a New BSD license which can be found in the LICENSE file
* in the root of the source tree. Refer to README.md.
* For WebRTC License & Patents information, please read files LICENSE.webrtc and PATENTS.webrtc.
*/
/*
* This file contains the Wrapper of WebRTC Voice Engine.
* You just need this header file , lib file , and dll file in the root folder.
*
*/
#ifndef __WRTC_VOICE_ENGINE_H__
#define __WRTC_VOICE_ENGINE_H__
#define _WEBRTC_API_EXPORTS // For DLL Building.
#define _WEBRTC_FOR_PC
#if defined(_WEBRTC_API_EXPORTS)
#define WEBRTC_API __declspec(dllexport)
#elif defined(_WEBRTC_API_IMPORTS)
#define WEBRTC_API __declspec(dllimport)
#else
#define WEBRTC_API
#endif
#define VOE_TRUE 1
#define VOE_FALSE 0
typedef short int16_t;
typedef struct webrtc_ec
{
void* AEC_inst;
void* NS_inst;
void* HP_FilterState;
unsigned samples_per_frame;
unsigned echo_tail;
unsigned echo_skew;
unsigned clock_rate;
unsigned blockLen10ms;
int16_t* tmp_frame;
int16_t* tmp_frame2;
} webrtc_ec;
typedef struct {
int instant;
int average;
int max;
int min;
} MyAecLevel;
typedef struct {
MyAecLevel rerl;
MyAecLevel erl;
MyAecLevel erle;
MyAecLevel aNlp;
} MyAecMetrics;
#if defined(_WEBRTC_FOR_PC)
#define WEBRTC_AEC_USE_MOBILE 0
#else
#define WEBRTC_AEC_USE_MOBILE 1
#endif
/************************************************************************/
/* Volume Control API */
/************************************************************************/
class WEBRTC_API WebRTCVolumeCtlImpl
{
private:
void* m_voe; //VoiceEngine*
void* m_base; //VoEBase*
void* volume_control; //VoEVolumeControl*
//void* m_apm; //VoEAudioProcessing*
//void* m_hardware; //VoEHardware*
public:
WebRTCVolumeCtlImpl();
~WebRTCVolumeCtlImpl();
int webrtc_voe_init();
void webrtc_voe_deinit();
/*--- Microphone Level Control. Valid range is [0,255]. ---*/
int SetMicVolume(unsigned int level);
int GetMicVolume(unsigned int &level);
/*--- Speaker Level Control. Valid range is [0,255]. ---*/
int SetSpkVolume(unsigned int volume);
int GetSpkVolume(unsigned int &volume);
};
class WEBRTC_API MyAudioLevel
{
public:
MyAudioLevel();
~MyAudioLevel();
signed char Level() const;
signed short Count() const;
signed short LevelFullRange() const;
void Clear();
void ComputeLevel(const signed short* audioFrame, int length);
private:
enum { kUpdateFrequency = 10};
signed short _absMax;
signed short _count;
signed char _currentLevel;
signed short _currentLevelFullRange;
signed short My_WebRtcSpl_MaxAbsValueW16C(const signed short* vector, int length);
};
/************************************************************************/
/* Main AEC API */
/************************************************************************/
extern "C" int WEBRTC_API webrtc_aec_create(
unsigned clock_rate,
unsigned channel_count,
unsigned samples_per_frame,
unsigned tail_ms,
unsigned options,
void **p_echo );
extern "C" int WEBRTC_API webrtc_aec_destroy(void *state );
extern "C" void WEBRTC_API webrtc_aec_reset(void *state );
extern "C" int WEBRTC_API webrtc_aec_cancel_echo(void *state,
int16_t *rec_frm,
const int16_t *play_frm,
unsigned framing,
unsigned options,
void *reserved );
extern "C" int WEBRTC_API webrtc_aec_get_metrics(
void *state,
void *_aec_metrics );
extern "C" int WEBRTC_API webrtc_aec_get_delay_metrics(
void *state,
int* median,
int* std );
/************************************************************************/
/* Main Resampler API */
/************************************************************************/
extern "C" int WEBRTC_API webrtc_resampler_create(
int inFreq,
int outFreq,
void **p_resampler
);
extern "C" int WEBRTC_API webrtc_resampler_destroy(void *state );
extern "C" int WEBRTC_API webrtc_resampler_reset( void *state, int inFreq, int outFreq );
extern "C" int WEBRTC_API webrtc_resampler_process(void *state,
const int16_t* samplesIn,
int lengthIn,
int16_t* samplesOut,
int maxLen, int &outLen
);
/************************************************************************/
/* Voice processing configure: (AEC, NS, AGC, VAD) */
/************************************************************************/
/*
**vad: mode
**0: low
**1:
**2:
**3: most high
*/
int WebRTCVoe_SetVADStatus(int channelsid, bool b, int mode = 1);
/*
**agc: mode
**0: previously set mode
**1: platform default
**2: adaptive mode for use when analog volume control exists (e.g. for PC softphone)
**3: scaling takes place in the digital domain (e.g. for conference servers and embedded devices)
**4: can be used on embedded devices where the capture signal level is predictable
*/
int WebRTCVoe_SetAgcStatus(bool b, int mode = 1);
/*
**EC mode
**0: previously set mode
**1: platform default
**2: conferencing default (aggressive AEC)
**3: Acoustic Echo Cancellation
**4: AEC mobile
*/
int WebRTCVoe_SetEcStatus(bool b, int mode = 3);
/*
**NS mode
**0: previously set mode
**1: platform default
**2: conferencing default
**3: lowest suppression
**4: Moderate Suppression
**5: High Suppression
**6: highest suppression
*/
int WebRTCVoe_SetNsStatus(bool b, int mode = 4);
int WebRTCVoe_GetVADStatus(int channelsid, bool &b, int &mode);
int WebRTCVoe_GetAgcStatus(bool &b, int &mode);
int WebRTCVoe_GetEcStatus(bool &b, int &mode) ;
int WebRTCVoe_GetNsStatus(bool &b, int &mode) ;
#endif //__WRTC_VOICE_ENGINE_H__