`

Asterisk local channels

 
阅读更多

 

Asterisk local channels

Local channel


chan_local is a pseudo-channel. Use of this channel simply loops calls back into the dialplan in a different context. Useful for recursive routing; it is able to return to the dialplan after call completion.

Syntax:

Local/extension@context[/n]
Local/extension@context[/nj] (starting with Asterisk 1.6, backport available for 1.4)

Adding "/n" at the end of the string will make the Local channel not do a native transfer (the "n" stands for "n"o release) upon the remote end answering the line. This is an esoteric, but important feature if you expect the Local channel to handle calls exactly like a normal channel. If you do not have the "no release" feature set, then as soon as the destination (inside of the Local channel) answers the line, the variables and dial plan will revert back to that of the original call, and the Local channel will become a zombie and be removed from the active channels list. This is desirable in some circumstances, but can result in unexpected dialplan behavior if you are doing fancy things with variables in your call handling.

Adding "/nj" will apply the the generic jitterbuffer to the Local channel driver; this feature was introduced in Asterisk 1.6, with a backport being available for 1.4 (see link above on how to obtain it from svn). With this jitter buffer and a Local channel now also calls that aren't bridged but 'talk' to an Asterisk application can take advantage of de-jittering - provided the generic jitter buffer (not the older adaptive jitter buffer?) has been enabled in SIP (or MGCP or ...).

Purpose:

The Local channel construct can be used to establish dialling into any part of the dialplan.

Imagine you have a TE410P in your box. You want to do something for which you must use a Dial statement (for instance when dropping files in /var/spool/outgoing) but you do want to be able to use your dialplans least-cost-routes or other intelligent stuff. What you could do before we had chan_local was create a cross-link between two ports of the TE410P and then Dial out one port and in the other. This way you could control where the call was going.

Of course, this was a nasty hack, and to make it more sensible, chan_local was built.

The "Local" channel driver allows you to convert an arbitrary extension into a channel. It is used in a variety of places, including agents, etc.

Here are some examples (primarily using conferencing) where it might be useful:

  • Suppose you wanted to build a web GUI for building conferences... You could make your script ask for what number to call and use Local/number@context as the channel in your .call file, and set the conference as the extension to go to.
  • Imagine you had a conference going on and you wanted to be able to add someone in sales. You could use Local/salesexten@context as the channel to add to the conference, which would then ring everyone in sales.
  • Imagine you wanted to link two conferences together.
  • Imagine you wanted to add MusicOnHold to a conference.
  • You'd like to use .call files for automated dialling and still want to make sure that a CDR record = log entry gets created


This also allows us to hop to contexts like a GoSub routine; See examples below.

Examples:


[inbound]
; here falls all incoming calls
exten => s,1,Answer
exten => s,2,Dial(local/200@internals,30,r)
exten => s,3,Playback(sorrynoanswer)
exten => s,4,Hangup

[internals]
; here where our phones falls for default
exten => 200,1,Dial(sip/blah)
exten => 200,102,VoiceMail(${EXTEN}@default)

exten => 201,1,Dial(zap/1)
exten => 201,102,VoiceMail(${EXTEN}@default)

exten => _0.,1,Dial(Zap/g1/${EXTEN:1}) ; outgoing calls with 0+number


so that let me to call a local (internal) extension, without:

  • duplicate the dial & voicemail statements
  • don't letting them to dial out, since in internal context I have the possibility to dialout.


Using the local channel to play music on hold when already answered while waiting for a script that takes a while:


[waitforscript]

exten => s,1,Dial(local/s@somescript,60,m)

[somescript]

exten => s,1,Ringing
exten => s,n,System(' .. something which takes a lot of work ..')
exten => s,n,Answer()


One could create a special music on hold class saying 'please wait while we process your request'. Just remember that the caller may fall into the music on hold loop at any point.

In Manager API or in a call-file, a CDR will not be generated without using the local channel. At its simplest, use these examples to Dial:


For Manager API or in a call-file use the following to specify an outbound call. (the trailing '/n' is important):

Channel: local/PHONENUMBERTOCALL@outbound/n

And in extensions.conf:

[outbound]
exten => _1.,1,Dial(SIP/${EXTEN}@some-outbound-carrier-context)
exten => _1.,2,Congestion




Caveats:

If you use chan_local from a call-file and you want to pass channel variables into your context, make sure you append the '/n', because otherwise chan_local will 'optimize' itself out of the call-path, and the variables will get lost. i.e.

Local/00531234567@pbx becomes Local/00531234567@pbx/n

Local channels don't support state information (see hint) in Asterisk 1.4. For that you either need to use 1.6 or backport of state_interface for 1.4. Then you have to set call-limit for peers, and specify state_interface device when logging in agents. For more information please search for "asterisk queue state" on the asterisk-users mailinglist.

Be aware that your CDR data will become clutter with extra data; you might want to consider using NoCDR() and ResetCDR() to prevent this from happening.

See also

分享到:
评论

相关推荐

    Asterisk 之数据库配置方案 asterisk数据库

    7. Asterisk 的配置文件包括 zapata.conf、zapata-channels.conf、sip.conf 和 extensions.conf 等。 8. 在 Kamailio.cfg 文件中需要配置 switch 语句来管理 Asterisk 的配置。 9. 在 Asterisk 中,需要安装 ...

    通过asterisk-java操作asterisk

    5. **使用通道(Channels)和拨号计划(Dialplan)**:Asterisk-java提供了对通道和拨号计划的操作,你可以查询现有的通道状态,修改拨号计划,甚至在运行时动态改变Asterisk的行为。 6. **实时监控**:通过...

    Asterisk 简介 Asterisk 架构 Asterisk程序框图

    Asterisk是一款开源的电话交换机软件,它允许用户创建高度自定义的通信系统,包括VoIP(Voice over IP)电话、会议桥、自动呼叫分配(ACD)以及许多其他电信功能。Asterisk的核心设计理念是灵活性和可扩展性,这使得...

    Asterisk AMI 接口代码

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

    asterisk拨号方案的配置

    在 Asterisk 中,你可以定义多个 context,每个context都可以嵌套另一个,例如default、local和longdistance等。每个context都可以定义一组具体的呼入和呼出电话处理规则,使得Asterisk拨号方案的配置非常灵活和强大...

    Asterisk权威指南中文

    Asterisk权威指南中文(第3版) Asterisk权威指南(第3版)第15章自动话务员 Asterisk权威指南(第3版)第02章Asterisk体系结构 Asterisk权威指南(第3版)第05章用户设备配置 Asterisk权威指南(第3版)第06章Dialplan基础 ...

    Asterisk.NET 1.6.3 控制Asterisk

    Asterisk.NET 1.6.3 是一个专门为.NET开发者设计的开源库,它提供了对Asterisk PBX系统的编程接口,使得用户可以方便地在C#、VB.NET或其他.NET支持的语言中控制和扩展Asterisk功能。这个库是基于Asterisk Manager ...

    Asterisk一些常用的命令

    * zap show channels 查看ZapTel语音卡各个通道 * stop now 立刻停止Asterisk * stop gracefully 温文尔雅滴停止Asterisk * restart now 立刻重启Asterisk * restart gracefully 温文尔雅滴重启Asterisk * database ...

    Asterisk 中文文档说明

    Asterisk是一款强大的开源通信平台,它被广泛用于构建VoIP(Voice over Internet Protocol)电话系统,SIP(Session Initiation Protocol)服务器以及各种通信应用。这个“Asterisk中文文档说明”涵盖了从基础概念到...

    asterisk16版本安装包

    Asterisk是一款开源的IP电话系统,用于构建VoIP(Voice over Internet Protocol)通信平台。在本场景中,我们讨论的是Asterisk的16版本安装包,这将引导我们深入理解Asterisk的核心功能、安装流程以及如何进行编译和...

    Asterisk中文语言包

    修改sip_general_custom.conf(作为测试,在所有SIP 通道上启用提示语为中文,在实际应用中,可根据需要修改--zapata-channels.conf,sipXXX.conf,IAXXXX.conf...,也可在FreePBX的WEB界面中有language选项的地方修改--...

    Asterisk 中文语音包

    Asterisk是一款开源的IP电话系统,它允许用户创建自己的通信平台,支持VoIP(Voice over IP)服务,包括电话会议、语音邮件和IVR(Interactive Voice Response)等。中文语音包是为Asterisk系统设计的一个关键组件,...

    最全Asterisk代码学习笔记

    2. **架构概述**:Asterisk的核心架构包括通道(Channels)、拨号计划(DialPlan)、应用程序(Apps)和管理接口(Manager API)。通道处理实际的通信连接,DialPlan定义了如何处理呼叫,应用程序执行特定的通话操作...

    asterisk info 录音实现方案

    标签“asterisk record”指的是与Asterisk录音相关的配置和功能,它表明文章将围绕如何在Asterisk中设置和实现录音功能。 在提供的部分内容中,提到了几个关键的配置文件和步骤,这些是实现Asterisk录音功能的核心...

    asterisk 视频通讯实现方法

    Asterisk是一款开源的PBX(Private Branch Exchange)软件,专用于实现VoIP(Voice over IP)通信。在本文中,我们将深入探讨如何利用Asterisk实现视频通讯功能。实现Asterisk视频通讯的关键在于配置sip.conf文件...

    asterisk 教程

    Zapata配置文件中,`[trunkgroups]`和`[channels]`部分定义了线路组和通道的属性,如语言、上下文、信号类型等。 通过这些步骤,你可以成功安装和配置Asterisk,从而建立起一个基本的VoIP服务器。不过,Asterisk的...

    asterisk 学习日志

    Asterisk是一个开源的IP电话系统,用于搭建VoIP服务器,提供电话呼叫、语音邮件、会议等通信功能。以下是对Asterisk学习日志中提到的一些关键知识点的详细解释: 1. **Asterisk调试与日志记录**: 在学习Asterisk...

    asterisk AGI应用说明

    ### Asterisk AGI应用详解 #### 一、概述 Asterisk是世界上最流行的开源PBX系统之一,它支持多种通信协议并提供了丰富的功能。在Asterisk中,AGI(Asterisk Gateway Interface)是一种非常重要的接口技术,它允许...

    Asterisk 客户端.rar

    Asterisk是一款开源的IP电话系统,用于构建VoIP网络通信基础设施。它的功能强大,能够支持PBX(Private Branch Exchange)、VoIP网关、呼叫中心和许多其他电信应用。在这个"Asterisk客户端.rar"压缩包中,我们主要...

    Asterisk 代码学习笔记,深入浅出asterisk,asterisk通道,呼叫情景(call scenario)

    本文将深入剖析Asterisk的核心概念,包括通道(Channel)、呼叫情景(Call Scenario)、桥接通道(Bridging Channels)以及植入通道(Masquerading Channels),并通过具体代码实例来解释这些概念的应用。...

Global site tag (gtag.js) - Google Analytics