summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/include/pjsua-lib/pjsua.h9
-rw-r--r--pjsip/src/pjsua-lib/pjsua_media.c14
2 files changed, 23 insertions, 0 deletions
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h
index 5114189d..e3d9dd31 100644
--- a/pjsip/include/pjsua-lib/pjsua.h
+++ b/pjsip/include/pjsua-lib/pjsua.h
@@ -2153,6 +2153,15 @@ typedef struct pjsua_transport_config
unsigned port;
/**
+ * Specify the port range for socket binding, relative to the start
+ * port number specified in \a port. Note that this setting is only
+ * applicable when the start port number is non zero.
+ *
+ * Default value is zero.
+ */
+ unsigned port_range;
+
+ /**
* Optional address to advertise as the address of this transport.
* Application can specify any address or hostname for this field,
* for example it can point to one of the interface address in the
diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c
index f891201a..26a6cb70 100644
--- a/pjsip/src/pjsua-lib/pjsua_media.c
+++ b/pjsip/src/pjsua-lib/pjsua_media.c
@@ -718,6 +718,13 @@ static pj_status_t create_ice_media_transport(
if (acc_cfg->ice_cfg.ice_max_host_cands >= 0)
ice_cfg.stun.max_host_cands = acc_cfg->ice_cfg.ice_max_host_cands;
+ /* Copy binding port setting to STUN setting */
+ pj_sockaddr_init(ice_cfg.af, &ice_cfg.stun.cfg.bound_addr,
+ &cfg->bound_addr, cfg->port);
+ ice_cfg.stun.cfg.port_range = cfg->port_range;
+ if (cfg->port != 0 && ice_cfg.stun.cfg.port_range == 0)
+ ice_cfg.stun.cfg.port_range = pjsua_var.ua_cfg.max_calls * 10;
+
/* Copy QoS setting to STUN setting */
ice_cfg.stun.cfg.qos_type = cfg->qos_type;
pj_memcpy(&ice_cfg.stun.cfg.qos_params, &cfg->qos_params,
@@ -743,6 +750,13 @@ static pj_status_t create_ice_media_transport(
ice_cfg.turn.cfg.qos_type = cfg->qos_type;
pj_memcpy(&ice_cfg.turn.cfg.qos_params, &cfg->qos_params,
sizeof(cfg->qos_params));
+
+ /* Copy binding port setting to TURN setting */
+ pj_sockaddr_init(ice_cfg.af, &ice_cfg.turn.cfg.bound_addr,
+ &cfg->bound_addr, cfg->port);
+ ice_cfg.turn.cfg.port_range = cfg->port_range;
+ if (cfg->port != 0 && ice_cfg.turn.cfg.port_range == 0)
+ ice_cfg.turn.cfg.port_range = pjsua_var.ua_cfg.max_calls * 10;
}
/* Configure packet size for STUN and TURN sockets */