summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiong Sauw Ming <ming@teluu.com>2016-12-06 11:23:39 +0000
committerLiong Sauw Ming <ming@teluu.com>2016-12-06 11:23:39 +0000
commit2374f629df8bc471aa0fbb1e0c0dda2e3536d2d8 (patch)
tree029eb5c5c3aa6427553e10db86d0fea5876f79e3
parent1b6df9b374d9e31d88854d5a270b48e26e55691e (diff)
Fixed #1983: Add option to update call Via address
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5493 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjsip-apps/src/swig/symbols.i2
-rw-r--r--pjsip/include/pjsua-lib/pjsua.h12
-rw-r--r--pjsip/src/pjsua-lib/pjsua_call.c60
3 files changed, 54 insertions, 20 deletions
diff --git a/pjsip-apps/src/swig/symbols.i b/pjsip-apps/src/swig/symbols.i
index 74332731..03bfa89f 100644
--- a/pjsip-apps/src/swig/symbols.i
+++ b/pjsip-apps/src/swig/symbols.i
@@ -163,7 +163,7 @@ typedef enum pjsua_call_vid_strm_op {PJSUA_CALL_VID_STRM_NO_OP, PJSUA_CALL_VID_S
typedef enum pjsua_vid_req_keyframe_method {PJSUA_VID_REQ_KEYFRAME_SIP_INFO = 1, PJSUA_VID_REQ_KEYFRAME_RTCP_PLI = 2} pjsua_vid_req_keyframe_method;
-typedef enum pjsua_call_flag {PJSUA_CALL_UNHOLD = 1, PJSUA_CALL_UPDATE_CONTACT = 2, PJSUA_CALL_INCLUDE_DISABLED_MEDIA = 4, PJSUA_CALL_NO_SDP_OFFER = 8, PJSUA_CALL_REINIT_MEDIA = 16} pjsua_call_flag;
+typedef enum pjsua_call_flag {PJSUA_CALL_UNHOLD = 1, PJSUA_CALL_UPDATE_CONTACT = 2, PJSUA_CALL_INCLUDE_DISABLED_MEDIA = 4, PJSUA_CALL_NO_SDP_OFFER = 8, PJSUA_CALL_REINIT_MEDIA = 16, PJSUA_CALL_UPDATE_VIA = 32} pjsua_call_flag;
typedef enum pjsua_create_media_transport_flag {PJSUA_MED_TP_CLOSE_MEMBER = 1} pjsua_create_media_transport_flag;
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h
index 3702ab67..137ca770 100644
--- a/pjsip/include/pjsua-lib/pjsua.h
+++ b/pjsip/include/pjsua-lib/pjsua.h
@@ -4297,7 +4297,17 @@ typedef enum pjsua_call_flag
* Warning: If the re-INVITE/UPDATE fails, the old media will not be
* reverted.
*/
- PJSUA_CALL_REINIT_MEDIA = 16
+ PJSUA_CALL_REINIT_MEDIA = 16,
+
+ /**
+ * Update the local invite session's Via with the via address from
+ * the account. This flag is only valid for #pjsua_call_set_hold2(),
+ * #pjsua_call_reinvite() and #pjsua_call_update(). Similar to
+ * the flag PJSUA_CALL_UPDATE_CONTACT above, this flag is useful
+ * in IP address change situation, after the local account's Via has
+ * been updated (typically with re-registration).
+ */
+ PJSUA_CALL_UPDATE_VIA = 32
} pjsua_call_flag;
diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c
index b3a07184..64896c19 100644
--- a/pjsip/src/pjsua-lib/pjsua_call.c
+++ b/pjsip/src/pjsua-lib/pjsua_call.c
@@ -569,7 +569,8 @@ on_error:
static void cleanup_call_setting_flag(pjsua_call_setting *opt)
{
opt->flag &= ~(PJSUA_CALL_UNHOLD | PJSUA_CALL_UPDATE_CONTACT |
- PJSUA_CALL_NO_SDP_OFFER | PJSUA_CALL_REINIT_MEDIA);
+ PJSUA_CALL_NO_SDP_OFFER | PJSUA_CALL_REINIT_MEDIA |
+ PJSUA_CALL_UPDATE_VIA);
}
@@ -638,6 +639,27 @@ static pj_status_t apply_call_setting(pjsua_call *call,
return PJ_SUCCESS;
}
+static void dlg_set_via(pjsip_dialog *dlg, pjsua_acc *acc)
+{
+ if (acc->cfg.allow_via_rewrite && acc->via_addr.host.slen > 0) {
+ pjsip_dlg_set_via_sent_by(dlg, &acc->via_addr, acc->via_tp);
+ } else if (!pjsua_sip_acc_is_using_stun(acc->index)) {
+ /* Choose local interface to use in Via if acc is not using
+ * STUN. See https://trac.pjsip.org/repos/ticket/1804
+ */
+ pjsip_host_port via_addr;
+ const void *via_tp;
+
+ if (pjsua_acc_get_uac_addr(acc->index, dlg->pool, &acc->cfg.id,
+ &via_addr, NULL, NULL,
+ &via_tp) == PJ_SUCCESS)
+ {
+ pjsip_dlg_set_via_sent_by(dlg, &via_addr,
+ (pjsip_transport*)via_tp);
+ }
+ }
+}
+
/*
* Make outgoing call to the specified URI using the specified account.
*/
@@ -777,23 +799,7 @@ PJ_DEF(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id,
*/
pjsip_dlg_inc_lock(dlg);
- if (acc->cfg.allow_via_rewrite && acc->via_addr.host.slen > 0) {
- pjsip_dlg_set_via_sent_by(dlg, &acc->via_addr, acc->via_tp);
- } else if (!pjsua_sip_acc_is_using_stun(acc_id)) {
- /* Choose local interface to use in Via if acc is not using
- * STUN. See https://trac.pjsip.org/repos/ticket/1804
- */
- pjsip_host_port via_addr;
- const void *via_tp;
-
- if (pjsua_acc_get_uac_addr(acc_id, dlg->pool, &acc->cfg.id,
- &via_addr, NULL, NULL,
- &via_tp) == PJ_SUCCESS)
- {
- pjsip_dlg_set_via_sent_by(dlg, &via_addr,
- (pjsip_transport*)via_tp);
- }
- }
+ dlg_set_via(dlg, acc);
/* Calculate call's secure level */
call->secure_level = get_secure_level(acc_id, dest_uri);
@@ -2499,6 +2505,12 @@ PJ_DEF(pj_status_t) pjsua_call_set_hold2(pjsua_call_id call_id,
new_contact = &pjsua_var.acc[call->acc_id].contact;
}
+ if ((options & PJSUA_CALL_UPDATE_VIA) &&
+ pjsua_acc_is_valid(call->acc_id))
+ {
+ dlg_set_via(call->inv->dlg, &pjsua_var.acc[call->acc_id]);
+ }
+
/* Create re-INVITE with new offer */
status = pjsip_inv_reinvite( call->inv, new_contact, sdp, &tdata);
if (status != PJ_SUCCESS) {
@@ -2620,6 +2632,12 @@ PJ_DEF(pj_status_t) pjsua_call_reinvite2(pjsua_call_id call_id,
new_contact = &pjsua_var.acc[call->acc_id].contact;
}
+ if ((call->opt.flag & PJSUA_CALL_UPDATE_VIA) &&
+ pjsua_acc_is_valid(call->acc_id))
+ {
+ dlg_set_via(call->inv->dlg, &pjsua_var.acc[call->acc_id]);
+ }
+
/* Create re-INVITE with new offer */
status = pjsip_inv_reinvite( call->inv, new_contact, sdp, &tdata);
if (status != PJ_SUCCESS) {
@@ -2729,6 +2747,12 @@ PJ_DEF(pj_status_t) pjsua_call_update2(pjsua_call_id call_id,
new_contact = &pjsua_var.acc[call->acc_id].contact;
}
+ if ((call->opt.flag & PJSUA_CALL_UPDATE_VIA) &&
+ pjsua_acc_is_valid(call->acc_id))
+ {
+ dlg_set_via(call->inv->dlg, &pjsua_var.acc[call->acc_id]);
+ }
+
/* Create UPDATE with new offer */
status = pjsip_inv_update(call->inv, new_contact, sdp, &tdata);
if (status != PJ_SUCCESS) {