Changeset 1377 for pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c
- Timestamp:
- Jun 20, 2007 4:19:46 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c
r1366 r1377 63 63 static void inv_on_state_disconnected( pjsip_inv_session *inv, pjsip_event *e); 64 64 65 static pj_status_t inv_check_sdp_in_incoming_msg( pjsip_inv_session *inv, 66 pjsip_transaction *tsx, 67 pjsip_rx_data *rdata); 68 static pj_status_t process_answer( pjsip_inv_session *inv, 69 int st_code, 70 pjsip_tx_data *tdata, 71 const pjmedia_sdp_session *local_sdp); 72 65 73 static void (*inv_state_handler[])( pjsip_inv_session *inv, pjsip_event *e) = 66 74 { … … 142 150 { 143 151 pjsip_inv_state prev_state = inv->state; 152 pj_status_t status; 153 154 155 /* If state is confirmed, check that SDP negotiation is done, 156 * otherwise disconnect the session. 157 */ 158 if (state == PJSIP_INV_STATE_CONFIRMED) { 159 if (pjmedia_sdp_neg_get_state(inv->neg)!=PJMEDIA_SDP_NEG_STATE_DONE) { 160 pjsip_tx_data *bye; 161 162 PJ_LOG(4,(inv->obj_name, "SDP offer/answer incomplete, ending the " 163 "session")); 164 165 status = pjsip_inv_end_session(inv, PJSIP_SC_NOT_ACCEPTABLE, 166 NULL, &bye); 167 if (status == PJ_SUCCESS && bye) 168 status = pjsip_inv_send_msg(inv, bye); 169 170 return; 171 } 172 } 144 173 145 174 /* Set state. */ … … 268 297 inv->invite_tsx->state <= PJSIP_TSX_STATE_COMPLETED) 269 298 { 299 /* Before we terminate INVITE transaction, process the SDP 300 * in the ACK request, if any. 301 */ 302 inv_check_sdp_in_incoming_msg(inv, inv->invite_tsx, rdata); 303 304 /* Now we can terminate the INVITE transaction */ 270 305 pj_assert(inv->invite_tsx->status_code >= 200); 271 306 pjsip_tsx_terminate(inv->invite_tsx, … … 2174 2209 2175 2210 case PJSIP_TSX_STATE_CONFIRMED: 2176 /* For some reason can go here */ 2211 /* For some reason can go here (maybe when ACK for 2xx has 2212 * the same branch value as the INVITE transaction) */ 2177 2213 2178 2214 case PJSIP_TSX_STATE_TERMINATED: … … 2262 2298 2263 2299 case PJSIP_TSX_STATE_CONFIRMED: 2264 if (tsx->status_code/100 == 2) 2300 /* It can only go here if incoming ACK request has the same Via 2301 * branch parameter as the INVITE transaction. 2302 */ 2303 if (tsx->status_code/100 == 2) { 2304 if (e->body.tsx_state.type == PJSIP_EVENT_RX_MSG) { 2305 inv_check_sdp_in_incoming_msg(inv, tsx, 2306 e->body.tsx_state.src.rdata); 2307 } 2308 2265 2309 inv_set_state(inv, PJSIP_INV_STATE_CONFIRMED, e); 2310 } 2266 2311 break; 2267 2312 … … 2453 2498 return; 2454 2499 2455 /* Process SDP in the answer */ 2456 status = process_answer(inv, 200, tdata, NULL); 2500 /* If the INVITE request has SDP body, send answer. 2501 * Otherwise generate offer from local active SDP. 2502 */ 2503 if (rdata->msg_info.msg->body != NULL) { 2504 status = process_answer(inv, 200, tdata, NULL); 2505 } else { 2506 const pjmedia_sdp_session *active_sdp; 2507 status = pjmedia_sdp_neg_send_local_offer(dlg->pool, 2508 inv->neg, 2509 &active_sdp); 2510 if (status == PJ_SUCCESS) { 2511 tdata->msg->body = create_sdp_body(tdata->pool, active_sdp); 2512 } 2513 } 2457 2514 2458 2515 if (status != PJ_SUCCESS) { … … 2488 2545 /* Send 2xx regardless of the status of negotiation */ 2489 2546 status = pjsip_inv_send_msg(inv, tdata); 2547 2548 } else if (tsx->state == PJSIP_TSX_STATE_CONFIRMED) { 2549 /* This is the case where ACK has the same branch as 2550 * the INVITE request. 2551 */ 2552 if (tsx->status_code/100 == 2 && 2553 e->body.tsx_state.type == PJSIP_EVENT_RX_MSG) 2554 { 2555 inv_check_sdp_in_incoming_msg(inv, tsx, 2556 e->body.tsx_state.src.rdata); 2557 } 2490 2558 2491 2559 }
Note: See TracChangeset
for help on using the changeset viewer.