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
224
226 return 0;
227 }
228
231 return 0;
232 }
233
237 is_new = 1;
238 } else {
240 si = datastore->
data;
241 }
242
243 if (!strcasecmp(data, "rx")) {
245 } else {
247 }
248
249 if (!*sdi) {
251 return 0;
252 }
253
254
255
257 }
258
259 if (!strcasecmp(cmd, "agc")) {
260 if (!sscanf(
value,
"%30f", &(*sdi)->agclevel))
262
263 if ((*sdi)->agclevel > 32768.0) {
264 ast_log(
LOG_WARNING,
"AGC(%s)=%.01f is greater than 32768... setting to 32768 instead\n",
265 ((*sdi == si->
rx) ?
"rx" :
"tx"), (*sdi)->agclevel);
266 (*sdi)->agclevel = 32768.0;
267 }
268
269 (*sdi)->agc = !!((*sdi)->agclevel);
270
271 if ((*sdi)->state) {
272 speex_preprocess_ctl((*sdi)->state, SPEEX_PREPROCESS_SET_AGC, &(*sdi)->agc);
273 if ((*sdi)->agc) {
274 speex_preprocess_ctl((*sdi)->state, SPEEX_PREPROCESS_SET_AGC_LEVEL, &(*sdi)->agclevel);
275 }
276 }
277 } else if (!strcasecmp(cmd, "denoise")) {
279
280 if ((*sdi)->state) {
281 speex_preprocess_ctl((*sdi)->state, SPEEX_PREPROCESS_SET_DENOISE, &(*sdi)->denoise);
282 }
283 }
284
285 if (!(*sdi)->agc && !(*sdi)->denoise) {
286 if ((*sdi)->state)
287 speex_preprocess_state_destroy((*sdi)->state);
288
291 }
292
293 if (!si->
rx && !si->
tx) {
294 if (is_new) {
295 is_new = 0;
296 } else {
302 }
303
305 }
306
307 if (is_new) {
308 datastore->
data = si;
313 }
314
315 return 0;
316}
#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