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
This commit is contained in:
Sauw Ming 2013-03-06 05:55:09 +00:00
parent 74f8514333
commit dd44fb1ba1
2 changed files with 39 additions and 7 deletions

View File

@ -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.

View File

@ -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;