Changeset 4329 for pjproject/branches/1.x/pjsip/src/pjsua-lib/pjsua_media.c
- Timestamp:
- Jan 23, 2013 2:57:30 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/1.x/pjsip/src/pjsua-lib/pjsua_media.c
r4261 r4329 1567 1567 } 1568 1568 1569 /* Match codec fmtp. This will compare the values and the order. */ 1570 static pj_bool_t match_codec_fmtp(const pjmedia_codec_fmtp *fmtp1, 1571 const pjmedia_codec_fmtp *fmtp2) 1572 { 1573 unsigned i; 1574 1575 if (fmtp1->cnt != fmtp2->cnt) 1576 return PJ_FALSE; 1577 1578 for (i = 0; i < fmtp1->cnt; ++i) { 1579 if (pj_stricmp(&fmtp1->param[i].name, &fmtp2->param[i].name)) 1580 return PJ_FALSE; 1581 if (pj_stricmp(&fmtp1->param[i].val, &fmtp2->param[i].val)) 1582 return PJ_FALSE; 1583 } 1584 1585 return PJ_TRUE; 1586 } 1587 1588 1589 static pj_bool_t is_media_changed(const pjsua_call *call, 1590 int new_audio_idx, 1591 const pjmedia_session_info *new_sess) 1592 { 1593 pjmedia_session_info old_sess; 1594 const pjmedia_stream_info *old_si = NULL; 1595 const pjmedia_stream_info *new_si; 1596 const pjmedia_codec_info *old_ci = NULL; 1597 const pjmedia_codec_info *new_ci; 1598 const pjmedia_codec_param *old_cp = NULL; 1599 const pjmedia_codec_param *new_cp; 1600 1601 /* Init new stream info (shortcut vars) */ 1602 new_si = &new_sess->stream_info[new_audio_idx]; 1603 new_ci = &new_si->fmt; 1604 new_cp = new_si->param; 1605 1606 /* Get current stream info */ 1607 if (call->session) { 1608 pjmedia_session_get_info(call->session, &old_sess); 1609 /* PJSUA always uses one stream per session */ 1610 pj_assert(old_sess.stream_cnt == 1); 1611 old_si = &old_sess.stream_info[0]; 1612 old_ci = &old_si->fmt; 1613 old_cp = old_si->param; 1614 } 1615 1616 /* Check for audio index change (is this really necessary?) */ 1617 if (new_audio_idx != call->audio_idx) 1618 return PJ_TRUE; 1619 1620 /* Check if stream stays inactive */ 1621 if (!old_si && new_si->dir == PJMEDIA_DIR_NONE) 1622 return PJ_FALSE; 1623 1624 /* Compare media direction */ 1625 if (!old_si || (old_si && old_si->dir != new_si->dir)) 1626 return PJ_TRUE; 1627 1628 /* Compare remote RTP address */ 1629 if (pj_sockaddr_cmp(&old_si->rem_addr, &new_si->rem_addr)) 1630 return PJ_TRUE; 1631 1632 /* Compare codec info */ 1633 if (pj_stricmp(&old_ci->encoding_name, &new_ci->encoding_name) || 1634 old_ci->clock_rate != new_ci->clock_rate || 1635 old_ci->channel_cnt != new_ci->channel_cnt || 1636 //old_si->rx_pt != new_si->rx_pt || 1637 old_si->tx_pt != new_si->tx_pt || 1638 old_si->rx_event_pt != new_si->tx_event_pt || 1639 old_si->tx_event_pt != new_si->tx_event_pt) 1640 { 1641 return PJ_TRUE; 1642 } 1643 1644 /* Compare codec param */ 1645 if (old_cp->setting.frm_per_pkt != new_cp->setting.frm_per_pkt || 1646 old_cp->setting.vad != new_cp->setting.vad || 1647 old_cp->setting.cng != new_cp->setting.cng || 1648 old_cp->setting.plc != new_cp->setting.plc || 1649 old_cp->setting.penh != new_cp->setting.penh || 1650 !match_codec_fmtp(&old_cp->setting.dec_fmtp, 1651 &new_cp->setting.dec_fmtp) || 1652 !match_codec_fmtp(&old_cp->setting.enc_fmtp, 1653 &new_cp->setting.enc_fmtp)) 1654 { 1655 return PJ_TRUE; 1656 } 1657 1658 return PJ_FALSE; 1659 } 1660 1661 1569 1662 pj_status_t pjsua_media_channel_deinit(pjsua_call_id call_id) 1570 1663 { … … 1614 1707 1615 1708 1709 /* Internal function: update media channel after SDP negotiation. 1710 * Warning: do not use temporary/flip-flop pool, e.g: inv->pool_prov, 1711 * for creating stream, etc, as after SDP negotiation and when 1712 * the SDP media is not changed, the stream should remain running 1713 * while the temporary/flip-flop pool may be released. 1714 */ 1616 1715 pj_status_t pjsua_media_channel_update(pjsua_call_id call_id, 1617 1716 const pjmedia_sdp_session *local_sdp, … … 1625 1724 pjmedia_port *media_port; 1626 1725 pj_status_t status; 1726 int audio_idx; 1627 1727 1628 1728 if (!pjsua_var.med_endpt) { … … 1631 1731 } 1632 1732 1633 /* Destroy existing media session, if any. */ 1634 prev_media_st = call->media_st; 1635 stop_media_session(call->index); 1636 1637 /* Create media session info based on SDP parameters. 1638 */ 1639 status = pjmedia_session_info_from_sdp( call->inv->pool_prov, 1640 pjsua_var.med_endpt, 1733 /* Create media session info based on SDP parameters. */ 1734 status = pjmedia_session_info_from_sdp( call->inv->pool_prov, 1735 pjsua_var.med_endpt, 1641 1736 PJMEDIA_MAX_SDP_MEDIA, &sess_info, 1642 1737 local_sdp, remote_sdp); … … 1644 1739 return status; 1645 1740 1741 /* Get audio index from the negotiated SDP */ 1742 audio_idx = find_audio_index(local_sdp, PJ_TRUE); 1743 1744 /* Check if media has just been changed. */ 1745 if (!pjsua_var.media_cfg.no_smart_media_update && 1746 !is_media_changed(call, audio_idx, &sess_info)) 1747 { 1748 PJ_LOG(4,(THIS_FILE, "Media session for call %d is unchanged", 1749 call_id)); 1750 return PJ_SUCCESS; 1751 } 1752 1753 /* Destroy existing media session, if any. */ 1754 prev_media_st = call->media_st; 1755 stop_media_session(call->index); 1756 1646 1757 for (i = 0; i < sess_info.stream_cnt; ++i) { 1647 1758 sess_info.stream_info[i].rtcp_sdes_bye_disabled = PJ_TRUE; … … 1649 1760 1650 1761 /* Update audio index from the negotiated SDP */ 1651 call->audio_idx = find_audio_index(local_sdp, PJ_TRUE);1762 call->audio_idx = audio_idx; 1652 1763 1653 1764 /* Find which session is audio */ … … 1808 1919 } 1809 1920 status = pjmedia_conf_add_port( pjsua_var.mconf, 1810 call->inv->pool _prov,1921 call->inv->pool, 1811 1922 media_port, 1812 1923 &port_name,
Note: See TracChangeset
for help on using the changeset viewer.