Changeset 5645
- Timestamp:
- Sep 6, 2017 3:44:35 AM (7 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsua2/call.hpp
r5417 r5645 602 602 603 603 /** 604 * Optional codec param. 605 */ 606 CodecParam codecParam; 604 * Optional audio codec param. 605 */ 606 CodecParam audCodecParam; 607 608 /** 609 * Optional video codec param. 610 */ 611 VidCodecParam vidCodecParam; 607 612 608 613 public: -
pjproject/trunk/pjsip/include/pjsua2/media.hpp
r5581 r5645 1955 1955 1956 1956 /** 1957 * Codec parameters, corresponds to pjmedia_codec_param.1958 */1959 typedef void *CodecParam;1960 1961 /**1962 1957 * Structure of codec specific parameters which contains name=value pairs. 1963 1958 * The codec specific parameters are to be used with SDP according to … … 1974 1969 1975 1970 /** 1976 * Detailed codec attributes used in configuring a codec and in querying 1977 * the capability of codec factories. 1971 * Audio codec parameters info. 1972 */ 1973 struct CodecParamInfo 1974 { 1975 unsigned clockRate; /**< Sampling rate in Hz */ 1976 unsigned channelCnt; /**< Channel count. */ 1977 unsigned avgBps; /**< Average bandwidth in bits/sec */ 1978 unsigned maxBps; /**< Maximum bandwidth in bits/sec */ 1979 unsigned maxRxFrameSize; /**< Maximum frame size */ 1980 unsigned frameLen; /**< Decoder frame ptime in msec. */ 1981 unsigned pcmBitsPerSample; /**< Bits/sample in the PCM side */ 1982 unsigned pt; /**< Payload type. */ 1983 pjmedia_format_id fmtId; /**< Source format, it's format of 1984 encoder input and decoder 1985 output. */ 1986 }; 1987 1988 /** 1989 * Audio codec parameters setting. 1990 */ 1991 struct CodecParamSetting 1992 { 1993 unsigned frmPerPkt; /**< Number of frames per packet. */ 1994 bool vad; /**< Voice Activity Detector. */ 1995 bool cng; /**< Comfort Noise Generator. */ 1996 bool penh; /**< Perceptual Enhancement */ 1997 bool plc; /**< Packet loss concealment */ 1998 bool reserved; /**< Reserved, must be zero. */ 1999 CodecFmtpVector encFmtp; /**< Encoder's fmtp params. */ 2000 CodecFmtpVector decFmtp; /**< Decoder's fmtp params. */ 2001 }; 2002 2003 /** 2004 * Detailed codec attributes used in configuring an audio codec and in querying 2005 * the capability of audio codec factories. 2006 * 2007 * Please note that codec parameter also contains SDP specific setting, 2008 * #setting::decFmtp and #setting::encFmtp, which may need to be set 2009 * appropriately based on the effective setting. 2010 * See each codec documentation for more detail. 2011 */ 2012 struct CodecParam 2013 { 2014 struct CodecParamInfo info; 2015 struct CodecParamSetting setting; 2016 2017 void fromPj(const pjmedia_codec_param ¶m); 2018 2019 pjmedia_codec_param toPj() const; 2020 }; 2021 2022 /** 2023 * Detailed codec attributes used in configuring a video codec and in querying 2024 * the capability of video codec factories. 1978 2025 * 1979 2026 * Please note that codec parameter also contains SDP specific setting, … … 2003 2050 2004 2051 pjmedia_vid_codec_param toPj() const; 2005 2006 private:2007 void setCodecFmtp(const pjmedia_codec_fmtp &in_fmtp,2008 CodecFmtpVector &out_fmtp);2009 2010 void getCodecFmtp(const CodecFmtpVector &in_fmtp,2011 pjmedia_codec_fmtp &out_fmtp) const;2012 2013 2052 }; 2014 2053 -
pjproject/trunk/pjsip/src/pjsua2/call.cpp
r5240 r5645 297 297 codecName = pj2Str(info.info.aud.fmt.encoding_name); 298 298 codecClockRate = info.info.aud.fmt.clock_rate; 299 codecParam = info.info.aud.param;299 audCodecParam.fromPj(*info.info.aud.param); 300 300 } else if (type == PJMEDIA_TYPE_VIDEO) { 301 301 proto = info.info.vid.proto; … … 308 308 rxPt = info.info.vid.rx_pt; 309 309 codecName = pj2Str(info.info.vid.codec_info.encoding_name); 310 codecClockRate = info.info.vid.codec_info.clock_rate; 311 codecParam = info.info.vid.codec_param;310 codecClockRate = info.info.vid.codec_info.clock_rate; 311 vidCodecParam.fromPj(*info.info.vid.codec_param); 312 312 } 313 313 } -
pjproject/trunk/pjsip/src/pjsua2/endpoint.cpp
r5636 r5645 1883 1883 CodecParam Endpoint::codecGetParam(const string &codec_id) const throw(Error) 1884 1884 { 1885 pjmedia_codec_param *pj_param = NULL; 1885 CodecParam param; 1886 pjmedia_codec_param pj_param; 1886 1887 pj_str_t codec_str = str2Pj(codec_id); 1887 1888 1888 PJSUA2_CHECK_EXPR( pjsua_codec_get_param(&codec_str, pj_param) ); 1889 1890 return pj_param; 1889 PJSUA2_CHECK_EXPR( pjsua_codec_get_param(&codec_str, &pj_param) ); 1890 1891 param.fromPj(pj_param); 1892 return param; 1891 1893 } 1892 1894 … … 1895 1897 { 1896 1898 pj_str_t codec_str = str2Pj(codec_id); 1897 pjmedia_codec_param *pj_param = (pjmedia_codec_param*)param;1898 1899 PJSUA2_CHECK_EXPR( pjsua_codec_set_param(&codec_str, pj_param) );1899 pjmedia_codec_param pj_param = param.toPj(); 1900 1901 PJSUA2_CHECK_EXPR( pjsua_codec_set_param(&codec_str, &pj_param) ); 1900 1902 } 1901 1903 -
pjproject/trunk/pjsip/src/pjsua2/media.cpp
r5635 r5645 1516 1516 1517 1517 /////////////////////////////////////////////////////////////////////////////// 1518 1519 /** 1520 * Utility class for converting CodecFmtpVector to and from pjmedia_codec_fmtp. 1521 */ 1522 class CodecFmtpUtil 1523 { 1524 public: 1525 static void fromPj(const pjmedia_codec_fmtp &in_fmtp, 1526 CodecFmtpVector &out_fmtp) 1527 { 1528 unsigned i = 0; 1529 for (; i<in_fmtp.cnt; ++i) { 1530 CodecFmtp fmtp; 1531 fmtp.name = pj2Str(in_fmtp.param[i].name); 1532 fmtp.val = pj2Str(in_fmtp.param[i].val); 1533 1534 out_fmtp.push_back(fmtp); 1535 } 1536 } 1537 1538 static void toPj(const CodecFmtpVector &in_fmtp, 1539 pjmedia_codec_fmtp &out_fmtp) 1540 { 1541 CodecFmtpVector::const_iterator i; 1542 out_fmtp.cnt = 0; 1543 for (i = in_fmtp.begin(); i != in_fmtp.end(); ++i) { 1544 if (out_fmtp.cnt >= PJMEDIA_CODEC_MAX_FMTP_CNT) { 1545 break; 1546 } 1547 out_fmtp.param[out_fmtp.cnt].name = str2Pj((*i).name); 1548 out_fmtp.param[out_fmtp.cnt].val = str2Pj((*i).val); 1549 ++out_fmtp.cnt; 1550 } 1551 } 1552 }; 1553 1554 /////////////////////////////////////////////////////////////////////////////// 1518 1555 void CodecInfo::fromPj(const pjsua_codec_info &codec_info) 1519 1556 { … … 1523 1560 } 1524 1561 1562 /////////////////////////////////////////////////////////////////////////////// 1563 void CodecParam::fromPj(const pjmedia_codec_param ¶m) 1564 { 1565 /* info part. */ 1566 info.clockRate = param.info.clock_rate; 1567 info.channelCnt = param.info.channel_cnt; 1568 info.avgBps = param.info.avg_bps; 1569 info.maxBps = param.info.max_bps; 1570 info.maxRxFrameSize = param.info.max_rx_frame_size; 1571 info.frameLen = param.info.frm_ptime; 1572 info.pcmBitsPerSample = param.info.pcm_bits_per_sample; 1573 info.pt = param.info.pt; 1574 info.fmtId = param.info.fmt_id; 1575 1576 /* setting part. */ 1577 setting.frmPerPkt = param.setting.frm_per_pkt; 1578 setting.vad = param.setting.vad; 1579 setting.cng = param.setting.cng; 1580 setting.penh = param.setting.penh; 1581 setting.plc = param.setting.plc; 1582 setting.reserved = param.setting.reserved; 1583 CodecFmtpUtil::fromPj(param.setting.enc_fmtp, setting.encFmtp); 1584 CodecFmtpUtil::fromPj(param.setting.dec_fmtp, setting.decFmtp); 1585 } 1586 1587 pjmedia_codec_param CodecParam::toPj() const 1588 { 1589 pjmedia_codec_param param; 1590 1591 /* info part. */ 1592 param.info.clock_rate = info.clockRate; 1593 param.info.channel_cnt = info.channelCnt; 1594 param.info.avg_bps = info.avgBps; 1595 param.info.max_bps= info.maxBps; 1596 param.info.max_rx_frame_size = info.maxRxFrameSize; 1597 param.info.frm_ptime = info.frameLen; 1598 param.info.pcm_bits_per_sample = info.pcmBitsPerSample; 1599 param.info.pt = info.pt; 1600 param.info.fmt_id = info.fmtId; 1601 1602 /* setting part. */ 1603 param.setting.frm_per_pkt = setting.frmPerPkt; 1604 param.setting.vad = setting.vad; 1605 param.setting.cng = setting.cng; 1606 param.setting.penh = setting.penh; 1607 param.setting.plc = setting.plc; 1608 param.setting.reserved = setting.reserved; 1609 CodecFmtpUtil::toPj(setting.encFmtp, param.setting.enc_fmtp); 1610 CodecFmtpUtil::toPj(setting.decFmtp, param.setting.dec_fmtp); 1611 return param; 1612 } 1613 1614 /////////////////////////////////////////////////////////////////////////////// 1525 1615 void VidCodecParam::fromPj(const pjmedia_vid_codec_param ¶m) 1526 1616 { … … 1531 1621 encFmt.fromPj(param.enc_fmt); 1532 1622 decFmt.fromPj(param.dec_fmt); 1533 setCodecFmtp(param.enc_fmtp, encFmtp);1534 setCodecFmtp(param.dec_fmtp, decFmtp);1623 CodecFmtpUtil::fromPj(param.enc_fmtp, encFmtp); 1624 CodecFmtpUtil::fromPj(param.dec_fmtp, decFmtp); 1535 1625 } 1536 1626 … … 1545 1635 param.enc_fmt = encFmt.toPj(); 1546 1636 param.dec_fmt = decFmt.toPj(); 1547 getCodecFmtp(encFmtp, param.enc_fmtp);1548 getCodecFmtp(decFmtp, param.dec_fmtp);1637 CodecFmtpUtil::toPj(encFmtp, param.enc_fmtp); 1638 CodecFmtpUtil::toPj(decFmtp, param.dec_fmtp); 1549 1639 return param; 1550 1640 } 1551 1641 1552 void VidCodecParam::setCodecFmtp(const pjmedia_codec_fmtp &in_fmtp,1553 CodecFmtpVector &out_fmtp)1554 {1555 unsigned i = 0;1556 for ( ; i<in_fmtp.cnt; ++i) {1557 CodecFmtp fmtp;1558 fmtp.name = pj2Str(in_fmtp.param[i].name);1559 fmtp.val = pj2Str(in_fmtp.param[i].val);1560 1561 out_fmtp.push_back(fmtp);1562 }1563 }1564 1565 void VidCodecParam::getCodecFmtp(const CodecFmtpVector &in_fmtp,1566 pjmedia_codec_fmtp &out_fmtp) const1567 {1568 CodecFmtpVector::const_iterator i;1569 out_fmtp.cnt = 0;1570 for (i=in_fmtp.begin(); i!=in_fmtp.end();++i) {1571 if (out_fmtp.cnt >= PJMEDIA_CODEC_MAX_FMTP_CNT) {1572 break;1573 }1574 out_fmtp.param[out_fmtp.cnt].name = str2Pj((*i).name);1575 out_fmtp.param[out_fmtp.cnt].val = str2Pj((*i).val);1576 ++out_fmtp.cnt;1577 }1578 }
Note: See TracChangeset
for help on using the changeset viewer.