如何快速编译和安装

编译新模块:make mod_book
安装新模块:make mod_book-install
或者: make mod_book && make mod_book-install

添加模块

增加Makefile

  1. BASE=/root/code/freeswitch
  2. include $(BASE)/build/modmake.rules

模块代码

增加一个dialplan模块

  1. #include "switch.h"
  2. SWITCH_MODULE_LOAD_FUNCTION(mod_book_load);
  3. SWITCH_MODULE_DEFINITION(mod_book,mod_book_load, NULL, NULL);
  4. SWITCH_STANDARD_DIALPLAN(book_dialplan_hunt)
  5. {
  6. switch_caller_extension_t *extension = NULL;
  7. switch_channel_t *channel = switch_core_session_get_channel(session);
  8. if(!caller_profile){
  9. caller_profile = switch_channel_get_caller_profile(channel);
  10. }
  11. switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(channel), SWITCH_LOG_INFO, "Processing %s <%s> -> %s in context %s\n",
  12. caller_profile->caller_id_name, caller_profile->caller_id_number, caller_profile->destination_number, caller_profile->context);
  13. extension = switch_caller_extension_new(session,"book","book");
  14. if(!extension) abort();
  15. switch_caller_extension_add_application(session, extension, "log", "INFO Hey, I am in the book");
  16. switch_caller_extension_add_application(session, extension, "set", "name=wchi");
  17. switch_caller_extension_add_application(session, extension, "info", NULL);
  18. switch_caller_extension_add_application(session, extension, "park", NULL);
  19. return extension;
  20. }
  21. SWITCH_MODULE_LOAD_FUNCTION(mod_book_load)
  22. {
  23. switch_dialplan_interface_t *myinterface;
  24. *module_interface = switch_loadable_module_create_module_interface(pool, modname);
  25. SWITCH_ADD_DIALPLAN(myinterface, "book", book_dialplan_hunt);
  26. return SWITCH_STATUS_SUCCESS;
  27. }