Ignore:
Timestamp:
Dec 3, 2013 10:45:36 AM (10 years ago)
Author:
riza
Message:

Re #1519: Added codec management operations to Media API in pjsua2.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/endpoint.cpp

    r4668 r4669  
    3232#define MAX_STUN_SERVERS        32 
    3333#define TIMER_SIGNATURE         0x600D878A 
     34#define MAX_CODEC_NUM           64 
    3435 
    3536struct UserTimer 
     
    376377    } 
    377378 
     379    clearCodecInfoList(); 
     380 
    378381    instance_ = NULL; 
    379382} 
     
    13651368    return audioDevMgr; 
    13661369} 
     1370 
     1371/* 
     1372 * Codec operations. 
     1373 */ 
     1374const CodecInfoVector &Endpoint::codecEnum() throw(Error) 
     1375{ 
     1376    pjsua_codec_info pj_codec[MAX_CODEC_NUM]; 
     1377    unsigned count = 0; 
     1378 
     1379    PJSUA2_CHECK_EXPR( pjsua_enum_codecs(pj_codec, &count) ); 
     1380 
     1381    clearCodecInfoList(); 
     1382 
     1383    pj_enter_critical_section(); 
     1384    for (unsigned i=0;(i<count && i<MAX_CODEC_NUM);++i) { 
     1385        CodecInfo *codec_info = new CodecInfo; 
     1386 
     1387        codec_info->fromPj(pj_codec[i]); 
     1388        codecInfoList.push_back(codec_info); 
     1389    } 
     1390    pj_leave_critical_section(); 
     1391    return codecInfoList; 
     1392} 
     1393 
     1394void Endpoint::codecSetPriority(const string &codec_id, 
     1395                                pj_uint8_t priority) throw(Error) 
     1396{ 
     1397    pj_str_t codec_str = str2Pj(codec_id); 
     1398    PJSUA2_CHECK_EXPR( pjsua_codec_set_priority(&codec_str, priority) ); 
     1399} 
     1400 
     1401CodecParam Endpoint::codecGetParam(const string &codec_id) const throw(Error) 
     1402{ 
     1403    pjmedia_codec_param *pj_param = NULL; 
     1404    pj_str_t codec_str = str2Pj(codec_id); 
     1405 
     1406    PJSUA2_CHECK_EXPR( pjsua_codec_get_param(&codec_str, pj_param) ); 
     1407 
     1408    return pj_param; 
     1409} 
     1410 
     1411void Endpoint::codecSetParam(const string &codec_id, 
     1412                             const CodecParam param) throw(Error) 
     1413{ 
     1414    pj_str_t codec_str = str2Pj(codec_id); 
     1415    pjmedia_codec_param *pj_param = (pjmedia_codec_param*)param; 
     1416 
     1417    PJSUA2_CHECK_EXPR( pjsua_codec_set_param(&codec_str, pj_param) ); 
     1418} 
     1419 
     1420void Endpoint::clearCodecInfoList() 
     1421{ 
     1422    pj_enter_critical_section(); 
     1423    for (unsigned i=0;i<codecInfoList.size();++i) { 
     1424        delete codecInfoList[i]; 
     1425    } 
     1426    codecInfoList.clear(); 
     1427    pj_leave_critical_section(); 
     1428} 
Note: See TracChangeset for help on using the changeset viewer.