1, 概述
freeswitch自带了许多app接口和api接口,可以满足常用的大部分需求,但是有些定制化需求仍然需要我们自己增加或修改当前接口
2, 环境
Centos:CentOS release 6.7 (Final)
Freeswitch:v1.6.5
3, 目的
原本的回拨流程:
呼叫1001用户
originate {origination_uuid=1}user/1001 &echo()
1001 answer后呼叫1002用户
originate {origination_uuid=2}user/1002 &echo()
1002answer后发送命令把1001和1002桥接起来
uuid_bridge 1 2
新的需求:
1002返回sip 183消息后,需要把1002的彩铃透传给1001
为了实现这一点,我们就需要在1002ring后,把1001和1002桥接起来
并且原本的流程中,originate1002到uuid_bridge之间的实现有些繁琐和冗余(因为&echo()的关系,需要收到answer和execute之后才能执行uuid_bridge,否则有可能桥接失败)
新的回拨流程:
呼叫1001用户
originate {origination_uuid=1}user/1001 &echo()
1001 answer后呼叫1002用户,并把1001和1002桥接起来
originate {origination_uuid=2}user/1002 &uuid_bridge(1,2)
新的问题:
originate 1002的时候,&后面需要的是一个app接口,但是uuid_bridge是一个api接口,不能这样调用
研究之后决定,新增一个实现uuid_bridge的功能的app接口,app_uuid_bridge()
4, 代码
修改fs1.6.5\src\mod\applications\mod_dptools\mod_dptools.c
#define APP_UUID_BRIDGE_Syntax "UUIDA UUIDB"
SWITCH_STANDARD_APP(app_uuid_bridge_function)
{
char *uuida;
char *uuidb;
char *mydata,*argv[2]= { 0 };
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),SWITCH_LOG_DEBUG,"app_uuid_bridge_function\n");
if (!zstr(data)&& (mydata = switch_core_session_strdup(session,data))) {
switch_separate_string(mydata,',argv,(sizeof(argv) / sizeof(argv[0])));
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),SWITCH_LOG_ERROR,"No uuid specified.\n");
return;
}
uuida = argv[0];
uuidb = argv[1];
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),"app_uuid_bridge_function(UUIDA=%s,UUIDB=%s)\n",uuida,uuidb);
switch_ivr_uuid_bridge(uuida,uuidb);
}
SWITCH_ADD_APP(app_interface,"app_uuid_bridge","bridge by uuid",app_uuid_bridge_function,APP_UUID_BRIDGE_Syntax,SAF_SUPPORT_NOMEDIA);
5, 编译安装
cd fs1.6.5/src/mod/applications/mod_dptools/
make
make install
6, 运行
因为mod_dptools是接口模块,无法unload,只能重启freeswitch
/usr/local/freeswitch/bin/freeswitch -stop
/usr/local/freeswitch/bin/freeswitch -nc
7, 测试
originate{origination_uuid=1}user/1001 &echo()
originate{origination_uuid=2}user/1002 &app_uuid_bridge(1,2)
1002ring之后,1001就可以听到1002的彩铃声音了
如果有更好的方法或建议,请留言,谢谢
原文链接:https://www.f2er.com/centos/382173.html