44 #include <speex/speex_preprocess.h>
51 #define DEFAULT_AGC_LEVEL 8000.0
119 speex_preprocess_state_destroy(si->
rx->
state);
123 speex_preprocess_state_destroy(si->
tx->
state);
159 si = datastore->
data;
169 speex_preprocess_state_destroy(sdi->
state);
176 speex_preprocess_ctl(sdi->
state, SPEEX_PREPROCESS_SET_AGC, &sdi->
agc);
179 speex_preprocess_ctl(sdi->
state, SPEEX_PREPROCESS_SET_AGC_LEVEL, &sdi->
agclevel);
182 speex_preprocess_ctl(sdi->
state, SPEEX_PREPROCESS_SET_DENOISE, &sdi->
denoise);
186 snprintf(source,
sizeof(source),
"%s/speex", frame->
src);
208 if (strcasecmp(data,
"rx") && strcasecmp(data,
"tx")) {
232 si = datastore->
data;
235 if (!strcasecmp(data,
"rx")) {
251 if (!strcasecmp(cmd,
"agc")) {
252 if (!sscanf(value,
"%30f", &(*sdi)->agclevel))
255 if ((*sdi)->agclevel > 32768.0) {
256 ast_log(
LOG_WARNING,
"AGC(%s)=%.01f is greater than 32768... setting to 32768 instead\n",
257 ((*sdi == si->
rx) ?
"rx" :
"tx"), (*sdi)->agclevel);
258 (*sdi)->agclevel = 32768.0;
261 (*sdi)->agc = !!((*sdi)->agclevel);
264 speex_preprocess_ctl((*sdi)->state, SPEEX_PREPROCESS_SET_AGC, &(*sdi)->agc);
266 speex_preprocess_ctl((*sdi)->state, SPEEX_PREPROCESS_SET_AGC_LEVEL, &(*sdi)->agclevel);
269 }
else if (!strcasecmp(cmd,
"denoise")) {
270 (*sdi)->denoise = (
ast_true(value) != 0);
273 speex_preprocess_ctl((*sdi)->state, SPEEX_PREPROCESS_SET_DENOISE, &(*sdi)->denoise);
277 if (!(*sdi)->agc && !(*sdi)->denoise) {
279 speex_preprocess_state_destroy((*sdi)->state);
285 if (!si->
rx && !si->
tx) {
300 datastore->
data = si;
328 si = datastore->
data;
330 if (!strcasecmp(data,
"tx"))
332 else if (!strcasecmp(data,
"rx"))
339 if (!strcasecmp(cmd,
"agc"))
340 snprintf(buf, len,
"%.01f", sdi ? sdi->
agclevel : 0.0);
342 snprintf(buf, len,
"%d", sdi ? sdi->
denoise : 0);
#define ast_channel_lock(chan)
Main Channel structure associated with a channel.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk main include file. File version handling, generic pbx functions.
int ast_audiohook_init(struct ast_audiohook *audiohook, enum ast_audiohook_type type, const char *source)
Initialize an audiohook structure.
static int load_module(void)
int ast_audiohook_remove(struct ast_channel *chan, struct ast_audiohook *audiohook)
Remove an audiohook from a specified channel.
static int speex_callback(struct ast_audiohook *audiohook, struct ast_channel *chan, struct ast_frame *frame, enum ast_audiohook_direction direction)
Structure for a data store type.
int ast_audiohook_attach(struct ast_channel *chan, struct ast_audiohook *audiohook)
Attach audiohook to channel.
static int speex_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
Structure for a data store object.
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.
int ast_audiohook_destroy(struct ast_audiohook *audiohook)
Destroys an audiohook structure.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
ast_audiohook_manipulate_callback manipulate_callback
struct ast_audiohook audiohook
General Asterisk PBX channel definitions.
static struct ast_custom_function denoise_function
Data structure associated with a custom dialplan function.
Core PBX routines and definitions.
int ast_audiohook_detach(struct ast_audiohook *audiohook)
Detach audiohook from channel.
static void destroy_callback(void *data)
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
struct speex_direction_info * tx
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
struct ast_datastore * ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
#define DEFAULT_AGC_LEVEL
#define ast_channel_unlock(chan)
static struct ast_custom_function agc_function
if(yyss+yystacksize-1<=yyssp)
static int unload_module(void)
struct speex_direction_info * rx
Data structure associated with a single frame of data.
enum ast_audiohook_status status
enum ast_frame_type frametype
static int speex_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
static struct ast_datastore_info speex_datastore
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
union ast_frame::@172 data
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
SpeexPreprocessState * state
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
#define ast_custom_function_register(acf)
Register a custom function.
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.