Ignore:
Timestamp:
Jun 6, 2006 6:40:40 PM (18 years ago)
Author:
bennylp
Message:

Another huge chunks of modifications in PJSUA API, too many things to mention!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/activex-pjsua/app.cpp

    r487 r492  
    1414{ 0x9ce3052a, 0x7a32, 0x4229, { 0xb3, 0x1c, 0x5e, 0x2, 0xe0, 0x66, 0x7a, 0x77 } }; 
    1515 
     16// {7F6CFF0F-C5B3-41e8-B278-61CD584C1F34} 
     17static const GUID IID_Pjsip_Sip_Uri =  
     18{ 0x7f6cff0f, 0xc5b3, 0x41e8, { 0xb2, 0x78, 0x61, 0xcd, 0x58, 0x4c, 0x1f, 0x34 } }; 
     19 
    1620// {3B12B04F-6E48-46a7-B9E0-6C4BF1594A96} 
    1721static const GUID IID_Pjsua_Acc_Config =  
     
    3337static const GUID IID_Pjsua_Acc_Info =  
    3438{ 0x8d345956, 0x10b7, 0x4450, { 0x8a, 0x6, 0xa8, 0xd, 0x2f, 0x31, 0x9e, 0xfd } }; 
     39 
     40// {0D05907A-3E1F-4c92-9FD0-26CB6E1CC56A} 
     41static const GUID IID_Pjsua_Conf_Port_Info =  
     42{ 0xd05907a, 0x3e1f, 0x4c92, { 0x9f, 0xd0, 0x26, 0xcb, 0x6e, 0x1c, 0xc5, 0x6a } }; 
     43 
    3544 
    3645#define SA_SIZE(lbound,ubound)  (ubound-lbound) 
     
    118127            *count = 0; 
    119128            for (i=0; i<sa->cbElements; ++i) { 
    120                 BSTR str; 
     129                BSTR str = NULL; 
    121130                long rg = lbound + i; 
    122131                hr = SafeArrayGetElement(sa, &rg, &str); 
     
    175184                Pjsip_Cred_Info cred_info; 
    176185                long rg = lbound + i; 
     186                pj_memset(&cred_info, 0, sizeof(cred_info)); 
    177187                hr = SafeArrayGetElement(c1->cred_info, &rg, &cred_info); 
    178188                if (FAILED(hr)) 
     
    245255    c2->sip_port = c1->sip_port; 
    246256    c2->start_rtp_port = c1->rtp_port; 
     257    c2->msg_logging = c1->msg_logging; 
    247258    c2->max_calls = c1->max_calls; 
    248259    c2->conf_ports = c1->conf_ports; 
     
    281292                Pjsua_Acc_Config acc_config; 
    282293                long rg = lbound + i; 
     294                pj_memset(&acc_config, 0, sizeof(acc_config)); 
    283295                hr = SafeArrayGetElement(c1->acc_config, &rg, &acc_config); 
    284296                if (FAILED(hr)) 
     
    312324    c2->sip_port = c1->sip_port; 
    313325    c2->rtp_port = c1->start_rtp_port; 
     326    c2->msg_logging = c1->msg_logging; 
    314327    c2->max_calls = c1->max_calls; 
    315328    c2->conf_ports = c1->conf_ports; 
     
    387400    c2->connect_duration = c1->connect_duration.sec; 
    388401    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); 
    391404    c2->has_media = c1->has_media; 
    392405    c2->conf_slot = c1->conf_slot; 
     
    398411 
    399412    info2->index = info1->index; 
    400     Cp(info2->acc_id, &info1->acc_id); 
     413    Cp(info2->acc_uri, &info1->acc_id); 
    401414    info2->has_registration = info1->has_registration; 
    402415    info2->expires = info1->expires; 
     
    420433    Cp(info2->status_text, &info1->status_text); 
    421434    info2->monitor = info1->monitor; 
    422     info2->acc_index = info1->acc_index; 
    423435} 
    424436 
     
    464476    Pjsua_Call_Info *Call_Info = new Pjsua_Call_Info; 
    465477 
    466     pjsua_get_call_info(call_index, &call_info); 
     478    pjsua_call_get_info(call_index, &call_info); 
    467479    callinfo2CallInfo(&call_info, Call_Info); 
    468480 
     
    470482} 
    471483 
    472 static void on_reg_state(int acc_index) 
    473 { 
    474     CApp_Instance->Fire_OnRegState(acc_index); 
     484static 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 
     490static void on_reg_state(int acc_id) 
     491{ 
     492    CApp_Instance->Fire_OnRegState(acc_id); 
    475493} 
    476494 
     
    513531    pj_memset(&cb, 0, sizeof(cb)); 
    514532    cb.on_call_state = &on_call_state; 
     533    cb.on_incoming_call = &on_incoming_call; 
    515534    cb.on_reg_state = &on_reg_state; 
    516535    cb.on_buddy_state = &on_buddy_state; 
     
    540559STDMETHODIMP CApp::call_get_max_count(int *retCount) 
    541560{ 
    542     *retCount = pjsua_get_max_calls(); 
     561    *retCount = pjsua_call_get_max_count(); 
    543562    return S_OK; 
    544563} 
     
    546565STDMETHODIMP CApp::call_get_count(int *retCount) 
    547566{ 
    548     *retCount = pjsua_get_call_count(); 
     567    *retCount = pjsua_call_get_count(); 
    549568    return S_OK; 
    550569} 
     
    565584{ 
    566585    pjsua_call_info info; 
    567     *pRet = pjsua_get_call_info(call_index, &info); 
     586    *pRet = pjsua_call_get_info(call_index, &info); 
    568587    callinfo2CallInfo(&info, pInfo); 
    569588    return S_OK; 
    570589} 
    571590 
    572 STDMETHODIMP CApp::call_make_call(int acc_index, Pj_String dst_uri, int *call_index, Pj_Status *pRet) 
     591STDMETHODIMP CApp::call_make_call(int acc_id, Pj_String dst_uri, int *call_index, Pj_Status *pRet) 
    573592{ 
    574593    Temp_Pool tp; 
    575594    pj_str_t tmp = Pj_str(tp.get_pool(), dst_uri); 
    576595 
    577     *pRet = pjsua_make_call(acc_index, &tmp, call_index); 
     596    *pRet = pjsua_call_make_call(acc_id, &tmp, call_index); 
    578597    return S_OK; 
    579598} 
     
    581600STDMETHODIMP CApp::call_answer(int call_index, int status_code, Pj_Status *pRet) 
    582601{ 
    583     pjsua_call_answer(call_index, status_code); 
    584     *pRet = PJ_SUCCESS; 
     602    *pRet = pjsua_call_answer(call_index, status_code); 
    585603    return S_OK; 
    586604} 
     
    602620STDMETHODIMP CApp::call_release_hold(int call_index, Pj_Status *pRet) 
    603621{ 
    604     pjsua_call_reinvite(call_index); 
    605     *pRet = PJ_SUCCESS; 
     622    *pRet = pjsua_call_reinvite(call_index); 
    606623    return S_OK; 
    607624} 
     
    611628    Temp_Pool tp; 
    612629    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); 
    615631    return S_OK; 
    616632} 
     
    628644    Temp_Pool tp; 
    629645    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); 
    632647    return S_OK; 
    633648} 
     
    635650STDMETHODIMP CApp::call_typing(int call_index, int is_typing, Pj_Status *pRet) 
    636651{ 
    637     pjsua_call_typing(call_index, is_typing); 
    638     *pRet = PJ_SUCCESS; 
     652    *pRet = pjsua_call_send_typing_ind(call_index, is_typing); 
    639653    return S_OK; 
    640654} 
     
    649663{ 
    650664    char buf[1024]; 
    651     pjsua_dump_call(call_index, 1, buf, sizeof(buf), ""); 
     665    pjsua_call_dump(call_index, 1, buf, sizeof(buf), ""); 
    652666 
    653667    OLECHAR wbuf[1024]; 
     
    664678} 
    665679 
    666 STDMETHODIMP CApp::acc_get_info(int acc_index, Pjsua_Acc_Info *pInfo, Pj_Status *pRet) 
     680STDMETHODIMP CApp::acc_get_info(int acc_id, Pjsua_Acc_Info *pInfo, Pj_Status *pRet) 
    667681{ 
    668682    pjsua_acc_info info; 
    669     *pRet = pjsua_acc_get_info(acc_index, &info); 
     683    *pRet = pjsua_acc_get_info(acc_id, &info); 
    670684    accinfo2AccInfo(&info, pInfo); 
    671685    return S_OK; 
     
    681695} 
    682696 
    683 STDMETHODIMP CApp::acc_set_online_status(int acc_index, int is_online, Pj_Status *pRet) 
    684 { 
    685     *pRet = pjsua_acc_set_online_status(acc_index, is_online); 
    686     return S_OK; 
    687 } 
    688  
    689 STDMETHODIMP CApp::acc_set_registration(int acc_index, int reg_active, Pj_Status *pRet) 
    690 { 
    691     *pRet = pjsua_acc_set_registration(acc_index, reg_active); 
     697STDMETHODIMP 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 
     703STDMETHODIMP CApp::acc_set_registration(int acc_id, int reg_active, Pj_Status *pRet) 
     704{ 
     705    *pRet = pjsua_acc_set_registration(acc_id, reg_active); 
    692706    return S_OK; 
    693707} 
     
    718732{ 
    719733    *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 
     737STDMETHODIMP CApp::im_send_text(int acc_id, Pj_String dst_uri, Pj_String text, Pj_Status *pRet) 
    725738{ 
    726739    Temp_Pool tp; 
    727740    pj_str_t tmp_uri = Pj_str(tp.get_pool(), dst_uri); 
    728741    pj_str_t tmp_text = Pj_str(tp.get_pool(), text); 
    729     *pRet = pjsua_im_send(acc_index, &tmp_uri, &tmp_text); 
    730     return S_OK; 
    731 } 
    732  
    733 STDMETHODIMP CApp::im_typing(int acc_index, 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 
     746STDMETHODIMP CApp::im_typing(int acc_id, Pj_URI dst_uri, int is_typing, Pj_Status *pRet) 
    734747{ 
    735748    Temp_Pool tp; 
    736749    pj_str_t tmp_uri = Pj_str(tp.get_pool(), dst_uri); 
    737     *pRet = pjsua_im_typing(acc_index, &tmp_uri, is_typing); 
     750    *pRet = pjsua_im_typing(acc_id, &tmp_uri, is_typing); 
    738751    return S_OK; 
    739752} 
     
    803816    pj_str_t tmp = Pj_str(tp.get_pool(), filename); 
    804817    pjsua_default_config(&config); 
    805     *pRet = pjsua_load_settings(tmp.ptr, &config); 
     818    *pRet = pjsua_load_settings(tmp.ptr, &config, NULL); 
    806819    if (*pRet == PJ_SUCCESS) 
    807820        *pRet = config2Config(&config, pConfig); 
     
    826839STDMETHODIMP CApp::app_get_current_config(Pjsua_Config *pConfig) 
    827840{ 
    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); 
    831846} 
    832847 
     
    857872    return S_OK; 
    858873} 
     874 
     875STDMETHODIMP 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 
     922STDMETHODIMP 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 
     955STDMETHODIMP 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 
     980STDMETHODIMP CApp::buddy_del(int buddy_index, Pj_Status *pRet) 
     981{ 
     982    *pRet = pjsua_buddy_del(buddy_index); 
     983    return S_OK; 
     984} 
     985 
     986STDMETHODIMP CApp::acc_del(int acc_id, Pj_Status *pRet) 
     987{ 
     988    *pRet = pjsua_acc_del(acc_id); 
     989    return S_OK; 
     990} 
     991 
     992STDMETHODIMP 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 
     1003STDMETHODIMP 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 
     1021STDMETHODIMP 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 
     1039STDMETHODIMP 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 
Note: See TracChangeset for help on using the changeset viewer.