Ignore:
Timestamp:
Dec 31, 2007 11:27:35 AM (16 years ago)
Author:
bennylp
Message:

Open access point establishment selection before starting the Symbian application. Also added IP addressing test in symbian_ua

File:
1 edited

Legend:

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

    r1646 r1648  
    2222 
    2323#define THIS_FILE       "symbian_ua.cpp" 
     24#define LOG_LEVEL       4 
    2425 
    2526// 
     
    3233// Destination URI (to make call, or to subscribe presence) 
    3334// 
    34 #define SIP_DST_URI     "sip:192.168.0.11:5060" 
     35#define SIP_DST_URI     "sip:192.168.0.13" 
    3536 
    3637// 
     
    5859// 
    5960// STUN server 
    60 #if 0 
     61#if 1 
    6162        // Use this to have the STUN server resolved normally 
    6263#   define STUN_DOMAIN  NULL 
     
    7576// Use ICE? 
    7677// 
    77 #define USE_ICE         0 
     78#define USE_ICE         1 
    7879 
    7980 
     
    269270 
    270271    /* Redirect log before pjsua_init() */ 
    271     pj_log_set_log_func((void (*)(int,const char*,int)) &log_writer); 
     272    pj_log_set_log_func(&log_writer); 
     273     
     274    /* Set log level */ 
     275    pj_log_set_level(LOG_LEVEL); 
    272276 
    273277    /* Create pjsua first! */ 
     
    456460            "  l    Start loopback audio device\n" 
    457461            "  L    Stop loopback audio device\n" 
    458             "  1    Call " SIP_DST_URI "\n" 
    459             "  2    Answer call\n" 
    460             "  3    Hangup all calls\n" 
     462            "  m    Call " SIP_DST_URI "\n" 
     463            "  a    Answer call\n" 
     464            "  g    Hangup all calls\n" 
    461465            "  s    Subscribe " SIP_DST_URI "\n" 
    462466            "  S    Unsubscribe presence\n" 
    463467            "  o    Set account online\n" 
    464468            "  O    Set account offline\n" 
    465             "  9    Quit\n")); 
     469            "  w    Quit\n")); 
    466470} 
    467471 
     
    473477     
    474478    switch (kc) { 
    475     case '9': 
     479    case 'w': 
    476480            asw_->AsyncStop(); 
    477481            reschedule = PJ_FALSE; 
     
    491495                pjsua_conf_disconnect(0, 0); 
    492496            break; 
    493     case '1': 
     497    case 'm': 
    494498            if (g_call_id != PJSUA_INVALID_ID) { 
    495499                    PJ_LOG(3,(THIS_FILE, "Another call is active"));     
     
    505509            } 
    506510            break; 
    507     case '2': 
     511    case 'a': 
    508512            if (g_call_id != PJSUA_INVALID_ID) 
    509513                    pjsua_call_answer(g_call_id, 200, NULL, NULL); 
    510514            break; 
    511     case '3': 
     515    case 'g': 
    512516            pjsua_call_hangup_all(); 
    513517            break; 
     
    533537} 
    534538 
     539#if 0 
     540// IP networking related testing 
     541static pj_status_t test_addr(void) 
     542{ 
     543        int af; 
     544        unsigned i, count; 
     545        pj_addrinfo ai[8]; 
     546        pj_sockaddr ifs[8]; 
     547        const pj_str_t *hostname; 
     548        pj_hostent he; 
     549        pj_status_t status; 
     550         
     551        pj_log_set_log_func(&log_writer); 
     552         
     553        status = pj_init(); 
     554        if (status != PJ_SUCCESS) { 
     555                pjsua_perror(THIS_FILE, "pj_init() error", status); 
     556                return status; 
     557        } 
     558         
     559        af = pj_AF_INET(); 
     560         
     561        // Hostname 
     562        hostname = pj_gethostname(); 
     563        if (hostname == NULL) { 
     564                status = PJ_ERESOLVE; 
     565                pjsua_perror(THIS_FILE, "pj_gethostname() error", status); 
     566                goto on_return; 
     567        } 
     568         
     569        PJ_LOG(3,(THIS_FILE, "Hostname: %.*s", hostname->slen, hostname->ptr)); 
     570         
     571        // Gethostbyname 
     572        status = pj_gethostbyname(hostname, &he); 
     573        if (status != PJ_SUCCESS) { 
     574                pjsua_perror(THIS_FILE, "pj_gethostbyname() error", status); 
     575        } else { 
     576                PJ_LOG(3,(THIS_FILE, "gethostbyname: %s",  
     577                                  pj_inet_ntoa(*(pj_in_addr*)he.h_addr))); 
     578        } 
     579         
     580        // Getaddrinfo 
     581        count = PJ_ARRAY_SIZE(ai); 
     582        status = pj_getaddrinfo(af, hostname, &count, ai); 
     583        if (status != PJ_SUCCESS) { 
     584                pjsua_perror(THIS_FILE, "pj_getaddrinfo() error", status); 
     585        } else { 
     586                for (i=0; i<count; ++i) { 
     587                        char ipaddr[PJ_INET6_ADDRSTRLEN+2]; 
     588                        PJ_LOG(3,(THIS_FILE, "Addrinfo: %s",  
     589                                          pj_sockaddr_print(&ai[i].ai_addr, ipaddr, sizeof(ipaddr), 2))); 
     590                } 
     591        } 
     592         
     593        // Enum interface 
     594        count = PJ_ARRAY_SIZE(ifs); 
     595        status = pj_enum_ip_interface(af, &count, ifs); 
     596        if (status != PJ_SUCCESS) { 
     597                pjsua_perror(THIS_FILE, "pj_enum_ip_interface() error", status); 
     598        } else { 
     599                for (i=0; i<count; ++i) { 
     600                        char ipaddr[PJ_INET6_ADDRSTRLEN+2]; 
     601                        PJ_LOG(3,(THIS_FILE, "Interface: %s",  
     602                                          pj_sockaddr_print(&ifs[i], ipaddr, sizeof(ipaddr), 2))); 
     603                } 
     604        } 
     605 
     606        // Get default iinterface 
     607        status = pj_getdefaultipinterface(af, &ifs[0]); 
     608        if (status != PJ_SUCCESS) { 
     609                pjsua_perror(THIS_FILE, "pj_getdefaultipinterface() error", status); 
     610        } else { 
     611                char ipaddr[PJ_INET6_ADDRSTRLEN+2]; 
     612                PJ_LOG(3,(THIS_FILE, "Default IP: %s",  
     613                                  pj_sockaddr_print(&ifs[0], ipaddr, sizeof(ipaddr), 2))); 
     614        } 
     615         
     616        // Get default IP address 
     617        status = pj_gethostip(af, &ifs[0]); 
     618        if (status != PJ_SUCCESS) { 
     619                pjsua_perror(THIS_FILE, "pj_gethostip() error", status); 
     620        } else { 
     621                char ipaddr[PJ_INET6_ADDRSTRLEN+2]; 
     622                PJ_LOG(3,(THIS_FILE, "Host IP: %s",  
     623                                  pj_sockaddr_print(&ifs[0], ipaddr, sizeof(ipaddr), 2))); 
     624        } 
     625         
     626        status = -1; 
     627         
     628on_return: 
     629        pj_shutdown(); 
     630        return status; 
     631} 
     632#endif 
     633 
     634 
     635#include <ES_SOCK.H> 
    535636 
    536637//////////////////////////////////////////////////////////////////////////// 
    537638int ua_main()  
    538639{ 
     640        RSocketServ aSocketServer; 
     641        RConnection aConn; 
     642        TInt err; 
     643        pj_symbianos_params sym_params; 
    539644    pj_status_t status; 
     645     
     646    // Initialize RSocketServ 
     647    if ((err=aSocketServer.Connect()) != KErrNone) 
     648        return PJ_STATUS_FROM_OS(err); 
     649     
     650    // Open up a connection 
     651    if ((err=aConn.Open(aSocketServer)) != KErrNone) { 
     652            aSocketServer.Close(); 
     653                return PJ_STATUS_FROM_OS(err); 
     654    } 
     655     
     656    if ((err=aConn.Start()) != KErrNone) { 
     657        aSocketServer.Close(); 
     658        return PJ_STATUS_FROM_OS(err); 
     659    } 
     660     
     661    // Set Symbian OS parameters in pjlib. 
     662    // This must be done before pj_init() is called. 
     663    pj_bzero(&sym_params, sizeof(sym_params)); 
     664    sym_params.rsocketserv = &aSocketServer; 
     665    sym_params.rconnection = &aConn; 
     666    pj_symbianos_set_params(&sym_params); 
    540667     
    541668    // Initialize pjsua 
    542669    status  = app_startup(); 
    543     if (status != PJ_SUCCESS) 
     670    //status = test_addr(); 
     671    if (status != PJ_SUCCESS) { 
     672        aConn.Close(); 
     673        aSocketServer.Close(); 
    544674            return status; 
     675    } 
    545676 
    546677    // Run the UI 
     
    559690    pjsua_destroy(); 
    560691     
    561 on_return: 
     692    // Close connection and socket server 
     693    aConn.Close(); 
     694        aSocketServer.Close(); 
     695         
    562696    return status; 
    563697} 
Note: See TracChangeset for help on using the changeset viewer.