Changeset 737
- Timestamp:
- Sep 24, 2006 12:07:11 AM (18 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
r733 r737 2139 2139 pjsua_call_xfer( current_call, &tmp, &msg_data); 2140 2140 } 2141 2142 /* Hangup call regardless of xfer status */ 2143 pjsua_call_hangup(current_call, PJSIP_SC_GONE, NULL, NULL); 2141 2144 } 2142 2145 break; -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r731 r737 1021 1021 1022 1022 /** 1023 * Default account priority. 1024 */ 1025 #ifndef PJSUA_DEFAULT_ACC_PRIORITY 1026 # define PJSUA_DEFAULT_ACC_PRIORITY 0 1027 #endif 1028 1029 1030 /** 1023 1031 * Account configuration. 1024 1032 */ 1025 1033 typedef struct pjsua_acc_config 1026 1034 { 1035 /** 1036 * Account priority, which is used to control the order of matching 1037 * incoming/outgoing requests. The higher the number means the higher 1038 * the priority is, and the account will be matched first. 1039 */ 1040 int priority; 1041 1027 1042 /** 1028 1043 * The full SIP URL for the account. The value can take name address or -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h
r729 r737 190 190 pjsua_acc_id default_acc; /**< Default account ID */ 191 191 pjsua_acc acc[PJSUA_MAX_ACC]; /**< Account array. */ 192 pjsua_acc_id acc_ids[PJSUA_MAX_ACC]; /**< Acc sorted by prio*/ 192 193 193 194 /* Calls: */ -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
r685 r737 230 230 pjsua_var.acc[acc_id].valid = PJ_TRUE; 231 231 232 /* Insert account ID into account ID array, sorted by priority */ 233 for (i=0; i<pjsua_var.acc_cnt; ++i) { 234 if ( pjsua_var.acc[pjsua_var.acc_ids[i]].cfg.priority < 235 pjsua_var.acc[acc_id].cfg.priority) 236 { 237 break; 238 } 239 } 240 pj_array_insert(pjsua_var.acc_ids, sizeof(pjsua_var.acc_ids[0]), 241 pjsua_var.acc_cnt, i, &acc_id); 232 242 233 243 return PJ_SUCCESS; … … 321 331 322 332 pjsua_acc_config_default(&cfg); 333 334 /* Lower the priority of local account */ 335 --cfg.priority; 323 336 324 337 /* Build URI for the account */ … … 341 354 PJ_DEF(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id) 342 355 { 356 unsigned i; 357 343 358 PJ_ASSERT_RETURN(acc_id>=0 && acc_id<(int)PJ_ARRAY_SIZE(pjsua_var.acc), 344 359 PJ_EINVAL); … … 356 371 /* Invalidate */ 357 372 pjsua_var.acc[acc_id].valid = PJ_FALSE; 373 374 /* Remove from array */ 375 for (i=0; i<pjsua_var.acc_cnt; ++i) { 376 if (pjsua_var.acc_ids[i] == acc_id) 377 break; 378 } 379 if (i != pjsua_var.acc_cnt) { 380 pj_array_erase(pjsua_var.acc_ids, sizeof(pjsua_var.acc_ids[0]), 381 pjsua_var.acc_cnt, i); 382 --pjsua_var.acc_cnt; 383 } 358 384 359 385 PJ_TODO(may_need_to_scan_calls); … … 710 736 pjsip_uri *uri; 711 737 pjsip_sip_uri *sip_uri; 712 unsigned acc_id;738 unsigned i; 713 739 714 740 PJSUA_LOCK(); … … 720 746 uri = pjsip_parse_uri(pjsua_var.pool, tmp.ptr, tmp.slen, 0); 721 747 if (!uri) { 722 acc_id = pjsua_var.default_acc;723 goto on_return;748 PJSUA_UNLOCK(); 749 return pjsua_var.default_acc; 724 750 } 725 751 … … 728 754 { 729 755 /* Return the first account with proxy */ 730 for ( acc_id=0; acc_id<PJ_ARRAY_SIZE(pjsua_var.acc); ++acc_id) {731 if (!pjsua_var.acc[ acc_id].valid)756 for (i=0; i<PJ_ARRAY_SIZE(pjsua_var.acc); ++i) { 757 if (!pjsua_var.acc[i].valid) 732 758 continue; 733 if (!pj_list_empty(&pjsua_var.acc[ acc_id].route_set))759 if (!pj_list_empty(&pjsua_var.acc[i].route_set)) 734 760 break; 735 761 } 736 762 737 if ( acc_id!= PJ_ARRAY_SIZE(pjsua_var.acc)) {763 if (i != PJ_ARRAY_SIZE(pjsua_var.acc)) { 738 764 /* Found rather matching account */ 739 goto on_return; 765 PJSUA_UNLOCK(); 766 return 0; 740 767 } 741 768 742 769 /* Not found, use default account */ 743 acc_id = pjsua_var.default_acc;744 goto on_return;770 PJSUA_UNLOCK(); 771 return pjsua_var.default_acc; 745 772 } 746 773 747 774 sip_uri = pjsip_uri_get_uri(uri); 748 775 749 /* See if default acc match */750 if (pjsua_var.default_acc != PJSUA_INVALID_ID &&751 pj_stricmp(&pjsua_var.acc[pjsua_var.default_acc].srv_domain, &sip_uri->host)==0 &&752 pjsua_var.acc[pjsua_var.default_acc].srv_port == sip_uri->port)753 {754 acc_id = pjsua_var.default_acc;755 } else {756 acc_id = PJ_ARRAY_SIZE(pjsua_var.acc);757 }758 759 776 /* Find matching domain AND port */ 760 if (acc_id == PJ_ARRAY_SIZE(pjsua_var.acc)) {761 for (acc_id=0; acc_id<PJ_ARRAY_SIZE(pjsua_var.acc); ++acc_id) {762 if (!pjsua_var.acc[acc_id].valid)763 continue;764 if (pj_stricmp(&pjsua_var.acc[acc_id].srv_domain, &sip_uri->host)==0 &&765 pjsua_var.acc[acc_id].srv_port == sip_uri->port)766 break;777 for (i=0; i<pjsua_var.acc_cnt; ++i) { 778 unsigned acc_id = pjsua_var.acc_ids[i]; 779 if (pj_stricmp(&pjsua_var.acc[acc_id].srv_domain, &sip_uri->host)==0 && 780 pjsua_var.acc[acc_id].srv_port == sip_uri->port) 781 { 782 PJSUA_UNLOCK(); 783 return acc_id; 767 784 } 768 785 } 769 786 770 787 /* If no match, try to match the domain part only */ 771 if (acc_id == PJ_ARRAY_SIZE(pjsua_var.acc)) { 772 /* Just use default account */ 773 for (acc_id=0; acc_id<PJ_ARRAY_SIZE(pjsua_var.acc); ++acc_id) { 774 if (!pjsua_var.acc[acc_id].valid) 775 continue; 776 if (pj_stricmp(&pjsua_var.acc[acc_id].srv_domain, &sip_uri->host)==0) 777 break; 778 } 779 } 780 781 if (acc_id == PJ_ARRAY_SIZE(pjsua_var.acc)) { 782 /* Just use default account */ 783 acc_id = pjsua_var.default_acc; 784 } 785 786 on_return: 788 for (i=0; i<pjsua_var.acc_cnt; ++i) { 789 unsigned acc_id = pjsua_var.acc_ids[i]; 790 if (pj_stricmp(&pjsua_var.acc[acc_id].srv_domain, &sip_uri->host)==0) 791 { 792 PJSUA_UNLOCK(); 793 return acc_id; 794 } 795 } 796 797 798 /* Still no match, just use default account */ 787 799 PJSUA_UNLOCK(); 788 789 return acc_id; 800 return pjsua_var.default_acc; 790 801 } 791 802 … … 799 810 pjsip_uri *uri; 800 811 pjsip_sip_uri *sip_uri; 801 unsigned acc_id;812 unsigned i; 802 813 803 814 uri = rdata->msg_info.to->uri; … … 816 827 817 828 /* Find account which has matching username and domain. */ 818 for ( acc_id=0; acc_id < pjsua_var.acc_cnt; ++acc_id) {819 829 for (i=0; i < pjsua_var.acc_cnt; ++i) { 830 unsigned acc_id = pjsua_var.acc_ids[i]; 820 831 pjsua_acc *acc = &pjsua_var.acc[acc_id]; 821 832 … … 829 840 } 830 841 831 /* No matching , try match domain part only. */832 for ( acc_id=0; acc_id < pjsua_var.acc_cnt; ++acc_id) {833 842 /* No matching account, try match domain part only. */ 843 for (i=0; i < pjsua_var.acc_cnt; ++i) { 844 unsigned acc_id = pjsua_var.acc_ids[i]; 834 845 pjsua_acc *acc = &pjsua_var.acc[acc_id]; 835 846 836 847 if (pj_stricmp(&acc->srv_domain, &sip_uri->host)==0) { 848 /* Match ! */ 849 PJSUA_UNLOCK(); 850 return acc_id; 851 } 852 } 853 854 /* No matching account, try match user part only. */ 855 for (i=0; i < pjsua_var.acc_cnt; ++i) { 856 unsigned acc_id = pjsua_var.acc_ids[i]; 857 pjsua_acc *acc = &pjsua_var.acc[acc_id]; 858 859 if (pj_stricmp(&acc->user_part, &sip_uri->user)==0) { 837 860 /* Match ! */ 838 861 PJSUA_UNLOCK(); -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
r734 r737 238 238 call = &pjsua_var.calls[call_id]; 239 239 240 PJ_LOG(4,(THIS_FILE, "Making call with acc #%d to %.*s", acc_id, 241 (int)dest_uri->slen, dest_uri->ptr)); 242 240 243 /* Mark call start time. */ 241 244 pj_gettimeofday(&call->start_time); … … 316 319 317 320 pjsua_process_msg_data( tdata, msg_data); 321 322 /* Must increment call counter now */ 323 ++pjsua_var.call_cnt; 318 324 319 325 /* Send initial INVITE: */ … … 333 339 334 340 /* Done. */ 335 336 ++pjsua_var.call_cnt;337 341 338 342 if (p_call_id) … … 463 467 * the call. 464 468 */ 465 acc_id = pjsua_acc_find_for_incoming(rdata);469 acc_id = call->acc_id = pjsua_acc_find_for_incoming(rdata); 466 470 467 471 /* Get suitable Contact header */
Note: See TracChangeset
for help on using the changeset viewer.