199{
203 int is_new = 0;
204
205 if (!chan) {
207 return -1;
208 }
209
210 if (strcasecmp(data, "rx") && strcasecmp(data, "tx")) {
212 return -1;
213 }
214
218
220 return 0;
221 }
222
225 return 0;
226 }
227
231 is_new = 1;
232 } else {
234 si = datastore->
data;
235 }
236
237 if (!strcasecmp(data, "rx")) {
239 } else {
241 }
242
243 if (!*sdi) {
245 return 0;
246 }
247
248
249
251 }
252
253 if (!strcasecmp(cmd, "agc")) {
254 if (!sscanf(
value,
"%30f", &(*sdi)->agclevel))
256
257 if ((*sdi)->agclevel > 32768.0) {
258 ast_log(
LOG_WARNING,
"AGC(%s)=%.01f is greater than 32768... setting to 32768 instead\n",
259 ((*sdi == si->
rx) ?
"rx" :
"tx"), (*sdi)->agclevel);
260 (*sdi)->agclevel = 32768.0;
261 }
262
263 (*sdi)->agc = !!((*sdi)->agclevel);
264
265 if ((*sdi)->state) {
266 speex_preprocess_ctl((*sdi)->state, SPEEX_PREPROCESS_SET_AGC, &(*sdi)->agc);
267 if ((*sdi)->agc) {
268 speex_preprocess_ctl((*sdi)->state, SPEEX_PREPROCESS_SET_AGC_LEVEL, &(*sdi)->agclevel);
269 }
270 }
271 } else if (!strcasecmp(cmd, "denoise")) {
273
274 if ((*sdi)->state) {
275 speex_preprocess_ctl((*sdi)->state, SPEEX_PREPROCESS_SET_DENOISE, &(*sdi)->denoise);
276 }
277 }
278
279 if (!(*sdi)->agc && !(*sdi)->denoise) {
280 if ((*sdi)->state)
281 speex_preprocess_state_destroy((*sdi)->state);
282
285 }
286
287 if (!si->
rx && !si->
tx) {
288 if (is_new) {
289 is_new = 0;
290 } else {
296 }
297
299 }
300
301 if (is_new) {
302 datastore->
data = si;
307 }
308
309 return 0;
310}
#define ast_calloc(num, len)
A wrapper for calloc()
@ AST_AUDIOHOOK_MANIPULATE_ALL_RATES
int ast_audiohook_init(struct ast_audiohook *audiohook, enum ast_audiohook_type type, const char *source, enum ast_audiohook_init_flags flags)
Initialize an audiohook structure.
int ast_audiohook_remove(struct ast_channel *chan, struct ast_audiohook *audiohook)
Remove an audiohook from a specified channel.
int ast_audiohook_detach(struct ast_audiohook *audiohook)
Detach audiohook from channel.
int ast_audiohook_attach(struct ast_channel *chan, struct ast_audiohook *audiohook)
Attach audiohook to channel.
@ AST_AUDIOHOOK_TYPE_MANIPULATE
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
#define ast_datastore_alloc(info, uid)
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
#define DEFAULT_AGC_LEVEL
static int speex_callback(struct ast_audiohook *audiohook, struct ast_channel *chan, struct ast_frame *frame, enum ast_audiohook_direction direction)
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
ast_audiohook_manipulate_callback manipulate_callback