diff options
author | Liong Sauw Ming <ming@teluu.com> | 2013-03-06 05:55:09 +0000 |
---|---|---|
committer | Liong Sauw Ming <ming@teluu.com> | 2013-03-06 05:55:09 +0000 |
commit | 5087300ce2189c93021234508a2bb0cd497f1876 (patch) | |
tree | 0052ab3df4904f55d19a4d58ddea88c4a61e1b27 /pjsip | |
parent | 22da209226aac2c65f45900e55cf5f162cd311d4 (diff) |
Fixed #1629: Add pjsua_call_set_hold2() API to allow update of Contact header
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4421 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r-- | pjsip/include/pjsua-lib/pjsua.h | 30 | ||||
-rw-r--r-- | 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 5a4a0fa4..67fe430b 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 6db50cd8..f0d75f5b 100644 --- a/pjsip/src/pjsua-lib/pjsua_call.c +++ b/pjsip/src/pjsua-lib/pjsua_call.c @@ -2257,10 +2257,18 @@ 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; |