FreeSWITCH is intentionally minimal at its core. Every capability beyond basic session management — SIP signaling, codec negotiation, dialplan routing, scripting, logging, CDR writing — is delivered by a loadable module: a shared library (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/signalwire/freeswitch/llms.txt
Use this file to discover all available pages before exploring further.
.so on Linux, .dll on Windows) that is compiled independently and loaded at runtime. This plugin architecture lets you include only the functionality your deployment needs, update individual modules without restarting the switch, and extend the platform with custom code without touching the core.
How Modules Work
Every FreeSWITCH module must expose a module function table using theSWITCH_MODULE_DEFINITION macro, defined in src/include/switch_types.h. This macro declares a switch_loadable_module_function_table_t that the module loader reads via dlopen / GetProcAddress:
| Function | Macro | Purpose |
|---|---|---|
load | SWITCH_MODULE_LOAD_FUNCTION(name) | Called once when the module is loaded. Register interfaces, allocate resources. |
shutdown | SWITCH_MODULE_SHUTDOWN_FUNCTION(name) | Called when the module is unloaded. Deregister interfaces, free resources. |
runtime | SWITCH_MODULE_RUNTIME_FUNCTION(name) | Optional background thread that runs for the lifetime of the module. |
mod_dptools — one of the most feature-rich application modules:
NULL for the runtime function) means mod_dptools does not need a persistent background thread.
Inside the load function, a module registers its capabilities by populating a switch_loadable_module_interface_t structure (defined in src/include/switch_loadable_module.h) with pointers to the interface tables it provides:
mod_av registers both a codec interface (video codecs) and a file-format interface (FFmpeg container support).
Module Types
The source tree organises modules into categories undersrc/mod/. Each category corresponds to a distinct interface type registered by the module at load time.
| Category | Directory | Description |
|---|---|---|
applications | src/mod/applications | Dialplan applications executed on a channel: answer, bridge, playback, record, conference, voicemail, etc. |
asr_tts | src/mod/asr_tts | Automatic speech recognition and text-to-speech engines: mod_unimrcp, mod_flite, mod_tts_commandline. |
codecs | src/mod/codecs | Audio and video codec plugins: mod_opus, mod_g729, mod_amr, mod_amrwb, mod_g723_1, mod_openh264, mod_silk. |
databases | src/mod/databases | Database backend plugins used by limit and hash interfaces. |
dialplans | src/mod/dialplans | Routing engines: mod_dialplan_xml (default), mod_dialplan_asterisk (extensions.conf syntax). |
directories | src/mod/directories | User directory providers: mod_ldap. |
endpoints | src/mod/endpoints | Signaling protocol drivers: mod_sofia (SIP), mod_verto (WebRTC), mod_skinny (SCCP), mod_loopback, mod_rtmp. |
event_handlers | src/mod/event_handlers | Event bus consumers: mod_event_socket (ESL), mod_json_cdr, mod_cdr_csv, mod_amqp, mod_snmp, mod_erlang_event. |
formats | src/mod/formats | Audio/video file I/O: mod_sndfile, mod_shout (MP3/Shoutcast), mod_av (FFmpeg). |
languages | src/mod/languages | Embedded scripting runtimes: mod_lua, mod_python, mod_javascript, mod_perl, mod_v8. |
loggers | src/mod/loggers | Log sinks: mod_logfile (rolling file), mod_syslog, mod_console. |
say | src/mod/say | Language-specific phrase rendering: mod_say_en, mod_say_es, mod_say_de, mod_say_ru, etc. |
sdk | src/mod/sdk | Development skeleton modules used as starting templates. |
timers | src/mod/timers | High-resolution timer backends: mod_timerfd (Linux), mod_posix_timer. |
xml_int | src/mod/xml_int | Dynamic XML registry providers: mod_xml_curl, mod_xml_rpc, mod_xml_cdr, mod_xml_ldap. |
Loading and Unloading
Autoloading at startup
Modules to load at startup are listed inconf/autoload_configs/modules.conf.xml:
Runtime management
Modules can be loaded, reloaded, and unloaded from the FreeSWITCH console or via the API at runtime:Module Configuration
Each module reads its own XML configuration from a file inconf/autoload_configs/, named after the module (e.g., sofia.conf.xml, event_socket.conf.xml). Configuration is fetched from the XML registry under the configuration section.
reloadxml to refresh the XML registry and then reload <module_name> to apply the changes.
Writing a Module
A custom module is a standard C shared library that:- Includes
<switch.h>(which pulls in the entire FreeSWITCH public API). - Declares its entry points with
SWITCH_MODULE_DEFINITION. - Implements a
SWITCH_MODULE_LOAD_FUNCTIONthat registers the module’s interfaces and returnsSWITCH_STATUS_SUCCESS.
SWITCH_DECLARE(return_type) — this macro resolves to the correct export attribute for each platform. Refer to src/include/switch_core.h, src/include/switch_channel.h, and src/include/switch_ivr.h for the full API surface.