From a69e3e09bcebcdec20e3224c6b073f58d4618d67 Mon Sep 17 00:00:00 2001 From: Nanang Izzuddin Date: Tue, 13 Dec 2011 04:59:15 +0000 Subject: Close #1424: Added new pjsua callback: on_call_rx_offer(). git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3908 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/include/pjsua-lib/pjsua.h | 24 ++++++++++++++++++++++++ pjsip/src/pjsua-lib/pjsua_call.c | 16 ++++++++++++++++ 2 files changed, 40 insertions(+) (limited to 'pjsip') diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h index f8789307..06d9646e 100644 --- a/pjsip/include/pjsua-lib/pjsua.h +++ b/pjsip/include/pjsua-lib/pjsua.h @@ -810,6 +810,30 @@ typedef struct pjsua_callback pjsua_call_id new_call_id); + /** + * Notify application when call has received new offer from remote + * (i.e. re-INVITE/UPDATE with SDP is received). Application can + * decide to accept/reject the offer by setting the code (default + * is 200). If the offer is accepted, application can update the + * call setting to be applied in the answer. When this callback is + * not defined, the default behavior is to accept the offer using + * current call setting. + * + * @param call_id The call index. + * @param offer The new offer received. + * @param reserved Reserved param, currently not used. + * @param code Status code to be returned for answering the + * offer. On input, it contains status code 200. + * Currently, valid values are only 200 and 488. + * @param opt The current call setting, application can update + * this setting for answering the offer. + */ + void (*on_call_rx_offer)(pjsua_call_id call_id, + const pjmedia_sdp_session *offer, + void *reserved, + pjsip_status_code *code, + pjsua_call_setting *opt); + /** * Notify application when registration or unregistration has been * initiated. Note that this only notifies the initial registration diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c index 15288538..ece37d51 100644 --- a/pjsip/src/pjsua-lib/pjsua_call.c +++ b/pjsip/src/pjsua-lib/pjsua_call.c @@ -3555,6 +3555,22 @@ static void pjsua_call_on_rx_offer(pjsip_inv_session *inv, call->index)); pj_log_push_indent(); + if (pjsua_var.ua_cfg.cb.on_call_rx_offer) { + pjsip_status_code code = PJSIP_SC_OK; + pjsua_call_setting opt = call->opt; + + (*pjsua_var.ua_cfg.cb.on_call_rx_offer)(call->index, offer, NULL, + &code, &opt); + + if (code != PJSIP_SC_OK) { + PJ_LOG(4,(THIS_FILE, "Rejecting updated media offer on call %d", + call->index)); + goto on_return; + } + + call->opt = opt; + } + /* Re-init media for the new remote offer before creating SDP */ status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAS, call->secure_level, -- cgit v1.2.3