FreeSwitch Lua编程接口(1)dialplan里的配置

本文详细介绍了FreeSwitch中使用Lua编程接口进行Dialplan配置的过程。当拨打特定号码时,FreeSwitch会通过XML拨号计划查询lua脚本,创建session和channel,执行lua应用程序。在接收到sip信号后,lua_function负责初始化lua状态,创建Session对象,并执行lua脚本文件。
摘要由CSDN通过智能技术生成

Dialplan里的配置

可以为freeswitch配置一个或若干个号码,当其他的sip终端通过拨打此号码时,通过拨号路由,查找到此号码,从而执行lua脚本。在Dialplan里的配置如下:

       <extension name="1200">

        <condition field="destination_number" expression="^1200$">

          <action application="lua" data="test.lua"/>

        </condition>

</extension>

 

需要说明的是:

dialplan是通过xml寻找拨号规则的,具体流程为:

①sip信令到达,invite消息,抵达sip endpoint的回调机制,例如sofia终端,会到达sip_handle_sip_i_invite函数做相应处理。

②在sofia_handle_sip_i_invite函数中,建立一个新的session,并未session创建一个channel。在channel中,包含一个caller_profile,这是一个类型为switch_caller_profile_t的结构体,记录了当前呼叫的各种必要属性。Caller_profile里记录了当前的route方式为“XML”,这里明确指明了通过xml文件查询拨号规则。(见该函数里的switch_channel_set_caller_profile(channel, tech_pvt->caller_profile)&

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Freeswitch is an open-source telephony platform that allows you to build various communication applications. It supports multiple scripting languages, including Lua. Lua is a lightweight and powerful scripting language that is often used for extending the functionality of Freeswitch. With Lua, you can write custom applications, create dial plans, handle call control logic, and interact with various telephony features provided by Freeswitch. Lua scripts in Freeswitch are typically used for tasks such as call routing, IVR (Interactive Voice Response) systems, call recording, and more. To use Lua with Freeswitch, you need to have the mod_lua module enabled in your Freeswitch installation. Once enabled, you can start writing Lua scripts to control call flows and handle telephony events. Here is a simple Lua script example for Freeswitch that answers an incoming call and plays a welcome message: ```lua -- answer.lua session:answer() session:streamFile("/path/to/welcome-message.wav") ``` In this example, the `session:answer()` function answers the incoming call, and the `session:streamFile()` function plays an audio file to the caller. You can save this script as `answer.lua` and load it in your Freeswitch dial plan configuration to execute it when an incoming call arrives. Note that this is just a basic example, and Lua with Freeswitch offers much more functionality and flexibility. Feel free to explore the official Freeswitch documentation and Lua scripting resources for more advanced use cases and examples.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值