Ignore:
Timestamp:
Oct 4, 2007 6:17:58 AM (17 years ago)
Author:
bennylp
Message:

Ticket #389: Added new commands in pjsua to change codec priorities and send UPDATE

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c

    r1463 r1471  
    19101910    puts("|  H  Hold call                |  u  Unsubscribe presence | ru  Unregister    |"); 
    19111911    puts("|  v  re-inVite (release hold) |  t  ToGgle Online status |  >  Cycle next ac.|"); 
    1912     puts("|  ]  Select next dialog       |  T  Set online status    |  <  Cycle prev ac.|"); 
    1913     puts("|  [  Select previous dialog   +--------------------------+-------------------+"); 
     1912    puts("|  U  send UPDATE              |  T  Set online status    |  <  Cycle prev ac.|"); 
     1913    puts("| ],[ Select next/prev call    +--------------------------+-------------------+"); 
    19141914    puts("|  x  Xfer call                |      Media Commands:     |  Status & Config: |"); 
    19151915    puts("|  X  Xfer with Replaces       |                          |                   |"); 
    1916     puts("|  #  Send DTMF string         | cl  List ports           |  d  Dump status   |"); 
    1917     puts("| dq  Dump curr. call quality  | cc  Connect port         | dd  Dump detailed |"); 
    1918     puts("|                              | cd  Disconnect port      | dc  Dump config   |"); 
    1919     puts("|  S  Send arbitrary REQUEST   |  V  Adjust audio Volume  |  f  Save config   |"); 
     1916    puts("|  #  Send RFC 2833 DTMF       | cl  List ports           |  d  Dump status   |"); 
     1917    puts("|  *  Send DTMF with INFO      | cc  Connect port         | dd  Dump detailed |"); 
     1918    puts("| dq  Dump curr. call quality  | cd  Disconnect port      | dc  Dump config   |"); 
     1919    puts("|                              |  V  Adjust audio Volume  |  f  Save config   |"); 
     1920    puts("|  S  Send arbitrary REQUEST   | Cp  Codec priorities     |  f  Save config   |"); 
    19201921    puts("+------------------------------+--------------------------+-------------------+"); 
    19211922    puts("|  q  QUIT                  sleep N: console sleep for N ms                   |"); 
     
    21902191 
    21912192/* 
     2193 * Change codec priorities. 
     2194 */ 
     2195static void manage_codec_prio(void) 
     2196{ 
     2197    pjsua_codec_info c[32]; 
     2198    unsigned i, count = PJ_ARRAY_SIZE(c); 
     2199    char input[32]; 
     2200    char *codec, *prio; 
     2201    pj_str_t id; 
     2202    int new_prio; 
     2203    pj_status_t status; 
     2204 
     2205    printf("List of codecs:\n"); 
     2206 
     2207    pjsua_enum_codecs(c, &count); 
     2208    for (i=0; i<count; ++i) { 
     2209        printf("  %d\t%.*s\n", c[i].priority, (int)c[i].codec_id.slen, 
     2210                               c[i].codec_id.ptr); 
     2211    } 
     2212 
     2213    puts(""); 
     2214    puts("Enter codec name and its new priority (e.g. \"speex/16000 200\"), empty to cancel:"); 
     2215 
     2216    printf("Codec name and priority: "); 
     2217    fgets(input, sizeof(input), stdin); 
     2218    if (input[0]=='\r' || input[0]=='\n') { 
     2219        puts("Done"); 
     2220        return; 
     2221    } 
     2222 
     2223    codec = strtok(input, " \t\r\n"); 
     2224    prio = strtok(NULL, " \r\n"); 
     2225 
     2226    if (!codec || !prio) { 
     2227        puts("Invalid input"); 
     2228        return; 
     2229    } 
     2230 
     2231    new_prio = atoi(prio); 
     2232    if (new_prio < 0)  
     2233        new_prio = 0; 
     2234    else if (new_prio > PJMEDIA_CODEC_PRIO_HIGHEST)  
     2235        new_prio = PJMEDIA_CODEC_PRIO_HIGHEST; 
     2236 
     2237    status = pjsua_codec_set_priority(pj_cstr(&id, codec),  
     2238                                      (pj_uint8_t)new_prio); 
     2239    if (status != PJ_SUCCESS) 
     2240        pjsua_perror(THIS_FILE, "Error setting codec priority", status); 
     2241} 
     2242 
     2243 
     2244/* 
    21922245 * Main "user interface" loop. 
    21932246 */ 
     
    26122665            break; 
    26132666 
     2667        case 'U': 
     2668            /* 
     2669             * Send UPDATE 
     2670             */ 
     2671            if (current_call != -1) { 
     2672                 
     2673                pjsua_call_update(current_call, 0, NULL); 
     2674 
     2675            } else { 
     2676                PJ_LOG(3,(THIS_FILE, "No current call")); 
     2677            } 
     2678            break; 
     2679 
     2680        case 'C': 
     2681            if (menuin[1] == 'p') { 
     2682                manage_codec_prio(); 
     2683            } 
     2684            break; 
     2685 
    26142686        case 'x': 
    26152687            /* 
Note: See TracChangeset for help on using the changeset viewer.