42#include <speex/speex_preprocess.h>
49#define DEFAULT_AGC_LEVEL 8000.0
120 speex_preprocess_state_destroy(si->
rx->
state);
124 speex_preprocess_state_destroy(si->
tx->
state);
160 si = datastore->
data;
171 speex_preprocess_state_destroy(sdi->
state);
178 speex_preprocess_ctl(sdi->
state, SPEEX_PREPROCESS_SET_AGC, &sdi->
agc);
181 speex_preprocess_ctl(sdi->
state, SPEEX_PREPROCESS_SET_AGC_LEVEL, &sdi->
agclevel);
184 speex_preprocess_ctl(sdi->
state, SPEEX_PREPROCESS_SET_DENOISE, &sdi->
denoise);
188 snprintf(source,
sizeof(source),
"%s/speex", frame->
src);
210 if (strcasecmp(data,
"rx") && strcasecmp(data,
"tx")) {
234 si = datastore->
data;
237 if (!strcasecmp(data,
"rx")) {
253 if (!strcasecmp(cmd,
"agc")) {
254 if (!sscanf(
value,
"%30f", &(*sdi)->agclevel))
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;
263 (*sdi)->agc = !!((*sdi)->agclevel);
266 speex_preprocess_ctl((*sdi)->state, SPEEX_PREPROCESS_SET_AGC, &(*sdi)->agc);
268 speex_preprocess_ctl((*sdi)->state, SPEEX_PREPROCESS_SET_AGC_LEVEL, &(*sdi)->agclevel);
271 }
else if (!strcasecmp(cmd,
"denoise")) {
275 speex_preprocess_ctl((*sdi)->state, SPEEX_PREPROCESS_SET_DENOISE, &(*sdi)->denoise);
279 if (!(*sdi)->agc && !(*sdi)->denoise) {
281 speex_preprocess_state_destroy((*sdi)->state);
287 if (!si->
rx && !si->
tx) {
302 datastore->
data = si;
330 si = datastore->
data;
332 if (!strcasecmp(data,
"tx"))
334 else if (!strcasecmp(data,
"rx"))
341 if (!strcasecmp(cmd,
"agc"))
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdup(str)
A wrapper for strdup()
#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.
@ AST_AUDIOHOOK_DIRECTION_READ
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.
int ast_audiohook_destroy(struct ast_audiohook *audiohook)
Destroys an audiohook structure.
@ AST_AUDIOHOOK_TYPE_MANIPULATE
@ AST_AUDIOHOOK_STATUS_DONE
General Asterisk PBX channel definitions.
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_channel_lock(chan)
#define ast_channel_unlock(chan)
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
#define ast_datastore_alloc(info, uid)
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
static int speex_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static struct ast_custom_function agc_function
#define DEFAULT_AGC_LEVEL
static struct ast_custom_function denoise_function
static int speex_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
static void destroy_callback(void *data)
static int load_module(void)
static int speex_callback(struct ast_audiohook *audiohook, struct ast_channel *chan, struct ast_frame *frame, enum ast_audiohook_direction direction)
static int unload_module(void)
static const struct ast_datastore_info speex_datastore
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Asterisk module definitions.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Core PBX routines and definitions.
#define ast_custom_function_register(acf)
Register a custom function.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
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
enum ast_audiohook_status status
Main Channel structure associated with a channel.
Data structure associated with a custom dialplan function.
Structure for a data store type.
Structure for a data store object.
struct ast_format * format
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
union ast_frame::@226 data
enum ast_frame_type frametype
SpeexPreprocessState * state
struct speex_direction_info * rx
struct ast_audiohook audiohook
struct speex_direction_info * tx