Ignore:
Timestamp:
Apr 27, 2006 10:36:40 PM (18 years ago)
Author:
bennylp
Message:

Initial support for stereo codecs, and added L16 codecs. Also better handling for case remote media is restarted

File:
1 edited

Legend:

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

    r320 r411  
    5757 
    5858/* Prototypes for Speex implementation. */ 
    59 static pj_status_t  spx_codec_default_attr(pjmedia_codec *codec,  
    60                                            pjmedia_codec_param *attr); 
    6159static pj_status_t  spx_codec_init( pjmedia_codec *codec,  
    6260                                    pj_pool_t *pool ); 
     
    8179static pjmedia_codec_op spx_op =  
    8280{ 
    83     &spx_codec_default_attr, 
    8481    &spx_codec_init, 
    8582    &spx_codec_open, 
     
    231228    spx_factory.speex_param[PARAM_NB].enabled =  
    232229        ((options & PJMEDIA_SPEEX_NO_NB) == 0); 
    233     spx_factory.speex_param[PARAM_NB].pt = 102; 
     230    spx_factory.speex_param[PARAM_NB].pt = PJMEDIA_RTP_PT_SPEEX_NB; 
    234231    spx_factory.speex_param[PARAM_NB].mode = &speex_nb_mode; 
    235232    spx_factory.speex_param[PARAM_NB].clock_rate = 8000; 
     
    239236    spx_factory.speex_param[PARAM_WB].enabled =  
    240237        ((options & PJMEDIA_SPEEX_NO_WB) == 0); 
    241     spx_factory.speex_param[PARAM_WB].pt = 103; 
     238    spx_factory.speex_param[PARAM_WB].pt = PJMEDIA_RTP_PT_SPEEX_WB; 
    242239    spx_factory.speex_param[PARAM_WB].mode = &speex_wb_mode; 
    243240    spx_factory.speex_param[PARAM_WB].clock_rate = 16000; 
     
    247244    spx_factory.speex_param[PARAM_UWB].enabled =  
    248245        ((options & PJMEDIA_SPEEX_NO_UWB) == 0); 
    249     spx_factory.speex_param[PARAM_UWB].pt = 104; 
     246    spx_factory.speex_param[PARAM_UWB].pt = PJMEDIA_RTP_PT_SPEEX_UWB; 
    250247    spx_factory.speex_param[PARAM_UWB].mode = &speex_uwb_mode; 
    251248    spx_factory.speex_param[PARAM_UWB].clock_rate = 32000; 
     
    359356    /* Check clock-rate */ 
    360357    for (i=0; i<PJ_ARRAY_SIZE(spx_factory.speex_param); ++i) { 
    361         if (info->sample_rate == spx_factory.speex_param[i].clock_rate) { 
     358        if (info->clock_rate == spx_factory.speex_param[i].clock_rate) { 
    362359            /* Okay, let's Speex! */ 
    363360            return PJ_SUCCESS; 
     
    382379    pj_memset(attr, 0, sizeof(pjmedia_codec_param)); 
    383380    attr->pt = id->pt; 
    384  
    385     if (id->sample_rate <= 8000) { 
    386         attr->sample_rate = spx_factory.speex_param[PARAM_NB].clock_rate; 
     381    attr->channel_cnt = 1; 
     382 
     383    if (id->clock_rate <= 8000) { 
     384        attr->clock_rate = spx_factory.speex_param[PARAM_NB].clock_rate; 
    387385        attr->avg_bps = spx_factory.speex_param[PARAM_NB].bitrate; 
    388386 
    389     } else if (id->sample_rate <= 16000) { 
    390         attr->sample_rate = spx_factory.speex_param[PARAM_WB].clock_rate; 
     387    } else if (id->clock_rate <= 16000) { 
     388        attr->clock_rate = spx_factory.speex_param[PARAM_WB].clock_rate; 
    391389        attr->avg_bps = spx_factory.speex_param[PARAM_WB].bitrate; 
    392390 
    393391    } else { 
    394392        /* Wow.. somebody is doing ultra-wideband. Cool...! */ 
    395         attr->sample_rate = spx_factory.speex_param[PARAM_UWB].clock_rate; 
     393        attr->clock_rate = spx_factory.speex_param[PARAM_UWB].clock_rate; 
    396394        attr->avg_bps = spx_factory.speex_param[PARAM_UWB].bitrate; 
    397395    } 
     
    402400 
    403401    /* Default flags. */ 
    404     attr->cng_enabled = 1; 
    405     attr->concl_enabled = 1; 
    406     attr->hpf_enabled = 1; 
    407     attr->lpf_enabled =1 ; 
    408     attr->penh_enabled =1 ; 
     402    attr->cng = 1; 
     403    attr->concl = 1; 
     404    attr->hpf = 1; 
     405    attr->lpf =1 ; 
     406    attr->penh =1 ; 
    409407 
    410408    /* Default, set VAD off as it caused voice chip off */ 
    411     attr->vad_enabled = 0; 
     409    attr->vad = 0; 
    412410 
    413411    return PJ_SUCCESS; 
     
    443441        codecs[*count].pt = spx_factory.speex_param[i].pt; 
    444442        codecs[*count].type = PJMEDIA_TYPE_AUDIO; 
    445         codecs[*count].sample_rate = spx_factory.speex_param[i].clock_rate; 
     443        codecs[*count].clock_rate = spx_factory.speex_param[i].clock_rate; 
     444        codecs[*count].channel_cnt = 1; 
    446445 
    447446        ++*count; 
     
    487486    spx->dec = NULL; 
    488487 
    489     if (id->sample_rate <= 8000) 
     488    if (id->clock_rate <= 8000) 
    490489        spx->param_id = PARAM_NB; 
    491     else if (id->sample_rate <= 16000) 
     490    else if (id->clock_rate <= 16000) 
    492491        spx->param_id = PARAM_WB; 
    493492    else 
     
    521520 
    522521    return PJ_SUCCESS; 
    523 } 
    524  
    525 /* 
    526  * Get codec default attributes. 
    527  */ 
    528 static pj_status_t spx_codec_default_attr( pjmedia_codec *codec,  
    529                                            pjmedia_codec_param *attr) 
    530 { 
    531     struct spx_private *spx; 
    532     pjmedia_codec_info info; 
    533  
    534     spx = (struct spx_private*) codec->codec_data; 
    535  
    536     info.encoding_name = pj_str("speex"); 
    537     info.pt = 200;  /* Don't care */ 
    538     info.sample_rate = spx_factory.speex_param[spx->param_id].clock_rate; 
    539     info.type = PJMEDIA_TYPE_AUDIO; 
    540  
    541     return spx_default_attr( codec->factory, &info, attr); 
    542522} 
    543523 
     
    580560 
    581561    /* Sampling rate. */ 
    582     tmp = attr->sample_rate; 
     562    tmp = attr->clock_rate; 
    583563    speex_encoder_ctl(spx->enc, SPEEX_SET_SAMPLING_RATE,  
    584564                      &spx_factory.speex_param[id].clock_rate); 
    585565 
    586566    /* VAD */ 
    587     tmp = attr->vad_enabled; 
     567    tmp = attr->vad; 
    588568    speex_encoder_ctl(spx->enc, SPEEX_SET_VAD, &tmp); 
    589569 
     
    609589 
    610590    /* PENH */ 
    611     tmp = attr->penh_enabled; 
     591    tmp = attr->penh; 
    612592    speex_decoder_ctl(spx->dec, SPEEX_SET_ENH, &tmp); 
    613593 
Note: See TracChangeset for help on using the changeset viewer.