Ignore:
Timestamp:
Jan 27, 2010 11:48:31 AM (14 years ago)
Author:
nanang
Message:

Ticket #1028: Recommit r3074 with updated codec.h.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia-codec/passthrough.c

    r3075 r3078  
    2525#include <pj/assert.h> 
    2626#include <pj/log.h> 
     27#include <pj/math.h> 
    2728#include <pj/pool.h> 
    2829#include <pj/string.h> 
     
    697698        } 
    698699 
     700        for (i = 0; i < attr->setting.enc_fmtp.cnt; ++i) { 
     701            /* mode-set, encoding mode is chosen based on local default mode  
     702             * setting: 
     703             * - if local default mode is included in the mode-set, use it 
     704             * - otherwise, find the closest mode to local default mode; 
     705             *   if there are two closest modes, prefer to use the higher 
     706             *   one, e.g: local default mode is 4, the mode-set param 
     707             *   contains '2,3,5,6', then 5 will be chosen. 
     708             */ 
     709            const pj_str_t STR_FMTP_MODE_SET = {"mode-set", 8}; 
     710             
     711            if (pj_stricmp(&attr->setting.enc_fmtp.param[i].name,  
     712                           &STR_FMTP_MODE_SET) == 0) 
     713            { 
     714                const char *p; 
     715                pj_size_t l; 
     716                pj_int8_t diff = 99; 
     717                 
     718                p = pj_strbuf(&attr->setting.enc_fmtp.param[i].val); 
     719                l = pj_strlen(&attr->setting.enc_fmtp.param[i].val); 
     720 
     721                while (l--) { 
     722                    if ((desc->pt==PJMEDIA_RTP_PT_AMR && *p>='0' && *p<='7') || 
     723                        (desc->pt==PJMEDIA_RTP_PT_AMRWB && *p>='0' && *p<='8')) 
     724                    { 
     725                        pj_int8_t tmp = (pj_int8_t)(*p - '0' - enc_mode); 
     726 
     727                        if (PJ_ABS(diff) > PJ_ABS(tmp) ||  
     728                            (PJ_ABS(diff) == PJ_ABS(tmp) && tmp > diff)) 
     729                        { 
     730                            diff = tmp; 
     731                            if (diff == 0) break; 
     732                        } 
     733                    } 
     734                    ++p; 
     735                } 
     736 
     737                if (diff == 99) 
     738                    return PJMEDIA_CODEC_EFAILED; 
     739 
     740                enc_mode = (pj_int8_t)(enc_mode + diff); 
     741 
     742                break; 
     743            } 
     744        } 
     745 
    699746        s = PJ_POOL_ZALLOC_T(pool, amr_settings_t); 
    700747        codec_data->codec_setting = s; 
    701748 
    702         s->enc_mode = pjmedia_codec_amr_get_mode(desc->def_bitrate); 
     749        s->enc_mode = enc_mode; 
    703750        if (s->enc_mode < 0) 
    704751            return PJMEDIA_CODEC_EINMODE; 
Note: See TracChangeset for help on using the changeset viewer.