Ignore:
Timestamp:
Feb 19, 2009 7:13:49 PM (15 years ago)
Author:
nanang
Message:

Added volume settings capability to Symbian APS audiodev.

Location:
pjproject/branches/projects/aps-direct/pjmedia
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia-audiodev/audiodev.h

    r2463 r2466  
    578578#define PJMEDIA_EAUD_NODEV      -1 
    579579 
     580/* Device not ready */ 
     581#define PJMEDIA_EAUD_NOTREADY   -1 
     582 
    580583/* Unknown system error */ 
    581584#define PJMEDIA_EAUD_SYSERR     -1 
  • pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia-audiodev/symb_aps_dev.cpp

    r2465 r2466  
    367367 
    368368    TInt ActivateSpeaker(TBool active); 
     369     
     370    TInt SetVolume(TInt vol) { return iSession.SetVolume(vol); } 
     371    TInt GetVolume() { return iSession.Volume(); } 
     372    TInt GetMaxVolume() { return iSession.MaxVolume(); } 
     373     
     374    TInt SetGain(TInt gain) { return iSession.SetGain(gain); } 
     375    TInt GetGain() { return iSession.Gain(); } 
     376    TInt GetMaxGain() { return iSession.MaxGain(); } 
    369377 
    370378private: 
     
    11071115    af->dev_info.default_samples_per_sec = 8000; 
    11081116    af->dev_info.caps = PJMEDIA_AUD_DEV_CAP_EXT_FORMAT | 
    1109                         //PJMEDIA_AUD_DEV_CAP_INPUT_VOLUME_SETTING | 
    1110                         //PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING | 
     1117                        PJMEDIA_AUD_DEV_CAP_INPUT_VOLUME_SETTING | 
     1118                        PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING | 
    11111119                        PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE | 
    11121120                        PJMEDIA_AUD_DEV_CAP_VAD | 
     
    11161124    af->dev_info.input_count = 1; 
    11171125    af->dev_info.output_count = 1; 
    1118      
    1119     af->dev_info.ext_fmt_cnt = 2; 
    1120      
     1126 
     1127    af->dev_info.ext_fmt_cnt = 6; 
    11211128    af->dev_info.ext_fmt[0].id = PJMEDIA_FORMAT_AMR; 
    1122     af->dev_info.ext_fmt[0].bitrate = 0; 
    1123     af->dev_info.ext_fmt[0].vad = PJ_TRUE; 
    1124  
    11251129    af->dev_info.ext_fmt[1].id = PJMEDIA_FORMAT_G729; 
    1126     af->dev_info.ext_fmt[1].bitrate = 0; 
    1127     af->dev_info.ext_fmt[1].vad = PJ_TRUE; 
     1130    af->dev_info.ext_fmt[2].id = PJMEDIA_FORMAT_ILBC; 
     1131    af->dev_info.ext_fmt[3].id = PJMEDIA_FORMAT_PCMU; 
     1132    af->dev_info.ext_fmt[4].id = PJMEDIA_FORMAT_PCMA; 
     1133    af->dev_info.ext_fmt[5].id = PJMEDIA_FORMAT_L16; 
    11281134     
    11291135    PJ_LOG(4, (THIS_FILE, "APS initialized")); 
     
    11411147    pj_pool_release(pool); 
    11421148 
     1149    PJ_LOG(4, (THIS_FILE, "APS destroyed")); 
     1150     
    11431151    return PJ_SUCCESS; 
    11441152} 
     
    11831191    param->bits_per_sample = BITS_PER_SAMPLE; 
    11841192    param->flags = af->dev_info.caps; 
     1193    param->ext_fmt.id = PJMEDIA_FORMAT_L16; 
     1194    param->out_route = PJMEDIA_AUD_DEV_ROUTE_EARPIECE; 
    11851195 
    11861196    return PJ_SUCCESS; 
     
    13521362        break; 
    13531363    case PJMEDIA_AUD_DEV_CAP_INPUT_VOLUME_SETTING: 
     1364        if (strm->param.dir & PJMEDIA_DIR_CAPTURE) { 
     1365            PJ_ASSERT_RETURN(strm->engine, PJ_EINVAL); 
     1366             
     1367            TInt max_gain = strm->engine->GetMaxGain(); 
     1368            TInt gain = strm->engine->GetGain(); 
     1369             
     1370            if (max_gain > 0 && gain >= 0) { 
     1371                *(unsigned*)pval = gain * 100 / max_gain;  
     1372                status = PJ_SUCCESS; 
     1373            } else { 
     1374                status = PJMEDIA_EAUD_NOTREADY; 
     1375            } 
     1376        } 
    13541377        break; 
    13551378    case PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING: 
     1379        if (strm->param.dir & PJMEDIA_DIR_PLAYBACK) { 
     1380            PJ_ASSERT_RETURN(strm->engine, PJ_EINVAL); 
     1381             
     1382            TInt max_vol = strm->engine->GetMaxVolume(); 
     1383            TInt vol = strm->engine->GetVolume(); 
     1384             
     1385            if (max_vol > 0 && vol >= 0) { 
     1386                *(unsigned*)pval = vol * 100 / max_vol;  
     1387                status = PJ_SUCCESS; 
     1388            } else { 
     1389                status = PJMEDIA_EAUD_NOTREADY; 
     1390            } 
     1391        } 
    13561392        break; 
    13571393    default: 
     
    13991435        break; 
    14001436    case PJMEDIA_AUD_DEV_CAP_INPUT_VOLUME_SETTING: 
     1437        if (strm->param.dir & PJMEDIA_DIR_CAPTURE) { 
     1438            PJ_ASSERT_RETURN(strm->engine, PJ_EINVAL); 
     1439             
     1440            TInt max_gain = strm->engine->GetMaxGain(); 
     1441            if (max_gain > 0) { 
     1442                TInt gain, err; 
     1443                 
     1444                gain = *(unsigned*)pval * max_gain / 100; 
     1445                err = strm->engine->SetGain(gain); 
     1446                status = (err==KErrNone)? PJ_SUCCESS:PJ_RETURN_OS_ERROR(err); 
     1447            } else { 
     1448                status = PJMEDIA_EAUD_NOTREADY; 
     1449            } 
     1450        } 
    14011451        break; 
    14021452    case PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING: 
     1453        if (strm->param.dir & PJMEDIA_DIR_CAPTURE) { 
     1454            PJ_ASSERT_RETURN(strm->engine, PJ_EINVAL); 
     1455             
     1456            TInt max_vol = strm->engine->GetMaxVolume(); 
     1457            if (max_vol > 0) { 
     1458                TInt vol, err; 
     1459                 
     1460                vol = *(unsigned*)pval * max_vol / 100; 
     1461                err = strm->engine->SetVolume(vol); 
     1462                status = (err==KErrNone)? PJ_SUCCESS:PJ_RETURN_OS_ERROR(err); 
     1463            } else { 
     1464                status = PJMEDIA_EAUD_NOTREADY; 
     1465            } 
     1466        } 
    14031467        break; 
    14041468    default: 
Note: See TracChangeset for help on using the changeset viewer.