Ticket #817: sdp_neg_cancel_remote_offer_r2669.patch
File sdp_neg_cancel_remote_offer_r2669.patch, 4.4 KB (added by bennylp, 14 years ago) |
---|
-
pjmedia/include/pjmedia/sdp_neg.h
50 50 * 51 51 * modify_local_offer() 52 52 * create_w_local_offer() +-------------+ send_local_offer() 53 * ----------------------->| LOCAL_OFFER |<-----------------------53 * /----------------------->| LOCAL_OFFER |<-----------------------\ 54 54 * | +-------------+______ | 55 * | | \______ cancel()|56 * | set_remote_answer() | \______|57 * | V \|55 * | | \_____________ | 56 * | set_remote_answer() | cancel_offer() \ | 57 * | V v | 58 58 * +--+---+ +-----------+ negotiate() +-~----+ 59 59 * | NULL | | WAIT_NEGO |-------------------->| DONE | 60 60 * +------+ +-----------+ +------+ 61 * | A 62 * | set_local_answer() | 63 * | | 61 * | A ______________________^ | 62 * | set_local_answer() | / cancel_remote_offer() | 63 * | | / | 64 64 * | +--------------+ set_remote_offer() | 65 * ----------------------->| REMOTE_OFFER |<----------------------65 * \----------------------->| REMOTE_OFFER |<----------------------/ 66 66 * create_w_remote_offer() +--------------+ 67 67 * 68 68 * </pre> … … 255 255 * Regardless of the return status of the #pjmedia_sdp_neg_negotiate(), 256 256 * the negotiator state will move to PJMEDIA_SDP_NEG_STATE_DONE. 257 257 * 258 * \subsection sdpneg_cancel_remote_offer Cancelling Remote Offer 259 * 260 * In other scenarios, application may want to reset the negotiator state 261 * after it has set a remote offer. Consider the following scenario: 262 * - media has been established, and negotiator state is 263 * PJMEDIA_SDP_NEG_STATE_DONE. 264 * - application receives a new offer in re-INVITE, so in this case 265 * it would call #pjmedia_sdp_neg_set_remote_offer(). 266 * - the negotiator state moves to PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER 267 * - application rejects the re-INVITE request with non-successful 268 * final response. 258 269 * 270 * In this case, application can call #pjmedia_sdp_neg_cancel_remote_offer() 271 * to reset the negotiator state back to PJMEDIA_SDP_NEG_STATE_DONE. 259 272 */ 260 273 261 274 #include <pjmedia/sdp.h> … … 634 647 635 648 636 649 /** 650 * Cancel previously received remote offer, and move negotiator state back 651 * to previous stable state ((PJMEDIA_SDP_NEG_STATE_DONE). The negotiator 652 * must be in PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER state. 653 * 654 * @param neg The negotiator. 655 * 656 * @return PJ_SUCCESS or the appropriate error code. 657 */ 658 PJ_DECL(pj_status_t) pjmedia_sdp_neg_cancel_remote_offer(pjmedia_sdp_neg *neg); 659 660 661 /** 637 662 * Negotiate local and remote answer. Before calling this function, the 638 663 * SDP negotiator must be in PJMEDIA_SDP_NEG_STATE_WAIT_NEGO state. 639 664 * After calling this function, the negotiator state will move to -
pjmedia/src/pjmedia/sdp_neg.c
1346 1346 } 1347 1347 1348 1348 1349 /* Cancel remote offer */ 1350 PJ_DEF(pj_status_t) pjmedia_sdp_neg_cancel_remote_offer(pjmedia_sdp_neg *neg) 1351 { 1352 PJ_ASSERT_RETURN(neg, PJ_EINVAL); 1353 1354 /* Must be in LOCAL_OFFER state. */ 1355 PJ_ASSERT_RETURN(neg->state == PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER, 1356 PJMEDIA_SDPNEG_EINSTATE); 1357 1358 /* Reset state to done */ 1359 neg->state = PJMEDIA_SDP_NEG_STATE_DONE; 1360 1361 /* Clear temporary SDP */ 1362 neg->neg_local_sdp = neg->neg_remote_sdp = NULL; 1363 1364 return PJ_SUCCESS; 1365 } 1366 1367 1349 1368 /* The best bit: SDP negotiation function! */ 1350 1369 PJ_DEF(pj_status_t) pjmedia_sdp_neg_negotiate( pj_pool_t *pool, 1351 1370 pjmedia_sdp_neg *neg,