]> git.ipfire.org Git - thirdparty/asterisk.git/commit
res_pjsip: Add per-endpoint RTP port range configuration master
authormattia <me@mattiacampagna.com>
Wed, 1 Apr 2026 12:46:57 +0000 (14:46 +0200)
committergithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Tue, 28 Apr 2026 17:46:01 +0000 (17:46 +0000)
commitfcb98380e49f9e40adf7d750895fbdc20a0007cc
tree3d1ebc8e022300083a7115b277fdf35e8bac54c6
parentcef63b761f437eb4c8e3d7e26b74485f3d91c7eb
res_pjsip: Add per-endpoint RTP port range configuration

Add rtp_port_start and rtp_port_end options to PJSIP endpoint
configuration, allowing each endpoint to use a dedicated RTP port
range instead of the global rtp.conf setting.

This is useful for scenarios where different endpoints need isolated
port ranges, such as firewall rules per trunk, multi-tenant systems,
or network QoS policies tied to port ranges.

The implementation adds ast_rtp_instance_new_with_port_range() to the
RTP engine API, which sets the port range on the instance before the
engine allocates the transport. The default RTP engine
(res_rtp_asterisk) checks for per-instance overrides in
rtp_allocate_transport() and falls back to the global range when
none is set.

Both options must be set together, with values >= 1024 and
rtp_port_end > rtp_port_start. Setting both to 0 (the default)
preserves existing behavior.

Resolves: https://github.com/asterisk/asterisk-feature-requests/issues/71

UserNote: PJSIP endpoints now support rtp_port_start and
rtp_port_end options to configure a dedicated RTP port range per
endpoint, overriding the global rtp.conf setting.

UpgradeNote: An alembic database migration has been added to add
the rtp_port_start and rtp_port_end columns to the ps_endpoints
table. Run "alembic upgrade head" to apply the schema change.

DeveloperNote: New public API: ast_rtp_instance_new_with_port_range()
creates an RTP instance with a per-instance port range.
ast_rtp_instance_get_port_start() and ast_rtp_instance_get_port_end()
allow RTP engines to query the override. Third-party RTP engines can
use these getters to support per-instance port ranges.
configs/samples/pjsip.conf.sample
contrib/ast-db-manage/config/versions/e89e30cee53f_add_rtp_port_range_to_ps_endpoints.py [new file with mode: 0644]
include/asterisk/res_pjsip.h
include/asterisk/rtp_engine.h
main/rtp_engine.c
res/res_pjsip/pjsip_config.xml
res/res_pjsip/pjsip_configuration.c
res/res_pjsip/pjsip_manager.xml
res/res_pjsip_sdp_rtp.c
res/res_rtp_asterisk.c