From bd669b9c601fa8c18e7fbfb6789d6135f1b4224b Mon Sep 17 00:00:00 2001 From: Liong Sauw Ming Date: Mon, 9 May 2016 03:29:28 +0000 Subject: Fixed #1913: Add callback for address change notification from STUN keep alive git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5282 74dad513-b988-da41-8d7b-12977e46ad98 --- pjnath/include/pjnath/ice_strans.h | 8 ++++++-- pjnath/src/pjnath/ice_strans.c | 8 ++++++++ pjsip/src/pjsua-lib/pjsua_media.c | 5 ++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/pjnath/include/pjnath/ice_strans.h b/pjnath/include/pjnath/ice_strans.h index 340bf605..d711d951 100644 --- a/pjnath/include/pjnath/ice_strans.h +++ b/pjnath/include/pjnath/ice_strans.h @@ -125,10 +125,14 @@ typedef enum pj_ice_strans_op /** Negotiation */ PJ_ICE_STRANS_OP_NEGOTIATION, - /** This operatino is used to report failure in keep-alive operation. + /** This operation is used to report failure in keep-alive operation. * Currently it is only used to report TURN Refresh failure. */ - PJ_ICE_STRANS_OP_KEEP_ALIVE + PJ_ICE_STRANS_OP_KEEP_ALIVE, + + /** IP address change notification from STUN keep-alive operation. + */ + PJ_ICE_STRANS_OP_ADDR_CHANGE } pj_ice_strans_op; diff --git a/pjnath/src/pjnath/ice_strans.c b/pjnath/src/pjnath/ice_strans.c index aee0c39d..66dce88e 100644 --- a/pjnath/src/pjnath/ice_strans.c +++ b/pjnath/src/pjnath/ice_strans.c @@ -1640,6 +1640,14 @@ static pj_bool_t stun_on_status(pj_stun_sock *stun_sock, sizeof(ipaddr), 3))); sess_init_update(ice_st); + + if (op == PJ_STUN_SOCK_MAPPED_ADDR_CHANGE && + ice_st->cb.on_ice_complete) + { + (*ice_st->cb.on_ice_complete)(ice_st, + PJ_ICE_STRANS_OP_ADDR_CHANGE, + status); + } } } diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c index f659e23e..5f948973 100644 --- a/pjsip/src/pjsua-lib/pjsua_media.c +++ b/pjsip/src/pjsua-lib/pjsua_media.c @@ -679,6 +679,7 @@ static void on_ice_complete(pjmedia_transport *tp, pjsua_call_schedule_reinvite_check(call, 0); break; case PJ_ICE_STRANS_OP_KEEP_ALIVE: + case PJ_ICE_STRANS_OP_ADDR_CHANGE: if (result != PJ_SUCCESS) { PJ_PERROR(4,(THIS_FILE, result, "ICE keep alive failure for transport %d:%d", @@ -695,7 +696,9 @@ static void on_ice_complete(pjmedia_transport *tp, (*pjsua_var.ua_cfg.cb.on_call_media_transport_state)( call->index, &info); } - if (pjsua_var.ua_cfg.cb.on_ice_transport_error) { + if (pjsua_var.ua_cfg.cb.on_ice_transport_error && + op == PJ_ICE_STRANS_OP_KEEP_ALIVE) + { pjsua_call_id id = call->index; (*pjsua_var.ua_cfg.cb.on_ice_transport_error)(id, op, result, NULL); -- cgit v1.2.3