Changeset 3891 for pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
- Timestamp:
- Dec 1, 2011 9:06:14 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
r3849 r3891 117 117 call_med->tp_auto_del = PJ_TRUE; 118 118 } 119 pjsua_call_setting_default(&call->opt); 119 120 } 120 121 … … 342 343 pjsua_acc *acc = &pjsua_var.acc[call->acc_id]; 343 344 pjsip_dialog *dlg = call->async_call.dlg; 344 unsigned options = call->async_call.call_var.out_call.options;345 unsigned options = 0; 345 346 pjsip_tx_data *tdata; 346 347 pj_status_t status = (info? info->status: PJ_SUCCESS); … … 488 489 489 490 /* 491 * Initialize call settings based on account ID. 492 */ 493 PJ_DEF(void) pjsua_call_setting_default(pjsua_call_setting *opt) 494 { 495 pj_assert(opt); 496 497 pj_bzero(opt, sizeof(*opt)); 498 opt->flag = PJSUA_CALL_INCLUDE_DISABLED_MEDIA; 499 opt->audio_cnt = 1; 500 501 #if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0) 502 opt->video_cnt = 1; 503 //{ 504 // unsigned i; 505 // for (i = 0; i < PJ_ARRAY_SIZE(opt->vid_cap_dev); ++i) 506 // opt->vid_cap_dev[i] = PJMEDIA_VID_DEFAULT_CAPTURE_DEV; 507 //} 508 #endif 509 } 510 511 static pj_status_t apply_call_setting(pjsua_call *call, 512 const pjsua_call_setting *opt, 513 const pjmedia_sdp_session *rem_sdp) 514 { 515 pj_assert(call); 516 517 if (!opt) 518 return PJ_SUCCESS; 519 520 #if !PJMEDIA_HAS_VIDEO 521 pj_assert(opt->video_cnt == 0); 522 #endif 523 524 /* If call is established, reinit media channel */ 525 if (call->inv && call->inv->state == PJSIP_INV_STATE_CONFIRMED) { 526 pjsua_call_setting old_opt; 527 pj_status_t status; 528 529 old_opt = call->opt; 530 call->opt = *opt; 531 532 /* Reinit media channel when media count is changed */ 533 if (opt->audio_cnt != old_opt.audio_cnt || 534 opt->video_cnt != old_opt.video_cnt) 535 { 536 pjsip_role_e role = rem_sdp? PJSIP_ROLE_UAS : PJSIP_ROLE_UAC; 537 status = pjsua_media_channel_init(call->index, role, 538 call->secure_level, 539 call->inv->pool_prov, 540 rem_sdp, NULL, 541 PJ_FALSE, NULL); 542 if (status != PJ_SUCCESS) { 543 pjsua_perror(THIS_FILE, "Error re-initializing media channel", 544 status); 545 return status; 546 } 547 } 548 } else { 549 call->opt = *opt; 550 } 551 552 return PJ_SUCCESS; 553 } 554 555 /* 490 556 * Make outgoing call to the specified URI using the specified account. 491 557 */ 492 PJ_DEF(pj_status_t) pjsua_call_make_call( 493 494 unsigned options,495 496 497 558 PJ_DEF(pj_status_t) pjsua_call_make_call(pjsua_acc_id acc_id, 559 const pj_str_t *dest_uri, 560 const pjsua_call_setting *opt, 561 void *user_data, 562 const pjsua_msg_data *msg_data, 563 pjsua_call_id *p_call_id) 498 564 { 499 565 pj_pool_t *tmp_pool = NULL; … … 555 621 call->acc_id = acc_id; 556 622 call->call_hold_type = acc->cfg.call_hold_type; 623 624 /* Apply call setting */ 625 status = apply_call_setting(call, opt, NULL); 626 if (status != PJ_SUCCESS) { 627 pjsua_perror(THIS_FILE, "Failed to apply call setting", status); 628 goto on_error; 629 } 557 630 558 631 /* Create temporary pool */ … … 623 696 * media transport creation is completed. 624 697 */ 625 call->async_call.call_var.out_call.options = options;626 698 if (msg_data) { 627 699 call->async_call.call_var.out_call.msg_data = pjsua_msg_data_clone( … … 1466 1538 sizeof(info->buf_.call_id)); 1467 1539 1540 /* call setting */ 1541 pj_memcpy(&info->setting, &call->opt, sizeof(call->opt)); 1542 1468 1543 /* state, state_text */ 1469 1544 info->state = (call->inv? call->inv->state: PJSIP_INV_STATE_DISCONNECTED); … … 1487 1562 } 1488 1563 1564 /* Audio & video count offered by remote */ 1565 info->rem_offerer = call->rem_offerer; 1566 if (call->rem_offerer) { 1567 info->rem_audio_cnt = call->rem_aud_cnt; 1568 info->rem_video_cnt = call->rem_vid_cnt; 1569 } 1570 1489 1571 /* Build array of media status and dir */ 1490 1572 info->media_cnt = 0; … … 1761 1843 const pjsua_msg_data *msg_data) 1762 1844 { 1845 return pjsua_call_answer2(call_id, NULL, code, reason, msg_data); 1846 } 1847 1848 1849 /* 1850 * Send response to incoming INVITE request. 1851 */ 1852 PJ_DEF(pj_status_t) pjsua_call_answer2(pjsua_call_id call_id, 1853 const pjsua_call_setting *opt, 1854 unsigned code, 1855 const pj_str_t *reason, 1856 const pjsua_msg_data *msg_data) 1857 { 1763 1858 pjsua_call *call; 1764 1859 pjsip_dialog *dlg = NULL; … … 1775 1870 if (status != PJ_SUCCESS) 1776 1871 goto on_return; 1872 1873 /* Apply call setting */ 1874 status = apply_call_setting(call, opt, NULL); 1875 if (status != PJ_SUCCESS) { 1876 pjsua_perror(THIS_FILE, "Failed to apply call setting", status); 1877 goto on_return; 1878 } 1777 1879 1778 1880 PJSUA_LOCK(); … … 2017 2119 const pjsua_msg_data *msg_data) 2018 2120 { 2121 pjsua_call *call; 2122 pjsip_dialog *dlg = NULL; 2123 pj_status_t status; 2124 2125 status = acquire_call("pjsua_call_reinvite()", call_id, &call, &dlg); 2126 if (status != PJ_SUCCESS) 2127 goto on_return; 2128 2129 if (options != call->opt.flag) 2130 call->opt.flag = options; 2131 2132 status = pjsua_call_reinvite2(call_id, NULL, msg_data); 2133 2134 on_return: 2135 if (dlg) pjsip_dlg_dec_lock(dlg); 2136 return status; 2137 } 2138 2139 2140 /* 2141 * Send re-INVITE (to release hold). 2142 */ 2143 PJ_DEF(pj_status_t) pjsua_call_reinvite2(pjsua_call_id call_id, 2144 const pjsua_call_setting *opt, 2145 const pjsua_msg_data *msg_data) 2146 { 2019 2147 pjmedia_sdp_session *sdp; 2020 2148 pj_str_t *new_contact = NULL; … … 2031 2159 pj_log_push_indent(); 2032 2160 2033 status = acquire_call("pjsua_call_reinvite ()", call_id, &call, &dlg);2161 status = acquire_call("pjsua_call_reinvite2()", call_id, &call, &dlg); 2034 2162 if (status != PJ_SUCCESS) 2035 2163 goto on_return; … … 2041 2169 } 2042 2170 2171 status = apply_call_setting(call, opt, NULL); 2172 if (status != PJ_SUCCESS) { 2173 pjsua_perror(THIS_FILE, "Failed to apply call setting", status); 2174 goto on_return; 2175 } 2176 2043 2177 /* Create SDP */ 2044 if (call->local_hold && ( options& PJSUA_CALL_UNHOLD)==0) {2178 if (call->local_hold && (call->opt.flag & PJSUA_CALL_UNHOLD)==0) { 2045 2179 status = create_sdp_of_call_hold(call, &sdp); 2046 2180 } else { … … 2056 2190 } 2057 2191 2058 if (( options& PJSUA_CALL_UPDATE_CONTACT) &2192 if ((call->opt.flag & PJSUA_CALL_UPDATE_CONTACT) & 2059 2193 pjsua_acc_is_valid(call->acc_id)) 2060 2194 { … … 2091 2225 PJ_DEF(pj_status_t) pjsua_call_update( pjsua_call_id call_id, 2092 2226 unsigned options, 2227 const pjsua_msg_data *msg_data) 2228 { 2229 pjsua_call *call; 2230 pjsip_dialog *dlg = NULL; 2231 pj_status_t status; 2232 2233 status = acquire_call("pjsua_call_update()", call_id, &call, &dlg); 2234 if (status != PJ_SUCCESS) 2235 goto on_return; 2236 2237 if (options != call->opt.flag) 2238 call->opt.flag = options; 2239 2240 status = pjsua_call_update2(call_id, NULL, msg_data); 2241 2242 on_return: 2243 if (dlg) pjsip_dlg_dec_lock(dlg); 2244 return status; 2245 } 2246 2247 2248 /* 2249 * Send UPDATE request. 2250 */ 2251 PJ_DEF(pj_status_t) pjsua_call_update2(pjsua_call_id call_id, 2252 const pjsua_call_setting *opt, 2093 2253 const pjsua_msg_data *msg_data) 2094 2254 { … … 2100 2260 pj_status_t status; 2101 2261 2102 PJ_UNUSED_ARG(options);2103 2104 2262 PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls, 2105 2263 PJ_EINVAL); … … 2108 2266 pj_log_push_indent(); 2109 2267 2110 status = acquire_call("pjsua_call_update ()", call_id, &call, &dlg);2268 status = acquire_call("pjsua_call_update2()", call_id, &call, &dlg); 2111 2269 if (status != PJ_SUCCESS) 2112 2270 goto on_return; 2271 2272 status = apply_call_setting(call, opt, NULL); 2273 if (status != PJ_SUCCESS) { 2274 pjsua_perror(THIS_FILE, "Failed to apply call setting", status); 2275 goto on_return; 2276 } 2113 2277 2114 2278 /* Create SDP */ … … 2122 2286 } 2123 2287 2124 if (( options& PJSUA_CALL_UPDATE_CONTACT) &2288 if ((call->opt.flag & PJSUA_CALL_UPDATE_CONTACT) & 2125 2289 pjsua_acc_is_valid(call->acc_id)) 2126 2290 { … … 3357 3521 pjmedia_sdp_session *answer; 3358 3522 unsigned i; 3523 int vid_idx; 3359 3524 pj_status_t status; 3360 3525 … … 3367 3532 call->index)); 3368 3533 pj_log_push_indent(); 3534 3535 #if 0 && PJMEDIA_HAS_VIDEO 3536 /* If current session has no video, let's just stay with no video. 3537 * If application want to enable video, it must send re-INVITE 3538 * with video. 3539 */ 3540 vid_idx = pjsua_call_get_vid_stream_idx(call->index); 3541 if (vid_idx == -1 || call->media[vid_idx].dir == PJMEDIA_DIR_NONE) 3542 call->opt.video_cnt = 0; 3543 #endif 3544 3545 /* Re-init media for the new remote offer before creating SDP */ 3546 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAS, 3547 call->secure_level, 3548 call->inv->pool_prov, 3549 offer, NULL, 3550 PJ_FALSE, NULL); 3551 if (status != PJ_SUCCESS) { 3552 pjsua_perror(THIS_FILE, "Error re-initializing media channel", status); 3553 goto on_return; 3554 } 3369 3555 3370 3556 status = pjsua_media_channel_create_sdp(call->index,
Note: See TracChangeset
for help on using the changeset viewer.