- 浏览: 411707 次
文章分类
- 全部博客 (327)
- Android (114)
- Java (13)
- Java基础 (14)
- Glib (2)
- linux (15)
- extjs (5)
- eclipse (2)
- Asterisk (56)
- MYSQL (6)
- 数据库 (9)
- PHP (7)
- C# (18)
- 杂谈~~ (1)
- web开发前端 (3)
- 网络编程 (2)
- Opensips (2)
- voip (3)
- debian (7)
- openfire (15)
- wordpress (1)
- 版本控制 (1)
- Android 线程服务广播 (1)
- SRTP (2)
- 单片机及ARM等 (3)
- 基础知识 (5)
- asp.net (2)
- 单片机 (1)
- 设计模式及架构 (1)
- 安全 (1)
- Cubieboard 草莓树莓各类派 Android开发板 (1)
- J2EE (2)
- BootStrap (3)
- BootStrap web前端开发 (1)
- web前端开发 (4)
- object-c (1)
- openwrt (8)
- 智能家居 (4)
- Node.js (4)
最新评论
-
xiaoxiecomeon:
你这个程序一存在线程的时间片相互抢占的问题,运行时间长了很可能 ...
Runnable 和 Thread -
dotjar:
我觉得话应该这么说:引用TestThread tt = new ...
Runnable 和 Thread -
dagf113225:
调用TelephonyManager的隐藏API是先参考Fra ...
Android提高第十四篇之探秘TelephonyManager
Asterisk的拨号函数/命令是Dial,下面就介绍一下这个函数的用法。
Dial()
摘要
在一个通道上发起一个新的外拨呼叫,然后把它连接到当前通道上。
语法
Dial(type/identifier, timeout, options, URL)
或
Dial(type1/identifier1[&type2/identifier2[&type3/identifier3... ] ], timeout, options, URL)
或
RetryDial(announce|sleep|loops|Technology/resource[&Technology2/resource2...][|[timeout][|[options][|URL]]])
说明:
同时外呼所有指定的通道,第一个应答的通道将占用,其他通道挂机,然后触发Dial命令的通道被应答(Answered),按照需要把两条通道连接起来。触发Dial命令的通道挂机后,将退出Dial命令。
在成功连接两个通道后,如果Dial函数的参数里有g 和 G,那么不会继续执行余下的流程。如果连接失败,那么可以跳转到下一个流程,或j参数指定的节点。
参数说明
可选参数部分,即上述语法里的options,可以是空,或者是下面这些参数或标志:
A(x): Play an announcement (x.gsm) to the called party.
C: Reset the CDR (Call Detail Record) for this call. This is like using the NoCDR command
c: Sets the channel driver flag that the "call is answered elsewhere" if Dial() cancels the call
D(digits): After the called party answers, send digits as a DTMF stream, then connect the call to the originating channel (you can also use 'w' to produce .5 second pauses). You can also provide digits after a colon - all digits before the colon are sent to the called channel, all digits after the colon are sent to the calling channel (all digits are sent to the called channel if there is no colon present).
d: This flag trumps the 'H' flag and intercepts any single DTMF tone while waiting for the call to be answered and jumps to that extension if it exists. This allows you to dial a 1-digit exit extension while waiting for the call to be answered - see also RetryDial. This uses the current context unless ${EXITCONTEXT} is defined.
e: Execute "h" as the peer when this call ends
F(context^exten^pri): When the caller hangs up, transfer the called party to the specified context and extension and continue execution.
f: forces callerid to be set based on a dialplan "hint" for the current channel. For example, some PSTNs don't allow callerids from other extensions than the ones that are assigned to you.
G(context^exten^pri): If the call is answered, transfer both parties to the specified context and extension. The calling party is transferred to priority x, and the called party to priority x+1. This allows the dialplan to distinguish between the calling and called legs of the call (new in v1.2). You cannot use any options that would affect the post-answer state if this option is used.
g: When the called party hangs up, continue to execute commands in the current context at the next priority.
H: Allow the caller to hang up by dialing *
h: Allow the callee to hang up by dialing *
i: Asterisk will ignore any forwarding requests it may receive on this dial attempt. (new in 1.4) Useful if you are ringing a group of people and one person has set their phone to forwarded direct to voicemail on their cell or something which normally prevents any of the other phones from ringing.
j: Asterisk 1.2 and later (1.6???): Jump to priority n+101 if all of the requested channels were busy (just like behaviour in Asterisk 1.0.x)
K: Allow the calling party to enable parking of the call by sending the DTMF sequence defined for call parking in features.conf (Asterisk v1.4.x)
k: Allow the called party to enable parking of the call by sending the DTMF sequence defined for call parking in features.conf (Asterisk v1.4.x)
L(x[:y][:z]): Limit the call to 'x' ms, warning when 'y' ms are left, repeated every 'z' ms) Only 'x' is required, 'y' and 'z' are optional. Numbers must be integers- beware of AGI scripts that may return long integers in scientific notation (esp PHP 5.2.5&6) The following special variables are optional for limit calls: (pasted from app_dial.c)
LIMIT_PLAYAUDIO_CALLER - yes|no (default yes) - Play sounds to the caller.
LIMIT_PLAYAUDIO_CALLEE - yes|no - Play sounds to the callee.
LIMIT_TIMEOUT_FILE - File to play when time is up.
LIMIT_CONNECT_FILE - File to play when call begins.
LIMIT_WARNING_FILE - File to play as warning if 'y' is defined. If LIMIT_WARNING_FILE is not defined, then the default behaviour is to announce ("You have [XX minutes] YY seconds").
M(x): Executes the macro (x) upon connect of the call (i.e. when the called party answers). See also U. IMPORTANT - The CDR 'billsecs' field is set to zero if the callee answers the call, but hangs up whilst the macro is still running (if the callee answers and the macro finishes, 'billsecs' contains the correct value). The macro can set ${MACRO_RESULT} to the following:
ABORT: Hang up both legs
CONGESTION: Signal congestion to the caller
BUSY: Signal busy to the caller
CONTINUE: Hangup the called party but continue execution at the next priority in the dialplan for the caller
GOTO: Transfer the execution to context^exten^pri
m: Provide Music on Hold to the calling party until the called channel answers. This is mutually exclusive with option 'r', obviously. Use m(class) to specify a class for the music on hold.
N: Modifies the privacy manager - turns off call screening if caller ID information is present
n(delete): (Asterisk 1.6) If delete is 0 or not specified, delete the privacy manager introduction if the caller hangs up before the call is answered. If set to 1, delete the recording even if the call is answered.
O(mode): If mode is set to 1 or isn't specified, ringback immediately if the originator hangs up. If mode is set to 2, ring back when the operator flashes the trunk. This is only valid when the caller and called channels areDAHDI channels. It is intended for calling an operator station.
o: Restore the Asterisk v1.0 CallerId behaviour (send the original caller's ID) in Asterisk v1.2 (default: send this extension's number)
P(x): Use the PrivacyManager, using x as the database (x is optional and will default to the current extension)
p: This option enables screening mode. This is basically Privacy mode without memory of how to handle the caller. It looks for the file sounds/priv-callerintros/${IF($[ "${CALLERID(num)}" != "" ]?${CALLERID(num)}:NOCALLERID_${EXTEN}${CUT(CHANNEL,/,1)}=${CUT(CHANNEL,/,2)})}.gsm and if it is not found, prompts the caller to say his name. It then rings the called party and plays sounds/priv-callpending, sounds/priv-callerintros/<see-above>, and sounds/screen-callee-options. If the called party enters 1, the call is accepted, 2, the DIAL command exits with ${DIALSTATUS} set to NOANSWER, 3, set to TORTURE and 4, set to DONTCALL. If no valid entry is made, the DIAL command exits with ${DIALSTATUS} set to ANSWER. The check for pre-existence of the name recording may not be what you want. For example, everyone from the same number is not necessarily the same person, especially if the number is OUTOFAREA, but if the file is there, no new name will be recorded. Since the files are never removed, you may wish to remove them with a System(rm /var/lib/asterisk/sounds/priv-callerintros/${IF($[ "${CALLERID(num)}" != "" ]?${CALLERID(num)}:NOCALLERID_${EXTEN}${CUT(CHANNEL,/,1)}=${CUT(CHANNEL,/,2)})}.*) right before the Dial command and clean up old ones with a cron job.
R: Indicate ringing to the calling party when the called party indicates ringing, pass no audio until answered. This is available only if you are using kapejod's Bristuff.
r: Generate a ringing tone for the calling party, passing no audio from the called channel(s) until one answers. Without this option, Asterisk will generate ring tones automatically where it is appropriate to do so; however, "r" will force Asterisk to generate ring tones, even if it is not appropriate. For example, if you used this option to force ringing but the line was busy the user would hear "RING RIBEEP BEEP BEEP" (thank you tzanger), which is potentially confusing and/or unprofessional. However, the option is necessary in a couple of places. For example, when you're dialing multiple channels, call progress information is not consistantly passed back. Look at Progress(), the progressinband setting in sip.conf or Ringing() if you would like to avoid the use of 'r' but have issues with the ringback behaviour of Dial().
S(n): Hangup the call n seconds AFTER called party picks up.
T: Allow the calling user to transfer the call by hitting the blind xfer keys (features.conf). Does not affect transfers initiated through other methods.
If you have set the variable GOTO_ON_BLINDXFR then the transferrer will be sent to the context|exten|pri (you can use ^ to represent | to avoid escapes), example: SetVar(GOTO_ON_BLINDXFR=woohoo^s^1); works with both t and T
t: Allow the called user to transfer the call by hitting the blind xfer keys (features.conf) Does not affect transfers initiated through other methods.
If you have set the variable GOTO_ON_BLINDXFR then the transferrer will be sent to the context|exten|pri (you can use ^ to represent | to avoid escapes), example: SetVar(GOTO_ON_BLINDXFR=woohoo^s^1); works with both t and T
U(x): Executes, via gosub, routine x on the called channel. This is similar to M above, but a gosub rather than a macro. The subroutine can set ${GOSUB_RESULT}__ to the following:
ABORT: Hang up both legs
CONGESTION: Signal congestion to the caller
BUSY: Signal busy to the caller
CONTINUE: Hangup the called party but continue execution at the next priority in the dialplan for the caller
GOTO: Transfer the execution to context^exten^pri
W: Allow the calling user to start recording after pressing *1 or what defined in features.conf (Asterisk v1.2.x); requires Set(DYNAMIC_FEATURES=automon)
w: Allow the called user to start recording after pressing *1 or what defined in features.conf (Asterisk v1.2.x); requires Set(DYNAMIC_FEATURES=automon)
X: Allow the calling user to start recording using automixer after pressing *1 or what defined in features.conf (Asterisk v1.6)
x: Allow the called user to start recording using automixer after pressing *1 or what defined in features.conf (Asterisk v1.6)
例子
Example 1: 简单的例子
复制代码
|
Dial macros
Dial(Zap/1|60|M(mymacro^cat^dog^bark))
Example 2: Dial macro
复制代码
|
Notes:
Do not put spaces between the arguments to the Dial command, it will not work.
When options t, T", "h", "H", "w", "W" or "L" (with multiple arguments) are applied, Asterisk will remain in the media path, even if canreinvite=yes'' (a SIP channel option) has been specified.
Return codes
Dial sets DIALSTATUS to indicate its success or failure. However, under some circumstances, execution will jump to priority n+101 in the current context. This happens when:
All channels dialed were busy
There is exists something at n+101 in the current context
You are running asterisk 1.0.x, priorityjumping=yes is set in extensions.conf, or the j option is specificed in the dial command
Note that in Asterisk v1.2+ priorityjumping is considered "off" by default, which is a change from previous versions.
If the g option is specified, and the called party hangs up before the calling party, then Dial continues execution at priority n+1.
Do Progress() before calling Dial() if you want asterisk to go in-band (in order to use playtones configured in indications.conf etc.). In some cases you may have to use Answer(), but that is to be avoided because it "charges", prevents auto-redial, etc.
Note: The bristuff patches change the dial behaviour slightly and jump to n+201 if the dialed destination isn't connected (e.g. a SIP softphone is not up and running, or hasn't registered).
DIALSTATUS - For more details see Asterisk Variable DIALSTATUS
${DIALSTATUS} will be one of:
CHANUNAVAIL : Channel unavailable (for example in sip.conf, when using qualify=, the SIP chan is unavailable)
BUSY : Returned busy
NOANSWER : No Answer (i.e SIP 480 or 604 response)
ANSWER : Call was answered
CANCEL : Call attempt cancelled (i.e user hung up before the call connected)
DONTCALL : Privacy manager don't call
TORTURE : Privacy manager torture menu
CONGESTION : Means Congestion, or anything else (some other error setting up the call)
Example 3: Dial multiple channels, partially delayed
复制代码
|
In the above example 200 and 201 extension will ring immediately, and 300 and 301 will start ringing after 15 seconds. After to 900 the first two digits are for the delay before start ringing and the last three are the extension that should be called. The trick here is that instead of simply using two Dial statements after each other we make sure we ring each phone only once; that prevents a) potential problems with SIP devices needing some wrap up time before being able to take another call, and b) avoids too many "missed call" entires in the phone's interface.
Look at ForkCDR and/or ResetCDR if you are not happy with the resulting CDRs of this example.
Example 4: Answering machine (by dsfr aka Chris Hozian)
Can be used for home answering machine with call screen. Provides CallerID to handset even if you don't pay for CallerID. Must associate CID name with number in Asterisk database in order to work.
复制代码
|
See also voicemail live: Listen to incoming caller during voicemail recording
Example 5: Using Bristuff
If you are using kapejod's Bristuff, you will have a n + 201 priority as well. Dial goes to this priority if no one is logged in on the called extension. I.e. giving an unavailable message instead of a busy message when no phone is connected to the extension.
复制代码
|
Example 6: Using IAX2 friends
I keep forgeting how to set this up, so I wanted to contribute a good example to explain the syntax a little clearer and make this information easier to find. I'm going to give example excerpts from iaxhost1's and iaxhost2's iax.conf and extensions.conf files. I'm going to use names that are fairly generic but very unique to this example. I also have instructions on how to do this with Asterisk@Home (at least with 2.5) (now known as TrixBox), so please pay attention.
Excerpt from iaxhost1's iax.conf:
复制代码
|
Excerpt from iaxhost1's extensions.conf
复制代码
|
Excerpt from iaxhost2's extensions.conf
复制代码
|
Dial() together with openining Jack ports for callee
复制代码
|
Note: only for asterisk 1.6.x
Return values in channel variables
For PRI connections over a ZAP channel, as well as IAX2 channels, the hangup result code will be found the HANGUPCAUSE variable.
Note that causecode 0 is effectively a notice that the causecode has not been set. Causecode 16 is not an error, but simply a notice that the call went through and was terminated normally.
For all channels types, except LOCAL, the DIALSTATUS variable contains the result of the call, which may be used for dial plan logic
The variables DIALEDTIME and ANSWEREDTIME contains timing for billing (as in CDR records)
Version comments
Option A and S: added to CVS after release 0.7.2
Option D: in CVS since May 2004
Option f: added to CVS in June/July 2004
Variables DIALSTATUS, ANSWEREDTIME and DIALEDTIME: added to CVS head in june 2004
Support for specific hardware
Set variable ALERT_INFO to change ring cadence on Cisco 79xx phones. See also MySQL custom ringtones
Phones running the SCCP (skinny) firmware have some support for pushing XML pages. If you want to test it, set the variable VXML_URL to point to a Cisco XML file on a web server.
For distinctive ringing on Cisco Ata, see Asterisk phone cisco ATA18x
Dial with A(x&y&z) multiple playback files
Diff file its a copy/paste from app_playback.c in Asterisk-1.6.1.2
复制代码
- --- app_dial.c 2009-03-19 17:33:19.000000000 -0300
- +++ /app_dial.c 2009-09-23 16:40:00.000000000 -0300
- @@ -1706,4 +1706,18 @@ static int dial_exec_full(struct ast_cha
- /* Now Stream the File */
- - if (!res)
- - res = ast_streamfile(peer, opt_args[OPT_ARG_ANNOUNCE], peer->language);
- + if (!res){
- + char *front;
- + char *args= opt_args[OPT_ARG_ANNOUNCE];
- + ast_log(LOG_INFO, "Dial Annoucement String: %s\n",opt_args[OPT_ARG_ANNOUNCE]);
- + while(front = strsep(&args, "&")){
- + res = ast_streamfile(peer, front, peer->language);
- + if (!res) {
- + res = ast_waitstream(peer, "");
- + ast_stopstream(peer);
- + } else {
- + ast_log(LOG_INFO, "ast_streamfile failed on %s\n", chan->name);
- + res = 0;
- + }
- + ast_log(LOG_WARNING, "Stream File %s\n",front);
- + }
- + }
- if (!res) {
发表评论
-
Configuring an Asterisk server
2013-06-28 09:05 892Configuring an Asterisk server ... -
asterisk ami
2013-06-28 08:56 1401Asterisk Manager Interface主要提供 ... -
Originate Using Asterisk Local Channels
2013-01-24 17:30 1320Whenever you want to place a c ... -
Asterisk 1.8 chan_sip模块代码分析
2013-01-18 16:33 1909和以前版本相比,Asterisk在架构上有了不小的变动,本文 ... -
Asterisk Kernel analysis 2 channel
2013-01-17 17:44 837从内核的角度去分析问题时,弄清楚呼叫流程是非常关键的,只有 ... -
Asterisk Kernel analysis 1
2013-01-17 17:44 845一、内核初始化。 从 main入口。Asterisk ... -
astersik bridge 支持
2013-01-17 17:27 683为支持通话过程中双方按键的接受及处理,asterisk 通过 ... -
Asterisk 之${BRIDGEPEER} 函数说明
2013-01-17 16:38 694${BRIDGEPEER} :个人理解是 获取当前通道类型 ... -
asterisk中常用函数说明
2012-12-15 11:56 954int ast_strlen_zero(co ... -
什么是1号信令、7号信令和PRI信令?
2012-04-11 14:26 1506按照信令的信道来分类,信令可以分为:随路信令和公共信道信 ... -
FreeSWITCH 与 Asterisk 比较
2012-03-29 15:45 3548VoIP通信,与传统的电话技术相比,不仅仅在于绝对的资费 ... -
Asterisk命令MeetMe详解
2012-03-29 14:44 994MeetMe 概要 MeetMe ... -
Asterisk local channels
2012-03-12 15:09 853Asterisk local channels ... -
35个最棒的Asterisk免费应用
2012-03-12 14:51 2211Hi, I was looking round o ... -
Asterisk Originate 内部执行流程
2012-03-11 20:34 9971. originate的执行 向客户端发起呼叫,将客 ... -
模拟板卡疑难杂症(转)
2012-03-11 20:34 2244转自:http://sun4love.javaeye.c ... -
Asterisk 通话过程中执行动作(即applicationmap )的使用方法和电话转会议的实现
2012-03-11 20:34 975asterisk在正常通话过程中执行拨号计划中动作是通过 ... -
asterisk feature applicationmap 的caller和callee 的区别
2012-03-11 20:34 1009经过测试,在applicationmap 中定 ... -
asterisk中关于实现会议室meetme的笔记
2012-03-09 11:07 1904一、资料: 1.http: ... -
Asterisk 之${BRIDGEPEER} 函数说明
2012-03-09 11:06 797${BRIDGEPEER} :个人理解是 获取当前通道类型通道 ...
相关推荐
6. Dial():Dial()函数是Asterisk中最复杂的拨号函数之一,它负责建立呼叫连接。Dial()有四个主要参数: - 被叫方:可以是SIP、ZAP或其他类型的通道,如`SIP/50000`或`Zap/1`,甚至可以同时拨打多个通道。 - 超时...
asterisk拨号方案的配置 Asterisk拨号方案的配置是Voice over Internet Protocol(VoIP)技术中的一个关键组件,它控制着呼入和呼出电话的处理和路由。配置文件“extensions.conf”是Asterisk拨号方案的核心,它...
"asterisk拨号方案中应用使用详解" Asterisk拨号方案中应用使用详解是指在Asterisk系统中使用拨号方案来实现各种应用的技术手段。本文将对Asterisk拨号方案中的各种应用进行详细地解释和示例。 1. Authenticate:...
Asterisk是一个开源的PBX软件,它提供了丰富的应用程序接口(API)和函数,用于构建和定制通信系统。本文将详细介绍一些Asterisk的app函数,帮助你理解和应用这些功能。 1. Authenticate: 此函数用于鉴别用户,通常...
天体图Astograph是一个简单的python工具,可以直观地表示您的Asterisk拨号计划它使用 GraphViz 绘制包含上下文之间的链接例子考虑以下extensions.conf文件: 和以下命令: cat extensions.conf | ./astograph.py | ...
asterisk dial apps (asterisk Dial拨号 APP模块)
### Asterisk Dialplan详解:构建复杂拨号方案的必备技能 #### 一、引言 在深入了解Asterisk的拨号计划(Dialplan)之前,我们先回顾一下Asterisk的基本概念。Asterisk是一款开源的PBX(Private Branch Exchange,...
- **asterisk函数.txt**:解释了Asterisk中的函数,这些函数在编写拨号计划和其他脚本时非常有用。 通过这些文档,学习者可以系统地了解并掌握Asterisk的核心知识,从基本的命令到复杂的配置,逐步成为一名Asterisk...
在Asterisk系统中,可以通过DTMF信号或者拨号计划(dial plan)来控制录音的开始和结束。此外,还需通过Asterisk的http资源发送这些录音信息到指定的服务器地址。通常情况下,服务器地址、节点编号以及录音文件存储...
### Asterisk详解 #### Asterisk概述 Asterisk是一款开源的通信平台,它支持多种通信协议,包括但不限于SIP(Session Initiation Protocol)、H.323等,并且能够提供语音邮件、会议呼叫、交互式语音应答(IVR)等...
### Asterisk AGI应用详解 #### 一、概述 Asterisk是世界上最流行的开源PBX系统之一,它支持多种通信协议并提供了丰富的功能。在Asterisk中,AGI(Asterisk Gateway Interface)是一种非常重要的接口技术,它允许...
- 呼叫处理:Asterisk根据拨号计划路由呼叫,可能包括IVR交互、呼叫转移、会议等。 - 信令处理:Asterisk管理所有参与者的连接状态,处理挂断、振铃、忙线等信令。 - 媒体流处理:Asterisk负责音频的编码和解码,...
5. **使用通道(Channels)和拨号计划(Dialplan)**:Asterisk-java提供了对通道和拨号计划的操作,你可以查询现有的通道状态,修改拨号计划,甚至在运行时动态改变Asterisk的行为。 6. **实时监控**:通过...
【 Asterisk 1.8 相关资料详解】 Asterisk 1.8 是 Asterisk 开源通信平台的一个重要版本,对于理解呼叫中心的工作原理及其内在机制,它提供了丰富的学习资源。初学者通过深入研究 Asterisk 1.8,不仅可以掌握基础的...
本文旨在深入解析Asterisk的高级配置技术,帮助读者掌握如何利用变量表达式、子字符串、变量操作符以及拨号计划函数等来优化和扩展Asterisk的功能。 #### 变量表达式 在Asterisk中,变量表达式用于减少配置复杂性...
Application定义了Asterisk实际执行的动作,例如Dial(SIP/2000,20)表示呼叫2000号码,振铃20秒,如果2000号码在20秒内没有摘机,Dial()执行完成,其priority会加1,那么符合条目就跳到下一条,例如exten=>2000,2,...
在该文档中对asterisk的各个功能模块的实现经行了详细的说明,对于学习asterisk的朋友是一份很好的工具。
在编写Asterisk的拨号计划(Dialplan)时,理解语法和结构至关重要,因为这直接影响到通信流程的效率和功能。"AsteriskSyntaxHighlighting"是一个针对Brackets编辑器的扩展,专门设计来帮助开发者更好地阅读和理解...
Asterisk 之数据库配置方案 Asterisk 是一个开源的 PBX(Private Branch Exchange)系统,可以实现电话交换和语音网关的功能。在传统的 Asterisk 配置中,配置文件都是存储在文件系统中的,但是随着系统的复杂度和...
### Asterisk 代码学习笔记详解 #### 一、Asterisk 概览及核心概念 Asterisk是一款开源的电话通信平台,它支持多种语音通信协议,并提供了丰富的API供开发者进行二次开发。本文将深入剖析Asterisk的核心概念,包括...