diff options
author | Benny Prijono <bennylp@teluu.com> | 2006-06-06 18:40:40 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2006-06-06 18:40:40 +0000 |
commit | 8db4ef281d67eee2ebeac22a31bc1961e96d78b2 (patch) | |
tree | b910ef526c864da15ab3d05840fc78ff8c6c7608 /pjsip-apps | |
parent | 40d75a0cb404fc0bafa20934e992befd0eab673b (diff) |
Another huge chunks of modifications in PJSUA API, too many things to mention!
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@492 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip-apps')
-rw-r--r-- | pjsip-apps/src/activex-pjsua/activex-pjsua.idl | 25 | ||||
-rw-r--r-- | pjsip-apps/src/activex-pjsua/activex-pjsuaCP.h | 24 | ||||
-rw-r--r-- | pjsip-apps/src/activex-pjsua/app.cpp | 285 | ||||
-rw-r--r-- | pjsip-apps/src/activex-pjsua/app.h | 23 | ||||
-rw-r--r-- | pjsip-apps/src/activex-pjsua/pjsua-structs.idl | 127 | ||||
-rw-r--r-- | pjsip-apps/src/pjsua/main.c | 11 |
6 files changed, 396 insertions, 99 deletions
diff --git a/pjsip-apps/src/activex-pjsua/activex-pjsua.idl b/pjsip-apps/src/activex-pjsua/activex-pjsua.idl index 6b980efa..6b85d2c6 100644 --- a/pjsip-apps/src/activex-pjsua/activex-pjsua.idl +++ b/pjsip-apps/src/activex-pjsua/activex-pjsua.idl @@ -29,7 +29,7 @@ import "../src/activex-pjsua/pjsua-structs.idl"; [id(9), helpstring("method call_is_active")] HRESULT call_is_active([in] int call_index, [out,retval] Pj_Bool *retVal); [id(10), helpstring("method call_has_media")] HRESULT call_has_media([in] int call_index, [out,retval] Pj_Bool *pRet); [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); - [id(12), helpstring("method call_make_call")] HRESULT call_make_call([in] int acc_index, [in,string] Pj_String dst_uri, [out] int *call_index, [out,retval] Pj_Status *pRet); + [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); [id(13), helpstring("method call_answer")] HRESULT call_answer([in] int call_index, [in] int status_code, [out,retval] Pj_Status *pRet); [id(14), helpstring("method call_hangup")] HRESULT call_hangup([in] int call_index, [out,retval] Pj_Status *pRet); [id(15), helpstring("method call_set_hold")] HRESULT call_set_hold([in] int call_index, [out,retval] Pj_Status *pRet); @@ -40,16 +40,16 @@ import "../src/activex-pjsua/pjsua-structs.idl"; [id(20), helpstring("method call_typing")] HRESULT call_typing([in] int call_index, [in] int is_typing, [out,retval] Pj_Status *pRet); [id(21), helpstring("method call_hangup_all")] HRESULT call_hangup_all(); [id(22), helpstring("method acc_get_count")] HRESULT acc_get_count([out,retval] int *pCount); - [id(23), helpstring("method acc_get_info")] HRESULT acc_get_info([in] int acc_index, [out] Pjsua_Acc_Info *pInfo, [out,retval] Pj_Status *pRet); + [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); [id(24), helpstring("method acc_add")] HRESULT acc_add([in] Pjsua_Acc_Config *pConfig, [out] int *pAcc_Index, [out,retval] Pj_Status *pRet); - [id(25), helpstring("method acc_set_online_status")] HRESULT acc_set_online_status([in] int acc_index, [in] int is_online, [out,retval] Pj_Status *pRet); - [id(26), helpstring("method acc_set_registration")] HRESULT acc_set_registration([in] int acc_index, [in] int reg_active, [out,retval] Pj_Status *pRet); + [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); + [id(26), helpstring("method acc_set_registration")] HRESULT acc_set_registration([in] int acc_id, [in] int reg_active, [out,retval] Pj_Status *pRet); [id(27), helpstring("method buddy_get_count")] HRESULT buddy_get_count([out,retval] int *pCount); [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); [id(29), helpstring("method buddy_add")] HRESULT buddy_add([in,string] Pj_String uri, [out] int *pBuddy_Index, [out,retval] Pj_Status *pRet); [id(30), helpstring("method buddy_subscribe_pres")] HRESULT buddy_subscribe_pres([in] int buddy_index, [in] int subscribe, [out,retval] Pj_Status *pRet); - [id(31), helpstring("method im_send_text")] HRESULT im_send_text([in] int acc_index, [in,string] Pj_String dst_uri, [in,string] Pj_String text, [out,retval] Pj_Status *pRet); - [id(32), helpstring("method im_typing")] HRESULT im_typing([in] int acc_index, [in,string] Pj_URI dst_uri, [in] int is_typing, [out,retval] Pj_Status *pRet); + [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); + [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); [id(33), helpstring("method conf_connect")] HRESULT conf_connect([in] int src_port, [in] int sink_port, [out,retval] Pj_Status *pRet); [id(34), helpstring("method conf_disconnect")] HRESULT conf_disconnect([in] int src_port, [in] int sink_port, [out,retval] Pj_Status *pRet); [id(35), helpstring("method player_create")] HRESULT player_create([in,string] Pj_String filename, [out] int *pPlayer_Id, [out,retval] Pj_Status *pRet); @@ -66,6 +66,15 @@ import "../src/activex-pjsua/pjsua-structs.idl"; [id(46), helpstring("method app_verify_sip_url")] HRESULT app_verify_sip_url([in,string] Pj_String uri, [out,retval] Pj_Status *pRet); [id(47), helpstring("method call_get_textstat")] HRESULT call_get_textstat([in] int call_index, [out,retval] BSTR *textstat); [id(48), helpstring("method app_handle_events")] HRESULT app_handle_events([in] int msec_timeout, [out,retval] int *pEvCount); + [id(49), helpstring("method app_parse_uri")] HRESULT app_parse_uri([in] BSTR uriString, [out] Pjsip_Sip_Uri *pSipUri, [out,retval] Pj_Status *pStatus); + [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); + [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); + [id(52), helpstring("method buddy_del")] HRESULT buddy_del([in] int buddy_index, [out,retval] Pj_Status *pRet); + [id(53), helpstring("method acc_del")] HRESULT acc_del([in] int acc_id, [out,retval] Pj_Status *pRet); + [id(54), helpstring("method acc_find_for_outgoing")] HRESULT acc_find_for_outgoing([in] BSTR url, [out,retval] int *acc_id); + [id(55), helpstring("method acc_enum_id")] HRESULT acc_enum_id([out,retval] SAFEARRAY(int) *accIdArray); + [id(56), helpstring("method conf_enum_ports")] HRESULT conf_enum_ports([out,retval] SAFEARRAY(int) *pPortsArray); + [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); }; [ @@ -84,6 +93,7 @@ library ACTIVEPJSUALib struct Pjsua_Call_Info; struct Pjsua_Buddy_Info; struct Pjsua_Acc_Info; + struct Pjsua_Conf_Port_Info; [ uuid(DC91CBCE-4B9E-4369-80B9-39341EEFD814), @@ -94,10 +104,11 @@ library ACTIVEPJSUALib properties: methods: [id(1), helpstring("method OnCallState")] void OnCallState([in] int call_index, [in] Pjsua_Call_Info *pInfo); - [id(2), helpstring("method OnRegState")] void OnRegState([in] int acc_index); + [id(2), helpstring("method OnRegState")] void OnRegState([in] int acc_id); [id(3), helpstring("method OnBuddyState")] void OnBuddyState([in] int buddy_index); [id(4), helpstring("method OnIncomingPager")] void OnIncomingPager([in] int call_index, [in] BSTR fromUri, [in] BSTR toURI, [in] BSTR pagerText); [id(5), helpstring("method OnTypingIndication")] void OnTypingIndication([in] int call_index, [in] BSTR fromUri, [in] BSTR toURI, [in] int isTyping); + [id(6), helpstring("method OnIncomingCall")] void OnIncomingCall([in] int call_index); }; [ diff --git a/pjsip-apps/src/activex-pjsua/activex-pjsuaCP.h b/pjsip-apps/src/activex-pjsua/activex-pjsuaCP.h index db150156..b9aaea41 100644 --- a/pjsip-apps/src/activex-pjsua/activex-pjsuaCP.h +++ b/pjsip-apps/src/activex-pjsua/activex-pjsuaCP.h @@ -2,6 +2,7 @@ #define _ACTIVEXPJSUACP_H_ //#import "C:\project\pjproject\pjsip-apps\src\activex-pjsua\activex-pjsua.tlb" raw_interfaces_only, raw_native_types, no_namespace, named_guids //"Import typelib" + template <class T> class CProxy_IPjsuaEvents : public IConnectionPointImpl<T, &DIID__IPjsuaEvents, CComDynamicUnkArray> { @@ -147,5 +148,28 @@ public: delete[] pvars; } + VOID Fire_OnIncomingCall(INT call_index) + { + T* pT = static_cast<T*>(this); + int nConnectionIndex; + CComVariant* pvars = new CComVariant[1]; + int nConnections = m_vec.GetSize(); + + for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++) + { + pT->Lock(); + CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex); + pT->Unlock(); + IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p); + if (pDispatch != NULL) + { + pvars[0] = call_index; + DISPPARAMS disp = { pvars, NULL, 1, 0 }; + pDispatch->Invoke(0x6, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL); + } + } + delete[] pvars; + + } }; #endif
\ No newline at end of file diff --git a/pjsip-apps/src/activex-pjsua/app.cpp b/pjsip-apps/src/activex-pjsua/app.cpp index bbcb9a38..6686279d 100644 --- a/pjsip-apps/src/activex-pjsua/app.cpp +++ b/pjsip-apps/src/activex-pjsua/app.cpp @@ -13,6 +13,10 @@ static const GUID IID_Pjsip_Cred_Info = { 0x9ce3052a, 0x7a32, 0x4229, { 0xb3, 0x1c, 0x5e, 0x2, 0xe0, 0x66, 0x7a, 0x77 } }; +// {7F6CFF0F-C5B3-41e8-B278-61CD584C1F34} +static const GUID IID_Pjsip_Sip_Uri = +{ 0x7f6cff0f, 0xc5b3, 0x41e8, { 0xb2, 0x78, 0x61, 0xcd, 0x58, 0x4c, 0x1f, 0x34 } }; + // {3B12B04F-6E48-46a7-B9E0-6C4BF1594A96} static const GUID IID_Pjsua_Acc_Config = { 0x3b12b04f, 0x6e48, 0x46a7, { 0xb9, 0xe0, 0x6c, 0x4b, 0xf1, 0x59, 0x4a, 0x96 } }; @@ -33,6 +37,11 @@ static const GUID IID_Pjsua_Buddy_Info = static const GUID IID_Pjsua_Acc_Info = { 0x8d345956, 0x10b7, 0x4450, { 0x8a, 0x6, 0xa8, 0xd, 0x2f, 0x31, 0x9e, 0xfd } }; +// {0D05907A-3E1F-4c92-9FD0-26CB6E1CC56A} +static const GUID IID_Pjsua_Conf_Port_Info = +{ 0xd05907a, 0x3e1f, 0x4c92, { 0x9f, 0xd0, 0x26, 0xcb, 0x6e, 0x1c, 0xc5, 0x6a } }; + + #define SA_SIZE(lbound,ubound) (ubound-lbound) @@ -117,7 +126,7 @@ static void SafeStringArray2pjstrarray(pj_pool_t *pool, else { *count = 0; for (i=0; i<sa->cbElements; ++i) { - BSTR str; + BSTR str = NULL; long rg = lbound + i; hr = SafeArrayGetElement(sa, &rg, &str); if (FAILED(hr)) @@ -174,6 +183,7 @@ static void AccConfig2accconfig(pj_pool_t *pool, for (i=0; i<c1->cred_info->cbElements; ++i) { Pjsip_Cred_Info cred_info; long rg = lbound + i; + pj_memset(&cred_info, 0, sizeof(cred_info)); hr = SafeArrayGetElement(c1->cred_info, &rg, &cred_info); if (FAILED(hr)) break; @@ -244,6 +254,7 @@ static HRESULT Config2config(pj_pool_t *pool, Pjsua_Config *c1, pjsua_config *c2 c2->sip_host = Pj_str(pool, c1->sip_host); c2->sip_port = c1->sip_port; c2->start_rtp_port = c1->rtp_port; + c2->msg_logging = c1->msg_logging; c2->max_calls = c1->max_calls; c2->conf_ports = c1->conf_ports; c2->thread_cnt = c1->thread_cnt; @@ -280,6 +291,7 @@ static HRESULT Config2config(pj_pool_t *pool, Pjsua_Config *c1, pjsua_config *c2 for (i=0; i<c1->acc_config->cbElements; ++i) { Pjsua_Acc_Config acc_config; long rg = lbound + i; + pj_memset(&acc_config, 0, sizeof(acc_config)); hr = SafeArrayGetElement(c1->acc_config, &rg, &acc_config); if (FAILED(hr)) break; @@ -311,6 +323,7 @@ static HRESULT config2Config(pjsua_config *c1, Pjsua_Config *c2) Cp(c2->sip_host, &c1->sip_host); c2->sip_port = c1->sip_port; c2->rtp_port = c1->start_rtp_port; + c2->msg_logging = c1->msg_logging; c2->max_calls = c1->max_calls; c2->conf_ports = c1->conf_ports; c2->thread_cnt = c1->thread_cnt; @@ -386,8 +399,8 @@ static void callinfo2CallInfo(pjsua_call_info *c1, Pjsua_Call_Info *c2) Cp(c2->state_text, &c1->state_text); c2->connect_duration = c1->connect_duration.sec; c2->total_duration = c1->total_duration.sec; - c2->cause = c1->cause; - Cp(c2->cause_text, &c1->cause_text); + c2->last_status = c1->last_status; + Cp(c2->last_status_text, &c1->last_status_text); c2->has_media = c1->has_media; c2->conf_slot = c1->conf_slot; } @@ -397,7 +410,7 @@ static void accinfo2AccInfo(pjsua_acc_info *info1, Pjsua_Acc_Info *info2) pj_memset(info2, 0, sizeof(Pjsua_Acc_Info)); info2->index = info1->index; - Cp(info2->acc_id, &info1->acc_id); + Cp(info2->acc_uri, &info1->acc_id); info2->has_registration = info1->has_registration; info2->expires = info1->expires; info2->status_code = info1->status; @@ -419,7 +432,6 @@ static void buddyinfo2BuddyInfo(pjsua_buddy_info *info1, Pjsua_Buddy_Info *info2 info2->status = (Pjsua_Buddy_State)info1->status; Cp(info2->status_text, &info1->status_text); info2->monitor = info1->monitor; - info2->acc_index = info1->acc_index; } static CApp *CApp_Instance; @@ -463,15 +475,21 @@ static void on_call_state(int call_index, pjsip_event *e) pjsua_call_info call_info; Pjsua_Call_Info *Call_Info = new Pjsua_Call_Info; - pjsua_get_call_info(call_index, &call_info); + pjsua_call_get_info(call_index, &call_info); callinfo2CallInfo(&call_info, Call_Info); CApp_Instance->Fire_OnCallState(call_index, Call_Info); } -static void on_reg_state(int acc_index) +static void on_incoming_call(int acc_id, int call_index, + pjsip_rx_data *rdata) { - CApp_Instance->Fire_OnRegState(acc_index); + CApp_Instance->Fire_OnIncomingCall(call_index); +} + +static void on_reg_state(int acc_id) +{ + CApp_Instance->Fire_OnRegState(acc_id); } static void on_buddy_state(int buddy_index) @@ -512,6 +530,7 @@ STDMETHODIMP CApp::app_init(Pjsua_Config *pConfig, Pj_Status *pStatus) pj_memset(&cb, 0, sizeof(cb)); cb.on_call_state = &on_call_state; + cb.on_incoming_call = &on_incoming_call; cb.on_reg_state = &on_reg_state; cb.on_buddy_state = &on_buddy_state; cb.on_pager = &on_pager; @@ -539,13 +558,13 @@ STDMETHODIMP CApp::app_destroy(Pj_Status *retStatus) STDMETHODIMP CApp::call_get_max_count(int *retCount) { - *retCount = pjsua_get_max_calls(); + *retCount = pjsua_call_get_max_count(); return S_OK; } STDMETHODIMP CApp::call_get_count(int *retCount) { - *retCount = pjsua_get_call_count(); + *retCount = pjsua_call_get_count(); return S_OK; } @@ -564,24 +583,23 @@ STDMETHODIMP CApp::call_has_media(int call_index, Pj_Bool *pRet) STDMETHODIMP CApp::call_get_info(int call_index, Pjsua_Call_Info *pInfo, Pj_Status *pRet) { pjsua_call_info info; - *pRet = pjsua_get_call_info(call_index, &info); + *pRet = pjsua_call_get_info(call_index, &info); callinfo2CallInfo(&info, pInfo); return S_OK; } -STDMETHODIMP CApp::call_make_call(int acc_index, Pj_String dst_uri, int *call_index, Pj_Status *pRet) +STDMETHODIMP CApp::call_make_call(int acc_id, Pj_String dst_uri, int *call_index, Pj_Status *pRet) { Temp_Pool tp; pj_str_t tmp = Pj_str(tp.get_pool(), dst_uri); - *pRet = pjsua_make_call(acc_index, &tmp, call_index); + *pRet = pjsua_call_make_call(acc_id, &tmp, call_index); return S_OK; } STDMETHODIMP CApp::call_answer(int call_index, int status_code, Pj_Status *pRet) { - pjsua_call_answer(call_index, status_code); - *pRet = PJ_SUCCESS; + *pRet = pjsua_call_answer(call_index, status_code); return S_OK; } @@ -601,8 +619,7 @@ STDMETHODIMP CApp::call_set_hold(int call_index, Pj_Status *pRet) STDMETHODIMP CApp::call_release_hold(int call_index, Pj_Status *pRet) { - pjsua_call_reinvite(call_index); - *pRet = PJ_SUCCESS; + *pRet = pjsua_call_reinvite(call_index); return S_OK; } @@ -610,8 +627,7 @@ STDMETHODIMP CApp::call_xfer(int call_index, Pj_String dst_uri, Pj_Status *pRet) { Temp_Pool tp; pj_str_t tmp = Pj_str(tp.get_pool(), dst_uri); - pjsua_call_xfer(call_index, &tmp); - *pRet = PJ_SUCCESS; + *pRet = pjsua_call_xfer(call_index, &tmp); return S_OK; } @@ -627,15 +643,13 @@ STDMETHODIMP CApp::call_send_im(int call_index, Pj_String text, Pj_Status *pRet) { Temp_Pool tp; pj_str_t tmp = Pj_str(tp.get_pool(), text); - pjsua_call_send_im(call_index, &tmp); - *pRet = PJ_SUCCESS; + *pRet = pjsua_call_send_im(call_index, &tmp); return S_OK; } STDMETHODIMP CApp::call_typing(int call_index, int is_typing, Pj_Status *pRet) { - pjsua_call_typing(call_index, is_typing); - *pRet = PJ_SUCCESS; + *pRet = pjsua_call_send_typing_ind(call_index, is_typing); return S_OK; } @@ -648,7 +662,7 @@ STDMETHODIMP CApp::call_hangup_all() STDMETHODIMP CApp::call_get_textstat(int call_index, BSTR *textstat) { char buf[1024]; - pjsua_dump_call(call_index, 1, buf, sizeof(buf), ""); + pjsua_call_dump(call_index, 1, buf, sizeof(buf), ""); OLECHAR wbuf[1024]; pj_ansi_to_unicode(buf, strlen(buf), wbuf, PJ_ARRAY_SIZE(wbuf)); @@ -663,10 +677,10 @@ STDMETHODIMP CApp::acc_get_count(int *pCount) return S_OK; } -STDMETHODIMP CApp::acc_get_info(int acc_index, Pjsua_Acc_Info *pInfo, Pj_Status *pRet) +STDMETHODIMP CApp::acc_get_info(int acc_id, Pjsua_Acc_Info *pInfo, Pj_Status *pRet) { pjsua_acc_info info; - *pRet = pjsua_acc_get_info(acc_index, &info); + *pRet = pjsua_acc_get_info(acc_id, &info); accinfo2AccInfo(&info, pInfo); return S_OK; } @@ -680,15 +694,15 @@ STDMETHODIMP CApp::acc_add(Pjsua_Acc_Config *pConfig, int *pAcc_Index, Pj_Status return S_OK; } -STDMETHODIMP CApp::acc_set_online_status(int acc_index, int is_online, Pj_Status *pRet) +STDMETHODIMP CApp::acc_set_online_status(int acc_id, int is_online, Pj_Status *pRet) { - *pRet = pjsua_acc_set_online_status(acc_index, is_online); + *pRet = pjsua_acc_set_online_status(acc_id, is_online); return S_OK; } -STDMETHODIMP CApp::acc_set_registration(int acc_index, int reg_active, Pj_Status *pRet) +STDMETHODIMP CApp::acc_set_registration(int acc_id, int reg_active, Pj_Status *pRet) { - *pRet = pjsua_acc_set_registration(acc_index, reg_active); + *pRet = pjsua_acc_set_registration(acc_id, reg_active); return S_OK; } @@ -717,24 +731,23 @@ STDMETHODIMP CApp::buddy_add(Pj_String uri, int *pBuddy_Index, Pj_Status *pRet) STDMETHODIMP CApp::buddy_subscribe_pres(int buddy_index, int subscribe, Pj_Status *pRet) { *pRet = pjsua_buddy_subscribe_pres(buddy_index, subscribe); - pjsua_pres_refresh(); return S_OK; } -STDMETHODIMP CApp::im_send_text(int acc_index, Pj_String dst_uri, Pj_String text, Pj_Status *pRet) +STDMETHODIMP CApp::im_send_text(int acc_id, Pj_String dst_uri, Pj_String text, Pj_Status *pRet) { Temp_Pool tp; pj_str_t tmp_uri = Pj_str(tp.get_pool(), dst_uri); pj_str_t tmp_text = Pj_str(tp.get_pool(), text); - *pRet = pjsua_im_send(acc_index, &tmp_uri, &tmp_text); + *pRet = pjsua_im_send(acc_id, &tmp_uri, &tmp_text); return S_OK; } -STDMETHODIMP CApp::im_typing(int acc_index, Pj_URI dst_uri, int is_typing, Pj_Status *pRet) +STDMETHODIMP CApp::im_typing(int acc_id, Pj_URI dst_uri, int is_typing, Pj_Status *pRet) { Temp_Pool tp; pj_str_t tmp_uri = Pj_str(tp.get_pool(), dst_uri); - *pRet = pjsua_im_typing(acc_index, &tmp_uri, is_typing); + *pRet = pjsua_im_typing(acc_id, &tmp_uri, is_typing); return S_OK; } @@ -802,7 +815,7 @@ STDMETHODIMP CApp::app_load_config(Pj_String filename, Pjsua_Config *pConfig, Pj Temp_Pool tp; pj_str_t tmp = Pj_str(tp.get_pool(), filename); pjsua_default_config(&config); - *pRet = pjsua_load_settings(tmp.ptr, &config); + *pRet = pjsua_load_settings(tmp.ptr, &config, NULL); if (*pRet == PJ_SUCCESS) *pRet = config2Config(&config, pConfig); return S_OK; @@ -825,9 +838,11 @@ STDMETHODIMP CApp::app_save_config(Pj_String filename, Pjsua_Config *pConfig, Pj STDMETHODIMP CApp::app_get_current_config(Pjsua_Config *pConfig) { - pjsua_config *config; - config = (pjsua_config*) pjsua_get_config(); - return config2Config(config, pConfig); + Temp_Pool tp; + pjsua_config config; + + pjsua_get_config(tp.get_pool(), &config); + return config2Config(&config, pConfig); } STDMETHODIMP CApp::app_get_error_msg(Pj_Status status, BSTR * pRet) @@ -856,3 +871,195 @@ STDMETHODIMP CApp::app_handle_events(int msec_timeout, int *pEvCount) *pEvCount = pjsua_handle_events(msec_timeout); return S_OK; } + +STDMETHODIMP CApp::app_parse_uri(BSTR uriString, Pjsip_Sip_Uri *pSipUri, Pj_Status *pStatus) +{ + Temp_Pool tp; + pj_str_t tmp = Pj_str(tp.get_pool(), uriString); + pjsip_name_addr *addr; + char buf[1024]; + pj_str_t s; + + addr = (pjsip_name_addr*) + pjsip_parse_uri(tp.get_pool(), tmp.ptr, tmp.slen, PJSIP_PARSE_URI_AS_NAMEADDR); + if (addr == NULL) { + *pStatus = PJSIP_EINVALIDURI; + return S_OK; + } + + if (!PJSIP_URI_SCHEME_IS_SIP(addr) && !PJSIP_URI_SCHEME_IS_SIPS(addr)) { + *pStatus = PJSIP_EINVALIDSCHEME; + return S_OK; + } + + pjsip_sip_uri *sip = (pjsip_sip_uri*)addr->uri; + + Cp2(&pSipUri->display, &addr->display); + Cp2(&pSipUri->user, &sip->user); + Cp2(&pSipUri->passwd, &sip->passwd); + Cp2(&pSipUri->host, &sip->host); + pSipUri->port = sip->port; + Cp2(&pSipUri->param_user, &sip->user_param); + Cp2(&pSipUri->param_method, &sip->method_param); + Cp2(&pSipUri->param_transport, &sip->transport_param); + pSipUri->param_ttl = sip->ttl_param; + pSipUri->param_lr = sip->lr_param; + Cp2(&pSipUri->param_maddr, &sip->maddr_param); + + s.ptr = buf; + s.slen = pjsip_param_print_on(&sip->other_param, buf, sizeof(buf), + &pjsip_PARAM_CHAR_SPEC, &pjsip_PARAM_CHAR_SPEC, ';'); + Cp2(&pSipUri->param_other, &s); + + s.slen = pjsip_param_print_on(&sip->header_param, buf, sizeof(buf), + &pjsip_HDR_CHAR_SPEC, &pjsip_HDR_CHAR_SPEC, '?'); + Cp2(&pSipUri->param_header, &s); + + *pStatus = PJ_SUCCESS; + return S_OK; +} + +STDMETHODIMP CApp::app_print_uri(Pjsip_Sip_Uri *pSipURI, Pjsip_Uri_Context context, BSTR *uriText) +{ + Temp_Pool tp; + pjsip_name_addr *addr; + pj_str_t tmp; + char buf[1024]; + pjsip_sip_uri *sip; + + addr = pjsip_name_addr_create(tp.get_pool()); + sip = pjsip_sip_uri_create(tp.get_pool(), PJ_FALSE); + addr->uri = (pjsip_uri*)sip; + + addr->display = Pj_str(tp.get_pool(), pSipURI->display); + sip->user = Pj_str(tp.get_pool(), pSipURI->user); + sip->passwd = Pj_str(tp.get_pool(), pSipURI->passwd); + sip->host = Pj_str(tp.get_pool(), pSipURI->host); + sip->port = pSipURI->port; + sip->user_param = Pj_str(tp.get_pool(), pSipURI->param_user); + sip->method_param = Pj_str(tp.get_pool(), pSipURI->param_method); + sip->transport_param = Pj_str(tp.get_pool(), pSipURI->param_transport); + sip->ttl_param = pSipURI->param_ttl; + sip->lr_param = pSipURI->param_lr; + sip->maddr_param = Pj_str(tp.get_pool(), pSipURI->param_maddr); + + /* Unfortunately can't transport params yet (no parsing function) */ + + tmp.ptr = buf; + tmp.slen = pjsip_uri_print((pjsip_uri_context_e)context, addr, buf, sizeof(buf)); + + Cp2(uriText, &tmp); + return S_OK; +} + +STDMETHODIMP CApp::app_compare_uri_string(Pjsip_Uri_Context context, BSTR uri1, BSTR uri2, Pj_Status *pStatus) +{ + Temp_Pool tp; + + pj_str_t tmp_uri1 = Pj_str(tp.get_pool(), uri1); + pj_str_t tmp_uri2 = Pj_str(tp.get_pool(), uri2); + + pjsip_uri *u1, *u2; + + u1 = pjsip_parse_uri(tp.get_pool(), tmp_uri1.ptr, tmp_uri1.slen, PJSIP_PARSE_URI_AS_NAMEADDR); + if (u1 == NULL) { + *pStatus = PJSIP_EINVALIDURI; + return S_OK; + } + + u2 = pjsip_parse_uri(tp.get_pool(), tmp_uri2.ptr, tmp_uri2.slen, PJSIP_PARSE_URI_AS_NAMEADDR); + if (u2 == NULL) { + *pStatus = PJSIP_EINVALIDURI; + return S_OK; + } + + *pStatus = pjsip_uri_cmp((pjsip_uri_context_e)context, u1, u2); + return S_OK; +} + +STDMETHODIMP CApp::buddy_del(int buddy_index, Pj_Status *pRet) +{ + *pRet = pjsua_buddy_del(buddy_index); + return S_OK; +} + +STDMETHODIMP CApp::acc_del(int acc_id, Pj_Status *pRet) +{ + *pRet = pjsua_acc_del(acc_id); + return S_OK; +} + +STDMETHODIMP CApp::acc_find_for_outgoing(BSTR url, int *acc_id) +{ + Temp_Pool tp; + + pj_str_t tmp_uri = Pj_str(tp.get_pool(), url); + + *acc_id = pjsua_acc_find_for_outgoing(&tmp_uri); + + return S_OK; +} + +STDMETHODIMP CApp::acc_enum_id(SAFEARRAY **accIdArray) +{ + int id[32]; + unsigned count = PJ_ARRAY_SIZE(id); + unsigned i; + + pjsua_acc_enum_id(id, &count); + + *accIdArray = SafeArrayCreateVector(VT_INT, 0, count); + + for (i=0; i<count; ++i) { + long rg = i; + SafeArrayPutElement(*accIdArray, &rg, &id[i]); + } + + return S_OK; +} + +STDMETHODIMP CApp::conf_enum_ports(SAFEARRAY **pPortsArray) +{ + int id[128]; + unsigned count = PJ_ARRAY_SIZE(id); + unsigned i; + + pjsua_conf_enum_port_ids(id, &count); + + *pPortsArray = SafeArrayCreateVector(VT_INT, 0, count); + + for (i=0; i<count; ++i) { + long rg = i; + SafeArrayPutElement(*pPortsArray, &rg, &id[i]); + } + + return S_OK; +} + +STDMETHODIMP CApp::conf_get_port_info(int port_id, Pjsua_Conf_Port_Info *pInfo, Pj_Status *pRet) +{ + unsigned i; + pjsua_conf_port_info info; + + *pRet = pjsua_conf_get_port_info(port_id, &info); + if (*pRet != PJ_SUCCESS) + return S_OK; + + pInfo->slot_id = info.slot_id; + Cp2(&pInfo->name, &info.name); + pInfo->clock_rate = info.clock_rate; + pInfo->channel_count = info.channel_count; + pInfo->samples_per_frame = info.samples_per_frame; + pInfo->bits_per_sample = info.bits_per_sample; + + + pInfo->listeners = SafeArrayCreateVector(VT_INT, 0, info.listener_cnt); + + for (i=0; i<info.listener_cnt; ++i) { + long rg = i; + SafeArrayPutElement(pInfo->listeners, &rg, &info.listeners[i]); + } + + return S_OK; +} + diff --git a/pjsip-apps/src/activex-pjsua/app.h b/pjsip-apps/src/activex-pjsua/app.h index ba0f9971..1c8483a5 100644 --- a/pjsip-apps/src/activex-pjsua/app.h +++ b/pjsip-apps/src/activex-pjsua/app.h @@ -4,7 +4,7 @@ #define __APP_H_ #include "resource.h" // main symbols -#include "..\activex-pjsua\activex-pjsuaCP.h" +#include "activex-pjsuaCP.h" ///////////////////////////////////////////////////////////////////////////// @@ -37,6 +37,15 @@ END_CONNECTION_POINT_MAP() // IApp public: + STDMETHOD(app_destroy)(/*[out,retval]*/ Pj_Status *retStatus); + STDMETHOD(app_start)(/*[out,retval]*/ Pj_Status *retStatus); + STDMETHOD(app_init)(/*[in]*/ Pjsua_Config *pConfig, /*[out,retval]*/ Pj_Status *pStatus); + STDMETHOD(app_test_config)(/*[in]*/ Pjsua_Config *pConfig, /*[out,retval,string]*/ BSTR *retmsg); + STDMETHOD(app_default_config)(/*[in,out]*/ Pjsua_Config *pConfig); + STDMETHOD(app_create)(/*[out,retval]*/ Pj_Status *ret); + STDMETHOD(app_compare_uri_string)(/*[in]*/ Pjsip_Uri_Context context, /*[in]*/ BSTR uri1, /*[in]*/ BSTR uri2, /*[out,retval]*/ Pj_Status *pStatus); + STDMETHOD(app_print_uri)(/*[in]*/ Pjsip_Sip_Uri *pSipURI, Pjsip_Uri_Context context, /*[out,retval]*/ BSTR *uriText); + STDMETHOD(app_parse_uri)(/*[in]*/ BSTR uriString, /*[out]*/ Pjsip_Sip_Uri *pSipUri, /*[out,retval]*/ Pj_Status *pStatus); STDMETHOD(app_handle_events)(/*[in]*/ int msec_timeout, /*[out,retval]*/ int *pEvCount); STDMETHOD(app_verify_sip_url)(/*[in,string]*/ Pj_String uri, /*[out,retval]*/ Pj_Status *pRet); STDMETHOD(app_get_error_msg)(/*[in]*/ Pj_Status status, /*[out,retval]*/ BSTR * errmsg); @@ -52,17 +61,23 @@ public: STDMETHOD(player_create)(/*[in,string]*/ Pj_String filename, /*[out]*/ int *pPlayer_Id, /*[out,retval]*/ Pj_Status *pRet); STDMETHOD(conf_disconnect)(/*[in]*/ int src_port, /*[in]*/ int sink_port, /*[out,retval]*/ Pj_Status *pRet); STDMETHOD(conf_connect)(/*[in]*/ int src_port, /*[in]*/ int sink_port, /*[out,retval]*/ Pj_Status *pRet); + STDMETHOD(conf_enum_ports)(SAFEARRAY **pPortsArray); + STDMETHOD(conf_get_port_info)(int port_id, Pjsua_Conf_Port_Info *pInfo, Pj_Status *pRet); STDMETHOD(im_typing)(/*[in]*/ int acc_index, /*[in,string]*/ Pj_URI dst_uri, /*[in]*/ int is_typing, /*[out,retval]*/ Pj_Status *pRet); STDMETHOD(im_send_text)(/*[in]*/ int acc_index, /*[in,string]*/ Pj_String dst_uri, /*[in,string]*/ Pj_String text, /*[out,retval]*/ Pj_Status *pRet); STDMETHOD(buddy_subscribe_pres)(/*[in]*/ int buddy_index, /*[in]*/ int subscribe, /*[out,retval]*/ Pj_Status *pRet); STDMETHOD(buddy_add)(/*[in,string]*/ Pj_String uri, /*[out]*/ int *pBuddy_Index, /*[out,retval]*/ Pj_Status *pRet); STDMETHOD(buddy_get_info)(/*[in]*/ int buddy_index, /*[out]*/ Pjsua_Buddy_Info *pInfo, /*[out,retval]*/ Pj_Status *pRet); STDMETHOD(buddy_get_count)(/*[out,retval]*/ int *pCount); + STDMETHOD(buddy_del)(/*[in]*/ int buddy_index, /*[out,retval]*/ Pj_Status *pRet); STDMETHOD(acc_set_registration)(/*[in]*/ int acc_index, /*[in]*/ int reg_active, /*[out,retval]*/ Pj_Status *pRet); STDMETHOD(acc_set_online_status)(/*[in]*/ int acc_index, /*[in]*/ int is_online, /*[out,retval]*/ Pj_Status *pRet); STDMETHOD(acc_add)(/*[in]*/ Pjsua_Acc_Config *pConfig, /*[out]*/ int *pAcc_Index, /*[out,retval]*/ Pj_Status *pRet); + STDMETHOD(acc_del)(/*[out,retval]*/ int acc_index, Pj_Status *pRet); STDMETHOD(acc_get_info)(/*[in]*/ int acc_index, /*[out]*/ Pjsua_Acc_Info *pInfo, /*[out,retval]*/ Pj_Status *pRet); STDMETHOD(acc_get_count)(/*[out,retval]*/ int *pCount); + STDMETHOD(acc_enum_id)(SAFEARRAY **accIdArray); + STDMETHOD(acc_find_for_outgoing)(/*[in]*/ BSTR url, /*[out,retval]*/ int *acc_index); STDMETHOD(call_hangup_all)(); STDMETHOD(call_typing)(/*[in]*/ int call_index, /*[in]*/ int is_typing, /*[out,retval]*/ Pj_Status *pRet); STDMETHOD(call_send_im)(/*[in]*/ int call_index, /*[in,string]*/ Pj_String text, /*[out,retval]*/ Pj_Status *pRet); @@ -78,12 +93,6 @@ public: STDMETHOD(call_is_active)(/*[in]*/ int call_index, /*[out,retval]*/ Pj_Bool *retVal); STDMETHOD(call_get_count)(/*[out,retval]*/ int *retCount); STDMETHOD(call_get_max_count)(/*[out,retval]*/ int *retCount); - STDMETHOD(app_destroy)(/*[out,retval]*/ Pj_Status *retStatus); - STDMETHOD(app_start)(/*[out,retval]*/ Pj_Status *retStatus); - STDMETHOD(app_init)(/*[in]*/ Pjsua_Config *pConfig, /*[out,retval]*/ Pj_Status *pStatus); - STDMETHOD(app_test_config)(/*[in]*/ Pjsua_Config *pConfig, /*[out,retval,string]*/ BSTR *retmsg); - STDMETHOD(app_default_config)(/*[in,out]*/ Pjsua_Config *pConfig); - STDMETHOD(app_create)(/*[out,retval]*/ Pj_Status *ret); STDMETHOD(call_get_textstat)(/* [in] */ int call_index, /* [retval][out] */ BSTR *textstat); }; diff --git a/pjsip-apps/src/activex-pjsua/pjsua-structs.idl b/pjsip-apps/src/activex-pjsua/pjsua-structs.idl index 1c90742f..e41f6711 100644 --- a/pjsip-apps/src/activex-pjsua/pjsua-structs.idl +++ b/pjsip-apps/src/activex-pjsua/pjsua-structs.idl @@ -23,6 +23,39 @@ typedef struct Pjsip_Cred_Info [ + uuid(7F6CFF0F-C5B3-41e8-B278-61CD584C1F34), + version(1.0), + helpstring("PJSIP SIP URI"), +] +typedef struct Pjsip_Sip_Uri +{ + Pj_String display; + Pj_String user; + Pj_String passwd; + Pj_String host; + int port; + Pj_String param_user; + Pj_String param_method; + Pj_String param_transport; + int param_ttl; + int param_lr; + Pj_String param_maddr; + Pj_String param_other; + Pj_String param_header; +} Pjsip_Sip_Uri; + + +typedef enum Pjsip_Uri_Context +{ + PJSIPX_URI_IN_REQ_URI, + PJSIPX_URI_IN_FROMTO_HDR, + PJSIPX_URI_IN_CONTACT_HDR, + PJSIPX_URI_IN_ROUTING_HDR, + PJSIPX_URI_IN_OTHER +} Pjsip_Uri_Context; + + +[ uuid(3B12B04F-6E48-46a7-B9E0-6C4BF1594A96), version(1.0), helpstring("PJSUA Account configuration"), @@ -44,33 +77,34 @@ typedef struct Pjsua_Acc_Config ] typedef struct Pjsua_Config { - unsigned int udp_port; - Pj_String sip_host; - unsigned int sip_port; - unsigned int rtp_port; - unsigned int max_calls; - unsigned int conf_ports; - unsigned int thread_cnt; - Pj_String stun_srv1; - unsigned int stun_port1; - Pj_String stun_srv2; - unsigned int stun_port2; - unsigned int snd_player_id; - unsigned int snd_capture_id; - unsigned int clock_rate; - Pj_Bool null_audio; - unsigned int quality; - unsigned int complexity; - SAFEARRAY(Pj_String) codec_arg; - unsigned int auto_answer; - unsigned int uas_refresh; - Pj_String outbound_proxy; + int udp_port; + Pj_String sip_host; + int sip_port; + int rtp_port; + int msg_logging; + int max_calls; + int conf_ports; + int thread_cnt; + Pj_String stun_srv1; + int stun_port1; + Pj_String stun_srv2; + int stun_port2; + int snd_player_id; + int snd_capture_id; + int clock_rate; + Pj_Bool null_audio; + int quality; + int complexity; + SAFEARRAY(Pj_String) codec_arg; + int auto_answer; + int uas_refresh; + Pj_String outbound_proxy; SAFEARRAY(Pjsua_Acc_Config) acc_config; - unsigned int log_level; - unsigned int app_log_level; - unsigned long log_decor; - Pj_String log_filename; - SAFEARRAY(Pj_String) buddy_uri; + int log_level; + int app_log_level; + long log_decor; + Pj_String log_filename; + SAFEARRAY(Pj_String) buddy_uri; } Pjsua_Config; @@ -93,19 +127,19 @@ typedef enum Pjsua_Call_State ] typedef struct Pjsua_Call_Info { - unsigned int index; + int index; Pj_Bool active; Pj_Bool is_uac; Pj_String local_info; Pj_String remote_info; Pjsua_Call_State state; Pj_String state_text; - unsigned int connect_duration; - unsigned int total_duration; - unsigned int cause; - Pj_String cause_text; + int connect_duration; + int total_duration; + int last_status; + Pj_String last_status_text; Pj_Bool has_media; - unsigned int conf_slot; + int conf_slot; } Pjsua_Call_Info; @@ -124,17 +158,16 @@ typedef enum Pjsua_Buddy_State ] typedef struct Pjsua_Buddy_Info { - unsigned int index; + int index; Pj_Bool is_valid; Pj_String name; Pj_String display; Pj_String host; - unsigned int port; + int port; Pj_URI uri; Pjsua_Buddy_State status; Pj_String status_text; Pj_Bool monitor; - int acc_index; } Pjsua_Buddy_Info; @@ -145,12 +178,30 @@ typedef struct Pjsua_Buddy_Info ] typedef struct Pjsua_Acc_Info { - unsigned int index; - Pj_URI acc_id; + int index; + Pj_URI acc_uri; Pj_Bool has_registration; int expires; - unsigned int status_code; + int status_code; Pj_String status_text; Pj_Bool online_status; } Pjsua_Acc_Info; + + +[ + uuid(0D05907A-3E1F-4c92-9FD0-26CB6E1CC56A), + version(1.0), + helpstring("PJSUA Conference Port Information"), +] +typedef struct Pjsua_Conf_Port_Info +{ + int slot_id; + Pj_String name; + int clock_rate; + int channel_count; + int samples_per_frame; + int bits_per_sample; + SAFEARRAY(int) listeners; +} Pjsua_Conf_Port_Info; + diff --git a/pjsip-apps/src/pjsua/main.c b/pjsip-apps/src/pjsua/main.c index 03e5eb6c..b5774e73 100644 --- a/pjsip-apps/src/pjsua/main.c +++ b/pjsip-apps/src/pjsua/main.c @@ -28,6 +28,7 @@ int main(int argc, char *argv[]) { pjsua_config cfg; + pj_str_t uri_to_call = { NULL, 0 }; /* Init default settings. */ pjsua_default_config(&cfg); @@ -38,7 +39,7 @@ int main(int argc, char *argv[]) /* Parse command line arguments: */ - if (pjsua_parse_args(argc, argv, &cfg) != PJ_SUCCESS) + if (pjsua_parse_args(argc, argv, &cfg, &uri_to_call) != PJ_SUCCESS) return 1; @@ -46,12 +47,6 @@ int main(int argc, char *argv[]) if (pjsua_init(&cfg, &console_callback) != PJ_SUCCESS) return 1; - /* Register message logger to print incoming and outgoing - * messages. - */ - pjsip_endpt_register_module(pjsua_get_pjsip_endpt(), - &pjsua_console_app_msg_logger); - /* Start pjsua! */ if (pjsua_start() != PJ_SUCCESS) { @@ -65,7 +60,7 @@ int main(int argc, char *argv[]) /* Start UI console main loop: */ - pjsua_console_app_main(); + pjsua_console_app_main(&uri_to_call); /* Destroy pjsua: */ |