freeswitch嵌入python脚本
2024-10-13 23:52:34
操作系统:debian8.5_x64
freeswitch 版本 : 1.6.8
python版本:2.7.9
开启python模块
安装python lib库
apt-get install python-dev
编辑modules.conf,开启python模块:
languages/mod_python
编译安装:
./configure && make && make install
在modules.conf.xml中开启python支持;
启动freeswitch;
测试脚本
API测试
添加测试脚本:
文件路径:/usr/local/freeswitch/scripts/test1.py
文件内容:
import freeswitch def fsapi(session,stream,env,args):
stream.write("hello")
freeswitch.consoleLog("info","test")
控制台测试
freeswitch@debian8> python test1
hello
-- ::09.069753 [NOTICE] mod_python.c: Invoking py module: test1
-- ::09.069753 [DEBUG] mod_python.c: Call python script
-- ::09.069753 [INFO] switch_cpp.cpp: test
-- ::09.069753 [DEBUG] mod_python.c: Finished calling python script
freeswitch@debian8>
APP测试
文件路径: /usr/local/freeswitch/scripts/testCall.py
文件内容:
import freeswitch
def handler(session, args):
session.answer()
freeswitch.console_log("info","testCall")
session.streamFile("local_stream://moh")
freeswitch.msleep(3000)
session.hangup()
在dialplan中加入如下配置:
<extension name="python test script">
<condition field="destination_number" expression="^400123456$">
<action application="python" data="testCall"/>
</condition>
</extension>
注册话机,拨打400123456号码即可听到moh声音,同时看到freeswitch控制台日志。
本文github地址:
https://github.com/mike-zhang/mikeBlogEssays/blob/master/2016/20160906_freeswitch嵌入python脚本.md
欢迎补充
最新文章
- 4-printf &; scanf函数
- mongodb(mongoose-redis-cache)
- 斗地主(Noip2015Day1T3)
- 《ASP.NET1200例》<;asp:DataList>;分页显示图片
- JQuery直接调用asp.net后台WebMethod方法
- 纯CSS实现的右侧底部简洁悬浮效果
- python抓取网页图片
- 动态加载EXE和DLL
- 我学的是设计模式的视频教程——命令模式vs策略模式,唠嗑
- js的特殊运算符
- 如何利用fis3来模拟后台返回数据
- Android帧布局(Frame Layout)
- Hive篇---Hive与Hbase整合
- Linux-centos7超过2TB使用parted命令分区
- jquery知识巩固
- 架构师成长之路2.2-PXE+Kickstart安装部署
- Java中的队列都有哪些,有什么区别?
- 《Linux命令行与shell脚本编程大全》 第五章理解shell
- 在Word 2007中添加参考文献及其引用的方法
- XCODE 添加不同IOS版本的模拟器