Changeset 3472 for pjproject


Ignore:
Timestamp:
Mar 22, 2011 9:50:48 AM (13 years ago)
Author:
nanang
Message:

Re #1214:

  • Added option in pjsua app to select video devices, and modified 'Cp' menu command to also change video codecs priority.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/2.0-dev/pjsip-apps/src/pjsua/pjsua_app.c

    r3457 r3472  
    125125    pjmedia_port           *ring_port; 
    126126 
     127    int                     vcapture_dev, vrender_dev; 
    127128} app_config; 
    128129 
     
    304305    puts  ("  --extra-audio       Add one more audio stream"); 
    305306 
     307#if PJMEDIA_HAS_VIDEO 
    306308    puts  (""); 
    307309    puts  ("Video Options:"); 
    308310    puts  ("  --video             Enable video"); 
     311    puts  ("  --vcapture-dev=id   Video capture device ID (default=-1)"); 
     312    puts  ("  --vrender-dev=id    Video render device ID (default=-1)"); 
     313#endif 
    309314 
    310315    puts  (""); 
     
    381386    for (i=0; i<PJ_ARRAY_SIZE(cfg->buddy_cfg); ++i) 
    382387        pjsua_buddy_config_default(&cfg->buddy_cfg[i]); 
     388 
     389    cfg->vcapture_dev = PJSUA_INVALID_ID; 
     390    cfg->vrender_dev = PJSUA_INVALID_ID; 
    383391} 
    384392 
     
    547555           OPT_NO_FORCE_LR, 
    548556           OPT_TIMER, OPT_TIMER_SE, OPT_TIMER_MIN_SE, 
    549            OPT_VIDEO, OPT_EXTRA_AUDIO 
     557           OPT_VIDEO, OPT_EXTRA_AUDIO, 
     558           OPT_VCAPTURE_DEV, OPT_VRENDER_DEV, 
    550559    }; 
    551560    struct pj_getopt_option long_options[] = { 
     
    668677        { "video",      0, 0, OPT_VIDEO}, 
    669678        { "extra-audio",0, 0, OPT_EXTRA_AUDIO}, 
     679        { "vcapture-dev", 1, 0, OPT_VCAPTURE_DEV}, 
     680        { "vrender-dev",  1, 0, OPT_VRENDER_DEV}, 
    670681        { NULL, 0, 0, 0} 
    671682    }; 
     
    14311442            ++cur_acc->max_audio_cnt; 
    14321443            break; 
     1444 
     1445        case OPT_VCAPTURE_DEV: 
     1446            cfg->vcapture_dev = atoi(pj_optarg); 
     1447            break; 
     1448 
     1449        case OPT_VRENDER_DEV: 
     1450            cfg->vrender_dev = atoi(pj_optarg); 
     1451            break; 
     1452 
    14331453        default: 
    14341454            PJ_LOG(1,(THIS_FILE,  
     
    20072027    } 
    20082028 
     2029    if (config->vcapture_dev != PJSUA_INVALID_ID) { 
     2030        pj_ansi_sprintf(line, "--vcapture-dev %d\n", config->vcapture_dev); 
     2031        pj_strcat2(&cfg, line); 
     2032    } 
     2033    if (config->vrender_dev != PJSUA_INVALID_ID) { 
     2034        pj_ansi_sprintf(line, "--vrender-dev %d\n", config->vrender_dev); 
     2035        pj_strcat2(&cfg, line); 
     2036    } 
    20092037 
    20102038    /* ptime */ 
     
    32153243    puts("| dq  Dump curr. call quality  | cd  Disconnect port      | dc  Dump config   |"); 
    32163244    puts("|                              |  V  Adjust audio Volume  |  f  Save config   |"); 
    3217     puts("|  S  Send arbitrary REQUEST   | Cp  Codec priorities     |  f  Save config   |"); 
     3245    puts("|  S  Send arbitrary REQUEST   | Cp  Codec priorities     |                   |"); 
    32183246    puts("+------------------------------+--------------------------+-------------------+"); 
    32193247    puts("|  q  QUIT   L  ReLoad   sleep MS   echo [0|1|txt]     n: detect NAT type     |"); 
     
    35033531    pj_status_t status; 
    35043532 
    3505     printf("List of codecs:\n"); 
    3506  
     3533    printf("List of audio codecs:\n"); 
    35073534    pjsua_enum_codecs(c, &count); 
    35083535    for (i=0; i<count; ++i) { 
     
    35113538    } 
    35123539 
     3540#if PJMEDIA_HAS_VIDEO 
    35133541    puts(""); 
    3514     puts("Enter codec id and its new priority " 
    3515          "(e.g. \"speex/16000 200\"), empty to cancel:"); 
     3542    printf("List of video codecs:\n"); 
     3543    pjsua_vid_enum_codecs(c, &count); 
     3544    for (i=0; i<count; ++i) { 
     3545        printf("  %d\t%.*s\n", c[i].priority, (int)c[i].codec_id.slen, 
     3546                               c[i].codec_id.ptr); 
     3547    } 
     3548#endif 
     3549 
     3550    puts(""); 
     3551    puts("Enter codec id and its new priority (e.g. \"speex/16000 200\", ""\"H263 200\"),"); 
     3552    puts("or empty to cancel."); 
    35163553 
    35173554    printf("Codec name (\"*\" for all) and priority: "); 
     
    35393576    status = pjsua_codec_set_priority(pj_cstr(&id, codec),  
    35403577                                      (pj_uint8_t)new_prio); 
     3578#if PJMEDIA_HAS_VIDEO 
     3579    if (status != PJ_SUCCESS) { 
     3580        status = pjsua_vid_codec_set_priority(pj_cstr(&id, codec),  
     3581                                              (pj_uint8_t)new_prio); 
     3582    } 
     3583#endif 
    35413584    if (status != PJ_SUCCESS) 
    35423585        pjsua_perror(THIS_FILE, "Error setting codec priority", status); 
     
    49705013    for (i=0; i<app_config.codec_dis_cnt; ++i) { 
    49715014        pjsua_codec_set_priority(&app_config.codec_dis[i],PJMEDIA_CODEC_PRIO_DISABLED); 
     5015#if PJMEDIA_HAS_VIDEO 
     5016        pjsua_vid_codec_set_priority(&app_config.codec_dis[i],PJMEDIA_CODEC_PRIO_DISABLED); 
     5017#endif 
    49725018    } 
    49735019 
     
    49765022        pjsua_codec_set_priority(&app_config.codec_arg[i], 
    49775023                                 (pj_uint8_t)(PJMEDIA_CODEC_PRIO_NORMAL+i+9)); 
     5024#if PJMEDIA_HAS_VIDEO 
     5025        pjsua_vid_codec_set_priority(&app_config.codec_arg[i], 
     5026                                     (pj_uint8_t)(PJMEDIA_CODEC_PRIO_NORMAL+i+9)); 
     5027#endif 
    49785028    } 
    49795029 
     
    50105060            goto on_error; 
    50115061    } 
     5062 
     5063#if PJMEDIA_HAS_VIDEO 
     5064    if (app_config.vcapture_dev != PJSUA_INVALID_ID || 
     5065        app_config.vrender_dev  != PJSUA_INVALID_ID)  
     5066    { 
     5067        status = pjsua_vid_set_dev(app_config.vcapture_dev,  
     5068                                   app_config.vrender_dev); 
     5069        if (status != PJ_SUCCESS) 
     5070            goto on_error; 
     5071    } 
     5072#endif 
    50125073 
    50135074    return PJ_SUCCESS; 
Note: See TracChangeset for help on using the changeset viewer.