操作系统: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

欢迎补充

最新文章

  1. 4-printf &amp; scanf函数
  2. mongodb(mongoose-redis-cache)
  3. 斗地主(Noip2015Day1T3)
  4. 《ASP.NET1200例》&lt;asp:DataList&gt;分页显示图片
  5. JQuery直接调用asp.net后台WebMethod方法
  6. 纯CSS实现的右侧底部简洁悬浮效果
  7. python抓取网页图片
  8. 动态加载EXE和DLL
  9. 我学的是设计模式的视频教程——命令模式vs策略模式,唠嗑
  10. js的特殊运算符
  11. 如何利用fis3来模拟后台返回数据
  12. Android帧布局(Frame Layout)
  13. Hive篇---Hive与Hbase整合
  14. Linux-centos7超过2TB使用parted命令分区
  15. jquery知识巩固
  16. 架构师成长之路2.2-PXE+Kickstart安装部署
  17. Java中的队列都有哪些,有什么区别?
  18. 《Linux命令行与shell脚本编程大全》 第五章理解shell
  19. 在Word 2007中添加参考文献及其引用的方法
  20. XCODE 添加不同IOS版本的模拟器

热门文章

  1. JavaScript动画知多少?
  2. ABP源码分析四十六:ABP ZERO中的Ldap模块
  3. android-解决全屏-webview-输入框被输入法挡住-FullScreen-adjustResize失效问题
  4. jQuery LigerUI系列:ligerComboBox
  5. TortoiseSVN的使用
  6. The Road To Hadoop(网盘系统的实现)
  7. MyCat源码分析系列之——结果合并
  8. UWP简单示例(二):快速开始你的3D编程
  9. 把UI图里的小图标制作成icon font
  10. Oracle 中的sql函数以及分页