FreeSWITCH訊號音檢測(忙音檢測,呼叫進度檢測)
keywords: FreeSWITCH 忙音檢測 呼叫進度檢測 訊號音檢測 detect busy ringing
description: FreeSWITCH忙音訊號檢測使用方法
categories: FreeSWITCH
mod_dptools tone_detect
<action application="tone_detect" data="<key> <freqs> <flags> <timeout> <app> <data> <hits>">
Field | Decription | examples |
---|---|---|
key | Name of the tone (user defined) | busy, fax, mytone |
freqs | Frequencies to “listen” for | 425 - 480,620 |
flags | Which direction to sniff the tones in (r = read (default), w = write) | r |
timeout | Window of time to listen for the tones in (0 = forever, + = milliseconds relative to the time tone_detect is called (now), = time in “epoch” (ie. seconds since January 1, 1970)) | +2000 (2 seconds) or 1227132612 (absolute example) |
app | Optional. Application to call when the tone detect conditions are met | transfer, hangup |
appdata | Optional. Argument to the application specified above | ‘1000 XML default’ , ‘normal_clearing’ |
hits | Number of hits needed before calling app/appdata (useful to avoid false positives) |
timeout這裡特別解析一下,0:一直檢測,+毫秒數:需要檢測的時間, epoch:絕對時間,比如要檢測60秒,就是now()+60
freqs 中國電話訊號音標準
- 撥號音 450±25 -10±3dBm0 <10% 連續訊號音
- 回鈴音 450±25 -10±3dBm0 <10% 1S(H)/4S(L)
- 忙音 450±25 -10±3dBm0 <10% 0.35S(H)/0.35S(L)
- 擁塞音 450±25 -10±3dBm0 <10% 0.7S(H)/0.7S(L)
如果上面表格中解析看不明白,沒事,下面有例子。
<!-- execute_on_tone_detect 檢測到訊號音執行的操作 -->
<action application="set" data="execute_on_tone_detect=set my_tone=true"/>
<!-- tone_detect_hits 訊號出現多少次才認為檢測成功,比如忙音檢測一般設定為3 -->
<action application="set" data="tone_detect_hits=2"/>
<action application="set" data="execute_on_media=tone_detect mytone 820 w +30000"/>
<action application="bridge" data="sofia/gateway/foo/123456789"/>
下面是一個檢測到3聲忙音就結束通話的例子。
<action application="tone_detect" data="busy 450 r 0 hangup 'normal_clearing' 3"/>
停止訊號音檢測
<application="stop_tone_detect"/>
mod_spandsp Call Progress
mod_dptools: tone_detect功能比較弱,現在我們介紹第二種吧
<configuration name="spandsp.conf" description="Tone detector descriptors">
<descriptors debug-level="0">
<!-- These tones are defined in Annex to ITU Operational Bulletin No. 781 - 1.II.2003 -->
<!-- Various Tones Used in National Networks (According to ITU-T Recommendation E.180)(03/1998) -->
<!-- North America -->
<!-- china -->
<descriptor name="cn">
<tone name="BUSY_TONE">
<element freq1="450" freq2="0" min="300" max="400"/>
<element freq1="0" freq2="0" min="300" max="400"/>
<element freq1="450" freq2="0" min="300" max="400"/>
<element freq1="0" freq2="0" min="300" max="400"/>
<element freq1="450" freq2="0" min="300" max="400"/>
<element freq1="0" freq2="0" min="300" max="400"/>
</tone>
</descriptor>
</descriptors>
</configuration>
通過配置檔案可以配置不同訊號因頻率、持續時間和週期。上面的配置是配置中國忙音,持續3聲認為檢測成功。
Channels Variables
- execute_on_spandsp_tone_detect_XXX 檢測到訊號執行APP
- api_on_spandsp_tone_detect_XXX 檢測到訊號執行API
Dialplan Applications
spandsp_start_tone_detect
Start background tone detection with cadence.
<!-- start detection for North American call progress tones -->
<action application="spandsp_start_tone_detect" data="1"/>
spandsp_stop_tone_detect
Stop background tone detection with cadence
<action application="spandsp_stop_tone_detect"/>
APIs
spandsp_start_tone_detect
Start background tone detection with cadence
spandsp_start_tone_detect <uuid> <descriptor name>
spandsp_stop_tone_detect
Stop background tone detection with cadence
spandsp_stop_tone_detect <uuid>
Events
DETECTED_TONE
This event is fired when the tone detector detects a tone.
The following headers are set:
Detected-Tone
Unique-ID
The Detected-Tone header will contain the name of the tone, as specified in the configuration file.
The Unique-ID will contain the session UUID.