Changeset 5828 for pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
- Timestamp:
- Jul 20, 2018 2:19:41 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
r5816 r5828 80 80 */ 81 81 static void pjsua_call_on_rx_offer(pjsip_inv_session *inv, 82 const pjmedia_sdp_session *offer); 82 struct pjsip_inv_on_rx_offer_cb_param *param); 83 84 /* 85 * Called when receiving re-INVITE. 86 */ 87 static pj_status_t pjsua_call_on_rx_reinvite(pjsip_inv_session *inv, 88 const pjmedia_sdp_session *offer, 89 pjsip_rx_data *rdata); 83 90 84 91 /* … … 191 198 inv_cb.on_new_session = &pjsua_call_on_forked; 192 199 inv_cb.on_media_update = &pjsua_call_on_media_update; 193 inv_cb.on_rx_offer = &pjsua_call_on_rx_offer;200 inv_cb.on_rx_offer2 = &pjsua_call_on_rx_offer; 194 201 inv_cb.on_create_offer = &pjsua_call_on_create_offer; 195 202 inv_cb.on_tsx_state_changed = &pjsua_call_on_tsx_state_changed; 196 203 inv_cb.on_redirected = &pjsua_call_on_redirected; 204 if (pjsua_var.ua_cfg.cb.on_call_rx_reinvite) { 205 inv_cb.on_rx_reinvite = &pjsua_call_on_rx_reinvite; 206 } 197 207 198 208 /* Initialize invite session module: */ … … 2404 2414 2405 2415 /* 2416 * Send response to incoming INVITE request. 2417 */ 2418 PJ_DEF(pj_status_t) 2419 pjsua_call_answer_with_sdp(pjsua_call_id call_id, 2420 const pjmedia_sdp_session *sdp, 2421 const pjsua_call_setting *opt, 2422 unsigned code, 2423 const pj_str_t *reason, 2424 const pjsua_msg_data *msg_data) 2425 { 2426 pjsua_call *call; 2427 pjsip_dialog *dlg = NULL; 2428 pj_status_t status; 2429 2430 PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls, 2431 PJ_EINVAL); 2432 2433 status = acquire_call("pjsua_call_answer_with_sdp()", 2434 call_id, &call, &dlg); 2435 if (status != PJ_SUCCESS) 2436 return status; 2437 2438 status = pjsip_inv_set_sdp_answer(call->inv, sdp); 2439 2440 pjsip_dlg_dec_lock(dlg); 2441 2442 if (status != PJ_SUCCESS) 2443 return status; 2444 2445 return pjsua_call_answer2(call_id, opt, code, reason, msg_data); 2446 } 2447 2448 2449 /* 2406 2450 * Hangup call by using method that is appropriate according to the 2407 2451 * call state. … … 4264 4308 */ 4265 4309 static void pjsua_call_on_rx_offer(pjsip_inv_session *inv, 4266 const pjmedia_sdp_session *offer)4310 struct pjsip_inv_on_rx_offer_cb_param *param) 4267 4311 { 4268 4312 pjsua_call *call; … … 4270 4314 unsigned i; 4271 4315 pj_status_t status; 4316 const pjmedia_sdp_session *offer = param->offer; 4317 pjsua_call_setting opt; 4318 pj_bool_t async = PJ_FALSE; 4272 4319 4273 4320 call = (pjsua_call*) inv->dlg->mod_data[pjsua_var.mod.id]; … … 4285 4332 4286 4333 cleanup_call_setting_flag(&call->opt); 4287 4288 if (pjsua_var.ua_cfg.cb.on_call_rx_offer) { 4334 opt = call->opt; 4335 4336 if (pjsua_var.ua_cfg.cb.on_call_rx_reinvite && 4337 param->rdata->msg_info.msg->type == PJSIP_REQUEST_MSG && 4338 param->rdata->msg_info.msg->line.req.method.id == PJSIP_INVITE_METHOD) 4339 { 4340 pjsip_status_code code = PJSIP_SC_OK; 4341 4342 /* If on_call_rx_reinvite() callback is implemented, 4343 * call it first. 4344 */ 4345 (*pjsua_var.ua_cfg.cb.on_call_rx_reinvite)( 4346 call->index, offer, 4347 (pjsip_rx_data *)param->rdata, 4348 NULL, &async, &code, &opt); 4349 if (async) { 4350 pjsip_tx_data *response; 4351 4352 status = pjsip_inv_initial_answer(inv, 4353 (pjsip_rx_data *)param->rdata, 4354 100, NULL, NULL, &response); 4355 if (status != PJ_SUCCESS) { 4356 PJ_LOG(3, (THIS_FILE, "Failed to create initial answer")); 4357 goto on_return; 4358 } 4359 4360 status = pjsip_inv_send_msg(inv, response); 4361 if (status != PJ_SUCCESS) { 4362 PJ_LOG(3, (THIS_FILE, "Failed to send initial answer")); 4363 goto on_return; 4364 } 4365 4366 PJ_LOG(4,(THIS_FILE, "App will manually answer the re-INVITE " 4367 "on call %d", call->index)); 4368 } 4369 if (code != PJSIP_SC_OK) { 4370 PJ_LOG(4,(THIS_FILE, "Rejecting re-INVITE updated media offer " 4371 "on call %d", call->index)); 4372 goto on_return; 4373 } 4374 4375 call->opt = opt; 4376 } 4377 4378 if (pjsua_var.ua_cfg.cb.on_call_rx_offer && !async) { 4289 4379 pjsip_status_code code = PJSIP_SC_OK; 4290 pjsua_call_setting opt; 4291 4292 opt = call->opt; 4380 4293 4381 (*pjsua_var.ua_cfg.cb.on_call_rx_offer)(call->index, offer, NULL, 4294 4382 &code, &opt); … … 4313 4401 if (status != PJ_SUCCESS) { 4314 4402 pjsua_perror(THIS_FILE, "Unable to create local SDP", status); 4403 goto on_return; 4404 } 4405 4406 if (async) { 4407 call->rx_reinv_async = async; 4315 4408 goto on_return; 4316 4409 } … … 4361 4454 on_return: 4362 4455 pj_log_pop_indent(); 4456 } 4457 4458 4459 /* 4460 * Called when receiving re-INVITE. 4461 */ 4462 static pj_status_t pjsua_call_on_rx_reinvite(pjsip_inv_session *inv, 4463 const pjmedia_sdp_session *offer, 4464 pjsip_rx_data *rdata) 4465 { 4466 pjsua_call *call; 4467 pj_bool_t async; 4468 4469 PJ_UNUSED_ARG(offer); 4470 PJ_UNUSED_ARG(rdata); 4471 4472 call = (pjsua_call*) inv->dlg->mod_data[pjsua_var.mod.id]; 4473 async = call->rx_reinv_async; 4474 call->rx_reinv_async = PJ_FALSE; 4475 4476 return (async? PJ_SUCCESS: !PJ_SUCCESS); 4363 4477 } 4364 4478
Note: See TracChangeset
for help on using the changeset viewer.