Changeset 184


Ignore:
Timestamp:
Feb 14, 2006 9:15:30 PM (18 years ago)
Author:
bennylp
Message:

Ported pjsip to WinCE

Location:
pjproject/trunk/pjsip
Files:
6 added
16 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/build/pjsip.dsw

    r177 r184  
    132132    Project_Dep_Name pjmedia_codec 
    133133    End Project Dependency 
     134    Begin Project Dependency 
     135    Project_Dep_Name pjlib_util 
     136    End Project Dependency 
    134137}}} 
    135138 
  • pjproject/trunk/pjsip/build/pjsua.dsp

    r167 r184  
    107107# Begin Source File 
    108108 
     109SOURCE=..\src\pjsua\pjsua_opt.c 
     110# End Source File 
     111# Begin Source File 
     112 
    109113SOURCE=..\src\pjsua\pjsua_reg.c 
    110114# End Source File 
  • pjproject/trunk/pjsip/include/pjsip-ua/sip_inv.h

    r175 r184  
    2222#include <pjsip/sip_dialog.h> 
    2323#include <pjmedia/sdp_neg.h> 
     24 
     25 
     26PJ_BEGIN_DECL 
     27 
    2428 
    2529typedef enum pjsip_inv_state pjsip_inv_state; 
     
    526530 
    527531 
     532PJ_END_DECL 
     533 
    528534 
    529535 
  • pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c

    r175 r184  
    17361736            break; 
    17371737 
     1738        case PJSIP_TSX_STATE_CONFIRMED: 
     1739            /* For some reason can go here */ 
     1740 
    17381741        case PJSIP_TSX_STATE_TERMINATED: 
    17391742            /* INVITE transaction can be terminated either because UAC 
  • pjproject/trunk/pjsip/src/pjsip/sip_endpoint.c

    r162 r184  
    911911    PJ_UNUSED_ARG(endpt); 
    912912 
    913     len = pj_native_strlen(format); 
     913    len = pj_ansi_strlen(format); 
    914914    if (len < sizeof(newformat)-30) { 
    915915        pj_str_t errstr; 
    916916 
    917         pj_native_strcpy(newformat, format); 
     917        pj_ansi_strcpy(newformat, format); 
    918918        pj_snprintf(newformat+len, sizeof(newformat)-len-1, 
    919919                    ": [err %d] ", error_code); 
    920         len += pj_native_strlen(newformat+len); 
     920        len += pj_ansi_strlen(newformat+len); 
    921921 
    922922        errstr = pjsip_strerror(error_code, newformat+len,  
  • pjproject/trunk/pjsip/src/pjsip/sip_errno.c

    r127 r184  
    133133             
    134134            msg.ptr = (char*)err_str[first].msg; 
    135             msg.slen = pj_native_strlen(err_str[first].msg); 
     135            msg.slen = pj_ansi_strlen(err_str[first].msg); 
    136136 
    137137            errstr.ptr = buf; 
  • pjproject/trunk/pjsip/src/pjsip/sip_parser.c

    r145 r184  
    460460 
    461461    /* Equal length and equal hash. compare the strings. */ 
    462     return pj_native_strcmp(r1->hname, name); 
     462    return pj_ansi_strcmp(r1->hname, name); 
    463463} 
    464464 
     
    666666 
    667667    /* Find the end of header area by finding an empty line. */ 
    668     pos = pj_native_strstr(buf, "\n\r\n"); 
     668    pos = pj_ansi_strstr(buf, "\n\r\n"); 
    669669    if (pos == NULL) { 
    670670        return PJSIP_EPARTIALMSG; 
     
    675675 
    676676    /* Find "Content-Length" header the hard way. */ 
    677     line = pj_native_strchr(buf, '\n'); 
     677    line = pj_ansi_strchr(buf, '\n'); 
    678678    while (line && line < hdr_end) { 
    679679        ++line; 
     
    726726 
    727727        /* Go to next line. */ 
    728         line = pj_native_strchr(line, '\n'); 
     728        line = pj_ansi_strchr(line, '\n'); 
    729729    } 
    730730 
  • pjproject/trunk/pjsip/src/pjsip/sip_transport.c

    r169 r184  
    368368        return rdata->msg_info.info; 
    369369 
    370     pj_native_strcpy(obj_name, "rdata"); 
     370    pj_ansi_strcpy(obj_name, "rdata"); 
    371371    pj_sprintf(obj_name+5, "%p", rdata); 
    372372 
     
    469469        const char *str_addr; 
    470470        str_addr = pj_inet_ntoa(((pj_sockaddr_in*)addr)->sin_addr); 
    471         pj_native_strcpy(tdata->tp_info.dst_name, str_addr); 
     471        pj_ansi_strcpy(tdata->tp_info.dst_name, str_addr); 
    472472        tdata->tp_info.dst_port = pj_ntohs(((pj_sockaddr_in*)addr)->sin_port); 
    473473    } else { 
    474         pj_native_strcpy(tdata->tp_info.dst_name, "<unknown>"); 
     474        pj_ansi_strcpy(tdata->tp_info.dst_name, "<unknown>"); 
    475475        tdata->tp_info.dst_port = 0; 
    476476    } 
  • pjproject/trunk/pjsip/src/pjsip/sip_transport_loop.c

    r123 r184  
    9292    pkt->rdata.pkt_info.src_addr_len = sizeof(pj_sockaddr_in); 
    9393    if (loop->base.key.type == PJSIP_TRANSPORT_LOOP) 
    94         pj_native_strcpy(pkt->rdata.pkt_info.src_name, ADDR_LOOP); 
     94        pj_ansi_strcpy(pkt->rdata.pkt_info.src_name, ADDR_LOOP); 
    9595    else 
    96         pj_native_strcpy(pkt->rdata.pkt_info.src_name, ADDR_LOOP_DGRAM); 
     96        pj_ansi_strcpy(pkt->rdata.pkt_info.src_name, ADDR_LOOP_DGRAM); 
    9797    pkt->rdata.pkt_info.src_port = loop->base.local_name.port; 
    9898 
  • pjproject/trunk/pjsip/src/pjsip/sip_transport_udp.c

    r109 r184  
    8383            rdata->pkt_info.zero = 0; 
    8484            pj_gettimeofday(&rdata->pkt_info.timestamp); 
    85             pj_native_strcpy(rdata->pkt_info.src_name, 
    86                              pj_inet_ntoa(src_addr->sin_addr)); 
     85            pj_ansi_strcpy(rdata->pkt_info.src_name, 
     86                           pj_inet_ntoa(src_addr->sin_addr)); 
    8787            rdata->pkt_info.src_port = pj_ntohs(src_addr->sin_port); 
    8888 
  • pjproject/trunk/pjsip/src/pjsip/sip_ua_layer.c

    r175 r184  
    748748    len = pjsip_hdr_print_on(dlg->remote.info, userinfo, sizeof(userinfo)); 
    749749    if (len < 1) 
    750         pj_native_strcpy(userinfo, "<--uri too long-->"); 
     750        pj_ansi_strcpy(userinfo, "<--uri too long-->"); 
    751751    else 
    752752        userinfo[len] = '\0'; 
     
    758758                      userinfo); 
    759759    if (len < 1 || len >= (int)size) { 
    760         pj_native_strcpy(buf, "<--uri too long-->"); 
     760        pj_ansi_strcpy(buf, "<--uri too long-->"); 
    761761    } else 
    762762        buf[len] = '\0'; 
  • pjproject/trunk/pjsip/src/pjsua/getopt.c

    r167 r184  
    3030 * modified by Mike Borella <mike_borella@mw.3com.com> 
    3131 * 
    32  * $Id: getopt.c,v 1.4 2000/10/30 22:06:03 mborella Exp $ 
     32 * $Id$ 
    3333 */ 
    3434 
     
    296296   in GCC.  */ 
    297297#include <string.h> 
    298 #define my_index        pj_native_strchr 
     298#define my_index        pj_ansi_strchr 
    299299#else 
    300300 
     
    486486  nextchar = NULL; 
    487487 
    488   posixly_correct = getenv ("POSIXLY_CORRECT"); 
     488  //posixly_correct = getenv ("POSIXLY_CORRECT"); 
     489  posixly_correct = NULL; 
    489490 
    490491  /* Determine how to handle the ordering of options and nonoptions.  */ 
     
    662663         then skip everything else like a non-option.  */ 
    663664 
    664       if (optind != argc && !pj_native_strcmp(argv[optind], "--")) 
     665      if (optind != argc && !pj_ansi_strcmp(argv[optind], "--")) 
    665666        { 
    666667          optind++; 
  • pjproject/trunk/pjsip/src/pjsua/main.c

    r177 r184  
    1818 */ 
    1919#include "pjsua.h" 
    20 #include "getopt.h" 
    2120#include <stdlib.h> 
    2221 
     
    2524 
    2625static pjsip_inv_session *inv_session; 
    27  
    28 static const char *inv_state_names[] = 
    29 { 
    30     "NULL      ", 
    31     "CALLING   ", 
    32     "INCOMING  ", 
    33     "EARLY     ", 
    34     "CONNECTING", 
    35     "CONFIRMED ", 
    36     "DISCONNCTD", 
    37     "TERMINATED", 
    38 }; 
    3926 
    4027/* 
     
    4633 
    4734    PJ_LOG(3,(THIS_FILE, "INVITE session state changed to %s",  
    48               inv_state_names[inv->state])); 
     35              pjsua_inv_state_names[inv->state])); 
    4936 
    5037    if (inv->state == PJSIP_INV_STATE_DISCONNECTED) { 
     
    5946} 
    6047 
    61  
    62 static void print_invite_session(const char *title, 
    63                                  struct pjsua_inv_data *inv_data,  
    64                                  char *buf, pj_size_t size) 
    65 { 
    66     int len; 
    67     pjsip_inv_session *inv = inv_data->inv; 
    68     pjsip_dialog *dlg = inv->dlg; 
    69     char userinfo[128]; 
    70  
    71     /* Dump invite sesion info. */ 
    72  
    73     len = pjsip_hdr_print_on(dlg->remote.info, userinfo, sizeof(userinfo)); 
    74     if (len < 1) 
    75         pj_native_strcpy(userinfo, "<--uri too long-->"); 
    76     else 
    77         userinfo[len] = '\0'; 
    78      
    79     len = pj_snprintf(buf, size, "%s[%s] %s", 
    80                       title, 
    81                       inv_state_names[inv->state], 
    82                       userinfo); 
    83     if (len < 1 || len >= (int)size) { 
    84         pj_native_strcpy(buf, "<--uri too long-->"); 
    85         len = 18; 
    86     } else 
    87         buf[len] = '\0'; 
    88 } 
    89  
    90 static void dump_media_session(pjmedia_session *session) 
    91 { 
    92     unsigned i; 
    93     pjmedia_session_info info; 
    94  
    95     pjmedia_session_get_info(session, &info); 
    96  
    97     for (i=0; i<info.stream_cnt; ++i) { 
    98         pjmedia_stream_stat strm_stat; 
    99         const char *rem_addr; 
    100         int rem_port; 
    101         const char *dir; 
    102  
    103         pjmedia_session_get_stream_stat(session, i, &strm_stat); 
    104         rem_addr = pj_inet_ntoa(info.stream_info[i].rem_addr.sin_addr); 
    105         rem_port = pj_ntohs(info.stream_info[i].rem_addr.sin_port); 
    106  
    107         if (info.stream_info[i].dir == PJMEDIA_DIR_ENCODING) 
    108             dir = "sendonly"; 
    109         else if (info.stream_info[i].dir == PJMEDIA_DIR_DECODING) 
    110             dir = "recvonly"; 
    111         else if (info.stream_info[i].dir == PJMEDIA_DIR_ENCODING_DECODING) 
    112             dir = "sendrecv"; 
    113         else 
    114             dir = "inactive"; 
    115  
    116          
    117         PJ_LOG(3,(THIS_FILE,  
    118                   "%s[Media strm#%d] %.*s, %s, peer=%s:%d", 
    119                   "               ", 
    120                   i, 
    121                   info.stream_info[i].fmt.encoding_name.slen, 
    122                   info.stream_info[i].fmt.encoding_name.ptr, 
    123                   dir, 
    124                   rem_addr, rem_port)); 
    125         PJ_LOG(3,(THIS_FILE,  
    126                   "%s tx {pkt=%u, bytes=%u} rx {pkt=%u, bytes=%u}", 
    127                   "                             ", 
    128                   strm_stat.enc.pkt, strm_stat.enc.bytes, 
    129                   strm_stat.dec.pkt, strm_stat.dec.bytes)); 
    130  
    131     } 
    132 } 
    133  
    134 /* 
    135  * Dump application states. 
    136  */ 
    137 static void pjsua_dump(void) 
    138 { 
    139     struct pjsua_inv_data *inv_data; 
    140     char buf[128]; 
    141     unsigned log_decor; 
    142  
    143     log_decor = pj_log_get_decor(); 
    144     pj_log_set_decor(PJ_LOG_HAS_NEWLINE); 
    145  
    146     pjsip_endpt_dump(pjsua.endpt, 1); 
    147     pjmedia_endpt_dump(pjsua.med_endpt); 
    148     pjsip_ua_dump(); 
    149  
    150  
    151     /* Dump all invite sessions: */ 
    152     PJ_LOG(3,(THIS_FILE, "Dumping invite sessions:")); 
    153  
    154     if (pj_list_empty(&pjsua.inv_list)) { 
    155  
    156         PJ_LOG(3,(THIS_FILE, "  - no sessions -")); 
    157  
    158     } else { 
    159  
    160         inv_data = pjsua.inv_list.next; 
    161  
    162         while (inv_data != &pjsua.inv_list) { 
    163  
    164             print_invite_session("  ", inv_data, buf, sizeof(buf)); 
    165             PJ_LOG(3,(THIS_FILE, "%s", buf)); 
    166  
    167             if (inv_data->session) 
    168                 dump_media_session(inv_data->session); 
    169  
    170             inv_data = inv_data->next; 
    171         } 
    172     } 
    173  
    174     pj_log_set_decor(log_decor); 
    175 } 
     48/** 
     49 * Notify UI when registration status has changed. 
     50 */ 
     51void pjsua_ui_regc_on_state_changed(int code) 
     52{ 
     53    PJ_UNUSED_ARG(code); 
     54 
     55    // Log already written. 
     56} 
     57 
    17658 
    17759 
     
    265147                    continue; 
    266148                 
     149                if (atoi(buf) < 100) 
     150                    continue; 
     151 
    267152                status = pjsip_inv_answer(inv_session, atoi(buf), NULL, NULL,  
    268153                                          &tdata); 
     
    434319 
    435320/***************************************************************************** 
    436  * Command line argument processing: 
    437  */ 
    438  
    439  
    440 /* Show usage */ 
    441 static void usage(void) 
    442 { 
    443     puts("Usage:"); 
    444     puts("  pjsua [options] [sip-url]"); 
    445     puts(""); 
    446     puts("  [sip-url]   Default URL to invite."); 
    447     puts(""); 
    448     puts("General options:"); 
    449     puts("  --config-file=file  Read the config/arguments from file."); 
    450     puts("  --log-file=fname    Log to filename (default stderr)"); 
    451     puts("  --log-level=N       Set log max level to N (0(none) to 6(trace))"); 
    452     puts("  --app-log-level=N   Set log max level for stdout display to N"); 
    453     puts("  --help              Display this help screen"); 
    454     puts("  --version           Display version info"); 
    455     puts(""); 
    456     puts("Media options:"); 
    457     puts("  --null-audio        Use NULL audio device"); 
    458     puts(""); 
    459     puts("User Agent options:"); 
    460     puts("  --auto-answer=sec   Auto-answer all incoming calls after sec seconds."); 
    461     puts("  --auto-hangup=sec   Auto-hangup all calls after sec seconds."); 
    462     puts(""); 
    463     puts("SIP options:"); 
    464     puts("  --local-port=port   Set TCP/UDP port"); 
    465     puts("  --id=url            Set the URL of local ID (used in From header)"); 
    466     puts("  --contact=url       Override the Contact information"); 
    467     puts("  --proxy=url         Set the URL of proxy server"); 
    468     puts("  --outbound=url      Set the URL of outbound proxy server"); 
    469     puts("  --registrar=url     Set the URL of registrar server"); 
    470     puts("  --reg-timeout=secs  Set registration interval to secs (default 3600)"); 
    471     puts(""); 
    472     puts("Authentication options:"); 
    473     puts("  --realm=string      Set realm"); 
    474     puts("  --username=string   Set authentication username"); 
    475     puts("  --password=string   Set authentication password"); 
    476     puts(""); 
    477     puts("STUN options (all must be specified):"); 
    478     puts("  --use-stun1=host[:port]"); 
    479     puts("  --use-stun2=host[:port]  Use STUN and set host name and port of STUN servers"); 
    480     puts(""); 
    481     //puts("SIMPLE options (may be specified more than once):"); 
    482     //puts("  --add-buddy url     Add the specified URL to the buddy list."); 
    483     //puts("  --offer-x-ms-msg    Offer \"x-ms-message\" in outgoing INVITE"); 
    484     //puts("  --no-presence     Do not subscribe presence of buddies"); 
    485     puts(""); 
    486     fflush(stdout); 
    487 } 
    488  
     321 * Error display: 
     322 */ 
    489323 
    490324/* 
    491  * Verify that valid SIP url is given. 
    492  */ 
    493 static pj_status_t verify_sip_url(char *url) 
    494 { 
    495     pjsip_uri *p; 
    496     pj_pool_t *pool; 
    497     int len = (url ? strlen(url) : 0); 
    498  
    499     if (!len) return -1; 
    500  
    501     pool = pj_pool_create(&pjsua.cp.factory, "check%p", 1024, 0, NULL); 
    502     if (!pool) return -1; 
    503  
    504     p = pjsip_parse_uri(pool, url, len, 0); 
    505     if (!p || pj_stricmp2(pjsip_uri_get_scheme(p), "sip") != 0) 
    506         p = NULL; 
    507  
    508     pj_pool_release(pool); 
    509     return p ? 0 : -1; 
    510 } 
    511  
    512  
    513 /* 
    514  * Read command arguments from config file. 
    515  */ 
    516 static int read_config_file(pj_pool_t *pool, const char *filename,  
    517                             int *app_argc, char ***app_argv) 
    518 { 
    519     int i; 
    520     FILE *fhnd; 
    521     char line[200]; 
    522     int argc = 0; 
    523     char **argv; 
    524     enum { MAX_ARGS = 64 }; 
    525  
    526     /* Allocate MAX_ARGS+1 (argv needs to be terminated with NULL argument) */ 
    527     argv = pj_pool_calloc(pool, MAX_ARGS+1, sizeof(char*)); 
    528     argv[argc++] = *app_argv[0]; 
    529  
    530     /* Open config file. */ 
    531     fhnd = fopen(filename, "rt"); 
    532     if (!fhnd) { 
    533         printf("Unable to open config file %s\n", filename); 
    534         fflush(stdout); 
    535         return -1; 
    536     } 
    537  
    538     /* Scan tokens in the file. */ 
    539     while (argc < MAX_ARGS && !feof(fhnd)) { 
    540         char *token, *p = line; 
    541  
    542         if (fgets(line, sizeof(line), fhnd) == NULL) break; 
    543  
    544         for (token = strtok(p, " \t\r\n"); argc < MAX_ARGS;  
    545              token = strtok(NULL, " \t\r\n")) 
    546         { 
    547             int token_len; 
    548              
    549             if (!token) break; 
    550             if (*token == '#') break; 
    551  
    552             token_len = strlen(token); 
    553             if (!token_len) 
    554                 continue; 
    555             argv[argc] = pj_pool_alloc(pool, token_len+1); 
    556             pj_memcpy(argv[argc], token, token_len+1); 
    557             ++argc; 
    558         } 
    559     } 
    560  
    561     /* Copy arguments from command line */ 
    562     for (i=1; i<*app_argc && argc < MAX_ARGS; ++i) 
    563         argv[argc++] = (*app_argv)[i]; 
    564  
    565     if (argc == MAX_ARGS && (i!=*app_argc || !feof(fhnd))) { 
    566         printf("Too many arguments specified in cmd line/config file\n"); 
    567         fflush(stdout); 
    568         fclose(fhnd); 
    569         return -1; 
    570     } 
    571  
    572     fclose(fhnd); 
    573  
    574     /* Assign the new command line back to the original command line. */ 
    575     *app_argc = argc; 
    576     *app_argv = argv; 
    577     return 0; 
    578  
    579 } 
    580  
    581  
    582 /* Parse arguments. */ 
    583 static pj_status_t parse_args(int argc, char *argv[]) 
    584 { 
    585     int c; 
    586     int option_index; 
    587     enum { OPT_CONFIG_FILE, OPT_LOG_FILE, OPT_LOG_LEVEL, OPT_APP_LOG_LEVEL,  
    588            OPT_HELP, OPT_VERSION, OPT_NULL_AUDIO, 
    589            OPT_LOCAL_PORT, OPT_PROXY, OPT_OUTBOUND_PROXY, OPT_REGISTRAR, 
    590            OPT_REG_TIMEOUT, OPT_ID, OPT_CONTACT,  
    591            OPT_REALM, OPT_USERNAME, OPT_PASSWORD, 
    592            OPT_USE_STUN1, OPT_USE_STUN2,  
    593            OPT_ADD_BUDDY, OPT_OFFER_X_MS_MSG, OPT_NO_PRESENCE, 
    594            OPT_AUTO_ANSWER, OPT_AUTO_HANGUP}; 
    595     struct option long_options[] = { 
    596         { "config-file",1, 0, OPT_CONFIG_FILE}, 
    597         { "log-file",   1, 0, OPT_LOG_FILE}, 
    598         { "log-level",  1, 0, OPT_LOG_LEVEL}, 
    599         { "app-log-level",1,0,OPT_APP_LOG_LEVEL}, 
    600         { "help",       0, 0, OPT_HELP}, 
    601         { "version",    0, 0, OPT_VERSION}, 
    602         { "null-audio", 0, 0, OPT_NULL_AUDIO}, 
    603         { "local-port", 1, 0, OPT_LOCAL_PORT}, 
    604         { "proxy",      1, 0, OPT_PROXY}, 
    605         { "outbound",   1, 0, OPT_OUTBOUND_PROXY}, 
    606         { "registrar",  1, 0, OPT_REGISTRAR}, 
    607         { "reg-timeout",1, 0, OPT_REG_TIMEOUT}, 
    608         { "id",         1, 0, OPT_ID}, 
    609         { "contact",    1, 0, OPT_CONTACT}, 
    610         { "realm",      1, 0, OPT_REALM}, 
    611         { "username",   1, 0, OPT_USERNAME}, 
    612         { "password",   1, 0, OPT_PASSWORD}, 
    613         { "use-stun1",  1, 0, OPT_USE_STUN1}, 
    614         { "use-stun2",  1, 0, OPT_USE_STUN2}, 
    615         { "add-buddy",  1, 0, OPT_ADD_BUDDY}, 
    616         { "offer-x-ms-msg",0,0,OPT_OFFER_X_MS_MSG}, 
    617         { "no-presence", 0, 0, OPT_NO_PRESENCE}, 
    618         { "auto-answer",1, 0, OPT_AUTO_ANSWER}, 
    619         { "auto-hangup",1, 0, OPT_AUTO_HANGUP}, 
    620         { NULL, 0, 0, 0} 
    621     }; 
    622     pj_status_t status; 
    623     char *config_file = NULL; 
    624  
    625     /* Run getopt once to see if user specifies config file to read. */ 
    626     while ((c=getopt_long(argc, argv, "", long_options, &option_index)) != -1) { 
    627         switch (c) { 
    628         case OPT_CONFIG_FILE: 
    629             config_file = optarg; 
    630             break; 
    631         } 
    632         if (config_file) 
    633             break; 
    634     } 
    635  
    636     if (config_file) { 
    637         status = read_config_file(pjsua.pool, config_file, &argc, &argv); 
    638         if (status != 0) 
    639             return status; 
    640     } 
    641  
    642  
    643     /* Reinitialize and re-run getopt again, possibly with new arguments 
    644      * read from config file. 
    645      */ 
    646     optind = 0; 
    647     while ((c=getopt_long(argc, argv, "", long_options, &option_index)) != -1) { 
    648         char *p; 
    649         pj_str_t tmp; 
    650         long lval; 
    651  
    652         switch (c) { 
    653  
    654         case OPT_LOG_FILE: 
    655             pjsua.log_filename = optarg; 
    656             break; 
    657  
    658         case OPT_LOG_LEVEL: 
    659             c = pj_strtoul(pj_cstr(&tmp, optarg)); 
    660             if (c < 0 || c > 6) { 
    661                 printf("Error: expecting integer value 0-6 for --log-level\n"); 
    662                 return PJ_EINVAL; 
    663             } 
    664             pj_log_set_level( c ); 
    665             break; 
    666  
    667         case OPT_APP_LOG_LEVEL: 
    668             pjsua.app_log_level = pj_strtoul(pj_cstr(&tmp, optarg)); 
    669             if (pjsua.app_log_level < 0 || pjsua.app_log_level > 6) { 
    670                 printf("Error: expecting integer value 0-6 for --app-log-level\n"); 
    671                 return PJ_EINVAL; 
    672             } 
    673             break; 
    674  
    675         case OPT_HELP: 
    676             usage(); 
    677             return PJ_EINVAL; 
    678  
    679         case OPT_VERSION:   /* version */ 
    680             pj_dump_config(); 
    681             return PJ_EINVAL; 
    682  
    683         case OPT_NULL_AUDIO: 
    684             pjsua.null_audio = 1; 
    685             break; 
    686  
    687         case OPT_LOCAL_PORT:   /* local-port */ 
    688             lval = pj_strtoul(pj_cstr(&tmp, optarg)); 
    689             if (lval < 1 || lval > 65535) { 
    690                 printf("Error: expecting integer value for --local-port\n"); 
    691                 return PJ_EINVAL; 
    692             } 
    693             pjsua.sip_port = (pj_uint16_t)lval; 
    694             break; 
    695  
    696         case OPT_PROXY:   /* proxy */ 
    697             if (verify_sip_url(optarg) != 0) { 
    698                 printf("Error: invalid SIP URL '%s' in proxy argument\n", optarg); 
    699                 return PJ_EINVAL; 
    700             } 
    701             pjsua.proxy = pj_str(optarg); 
    702             break; 
    703  
    704         case OPT_OUTBOUND_PROXY:   /* outbound proxy */ 
    705             if (verify_sip_url(optarg) != 0) { 
    706                 printf("Error: invalid SIP URL '%s' in outbound proxy argument\n", optarg); 
    707                 return PJ_EINVAL; 
    708             } 
    709             pjsua.outbound_proxy = pj_str(optarg); 
    710             break; 
    711  
    712         case OPT_REGISTRAR:   /* registrar */ 
    713             if (verify_sip_url(optarg) != 0) { 
    714                 printf("Error: invalid SIP URL '%s' in registrar argument\n", optarg); 
    715                 return PJ_EINVAL; 
    716             } 
    717             pjsua.registrar_uri = pj_str(optarg); 
    718             break; 
    719  
    720         case OPT_REG_TIMEOUT:   /* reg-timeout */ 
    721             pjsua.reg_timeout = pj_strtoul(pj_cstr(&tmp,optarg)); 
    722             if (pjsua.reg_timeout < 1 || pjsua.reg_timeout > 3600) { 
    723                 printf("Error: invalid value for --reg-timeout (expecting 1-3600)\n"); 
    724                 return PJ_EINVAL; 
    725             } 
    726             break; 
    727  
    728         case OPT_ID:   /* id */ 
    729             if (verify_sip_url(optarg) != 0) { 
    730                 printf("Error: invalid SIP URL '%s' in local id argument\n", optarg); 
    731                 return PJ_EINVAL; 
    732             } 
    733             pjsua.local_uri = pj_str(optarg); 
    734             break; 
    735  
    736         case OPT_CONTACT:   /* contact */ 
    737             if (verify_sip_url(optarg) != 0) { 
    738                 printf("Error: invalid SIP URL '%s' in contact argument\n", optarg); 
    739                 return PJ_EINVAL; 
    740             } 
    741             pjsua.contact_uri = pj_str(optarg); 
    742             break; 
    743  
    744         case OPT_USERNAME:   /* Default authentication user */ 
    745             if (!pjsua.cred_count) pjsua.cred_count = 1; 
    746             pjsua.cred_info[0].username = pj_str(optarg); 
    747             break; 
    748  
    749         case OPT_REALM:     /* Default authentication realm. */ 
    750             if (!pjsua.cred_count) pjsua.cred_count = 1; 
    751             pjsua.cred_info[0].realm = pj_str(optarg); 
    752             break; 
    753  
    754         case OPT_PASSWORD:   /* authentication password */ 
    755             if (!pjsua.cred_count) pjsua.cred_count = 1; 
    756             pjsua.cred_info[0].data_type = 0; 
    757             pjsua.cred_info[0].data = pj_str(optarg); 
    758             break; 
    759  
    760         case OPT_USE_STUN1:   /* STUN server 1 */ 
    761             p = pj_native_strchr(optarg, ':'); 
    762             if (p) { 
    763                 *p = '\0'; 
    764                 pjsua.stun_srv1 = pj_str(optarg); 
    765                 pjsua.stun_port1 = pj_strtoul(pj_cstr(&tmp, p+1)); 
    766                 if (pjsua.stun_port1 < 1 || pjsua.stun_port1 > 65535) { 
    767                     printf("Error: expecting port number with option --use-stun1\n"); 
    768                     return PJ_EINVAL; 
    769                 } 
    770             } else { 
    771                 pjsua.stun_port1 = 3478; 
    772                 pjsua.stun_srv1 = pj_str(optarg); 
    773             } 
    774             break; 
    775  
    776         case OPT_USE_STUN2:   /* STUN server 2 */ 
    777             p = pj_native_strchr(optarg, ':'); 
    778             if (p) { 
    779                 *p = '\0'; 
    780                 pjsua.stun_srv2 = pj_str(optarg); 
    781                 pjsua.stun_port2 = pj_strtoul(pj_cstr(&tmp,p+1)); 
    782                 if (pjsua.stun_port2 < 1 || pjsua.stun_port2 > 65535) { 
    783                     printf("Error: expecting port number with option --use-stun2\n"); 
    784                     return PJ_EINVAL; 
    785                 } 
    786             } else { 
    787                 pjsua.stun_port2 = 3478; 
    788                 pjsua.stun_srv2 = pj_str(optarg); 
    789             } 
    790             break; 
    791         } 
    792     } 
    793  
    794     if (optind != argc) { 
    795         printf("Error: unknown options %s\n", argv[optind]); 
    796         return PJ_EINVAL; 
    797     } 
    798  
    799     if (pjsua.reg_timeout == 0) 
    800         pjsua.reg_timeout = 3600; 
    801  
    802  
    803     return PJ_SUCCESS; 
    804 } 
     325 * Display error message for the specified error code. 
     326 */ 
     327void pjsua_perror(const char *title, pj_status_t status) 
     328{ 
     329    char errmsg[PJ_ERR_MSG_SIZE]; 
     330 
     331    pj_strerror(status, errmsg, sizeof(errmsg)); 
     332 
     333    PJ_LOG(1,(THIS_FILE, "%s: %s [code=%d]", title, errmsg, status)); 
     334} 
     335 
    805336 
    806337 
     
    825356    /* Parse command line arguments: */ 
    826357 
    827     if (parse_args(argc, argv) != PJ_SUCCESS) 
     358    if (pjsua_parse_args(argc, argv) != PJ_SUCCESS) 
    828359        return 1; 
    829360 
  • pjproject/trunk/pjsip/src/pjsua/pjsua.h

    r177 r184  
    4242 
    4343 
     44/** 
     45 * Max buddies in buddy list. 
     46 */ 
     47#define PJSUA_MAX_BUDDIES   32 
     48 
    4449/**  
    4550 * Structure to be attached to all dialog.  
     
    5358    pjsip_inv_session   *inv; 
    5459    pjmedia_session     *session; 
     60    void                *mod_data[PJSIP_MAX_MODULE]; 
    5561}; 
    5662 
     
    9298    pj_int32_t       reg_timeout; 
    9399    pj_timer_entry   regc_timer; 
     100    int              regc_last_code;/**< Last status last register.     */ 
    94101 
    95102 
    96103    /* Authentication credentials: */ 
    97104 
    98     int              cred_count; 
     105    unsigned         cred_count; 
    99106    pjsip_cred_info  cred_info[4]; 
    100107 
     
    129136    char            *log_filename;  /**< Log filename.                  */ 
    130137 
     138 
    131139    /* List of invite sessions: */ 
    132140 
    133141    struct pjsua_inv_data inv_list; 
     142 
     143 
     144    /* Buddy list: */ 
     145 
     146    unsigned        buddy_cnt; 
     147    pj_str_t        buddies[PJSUA_MAX_BUDDIES]; 
    134148}; 
    135149 
     
    252266void pjsua_ui_inv_on_state_changed(pjsip_inv_session *inv, pjsip_event *e); 
    253267 
     268/** 
     269 * Notify UI when registration status has changed. 
     270 */ 
     271void pjsua_ui_regc_on_state_changed(int code); 
     272 
     273 
     274/***************************************************************************** 
     275 * Utilities. 
     276 * 
     277 */ 
     278 
     279/** String to describe invite session states */ 
     280extern const char *pjsua_inv_state_names[]; 
     281 
     282/** 
     283 * Parse arguments (pjsua_opt.c). 
     284 */ 
     285pj_status_t pjsua_parse_args(int argc, char *argv[]); 
     286 
     287/** 
     288 * Load settings from a file. 
     289 */ 
     290pj_status_t pjsua_load_settings(const char *filename); 
     291 
     292/** 
     293 * Save settings to a file. 
     294 */ 
     295pj_status_t pjsua_save_settings(const char *filename); 
     296 
     297 
     298/* 
     299 * Verify that valid SIP url is given. 
     300 * @return  PJ_SUCCESS if valid. 
     301 */ 
     302pj_status_t pjsua_verify_sip_url(const char *c_url); 
     303 
     304/* 
     305 * Dump application states. 
     306 */ 
     307void pjsua_dump(void); 
     308 
    254309 
    255310PJ_END_DECL 
    256311 
     312 
    257313#endif  /* __PJSUA_H__ */ 
  • pjproject/trunk/pjsip/src/pjsua/pjsua_core.c

    r177 r184  
    8282} 
    8383 
    84  
    85 /* 
    86  * Display error message for the specified error code. 
    87  */ 
    88 void pjsua_perror(const char *title, pj_status_t status) 
    89 { 
    90     char errmsg[PJ_ERR_MSG_SIZE]; 
    91  
    92     pj_strerror(status, errmsg, sizeof(errmsg)); 
    93  
    94     PJ_LOG(1,(THIS_FILE, "%s: %s [code=%d]", title, errmsg, status)); 
    95 } 
    9684 
    9785 
     
    512500 
    513501        addr_name.host.ptr = pj_inet_ntoa(pjsua.sip_sock_name.sin_addr); 
    514         addr_name.host.slen = pj_native_strlen(addr_name.host.ptr); 
     502        addr_name.host.slen = pj_ansi_strlen(addr_name.host.ptr); 
    515503        addr_name.port = pj_ntohs(pjsua.sip_sock_name.sin_port); 
    516504 
  • pjproject/trunk/pjsip/src/pjsua/pjsua_reg.c

    r167 r184  
    5353        PJ_LOG(4, (THIS_FILE, "SIP registration updated status=%d", param->code)); 
    5454    } 
     55 
     56    pjsua.regc_last_code = param->code; 
     57 
     58    pjsua_ui_regc_on_state_changed(pjsua.regc_last_code); 
    5559} 
    5660 
Note: See TracChangeset for help on using the changeset viewer.