Ignore:
Timestamp:
May 10, 2007 8:40:57 PM (17 years ago)
Author:
bennylp
Message:

Added registration and other settings in WinCE sample

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/pjsua_wince/pjsua_wince.cpp

    r774 r1260  
    1616static HWND         hwndActionButton, hwndExitButton; 
    1717 
     18 
     19 
     20// 
     21// Basic config. 
     22// 
     23#define SIP_PORT        5060 
     24 
     25 
     26// 
     27// Destination URI (to make call, or to subscribe presence) 
     28// 
     29#define SIP_DST_URI     "sip:192.168.0.7:5061" 
     30 
     31// 
     32// Account 
     33// 
     34#define HAS_SIP_ACCOUNT 0       // 0 to disable registration 
     35#define SIP_DOMAIN      "server" 
     36#define SIP_REALM       "server" 
     37#define SIP_USER        "user" 
     38#define SIP_PASSWD      "secret" 
     39 
     40// 
     41// Outbound proxy for all accounts 
     42// 
     43#define SIP_PROXY       NULL 
     44//#define SIP_PROXY     "sip:192.168.0.2;lr" 
     45 
     46 
     47// 
     48// Configure nameserver if DNS SRV is to be used with both SIP 
     49// or STUN (for STUN see other settings below) 
     50// 
     51#define NAMESERVER      NULL 
     52//#define NAMESERVER    "62.241.163.201" 
     53 
     54// 
     55// STUN server 
     56#if 0 
     57        // Use this to have the STUN server resolved normally 
     58#   define STUN_DOMAIN  NULL 
     59#   define STUN_SERVER  "stun.fwdnet.net" 
     60#elif 0 
     61        // Use this to have the STUN server resolved with DNS SRV 
     62#   define STUN_DOMAIN  "iptel.org" 
     63#   define STUN_SERVER  NULL 
     64#else 
     65        // Use this to disable STUN 
     66#   define STUN_DOMAIN  NULL 
     67#   define STUN_SERVER  NULL 
     68#endif 
     69 
     70// 
     71// Use ICE? 
     72// 
     73#define USE_ICE         1 
     74 
     75 
     76// 
     77// Globals 
     78// 
    1879static pj_pool_t   *g_pool; 
    1980static pj_str_t     g_local_uri; 
     
    3899    ID_BTN_ACTION, 
    39100}; 
    40  
    41 #define DEFAULT_URI     "sip:192.168.0.7" 
    42101 
    43102 
     
    144203 
    145204        g_current_call = PJSUA_INVALID_ID; 
    146         SetURI(DEFAULT_URI, -1); 
     205        SetURI(SIP_DST_URI, -1); 
    147206        SetAction(ID_MENU_CALL); 
    148207        //SetCallStatus(call_info.state_text.ptr, call_info.state_text.slen); 
     
    277336    pjsua_media_config_default(&media_cfg); 
    278337    pjsua_transport_config_default(&udp_cfg); 
    279     udp_cfg.port = 50060; 
     338    udp_cfg.port = SIP_PORT; 
     339 
    280340    pjsua_transport_config_default(&rtp_cfg); 
    281341    rtp_cfg.port = 40000; 
     
    293353    media_cfg.quality = 1; 
    294354    media_cfg.ptime = 20; 
     355    media_cfg.enable_ice = USE_ICE; 
    295356 
    296357    /* Initialize application callbacks */ 
     
    303364    cfg.cb.on_typing = &on_typing; 
    304365 
     366    if (SIP_PROXY) { 
     367            cfg.outbound_proxy_cnt = 1; 
     368            cfg.outbound_proxy[0] = pj_str(SIP_PROXY); 
     369    } 
     370     
     371    if (NAMESERVER) { 
     372            cfg.nameserver_count = 1; 
     373            cfg.nameserver[0] = pj_str(NAMESERVER); 
     374    } 
     375     
     376    if (NAMESERVER && STUN_DOMAIN) { 
     377            cfg.stun_domain = pj_str(STUN_DOMAIN); 
     378    } else if (STUN_SERVER) { 
     379            cfg.stun_host = pj_str(STUN_SERVER); 
     380    } 
     381     
     382     
    305383    /* Initialize pjsua */ 
    306384    status = pjsua_init(&cfg, &log_cfg, &media_cfg); 
     
    341419    pjsua_acc_add_local(transport_id, PJ_TRUE, &g_current_acc); 
    342420    pjsua_acc_set_online_status(g_current_acc, PJ_TRUE); 
     421 
     422    /* Add account */ 
     423    if (HAS_SIP_ACCOUNT) { 
     424        pjsua_acc_config cfg; 
     425 
     426        pjsua_acc_config_default(&cfg); 
     427        cfg.id = pj_str("sip:" SIP_USER "@" SIP_DOMAIN); 
     428        cfg.reg_uri = pj_str("sip:" SIP_DOMAIN); 
     429        cfg.cred_count = 1; 
     430        cfg.cred_info[0].realm = pj_str(SIP_REALM); 
     431        cfg.cred_info[0].scheme = pj_str("digest"); 
     432        cfg.cred_info[0].username = pj_str(SIP_USER); 
     433        cfg.cred_info[0].data_type = PJSIP_CRED_DATA_PLAIN_PASSWD; 
     434        cfg.cred_info[0].data = pj_str(SIP_PASSWD); 
     435 
     436        status = pjsua_acc_add(&cfg, PJ_TRUE, &g_current_acc); 
     437        if (status != PJ_SUCCESS) { 
     438            pjsua_destroy(); 
     439            return PJ_FALSE; 
     440        } 
     441    } 
     442 
     443    /* Add buddy */ 
     444    if (SIP_DST_URI) { 
     445        pjsua_buddy_config bcfg; 
     446     
     447        pjsua_buddy_config_default(&bcfg); 
     448        bcfg.uri = pj_str(SIP_DST_URI); 
     449        bcfg.subscribe = PJ_FALSE; 
     450         
     451        pjsua_buddy_add(&bcfg, NULL); 
     452    } 
    343453 
    344454    /* Start pjsua */ 
     
    535645    SetCallStatus("Ready", 5); 
    536646    SetAction(ID_MENU_CALL); 
    537     SetURI(DEFAULT_URI, -1); 
     647    SetURI(SIP_DST_URI, -1); 
    538648    SetFocus(hWnd); 
    539649 
Note: See TracChangeset for help on using the changeset viewer.