205{
209 int is_new = 0;
210
211 if (!chan) {
213 return -1;
214 }
215
216 if (strcasecmp(data, "rx") && strcasecmp(data, "tx")) {
218 return -1;
219 }
220
223
226 return 0;
227 }
228
232 return 0;
233 }
234
238 is_new = 1;
239
240 } else {
241 si = datastore->
data;
242 }
243
244 if (!strcasecmp(data, "rx")) {
246 } else {
248 }
249
250 if (!*sdi) {
252 if (is_new) {
253 datastore->
data = si;
256 } else {
258 }
259 return 0;
260 }
261
262
263
264 (*sdi)->samples = -1;
265 }
266
267 if (!strcasecmp(cmd, "agc")) {
268 if (!sscanf(
value,
"%30f", &(*sdi)->agclevel))
270
271 if ((*sdi)->agclevel > 32768.0) {
272 ast_log(
LOG_WARNING,
"AGC(%s)=%.01f is greater than 32768... setting to 32768 instead\n",
273 ((*sdi == si->
rx) ?
"rx" :
"tx"), (*sdi)->
agclevel);
274 (*sdi)->agclevel = 32768.0;
275 }
276
277 (*sdi)->agc = !!((*sdi)->agclevel);
278
279 if ((*sdi)->state) {
280 speex_preprocess_ctl((*sdi)->state, SPEEX_PREPROCESS_SET_AGC, &(*sdi)->agc);
281 if ((*sdi)->agc) {
282 speex_preprocess_ctl((*sdi)->state, SPEEX_PREPROCESS_SET_AGC_LEVEL, &(*sdi)->agclevel);
283 }
284 }
285 } else if (!strcasecmp(cmd, "denoise")) {
287
288 if ((*sdi)->state) {
289 speex_preprocess_ctl((*sdi)->state, SPEEX_PREPROCESS_SET_DENOISE, &(*sdi)->denoise);
290 }
291 }
292
293 if (!(*sdi)->agc && !(*sdi)->denoise) {
294 if ((*sdi)->state)
295 speex_preprocess_state_destroy((*sdi)->state);
296
299 }
300
301 if (!si->
rx && !si->
tx) {
302 if (is_new) {
303 datastore->
data = si;
304 is_new = 0;
306 } else {
311 }
313 return 0;
314 }
315
316 if (is_new) {
317 datastore->
data = si;
321 } else {
323 }
324
325 return 0;
326}
#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