Changeset 492
- Timestamp:
- Jun 6, 2006 6:40:40 PM (18 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/build/pjmedia.dsp
r458 r492 304 304 # Begin Source File 305 305 306 SOURCE=..\include\pjmedia\splitcomb.h 307 # End Source File 308 # Begin Source File 309 306 310 SOURCE=..\include\pjmedia\stream.h 307 311 # End Source File -
pjproject/trunk/pjmedia/include/pjmedia/conference.h
r347 r492 47 47 pj_bool_t *listener; /**< Array of listeners. */ 48 48 unsigned clock_rate; /**< Clock rate of the port. */ 49 unsigned channel_count; /**< Number of channels. */ 49 50 unsigned samples_per_frame; /**< Samples per frame */ 51 unsigned bits_per_sample; /**< Bits per sample. */ 50 52 int tx_adj_level; /**< Tx level adjustment. */ 51 53 int rx_adj_level; /**< Rx level adjustment. */ … … 255 257 256 258 /** 259 * Enumerate occupied ports in the bridge. 260 * 261 * @param conf The conference bridge. 262 * @param ports Array of port numbers to be filled in. 263 * @param count On input, specifies the maximum number of ports 264 * in the array. On return, it will be filled with 265 * the actual number of ports. 266 * 267 * @return PJ_SUCCESS on success. 268 */ 269 PJ_DECL(pj_status_t) pjmedia_conf_enum_ports( pjmedia_conf *conf, 270 unsigned ports[], 271 unsigned *count ); 272 273 274 /** 257 275 * Get port info. 258 276 * -
pjproject/trunk/pjmedia/src/pjmedia/conference.c
r481 r492 821 821 } 822 822 823 824 /* 825 * Enum ports. 826 */ 827 PJ_DEF(pj_status_t) pjmedia_conf_enum_ports( pjmedia_conf *conf, 828 unsigned ports[], 829 unsigned *p_count ) 830 { 831 unsigned i, count=0; 832 833 PJ_ASSERT_RETURN(conf && p_count && ports, PJ_EINVAL); 834 835 for (i=0; i<conf->max_ports && count<*p_count; ++i) { 836 if (!conf->ports[i]) 837 continue; 838 839 ports[count++] = i; 840 } 841 842 *p_count = count; 843 return PJ_SUCCESS; 844 } 845 823 846 /* 824 847 * Get port info … … 844 867 info->listener = conf_port->listeners; 845 868 info->clock_rate = conf_port->clock_rate; 869 info->channel_count = conf->channel_count; 846 870 info->samples_per_frame = conf_port->samples_per_frame; 871 info->bits_per_sample = conf->bits_per_sample; 847 872 info->tx_adj_level = conf_port->tx_adj_level - NORMAL_LEVEL; 848 873 info->rx_adj_level = conf_port->rx_adj_level - NORMAL_LEVEL; -
pjproject/trunk/pjsip-apps/src/activex-pjsua/activex-pjsua.idl
r487 r492 30 30 [id(10), helpstring("method call_has_media")] HRESULT call_has_media([in] int call_index, [out,retval] Pj_Bool *pRet); 31 31 [id(11), helpstring("method call_get_info")] HRESULT call_get_info([in] int call_index, [out] Pjsua_Call_Info *pInfo, [out,retval] Pj_Status *pRet); 32 [id(12), helpstring("method call_make_call")] HRESULT call_make_call([in] int acc_i ndex, [in,string] Pj_String dst_uri, [out] int *call_index, [out,retval] Pj_Status *pRet);32 [id(12), helpstring("method call_make_call")] HRESULT call_make_call([in] int acc_id, [in,string] Pj_String dst_uri, [out] int *call_index, [out,retval] Pj_Status *pRet); 33 33 [id(13), helpstring("method call_answer")] HRESULT call_answer([in] int call_index, [in] int status_code, [out,retval] Pj_Status *pRet); 34 34 [id(14), helpstring("method call_hangup")] HRESULT call_hangup([in] int call_index, [out,retval] Pj_Status *pRet); … … 41 41 [id(21), helpstring("method call_hangup_all")] HRESULT call_hangup_all(); 42 42 [id(22), helpstring("method acc_get_count")] HRESULT acc_get_count([out,retval] int *pCount); 43 [id(23), helpstring("method acc_get_info")] HRESULT acc_get_info([in] int acc_i ndex, [out] Pjsua_Acc_Info *pInfo, [out,retval] Pj_Status *pRet);43 [id(23), helpstring("method acc_get_info")] HRESULT acc_get_info([in] int acc_id, [out] Pjsua_Acc_Info *pInfo, [out,retval] Pj_Status *pRet); 44 44 [id(24), helpstring("method acc_add")] HRESULT acc_add([in] Pjsua_Acc_Config *pConfig, [out] int *pAcc_Index, [out,retval] Pj_Status *pRet); 45 [id(25), helpstring("method acc_set_online_status")] HRESULT acc_set_online_status([in] int acc_i ndex, [in] int is_online, [out,retval] Pj_Status *pRet);46 [id(26), helpstring("method acc_set_registration")] HRESULT acc_set_registration([in] int acc_i ndex, [in] int reg_active, [out,retval] Pj_Status *pRet);45 [id(25), helpstring("method acc_set_online_status")] HRESULT acc_set_online_status([in] int acc_id, [in] int is_online, [out,retval] Pj_Status *pRet); 46 [id(26), helpstring("method acc_set_registration")] HRESULT acc_set_registration([in] int acc_id, [in] int reg_active, [out,retval] Pj_Status *pRet); 47 47 [id(27), helpstring("method buddy_get_count")] HRESULT buddy_get_count([out,retval] int *pCount); 48 48 [id(28), helpstring("method buddy_get_info")] HRESULT buddy_get_info([in] int buddy_index, [out] Pjsua_Buddy_Info *pInfo, [out,retval] Pj_Status *pRet); 49 49 [id(29), helpstring("method buddy_add")] HRESULT buddy_add([in,string] Pj_String uri, [out] int *pBuddy_Index, [out,retval] Pj_Status *pRet); 50 50 [id(30), helpstring("method buddy_subscribe_pres")] HRESULT buddy_subscribe_pres([in] int buddy_index, [in] int subscribe, [out,retval] Pj_Status *pRet); 51 [id(31), helpstring("method im_send_text")] HRESULT im_send_text([in] int acc_i ndex, [in,string] Pj_String dst_uri, [in,string] Pj_String text, [out,retval] Pj_Status *pRet);52 [id(32), helpstring("method im_typing")] HRESULT im_typing([in] int acc_i ndex, [in,string] Pj_URI dst_uri, [in] int is_typing, [out,retval] Pj_Status *pRet);51 [id(31), helpstring("method im_send_text")] HRESULT im_send_text([in] int acc_id, [in,string] Pj_String dst_uri, [in,string] Pj_String text, [out,retval] Pj_Status *pRet); 52 [id(32), helpstring("method im_typing")] HRESULT im_typing([in] int acc_id, [in,string] Pj_URI dst_uri, [in] int is_typing, [out,retval] Pj_Status *pRet); 53 53 [id(33), helpstring("method conf_connect")] HRESULT conf_connect([in] int src_port, [in] int sink_port, [out,retval] Pj_Status *pRet); 54 54 [id(34), helpstring("method conf_disconnect")] HRESULT conf_disconnect([in] int src_port, [in] int sink_port, [out,retval] Pj_Status *pRet); … … 67 67 [id(47), helpstring("method call_get_textstat")] HRESULT call_get_textstat([in] int call_index, [out,retval] BSTR *textstat); 68 68 [id(48), helpstring("method app_handle_events")] HRESULT app_handle_events([in] int msec_timeout, [out,retval] int *pEvCount); 69 [id(49), helpstring("method app_parse_uri")] HRESULT app_parse_uri([in] BSTR uriString, [out] Pjsip_Sip_Uri *pSipUri, [out,retval] Pj_Status *pStatus); 70 [id(50), helpstring("method app_print_uri")] HRESULT app_print_uri([in] Pjsip_Sip_Uri *pSipURI, [in] Pjsip_Uri_Context context, [out,retval] BSTR *uriText); 71 [id(51), helpstring("method app_compare_uri_string")] HRESULT app_compare_uri_string([in] Pjsip_Uri_Context context, [in] BSTR uri1, [in] BSTR uri2, [out,retval] Pj_Status *pStatus); 72 [id(52), helpstring("method buddy_del")] HRESULT buddy_del([in] int buddy_index, [out,retval] Pj_Status *pRet); 73 [id(53), helpstring("method acc_del")] HRESULT acc_del([in] int acc_id, [out,retval] Pj_Status *pRet); 74 [id(54), helpstring("method acc_find_for_outgoing")] HRESULT acc_find_for_outgoing([in] BSTR url, [out,retval] int *acc_id); 75 [id(55), helpstring("method acc_enum_id")] HRESULT acc_enum_id([out,retval] SAFEARRAY(int) *accIdArray); 76 [id(56), helpstring("method conf_enum_ports")] HRESULT conf_enum_ports([out,retval] SAFEARRAY(int) *pPortsArray); 77 [id(57), helpstring("method conf_get_port_info")] HRESULT conf_get_port_info([in] int port_id, [out] Pjsua_Conf_Port_Info *pInfo, [out,retval] Pj_Status *pRet); 69 78 }; 70 79 … … 85 94 struct Pjsua_Buddy_Info; 86 95 struct Pjsua_Acc_Info; 96 struct Pjsua_Conf_Port_Info; 87 97 88 98 [ … … 95 105 methods: 96 106 [id(1), helpstring("method OnCallState")] void OnCallState([in] int call_index, [in] Pjsua_Call_Info *pInfo); 97 [id(2), helpstring("method OnRegState")] void OnRegState([in] int acc_i ndex);107 [id(2), helpstring("method OnRegState")] void OnRegState([in] int acc_id); 98 108 [id(3), helpstring("method OnBuddyState")] void OnBuddyState([in] int buddy_index); 99 109 [id(4), helpstring("method OnIncomingPager")] void OnIncomingPager([in] int call_index, [in] BSTR fromUri, [in] BSTR toURI, [in] BSTR pagerText); 100 110 [id(5), helpstring("method OnTypingIndication")] void OnTypingIndication([in] int call_index, [in] BSTR fromUri, [in] BSTR toURI, [in] int isTyping); 111 [id(6), helpstring("method OnIncomingCall")] void OnIncomingCall([in] int call_index); 101 112 }; 102 113 -
pjproject/trunk/pjsip-apps/src/activex-pjsua/activex-pjsuaCP.h
r487 r492 3 3 4 4 //#import "C:\project\pjproject\pjsip-apps\src\activex-pjsua\activex-pjsua.tlb" raw_interfaces_only, raw_native_types, no_namespace, named_guids //"Import typelib" 5 5 6 template <class T> 6 7 class CProxy_IPjsuaEvents : public IConnectionPointImpl<T, &DIID__IPjsuaEvents, CComDynamicUnkArray> … … 148 149 149 150 } 151 VOID Fire_OnIncomingCall(INT call_index) 152 { 153 T* pT = static_cast<T*>(this); 154 int nConnectionIndex; 155 CComVariant* pvars = new CComVariant[1]; 156 int nConnections = m_vec.GetSize(); 157 158 for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++) 159 { 160 pT->Lock(); 161 CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex); 162 pT->Unlock(); 163 IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p); 164 if (pDispatch != NULL) 165 { 166 pvars[0] = call_index; 167 DISPPARAMS disp = { pvars, NULL, 1, 0 }; 168 pDispatch->Invoke(0x6, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); 169 } 170 } 171 delete[] pvars; 172 173 } 150 174 }; 151 175 #endif -
pjproject/trunk/pjsip-apps/src/activex-pjsua/app.cpp
r487 r492 14 14 { 0x9ce3052a, 0x7a32, 0x4229, { 0xb3, 0x1c, 0x5e, 0x2, 0xe0, 0x66, 0x7a, 0x77 } }; 15 15 16 // {7F6CFF0F-C5B3-41e8-B278-61CD584C1F34} 17 static const GUID IID_Pjsip_Sip_Uri = 18 { 0x7f6cff0f, 0xc5b3, 0x41e8, { 0xb2, 0x78, 0x61, 0xcd, 0x58, 0x4c, 0x1f, 0x34 } }; 19 16 20 // {3B12B04F-6E48-46a7-B9E0-6C4BF1594A96} 17 21 static const GUID IID_Pjsua_Acc_Config = … … 33 37 static const GUID IID_Pjsua_Acc_Info = 34 38 { 0x8d345956, 0x10b7, 0x4450, { 0x8a, 0x6, 0xa8, 0xd, 0x2f, 0x31, 0x9e, 0xfd } }; 39 40 // {0D05907A-3E1F-4c92-9FD0-26CB6E1CC56A} 41 static const GUID IID_Pjsua_Conf_Port_Info = 42 { 0xd05907a, 0x3e1f, 0x4c92, { 0x9f, 0xd0, 0x26, 0xcb, 0x6e, 0x1c, 0xc5, 0x6a } }; 43 35 44 36 45 #define SA_SIZE(lbound,ubound) (ubound-lbound) … … 118 127 *count = 0; 119 128 for (i=0; i<sa->cbElements; ++i) { 120 BSTR str ;129 BSTR str = NULL; 121 130 long rg = lbound + i; 122 131 hr = SafeArrayGetElement(sa, &rg, &str); … … 175 184 Pjsip_Cred_Info cred_info; 176 185 long rg = lbound + i; 186 pj_memset(&cred_info, 0, sizeof(cred_info)); 177 187 hr = SafeArrayGetElement(c1->cred_info, &rg, &cred_info); 178 188 if (FAILED(hr)) … … 245 255 c2->sip_port = c1->sip_port; 246 256 c2->start_rtp_port = c1->rtp_port; 257 c2->msg_logging = c1->msg_logging; 247 258 c2->max_calls = c1->max_calls; 248 259 c2->conf_ports = c1->conf_ports; … … 281 292 Pjsua_Acc_Config acc_config; 282 293 long rg = lbound + i; 294 pj_memset(&acc_config, 0, sizeof(acc_config)); 283 295 hr = SafeArrayGetElement(c1->acc_config, &rg, &acc_config); 284 296 if (FAILED(hr)) … … 312 324 c2->sip_port = c1->sip_port; 313 325 c2->rtp_port = c1->start_rtp_port; 326 c2->msg_logging = c1->msg_logging; 314 327 c2->max_calls = c1->max_calls; 315 328 c2->conf_ports = c1->conf_ports; … … 387 400 c2->connect_duration = c1->connect_duration.sec; 388 401 c2->total_duration = c1->total_duration.sec; 389 c2-> cause = c1->cause;390 Cp(c2-> cause_text, &c1->cause_text);402 c2->last_status = c1->last_status; 403 Cp(c2->last_status_text, &c1->last_status_text); 391 404 c2->has_media = c1->has_media; 392 405 c2->conf_slot = c1->conf_slot; … … 398 411 399 412 info2->index = info1->index; 400 Cp(info2->acc_ id, &info1->acc_id);413 Cp(info2->acc_uri, &info1->acc_id); 401 414 info2->has_registration = info1->has_registration; 402 415 info2->expires = info1->expires; … … 420 433 Cp(info2->status_text, &info1->status_text); 421 434 info2->monitor = info1->monitor; 422 info2->acc_index = info1->acc_index;423 435 } 424 436 … … 464 476 Pjsua_Call_Info *Call_Info = new Pjsua_Call_Info; 465 477 466 pjsua_ get_call_info(call_index, &call_info);478 pjsua_call_get_info(call_index, &call_info); 467 479 callinfo2CallInfo(&call_info, Call_Info); 468 480 … … 470 482 } 471 483 472 static void on_reg_state(int acc_index) 473 { 474 CApp_Instance->Fire_OnRegState(acc_index); 484 static void on_incoming_call(int acc_id, int call_index, 485 pjsip_rx_data *rdata) 486 { 487 CApp_Instance->Fire_OnIncomingCall(call_index); 488 } 489 490 static void on_reg_state(int acc_id) 491 { 492 CApp_Instance->Fire_OnRegState(acc_id); 475 493 } 476 494 … … 513 531 pj_memset(&cb, 0, sizeof(cb)); 514 532 cb.on_call_state = &on_call_state; 533 cb.on_incoming_call = &on_incoming_call; 515 534 cb.on_reg_state = &on_reg_state; 516 535 cb.on_buddy_state = &on_buddy_state; … … 540 559 STDMETHODIMP CApp::call_get_max_count(int *retCount) 541 560 { 542 *retCount = pjsua_ get_max_calls();561 *retCount = pjsua_call_get_max_count(); 543 562 return S_OK; 544 563 } … … 546 565 STDMETHODIMP CApp::call_get_count(int *retCount) 547 566 { 548 *retCount = pjsua_ get_call_count();567 *retCount = pjsua_call_get_count(); 549 568 return S_OK; 550 569 } … … 565 584 { 566 585 pjsua_call_info info; 567 *pRet = pjsua_ get_call_info(call_index, &info);586 *pRet = pjsua_call_get_info(call_index, &info); 568 587 callinfo2CallInfo(&info, pInfo); 569 588 return S_OK; 570 589 } 571 590 572 STDMETHODIMP CApp::call_make_call(int acc_i ndex, Pj_String dst_uri, int *call_index, Pj_Status *pRet)591 STDMETHODIMP CApp::call_make_call(int acc_id, Pj_String dst_uri, int *call_index, Pj_Status *pRet) 573 592 { 574 593 Temp_Pool tp; 575 594 pj_str_t tmp = Pj_str(tp.get_pool(), dst_uri); 576 595 577 *pRet = pjsua_ make_call(acc_index, &tmp, call_index);596 *pRet = pjsua_call_make_call(acc_id, &tmp, call_index); 578 597 return S_OK; 579 598 } … … 581 600 STDMETHODIMP CApp::call_answer(int call_index, int status_code, Pj_Status *pRet) 582 601 { 583 pjsua_call_answer(call_index, status_code); 584 *pRet = PJ_SUCCESS; 602 *pRet = pjsua_call_answer(call_index, status_code); 585 603 return S_OK; 586 604 } … … 602 620 STDMETHODIMP CApp::call_release_hold(int call_index, Pj_Status *pRet) 603 621 { 604 pjsua_call_reinvite(call_index); 605 *pRet = PJ_SUCCESS; 622 *pRet = pjsua_call_reinvite(call_index); 606 623 return S_OK; 607 624 } … … 611 628 Temp_Pool tp; 612 629 pj_str_t tmp = Pj_str(tp.get_pool(), dst_uri); 613 pjsua_call_xfer(call_index, &tmp); 614 *pRet = PJ_SUCCESS; 630 *pRet = pjsua_call_xfer(call_index, &tmp); 615 631 return S_OK; 616 632 } … … 628 644 Temp_Pool tp; 629 645 pj_str_t tmp = Pj_str(tp.get_pool(), text); 630 pjsua_call_send_im(call_index, &tmp); 631 *pRet = PJ_SUCCESS; 646 *pRet = pjsua_call_send_im(call_index, &tmp); 632 647 return S_OK; 633 648 } … … 635 650 STDMETHODIMP CApp::call_typing(int call_index, int is_typing, Pj_Status *pRet) 636 651 { 637 pjsua_call_typing(call_index, is_typing); 638 *pRet = PJ_SUCCESS; 652 *pRet = pjsua_call_send_typing_ind(call_index, is_typing); 639 653 return S_OK; 640 654 } … … 649 663 { 650 664 char buf[1024]; 651 pjsua_ dump_call(call_index, 1, buf, sizeof(buf), "");665 pjsua_call_dump(call_index, 1, buf, sizeof(buf), ""); 652 666 653 667 OLECHAR wbuf[1024]; … … 664 678 } 665 679 666 STDMETHODIMP CApp::acc_get_info(int acc_i ndex, Pjsua_Acc_Info *pInfo, Pj_Status *pRet)680 STDMETHODIMP CApp::acc_get_info(int acc_id, Pjsua_Acc_Info *pInfo, Pj_Status *pRet) 667 681 { 668 682 pjsua_acc_info info; 669 *pRet = pjsua_acc_get_info(acc_i ndex, &info);683 *pRet = pjsua_acc_get_info(acc_id, &info); 670 684 accinfo2AccInfo(&info, pInfo); 671 685 return S_OK; … … 681 695 } 682 696 683 STDMETHODIMP CApp::acc_set_online_status(int acc_i ndex, int is_online, Pj_Status *pRet)684 { 685 *pRet = pjsua_acc_set_online_status(acc_i ndex, is_online);686 return S_OK; 687 } 688 689 STDMETHODIMP CApp::acc_set_registration(int acc_i ndex, int reg_active, Pj_Status *pRet)690 { 691 *pRet = pjsua_acc_set_registration(acc_i ndex, reg_active);697 STDMETHODIMP CApp::acc_set_online_status(int acc_id, int is_online, Pj_Status *pRet) 698 { 699 *pRet = pjsua_acc_set_online_status(acc_id, is_online); 700 return S_OK; 701 } 702 703 STDMETHODIMP CApp::acc_set_registration(int acc_id, int reg_active, Pj_Status *pRet) 704 { 705 *pRet = pjsua_acc_set_registration(acc_id, reg_active); 692 706 return S_OK; 693 707 } … … 718 732 { 719 733 *pRet = pjsua_buddy_subscribe_pres(buddy_index, subscribe); 720 pjsua_pres_refresh(); 721 return S_OK; 722 } 723 724 STDMETHODIMP CApp::im_send_text(int acc_index, Pj_String dst_uri, Pj_String text, Pj_Status *pRet) 734 return S_OK; 735 } 736 737 STDMETHODIMP CApp::im_send_text(int acc_id, Pj_String dst_uri, Pj_String text, Pj_Status *pRet) 725 738 { 726 739 Temp_Pool tp; 727 740 pj_str_t tmp_uri = Pj_str(tp.get_pool(), dst_uri); 728 741 pj_str_t tmp_text = Pj_str(tp.get_pool(), text); 729 *pRet = pjsua_im_send(acc_i ndex, &tmp_uri, &tmp_text);730 return S_OK; 731 } 732 733 STDMETHODIMP CApp::im_typing(int acc_i ndex, Pj_URI dst_uri, int is_typing, Pj_Status *pRet)742 *pRet = pjsua_im_send(acc_id, &tmp_uri, &tmp_text); 743 return S_OK; 744 } 745 746 STDMETHODIMP CApp::im_typing(int acc_id, Pj_URI dst_uri, int is_typing, Pj_Status *pRet) 734 747 { 735 748 Temp_Pool tp; 736 749 pj_str_t tmp_uri = Pj_str(tp.get_pool(), dst_uri); 737 *pRet = pjsua_im_typing(acc_i ndex, &tmp_uri, is_typing);750 *pRet = pjsua_im_typing(acc_id, &tmp_uri, is_typing); 738 751 return S_OK; 739 752 } … … 803 816 pj_str_t tmp = Pj_str(tp.get_pool(), filename); 804 817 pjsua_default_config(&config); 805 *pRet = pjsua_load_settings(tmp.ptr, &config );818 *pRet = pjsua_load_settings(tmp.ptr, &config, NULL); 806 819 if (*pRet == PJ_SUCCESS) 807 820 *pRet = config2Config(&config, pConfig); … … 826 839 STDMETHODIMP CApp::app_get_current_config(Pjsua_Config *pConfig) 827 840 { 828 pjsua_config *config; 829 config = (pjsua_config*) pjsua_get_config(); 830 return config2Config(config, pConfig); 841 Temp_Pool tp; 842 pjsua_config config; 843 844 pjsua_get_config(tp.get_pool(), &config); 845 return config2Config(&config, pConfig); 831 846 } 832 847 … … 857 872 return S_OK; 858 873 } 874 875 STDMETHODIMP CApp::app_parse_uri(BSTR uriString, Pjsip_Sip_Uri *pSipUri, Pj_Status *pStatus) 876 { 877 Temp_Pool tp; 878 pj_str_t tmp = Pj_str(tp.get_pool(), uriString); 879 pjsip_name_addr *addr; 880 char buf[1024]; 881 pj_str_t s; 882 883 addr = (pjsip_name_addr*) 884 pjsip_parse_uri(tp.get_pool(), tmp.ptr, tmp.slen, PJSIP_PARSE_URI_AS_NAMEADDR); 885 if (addr == NULL) { 886 *pStatus = PJSIP_EINVALIDURI; 887 return S_OK; 888 } 889 890 if (!PJSIP_URI_SCHEME_IS_SIP(addr) && !PJSIP_URI_SCHEME_IS_SIPS(addr)) { 891 *pStatus = PJSIP_EINVALIDSCHEME; 892 return S_OK; 893 } 894 895 pjsip_sip_uri *sip = (pjsip_sip_uri*)addr->uri; 896 897 Cp2(&pSipUri->display, &addr->display); 898 Cp2(&pSipUri->user, &sip->user); 899 Cp2(&pSipUri->passwd, &sip->passwd); 900 Cp2(&pSipUri->host, &sip->host); 901 pSipUri->port = sip->port; 902 Cp2(&pSipUri->param_user, &sip->user_param); 903 Cp2(&pSipUri->param_method, &sip->method_param); 904 Cp2(&pSipUri->param_transport, &sip->transport_param); 905 pSipUri->param_ttl = sip->ttl_param; 906 pSipUri->param_lr = sip->lr_param; 907 Cp2(&pSipUri->param_maddr, &sip->maddr_param); 908 909 s.ptr = buf; 910 s.slen = pjsip_param_print_on(&sip->other_param, buf, sizeof(buf), 911 &pjsip_PARAM_CHAR_SPEC, &pjsip_PARAM_CHAR_SPEC, ';'); 912 Cp2(&pSipUri->param_other, &s); 913 914 s.slen = pjsip_param_print_on(&sip->header_param, buf, sizeof(buf), 915 &pjsip_HDR_CHAR_SPEC, &pjsip_HDR_CHAR_SPEC, '?'); 916 Cp2(&pSipUri->param_header, &s); 917 918 *pStatus = PJ_SUCCESS; 919 return S_OK; 920 } 921 922 STDMETHODIMP CApp::app_print_uri(Pjsip_Sip_Uri *pSipURI, Pjsip_Uri_Context context, BSTR *uriText) 923 { 924 Temp_Pool tp; 925 pjsip_name_addr *addr; 926 pj_str_t tmp; 927 char buf[1024]; 928 pjsip_sip_uri *sip; 929 930 addr = pjsip_name_addr_create(tp.get_pool()); 931 sip = pjsip_sip_uri_create(tp.get_pool(), PJ_FALSE); 932 addr->uri = (pjsip_uri*)sip; 933 934 addr->display = Pj_str(tp.get_pool(), pSipURI->display); 935 sip->user = Pj_str(tp.get_pool(), pSipURI->user); 936 sip->passwd = Pj_str(tp.get_pool(), pSipURI->passwd); 937 sip->host = Pj_str(tp.get_pool(), pSipURI->host); 938 sip->port = pSipURI->port; 939 sip->user_param = Pj_str(tp.get_pool(), pSipURI->param_user); 940 sip->method_param = Pj_str(tp.get_pool(), pSipURI->param_method); 941 sip->transport_param = Pj_str(tp.get_pool(), pSipURI->param_transport); 942 sip->ttl_param = pSipURI->param_ttl; 943 sip->lr_param = pSipURI->param_lr; 944 sip->maddr_param = Pj_str(tp.get_pool(), pSipURI->param_maddr); 945 946 /* Unfortunately can't transport params yet (no parsing function) */ 947 948 tmp.ptr = buf; 949 tmp.slen = pjsip_uri_print((pjsip_uri_context_e)context, addr, buf, sizeof(buf)); 950 951 Cp2(uriText, &tmp); 952 return S_OK; 953 } 954 955 STDMETHODIMP CApp::app_compare_uri_string(Pjsip_Uri_Context context, BSTR uri1, BSTR uri2, Pj_Status *pStatus) 956 { 957 Temp_Pool tp; 958 959 pj_str_t tmp_uri1 = Pj_str(tp.get_pool(), uri1); 960 pj_str_t tmp_uri2 = Pj_str(tp.get_pool(), uri2); 961 962 pjsip_uri *u1, *u2; 963 964 u1 = pjsip_parse_uri(tp.get_pool(), tmp_uri1.ptr, tmp_uri1.slen, PJSIP_PARSE_URI_AS_NAMEADDR); 965 if (u1 == NULL) { 966 *pStatus = PJSIP_EINVALIDURI; 967 return S_OK; 968 } 969 970 u2 = pjsip_parse_uri(tp.get_pool(), tmp_uri2.ptr, tmp_uri2.slen, PJSIP_PARSE_URI_AS_NAMEADDR); 971 if (u2 == NULL) { 972 *pStatus = PJSIP_EINVALIDURI; 973 return S_OK; 974 } 975 976 *pStatus = pjsip_uri_cmp((pjsip_uri_context_e)context, u1, u2); 977 return S_OK; 978 } 979 980 STDMETHODIMP CApp::buddy_del(int buddy_index, Pj_Status *pRet) 981 { 982 *pRet = pjsua_buddy_del(buddy_index); 983 return S_OK; 984 } 985 986 STDMETHODIMP CApp::acc_del(int acc_id, Pj_Status *pRet) 987 { 988 *pRet = pjsua_acc_del(acc_id); 989 return S_OK; 990 } 991 992 STDMETHODIMP CApp::acc_find_for_outgoing(BSTR url, int *acc_id) 993 { 994 Temp_Pool tp; 995 996 pj_str_t tmp_uri = Pj_str(tp.get_pool(), url); 997 998 *acc_id = pjsua_acc_find_for_outgoing(&tmp_uri); 999 1000 return S_OK; 1001 } 1002 1003 STDMETHODIMP CApp::acc_enum_id(SAFEARRAY **accIdArray) 1004 { 1005 int id[32]; 1006 unsigned count = PJ_ARRAY_SIZE(id); 1007 unsigned i; 1008 1009 pjsua_acc_enum_id(id, &count); 1010 1011 *accIdArray = SafeArrayCreateVector(VT_INT, 0, count); 1012 1013 for (i=0; i<count; ++i) { 1014 long rg = i; 1015 SafeArrayPutElement(*accIdArray, &rg, &id[i]); 1016 } 1017 1018 return S_OK; 1019 } 1020 1021 STDMETHODIMP CApp::conf_enum_ports(SAFEARRAY **pPortsArray) 1022 { 1023 int id[128]; 1024 unsigned count = PJ_ARRAY_SIZE(id); 1025 unsigned i; 1026 1027 pjsua_conf_enum_port_ids(id, &count); 1028 1029 *pPortsArray = SafeArrayCreateVector(VT_INT, 0, count); 1030 1031 for (i=0; i<count; ++i) { 1032 long rg = i; 1033 SafeArrayPutElement(*pPortsArray, &rg, &id[i]); 1034 } 1035 1036 return S_OK; 1037 } 1038 1039 STDMETHODIMP CApp::conf_get_port_info(int port_id, Pjsua_Conf_Port_Info *pInfo, Pj_Status *pRet) 1040 { 1041 unsigned i; 1042 pjsua_conf_port_info info; 1043 1044 *pRet = pjsua_conf_get_port_info(port_id, &info); 1045 if (*pRet != PJ_SUCCESS) 1046 return S_OK; 1047 1048 pInfo->slot_id = info.slot_id; 1049 Cp2(&pInfo->name, &info.name); 1050 pInfo->clock_rate = info.clock_rate; 1051 pInfo->channel_count = info.channel_count; 1052 pInfo->samples_per_frame = info.samples_per_frame; 1053 pInfo->bits_per_sample = info.bits_per_sample; 1054 1055 1056 pInfo->listeners = SafeArrayCreateVector(VT_INT, 0, info.listener_cnt); 1057 1058 for (i=0; i<info.listener_cnt; ++i) { 1059 long rg = i; 1060 SafeArrayPutElement(pInfo->listeners, &rg, &info.listeners[i]); 1061 } 1062 1063 return S_OK; 1064 } 1065 -
pjproject/trunk/pjsip-apps/src/activex-pjsua/app.h
r487 r492 5 5 6 6 #include "resource.h" // main symbols 7 #include " ..\activex-pjsua\activex-pjsuaCP.h"7 #include "activex-pjsuaCP.h" 8 8 9 9 … … 38 38 // IApp 39 39 public: 40 STDMETHOD(app_destroy)(/*[out,retval]*/ Pj_Status *retStatus); 41 STDMETHOD(app_start)(/*[out,retval]*/ Pj_Status *retStatus); 42 STDMETHOD(app_init)(/*[in]*/ Pjsua_Config *pConfig, /*[out,retval]*/ Pj_Status *pStatus); 43 STDMETHOD(app_test_config)(/*[in]*/ Pjsua_Config *pConfig, /*[out,retval,string]*/ BSTR *retmsg); 44 STDMETHOD(app_default_config)(/*[in,out]*/ Pjsua_Config *pConfig); 45 STDMETHOD(app_create)(/*[out,retval]*/ Pj_Status *ret); 46 STDMETHOD(app_compare_uri_string)(/*[in]*/ Pjsip_Uri_Context context, /*[in]*/ BSTR uri1, /*[in]*/ BSTR uri2, /*[out,retval]*/ Pj_Status *pStatus); 47 STDMETHOD(app_print_uri)(/*[in]*/ Pjsip_Sip_Uri *pSipURI, Pjsip_Uri_Context context, /*[out,retval]*/ BSTR *uriText); 48 STDMETHOD(app_parse_uri)(/*[in]*/ BSTR uriString, /*[out]*/ Pjsip_Sip_Uri *pSipUri, /*[out,retval]*/ Pj_Status *pStatus); 40 49 STDMETHOD(app_handle_events)(/*[in]*/ int msec_timeout, /*[out,retval]*/ int *pEvCount); 41 50 STDMETHOD(app_verify_sip_url)(/*[in,string]*/ Pj_String uri, /*[out,retval]*/ Pj_Status *pRet); … … 53 62 STDMETHOD(conf_disconnect)(/*[in]*/ int src_port, /*[in]*/ int sink_port, /*[out,retval]*/ Pj_Status *pRet); 54 63 STDMETHOD(conf_connect)(/*[in]*/ int src_port, /*[in]*/ int sink_port, /*[out,retval]*/ Pj_Status *pRet); 64 STDMETHOD(conf_enum_ports)(SAFEARRAY **pPortsArray); 65 STDMETHOD(conf_get_port_info)(int port_id, Pjsua_Conf_Port_Info *pInfo, Pj_Status *pRet); 55 66 STDMETHOD(im_typing)(/*[in]*/ int acc_index, /*[in,string]*/ Pj_URI dst_uri, /*[in]*/ int is_typing, /*[out,retval]*/ Pj_Status *pRet); 56 67 STDMETHOD(im_send_text)(/*[in]*/ int acc_index, /*[in,string]*/ Pj_String dst_uri, /*[in,string]*/ Pj_String text, /*[out,retval]*/ Pj_Status *pRet); … … 59 70 STDMETHOD(buddy_get_info)(/*[in]*/ int buddy_index, /*[out]*/ Pjsua_Buddy_Info *pInfo, /*[out,retval]*/ Pj_Status *pRet); 60 71 STDMETHOD(buddy_get_count)(/*[out,retval]*/ int *pCount); 72 STDMETHOD(buddy_del)(/*[in]*/ int buddy_index, /*[out,retval]*/ Pj_Status *pRet); 61 73 STDMETHOD(acc_set_registration)(/*[in]*/ int acc_index, /*[in]*/ int reg_active, /*[out,retval]*/ Pj_Status *pRet); 62 74 STDMETHOD(acc_set_online_status)(/*[in]*/ int acc_index, /*[in]*/ int is_online, /*[out,retval]*/ Pj_Status *pRet); 63 75 STDMETHOD(acc_add)(/*[in]*/ Pjsua_Acc_Config *pConfig, /*[out]*/ int *pAcc_Index, /*[out,retval]*/ Pj_Status *pRet); 76 STDMETHOD(acc_del)(/*[out,retval]*/ int acc_index, Pj_Status *pRet); 64 77 STDMETHOD(acc_get_info)(/*[in]*/ int acc_index, /*[out]*/ Pjsua_Acc_Info *pInfo, /*[out,retval]*/ Pj_Status *pRet); 65 78 STDMETHOD(acc_get_count)(/*[out,retval]*/ int *pCount); 79 STDMETHOD(acc_enum_id)(SAFEARRAY **accIdArray); 80 STDMETHOD(acc_find_for_outgoing)(/*[in]*/ BSTR url, /*[out,retval]*/ int *acc_index); 66 81 STDMETHOD(call_hangup_all)(); 67 82 STDMETHOD(call_typing)(/*[in]*/ int call_index, /*[in]*/ int is_typing, /*[out,retval]*/ Pj_Status *pRet); … … 79 94 STDMETHOD(call_get_count)(/*[out,retval]*/ int *retCount); 80 95 STDMETHOD(call_get_max_count)(/*[out,retval]*/ int *retCount); 81 STDMETHOD(app_destroy)(/*[out,retval]*/ Pj_Status *retStatus);82 STDMETHOD(app_start)(/*[out,retval]*/ Pj_Status *retStatus);83 STDMETHOD(app_init)(/*[in]*/ Pjsua_Config *pConfig, /*[out,retval]*/ Pj_Status *pStatus);84 STDMETHOD(app_test_config)(/*[in]*/ Pjsua_Config *pConfig, /*[out,retval,string]*/ BSTR *retmsg);85 STDMETHOD(app_default_config)(/*[in,out]*/ Pjsua_Config *pConfig);86 STDMETHOD(app_create)(/*[out,retval]*/ Pj_Status *ret);87 96 STDMETHOD(call_get_textstat)(/* [in] */ int call_index, /* [retval][out] */ BSTR *textstat); 88 97 -
pjproject/trunk/pjsip-apps/src/activex-pjsua/pjsua-structs.idl
r487 r492 21 21 Pj_String data; 22 22 } Pjsip_Cred_Info; 23 24 25 [ 26 uuid(7F6CFF0F-C5B3-41e8-B278-61CD584C1F34), 27 version(1.0), 28 helpstring("PJSIP SIP URI"), 29 ] 30 typedef struct Pjsip_Sip_Uri 31 { 32 Pj_String display; 33 Pj_String user; 34 Pj_String passwd; 35 Pj_String host; 36 int port; 37 Pj_String param_user; 38 Pj_String param_method; 39 Pj_String param_transport; 40 int param_ttl; 41 int param_lr; 42 Pj_String param_maddr; 43 Pj_String param_other; 44 Pj_String param_header; 45 } Pjsip_Sip_Uri; 46 47 48 typedef enum Pjsip_Uri_Context 49 { 50 PJSIPX_URI_IN_REQ_URI, 51 PJSIPX_URI_IN_FROMTO_HDR, 52 PJSIPX_URI_IN_CONTACT_HDR, 53 PJSIPX_URI_IN_ROUTING_HDR, 54 PJSIPX_URI_IN_OTHER 55 } Pjsip_Uri_Context; 23 56 24 57 … … 45 78 typedef struct Pjsua_Config 46 79 { 47 unsigned int udp_port; 48 Pj_String sip_host; 49 unsigned int sip_port; 50 unsigned int rtp_port; 51 unsigned int max_calls; 52 unsigned int conf_ports; 53 unsigned int thread_cnt; 54 Pj_String stun_srv1; 55 unsigned int stun_port1; 56 Pj_String stun_srv2; 57 unsigned int stun_port2; 58 unsigned int snd_player_id; 59 unsigned int snd_capture_id; 60 unsigned int clock_rate; 61 Pj_Bool null_audio; 62 unsigned int quality; 63 unsigned int complexity; 64 SAFEARRAY(Pj_String) codec_arg; 65 unsigned int auto_answer; 66 unsigned int uas_refresh; 67 Pj_String outbound_proxy; 80 int udp_port; 81 Pj_String sip_host; 82 int sip_port; 83 int rtp_port; 84 int msg_logging; 85 int max_calls; 86 int conf_ports; 87 int thread_cnt; 88 Pj_String stun_srv1; 89 int stun_port1; 90 Pj_String stun_srv2; 91 int stun_port2; 92 int snd_player_id; 93 int snd_capture_id; 94 int clock_rate; 95 Pj_Bool null_audio; 96 int quality; 97 int complexity; 98 SAFEARRAY(Pj_String) codec_arg; 99 int auto_answer; 100 int uas_refresh; 101 Pj_String outbound_proxy; 68 102 SAFEARRAY(Pjsua_Acc_Config) acc_config; 69 unsigned intlog_level;70 unsigned intapp_log_level;71 unsigned longlog_decor;72 Pj_String 73 SAFEARRAY(Pj_String) 103 int log_level; 104 int app_log_level; 105 long log_decor; 106 Pj_String log_filename; 107 SAFEARRAY(Pj_String) buddy_uri; 74 108 } Pjsua_Config; 75 109 … … 94 128 typedef struct Pjsua_Call_Info 95 129 { 96 unsigned intindex;130 int index; 97 131 Pj_Bool active; 98 132 Pj_Bool is_uac; … … 101 135 Pjsua_Call_State state; 102 136 Pj_String state_text; 103 unsigned intconnect_duration;104 unsigned inttotal_duration;105 unsigned int cause;106 Pj_String cause_text;137 int connect_duration; 138 int total_duration; 139 int last_status; 140 Pj_String last_status_text; 107 141 Pj_Bool has_media; 108 unsigned intconf_slot;142 int conf_slot; 109 143 } Pjsua_Call_Info; 110 144 … … 125 159 typedef struct Pjsua_Buddy_Info 126 160 { 127 unsignedint index;161 int index; 128 162 Pj_Bool is_valid; 129 163 Pj_String name; 130 164 Pj_String display; 131 165 Pj_String host; 132 unsigned intport;166 int port; 133 167 Pj_URI uri; 134 168 Pjsua_Buddy_State status; 135 169 Pj_String status_text; 136 170 Pj_Bool monitor; 137 int acc_index;138 171 } Pjsua_Buddy_Info; 139 172 … … 146 179 typedef struct Pjsua_Acc_Info 147 180 { 148 unsigned intindex;149 Pj_URI acc_ id;181 int index; 182 Pj_URI acc_uri; 150 183 Pj_Bool has_registration; 151 184 int expires; 152 unsigned intstatus_code;185 int status_code; 153 186 Pj_String status_text; 154 187 Pj_Bool online_status; 155 188 } Pjsua_Acc_Info; 156 189 190 191 192 [ 193 uuid(0D05907A-3E1F-4c92-9FD0-26CB6E1CC56A), 194 version(1.0), 195 helpstring("PJSUA Conference Port Information"), 196 ] 197 typedef struct Pjsua_Conf_Port_Info 198 { 199 int slot_id; 200 Pj_String name; 201 int clock_rate; 202 int channel_count; 203 int samples_per_frame; 204 int bits_per_sample; 205 SAFEARRAY(int) listeners; 206 } Pjsua_Conf_Port_Info; 207 -
pjproject/trunk/pjsip-apps/src/pjsua/main.c
r487 r492 29 29 { 30 30 pjsua_config cfg; 31 pj_str_t uri_to_call = { NULL, 0 }; 31 32 32 33 /* Init default settings. */ … … 39 40 40 41 /* Parse command line arguments: */ 41 if (pjsua_parse_args(argc, argv, &cfg ) != PJ_SUCCESS)42 if (pjsua_parse_args(argc, argv, &cfg, &uri_to_call) != PJ_SUCCESS) 42 43 return 1; 43 44 … … 46 47 if (pjsua_init(&cfg, &console_callback) != PJ_SUCCESS) 47 48 return 1; 48 49 /* Register message logger to print incoming and outgoing50 * messages.51 */52 pjsip_endpt_register_module(pjsua_get_pjsip_endpt(),53 &pjsua_console_app_msg_logger);54 49 55 50 … … 66 61 67 62 /* Start UI console main loop: */ 68 pjsua_console_app_main( );63 pjsua_console_app_main(&uri_to_call); 69 64 70 65 -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r487 r492 69 69 70 70 71 typedef int pjsua_acc_id; 72 typedef int pjsua_buddy_id; 73 typedef int pjsua_player_id; 74 typedef int pjsua_recorder_id; 75 typedef int pjsua_conf_port_id; 76 77 71 78 /** 72 79 * Account configuration. … … 136 143 unsigned start_rtp_port; 137 144 145 /** 146 * Enable incoming and outgoing message logging (default: 1). 147 */ 148 pj_bool_t msg_logging; 149 138 150 /** Maximum calls to support (default: 4) */ 139 151 unsigned max_calls; … … 223 235 /** Outbound proxy (default: none) */ 224 236 pj_str_t outbound_proxy; 225 226 /** URI to call. */227 pj_str_t uri_to_call;228 237 229 238 /** Number of SIP accounts */ … … 273 282 274 283 /** 284 * Notify application on incoming call. 285 */ 286 void (*on_incoming_call)(pjsua_acc_id acc_id, int call_index, 287 pjsip_rx_data *rdata); 288 289 /** 275 290 * Notify application on call being transfered. 276 291 * Application can decide to accept/reject transfer request … … 288 303 * registration details. 289 304 */ 290 void (*on_reg_state)( int acc_index);305 void (*on_reg_state)(pjsua_acc_id acc_id); 291 306 292 307 /** … … 294 309 * Application may then query the buddy into to get the details. 295 310 */ 296 void (*on_buddy_state)( int buddy_index);311 void (*on_buddy_state)(pjsua_buddy_id buddy_id); 297 312 298 313 /** … … 330 345 pjsip_inv_state state; 331 346 pj_str_t state_text; 347 pjsip_status_code last_status; 348 pj_str_t last_status_text; 332 349 pj_time_val connect_duration; 333 350 pj_time_val total_duration; 334 pjsip_status_code cause;335 pj_str_t cause_text;336 351 pj_bool_t has_media; 337 unsignedconf_slot;352 pjsua_conf_port_id conf_slot; 338 353 }; 339 354 … … 356 371 struct pjsua_buddy_info 357 372 { 358 unsignedindex;373 pjsua_buddy_id index; 359 374 pj_bool_t is_valid; 360 375 pj_str_t name; … … 366 381 pj_str_t status_text; 367 382 pj_bool_t monitor; 368 int acc_index;369 383 }; 370 384 … … 377 391 struct pjsua_acc_info 378 392 { 379 unsignedindex;393 pjsua_acc_id index; 380 394 pj_str_t acc_id; 381 395 pj_bool_t has_registration; … … 390 404 391 405 392 typedef int pjsua_player_id; 393 typedef int pjsua_recorder_id; 394 406 /** 407 * Conference port info. 408 */ 409 struct pjsua_conf_port_info 410 { 411 pjsua_conf_port_id slot_id; 412 pj_str_t name; 413 unsigned clock_rate; 414 unsigned channel_count; 415 unsigned samples_per_frame; 416 unsigned bits_per_sample; 417 unsigned listener_cnt; 418 pjsua_conf_port_id listeners[256]; 419 }; 420 421 422 typedef struct pjsua_conf_port_info pjsua_conf_port_info; 395 423 396 424 … … 479 507 * Get maximum number of calls configured in pjsua. 480 508 */ 481 PJ_DECL(unsigned) pjsua_ get_max_calls(void);509 PJ_DECL(unsigned) pjsua_call_get_max_count(void); 482 510 483 511 /** 484 512 * Get current number of active calls. 485 513 */ 486 PJ_DECL(unsigned) pjsua_ get_call_count(void);514 PJ_DECL(unsigned) pjsua_call_get_count(void); 487 515 488 516 /** … … 502 530 * Get call info. 503 531 */ 504 PJ_DECL(pj_status_t) pjsua_ get_call_info(unsigned call_index,532 PJ_DECL(pj_status_t) pjsua_call_get_info(unsigned call_index, 505 533 pjsua_call_info *info); 506 534 … … 509 537 * Duplicate call info. 510 538 */ 511 PJ_DECL(void) pjsua_ dup_call_info(pj_pool_t *pool,539 PJ_DECL(void) pjsua_call_info_dup(pj_pool_t *pool, 512 540 pjsua_call_info *dst_info, 513 541 const pjsua_call_info *src_info); … … 517 545 * Make outgoing call. 518 546 */ 519 PJ_DECL(pj_status_t) pjsua_ make_call(unsigned acc_index,520 521 547 PJ_DECL(pj_status_t) pjsua_call_make_call(unsigned acc_id, 548 const pj_str_t *dst_uri, 549 int *p_call_index); 522 550 523 551 … … 525 553 * Answer call. 526 554 */ 527 PJ_DECL( void) pjsua_call_answer(int call_index, int code);555 PJ_DECL(pj_status_t) pjsua_call_answer(int call_index, int code); 528 556 529 557 /** … … 536 564 * Put call on-hold. 537 565 */ 538 PJ_DECL( void) pjsua_call_set_hold(int call_index);566 PJ_DECL(pj_status_t) pjsua_call_set_hold(int call_index); 539 567 540 568 … … 542 570 * Send re-INVITE (to release hold). 543 571 */ 544 PJ_DECL( void) pjsua_call_reinvite(int call_index);572 PJ_DECL(pj_status_t) pjsua_call_reinvite(int call_index); 545 573 546 574 … … 548 576 * Transfer call. 549 577 */ 550 PJ_DECL( void) pjsua_call_xfer(unsigned call_index, const pj_str_t *dest);578 PJ_DECL(pj_status_t) pjsua_call_xfer(unsigned call_index, const pj_str_t *dest); 551 579 552 580 /** … … 560 588 * Send instant messaging inside INVITE session. 561 589 */ 562 PJ_DECL( void) pjsua_call_send_im(int call_index, const pj_str_t *text);590 PJ_DECL(pj_status_t) pjsua_call_send_im(int call_index, const pj_str_t *text); 563 591 564 592 … … 566 594 * Send IM typing indication inside INVITE session. 567 595 */ 568 PJ_DECL(void) pjsua_call_typing(int call_index, pj_bool_t is_typing); 596 PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(int call_index, 597 pj_bool_t is_typing); 569 598 570 599 /** … … 577 606 * Dump call and media statistics to string. 578 607 */ 579 PJ_DECL(void) pjsua_ dump_call(int call_index, int with_media,608 PJ_DECL(void) pjsua_call_dump(int call_index, int with_media, 580 609 char *buffer, unsigned maxlen, 581 610 const char *indent); … … 595 624 * Get account info. 596 625 */ 597 PJ_DECL(pj_status_t) pjsua_acc_get_info( unsigned acc_index,626 PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id, 598 627 pjsua_acc_info *info); 628 629 630 /** 631 * Enum accounts id. 632 */ 633 PJ_DECL(pj_status_t) pjsua_acc_enum_id( pjsua_acc_id ids[], 634 unsigned *count ); 635 636 637 /** 638 * Enum accounts info. 639 */ 640 PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[], 641 unsigned *count ); 642 643 644 /** 645 * Find account for outgoing request. 646 */ 647 PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url); 648 649 /** 650 * Find account for incoming request. 651 */ 652 PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata); 599 653 600 654 /** … … 605 659 */ 606 660 PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *cfg, 607 int *acc_index); 661 pjsua_acc_id *acc_id); 662 663 /** 664 * Delete account. 665 */ 666 PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id); 608 667 609 668 610 669 /** 611 670 * Set account's presence status. 612 * Must call pjsua_pres_refresh() after this. 613 */ 614 PJ_DECL(pj_status_t) pjsua_acc_set_online_status(unsigned acc_index, 671 */ 672 PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id, 615 673 pj_bool_t is_online); 616 674 … … 620 678 * this will start unregistration process. 621 679 */ 622 PJ_DECL(pj_status_t) pjsua_acc_set_registration(unsigned acc_index, pj_bool_t renew); 680 PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id, 681 pj_bool_t renew); 623 682 624 683 … … 638 697 * Get buddy info. 639 698 */ 640 PJ_DECL(pj_status_t) pjsua_buddy_get_info( unsigned buddy_index,699 PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_index, 641 700 pjsua_buddy_info *info); 642 701 … … 645 704 */ 646 705 PJ_DECL(pj_status_t) pjsua_buddy_add(const pj_str_t *uri, 647 int *buddy_index); 706 pjsua_buddy_id *buddy_index); 707 708 709 /** 710 * Delete buddy. 711 */ 712 PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_index); 648 713 649 714 650 715 /** 651 716 * Enable/disable buddy's presence monitoring. 652 * Must call pjsua_pres_refresh() after this. 653 */ 654 PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(unsigned buddy_index, 717 */ 718 PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_index, 655 719 pj_bool_t monitor); 656 720 657 658 /**659 * Refresh both presence client and server subscriptions.660 */661 PJ_DECL(void) pjsua_pres_refresh(void);662 721 663 722 /** … … 681 740 * Send IM outside dialog. 682 741 */ 683 PJ_DECL(pj_status_t) pjsua_im_send(int acc_i ndex, const pj_str_t *dst_uri,742 PJ_DECL(pj_status_t) pjsua_im_send(int acc_id, const pj_str_t *dst_uri, 684 743 const pj_str_t *text); 685 744 … … 688 747 * Send typing indication outside dialog. 689 748 */ 690 PJ_DECL(pj_status_t) pjsua_im_typing(int acc_i ndex, const pj_str_t *dst_uri,749 PJ_DECL(pj_status_t) pjsua_im_typing(int acc_id, const pj_str_t *dst_uri, 691 750 pj_bool_t is_typing); 692 751 … … 706 765 * Enum all conference ports. 707 766 */ 708 PJ_DECL(pj_status_t) pjsua_conf_enum_ports(unsigned *count, 709 pjmedia_conf_port_info info[]); 767 PJ_DECL(pj_status_t) pjsua_conf_enum_port_ids(pjsua_conf_port_id id[], 768 unsigned *count); 769 770 771 /** 772 * Get information about the specified conference port 773 */ 774 PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id id, 775 pjsua_conf_port_info *info); 710 776 711 777 … … 713 779 * Connect conference port. 714 780 */ 715 PJ_DECL(pj_status_t) pjsua_conf_connect( unsigned src_port,716 unsigned dst_port);781 PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id src_port, 782 pjsua_conf_port_id dst_port); 717 783 718 784 … … 720 786 * Connect conference port connection. 721 787 */ 722 PJ_DECL(pj_status_t) pjsua_conf_disconnect( unsigned src_port,723 unsigned dst_port);788 PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id src_port, 789 pjsua_conf_port_id dst_port); 724 790 725 791 … … 734 800 * Get conference port associated with player. 735 801 */ 736 PJ_DECL( int) pjsua_player_get_conf_port(pjsua_player_id id);802 PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id); 737 803 738 804 … … 761 827 * Get conference port associated with recorder. 762 828 */ 763 PJ_DECL( int) pjsua_recorder_get_conf_port(pjsua_recorder_id id);829 PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id); 764 830 765 831 … … 798 864 */ 799 865 PJ_DECL(pj_status_t) pjsua_parse_args(int argc, char *argv[], 800 pjsua_config *cfg); 866 pjsua_config *cfg, 867 pj_str_t *uri_to_call); 801 868 802 869 /** … … 804 871 */ 805 872 PJ_DECL(pj_status_t) pjsua_load_settings(const char *filename, 806 pjsua_config *cfg); 873 pjsua_config *cfg, 874 pj_str_t *uri_to_call); 807 875 808 876 /** 809 877 * Get pjsua running config. 810 878 */ 811 PJ_DECL(const pjsua_config*) pjsua_get_config(void); 879 PJ_DECL(void) pjsua_get_config(pj_pool_t *pool, 880 pjsua_config *config); 812 881 813 882 -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua_console_app.h
r487 r492 21 21 22 22 23 void pjsua_console_app_main( void);23 void pjsua_console_app_main(const pj_str_t *uri_to_call); 24 24 25 25 extern pjsip_module pjsua_console_app_msg_logger; -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
r482 r492 128 128 * Get maximum number of calls configured in pjsua. 129 129 */ 130 PJ_DEF(unsigned) pjsua_ get_max_calls(void)130 PJ_DEF(unsigned) pjsua_call_get_max_count(void) 131 131 { 132 132 return pjsua.config.max_calls; … … 137 137 * Get current number of active calls. 138 138 */ 139 PJ_DEF(unsigned) pjsua_ get_call_count(void)139 PJ_DEF(unsigned) pjsua_call_get_count(void) 140 140 { 141 141 return pjsua.call_cnt; … … 167 167 * Get call info. 168 168 */ 169 PJ_DEF(pj_status_t) pjsua_ get_call_info( unsigned call_index,169 PJ_DEF(pj_status_t) pjsua_call_get_info( unsigned call_index, 170 170 pjsua_call_info *info) 171 171 { … … 213 213 } 214 214 215 info-> cause = call->inv->cause;216 info-> cause_text = *pjsip_get_status_text(info->cause);215 info->last_status = call->last_code; 216 info->last_status_text = *pjsip_get_status_text(info->last_status); 217 217 218 218 info->has_media = (call->session != NULL); … … 226 226 * Duplicate call info. 227 227 */ 228 PJ_DEF(void) pjsua_ dup_call_info( pj_pool_t *pool,228 PJ_DEF(void) pjsua_call_info_dup( pj_pool_t *pool, 229 229 pjsua_call_info *dst_info, 230 230 const pjsua_call_info *src_info) … … 246 246 * Make outgoing call. 247 247 */ 248 PJ_DEF(pj_status_t) pjsua_ make_call(unsigned acc_index,249 250 248 PJ_DEF(pj_status_t) pjsua_call_make_call(unsigned acc_index, 249 const pj_str_t *dest_uri, 250 int *p_call_index) 251 251 { 252 252 pjsip_dialog *dlg = NULL; … … 385 385 * Answer call. 386 386 */ 387 PJ_DEF( void) pjsua_call_answer(int call_index, int code)387 PJ_DEF(pj_status_t) pjsua_call_answer(int call_index, int code) 388 388 { 389 389 pjsip_tx_data *tdata; 390 390 pj_status_t status; 391 391 392 PJ_ASSERT_ ON_FAIL(call_index >= 0 &&392 PJ_ASSERT_RETURN( call_index >= 0 && 393 393 call_index < (int)pjsua.config.max_calls, 394 return);394 PJ_EINVAL); 395 395 396 396 if (pjsua.calls[call_index].inv == NULL) { 397 397 PJ_LOG(3,(THIS_FILE, "Call %d already disconnected")); 398 return ;398 return PJSIP_ESESSIONTERMINATED; 399 399 } 400 400 … … 409 409 status); 410 410 411 return status; 411 412 } 412 413 … … 613 614 } 614 615 616 /* Notify application */ 617 if (pjsua.cb.on_incoming_call) 618 pjsua.cb.on_incoming_call(acc_index, call_index, rdata); 619 620 615 621 /* This INVITE request has been handled. */ 616 622 return PJ_TRUE; … … 636 642 if (call->res_time.sec == 0) 637 643 pj_gettimeofday(&call->res_time); 644 call->last_code = e->body.tsx_state.tsx->status_code; 638 645 break; 639 646 case PJSIP_INV_STATE_CONFIRMED: … … 642 649 case PJSIP_INV_STATE_DISCONNECTED: 643 650 pj_gettimeofday(&call->dis_time); 651 if (e->body.tsx_state.tsx->status_code > call->last_code) { 652 call->last_code = e->body.tsx_state.tsx->status_code; 653 } 644 654 break; 645 655 default: 646 /* Nothing to do. Just to keep gcc from complaining about 647 * unused enums. 648 */ 656 call->last_code = e->body.tsx_state.tsx->status_code; 649 657 break; 650 658 } … … 683 691 break; 684 692 685 default:693 case PJSIP_INV_STATE_INCOMING: 686 694 /* Nothing to do. Just to keep gcc from complaining about 687 695 * unused enums. … … 854 862 /* Now make the outgoing call. */ 855 863 tmp = pj_str(uri); 856 status = pjsua_ make_call(existing_call->acc_index, &tmp, &new_call);864 status = pjsua_call_make_call(existing_call->acc_index, &tmp, &new_call); 857 865 if (status != PJ_SUCCESS) { 858 866 … … 1355 1363 * Put call on-Hold. 1356 1364 */ 1357 PJ_DEF( void) pjsua_call_set_hold(int call_index)1365 PJ_DEF(pj_status_t) pjsua_call_set_hold(int call_index) 1358 1366 { 1359 1367 pjmedia_sdp_session *sdp; … … 1366 1374 if (!call->inv) { 1367 1375 PJ_LOG(3,(THIS_FILE,"Call has been disconnected")); 1368 return ;1376 return PJSIP_ESESSIONTERMINATED; 1369 1377 } 1370 1378 1371 1379 if (call->inv->state != PJSIP_INV_STATE_CONFIRMED) { 1372 1380 PJ_LOG(3,(THIS_FILE, "Can not hold call that is not confirmed")); 1373 return ;1381 return PJSIP_ESESSIONSTATE; 1374 1382 } 1375 1383 1376 1384 status = create_inactive_sdp(call, &sdp); 1377 1385 if (status != PJ_SUCCESS) 1378 return ;1386 return status; 1379 1387 1380 1388 /* Send re-INVITE with new offer */ … … 1382 1390 if (status != PJ_SUCCESS) { 1383 1391 pjsua_perror(THIS_FILE, "Unable to create re-INVITE", status); 1384 return ;1392 return status; 1385 1393 } 1386 1394 … … 1388 1396 if (status != PJ_SUCCESS) { 1389 1397 pjsua_perror(THIS_FILE, "Unable to send re-INVITE", status); 1390 return; 1391 } 1398 return status; 1399 } 1400 1401 return PJ_SUCCESS; 1392 1402 } 1393 1403 … … 1396 1406 * re-INVITE. 1397 1407 */ 1398 PJ_DEF( void) pjsua_call_reinvite(int call_index)1408 PJ_DEF(pj_status_t) pjsua_call_reinvite(int call_index) 1399 1409 { 1400 1410 pjmedia_sdp_session *sdp; … … 1407 1417 if (!call->inv) { 1408 1418 PJ_LOG(3,(THIS_FILE,"Call has been disconnected")); 1409 return ;1419 return PJSIP_ESESSIONTERMINATED; 1410 1420 } 1411 1421 … … 1413 1423 if (call->inv->state != PJSIP_INV_STATE_CONFIRMED) { 1414 1424 PJ_LOG(3,(THIS_FILE, "Can not re-INVITE call that is not confirmed")); 1415 return ;1425 return PJSIP_ESESSIONSTATE; 1416 1426 } 1417 1427 … … 1422 1432 pjsua_perror(THIS_FILE, "Unable to get SDP from media endpoint", 1423 1433 status); 1424 return ;1434 return status; 1425 1435 } 1426 1436 … … 1429 1439 if (status != PJ_SUCCESS) { 1430 1440 pjsua_perror(THIS_FILE, "Unable to create re-INVITE", status); 1431 return ;1441 return status; 1432 1442 } 1433 1443 … … 1435 1445 if (status != PJ_SUCCESS) { 1436 1446 pjsua_perror(THIS_FILE, "Unable to send re-INVITE", status); 1437 return; 1438 } 1447 return status; 1448 } 1449 1450 return PJ_SUCCESS; 1439 1451 } 1440 1452 … … 1443 1455 * Transfer call. 1444 1456 */ 1445 PJ_DEF( void) pjsua_call_xfer(unsigned call_index, const pj_str_t *dest)1457 PJ_DEF(pj_status_t) pjsua_call_xfer(unsigned call_index, const pj_str_t *dest) 1446 1458 { 1447 1459 pjsip_evsub *sub; … … 1455 1467 if (!call->inv) { 1456 1468 PJ_LOG(3,(THIS_FILE,"Call has been disconnected")); 1457 return ;1469 return PJSIP_ESESSIONTERMINATED; 1458 1470 } 1459 1471 … … 1465 1477 if (status != PJ_SUCCESS) { 1466 1478 pjsua_perror(THIS_FILE, "Unable to create xfer", status); 1467 return ;1479 return status; 1468 1480 } 1469 1481 … … 1474 1486 if (status != PJ_SUCCESS) { 1475 1487 pjsua_perror(THIS_FILE, "Unable to create REFER request", status); 1476 return ;1488 return status; 1477 1489 } 1478 1490 … … 1481 1493 if (status != PJ_SUCCESS) { 1482 1494 pjsua_perror(THIS_FILE, "Unable to send REFER request", status); 1483 return ;1495 return status; 1484 1496 } 1485 1497 … … 1488 1500 * may want to hold the INVITE, or terminate the invite, or whatever. 1489 1501 */ 1502 1503 return PJ_SUCCESS; 1490 1504 } 1491 1505 … … 1513 1527 * Send instant messaging inside INVITE session. 1514 1528 */ 1515 PJ_DE CL(void) pjsua_call_send_im(int call_index, const pj_str_t *str)1529 PJ_DEF(pj_status_t) pjsua_call_send_im(int call_index, const pj_str_t *str) 1516 1530 { 1517 1531 pjsua_call *call; … … 1525 1539 if (!call->inv) { 1526 1540 PJ_LOG(3,(THIS_FILE,"Call has been disconnected")); 1527 return ;1541 return PJSIP_ESESSIONTERMINATED; 1528 1542 } 1529 1543 … … 1561 1575 on_return: 1562 1576 pjsip_dlg_dec_lock(call->inv->dlg); 1577 return status; 1563 1578 } 1564 1579 … … 1567 1582 * Send IM typing indication inside INVITE session. 1568 1583 */ 1569 PJ_DECL(void) pjsua_call_typing(int call_index, pj_bool_t is_typing) 1584 PJ_DEF(pj_status_t) pjsua_call_send_typing_ind(int call_index, 1585 pj_bool_t is_typing) 1570 1586 { 1571 1587 pjsua_call *call; … … 1577 1593 if (!call->inv) { 1578 1594 PJ_LOG(3,(THIS_FILE,"Call has been disconnected")); 1579 return ;1595 return PJSIP_ESESSIONTERMINATED; 1580 1596 } 1581 1597 … … 1603 1619 1604 1620 on_return: 1605 pjsip_dlg_dec_lock(call->inv->dlg);} 1621 pjsip_dlg_dec_lock(call->inv->dlg); 1622 return status; 1623 } 1606 1624 1607 1625 -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_console_app.c
r487 r492 37 37 int i, max; 38 38 39 max = pjsua_ get_max_calls();39 max = pjsua_call_get_max_count(); 40 40 for (i=current_call+1; i<max; ++i) { 41 41 if (pjsua_call_is_active(i)) { … … 64 64 int i, max; 65 65 66 max = pjsua_ get_max_calls();66 max = pjsua_call_get_max_count(); 67 67 for (i=current_call-1; i>=0; --i) { 68 68 if (pjsua_call_is_active(i)) { … … 94 94 PJ_UNUSED_ARG(e); 95 95 96 pjsua_ get_call_info(call_index, &call_info);96 pjsua_call_get_info(call_index, &call_info); 97 97 98 98 if (call_info.state == PJSIP_INV_STATE_DISCONNECTED) { … … 100 100 PJ_LOG(3,(THIS_FILE, "Call %d is DISCONNECTED [reason=%d (%s)]", 101 101 call_index, 102 call_info. cause,103 call_info. cause_text.ptr));102 call_info.last_status, 103 call_info.last_status_text.ptr)); 104 104 105 105 if ((int)call_index == current_call) { … … 386 386 { 387 387 unsigned i, count; 388 pj media_conf_port_info info[PJSUA_MAX_CALLS];388 pjsua_conf_port_id id[PJSUA_MAX_CALLS]; 389 389 390 390 printf("Conference ports:\n"); 391 391 392 count = PJ_ARRAY_SIZE(info); 393 pjsua_conf_enum_ports(&count, info); 392 count = PJ_ARRAY_SIZE(id); 393 pjsua_conf_enum_port_ids(id, &count); 394 394 395 for (i=0; i<count; ++i) { 395 396 char txlist[PJSUA_MAX_CALLS*4+10]; 396 int j; 397 pjmedia_conf_port_info *port_info = &info[i]; 398 397 unsigned j; 398 pjsua_conf_port_info info; 399 400 pjsua_conf_get_port_info(id[i], &info); 401 399 402 txlist[0] = '\0'; 400 for (j=0; j< (int)count; ++j) {403 for (j=0; j<info.listener_cnt; ++j) { 401 404 char s[10]; 402 if (port_info->listener[j]) { 403 pj_ansi_sprintf(s, "#%d ", j); 404 pj_ansi_strcat(txlist, s); 405 } 405 pj_ansi_sprintf(s, "#%d ", info.listeners[j]); 406 pj_ansi_strcat(txlist, s); 406 407 } 407 408 printf("Port #%02d[%2dKHz/%dms] %20.*s transmitting to: %s\n", 408 port_info->slot,409 port_info->clock_rate/1000,410 port_info->samples_per_frame * 1000 / port_info->clock_rate,411 (int) port_info->name.slen,412 port_info->name.ptr,409 info.slot_id, 410 info.clock_rate/1000, 411 info.samples_per_frame * 1000 / info.clock_rate, 412 (int)info.name.slen, 413 info.name.ptr, 413 414 txlist); 414 415 … … 418 419 419 420 420 void pjsua_console_app_main( void)421 void pjsua_console_app_main(const pj_str_t *uri_to_call) 421 422 { 422 423 char menuin[10]; … … 432 433 433 434 /* If user specifies URI to call, then call the URI */ 434 if (pjsua_get_config()->uri_to_call.slen) { 435 pjsua_make_call( current_acc, &pjsua_get_config()->uri_to_call, 436 NULL); 435 if (uri_to_call->slen) { 436 pjsua_call_make_call( current_acc, uri_to_call, NULL); 437 437 } 438 438 … … 450 450 case 'm': 451 451 /* Make call! : */ 452 printf("(You currently have %d calls)\n", pjsua_get_call_count()); 452 printf("(You currently have %d calls)\n", 453 pjsua_call_get_count()); 453 454 454 455 uri = NULL; … … 470 471 471 472 tmp = pj_str(uri); 472 pjsua_ make_call( current_acc, &tmp, NULL);473 pjsua_call_make_call( current_acc, &tmp, NULL); 473 474 break; 474 475 475 476 case 'M': 476 477 /* Make multiple calls! : */ 477 printf("(You currently have %d calls)\n", pjsua_get_call_count()); 478 printf("(You currently have %d calls)\n", 479 pjsua_call_get_count()); 478 480 479 481 if (!simple_input("Number of calls", menuin, sizeof(menuin))) … … 501 503 502 504 tmp = pj_str(uri); 503 status = pjsua_ make_call(current_acc, &tmp, NULL);505 status = pjsua_call_make_call(current_acc, &tmp, NULL); 504 506 if (status != PJ_SUCCESS) 505 507 break; … … 541 543 /* Send typing indication. */ 542 544 if (i != -1) 543 pjsua_call_ typing(i, PJ_TRUE);545 pjsua_call_send_typing_ind(i, PJ_TRUE); 544 546 else { 545 547 pj_str_t tmp_uri = pj_str(uri); … … 554 556 */ 555 557 if (i != -1) 556 pjsua_call_ typing(i, PJ_FALSE);558 pjsua_call_send_typing_ind(i, PJ_FALSE); 557 559 else { 558 560 pj_str_t tmp_uri = pj_str(uri); … … 577 579 578 580 if (current_call != -1) { 579 pjsua_ get_call_info(current_call, &call_info);581 pjsua_call_get_info(current_call, &call_info); 580 582 } else { 581 583 /* Make compiler happy */ … … 651 653 if (current_call != -1) { 652 654 653 pjsua_ get_call_info(current_call, &call_info);655 pjsua_call_get_info(current_call, &call_info); 654 656 PJ_LOG(3,(THIS_FILE,"Current dialog: %.*s", 655 657 (int)call_info.remote_info.slen, … … 782 784 } 783 785 784 pjsua_pres_refresh();785 786 786 } else if (result.uri_result) { 787 787 puts("Sorry, can only subscribe to buddy's presence, " … … 815 815 acc_info.acc_id.ptr, 816 816 (acc_info.online_status?"online":"offline")); 817 pjsua_pres_refresh();818 817 break; 819 818 … … 898 897 899 898 /***************************************************************************** 900 * This is a very simple PJSIP module, whose sole purpose is to display901 * incoming and outgoing messages to log. This module will have priority902 * higher than transport layer, which means:903 *904 * - incoming messages will come to this module first before reaching905 * transaction layer.906 *907 * - outgoing messages will come to this module last, after the message908 * has been 'printed' to contiguous buffer by transport layer and909 * appropriate transport instance has been decided for this message.910 *911 */912 913 /* Notification on incoming messages */914 static pj_bool_t console_on_rx_msg(pjsip_rx_data *rdata)915 {916 PJ_LOG(4,(THIS_FILE, "RX %d bytes %s from %s:%d:\n"917 "%s\n"918 "--end msg--",919 rdata->msg_info.len,920 pjsip_rx_data_get_info(rdata),921 rdata->pkt_info.src_name,922 rdata->pkt_info.src_port,923 rdata->msg_info.msg_buf));924 925 /* Always return false, otherwise messages will not get processed! */926 return PJ_FALSE;927 }928 929 /* Notification on outgoing messages */930 static pj_status_t console_on_tx_msg(pjsip_tx_data *tdata)931 {932 933 /* Important note:934 * tp_info field is only valid after outgoing messages has passed935 * transport layer. So don't try to access tp_info when the module936 * has lower priority than transport layer.937 */938 939 PJ_LOG(4,(THIS_FILE, "TX %d bytes %s to %s:%d:\n"940 "%s\n"941 "--end msg--",942 (tdata->buf.cur - tdata->buf.start),943 pjsip_tx_data_get_info(tdata),944 tdata->tp_info.dst_name,945 tdata->tp_info.dst_port,946 tdata->buf.start));947 948 /* Always return success, otherwise message will not get sent! */949 return PJ_SUCCESS;950 }951 952 /* The module instance. */953 pjsip_module pjsua_console_app_msg_logger =954 {955 NULL, NULL, /* prev, next. */956 { "mod-pjsua-log", 13 }, /* Name. */957 -1, /* Id */958 PJSIP_MOD_PRIORITY_TRANSPORT_LAYER-1,/* Priority */959 NULL, /* load() */960 NULL, /* start() */961 NULL, /* stop() */962 NULL, /* unload() */963 &console_on_rx_msg, /* on_rx_request() */964 &console_on_rx_msg, /* on_rx_response() */965 &console_on_tx_msg, /* on_tx_request. */966 &console_on_tx_msg, /* on_tx_response() */967 NULL, /* on_tsx_state() */968 969 };970 971 972 973 /*****************************************************************************974 899 * Error display: 975 900 */ … … 993 918 { 994 919 &console_on_call_state, 995 NULL, /* default accept transfer */ 920 NULL, /* on_incoming_call */ 921 NULL, /* default accept transfer */ 996 922 &console_on_reg_state, 997 923 &console_on_buddy_state, -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r487 r492 56 56 cfg->udp_port = 5060; 57 57 cfg->start_rtp_port = 4000; 58 cfg->msg_logging = PJ_TRUE; 58 59 cfg->max_calls = 4; 59 60 cfg->conf_ports = 0; … … 722 723 unsigned j; 723 724 725 pj_memcpy(dst_acc, src_acc, sizeof(pjsua_acc_config)); 726 724 727 pj_strdup_with_null(pool, &dst_acc->id, &src_acc->id); 725 728 pj_strdup_with_null(pool, &dst_acc->reg_uri, &src_acc->reg_uri); … … 743 746 * Copy configuration. 744 747 */ 745 static void copy_config(pj_pool_t *pool, pjsua_config *dst,748 void pjsua_copy_config( pj_pool_t *pool, pjsua_config *dst, 746 749 const pjsua_config *src) 747 750 { … … 762 765 763 766 pj_strdup_with_null(pool, &dst->outbound_proxy, &src->outbound_proxy); 764 pj_strdup_with_null(pool, &dst->uri_to_call, &src->uri_to_call);767 //pj_strdup_with_null(pool, &dst->uri_to_call, &src->uri_to_call); 765 768 766 769 for (i=0; i<src->acc_cnt; ++i) { … … 814 817 } 815 818 819 /* Enable SIP message logging */ 820 if (pjsua.config.msg_logging) 821 pjsip_endpt_register_module(pjsua.endpt, &pjsua_msg_logger); 822 816 823 return PJ_SUCCESS; 817 824 } … … 864 871 865 872 /* Copy configuration */ 866 copy_config(pjsua.pool, &pjsua.config, cfg);873 pjsua_copy_config(pjsua.pool, &pjsua.config, cfg); 867 874 868 875 /* Copy callback */ … … 1027 1034 * Find account for incoming request. 1028 1035 */ 1029 int pjsua_find_account_for_incoming(pjsip_rx_data *rdata)1036 PJ_DEF(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata) 1030 1037 { 1031 1038 pjsip_uri *uri; … … 1035 1042 uri = rdata->msg_info.to->uri; 1036 1043 1037 /* Just return last account if To URI is not SIP: */1044 /* Just return default account if To URI is not SIP: */ 1038 1045 if (!PJSIP_URI_SCHEME_IS_SIP(uri) && 1039 1046 !PJSIP_URI_SCHEME_IS_SIPS(uri)) 1040 1047 { 1041 return pjsua. config.acc_cnt;1048 return pjsua.default_acc; 1042 1049 } 1043 1050 … … 1069 1076 } 1070 1077 1071 /* Still no match, just return last account */1072 return pjsua. config.acc_cnt;1078 /* Still no match, use default account */ 1079 return pjsua.default_acc; 1073 1080 } 1074 1081 … … 1077 1084 * Find account for outgoing request. 1078 1085 */ 1079 int pjsua_find_account_for_outgoing(const pj_str_t *url) 1080 { 1081 PJ_UNUSED_ARG(url); 1082 1083 /* Just use account #0 */ 1084 return 0; 1086 PJ_DEF(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *str_url) 1087 { 1088 pj_str_t tmp; 1089 pjsip_uri *uri; 1090 pjsip_sip_uri *sip_uri; 1091 unsigned i; 1092 1093 pj_strdup_with_null(pjsua.pool, &tmp, str_url); 1094 1095 uri = pjsip_parse_uri(pjsua.pool, tmp.ptr, tmp.slen, 0); 1096 if (!uri) 1097 return pjsua.config.acc_cnt-1; 1098 1099 if (!PJSIP_URI_SCHEME_IS_SIP(uri) && 1100 !PJSIP_URI_SCHEME_IS_SIPS(uri)) 1101 { 1102 /* Return the first account with proxy */ 1103 for (i=0; i<PJ_ARRAY_SIZE(pjsua.acc); ++i) { 1104 if (!pjsua.acc[i].valid) 1105 continue; 1106 if (pjsua.config.acc_config[i].proxy.slen) 1107 break; 1108 } 1109 1110 if (i != PJ_ARRAY_SIZE(pjsua.acc)) 1111 return i; 1112 1113 /* Not found, use default account */ 1114 return pjsua.default_acc; 1115 } 1116 1117 sip_uri = pjsip_uri_get_uri(uri); 1118 1119 /* Find matching domain */ 1120 for (i=0; i<PJ_ARRAY_SIZE(pjsua.acc); ++i) { 1121 if (!pjsua.acc[i].valid) 1122 continue; 1123 if (pj_stricmp(&pjsua.acc[i].host_part, &sip_uri->host)==0) 1124 break; 1125 } 1126 1127 if (i != PJ_ARRAY_SIZE(pjsua.acc)) 1128 return i; 1129 1130 /* Just use default account */ 1131 return pjsua.default_acc; 1085 1132 } 1086 1133 … … 1193 1240 } 1194 1241 1242 /* Mark account as valid */ 1243 pjsua.acc[acc_index].valid = PJ_TRUE; 1244 1245 1195 1246 return PJ_SUCCESS; 1196 1247 } … … 1200 1251 */ 1201 1252 PJ_DEF(pj_status_t) pjsua_acc_add( const pjsua_acc_config *cfg, 1202 int *acc_index) 1203 { 1253 pjsua_acc_id *acc_index) 1254 { 1255 unsigned index; 1204 1256 pj_status_t status; 1205 1257 1206 PJ_ASSERT_RETURN(pjsua.config.acc_cnt<PJ_ARRAY_SIZE(pjsua.config.acc_config), 1258 PJ_ASSERT_RETURN(pjsua.config.acc_cnt < 1259 PJ_ARRAY_SIZE(pjsua.config.acc_config), 1207 1260 PJ_ETOOMANY); 1208 1261 1209 copy_acc_config(pjsua.pool, &pjsua.config.acc_config[pjsua.config.acc_cnt], cfg); 1262 /* Find empty account index. */ 1263 for (index=0; index < PJ_ARRAY_SIZE(pjsua.acc); ++index) { 1264 if (pjsua.acc[index].valid == PJ_FALSE) 1265 break; 1266 } 1267 1268 /* Expect to find a slot */ 1269 PJ_ASSERT_RETURN(index < PJ_ARRAY_SIZE(pjsua.acc), PJ_EBUG); 1270 1271 copy_acc_config(pjsua.pool, &pjsua.config.acc_config[index], cfg); 1210 1272 1211 status = init_acc( pjsua.config.acc_cnt);1273 status = init_acc(index); 1212 1274 if (status != PJ_SUCCESS) { 1213 1275 pjsua_perror(THIS_FILE, "Error adding account", status); … … 1216 1278 1217 1279 if (acc_index) 1218 *acc_index = pjsua.config.acc_cnt;1280 *acc_index = index; 1219 1281 1220 1282 pjsua.config.acc_cnt++; … … 1223 1285 } 1224 1286 1287 1288 /* 1289 * Delete account. 1290 */ 1291 PJ_DEF(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_index) 1292 { 1293 PJ_ASSERT_RETURN(acc_index < (int)pjsua.config.acc_cnt, 1294 PJ_EINVAL); 1295 PJ_ASSERT_RETURN(pjsua.acc[acc_index].valid, PJ_EINVALIDOP); 1296 1297 /* Delete registration */ 1298 if (pjsua.acc[acc_index].regc != NULL) 1299 pjsua_acc_set_registration(acc_index, PJ_FALSE); 1300 1301 /* Invalidate */ 1302 pjsua.acc[acc_index].valid = PJ_FALSE; 1303 1304 return PJ_SUCCESS; 1305 } 1225 1306 1226 1307 … … 1267 1348 1268 1349 tmp.ptr = buf; 1269 tmp.slen = pj_ansi_sprintf(tmp.ptr, " <sip:%s:%d>",1350 tmp.slen = pj_ansi_sprintf(tmp.ptr, "Local <sip:%s:%d>", 1270 1351 pjsua.config.sip_host.ptr, 1271 1352 pjsua.config.sip_port); … … 1283 1364 } 1284 1365 1366 1367 /* Add another account as the last one. 1368 * This account corresponds to local endpoint, and is user-less. 1369 * This is also the default account. 1370 */ 1371 if (pjsua.config.acc_cnt < PJ_ARRAY_SIZE(pjsua.config.acc_config)) { 1372 pjsua.default_acc = pjsua.config.acc_cnt; 1373 pjsua.acc[pjsua.default_acc].auto_gen = 1; 1374 pjsua.config.acc_cnt++; 1375 } 1376 1285 1377 1286 1378 /* Initialize accounts: */ … … 1292 1384 } 1293 1385 } 1294 1295 1386 1296 1387 … … 1334 1425 1335 1426 1427 /* Refresh presence */ 1428 pjsua_pres_refresh(); 1429 1336 1430 1337 1431 PJ_LOG(3,(THIS_FILE, "PJSUA version %s started", PJ_VERSION)); … … 1369 1463 1370 1464 /** 1371 * Enum all conference ports. 1372 */ 1373 PJ_DEF(pj_status_t) pjsua_conf_enum_ports( unsigned *count, 1374 pjmedia_conf_port_info info[]) 1375 { 1376 return pjmedia_conf_get_ports_info(pjsua.mconf, count, info); 1377 } 1378 1379 1465 * Enum all conference port ID. 1466 */ 1467 PJ_DEF(pj_status_t) pjsua_conf_enum_port_ids( pjsua_conf_port_id id[], 1468 unsigned *count) 1469 { 1470 return pjmedia_conf_enum_ports( pjsua.mconf, (unsigned*)id, count); 1471 } 1472 1473 1474 1475 /** 1476 * Get information about the specified conference port 1477 */ 1478 PJ_DEF(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id id, 1479 pjsua_conf_port_info *info) 1480 { 1481 pjmedia_conf_port_info cinfo; 1482 unsigned i, count; 1483 pj_status_t status; 1484 1485 status = pjmedia_conf_get_port_info( pjsua.mconf, id, &cinfo); 1486 if (status != PJ_SUCCESS) 1487 return status; 1488 1489 pj_memset(info, 0, sizeof(*info)); 1490 info->slot_id = id; 1491 info->name = cinfo.name; 1492 info->clock_rate = cinfo.clock_rate; 1493 info->channel_count = cinfo.channel_count; 1494 info->samples_per_frame = cinfo.samples_per_frame; 1495 info->bits_per_sample = cinfo.bits_per_sample; 1496 1497 /* Build array of listeners */ 1498 count = pjsua.config.conf_ports; 1499 for (i=0; i<count; ++i) { 1500 if (cinfo.listener[i]) { 1501 info->listeners[info->listener_cnt++] = i; 1502 } 1503 } 1504 1505 return PJ_SUCCESS; 1506 } 1380 1507 1381 1508 … … 1383 1510 * Connect conference port. 1384 1511 */ 1385 PJ_DEF(pj_status_t) pjsua_conf_connect( unsigned src_port,1386 unsigned dst_port)1512 PJ_DEF(pj_status_t) pjsua_conf_connect( pjsua_conf_port_id src_port, 1513 pjsua_conf_port_id dst_port) 1387 1514 { 1388 1515 return pjmedia_conf_connect_port(pjsua.mconf, src_port, dst_port, 0); … … 1393 1520 * Connect conference port connection. 1394 1521 */ 1395 PJ_DEF(pj_status_t) pjsua_conf_disconnect( unsigned src_port,1396 unsigned dst_port)1522 PJ_DEF(pj_status_t) pjsua_conf_disconnect( pjsua_conf_port_id src_port, 1523 pjsua_conf_port_id dst_port) 1397 1524 { 1398 1525 return pjmedia_conf_disconnect_port(pjsua.mconf, src_port, dst_port); … … 1435 1562 pjsua.player[pjsua.player_cnt].slot = slot; 1436 1563 1437 if ( *id)1564 if (id) 1438 1565 *id = pjsua.player_cnt; 1439 1566 … … 1447 1574 * Get conference port associated with player. 1448 1575 */ 1449 PJ_DEF( int) pjsua_player_get_conf_port(pjsua_player_id id)1576 PJ_DEF(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id) 1450 1577 { 1451 1578 PJ_ASSERT_RETURN(id>=0 && id < PJ_ARRAY_SIZE(pjsua.player), PJ_EINVAL); … … 1531 1658 * Get conference port associated with recorder. 1532 1659 */ 1533 PJ_DEF( int) pjsua_recorder_get_conf_port(pjsua_recorder_id id)1660 PJ_DEF(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id) 1534 1661 { 1535 1662 PJ_ASSERT_RETURN(id>=0 && id < PJ_ARRAY_SIZE(pjsua.recorder), PJ_EINVAL); -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_im.c
r482 r492 186 186 pj_str_t from, to; 187 187 pjsip_accept_hdr *accept_hdr; 188 pjsip_contact_hdr *contact_hdr; 188 189 pjsip_msg *msg; 189 190 pj_status_t status; … … 222 223 NULL, NULL, NULL); 223 224 224 /* Build the From text. */ 225 /* For the source URI, we use Contact header if present, since 226 * Contact header contains the port number information. If this is 227 * not available, then use From header. 228 */ 225 229 from.ptr = pj_pool_alloc(rdata->tp_info.pool, PJSIP_MAX_URL_SIZE); 226 from.slen = pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, 227 rdata->msg_info.from->uri, 228 from.ptr, PJSIP_MAX_URL_SIZE); 230 contact_hdr = pjsip_msg_find_hdr(rdata->msg_info.msg, 231 PJSIP_H_CONTACT, NULL); 232 if (contact_hdr) { 233 from.slen = pjsip_uri_print(PJSIP_URI_IN_CONTACT_HDR, 234 contact_hdr->uri, 235 from.ptr, PJSIP_MAX_URL_SIZE); 236 } else { 237 from.slen = pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, 238 rdata->msg_info.from->uri, 239 from.ptr, PJSIP_MAX_URL_SIZE); 240 } 241 229 242 if (from.slen < 1) 230 243 from = pj_str("<--URI is too long-->"); … … 337 350 pj_bool_t is_typing) 338 351 { 352 const pj_str_t STR_CONTACT = { "Contact", 7 }; 339 353 pjsip_tx_data *tdata; 340 354 pj_status_t status; … … 351 365 352 366 367 /* Add accept header. */ 368 pjsip_msg_add_hdr( tdata->msg, 369 (pjsip_hdr*)pjsua_im_create_accept(tdata->pool)); 370 371 372 /* Add contact. */ 373 pjsip_msg_add_hdr( tdata->msg, (pjsip_hdr*) 374 pjsip_generic_string_hdr_create(tdata->pool, 375 &STR_CONTACT, 376 &pjsua.config.acc_config[acc_index].contact)); 377 378 353 379 /* Create "application/im-iscomposing+xml" msg body. */ 354 380 tdata->msg->body = pjsip_iscomposing_create_body( tdata->pool, is_typing, -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_imp.h
r487 r492 33 33 unsigned index; /**< Index in pjsua array. */ 34 34 pjsip_inv_session *inv; /**< The invite session. */ 35 pjsip_status_code last_code; /**<Last status code seen. */ 35 36 pj_time_val start_time;/**< First INVITE sent/received. */ 36 37 pj_time_val res_time; /**< First response sent/received. */ … … 62 63 pj_str_t host; /**< Buddy host. */ 63 64 unsigned port; /**< Buddy port. */ 64 int acc_index; /**< Which account to use. */65 65 pj_bool_t monitor; /**< Should we monitor? */ 66 66 pjsip_evsub *sub; /**< Buddy presence subscription */ … … 90 90 struct pjsua_acc 91 91 { 92 pj_bool_t valid; /**< Is this account valid? */ 93 pj_bool_t auto_gen; /**< Is this account generated. */ 92 94 int index; /**< Index in accounts array. */ 93 95 pj_str_t user_part; /**< User part of local URI. */ … … 160 162 161 163 /* Account: */ 164 int default_acc; /**< Default account to use. */ 162 165 pjsua_acc acc[PJSUA_MAX_ACC]; /** Client regs array. */ 163 166 … … 176 179 pjsua_call calls[PJSUA_MAX_CALLS]; /** Calls array. */ 177 180 178 179 181 /* SIMPLE and buddy status: */ 180 182 pjsua_buddy buddies[PJSUA_MAX_BUDDIES]; … … 186 188 187 189 188 189 /** 190 * Find account for incoming request. 191 */ 192 int pjsua_find_account_for_incoming(pjsip_rx_data *rdata); 193 194 195 /** 196 * Find account for outgoing request. 197 */ 198 int pjsua_find_account_for_outgoing(const pj_str_t *url); 190 void pjsua_copy_config( pj_pool_t *pool, pjsua_config *dst, 191 const pjsua_config *src); 199 192 200 193 … … 224 217 pj_status_t pjsua_pres_init(); 225 218 219 220 /** 221 * Refresh both presence client and server subscriptions. 222 */ 223 void pjsua_pres_refresh(void); 226 224 227 225 /** … … 256 254 257 255 256 extern pjsip_module pjsua_msg_logger; 258 257 259 258 #endif /* __PJSUA_IMP_H__ */ -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c
r487 r492 98 98 99 99 /* Find which account for the incoming request. */ 100 acc_index = pjsua_ find_account_for_incoming(rdata);100 acc_index = pjsua_acc_find_for_incoming(rdata); 101 101 acc_config = &pjsua.config.acc_config[acc_index]; 102 102 … … 311 311 pj_status_t status; 312 312 313 acc_index = pjsua.buddies[index].acc_index; 313 acc_index = pjsua_acc_find_for_outgoing(&pjsua.config.buddy_uri[index]); 314 314 315 acc_config = &pjsua.config.acc_config[acc_index]; 315 316 … … 440 441 * Get buddy info. 441 442 */ 442 PJ_DEF(pj_status_t) pjsua_buddy_get_info( unsigned index,443 PJ_DEF(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id index, 443 444 pjsua_buddy_info *info) 444 445 { 445 446 pjsua_buddy *buddy; 446 447 447 PJ_ASSERT_RETURN(index < pjsua.config.buddy_cnt, PJ_EINVAL); 448 PJ_ASSERT_RETURN(index < (int)PJ_ARRAY_SIZE(pjsua.config.buddy_uri), 449 PJ_EINVAL); 448 450 449 451 pj_memset(info, 0, sizeof(pjsua_buddy_info)); … … 472 474 } 473 475 474 info->acc_index = buddy->acc_index;475 476 return PJ_SUCCESS; 476 477 } … … 481 482 */ 482 483 PJ_DEF(pj_status_t) pjsua_buddy_add( const pj_str_t *uri, 483 int*buddy_index)484 pjsua_buddy_id *buddy_index) 484 485 { 485 486 pjsip_name_addr *url; … … 488 489 pj_str_t tmp; 489 490 490 PJ_ASSERT_RETURN(pjsua.config.buddy_cnt <= PJ_ARRAY_SIZE(pjsua.config.buddy_uri), 491 PJ_ASSERT_RETURN(pjsua.config.buddy_cnt <= 492 PJ_ARRAY_SIZE(pjsua.config.buddy_uri), 491 493 PJ_ETOOMANY); 492 494 493 index = pjsua.config.buddy_cnt; 495 /* Find empty slot */ 496 for (index=0; index<PJ_ARRAY_SIZE(pjsua.config.buddy_uri); ++index) { 497 if (pjsua.config.buddy_uri[index].slen == 0) 498 break; 499 } 500 501 /* Expect to find an empty slot */ 502 PJ_ASSERT_RETURN(index < PJ_ARRAY_SIZE(pjsua.config.buddy_uri), 503 PJ_ETOOMANY); 504 494 505 495 506 /* Get name and display name for buddy */ … … 512 523 pjsua.buddies[index].port = 5060; 513 524 514 /* Find account for outgoing preence subscription */515 pjsua.buddies[index].acc_index =516 pjsua_find_account_for_outgoing(&pjsua.config.buddy_uri[index]);517 518 525 if (buddy_index) 519 526 *buddy_index = index; … … 526 533 527 534 528 PJ_DEF(pj_status_t) pjsua_buddy_subscribe_pres( unsigned index, 535 /** 536 * Delete buddy. 537 */ 538 PJ_DEF(pj_status_t) pjsua_buddy_del(pjsua_buddy_id index) 539 { 540 PJ_ASSERT_RETURN(index < (int)PJ_ARRAY_SIZE(pjsua.config.buddy_uri), 541 PJ_EINVAL); 542 543 if (pjsua.config.buddy_uri[index].slen == 0) 544 return PJ_SUCCESS; 545 546 /* Unsubscribe presence */ 547 pjsua_buddy_subscribe_pres(index, PJ_FALSE); 548 549 /* Remove buddy */ 550 pjsua.config.buddy_uri[index].slen = 0; 551 pjsua.config.buddy_cnt--; 552 553 return PJ_SUCCESS; 554 } 555 556 557 PJ_DEF(pj_status_t) pjsua_buddy_subscribe_pres( pjsua_buddy_id index, 529 558 pj_bool_t monitor) 530 559 { 531 560 pjsua_buddy *buddy; 532 561 533 PJ_ASSERT_RETURN(index < pjsua.config.buddy_cnt, PJ_EINVAL); 562 PJ_ASSERT_RETURN(index < (int)PJ_ARRAY_SIZE(pjsua.config.buddy_uri), 563 PJ_EINVAL); 534 564 535 565 buddy = &pjsua.buddies[index]; 536 566 buddy->monitor = monitor; 567 pjsua_pres_refresh(); 537 568 return PJ_SUCCESS; 538 569 } 539 570 540 571 541 PJ_DEF(pj_status_t) pjsua_acc_set_online_status( unsigned acc_index,572 PJ_DEF(pj_status_t) pjsua_acc_set_online_status( pjsua_acc_id acc_index, 542 573 pj_bool_t is_online) 543 574 { 544 PJ_ASSERT_RETURN(acc_index < pjsua.config.acc_cnt, PJ_EINVAL); 575 PJ_ASSERT_RETURN(acc_index < (int)PJ_ARRAY_SIZE(pjsua.acc), 576 PJ_EINVAL); 577 PJ_ASSERT_RETURN(pjsua.acc[acc_index].valid, PJ_EINVALIDOP); 578 545 579 pjsua.acc[acc_index].online_status = is_online; 580 pjsua_pres_refresh(); 546 581 return PJ_SUCCESS; 547 582 } -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_reg.c
r487 r492 96 96 * Get account info. 97 97 */ 98 PJ_DEF(pj_status_t) pjsua_acc_get_info( unsigned acc_index,98 PJ_DEF(pj_status_t) pjsua_acc_get_info( pjsua_acc_id acc_index, 99 99 pjsua_acc_info *info) 100 100 { … … 102 102 pjsua_acc_config *acc_cfg = &pjsua.config.acc_config[acc_index]; 103 103 104 PJ_ASSERT_RETURN( acc_index < pjsua.config.acc_cnt, PJ_EINVAL);105 104 PJ_ASSERT_RETURN(info != NULL, PJ_EINVAL); 105 106 106 pj_memset(info, 0, sizeof(pjsua_acc_info)); 107 107 108 PJ_ASSERT_RETURN(acc_index < (int)pjsua.config.acc_cnt, 109 PJ_EINVAL); 110 PJ_ASSERT_RETURN(pjsua.acc[acc_index].valid, PJ_EINVALIDOP); 111 112 108 113 info->index = acc_index; 109 114 info->acc_id = acc_cfg->id; … … 115 120 pj_strerror(acc->reg_last_err, info->buf, sizeof(info->buf)); 116 121 info->status_text = pj_str(info->buf); 117 } else {122 } else if (acc->reg_last_code) { 118 123 info->status = acc->reg_last_code; 119 124 info->status_text = *pjsip_get_status_text(acc->reg_last_code); 125 } else { 126 info->status = 0; 127 info->status_text = pj_str("In Progress"); 120 128 } 121 129 … … 130 138 131 139 140 PJ_DEF(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[], 141 unsigned *count ) 142 { 143 unsigned i, c; 144 145 for (i=0, c=0; c<*count && i<PJ_ARRAY_SIZE(pjsua.acc); ++i) { 146 if (!pjsua.acc[i].valid) 147 continue; 148 149 pjsua_acc_get_info(i, &info[c]); 150 ++c; 151 } 152 153 *count = c; 154 return PJ_SUCCESS; 155 } 156 157 158 /** 159 * Enum accounts id. 160 */ 161 PJ_DEF(pj_status_t) pjsua_acc_enum_id( pjsua_acc_id ids[], 162 unsigned *count ) 163 { 164 unsigned i, c; 165 166 for (i=0, c=0; c<*count && i<PJ_ARRAY_SIZE(pjsua.acc); ++i) { 167 if (!pjsua.acc[i].valid) 168 continue; 169 ids[c] = i; 170 ++c; 171 } 172 173 *count = c; 174 return PJ_SUCCESS; 175 } 176 177 132 178 /* 133 179 * Update registration. If renew is false, then unregistration will be performed. 134 180 */ 135 PJ_DECL(pj_status_t) pjsua_acc_set_registration(unsigned acc_index, pj_bool_t renew) 181 PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_index, 182 pj_bool_t renew) 136 183 { 137 184 pj_status_t status = 0; 138 185 pjsip_tx_data *tdata = 0; 186 187 PJ_ASSERT_RETURN(acc_index < (int)pjsua.config.acc_cnt, 188 PJ_EINVAL); 189 PJ_ASSERT_RETURN(pjsua.acc[acc_index].valid, PJ_EINVALIDOP); 139 190 140 191 if (renew) { -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_settings.c
r487 r492 212 212 /* Parse arguments. */ 213 213 PJ_DEF(pj_status_t) pjsua_parse_args(int argc, char *argv[], 214 pjsua_config *cfg) 214 pjsua_config *cfg, 215 pj_str_t *uri_to_call) 215 216 { 216 217 int c; … … 596 597 597 598 if (pj_optind != argc) { 599 pj_str_t uri_arg; 598 600 599 601 if (pjsua_verify_sip_url(argv[pj_optind]) != PJ_SUCCESS) { … … 601 603 return -1; 602 604 } 603 cfg->uri_to_call = pj_str(argv[pj_optind]); 605 uri_arg = pj_str(argv[pj_optind]); 606 if (uri_to_call) 607 *uri_to_call = uri_arg; 604 608 pj_optind++; 605 609 606 610 /* Add URI to call to buddy list if it's not already there */ 607 611 for (i=0; i<cfg->buddy_cnt; ++i) { 608 if (pj_stricmp(&cfg->buddy_uri[i], & cfg->uri_to_call)==0)612 if (pj_stricmp(&cfg->buddy_uri[i], &uri_arg)==0) 609 613 break; 610 614 } 611 615 if (i == cfg->buddy_cnt && cfg->buddy_cnt < PJSUA_MAX_BUDDIES) { 612 cfg->buddy_uri[cfg->buddy_cnt++] = cfg->uri_to_call; 613 } 616 cfg->buddy_uri[cfg->buddy_cnt++] = uri_arg; 617 } 618 619 } else { 620 if (uri_to_call) 621 uri_to_call->slen = 0; 614 622 } 615 623 … … 870 878 } 871 879 872 PJ_DEF(void) pjsua_ dump_call(int call_index, int with_media,880 PJ_DEF(void) pjsua_call_dump(int call_index, int with_media, 873 881 char *buffer, unsigned maxlen, 874 882 const char *indent) … … 976 984 for (i=0; i<pjsua.config.max_calls; ++i) { 977 985 if (pjsua.calls[i].inv) { 978 pjsua_ dump_call(i, detail, buf, sizeof(buf), " ");986 pjsua_call_dump(i, detail, buf, sizeof(buf), " "); 979 987 PJ_LOG(3,(THIS_FILE, "%s", buf)); 980 988 } … … 994 1002 */ 995 1003 PJ_DECL(pj_status_t) pjsua_load_settings(const char *filename, 996 pjsua_config *cfg) 1004 pjsua_config *cfg, 1005 pj_str_t *uri_to_call) 997 1006 { 998 1007 int argc = 3; … … 1000 1009 1001 1010 argv[2] = (char*)filename; 1002 return pjsua_parse_args(argc, argv, cfg );1011 return pjsua_parse_args(argc, argv, cfg, uri_to_call); 1003 1012 } 1004 1013 … … 1298 1307 * Get pjsua running config. 1299 1308 */ 1300 PJ_DEF(const pjsua_config*) pjsua_get_config(void) 1301 { 1302 return &pjsua.config; 1303 } 1304 1309 PJ_DEF(void) pjsua_get_config(pj_pool_t *pool, 1310 pjsua_config *cfg) 1311 { 1312 unsigned i; 1313 1314 pjsua_copy_config(pool, cfg, &pjsua.config); 1315 1316 /* Compact buddy uris. */ 1317 for (i=0; i<PJ_ARRAY_SIZE(pjsua.config.buddy_uri)-1; ++i) { 1318 if (pjsua.config.buddy_uri[i].slen == 0) { 1319 unsigned j; 1320 1321 for (j=i+1; j<PJ_ARRAY_SIZE(pjsua.config.buddy_uri); ++j) { 1322 if (pjsua.config.buddy_uri[j].slen != 0) 1323 break; 1324 } 1325 1326 if (j == PJ_ARRAY_SIZE(pjsua.config.buddy_uri)) 1327 break; 1328 else 1329 pjsua.config.buddy_uri[i] = pjsua.config.buddy_uri[j]; 1330 } 1331 } 1332 1333 /* Compact accounts. */ 1334 for (i=0; i<PJ_ARRAY_SIZE(pjsua.config.acc_config)-1; ++i) { 1335 1336 if (pjsua.acc[i].valid == PJ_FALSE || pjsua.acc[i].auto_gen) { 1337 unsigned j; 1338 1339 for (j=i+1; j<PJ_ARRAY_SIZE(pjsua.config.acc_config); ++j) { 1340 if (pjsua.acc[j].valid && !pjsua.acc[j].auto_gen) 1341 break; 1342 } 1343 1344 if (j == PJ_ARRAY_SIZE(pjsua.config.acc_config)) { 1345 break; 1346 } else { 1347 pj_memcpy(&pjsua.config.acc_config[i] , 1348 &pjsua.config.acc_config[j], 1349 sizeof(pjsua_acc_config)); 1350 } 1351 } 1352 1353 } 1354 1355 /* Remove auto generated account from config */ 1356 for (i=0; i<PJ_ARRAY_SIZE(pjsua.config.acc_config); ++i) { 1357 if (pjsua.acc[i].auto_gen) 1358 --cfg->acc_cnt; 1359 } 1360 } 1361 1362 1363 1364 /***************************************************************************** 1365 * This is a very simple PJSIP module, whose sole purpose is to display 1366 * incoming and outgoing messages to log. This module will have priority 1367 * higher than transport layer, which means: 1368 * 1369 * - incoming messages will come to this module first before reaching 1370 * transaction layer. 1371 * 1372 * - outgoing messages will come to this module last, after the message 1373 * has been 'printed' to contiguous buffer by transport layer and 1374 * appropriate transport instance has been decided for this message. 1375 * 1376 */ 1377 1378 /* Notification on incoming messages */ 1379 static pj_bool_t logging_on_rx_msg(pjsip_rx_data *rdata) 1380 { 1381 PJ_LOG(4,(THIS_FILE, "RX %d bytes %s from %s:%d:\n" 1382 "%s\n" 1383 "--end msg--", 1384 rdata->msg_info.len, 1385 pjsip_rx_data_get_info(rdata), 1386 rdata->pkt_info.src_name, 1387 rdata->pkt_info.src_port, 1388 rdata->msg_info.msg_buf)); 1389 1390 /* Always return false, otherwise messages will not get processed! */ 1391 return PJ_FALSE; 1392 } 1393 1394 /* Notification on outgoing messages */ 1395 static pj_status_t logging_on_tx_msg(pjsip_tx_data *tdata) 1396 { 1397 1398 /* Important note: 1399 * tp_info field is only valid after outgoing messages has passed 1400 * transport layer. So don't try to access tp_info when the module 1401 * has lower priority than transport layer. 1402 */ 1403 1404 PJ_LOG(4,(THIS_FILE, "TX %d bytes %s to %s:%d:\n" 1405 "%s\n" 1406 "--end msg--", 1407 (tdata->buf.cur - tdata->buf.start), 1408 pjsip_tx_data_get_info(tdata), 1409 tdata->tp_info.dst_name, 1410 tdata->tp_info.dst_port, 1411 tdata->buf.start)); 1412 1413 /* Always return success, otherwise message will not get sent! */ 1414 return PJ_SUCCESS; 1415 } 1416 1417 /* The module instance. */ 1418 pjsip_module pjsua_msg_logger = 1419 { 1420 NULL, NULL, /* prev, next. */ 1421 { "mod-pjsua-log", 13 }, /* Name. */ 1422 -1, /* Id */ 1423 PJSIP_MOD_PRIORITY_TRANSPORT_LAYER-1,/* Priority */ 1424 NULL, /* load() */ 1425 NULL, /* start() */ 1426 NULL, /* stop() */ 1427 NULL, /* unload() */ 1428 &logging_on_rx_msg, /* on_rx_request() */ 1429 &logging_on_rx_msg, /* on_rx_response() */ 1430 &logging_on_tx_msg, /* on_tx_request. */ 1431 &logging_on_tx_msg, /* on_tx_response() */ 1432 NULL, /* on_tsx_state() */ 1433 1434 }; 1435
Note: See TracChangeset
for help on using the changeset viewer.