Changeset 4028 for pjproject/trunk


Ignore:
Timestamp:
Apr 5, 2012 8:41:20 AM (13 years ago)
Author:
nanang
Message:

Misc (Re #1446): limit pjsua_vid_codec_get/set_param() search domain to only codecs with RTP packetizations.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_vid.c

    r4012 r4028  
    228228 */ 
    229229 
     230static pj_status_t find_codecs_with_rtp_packing( 
     231                                    const pj_str_t *codec_id, 
     232                                    unsigned *count, 
     233                                    const pjmedia_vid_codec_info *p_info[]) 
     234{ 
     235    const pjmedia_vid_codec_info *info[32]; 
     236    unsigned i, j, count_ = PJ_ARRAY_SIZE(info); 
     237    pj_status_t status; 
     238     
     239    status = pjmedia_vid_codec_mgr_find_codecs_by_id(NULL, codec_id, 
     240                                                     &count_, info, NULL); 
     241    if (status != PJ_SUCCESS) 
     242        return status; 
     243 
     244    for (i = 0, j = 0; i < count_ && j<*count; ++i) { 
     245        if ((info[i]->packings & PJMEDIA_VID_PACKING_PACKETS) == 0) 
     246            continue; 
     247        p_info[j++] = info[i]; 
     248    } 
     249    *count = j; 
     250    return PJ_SUCCESS; 
     251} 
     252 
    230253/* 
    231254 * Enum all supported video codecs in the system. 
     
    292315                                        pjmedia_vid_codec_param *param) 
    293316{ 
    294     const pj_str_t all = { NULL, 0 }; 
    295     const pjmedia_vid_codec_info *info; 
    296     unsigned count = 1; 
     317    const pjmedia_vid_codec_info *info[2]; 
     318    unsigned count = 2; 
    297319    pj_status_t status; 
    298320 
    299     if (codec_id->slen==1 && *codec_id->ptr=='*') 
    300         codec_id = &all; 
    301  
    302     status = pjmedia_vid_codec_mgr_find_codecs_by_id(NULL, codec_id, 
    303                                                      &count, &info, NULL); 
     321    status = find_codecs_with_rtp_packing(codec_id, &count, info); 
    304322    if (status != PJ_SUCCESS) 
    305323        return status; 
     
    308326        return (count > 1? PJ_ETOOMANY : PJ_ENOTFOUND); 
    309327 
    310     status = pjmedia_vid_codec_mgr_get_default_param(NULL, info, param); 
     328    status = pjmedia_vid_codec_mgr_get_default_param(NULL, info[0], param); 
    311329    return status; 
    312330} 
     
    324342    pj_status_t status; 
    325343 
    326     status = pjmedia_vid_codec_mgr_find_codecs_by_id(NULL, codec_id, 
    327                                                      &count, info, NULL); 
     344    status = find_codecs_with_rtp_packing(codec_id, &count, info); 
    328345    if (status != PJ_SUCCESS) 
    329346        return status; 
    330347 
    331     /* Codec ID should be specific */ 
    332     if (count > 1) { 
    333         pj_assert(!"Codec ID is not specific"); 
    334         return PJ_ETOOMANY; 
    335     } 
     348    if (count != 1) 
     349        return (count > 1? PJ_ETOOMANY : PJ_ENOTFOUND); 
    336350 
    337351    status = pjmedia_vid_codec_mgr_set_default_param(NULL, info[0], param); 
Note: See TracChangeset for help on using the changeset viewer.