Fixed #2037: Add on_rx_offer2() callback for SIP invite

Thanks to Andrey Kovalenko for the suggestion and the initial version of the patch.



git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@5641 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
Sauw Ming 2017-08-16 04:53:44 +00:00
parent add2753ff5
commit 2cd3d0a311
2 changed files with 32 additions and 4 deletions

View File

@ -96,6 +96,17 @@ typedef enum pjsip_inv_state
PJSIP_INV_STATE_DISCONNECTED, /**< Session is terminated. */
} pjsip_inv_state;
/**
* Structure to hold parameters when calling the callback
* #on_rx_offer2().
*/
struct pjsip_inv_on_rx_offer_cb_param
{
const pjmedia_sdp_session *offer; /** Remote offer. */
const pjsip_rx_data *rdata; /** The received request. */
};
/**
* This structure contains callbacks to be registered by application to
* receieve notifications from the framework about various events in
@ -154,11 +165,24 @@ typedef struct pjsip_inv_callback
* this SDP answer will be negotiated with the offer, and the result
* will be sent with the SIP message.
*
* Note: if callback #on_rx_offer2() is implemented, this callback will
* not be called.
*
* @param inv The invite session.
* @param offer Remote offer.
*/
void (*on_rx_offer)(pjsip_inv_session *inv,
const pjmedia_sdp_session *offer);
const pjmedia_sdp_session *offer);
/**
* This callback is called when the invite session has received
* new offer from peer. Variant of #on_rx_offer() callback.
*
* @param inv The invite session.
* @param param The callback parameters.
*/
void (*on_rx_offer2)(pjsip_inv_session *inv,
struct pjsip_inv_on_rx_offer_cb_param *param);
/**
* This callback is optional, and is called when the invite session has

View File

@ -2103,10 +2103,14 @@ static pj_status_t inv_check_sdp_in_incoming_msg( pjsip_inv_session *inv,
}
/* Inform application about remote offer. */
if (mod_inv.cb.on_rx_offer && inv->notify) {
(*mod_inv.cb.on_rx_offer)(inv, sdp_info->sdp);
if (mod_inv.cb.on_rx_offer2 && inv->notify) {
struct pjsip_inv_on_rx_offer_cb_param param;
param.offer = sdp_info->sdp;
param.rdata = rdata;
(*mod_inv.cb.on_rx_offer2)(inv, &param);
} else if (mod_inv.cb.on_rx_offer && inv->notify) {
(*mod_inv.cb.on_rx_offer)(inv, sdp_info->sdp);
}
/* application must have supplied an answer at this point. */