Ignore:
Timestamp:
Apr 5, 2012 7:22:30 AM (12 years ago)
Author:
nanang
Message:

Misc (Re #1446): Add pjsua app video commands for modifying video codec bitrate & framerate.

File:
1 edited

Legend:

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

    r4024 r4025  
    35833583    puts("| vid acc cap ID            Set default capture device for current acc        |"); 
    35843584    puts("| vid acc rend ID           Set default renderer device for current acc       |"); 
    3585     puts("| vid call rx on|off N      Enable/disable video rx for stream N in curr call |"); 
    3586     puts("| vid call tx on|off N      Enable/disable video tx for stream N in curr call |"); 
     3585    puts("| vid call rx on|off N      Enable/disable video RX for stream N in curr call |"); 
     3586    puts("| vid call tx on|off N      Enable/disable video TX for stream N in curr call |"); 
    35873587    puts("| vid call add              Add video stream for current call                 |"); 
    35883588    puts("| vid call enable|disable N Enable/disable stream #N in current call          |"); 
     
    35923592    puts("| vid dev prev on|off ID    Enable/disable preview for specified device ID    |"); 
    35933593    puts("| vid codec list            List video codecs                                 |"); 
    3594     puts("| vid codec prio PT PRIO    Set codec with pt PT priority to PRIO             |"); 
     3594    puts("| vid codec prio ID PRIO    Set codec ID priority to PRIO                     |"); 
     3595    puts("| vid codec fps ID NUM DEN  Set codec ID framerate to (NUM/DEN) fps           |"); 
     3596    puts("| vid codec bw ID AVG MAX   Set codec ID bitrate to AVG & MAX kbps            |"); 
    35953597    puts("| vid win list              List all active video windows                     |"); 
    35963598    puts("| vid win arrange           Auto arrange windows                              |"); 
     
    42494251 
    42504252    } else if (strcmp(argv[1], "codec")==0) { 
    4251         pjmedia_vid_codec_info ci[PJMEDIA_CODEC_MGR_MAX_CODECS]; 
    4252         unsigned prio[PJMEDIA_CODEC_MGR_MAX_CODECS]; 
    4253         unsigned count = PJMEDIA_CODEC_MGR_MAX_CODECS; 
     4253        pjsua_codec_info ci[PJMEDIA_CODEC_MGR_MAX_CODECS]; 
     4254        unsigned count = PJ_ARRAY_SIZE(ci); 
    42544255        pj_status_t status; 
    42554256 
    42564257        if (argc==3 && strcmp(argv[2], "list")==0) { 
    4257             status = pjmedia_vid_codec_mgr_enum_codecs(NULL, &count, ci, prio); 
     4258            status = pjsua_vid_enum_codecs(ci, &count); 
    42584259            if (status != PJ_SUCCESS) { 
    42594260                PJ_PERROR(1,(THIS_FILE, status, "Error enumerating codecs")); 
     
    42614262                unsigned i; 
    42624263                PJ_LOG(3,(THIS_FILE, "Found %d video codecs:", count)); 
    4263                 PJ_LOG(3,(THIS_FILE, " PT  Prio  Name")); 
    4264                 PJ_LOG(3,(THIS_FILE, "-------------------------")); 
     4264                PJ_LOG(3,(THIS_FILE, "codec id      prio  fps   br(kbps)")); 
     4265                PJ_LOG(3,(THIS_FILE, "----------------------------------")); 
    42654266                for (i=0; i<count; ++i) { 
    4266                     PJ_LOG(3,(THIS_FILE, "% 3d % 3d  %.*s", ci[i].pt, prio[i], 
    4267                               (int)ci[i].encoding_name.slen, 
    4268                               ci[i].encoding_name.ptr)); 
     4267                    pjmedia_vid_codec_param cp; 
     4268                    pjmedia_video_format_detail *vfd; 
     4269 
     4270                    status = pjsua_vid_codec_get_param(&ci[i].codec_id, &cp); 
     4271                    if (status != PJ_SUCCESS) 
     4272                        continue; 
     4273 
     4274                    vfd = pjmedia_format_get_video_format_detail(&cp.enc_fmt, 
     4275                                                                 PJ_TRUE); 
     4276                    PJ_LOG(3,(THIS_FILE, "%.*s%.*s %3d %7.2f %d/%d",  
     4277                              (int)ci[i].codec_id.slen, ci[i].codec_id.ptr, 
     4278                              13-(int)ci[i].codec_id.slen, "                ", 
     4279                              ci[i].priority, 
     4280                              (vfd->fps.num*1.0/vfd->fps.denum), 
     4281                              vfd->avg_bps/1000, vfd->max_bps/1000)); 
    42694282                } 
    42704283            } 
    42714284        } else if (argc==5 && strcmp(argv[2], "prio")==0) { 
    4272             int pt = atoi(argv[3]); 
    4273             int prio = atoi(argv[4]); 
    4274             const pjmedia_vid_codec_info *pci; 
    4275  
    4276             status = pjmedia_vid_codec_mgr_get_codec_info(NULL, pt, &pci); 
    4277             if (status != PJ_SUCCESS) { 
    4278                 PJ_PERROR(1,(THIS_FILE, status, "Unable to find codec")); 
    4279             } else { 
    4280                 char codec_id[40]; 
    4281                 if (pjmedia_vid_codec_info_to_id(pci, codec_id, 
    4282                                                  sizeof(codec_id)) == NULL) 
    4283                 { 
    4284                     PJ_PERROR(1,(THIS_FILE, status, "Unable to get codec id")); 
    4285                 } else { 
    4286                     pj_str_t cid = pj_str(codec_id); 
    4287                     status = pjsua_vid_codec_set_priority(&cid, 
    4288                                                           (pj_uint8_t)prio); 
    4289                 } 
    4290             } 
    4291  
     4285            pj_str_t cid; 
     4286            int prio; 
     4287            cid = pj_str(argv[3]); 
     4288            prio = atoi(argv[4]); 
     4289            status = pjsua_vid_codec_set_priority(&cid, (pj_uint8_t)prio); 
     4290            if (status != PJ_SUCCESS) 
     4291                PJ_PERROR(1,(THIS_FILE, status, "Set codec priority error")); 
     4292        } else if (argc==6 && strcmp(argv[2], "fps")==0) { 
     4293            pjmedia_vid_codec_param cp; 
     4294            pj_str_t cid; 
     4295            int M, N; 
     4296            cid = pj_str(argv[3]); 
     4297            M = atoi(argv[4]); 
     4298            N = atoi(argv[5]); 
     4299            status = pjsua_vid_codec_get_param(&cid, &cp); 
     4300            if (status == PJ_SUCCESS) { 
     4301                cp.enc_fmt.det.vid.fps.num = M; 
     4302                cp.enc_fmt.det.vid.fps.denum = N; 
     4303                status = pjsua_vid_codec_set_param(&cid, &cp); 
     4304            } 
     4305            if (status != PJ_SUCCESS) 
     4306                PJ_PERROR(1,(THIS_FILE, status, "Set codec framerate error")); 
     4307        } else if (argc==6 && strcmp(argv[2], "bw")==0) { 
     4308            pjmedia_vid_codec_param cp; 
     4309            pj_str_t cid; 
     4310            int M, N; 
     4311            cid = pj_str(argv[3]); 
     4312            M = atoi(argv[4]); 
     4313            N = atoi(argv[5]); 
     4314            status = pjsua_vid_codec_get_param(&cid, &cp); 
     4315            if (status == PJ_SUCCESS) { 
     4316                cp.enc_fmt.det.vid.avg_bps = M * 1000; 
     4317                cp.enc_fmt.det.vid.max_bps = N * 1000; 
     4318                status = pjsua_vid_codec_set_param(&cid, &cp); 
     4319            } 
     4320            if (status != PJ_SUCCESS) 
     4321                PJ_PERROR(1,(THIS_FILE, status, "Set codec bitrate error")); 
    42924322        } else 
    42934323            goto on_error; 
Note: See TracChangeset for help on using the changeset viewer.