如何快速编译和安装
编译新模块:make mod_book
安装新模块:make mod_book-install
或者: make mod_book && make mod_book-install
添加模块
增加Makefile
BASE=/root/code/freeswitch
include $(BASE)/build/modmake.rules
模块代码
增加一个dialplan模块
#include "switch.h"
SWITCH_MODULE_LOAD_FUNCTION(mod_book_load);
SWITCH_MODULE_DEFINITION(mod_book,mod_book_load, NULL, NULL);
SWITCH_STANDARD_DIALPLAN(book_dialplan_hunt)
{
switch_caller_extension_t *extension = NULL;
switch_channel_t *channel = switch_core_session_get_channel(session);
if(!caller_profile){
caller_profile = switch_channel_get_caller_profile(channel);
}
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(channel), SWITCH_LOG_INFO, "Processing %s <%s> -> %s in context %s\n",
caller_profile->caller_id_name, caller_profile->caller_id_number, caller_profile->destination_number, caller_profile->context);
extension = switch_caller_extension_new(session,"book","book");
if(!extension) abort();
switch_caller_extension_add_application(session, extension, "log", "INFO Hey, I am in the book");
switch_caller_extension_add_application(session, extension, "set", "name=wchi");
switch_caller_extension_add_application(session, extension, "info", NULL);
switch_caller_extension_add_application(session, extension, "park", NULL);
return extension;
}
SWITCH_MODULE_LOAD_FUNCTION(mod_book_load)
{
switch_dialplan_interface_t *myinterface;
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
SWITCH_ADD_DIALPLAN(myinterface, "book", book_dialplan_hunt);
return SWITCH_STATUS_SUCCESS;
}