从上个月开始从事freeswitch相关的开发工作。读文档和上网搜索,踩过太多坑,记录一下心得。以备以后复习
添加模块的方式尝试了很多种,试过的比较好的,比较方便的,如下
a、Makefile.am文件需要包含build目录下的modmake.rules
1、先写Makefile文件
Makefile 文件的内容是:
#BASE 是freeswitch的源码路径
BASE=/usr/src/freeswitch
include $(BASE)/build/modmake.rules
就是这两句话,当然也可以写成一句。
2、写模块代码 简历模块文件夹和模块的代码文件名一致 例如mod_example/mod_example.c
这里说明一下,如果是.c文件的话,那么代码将会以c的方式编译代码,如果.cpp文件的话,那么将使用c++的方式编译代码。
mod_sample.c的代码如下
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005/2012, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License.