Skip to content

Architecture

Germán Luis Aracil Boned edited this page Jun 24, 2026 · 2 revisions

Architecture

GABPBX follows the classic Asterisk modular architecture: a small core loads channel drivers, dialplan applications, dialplan functions, media translators, file formats, resources, CDR/CEL backends and PBX engines.

The system is designed around runtime-loadable modules. Most behavior is added by .so modules built from the source directories under the project root.

Main Subsystems

Core engine:

  • main/gabpbx.c starts the process and runtime.
  • main/loader.c loads and unloads modules.
  • main/channel.c owns channel allocation, state and core channel behavior.
  • main/pbx.c executes dialplan logic.
  • main/bridging.c provides bridge behavior for connected channels.
  • main/rtp_engine.c abstracts RTP engines and payload mappings.
  • main/manager.c implements AMI.
  • main/cli.c implements the console CLI.
  • main/config.c parses configuration files.
  • main/logger.c handles logs and verbose output.
  • main/sched.c provides scheduling.
  • main/taskprocessor.c provides queued task execution.
  • main/devicestate.c and main/event.c provide device and event state.

Module families:

  • channels/ - channel drivers and signaling/media endpoints.
  • apps/ - dialplan applications.
  • funcs/ - dialplan functions.
  • res/ - shared resources and service modules.
  • codecs/ - audio translators.
  • formats/ - file format handlers.
  • cdr/ - Call Detail Record backends.
  • cel/ - Channel Event Logging backends.
  • pbx/ - PBX/dialplan engines.
  • bridges/ - bridge technologies.
  • addons/ - optional or legacy add-on modules.

Configuration:

  • configs/*.conf.sample contains sample runtime configuration.
  • menuselect controls which modules are selected for build.
  • modules.conf controls which modules load at runtime.

Call Flow

A normal SIP call through chan_sofia follows this high-level path:

  1. Sofia-SIP receives SIP signaling.
  2. chan_sofia maps SIP state into a GABPBX channel.
  3. The core PBX sends the channel into a dialplan context.
  4. Dialplan applications execute, commonly Dial().
  5. The target channel is allocated by its channel driver.
  6. The bridge layer joins the channels.
  7. RTP media is negotiated through the RTP engine.
  8. CDR/CEL modules record the call lifecycle.

This is the same broad architecture as Asterisk, with GABPBX-specific work focused heavily on chan_sofia, realtime operation, media support and production behavior.

Module Loading

Modules are normally built as .so files and installed into the GABPBX module directory. Runtime loading is controlled by:

/etc/gabpbx/modules.conf

Use:

*CLI> module show
*CLI> module show like sofia
*CLI> module load chan_sofia.so
*CLI> module unload <module>.so

Some modules are not safe or useful to unload after active use. SIP channel driver switching should be done with a full GABPBX restart.

Realtime Architecture

Realtime allows configuration data to be stored outside flat files, commonly in PostgreSQL, ODBC, SQLite or other backends.

Important pieces:

  • res/res_realtime.c - realtime data lookup/rewrite.
  • res/res_config_pgsql.c - PostgreSQL realtime configuration driver.
  • res/res_config_odbc.c - ODBC realtime configuration driver.
  • res/res_config_sqlite3.c - SQLite realtime configuration driver.
  • funcs/func_realtime.c - dialplan read/write/store/destroy access.
  • configs/extconfig.conf.sample - maps realtime families to backends.

For chan_sofia, the important families are:

sippeers
sipregs

sippeers stores peer configuration. sipregs can optionally store registration state separately.

Media Architecture

Media is split into several layers:

  • Channel driver SDP/signaling logic.
  • RTP engine and RTP instance handling.
  • Codec translators.
  • File format modules.
  • DSP helpers for DTMF, fax/tone detection and audio processing.
  • SRTP and UDPTL resources where required.

Important files:

main/rtp_engine.c
res/res_rtp_gabpbx.c
res/res_srtp.c
main/dsp.c
main/udptl.c
codecs/codec_opus.c
channels/chan_sofia.c

Operational Rule

When documenting or modifying behavior, read the source first. Many modules preserve compatibility with Asterisk behavior, while selected GABPBX modules extend or deliberately improve that behavior.

Clone this wiki locally