java实现语音外呼,基于freeswitch 自动外呼系统实现(一)_呼叫中心_人工智能_asterisk_freeswitch_语音机器人_语音识别ASR_语音合成TTS_自然语言处理NLP,语音...

本文介绍了一个使用Java实现的基于FreeSwitch的自动群呼系统。系统包括监听模块、任务外呼模块和FIFO实现。通过调用FreeSwitch的API和数据库操作,实现了电话外呼任务的管理和执行,包括任务状态更新、外呼数据获取等核心功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

15年基于freewitch做的自动群呼系统,主要由监听模块,任务外呼模块,及FIFO实现。

1、mod_cctask.c#include 

#include 

#define zstr(x) _zstr(x)

SWITCH_MODULE_LOAD_FUNCTION(mod_cctask_load);

SWITCH_MODULE_RUNTIME_FUNCTION(mod_cctask_runtime);

SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cctask_shutdown);

SWITCH_MODULE_DEFINITION(mod_cctask, mod_cctask_load, mod_cctask_shutdown, mod_cctask_runtime);

switch_api_interface_t *api_interface;

static struct {

switch_hash_t *caller_orig_hash;

switch_hash_t *consumer_orig_hash;

switch_hash_t *bridge_hash;

switch_hash_t *use_hash;

switch_mutex_t *use_mutex;

switch_mutex_t *caller_orig_mutex;

switch_mutex_t *consumer_orig_mutex;

switch_mutex_t *bridge_mutex;

switch_hash_t *fifo_hash;

switch_mutex_t *mutex;

switch_mutex_t *sql_mutex;

switch_memory_pool_t *pool;

int running;

switch_event_node_t *node;

char hostname[256];

char *dbname;

char odbc_dsn[1024];

int node_thread_running;

switch_odbc_handle_t *master_odbc;

int threads;

switch_thread_t *node_thread;

int debug;

struct fifo_node *nodes;

char *pre_trans_execute;

char *post_trans_execute;

char *inner_pre_trans_execute;

char *inner_post_trans_execute;

switch_sql_queue_manager_t *qm;

int allow_transcoding;

switch_bool_t delete_all_members_on_startup;

} globals;

struct callback {

char *buf;

size_t len;

int matches;

};

typedef struct callback callback_t;

struct cc_cctask_call_obj {

char task_id[32];

char gateway[64]; //网关

char exten[64];//分机

char context[64];//context区分

char cid_name[64];//主叫

char cid_num[64];//主叫号码

char fifo_name[64];

};

typedef struct cc_cctask_call_obj cctask_call_obj;

switch_cache_db_handle_t *cctask_get_db_handle(void)

{

switch_cache_db_handle_t *dbh = NULL;

char *dsn;

if (!zstr(globals.odbc_dsn)) {

dsn = globals.odbc_dsn;

} else {

dsn = globals.dbname;

}

if (switch_cache_db_get_db_handle_dsn(&dbh, dsn) != SWITCH_STATUS_SUCCESS) {

dbh = NULL;

}

return dbh;

}

static switch_bool_t cctask_execute_sql_callback(switch_mutex_t *mutex, char *sql, switch_core_db_callback_func_t callback, void *pdata)

{

switch_bool_t ret = SWITCH_FALSE;

char *errmsg = NULL;

switch_cache_db_handle_t *dbh = NULL;

if (mutex) {

switch_mutex_lock(mutex);

}

if (!(dbh = cctask_get_db_handle())) {

switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB\n");

goto end;

}

if (globals.debug > 1) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "sql: %s\n", sql);

switch_cache_db_execute_sql_callback(dbh, sql, callback, pdata, &errmsg);

if (errmsg) {

switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR: [%s] %s\n", sql, errmsg);

free(errmsg);

}

end:

switch_cache_db_release_db_handle(&dbh);

if (mutex) {

switch_mut

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值