Changeset 2833


Ignore:
Timestamp:
Jul 14, 2009 2:33:39 PM (15 years ago)
Author:
nanang
Message:

Ticket #909:

  • Added support for Nokia VAS 2.0.
  • Fixed wrong value assigned to last downstream state var in downstream callback.
  • Minor fix in config_site_sample.h related to VAS Direct setting.
Location:
pjproject/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/include/pj/config_site_sample.h

    r2821 r2833  
    223223    #define PJMEDIA_CONF_USE_SWITCH_BOARD       1 
    224224 
    225     /* Enable APS sound device backend and disable MDA */ 
     225    /* Enable APS sound device backend and disable MDA & VAS */ 
    226226    #define PJMEDIA_AUDIO_DEV_HAS_SYMB_MDA      0 
    227227    #define PJMEDIA_AUDIO_DEV_HAS_SYMB_APS      1 
     228    #define PJMEDIA_AUDIO_DEV_HAS_SYMB_VAS      0 
    228229 
    229230    /* Enable passthrough codec framework */ 
     
    251252    #define PJMEDIA_CONF_USE_SWITCH_BOARD       1 
    252253 
    253     /* Enable APS sound device backend and disable MDA */ 
     254    /* Enable VAS sound device backend and disable MDA & APS */ 
    254255    #define PJMEDIA_AUDIO_DEV_HAS_SYMB_MDA      0 
     256    #define PJMEDIA_AUDIO_DEV_HAS_SYMB_APS      0 
    255257    #define PJMEDIA_AUDIO_DEV_HAS_SYMB_VAS      1 
    256258 
  • pjproject/trunk/pjmedia/include/pjmedia-audiodev/config.h

    r2821 r2833  
    7272#ifndef PJMEDIA_AUDIO_DEV_HAS_SYMB_VAS 
    7373#   define PJMEDIA_AUDIO_DEV_HAS_SYMB_VAS       0 
     74#endif 
     75 
     76/** 
     77 * This setting controls Symbian VAS version to be used. Currently, valid 
     78 * values are only 1 (for VAS 1.0) and 2 (for VAS 2.0). 
     79 * 
     80 * Default: 1 (VAS version 1.0) 
     81 */ 
     82#ifndef PJMEDIA_AUDIO_DEV_SYMB_VAS_VERSION 
     83#   define PJMEDIA_AUDIO_DEV_SYMB_VAS_VERSION   1 
    7484#endif 
    7585 
  • pjproject/trunk/pjmedia/src/pjmedia-audiodev/symb_vas_dev.cpp

    r2821 r2833  
    313313{ 
    314314    TInt err; 
    315     const TVersion ver(1, 0, 0); 
     315    const TVersion ver(1, 0, 0); /* Not really used at this time */ 
    316316 
    317317    err = CVoIPUtilityFactory::CreateFactory(iFactory); 
     
    396396    if (err != KErrNone) 
    397397        return err; 
    398  
     398     
     399    err = enc_fmt_if->SetObserver(*this); 
     400    if (err != KErrNone) 
     401        return err; 
     402     
    399403    return iVoIPUplink->Open(*this); 
    400404} 
     
    402406TInt CPjAudioEngine::StartPlay() 
    403407{ 
     408    TInt err; 
     409     
    404410    pj_assert(iVoIPDnlink); 
    405411    pj_assert(dn_state_ == STATE_READY); 
     
    408414    switch (setting_.format) { 
    409415    case EG711: 
    410     //case EG711_10MS: 
    411416        { 
    412417            CVoIPG711DecoderIntfc *g711dec_if = (CVoIPG711DecoderIntfc*) 
    413418                                                dec_fmt_if; 
    414             g711dec_if->SetMode((CVoIPFormatIntfc::TG711CodecMode) 
    415                                 setting_.mode); 
     419            err = g711dec_if->SetMode((CVoIPFormatIntfc::TG711CodecMode) 
     420                                      setting_.mode); 
     421            pj_assert(err == KErrNone); 
    416422        } 
    417423        break; 
     
    421427            CVoIPILBCDecoderIntfc *ilbcdec_if = (CVoIPILBCDecoderIntfc*) 
    422428                                                dec_fmt_if; 
    423             ilbcdec_if->SetMode((CVoIPFormatIntfc::TILBCCodecMode) 
    424                                 setting_.mode); 
     429            err = ilbcdec_if->SetMode((CVoIPFormatIntfc::TILBCCodecMode) 
     430                                      setting_.mode); 
     431            pj_assert(err == KErrNone); 
    425432        } 
    426433        break; 
     
    434441 
    435442    /* Start player */ 
    436     TInt err = iVoIPDnlink->Start(); 
     443    err = iVoIPDnlink->Start(); 
    437444     
    438445    if (err == KErrNone) { 
     
    448455TInt CPjAudioEngine::StartRec() 
    449456{ 
     457    TInt err; 
     458     
    450459    pj_assert(iVoIPUplink); 
    451460    pj_assert(up_state_ == STATE_READY); 
    452461 
    453     /* Configure general codec setting */ 
    454     enc_fmt_if->SetVAD(setting_.vad); 
    455      
    456462    /* Configure specific codec setting */ 
    457463    switch (setting_.format) { 
    458464    case EG711: 
    459     //case EG711_10MS: 
    460465        { 
    461466            CVoIPG711EncoderIntfc *g711enc_if = (CVoIPG711EncoderIntfc*) 
    462467                                                enc_fmt_if; 
    463             g711enc_if->SetMode((CVoIPFormatIntfc::TG711CodecMode) 
    464                                 setting_.mode); 
     468            err = g711enc_if->SetMode((CVoIPFormatIntfc::TG711CodecMode) 
     469                                      setting_.mode); 
     470            pj_assert(err == KErrNone); 
    465471        } 
    466472        break; 
     
    470476            CVoIPILBCEncoderIntfc *ilbcenc_if = (CVoIPILBCEncoderIntfc*) 
    471477                                                enc_fmt_if; 
    472             ilbcenc_if->SetMode((CVoIPFormatIntfc::TILBCCodecMode) 
    473                                 setting_.mode); 
     478            err = ilbcenc_if->SetMode((CVoIPFormatIntfc::TILBCCodecMode) 
     479                                      setting_.mode); 
     480            pj_assert(err == KErrNone); 
    474481        } 
    475482        break; 
     
    479486    } 
    480487     
     488    /* Configure general codec setting */ 
     489    enc_fmt_if->SetVAD(setting_.vad); 
     490     
    481491    /* Start recorder */ 
    482     TInt err = iVoIPUplink->Start(); 
     492    err = iVoIPUplink->Start(); 
    483493     
    484494    if (err == KErrNone) { 
     
    601611    case MVoIPDownlinkObserver::KOpenComplete: 
    602612        if (aError == KErrNone) { 
    603             State last_state = up_state_; 
     613            State last_state = dn_state_; 
    604614 
    605615            dn_state_ = STATE_READY; 
     
    944954        { 
    945955            /* Check if we got a normal or SID frame. */ 
    946             if (buffer[0] != 0 || buffer[1] != 0) { 
     956            if (buffer[0] != 0) { 
    947957                enum { NORMAL_LEN = 22, SID_LEN = 8 }; 
    948958                TBitStream *bitstream = (TBitStream*)strm->strm_data; 
     
    950960                 
    951961                pj_assert(src_len == NORMAL_LEN || src_len == SID_LEN); 
    952  
     962                 
    953963                const TDesC8& p = bitstream->CompressG729Frame( 
    954964                                            buffer.Right(src_len),  
     
    976986            samples_got = strm->param.ext_fmt.bitrate == 15200? 160 : 240; 
    977987             
    978             /* Check if we got a normal frame. */ 
    979             if (buffer[0] == 1 && buffer[1] == 0) { 
     988            /* Check if we got a normal or SID frame. */ 
     989            if (buffer[0] != 0) { 
    980990                const pj_uint8_t *p = (const pj_uint8_t*)buffer.Ptr() + 2; 
    981991                unsigned len = buffer.Length() - 2; 
     
    11261136                                                                   sid_frame);  
    11271137                    if (sid_frame) { 
     1138                        buffer.Append(2); 
    11281139                        buffer.Append(0); 
    1129                         buffer.Append(1); 
    11301140                    } else { 
    11311141                        buffer.Append(1); 
     
    11341144                    buffer.Append(dst); 
    11351145                } else { 
     1146                    buffer.Append(2); 
    11361147                    buffer.Append(0); 
    1137                     buffer.Append(0); 
     1148 
     1149                    buffer.AppendFill(0, 22); 
    11381150                } 
    11391151 
     
    11411153             
    11421154            } else { /* PJMEDIA_FRAME_TYPE_NONE */ 
     1155                buffer.Append(2); 
    11431156                buffer.Append(0); 
    1144                 buffer.Append(0); 
    1145                  
    1146                 frame->samples_cnt = 0; 
    1147                 frame->subframe_cnt = 0; 
     1157                 
     1158                buffer.AppendFill(0, 22); 
    11481159            } 
    11491160        } 
     
    11761187                    buffer.Append((TUint8*)sf->data, sf->bitlen>>3); 
    11771188                } else { 
     1189                    unsigned frame_len; 
     1190                     
     1191                    buffer.Append(1); 
    11781192                    buffer.Append(0); 
    1179                     buffer.Append(0); 
     1193                     
     1194                    /* VAS iLBC frame is 20ms or 30ms */ 
     1195                    frame_len = strm->param.ext_fmt.bitrate == 15200? 38 : 50; 
     1196                    buffer.AppendFill(0, frame_len); 
    11801197                } 
    11811198 
     
    11831200             
    11841201            } else { /* PJMEDIA_FRAME_TYPE_NONE */ 
     1202                 
     1203                unsigned frame_len; 
     1204                 
     1205                buffer.Append(1); 
    11851206                buffer.Append(0); 
    1186                 buffer.Append(0); 
    1187                  
    1188                 frame->samples_cnt = 0; 
    1189                 frame->subframe_cnt = 0; 
     1207                 
     1208                /* VAS iLBC frame is 20ms or 30ms */ 
     1209                frame_len = strm->param.ext_fmt.bitrate == 15200? 38 : 50; 
     1210                buffer.AppendFill(0, frame_len); 
     1211 
    11901212            } 
    11911213        } 
     
    12891311    struct vas_factory *af = (struct vas_factory*)f; 
    12901312    CVoIPUtilityFactory *vas_factory; 
     1313    CVoIPAudioUplinkStream *vas_uplink; 
     1314    CVoIPAudioDownlinkStream *vas_dnlink; 
    12911315    RArray<TVoIPCodecFormat> uplink_formats, dnlink_formats; 
    12921316    unsigned ext_fmt_cnt = 0; 
     1317    TVersion vas_version(1, 0, 0); /* Not really used at this time */ 
    12931318    TInt err; 
    12941319 
     
    13121337        goto on_error; 
    13131338 
     1339    /* On VAS 2.0, uplink & downlink stream should be instantiated before  
     1340     * querying formats. 
     1341     */ 
     1342    err = vas_factory->CreateUplinkStream(vas_version,  
     1343                                          CVoIPUtilityFactory::EVoIPCall, 
     1344                                          vas_uplink); 
     1345    if (err != KErrNone) 
     1346        goto on_error; 
     1347     
     1348    err = vas_factory->CreateDownlinkStream(vas_version,  
     1349                                            CVoIPUtilityFactory::EVoIPCall, 
     1350                                            vas_dnlink); 
     1351    if (err != KErrNone) 
     1352        goto on_error; 
     1353     
    13141354    uplink_formats.Reset(); 
    13151355    err = vas_factory->GetSupportedUplinkFormats(uplink_formats); 
     
    13221362        goto on_error; 
    13231363 
     1364    /* Free the streams, they are just used for querying formats */ 
     1365    delete vas_uplink; 
     1366    vas_uplink = NULL; 
     1367    delete vas_dnlink; 
     1368    vas_dnlink = NULL; 
     1369     
    13241370    for (TInt i = 0; i < dnlink_formats.Count(); i++) { 
    13251371        /* Format must be supported by both downlink & uplink. */ 
     
    13471393 
    13481394        case EG711: 
     1395#if PJMEDIA_AUDIO_DEV_SYMB_VAS_VERSION==2 
     1396        case EG711_10MS: 
     1397#endif 
    13491398            af->dev_info.ext_fmt[ext_fmt_cnt].id = PJMEDIA_FORMAT_PCMU; 
    13501399            af->dev_info.ext_fmt[ext_fmt_cnt].bitrate = 64000; 
     
    15411590    } 
    15421591 
    1543     /* Disable VAD on L16, G711, and also G729 (G729's VAD potentially  
    1544      * causes noise?). 
     1592    /* Disable VAD on L16, G711, iLBC, and also G729 (G729's SID  
     1593     * potentially cause noise?). 
    15451594     */ 
    15461595    if (strm->param.ext_fmt.id == PJMEDIA_FORMAT_PCMU || 
    15471596        strm->param.ext_fmt.id == PJMEDIA_FORMAT_PCMA || 
    15481597        strm->param.ext_fmt.id == PJMEDIA_FORMAT_L16 || 
     1598        strm->param.ext_fmt.id == PJMEDIA_FORMAT_ILBC || 
    15491599        strm->param.ext_fmt.id == PJMEDIA_FORMAT_G729) 
    15501600    { 
Note: See TracChangeset for help on using the changeset viewer.