做了点小活,一个是实现电话会议,一个是实现接听提醒,一个是实现系统生成CDR。
一、电话会议使用meetme,但meetme是在zaptel的支持下运行的,所以要先安装zaptel
在/usr/src下 svn checkout http://svn.digium.com/svn/zaptel/branches/1.4 zaptel
然后/make clean/make config/make/make install/
加载ztdummy(提供分时接口:Asterisk应用程序和函数需要分时性)
#modprobe ztdummy(查看lsmod | grep ztdummy)
之后在asterisk目录下make menuconfig 进入app中选上meetme模块,重新编译asterisk即可
/make clean/make config/make/make install/
接下来进入cli就能使用meetme的命令
举一个meetme.conf的简单配置例子
[rooms]
conf => 1001,1001,1234 #房间号 密码 管理员密码
二、接听提醒可以在内核中实现,channel.c定义了ast_answer函数,是用户接听的实现
这样改即可:
int ast_answer(struct ast_channel *chan)
{
int res = 0;
ast_channel_lock(chan);
/* You can't answer an outbound call */
if (ast_test_flag(chan, AST_FLAG_OUTGOING)) {
ast_channel_unlock(chan);
return 0;
}
/* Stop if we're a zombie or need a soft hangup */
if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
ast_channel_unlock(chan);
return -1;
}
switch(chan->_state) {
case AST_STATE_RINGING:
case AST_STATE_RING:
if (chan->tech->answer)
res = chan->tech->answer(chan);
ast_streamfile(chan, "/var/lib/asterisk/sounds/callstart", (char *)chan->language);
ast_setstate(chan, AST_STATE_UP);
ast_cdr_answer(chan->cdr);
break;
case AST_STATE_UP:
ast_streamfile(chan, "/var/lib/asterisk/sounds/callstart", (char *)chan->language);
ast_cdr_answer(chan->cdr);
break;
default:
break;
}
ast_channel_unlock(chan);
return res;
}
改完后编译*
三、系统生成CDR
pbx.c中实现了dialplan的命令对应修改的是Answer()和Hangup();
static int pbx_builtin_answer(struct ast_channel *chan, void *data)
{
int delay = 0;
int res;
if (chan->_state == AST_STATE_UP)
delay = 0;
else if (!ast_strlen_zero(data))
delay = atoi(data);
ast_cdr_answer(chan->cdr); //☆
res = ast_answer(chan);
if (res)
return res;
if (delay)
res = ast_safe_sleep(chan, delay);
return res;
}
static int pbx_builtin_hangup(struct ast_channel *chan, void *data)
{
struct ast_cdr *cdr = NULL; /*☆*/
if (chan->cdr) { /* End the CDR if it hasn't already */
ast_cdr_end(chan->cdr);
cdr = chan->cdr;
chan->cdr = NULL;
}
if (cdr)
ast_cdr_detach(chan->cdr); /* post and free the record ☆*/
if (!ast_strlen_zero(data)) {
int cause;
char *endptr;
if ((cause = ast_str2cause(data)) > -1) {
chan->hangupcause = cause;
return -1;
}
cause = strtol((const char *) data, &endptr, 10);
if (cause != 0 || (data != endptr)) {
chan->hangupcause = cause;
return -1;
}
ast_log(LOG_NOTICE, "Invalid cause given to Hangup(): \"%s\"\n", (char *) data);
}
if (!chan->hangupcause) {
chan->hangupcause = AST_CAUSE_NORMAL_CLEARING;
}
return -1;
}
记得重新编译