keywords: FreeSWITCH 忙音检测 呼叫进度检测 信号音检测 detect busy ringing
description: FreeSWITCH忙音信号检测使用方法
categories: FreeSWITCH
FreeSWTICH有2种信号音检测方法一种mod_dptools: tone_detect,还有一个是mod_spandsp Call Progress,我们先介绍第一种。
mod_dptools tone_detect
1、<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)
1、timeout这里特别解析一下,0:一直检测,+毫秒数:需要检测的时间, epoch:绝对时间,比如要检测60秒,就是now()+60
2、freqs 中国电话信号音标准
2.1、拨号音 450±25 -10±3dBm0 <10% 连续信号音
2.2、 回铃音 450±25 -10±3dBm0 <10% 1S(H)/4S(L)
2.3、忙音 450±25 -10±3dBm0 <10% 0.35S(H)/0.35S(L)
2.4、拥塞音 450±25 -10±3dBm0 <10% 0.7S(H)/0.7S(L)
如果上面表格中解析看不明白,没事,下面有例子。
1、<!-- execute_on_tone_detect 检测到信号音执行的操作 -->
2、<action application="set" data="execute_on_tone_detect=set my_tone=true"/>
3、<!-- tone_detect_hits 信号出现多少次才认为检测成功,比如忙音检测一般设置为3 -->
4、<action application="set" data="tone_detect_hits=2"/>
5、<action application="set" data="execute_on_media=tone_detect mytone 820 w +30000"/>
6、<action application="bridge" data="sofia/gateway/foo/123456789"/>
下面是一个检测到3声忙音就挂断的例子。
<action application="tone_detect" data="busy 450 r 0 hangup 'normal_clearing' 3"/>
1
停止信号音检测
<application="stop_tone_detect"/>
1
mod_spandsp Call Progress
mod_dptools: tone_detect功能比较弱,现在我们介绍第二种吧
1、<configuration name="spandsp.conf" description="Tone detector descriptors">
2、 <descriptors debug-level="0">
3、<!-- These tones are defined in Annex to ITU Operational Bulletin No. 781 - 1.II.2003 -->
4、<!-- Various Tones Used in National Networks (According to ITU-T Recommendation E.180)(03/1998) -->
5、 <!-- North America -->
6、 <!-- china -->
7、 <descriptor name="cn">
8、 <tone name="BUSY_TONE">
9、 <element freq1="450" freq2="0" min="300" max="400"/>
10、 <element freq1="0" freq2="0" min="300" max="400"/>
11、 <element freq1="450" freq2="0" min="300" max="400"/>
12、 <element freq1="0" freq2="0" min="300" max="400"/>
13、 <element freq1="450" freq2="0" min="300" max="400"/>
14、 <element freq1="0" freq2="0" min="300" max="400"/>
15、 </tone>
16、 </descriptor>
17、</descriptors>
18、</configuration>
通过配置文件可以配置不同信号因频率、持续时间和周期。上面的配置是配置中国忙音,持续3声认为检测成功。
Channels Variables
1、execute_on_spandsp_tone_detect_XXX 检测到信号执行APP
2、api_on_spandsp_tone_detect_XXX 检测到信号执行API
Dialplan Applications
spandsp_start_tone_detect
1、Start background tone detection with cadence.
<!-- start detection for North American call progress tones -->
<action application="spandsp_start_tone_detect" data="1"/>
1、spandsp_stop_tone_detect
Stop background tone detection with cadence
1、<action application="spandsp_stop_tone_detect"/>
APIs
spandsp_start_tone_detect
Start background tone detection with cadence
1、spandsp_start_tone_detect <uuid> <descriptor name>
spandsp_stop_tone_detect
Stop background tone detection with cadence
1、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.
————————————————
版权声明:本文为优快云博主「顶顶通电话机器人」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.youkuaiyun.com/iyaosan/article/details/79109387