freeswitch 新模块开发

发布时间 2023-09-22 19:07:17作者: PerKins.Zhu

1、在Debian系统上 成功编译并通过源码安装 freeswitch

2、在src/mod/application/ 目录下新建 mod_helloworld 目录。

2、在 src/mod/application/mod_helloworld/ 目录下创建 mod_helloworld.c 文件

3、在文件中写入如下内容:

#include <switch.h>

SWITCH_MODULE_LOAD_FUNCTION(mod_helloworld_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_helloworld_shutdown);


SWITCH_MODULE_DEFINITION(mod_helloworld, mod_helloworld_load, mod_helloworld_shutdown, NULL);

SWITCH_MODULE_LOAD_FUNCTION(mod_helloworld_load)
{
	// init module interface
	*module_interface = switch_loadable_module_create_module_interface(pool, modname);


	return SWITCH_STATUS_SUCCESS;
}

SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_helloworld_shutdown) { return SWITCH_STATUS_SUCCESS; }

  

4、在 freeswitch/module.conf 加入:  applications/mod_helloworld

5、在freeswitch/ 目录下 执行  编译安装命令

make  mod_helloworld && make install mod_helloworld

6、去 freeswitch控制台  load mod_helloworld 加载模块