freeswitch支持电话拨入,可以接入远端IPPBX实现和现网电话的互通。
有时候我们需要统计记录所有的电话详单,并输出到指定的数据库用于数据统计。
包括呼叫方,被叫方,呼叫时间,接听时间,挂断时间,通话时长,会话等等信息。
于是,这部分可以自己写一个freeswitch插件来完成上述功能。
自己动手即可。
诀窍很简单,只要知道几个关键API即可。
首先创建一个插件。
SWITCH_MODULE_LOAD_FUNCTION(mod_cdr_mysql_load)
{
switch_status_t status = SWITCH_STATUS_SUCCESS;
load_config(pool);
if ((status = switch_dir_make_recursive(globals.log_dir, SWITCH_DEFAULT_DIR_PERMS, pool)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating %s\n", globals.log_dir);
}
switch_core_add_state_handler(&state_handlers);
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
return status;
}
SWITCH_MODULE_SHUTD