Freeswitch FAQ

How to configure DID under FreeSwitch

First of all, what is DID? Translated into Chinese as "direct inward dialing", this service is provided by the telephone company, which enables users to directly dial extension numbers in PBX or VOIP systems without resorting to switchboards or automated calls service system.

Now to achieve such a function - dial a number (for example: 01088888888) through a mobile phone or landline, you can directly contact the user 1008 of the VOIP system (FreeSwitch system). As shown below:

Mobile/Landline-------------------> 01088888888 ---------------> VOIP System--------- --------> 1008

This is done in two steps:

(1) Configure the gateway

Add an XML file in \conf\sip_profiles\external named: gw-DID.xml. The content is as follows:

              <include>
                      <gateway name="gw-DID">
                            <param name="realm" value="27.54.226.74"/> // Server IP provided by sip provider
                            <param name="username" value="88888888"/>// DID account provided by sip provider
                            <param name="password" value="12345678"/> // DID account password provided by sip provider
                            <param name="proxy" value="27.54.226.74"/> // server IP provided by sip provider
                            <param name="register" value="true"/>
                            <param name="expire-seconds" value="600"/>
                            <param name="ping" value="30"/>
                            <param name="sip-trace" value="true"/>
                      </gateway>
                </include>



(2) Configure the dial plan

Modify public.xml in \conf\dialplan and add the following:

 

               <extension name="sipprovider">   
                      <condition field="destination_number" expression="^88888888$">
                             <action application="transfer" data="1008 XML default"/>
                       </condition>
                </extension>



           Enter reloadxml through FS_CLI.

 

Call multiple users simultaneously via FreeSwitch

You can call multiple terminals through FreeSwitch. According to different ringing sequences, they can be divided into: simultaneous ringing and sequential ringing.

Simultaneous ringing refers to the simultaneous ringing of multiple terminals; sequential ringing refers to sequential ringing of multiple terminals.

The following application is implemented below. A user dials the access number 2000 and hopes that 1000 and 1001 will ring at the same time. Either one answers the incoming call and the other stops ringing.

(1) Add the following content to \conf\dialplan\default.xml,

                      <extension name="group_dial_sim">
                           <condition field="destination_number" expression="^2000$">
                               <action application="bridge" data="sofia/internal/[email protected],sofia/sip/[email protected]"/>
                           </condition>
                       </extension>

            在 FS_CLI.exe 中运行 reloadxml 即可。

下面实现如下应用, 某用户拨叫 2000 这个接入号码,希望 1000 和 1001 顺序振铃,其中任一个接听来话,另一个停止振铃。

2)在 \conf\dialplan\default.xml中添加如下内容,

                      <extension name="group_dial_seq">
                           <condition field="destination_number" expression="^2000$">
                               <action application="bridge" data="sofia/internal/[email protected]|sofia/sip/[email protected]"/>
                           </condition>
                       </extension>

在 FS_CLI.exe 中运行 reloadxml 即可。

 

在FreeSwitch中修改主叫显示名称

如果你想通过你的IP话机呼叫其他用户的时候,在对方话机显示能标识你的名称,在FreeSwitch中该怎么配置?

需求:

1000 和 1001 分别是两部话机,1000时张三的话机,1001是李四的话机。若1000发起呼叫,需要在对方话机上显示“zhangsan”;若1001发起呼叫,需要在对方话机上显示“lisi”.

配置:

进入 \conf\directory\default\*.xml

(1) 编辑 1000.xml ,找到 <variable name="effective_caller_id_name" value="1000"/>,修改为 <variable name="effective_caller_id_name" value="zhangsan"/>;

(2) 编辑 1000.xml ,找到 <variable name="effective_caller_id_name" value="1001"/>,修改为 <variable name="effective_caller_id_name" value="lisi"/>;

通过 FS_CLI.exe 运行 reloadxml 即可。

 

FreeSwitch中修改注册用户的密码

在FreeSwitch系统中,所有用户的密码默认为 1234,该设置在 \conf\vars.xml 中,如下所示:<X-PRE-PROCESS cmd="set" data="default_password=1234"/>

若需要修改默认密码的话,直接修改该处即可。

那用户的密码和默认密码怎么关联起来?请看下面的配置文件,以 用户 1000 为例,打开 \conf\directory\default\1000.xml ,找到如下设置:

<param name="password" value="$${default_password}"/>,即可找到他们之间的联系。若需要修改某用户的密码,直接修改 value 值即可。

修改配置完成后,通过 FS_CLI.exe 运行 reloadxml 即可。

 

FreeSwitch中用户不经过认证即可注册成功

一般来说,FreeSwitch中的SIP 用户都需要通过用户名和密码进行认证后才能注册成功,并进行通话。若有特殊需要,也可以设置为无认证即可使用,具体设置如下 :

打开 \conf\sip_profiles\internal.xml ,将如下两条设置去掉注释即可,

 

 

           即:

           <param name="accept-blind-auth" value="true"/> 
            <param name="suppress-cng" value="true"/> 

 

在 FS_CLI.exe 中运行 reloadxml 即可。

 

FreeSwitch中添加新组

FreeSwitch中默认有三个组,分别为:sales ,billing,support。 在 \conf\directory\default.xml 中可以查到。

注意: 在 FreeSwitch中,同一个用户可以在不同的分组中存在。官方解释如下 :


type="pointer" is a pointer so you can have the same user in multiple groups. It basically means to keep searching for the user in the directory.


若需要添加一个 名为 ZOO的新组,需要在 \conf\directory\default.xml 中,找到 <groups> 标签,然后添加如下内容即可,

                  <group name="ZOO">
                      <users>
                      <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"/>
                      </users>
                  </group>



在 FS_CLI.exe 中输入 reloadxml,重新加载新的XML文件即可。

 

FreeSwitch中添加新用户

FreeSwitch 中默认配置了20个用户,分别是: 1000 到 1019。在 \conf\directory\default 目录下有每个用户的XML配置文件。

若想新添加一个用户,可以通过如下步骤进行:

(1)在/conf/directory/default/增加一个用户配置文件.如下所示:

                <include>
                     <user id="1020">
                          <params>
                              <param name="password" value="$${default_password}"/>
                              <param name="vm-password" value="1020"/>
                          </params>
                          <variables>
                               <variable name="toll_allow" value="domestic,international,local"/>
                               <variable name="accountcode" value="1020"/>
                               <variable name="user_context" value="default"/>
                               <variable name="effective_caller_id_name" value="Extension 1020"/>
                               <variable name="effective_caller_id_number" value="1020"/>
                               <variable name="outbound_caller_id_name" value="$${outbound_caller_name}"/>
                               <variable name="outbound_caller_id_number" value="$${outbound_caller_id}"/>
                               <variable name="callgroup" value="techsupport"/>
                          </variables>
                  </user>
             </include>



(2) 修改拨号计划,以使得其他用户可以呼到他。如下所示:

                   在  \conf\dialplan\default.xml中,修改 如下 语句 - 
                  <extension name="Local_Extension">
                      <condition field="destination_number" expression="^(10[01][0-9])$">

                   为 -》

                  <extension name="Local_Extension">
                       <condition field="destination_number" expression="^(10[012][0-9])$">



(3) 在 FS_CLI.exe 中运行 reloadxml,即可生效。

 

FreeSwitch中配置网关的方法

在VOIP通信系统中,经常要用到网关。那么网关怎么和FreeSwitch在一起配合使用?

有如下需求:

有一虚拟运营商(即:SIP PROVIDER ),提供拨打外线的功能。从该处购买一 SIP 账号,具体配置信息如下:

用户名:user

密码: pass

服务器IP:100. 100.100.100

想通过和该SIP PROVIDER 对接实现拨打外线功能。即:0+要拨打的号码,就送到该SIP PROVIER (说明:此时的 SIP PROVIDER 相当于一网关)。

解决方法:

1)添加一个网关

                 在 \conf\sip_profiles\external 中添加一个名为GW_TEST.xml 的文件,内容如下:

                 <gateway name="GW_TEST">
                     <param name="realm" value="100. 100.100.100"/>
                     <param name="username" value="user"/>
                     <param name="password" value="pass"/>
                  </gateway>

(2) 新建一个拨码计划

                在 \conf\dialplan\default 中新建一个名为 call_gw_test.xml 的文件 ,内容如下:

                 <include>
                     <extension name="call out">
                        <condition field="destination_number" expression="^0(\d+)$">
                           <action application="bridge" data="sofia/gateway/GW_TEST/$1"/>
                        </condition>
                     </extension>
                 </include>



(3) 通过 FS_CLI.exe 运行 reloadxml ,即可生效。

 

FreeSwitch中的录像功能和播放录像功能

FreeSwitch 系统中的录像功能 和 播放录像功能,系统都默认提供。

按默认配置,通过IP电话拨打9193,即可录像;通过IP电话拨打9194即可播放录像。

同时,我测试了一种有趣的用法,描述如下:

        (1) 1000  呼叫 9193 并且发送视频;

        (2) 1001 呼叫 9194 ,可以看到 1000 上传的视频,但非实时;

        (3) 1002 呼叫 9194, 可以看到 1000 上传的视频,但非实时。

这样看来,一个点播系统,FreeSwitch 默认就支持!稍加改造,就可以变为一套视频直播系统。

实现上述功能的配置文件在 \conf\dialplan\default.xml 中,如下所示:

          [录像]

          <extension name="video_record">
             <condition field="destination_number" expression="^9193$">
                 <action application="answer"/>
                 <action application="record_fsv" data="/tmp/testrecord.fsv"/>
             </condition>
           </extension>

          [播放录像]

          <extension name="video_playback">
              <condition field="destination_number" expression="^9194$">
                   <action application="answer"/>
                   <action application="play_fsv" data="/tmp/testrecord.fsv"/>
               </condition>
           </extension>

FreeSwitch的录音功能

一般电话系统都可以将本系统内的语音通话录制下来,FreeSwitch 系统中也可以进行语音录制。

需求: 录制系统中的所有通话。

实现:

(1)建立一个文件夹 freeswitch/recordings/archive/ ,用来存储录音文件;

(2)修改拨码计划,打开 \conf\dialplan\default.xml

找到下面的语句:

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

在其下,添加:

                     <action application="set" data="RECORD_TITLE=Recording ${destination_number} ${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"/>

(3)在 FS_CLI.EXE 中运行 reloadxml 或 按 F6 即可生效。

查询 FreeSwitch 支持的音频文件格式,可以在 FS_CLI.exe 中运行 show file 命令。

FreeSwitch播放语音文件

上一篇介绍了 FreeSwitch 的录音功能,若想回放这些录音,是否可以实现?或者说,通过 FreeSwitch ,是否可以直接播放语音文件?

FreeSwitch 中有一个 playback 的 application ,可以播放语音文件。

具体用法如下:

(1)播放本地文件

                       <action application="set" data="playback_terminators=none"/>

                       <action application="playback" data="sounds/soundfile.wav"/>  

(2)播放远程服务器上的文件

                       <action application="playback" data="${http_get(http://myserver.yo/media/hello_world.wav)}"/>

 

FreeSwitch中的会议功能(1)

FreeSwitch 默认支持会议功能,有如下特点:

(1) 不需要创建一个会议室的操作,只需要通过 conference 拨码计划就可以实现;

(2) 会议室不真正存在, 直到有人呼入为止;

(3) 会议功能很强大,能实现灵活控制。


这样讲太学术化,来点直观的,步骤如下:

         (1) 运行 FREESWITCH 服务器程序;

         (2) 注册 1000、1001、1002三部IP话机;

         (3) 通过 1000 呼叫 3000,通话建立后, 1000 将听到一段保持音乐;

         (4) 通过 1001 呼叫 3000,通话建立后, 1001将能听到1000的声音,1000也能听到1001的声音;

         (5) 通过 1002 呼叫 3000,通话建立后,  1002将能听到 1000 和 1001的声音,1001能听到1000和1002的声音,1000也能听到 1001 和 1002 的声音。

         

那 3000 这个号码是怎么来的? 请看 \conf\dialplan\default.xml 中的内容,如下所示:

            <extension name="nb_conferences">
                <condition field="destination_number" expression="^(30\d{2})$">
                   <action application="answer"/>
                   <action application="conference" data="$1-${domain_name}@default"/>
                </condition>
             </extension>

           ......

 

FreeSwitch中的会议功能(2)

FreeSwitch 提供了一些控制会议成员行为的方法,罗列如下:

(1)Talk volume: The volume of the audio the caller sends (that is, gain control).

    与会成员讲话的音量控制;

(2)Listen volume: The volume of the audio the caller hears.

    与会成员收听语音的音量控制;

(3)Energy threshold: The minimum energy level of the audio from the caller to be considered talking. Raising the energy level will cut down on background noise when a participant is in a noisy environment.

    语音门限控制 。

具体用法,可以查看:\conf\autoload_configs\console.conf.xml ,内容如下:

            <caller-controls>
                 <group name="default">
                   <control action="mute" digits="0"/>             // 静音
                   <control action="deaf mute" digits="*"/>      // 解除静音
                   <control action="energy up" digits="9"/>     // 增加门限
                   <control action="energy equ" digits="8"/>   // 
                  <control action="energy dn" digits="7"/>     // 降低门限
                   <control action="vol talk up" digits="3"/>     // 提高讲话音量 
                   <control action="vol talk zero" digits="2"/>  // 讲话音量设置为0
                   <control action="vol talk dn" digits="1"/>     // 降低讲话音量
                   <control action="vol listen up" digits="6"/>  // 提高收听音量
                   <control action="vol listen zero" digits="5"/> // 收听音量设置为0
                   <control action="vol listen dn" digits="4"/>    // 降低收听音量 
                   <control action="hangup" digits="#"/>           // 退出会议
               </group>
            </caller-controls>

 

FreeSwitch中的会议功能(3)

FreeSwitch中可以设置主持人以及会议密码。设置了主持人后,可以影响会议的开展;设置了会议密码后,与会成员必须输入正确密码才能入会。

主持人对会议的影响主要体现在以下两个方面:

     (1)直到主持人入会后,会议才开始;

     (2)主持人退出会议后,会议才结束。



那怎么设置主持人?方法如下:

       <action application="conference" data="$1@default"/> // 未设置主持人
        <action application="conference" data="$1@default+flags{moderator}"/> // 设置了主持人

 
       如何设置会议密码?方法如下:

       <action application="conference" data="$1@default+1234"/> // 设置入会密码为 1234



       如何既设置主持人,又设置会议密码?方法如下:

      <action application="conference" data="$1@default+1234+flags{moderator}"/>

 

FreeSwitch中的会议功能(4)

FreeSwitch 是否支持视频会议?答案是 支持的!

FreeSwitch 默认只支持与会成员看到当前“嗓门最大”的那个人的视频。

在实际应用中,当讲话人改变时,视频会切换,但切换的时候,视频会有马赛克现象。此问题期待高手解决!


场景描述如下:

三个用户 1000、1001、1002 都注册到同一台服务器。

(1)1000 呼叫 3000,进入会议,同时发送自己的视频,1000 可以看到自己;

(2)1001 呼叫 3000,进入会议,可以看到 1000 的视频。若1001也发送自己的视频,双方看到的视频是当前讲话声音大的一方的视频;

(3)1002 呼叫 3000,进入会议,可以看到当前讲话一方的视频。若 1002 也发送自己的视频,三方看到的视频是当前讲话声音大的一方的视频。

再扩展下思维,能否让 FreeSwitch 实现融屏功能,实现与会各方都能彼此看到自己!那FreeSwitch就更强大了。以下是几个相关的资源简介:

(1)BigBluebutton 这个视频会议项目中用到了 FreeSwitch, 项目主页:  http://www.bigbluebutton.org/ 。但对视频的处理只是转发各路视频,没有实现融屏合成一路视频推送到各方显示。

(2)openvcs 是一个开源的 SIP MCU 实现,项目主页:http://code.google.com/p/openvcs/ 。 在 Windows 下实现了融屏的原型设计,但在效率以及并发处理方面,还有许多需要完善的地方。但提供了一个开发 SIP MCU 的思路,这个是很有价值的。

FreeSwitch中的会议功能(5)

邀请手机用户或座机用户入会: 在 FS_CLI.EXE 中运行 类似 conference <conf-id> dial Sofia/gateway/xyz/1234567890 即可。

 

FreeSwitch中的音乐保持功能

Music on hold(MOH) ,即:音乐保持,在一般电话系统中都存在。FreeSwitch也支持该功能,并且保持音乐可配置。 FreeSwitch默认的配置中,用户通过某IP话机拨打 9664 ,呼叫建立后,就可以听到保持音乐。 查看当前系统中音乐文件的路径,可以通过 FS _CLI.EXE 运行 show_local_stream 来显示。 如果你想修改默认的保持音乐,可以自己添加一些好听的音乐进来,方法如下: (1)在 \sounds\music 新建一个文件夹 MOH_TEST,并拷贝音乐文件进去(WAV文件);

(2)在 \conf\autoload_configs\local_stream.conf.xml 中添加如下内容,
                 <directory name="moh_test" path="$${sounds_dir}/music/MOH_TEST">
                    <param name="rate" value="8000"/>
                    <param name="shuffle" value="true"/>
                    <param name="channels" value="1"/>
                    <param name="interval" value="20"/>
                    <param name="timer-name" value="soft"/>
                  </directory>
(3)  在  \conf\vars.xml 中添加如下内容,
                <X-PRE-PROCESS cmd="set" data="moh_test=local_stream://MOH_TEST"/>
(4) 在 \conf\dialplan\default 中添加一个名为 moh_test_call.xml 的文件,内容如下: 
               <include>
                  <extension name="moh_test_call">
                    <condition field="destination_number" expression="^96646$"/>
                       <action application"playback" data="${moh_test}"/>
                    </condition>
                  </extension>
                 </include>

(5)改变了默认的音乐文件后,需要重新加载  mod_local_stream 模块,在 FS_CLI.exe 中运行 reload mod_local_stream 即可生效。 
(6)在 FS_CLI.EXE 中运行 reloadxml 或 按F6,即可生效。

通过某一IP 话机拨打 96646 后,即可听到你自己设置的保持音乐。

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324778613&siteId=291194637