我建了一個 Freeswitch 核心研究 交流群, 45211986, 歡迎加入, 另外,提供基于SIP的通信伺服器及用戶端解決方案,
承接 sip/ims 視訊用戶端開發,支援接入sip軟交換,ims核心網,支援 語音,視訊,即時通信功能,視訊格式支援 h263,h264,mpeg4 軟編軟解,提供硬體編解碼接口對接,提供伺服器,有興趣請聯系我。
Freeswitch包含xml 格式dialplan,asterisk likedialplan以及外部語言接口的dialplan,
Dialplan放在conf/dialplan目錄,由三個主要檔案組成:
default.xml—The primary FreeSWITCHDialplan configuration
public.xml—Handles calls coming in toFreeSWITCH from another location
features.xml—A special context for handlingspecific dialing features
default/—Files in this directory getincluded in the default context
public/—Filesin this directory get included in the public context
Xml格式dialplan從高到低分group ,Context,extenstion,級别.Group是Context的集合,
每個Context一個或者多個extenstion的組合,是一個邏輯上的概念,extension 實際上也是一個邏輯上的概念,他并不是傳統pbx上分機的概念,一個extension 代表一個小的,根據被叫号碼指定的一個功能集合,一個extension被其name唯一标示,freeswitch預設配置包含三個Context, 名字分别為default,public和features,default為主dialplan,注冊到freeswitch的分機會被路由到此context,大部分都在這裡實作,public是從外部(未注冊)或者那些未認證的用戶端呼叫到freeswitch時采用的Context,features context是一些呼叫特性的實作,每個extension是根據條件執行的一系列application,一般是根據被叫号碼指定的一系列規則,這些application 構成了可程式設計pbx的基礎,context, extension,application(action)關系如下:
每個進入freeswitch的呼叫都在freeswitch裡預先定義了其 context,DialPlan,及extenstion,這些規則指定了如何路由這個呼叫,系統預設xml dialplan的context為default.
/usr/local/freeswitch/conf/dialplan/default.xml
為freeswitch内部分機(驗證)的預設dialplan,Context name 為default,裡面包含許多例子,
此檔案同時包括/usr/local/freeswitch/conf/dialplan/default/*.xml目錄下的所有檔案,
是以如果想在default context下添加自己的dialplan,令寫一個xml放在 default目錄即可。
另外,如果想添加自己的context,可以在/usr/local/freeswitch/conf/dialplan/ 添加一個xml檔案,
與default.xml類似,/usr/local/freeswitch/conf/dialplan/public.xml為非注冊到freeswitch的終端呼入的dialplan,Context 名為 public,/usr/local/freeswitch/conf/dialplan/public/目錄可以添加context為public的extension.
在xml配置檔案裡包含其他目錄下檔案的方法為用宏X-PRE-PROCESS,如下例子包含default目錄下的所有xml檔案到此xml檔案。
<X-PRE-PROCESS cmd="include"data="default/*.xml"/>
Freeswitch預設提供了大量測試demo,根據被叫号碼對應不同功能,清單如下:
Extension: | Function: |
1000—1019 | Local Extensions |
** + Extension Number | Intercept a ringing phone (that is, "call pickup") |
2000 | Sample call group: Sales |
2001 | Sample call group: Support |
2002 | Sample call group: Billing |
3000-3399 | Sample conference rooms |
4000 or *98 | Retrieve voicemail |
5000 | Demo IVR |
5900 | FIFO queue park |
5901 | FIFO queue retrieve |
6000 | Valet park retrieval, manual |
6001-6099 | Valet park/retrieval, automatic |
9178 | Example fax receive |
9179 | Example fax transmit |
9180 | Ring test, far end generates ring tone |
9181 | Ring test, send U.K. ring tone |
9182 | Ring test, send music as ring tone |
9183 | Answer, then send U.K. ring tone |
9184 | Answer, then send music as ring tone |
9191 | ClueCon registration |
9192 | Information dump |
9195 | Delayed echo test |
9196 | Echo test |
9197 | Milliwatt tone (test signal quality) |
9198 | Tetris |
9664 | Music on hold |
這些功能的實作預設都在default.xml中。
Xml dialplan大量使用相容perl的正規表達式,大多用在${destination_number}的比較上,
常用的如
^789 --------------------------比對與789開頭的
789$ ---------------------------比對以789結尾的
\d-------------------------------比對 0-9任意數字
^\d$----------------------------以任意數字開頭的
^\d{3}$ ---------------------比對以三個數字開頭的
^(\d{5})$--------------------比對以五個數字開頭的,并把變量儲存到$1中
^(9\d{10}|123)$ 比對以123開頭或者以9,加上10個數字開頭
等等。
另外,freeswitch提供控制台指令regex,可以測試指定字元串是否與某個模式比對,