Changeset 5645 for pjproject/trunk/pjsip/src/pjsua2/media.cpp
- Timestamp:
- Sep 6, 2017 3:44:35 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.