Changeset 3075


Ignore:
Timestamp:
Jan 26, 2010 6:54:28 PM (14 years ago)
Author:
bennylp
Message:

Undo r3074 for ticket #1028 as it is missing updated codec.h hence causing build errors (thanks Michael Bradley Jr for the report)

Location:
pjproject/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia-audiodev/symb_vas_dev.cpp

    r3074 r3075  
    492492        break; 
    493493         
    494     case EAMR_NB: 
    495         enc_fmt_if->SetBitRate(setting_.mode); 
    496         break; 
    497          
    498494    default: 
    499495        break; 
  • pjproject/trunk/pjmedia/src/pjmedia-codec/ipp_codecs.c

    r3074 r3075  
    11961196                  s->enc_mode, 
    11971197                  codec_data->info->params.modes.bitrate)); 
    1198  
    1199         /* Return back bitrate info to application */ 
    1200         attr->info.avg_bps = codec_data->info->params.modes.bitrate; 
    12011198    } 
    12021199#endif 
  • pjproject/trunk/pjmedia/src/pjmedia-codec/passthrough.c

    r3074 r3075  
    2525#include <pj/assert.h> 
    2626#include <pj/log.h> 
    27 #include <pj/math.h> 
    2827#include <pj/pool.h> 
    2928#include <pj/string.h> 
     
    682681        amr_settings_t *s; 
    683682        pj_uint8_t octet_align = 0; 
    684         pj_int8_t enc_mode; 
    685  
    686         enc_mode = pjmedia_codec_amr_get_mode(attr->info.avg_bps); 
    687         pj_assert(enc_mode >= 0 && enc_mode <= 8); 
     683        const pj_str_t STR_FMTP_OCTET_ALIGN = {"octet-align", 11}; 
    688684 
    689685        /* Fetch octet-align setting. It should be fine to fetch only  
     
    692688         */ 
    693689        for (i = 0; i < attr->setting.dec_fmtp.cnt; ++i) { 
    694             const pj_str_t STR_FMTP_OCTET_ALIGN = {"octet-align", 11}; 
    695  
    696690            if (pj_stricmp(&attr->setting.dec_fmtp.param[i].name,  
    697691                           &STR_FMTP_OCTET_ALIGN) == 0) 
     
    703697        } 
    704698 
    705         for (i = 0; i < attr->setting.enc_fmtp.cnt; ++i) { 
    706             /* mode-set, encoding mode is chosen based on local default mode  
    707              * setting: 
    708              * - if local default mode is included in the mode-set, use it 
    709              * - otherwise, find the closest mode to local default mode; 
    710              *   if there are two closest modes, prefer to use the higher 
    711              *   one, e.g: local default mode is 4, the mode-set param 
    712              *   contains '2,3,5,6', then 5 will be chosen. 
    713              */ 
    714             const pj_str_t STR_FMTP_MODE_SET = {"mode-set", 8}; 
    715              
    716             if (pj_stricmp(&attr->setting.enc_fmtp.param[i].name,  
    717                            &STR_FMTP_MODE_SET) == 0) 
    718             { 
    719                 const char *p; 
    720                 pj_size_t l; 
    721                 pj_int8_t diff = 99; 
    722                  
    723                 p = pj_strbuf(&attr->setting.enc_fmtp.param[i].val); 
    724                 l = pj_strlen(&attr->setting.enc_fmtp.param[i].val); 
    725  
    726                 while (l--) { 
    727                     if ((desc->pt==PJMEDIA_RTP_PT_AMR && *p>='0' && *p<='7') || 
    728                         (desc->pt==PJMEDIA_RTP_PT_AMRWB && *p>='0' && *p<='8')) 
    729                     { 
    730                         pj_int8_t tmp = (pj_int8_t)(*p - '0' - enc_mode); 
    731  
    732                         if (PJ_ABS(diff) > PJ_ABS(tmp) ||  
    733                             (PJ_ABS(diff) == PJ_ABS(tmp) && tmp > diff)) 
    734                         { 
    735                             diff = tmp; 
    736                             if (diff == 0) break; 
    737                         } 
    738                     } 
    739                     ++p; 
    740                 } 
    741  
    742                 if (diff == 99) 
    743                     return PJMEDIA_CODEC_EFAILED; 
    744  
    745                 enc_mode = (pj_int8_t)(enc_mode + diff); 
    746  
    747                 break; 
    748             } 
    749         } 
    750  
    751699        s = PJ_POOL_ZALLOC_T(pool, amr_settings_t); 
    752700        codec_data->codec_setting = s; 
    753701 
    754         s->enc_mode = enc_mode; 
     702        s->enc_mode = pjmedia_codec_amr_get_mode(desc->def_bitrate); 
    755703        if (s->enc_mode < 0) 
    756704            return PJMEDIA_CODEC_EINMODE; 
     
    768716                                              doesn't do sensitivity bits  
    769717                                              reordering */ 
    770  
    771         /* Return back bitrate info to application */ 
    772         attr->info.avg_bps = s->enc_setting.amr_nb? 
    773                                 pjmedia_codec_amrnb_bitrates[s->enc_mode]: 
    774                                 pjmedia_codec_amrwb_bitrates[s->enc_mode]; 
    775718    } 
    776719#endif 
  • pjproject/trunk/pjmedia/src/pjmedia/codec.c

    r3074 r3075  
    2323#include <pj/assert.h> 
    2424#include <pj/log.h> 
     25#include <pj/pool.h> 
    2526#include <pj/string.h> 
    2627 
     
    2829 
    2930 
    30  
    31 /* Definition of default codecs parameters */ 
    32 struct pjmedia_codec_default_param 
    33 { 
    34     pj_pool_t           *pool; 
    35     pjmedia_codec_param *param; 
    36 }; 
    3731 
    3832 
     
    4438 * Initialize codec manager. 
    4539 */ 
    46 PJ_DEF(pj_status_t) pjmedia_codec_mgr_init (pjmedia_codec_mgr *mgr, 
    47                                             pj_pool_factory *pf) 
    48 { 
    49     pj_status_t status; 
    50  
    51     PJ_ASSERT_RETURN(mgr && pf, PJ_EINVAL); 
    52  
    53     /* Init codec manager */ 
    54     pj_bzero(mgr, sizeof(pjmedia_codec_mgr)); 
    55     mgr->pf = pf; 
     40PJ_DEF(pj_status_t) pjmedia_codec_mgr_init (pjmedia_codec_mgr *mgr) 
     41{ 
     42    PJ_ASSERT_RETURN(mgr, PJ_EINVAL); 
     43 
    5644    pj_list_init (&mgr->factory_list); 
    5745    mgr->codec_cnt = 0; 
    58  
    59     /* Create pool */ 
    60     mgr->pool = pj_pool_create(mgr->pf, "codec-mgr", 256, 256, NULL); 
    61  
    62     /* Create mutex */ 
    63     status = pj_mutex_create_recursive(mgr->pool, "codec-mgr", &mgr->mutex); 
    64     if (status != PJ_SUCCESS) 
    65         return status; 
    66  
    67     return PJ_SUCCESS; 
    68 } 
    69  
    70 /* 
    71  * Initialize codec manager. 
    72  */ 
    73 PJ_DEF(pj_status_t) pjmedia_codec_mgr_destroy (pjmedia_codec_mgr *mgr) 
    74 { 
    75     unsigned i; 
    76  
    77     PJ_ASSERT_RETURN(mgr, PJ_EINVAL); 
    78  
    79     /* Cleanup all pools of all codec default params */ 
    80     for (i=0; i<mgr->codec_cnt; ++i) { 
    81         if (mgr->codec_desc[i].param) { 
    82             pj_assert(mgr->codec_desc[i].param->pool); 
    83             pj_pool_release(mgr->codec_desc[i].param->pool); 
    84         } 
    85     } 
    86  
    87     /* Destroy mutex */ 
    88     pj_mutex_destroy(mgr->mutex); 
    89  
    90     /* Release pool */ 
    91     pj_pool_release(mgr->pool); 
    92  
    93     /* Just for safety, set codec manager states to zero */ 
    94     pj_bzero(mgr, sizeof(pjmedia_codec_mgr)); 
    9546 
    9647    return PJ_SUCCESS; 
     
    11566    if (status != PJ_SUCCESS) 
    11667        return status; 
    117  
    118     pj_mutex_lock(mgr->mutex); 
     68     
    11969 
    12070    /* Check codec count */ 
    121     if (count + mgr->codec_cnt > PJ_ARRAY_SIZE(mgr->codec_desc)) { 
    122         pj_mutex_unlock(mgr->mutex); 
     71    if (count + mgr->codec_cnt > PJ_ARRAY_SIZE(mgr->codec_desc)) 
    12372        return PJ_ETOOMANY; 
    124     } 
    12573 
    12674 
     
    14593    pj_list_push_back(&mgr->factory_list, factory); 
    14694 
    147     pj_mutex_unlock(mgr->mutex); 
    14895 
    14996    return PJ_SUCCESS; 
     
    161108    PJ_ASSERT_RETURN(mgr && factory, PJ_EINVAL); 
    162109 
    163     pj_mutex_lock(mgr->mutex); 
    164  
    165110    /* Factory must be registered. */ 
    166     if (pj_list_find_node(&mgr->factory_list, factory) != factory) { 
    167         pj_mutex_unlock(mgr->mutex); 
    168         return PJ_ENOTFOUND; 
    169     } 
     111    PJ_ASSERT_RETURN(pj_list_find_node(&mgr->factory_list, factory)==factory, 
     112                     PJ_ENOTFOUND); 
    170113 
    171114    /* Erase factory from the factory list */ 
     
    179122 
    180123        if (mgr->codec_desc[i].factory == factory) { 
    181             /* Release pool of codec default param */ 
    182             if (mgr->codec_desc[i].param) { 
    183                 pj_assert(mgr->codec_desc[i].param->pool); 
    184                 pj_pool_release(mgr->codec_desc[i].param->pool); 
    185             } 
    186  
    187             /* Remove the codec from array of codec descriptions */ 
     124 
    188125            pj_array_erase(mgr->codec_desc, sizeof(mgr->codec_desc[0]),  
    189126                           mgr->codec_cnt, i); 
     
    195132    } 
    196133 
    197     pj_mutex_unlock(mgr->mutex); 
    198134 
    199135    return PJ_SUCCESS; 
     
    212148 
    213149    PJ_ASSERT_RETURN(mgr && count && codecs, PJ_EINVAL); 
    214  
    215     pj_mutex_lock(mgr->mutex); 
    216150 
    217151    if (*count > mgr->codec_cnt) 
     
    229163    } 
    230164 
    231     pj_mutex_unlock(mgr->mutex); 
    232  
    233165    return PJ_SUCCESS; 
    234166} 
     
    246178    PJ_ASSERT_RETURN(mgr && p_info && pt>=0 && pt < 96, PJ_EINVAL); 
    247179 
    248     pj_mutex_lock(mgr->mutex); 
    249  
    250180    for (i=0; i<mgr->codec_cnt; ++i) { 
    251181        if (mgr->codec_desc[i].info.pt == pt) { 
    252182            *p_info = &mgr->codec_desc[i].info; 
    253  
    254             pj_mutex_unlock(mgr->mutex); 
    255183            return PJ_SUCCESS; 
    256184        } 
    257185    } 
    258  
    259     pj_mutex_unlock(mgr->mutex); 
    260186 
    261187    return PJMEDIA_CODEC_EUNSUP; 
     
    305231    PJ_ASSERT_RETURN(mgr && codec_id && count && *count, PJ_EINVAL); 
    306232 
    307     pj_mutex_lock(mgr->mutex); 
    308  
    309233    for (i=0; i<mgr->codec_cnt; ++i) { 
    310234 
     
    326250 
    327251    } 
    328  
    329     pj_mutex_unlock(mgr->mutex); 
    330252 
    331253    *count = found; 
     
    391313 
    392314    PJ_ASSERT_RETURN(mgr && codec_id, PJ_EINVAL); 
    393  
    394     pj_mutex_lock(mgr->mutex); 
    395315 
    396316    /* Update the priorities of affected codecs */ 
     
    406326    } 
    407327 
    408     if (!found) { 
    409         pj_mutex_unlock(mgr->mutex); 
     328    if (!found) 
    410329        return PJ_ENOTFOUND; 
    411     } 
    412330 
    413331    /* Re-sort codecs */ 
    414332    sort_codecs(mgr); 
    415  
    416     pj_mutex_unlock(mgr->mutex); 
     333  
    417334 
    418335    return PJ_SUCCESS; 
     
    434351    *p_codec = NULL; 
    435352 
    436     pj_mutex_lock(mgr->mutex); 
    437  
    438353    factory = mgr->factory_list.next; 
    439354    while (factory != &mgr->factory_list) { 
     
    442357 
    443358            status = (*factory->op->alloc_codec)(factory, info, p_codec); 
    444             if (status == PJ_SUCCESS) { 
    445                 pj_mutex_unlock(mgr->mutex); 
     359            if (status == PJ_SUCCESS) 
    446360                return PJ_SUCCESS; 
    447             } 
    448361 
    449362        } 
     
    452365    } 
    453366 
    454     pj_mutex_unlock(mgr->mutex); 
    455367 
    456368    return PJMEDIA_CODEC_EUNSUP; 
     
    467379    pjmedia_codec_factory *factory; 
    468380    pj_status_t status; 
    469     pjmedia_codec_id codec_id; 
    470     struct pjmedia_codec_desc *codec_desc = NULL; 
    471     unsigned i; 
    472381 
    473382    PJ_ASSERT_RETURN(mgr && info && param, PJ_EINVAL); 
    474383 
    475     if (!pjmedia_codec_info_to_id(info, (char*)&codec_id, sizeof(codec_id))) 
    476         return PJ_EINVAL; 
    477  
    478     pj_mutex_lock(mgr->mutex); 
    479  
    480     /* First, lookup default param in codec desc */ 
    481     for (i=0; i < mgr->codec_cnt; ++i) { 
    482         if (pj_ansi_stricmp(codec_id, mgr->codec_desc[i].id) == 0) { 
    483             codec_desc = &mgr->codec_desc[i]; 
    484             break; 
    485         } 
    486     } 
    487  
    488     /* If we found the codec and its default param is set, return it */ 
    489     if (codec_desc && codec_desc->param) { 
    490         pj_assert(codec_desc->param->param); 
    491         pj_memcpy(param, codec_desc->param->param,  
    492                   sizeof(pjmedia_codec_param)); 
    493  
    494         pj_mutex_unlock(mgr->mutex); 
    495         return PJ_SUCCESS; 
    496     } 
    497  
    498     /* Otherwise query the default param from codec factory */ 
    499384    factory = mgr->factory_list.next; 
    500385    while (factory != &mgr->factory_list) { 
     
    508393                    param->info.max_bps = param->info.avg_bps; 
    509394 
    510                 pj_mutex_unlock(mgr->mutex); 
    511395                return PJ_SUCCESS; 
    512396            } 
     
    517401    } 
    518402 
    519     pj_mutex_unlock(mgr->mutex); 
    520  
    521403 
    522404    return PJMEDIA_CODEC_EUNSUP; 
    523 } 
    524  
    525  
    526 /* 
    527  * Set default codec parameter. 
    528  */ 
    529 PJ_DEF(pj_status_t) pjmedia_codec_mgr_set_default_param(  
    530                                             pjmedia_codec_mgr *mgr, 
    531                                             const pjmedia_codec_info *info, 
    532                                             const pjmedia_codec_param *param ) 
    533 { 
    534     unsigned i; 
    535     pjmedia_codec_id codec_id; 
    536     pj_pool_t *pool; 
    537     struct pjmedia_codec_desc *codec_desc = NULL; 
    538     pjmedia_codec_default_param *p; 
    539  
    540     PJ_ASSERT_RETURN(mgr && info, PJ_EINVAL); 
    541  
    542     if (!pjmedia_codec_info_to_id(info, (char*)&codec_id, sizeof(codec_id))) 
    543         return PJ_EINVAL; 
    544  
    545     pj_mutex_lock(mgr->mutex); 
    546  
    547     /* Lookup codec desc */ 
    548     for (i=0; i < mgr->codec_cnt; ++i) { 
    549         if (pj_ansi_stricmp(codec_id, mgr->codec_desc[i].id) == 0) { 
    550             codec_desc = &mgr->codec_desc[i]; 
    551             break; 
    552         } 
    553     } 
    554  
    555     /* Codec not found */ 
    556     if (!codec_desc) { 
    557         pj_mutex_unlock(mgr->mutex); 
    558         return PJMEDIA_CODEC_EUNSUP; 
    559     } 
    560  
    561     /* If codec param is previously set, release codec param pool */ 
    562     if (codec_desc->param) { 
    563         pj_assert(codec_desc->param->pool); 
    564         pj_pool_release(codec_desc->param->pool); 
    565         codec_desc->param = NULL; 
    566     } 
    567  
    568     /* When param is set to NULL, i.e: setting default codec param to library 
    569      * default setting, just return PJ_SUCCESS. 
    570      */ 
    571     if (NULL == param) { 
    572         pj_mutex_unlock(mgr->mutex); 
    573         return PJ_SUCCESS; 
    574     } 
    575  
    576     /* Instantiate and initialize codec param */ 
    577     pool = pj_pool_create(mgr->pf, (char*)codec_id, 256, 256, NULL); 
    578     codec_desc->param = PJ_POOL_ZALLOC_T(pool, pjmedia_codec_default_param); 
    579     p = codec_desc->param; 
    580     p->pool = pool; 
    581     p->param = PJ_POOL_ZALLOC_T(pool, pjmedia_codec_param); 
    582  
    583     /* Update codec param */ 
    584     pj_memcpy(p->param, param, sizeof(pjmedia_codec_param)); 
    585     for (i = 0; i < param->setting.dec_fmtp.cnt; ++i) { 
    586         pj_strdup(pool, &p->param->setting.dec_fmtp.param[i].name,  
    587                   &param->setting.dec_fmtp.param[i].name); 
    588         pj_strdup(pool, &p->param->setting.dec_fmtp.param[i].val,  
    589                   &param->setting.dec_fmtp.param[i].val); 
    590     } 
    591     for (i = 0; i < param->setting.dec_fmtp.cnt; ++i) { 
    592         pj_strdup(pool, &p->param->setting.dec_fmtp.param[i].name,  
    593                   &param->setting.dec_fmtp.param[i].name); 
    594         pj_strdup(pool, &p->param->setting.dec_fmtp.param[i].val,  
    595                   &param->setting.dec_fmtp.param[i].val); 
    596     } 
    597  
    598     pj_mutex_unlock(mgr->mutex); 
    599  
    600     return PJ_SUCCESS; 
    601405} 
    602406 
  • pjproject/trunk/pjmedia/src/pjmedia/endpoint.c

    r3074 r3075  
    128128 
    129129    /* Init codec manager. */ 
    130     status = pjmedia_codec_mgr_init(&endpt->codec_mgr, endpt->pf); 
     130    status = pjmedia_codec_mgr_init(&endpt->codec_mgr); 
    131131    if (status != PJ_SUCCESS) 
    132132        goto on_error; 
     
    173173        pj_ioqueue_destroy(endpt->ioqueue); 
    174174 
    175     pjmedia_codec_mgr_destroy(&endpt->codec_mgr); 
    176175    pjmedia_aud_subsys_shutdown(); 
    177176    pj_pool_release(pool); 
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h

    r3074 r3075  
    44844484 * 
    44854485 * @param codec_id      Codec ID. 
    4486  * @param param         Codec parameter to set. Set to NULL to reset 
    4487  *                      codec parameter to library default settings. 
     4486 * @param param         Codec parameter to set. 
    44884487 * 
    44894488 * @return              PJ_SUCCESS on success, or the appropriate error code. 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c

    r3074 r3075  
    30553055 * Set codec parameters. 
    30563056 */ 
    3057 PJ_DEF(pj_status_t) pjsua_codec_set_param( const pj_str_t *codec_id, 
     3057PJ_DEF(pj_status_t) pjsua_codec_set_param( const pj_str_t *id, 
    30583058                                           const pjmedia_codec_param *param) 
    30593059{ 
    3060     const pjmedia_codec_info *info[2]; 
    3061     pjmedia_codec_mgr *codec_mgr; 
    3062     unsigned count = 2; 
    3063     pj_status_t status; 
    3064  
    3065     codec_mgr = pjmedia_endpt_get_codec_mgr(pjsua_var.med_endpt); 
    3066  
    3067     status = pjmedia_codec_mgr_find_codecs_by_id(codec_mgr, codec_id, 
    3068                                                  &count, info, NULL); 
    3069     if (status != PJ_SUCCESS) 
    3070         return status; 
    3071  
    3072     /* Codec ID should be specific, except for G.722.1 */ 
    3073     if (count > 1 &&  
    3074         pj_strnicmp2(codec_id, "G7221/16", 8) != 0 && 
    3075         pj_strnicmp2(codec_id, "G7221/32", 8) != 0) 
    3076     { 
    3077         pj_assert(!"Codec ID is not specific"); 
    3078         return PJ_ETOOMANY; 
    3079     } 
    3080  
    3081     status = pjmedia_codec_mgr_set_default_param(codec_mgr, info[0], param); 
    3082     return status; 
    3083 } 
     3060    PJ_UNUSED_ARG(id); 
     3061    PJ_UNUSED_ARG(param); 
     3062    PJ_TODO(set_codec_param); 
     3063    return PJ_SUCCESS; 
     3064} 
Note: See TracChangeset for help on using the changeset viewer.