`

Originate Using Asterisk Local Channels

 
阅读更多

Whenever you want to place a call between two extensions in the dialplan you have to use Local channels.


The OriginateAction that you use when placing calls through the Manager API requires a channel name for the first leg. Usually your application has no knowledge of the dialplan details, i.e. it does not know which channel is triggered by an extension (maybe it’s a SIP hardphone, an IAX device or a link to another Asterisk server). What you want to do is “place a call between number a and number b” and leave the rest to Asterisk.

Local channels act as a proxy to the real channels mapped to an extension. So to place a call from 1310 to 1299 your Originate looks like:

1
2
3
4
Channel: Local/1310@from-local
Context: from-local
Exten: 1310
Priority: 1

instead of

1
2
3
4
Channel: SIP/1310
Context: from-local
Exten: 1399
Priority: 1

There is an article about Local Channels at voip-info.org that covers the basics.

So that’s all very nice and looks straight forward. It becomes more interesting if you have a look at what happens under the hood:

A Local channel actually consists of two channels in Asterisk: Local/XXX,1 and Local/XXX,2. The Local/XXX,2 channel traverses the dialplan starting at the context and extension you provided. In our example this is the extension 1310 in from-local. If you watch the CLI or the events triggered you will see:

1
2
3
Set(_ALERT_INFO=<Bellcore-dr1>)
Macro(localexten|1310|SIP/1310)
Dial(SIP/1310|30|t)

This corresponds to the defintion of 1310 in my dialplan:

1
2
3
4
5
6
7
8
9
10
11
[from-local]
exten => 1310,1,Set(_ALERT_INFO=<Bellcore-dr1>)
exten => 1310,n,Macro(localexten,${EXTEN},SIP/${EXTEN})
 
[macro-localexten]
exten => s,1,Dial(${ARG2},30,t)
exten => s,n,Goto(s-${DIALSTATUS},1)
exten => s-NOANSWER,1,Voicemail(u${ARG1})
exten => s-NOANSWER,n,Hangup
exten => s-BUSY,1,Busy
exten => _s-.,1,Goto(s-NOANSWER,1)

The Dial command triggers an additional channel (SIP/1310). This is the actual channel that is proxied by the Local channel.

The other side of the Local channel, Local/XXX,1, is used for the desination. In our example this is the extension 1299 in from-local. You see similar events for this channel. The actual channel that is triggered for 1299 is an IAX channel to another Asterisk server: IAX2/iax_reucon_net-3.

Now we reach the point where we have four channels set up: The two sides of the Local channel and the two “real” channels SIP/1310 and IAX2/iax_reucon_net. Two channels are now longer needed and will vanish. Before this happens all data of the proxied channel is copied (masqueraded) to Local/XXX,1 so that Local/XXX,1 is renamed to SIP/1310. The “old” SIP/1310 channel is renamed to SIP/1310-0820f718<MASQ> and finally to Local/1310@from-local-1e71,1<ZOMBIE> before it is hung up. Local/XXX,2 is hung up without any renaming.


So in the end you have exactly what you would have expected: Two channels, SIP/1310 and IAX2/iax_reucon_net up and connected.

I have prepared a nice diagram that shows all these steps in detail and helps you understand what happens:

分享到:
评论

相关推荐

    Asterisk AMI 接口代码

    - `ManagerCommand`:用于向Asterisk发送命令,例如`Originate`命令发起一个呼叫,或者`CoreShowChannels`命令获取所有通道的信息。 - `ActionID`:每个发送的命令都有一个唯一的`ActionID`,通过它可以跟踪命令的...

    Asterisk CLI 命令列表

    Asterisk是一款开源的IP电话系统,主要用于VoIP通信,其功能强大且可高度定制。在Asterisk的管理中,CLI(Command Line Interface)是一个非常重要的工具,它允许管理员直接与Asterisk服务器交互,执行各种管理和...

    Asterisk-CLI-命令列表.zip_asterisk_cli

    - `originate`: 从CLI发起一个新通话。 - `hangup &lt;channel&gt;`: 结束指定通道的通话。 - `transfer &lt;channel&gt; &lt;destination&gt;`: 将通话转移到另一个目的地。 5. **日志和调试** - `loglevel &lt;module&gt; &lt;level&gt;`: ...

    Asterisk.NET.1.6.3.1.zip

    3. **命令执行**:库支持发送Asterisk命令,如Originate发起呼叫,Dial挂起或恢复通话,以及执行AMI(Asterisk Manager Interface)命令,以实现对Asterisk的远程管理。 4. **实时通信**:利用Asterisk.NET,开发者...

    Asterisk CLI命令1

    9. `channel originate` 和 `channel redirect`:创建新的呼叫或重定向已存在的呼叫,是Asterisk核心的呼叫控制功能。 10. `channel request hangup`:挂断指定的通道,终止通话。 11. `cli check permissions` 和...

    前端开源库-originate

    "前端开源库-originate" 是一个专门为前端开发者设计的开源工具,它的主要功能是利用“织布机”(Yeoman)技术来帮助快速生成项目脚手架。在前端开发中,项目脚手架通常是一组预先配置好的文件和目录结构,能够帮助...

    20120618_扩展Asterisk1.8.7的AMI接口1

    在实际应用中,`action_myOriginate`函数可能会调用Asterisk的API来创建一个新的呼叫,如`ast_channel_originate()`,并将从消息中获取的参数传递给它。不过,这个例子并没有展示如何实际发起呼叫,只是展示了如何...

    Go-gami-AsteriskAMI接口的Go库

    4. **命令执行**:`SendAction`方法允许开发者构造并发送自定义的AMI命令,如`CoreShowChannels`来获取当前的通话详情,或者`Originate`来发起一个新的呼叫。 5. **响应处理**:库中包含了处理AMI响应的机制,帮助...

    python 控制Asterisk AMI接口外呼电话的例子

    'Originate', Channel=f'SIP/{ponebind}', Exten=callid, Priority=1, Context='MAIN_OUTGOING', CallerID=exten, ) ``` 发送外呼请求并等待响应: ```python client.send_action(action) future = client....

    AsteriskCookBook

    ,3,GotoIf($["${ TIME("YYYY-MM-DD HH:MM:SS", "local") }" ]?1,2) ,4,Playback(workhours) ,5,Hangup() ,6,Playback(afterhours) ,7,Hangup() ``` 以上代码示例展示了如何根据当前时间来决定播放不同的消息。...

    default-information originate command

    ### default-information originate 命令详解 #### 概述 `default-information originate` 命令主要用于在网络设备上配置默认路由的发布。该命令支持多种路由协议,包括BGP、IS-IS、OSPF 和 RIP。通过这个命令,...

    dami:适用于Deno的Asterisk Manager Interface(AMI)客户端

    例如,采取“ Originate操作。 从Asterisks的文档中,他们概述了它需要以下数据: Action: OriginateChannel: SIP/101testContext: defaultExten: 8135551212Priority: 1Callerid: 3125551212Timeout: 30000...

    API应用资料

    - Originate:拨出电话并连接到指定的上下文、扩展和优先级。 - Ping:检测到Asterisk服务器的连接是否还有效。 在实际应用中,开发者可以通过阅读API文档来获取更全面的操作方法和参数细节,编写符合自己需求的...

    originate-frontend-lib:织机起源,用于创建前端javascript库

    用法$ npm install -g loom# now the originate program is available$ originate frontend-lib my-lib __my-lib-global-name$ cd my-lib$ git init$ npm install# ready to go! 如果安装了,则可以像这样简化流程:...

    drift-prototype:Originate NY Office 项目 Drift 的原型

    "Drift Prototype: Originate NY Office 项目"是基于Java技术构建的一个原型系统,主要用于展示和测试Drift产品在 Originate NY Office环境中的应用。这个项目可能是为了优化办公室的沟通和客户交互流程,利用Drift...

    Freeswitch外呼群呼接口

    调用此接口时,需要携带一系列参数,如`originate`、`hangup_after_bridge`等,这些参数用于控制外呼行为和通话流程。 `originate`参数是一个复杂的JSON对象,包含了如下的关键字段: 1. `hangup_after_bridge`: ...

    Freeswitchivr外呼接口

    - `originate_timeout=30`: 设置呼叫超时时间为30秒,如果30秒内未连接上,呼叫将被终止。 - `origination_caller_id_number=******`: 设置主叫号码,这里需要是合法的联通号码才能发起外呼。 - `sofia/gateway/...

    linux下设置ftp及增加SSL服务.docx

    ## Make sure PORT transfer connections originate from port 20 (ftp-data). connect_from_port_20=YES ## If you want, you can arrange for uploaded anonymous files to be owned # by a different user. Note...

Global site tag (gtag.js) - Google Analytics