From dd44fb1ba190e10c5352edf77384c9286011a62a Mon Sep 17 00:00:00 2001 From: Sauw Ming Date: Wed, 6 Mar 2013 05:55:09 +0000 Subject: [PATCH] Fixed #1629: Add pjsua_call_set_hold2() API to allow update of Contact header git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@4421 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/include/pjsua-lib/pjsua.h | 30 ++++++++++++++++++++++++------ pjsip/src/pjsua-lib/pjsua_call.c | 16 +++++++++++++++- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h index 5a4a0fa4b..67fe430bc 100644 --- a/pjsip/include/pjsua-lib/pjsua.h +++ b/pjsip/include/pjsua-lib/pjsua.h @@ -4009,12 +4009,12 @@ typedef enum pjsua_call_flag /** * Update the local invite session's contact with the contact URI from - * the account. This flag is only valid for #pjsua_call_reinvite() and - * #pjsua_call_update(). This flag is useful in IP address change - * situation, after the local account's Contact has been updated - * (typically with re-registration) use this flag to update the invite - * session with the new Contact and to inform this new Contact to the - * remote peer with the outgoing re-INVITE or UPDATE + * the account. This flag is only valid for #pjsua_call_set_hold2(), + * #pjsua_call_reinvite() and #pjsua_call_update(). This flag is useful + * in IP address change situation, after the local account's Contact has + * been updated (typically with re-registration) use this flag to update + * the invite session with the new Contact and to inform this new Contact + * to the remote peer with the outgoing re-INVITE or UPDATE. */ PJSUA_CALL_UPDATE_CONTACT = 2, @@ -4474,6 +4474,24 @@ PJ_DECL(pj_status_t) pjsua_call_process_redirect(pjsua_call_id call_id, PJ_DECL(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id, const pjsua_msg_data *msg_data); +/** + * Put the specified call on hold. This will send re-INVITE with the + * appropriate SDP to inform remote that the call is being put on hold. + * The final status of the request itself will be reported on the + * \a on_call_media_state() callback, which inform the application that + * the media state of the call has changed. + * + * @param call_id Call identification. + * @param options Bitmask of pjsua_call_flag constants. Currently, only + * the flag PJSUA_CALL_UPDATE_CONTACT can be used. + * @param msg_data Optional message components to be sent with + * the request. + * + * @return PJ_SUCCESS on success, or the appropriate error code. + */ +PJ_DECL(pj_status_t) pjsua_call_set_hold2(pjsua_call_id call_id, + unsigned options, + const pjsua_msg_data *msg_data); /** * Send re-INVITE to release hold. diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c index 6db50cd8e..f0d75f5b7 100644 --- a/pjsip/src/pjsua-lib/pjsua_call.c +++ b/pjsip/src/pjsua-lib/pjsua_call.c @@ -2256,11 +2256,19 @@ PJ_DEF(pj_status_t) pjsua_call_process_redirect( pjsua_call_id call_id, */ PJ_DEF(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id, const pjsua_msg_data *msg_data) +{ + return pjsua_call_set_hold2(call_id, 0, msg_data); +} + +PJ_DEF(pj_status_t) pjsua_call_set_hold2(pjsua_call_id call_id, + unsigned options, + const pjsua_msg_data *msg_data) { pjmedia_sdp_session *sdp; pjsua_call *call; pjsip_dialog *dlg = NULL; pjsip_tx_data *tdata; + pj_str_t *new_contact = NULL; pj_status_t status; PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls, @@ -2283,8 +2291,14 @@ PJ_DEF(pj_status_t) pjsua_call_set_hold(pjsua_call_id call_id, if (status != PJ_SUCCESS) goto on_return; + if ((options & PJSUA_CALL_UPDATE_CONTACT) && + pjsua_acc_is_valid(call->acc_id)) + { + new_contact = &pjsua_var.acc[call->acc_id].contact; + } + /* Create re-INVITE with new offer */ - status = pjsip_inv_reinvite( call->inv, NULL, sdp, &tdata); + status = pjsip_inv_reinvite( call->inv, new_contact, sdp, &tdata); if (status != PJ_SUCCESS) { pjsua_perror(THIS_FILE, "Unable to create re-INVITE", status); goto on_return;