Changeset 4562 for pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c
- Timestamp:
- Jul 15, 2013 4:23:31 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c
r4556 r4562 1836 1836 PJMEDIA_SDP_NEG_STATE_WAIT_NEGO) 1837 1837 { 1838 if (mod_inv.cb.on_rx_reinvite && inv->notify && 1839 msg->type == PJSIP_REQUEST_MSG && 1840 msg->line.req.method.id == PJSIP_INVITE_METHOD) 1841 { 1842 /* Do not return failure first, allow the application 1843 * to set the answer in the on_rx_reinvite() callback. 1844 */ 1845 return PJ_SUCCESS; 1846 } 1838 1847 return PJ_EINVALIDOP; 1839 1848 } … … 1973 1982 } 1974 1983 1984 /* Cancel SDP negotiation if this is a negative reply to a re-INVITE */ 1985 if (st_code >= 300 && inv->neg != NULL && 1986 inv->state == PJSIP_INV_STATE_CONFIRMED) 1987 { 1988 pjmedia_sdp_neg_state neg_state; 1989 neg_state = pjmedia_sdp_neg_get_state(inv->neg); 1990 if (neg_state == PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER) { 1991 pjmedia_sdp_neg_cancel_offer(inv->neg); 1992 } 1993 } 1975 1994 1976 1995 return PJ_SUCCESS; … … 2053 2072 2054 2073 /* 2055 * Answer initial INVITE 2056 * Re-INVITE will be answered automatically, and will not use this function. 2074 * Answer INVITE request. 2057 2075 */ 2058 2076 PJ_DEF(pj_status_t) pjsip_inv_answer( pjsip_inv_session *inv, … … 2277 2295 2278 2296 pj_log_pop_indent(); 2297 return PJ_SUCCESS; 2298 } 2299 2300 /* 2301 * Cancel re-INVITE transaction. 2302 */ 2303 PJ_DEF(pj_status_t) pjsip_inv_cancel_reinvite( pjsip_inv_session *inv, 2304 pjsip_tx_data **p_tdata ) 2305 { 2306 pjsip_tx_data *tdata; 2307 pj_status_t status; 2308 2309 /* Verify arguments. */ 2310 PJ_ASSERT_RETURN(inv && p_tdata, PJ_EINVAL); 2311 2312 pj_log_push_indent(); 2313 2314 /* Create appropriate message. */ 2315 switch (inv->state) { 2316 case PJSIP_INV_STATE_CONFIRMED: 2317 /* MUST have the original UAC INVITE transaction */ 2318 PJ_ASSERT_RETURN(inv->invite_tsx != NULL, PJ_EBUG); 2319 2320 /* CANCEL should only be called when we have received a 2321 * provisional response. 2322 */ 2323 if (inv->invite_tsx->status_code < 100) { 2324 inv->cancelling = PJ_TRUE; 2325 inv->pending_cancel = PJ_TRUE; 2326 *p_tdata = NULL; 2327 PJ_LOG(4, (inv->obj_name, "Delaying CANCEL since no " 2328 "provisional response is received yet")); 2329 pj_log_pop_indent(); 2330 return PJ_SUCCESS; 2331 } 2332 2333 status = pjsip_endpt_create_cancel(inv->dlg->endpt, 2334 inv->invite_tsx->last_tx, 2335 &tdata); 2336 if (status != PJ_SUCCESS) { 2337 pj_log_pop_indent(); 2338 return status; 2339 } 2340 break; 2341 2342 default: 2343 /* We cannot send CANCEL to a re-INVITE if the INVITE session is 2344 * not confirmed. 2345 */ 2346 pj_log_pop_indent(); 2347 return PJ_EINVALIDOP; 2348 } 2349 2350 pj_log_pop_indent(); 2351 2352 *p_tdata = tdata; 2279 2353 return PJ_SUCCESS; 2280 2354 } … … 4083 4157 4084 4158 /* 4085 * Handle strandled incoming CANCEL. 4086 */ 4087 pjsip_rx_data *rdata = e->body.tsx_state.src.rdata; 4088 pjsip_tx_data *tdata; 4089 pj_status_t status; 4090 4091 status = pjsip_dlg_create_response(dlg, rdata, 200, NULL, &tdata); 4092 if (status != PJ_SUCCESS) return; 4093 4094 status = pjsip_dlg_send_response(dlg, tsx, tdata); 4095 if (status != PJ_SUCCESS) return; 4159 * Handle strandled incoming CANCEL or CANCEL for re-INVITE 4160 */ 4161 inv_respond_incoming_cancel(inv, tsx, e); 4096 4162 4097 4163 } else if (tsx->role == PJSIP_ROLE_UAS && … … 4229 4295 pjsip_tx_data *tdata; 4230 4296 pj_status_t status; 4231 pjsip_rdata_sdp_info *sdp_info ;4297 pjsip_rdata_sdp_info *sdp_info = NULL; 4232 4298 pjsip_status_code st_code; 4233 4299 … … 4302 4368 status = inv_check_sdp_in_incoming_msg(inv, tsx, rdata); 4303 4369 4370 if (status == PJ_SUCCESS && mod_inv.cb.on_rx_reinvite && 4371 inv->notify) 4372 { 4373 sdp_info = pjsip_rdata_get_sdp_info(rdata); 4374 if ((*mod_inv.cb.on_rx_reinvite) 4375 (inv, sdp_info->sdp, rdata) == PJ_SUCCESS) 4376 { 4377 /* Application will send its own response. 4378 * Our job is done. */ 4379 return; 4380 } 4381 4382 /* If application lets us answer the re-INVITE, 4383 * application must set the SDP answer with 4384 * #pjsip_inv_set_sdp_answer(). 4385 */ 4386 if (pjmedia_sdp_neg_get_state(inv->neg) != 4387 PJMEDIA_SDP_NEG_STATE_WAIT_NEGO) 4388 { 4389 status = PJ_EINVALIDOP; 4390 } 4391 } 4392 4304 4393 if (status != PJ_SUCCESS) { 4305 4394 … … 4343 4432 * Otherwise generate offer from local active SDP. 4344 4433 */ 4345 sdp_info = pjsip_rdata_get_sdp_info(rdata); 4434 if (!sdp_info) 4435 sdp_info = pjsip_rdata_get_sdp_info(rdata); 4346 4436 if (sdp_info->sdp != NULL) { 4347 4437 status = process_answer(inv, 200, tdata, NULL); … … 4460 4550 inv->invite_tsx = tsx; 4461 4551 4552 } else if (tsx->state == PJSIP_TSX_STATE_PROCEEDING) { 4553 4554 /* CANCEL the re-INVITE if necessary */ 4555 if (inv->pending_cancel) { 4556 pj_status_t status; 4557 pjsip_tx_data *cancel; 4558 4559 inv->pending_cancel = PJ_FALSE; 4560 4561 status = pjsip_inv_cancel_reinvite(inv, &cancel); 4562 if (status == PJ_SUCCESS && cancel) 4563 status = pjsip_inv_send_msg(inv, cancel); 4564 } 4565 4462 4566 } else if (tsx->state == PJSIP_TSX_STATE_TERMINATED && 4463 4567 tsx->status_code/100 == 2)
Note: See TracChangeset
for help on using the changeset viewer.