Freeswitch配置变量

简介: 1、SIP 协议

1、SIP 协议

2.设置该变量,告诉系统如果当前有一个桥接成功的通话,挂断当前通话。

网络异常,图片无法展示
|


\

3、Freeswitch 监听电话;


mod_spy 是固定监听一个用户, 是你先开着电话,别人有一电话就开始听。

eavesdrop 是系统自身一个命令APP,  可以实现你说的那些功能,前提是要知道  channel 的 UUID。  

wiki.freeswitch.org/wiki/Misc._…
Mod_spy

4, modules.conf.xml  可以配置哪些模块需要加载,配置后,下次FS启动时,会自动加载这些模块。

该文件位于:\conf\autoload_configs\modules.conf.xml


5,使Freeswitch作为服务运行:

打开cmd命令提示符,切换到Freeswitch的Release目录,然后运行:

freeswitchConsole -install Freeswitch

此时,打开Services.msc控制台,就可以看到Freeswitch服务了,建议设置为自动启动。

6, 主叫,Caller ,被叫 Callee

网络异常,图片无法展示
|

7,  Dialplan中可以使用的caller profile 变量,这些变量可以在呼叫中被传递,passed along from one Leg to Another. 特点,ReadOnly

网络异常,图片无法展示
|

8, FS录音功能:

首先备份/usr/local/freeswitch/conf/dialplan/default.xml 。

然后vi编辑default.xml ,在

<extension name="Local_Extension">

    <condition field="destination_number" expression="^(10[01][0-8])$">

下面加入以下语句即可录音。

<action application="set" data="RECORD_TITLE=Recording destinationnumber {destination_number} destinationnumber {caller_id_number} ${strftime(%Y-%m-%d %H:%M)}"/>

  <action application="set" data="RECORD_COPYRIGHT=(c) 2011"/>

  <action application="set" data="RECORD_SOFTWARE=FreeSWITCH"/>

  <action application="set" data="RECORD_ARTIST=FreeSWITCH"/>

  <action application="set" data="RECORD_COMMENT=FreeSWITCH"/>

  <action application="set" data="RECORD_DATE=${strftime(%Y-%m-%d %H:%M)}"/>

  <action application="set" data="RECORD_STEREO=true"/>

  <action application="record_session" data="$${base_dir}/recordings/archive/{strftime(%Y-%m-%d-%H-%M-%S)}_{destination_number}_${caller_id_number}.wav"/>

大家应该看明白了,录音会自动存放在${base_dir}/recordings/archive下。


9, 设置fs 的Log级别:

Log 6 ,详细见如下表格:

网络异常,图片无法展示
|

10, FSCLI 常用命令;

Show Calls   显示目前有哪些通话

Show Channels  显示目前活跃的独立通道

说明: A channel is a single  Call  leg.

一个call是两个独立的Channel桥接到一块的。


11, 配置SIP网关拨打外部电话


如果你在某个运营商拥有SIP账号,你就可以配置上拨打外部电话了。该SIP账号(或提供该账号的设备)在 FreeSWITCH 中称为SIP网关(Gateway)。添加一个网关只需要在 conf/sip_profiles/external/ 创建一个XML文件,名字可以随便起,如gw1.xml。

<gateway name="gw1">

   <param name="realm" value="SIP服务器地址,可以是IP或IP:端口号"/>

   <param name="username" value="SIP用户名"/>

   <param name="password" value="密码"/>

   <param name="register" value="true" />

如果你的SIP网关还需要其它参数,可以参阅同目录下的 example.xml,但一般来说上述参数就够了。你可以重启 FreeSWITCH,或者执行以下命令使用之生效。

FS> sofia profile external rescan reloadxml

然后显示一下状态:

FS> sofia status

如果显示 gateway gw1 的状态是 REGED ,则表明正确的注册到了网关上。你可以先用命令试一下网关是否工作正常:

FS> originate sofia/gateway/myDefaultGateway/015005600327 &echo()

以上命令会通过网关 gw1 呼叫号码 xxxxxx(可能是你的手机号),被叫号码接听电话后,FreeSWITCH 会执行 echo() 程序,你应该能听到自己的回音。


从某一分机上呼出

如果网关测试正常,你就可以配置从你的SIP软电话或portaudio呼出了。由于我们是把 FreeSWITCH 当作 PBX 用,我们需要选一个出局字冠。常见的 PBX 一般是内部拨小号,打外部电话就需要加拨 0 或先拨 9 。当然,这是你自己的交换机,你可以用任何你喜欢的数字(甚至是字母)。 继续修改拨号计划,创建新XML文件: conf/dialplan/default/call_out.xml :

 <extension name="call out">

   <condition field="destination_number" expression="^0(\d+)$">

     <action application="bridge" data="sofia/gateway/gw1/$1"/>

   

 

其中,(\d+)为正则表达式,匹配 0 后面的所有数字并存到变量 $1 中。然后通过 bridge 程序通过网关 gw1 打出该号码。当然,建立该XML后需要在Fs-Con中执行 reloadxml 使用之生效。

12,  Authentication AND  Authorization

Authentication is the process of  identifying a user.

Authorization is the process of determining the level of access of a user.

13, Freeswitch 添加用户步骤:

1), \conf\directory\default 添加一个xml文件,拷贝其他作为参考。

2),修改\conf\dialplan\default.xml 找到 Local_Extension,修改正则表达式

<condition field="destination_number" expression="^(10[01][0-9]|1100)$">

使得新添加的用户立即生效,


Reloadxml

14,Freeswitch查看目前有哪些分机已经注册:

sofia status  profile internal reg

15,Freeswitch 拨打分机,当被叫分机不在线时,按键#号,可以跳过语音提示,直接留言。

用户如果需要听语音留言,可以拨号 4000, 按照语音提示输入 分机号和 密码,通过认证后即可收听语音留言。

16,配置Freeswitch的group,当用户拨打组的分机号时, 组内所有的分机都会ringing,

其中一个用户接听后,其他的用户都会stop ringing。同一个用户可以属于多个group

示例:\conf\dialplan\default.xml 配置信息;

  <extension name="group_dial_billing">

     <condition field="destination_number" expression="^2002$">

<action application="bridge" data="group/billing@${domain_name}"/>

     

Group的配置信息:\conf\directory\default.xml

     <group name="billing">

 <user id="1005" type="pointer"/>

 <user id="1006" type="pointer"/>

 <user id="1007" type="pointer"/>

 <user id="1008" type="pointer"/>

 <user id="1009" type="pointer"/>

     

17, 重新加载外部SIP账户信息:

Sofia profile External restart ReloadXml    (该操作会中断所有正在进行的通话)

查看外部SIP账户注册状态:

Sofia Status

仅重新加载指定的外部SIP账户信息,而不是全部:

Sofia profile  rescan ReloadXML

18, dialplan 中可以使用的条件变量:condition

condition就是决定当然呼叫是否要在这个extension中处理的一个模式匹配标签。

语法:

<condition field="[{field_name}|variablename∣{variable_name}|variablename{api_func(api_args ${var_name})}]" expression="{expression}" break="[on-true|on-false|always|never]">

  <action application="app name" data="app arg"/>

  <anti-action application="app name" data="app arg"/>

condition>fileld和expression是必须的,break是可选的。

有一些内部变量可以用:

•context Why can we use the context as a field? Give us examples of usages please.

•rdnis Redirected Number, the directory number to which the call was last presented.

•destination_number Called Number, the number this call is trying to reach (within a given context)

•dialplan Name of the dialplan module that are used, the name is provided by each dialplan module. Example: XML

•caller_id_name Name of the caller (provided by the User Agent that has called us).

•caller_id_number Directory Number of the party who called (caller) -- can be masked (hidden)

•ani Automatic Number Identification, the number of the calling party (caller) -- cannot be masked

•aniii The type of device placing the call ANI2

•uuid Unique identifier&nb, sp;of the current call? (looks like a GUID)

•source Name of the FreeSWITCH module that received the call (e.g. PortAudio)

•chan_name Name of the current channel (Example: PortAudio/1234). Give us examples when this one can be used.

•network_addr IP address of the signaling source for a VoIP call.

•year Calendar year, 0-9999

•yday Day of year, 1-366

•mon Month, 1-12 (Jan = 1, etc.)

•mday Day of month, 1-31

•week Week of year, 1-53

•mweek Week of month, 1-6

•wday Day of week, 1-7 (Sun = 1, Mon = 2, etc.)

•hour Hour, 0-23

•minute Minute (of the hour), 0-59

•minute-of-day Minute of the day, (1-1440) (midnight = 1, 1am = 60, noon = 720, etc.)

除了上面的变量外,还可以使用自定义的变量variable,以及一些api函数{variable},以及一些api函数variableapi{api(args)}

这些变量可以在field及expression里。

condition是不能嵌套的,但可以将多个condition堆在一起,并设置break为on-false(默认值),这样的效果与嵌套一样。

示例1,利用cond API函数:

<condition field="{cond({my_var} > 12 ? YES : NO)}" expression="^YES$">

   <action application="log" data="INFO ${my_var} is indeed greater than 12"/>

   <anti-action application="log" data="INFO ${my_var} is not greater than 12"/>

condition>示例2, 嵌套效果:

<extension name="To PSTN">

 <condition field="fdnis" expression="9541231234"/>

 <condition field="destination_number" expression="(.*)">

   

     <action application="bridge" data="sofia/profilename/$1@x.x.x.x:5061"/>

  condition>

extension>


相关文章
|
测试技术 Linux 内存技术
怎样设置freeswitch 的高并发数
怎样设置freeswitch 的高并发数
freeswitch 默认拨号方案(下)
freeswitch默认拨号方案中(conf/dialplan/default.xml)设置了一些基本的测试功能和PBX电话系统功能 包含了分机互拨及简单IVR功能
|
Web App开发 存储 编解码
Freeswitch关于支持jsip的配置
1、freeswitch安装过程(安装过程省略,运行环境为centos7,freeswitch1.6.5)
|
Web App开发 存储 人工智能
从入门到进阶-如何基于FreeSWITCH搭建呼叫中心平台
FreeSWITCH 是一个开源的电话交换平台。博主从事多年AI技术,外呼中心搭建,需要演示站或技术支持联系博主。官方给它的定义是–世界上第一个跨平台的、伸缩性极好的、免费的、多协议的电话软交换平台
1851 0
|
Java API Maven
【开源视频联动物联网平台】JAIN-SIP库写一个SIP服务器
【开源视频联动物联网平台】JAIN-SIP库写一个SIP服务器
908 0
|
Ubuntu Linux 开发工具
Android 使用Linphone SDK开发SIP客户端
Android 使用Linphone SDK开发SIP客户端
1684 0
Android 使用Linphone SDK开发SIP客户端
|
Web App开发 编解码 人工智能
从通信到AI FreeSWITCH与WebRTC
FreeSWITCH是一个开源的软交换平台,具有模块化结构,支持包括WebRTC在内的多种互通互联。本文来自FreeSWITCH 中文社区创始人杜金房在LiveVideoStack线上交流分享中的演讲,详细介绍了FreeSWITCH的功能特性、架构以及现状。
1824 1
从通信到AI FreeSWITCH与WebRTC
|
Java 数据库连接 数据库
FreeSwitch实现简单呼叫中心功能
FreeSwitch实现简单呼叫中心功能
|
存储 视频直播
FreeSwitch中的录像和录音设置
FreeSwitch中的录像和录音设置