Changeset 4329
- Timestamp:
- Jan 23, 2013 2:57:30 AM (12 years ago)
- Location:
- pjproject/branches/1.x
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/1.x/pjmedia/include/pjmedia/codec.h
r3553 r4329 310 310 311 311 312 /** 313 * Duplicate codec parameter. 314 * 315 * @param pool The pool. 316 * @param src The codec parameter to be duplicated. 317 * 318 * @return Duplicated codec parameter. 319 */ 320 PJ_DECL(pjmedia_codec_param*) pjmedia_codec_param_clone( 321 pj_pool_t *pool, 322 const pjmedia_codec_param *src); 323 312 324 313 325 /* -
pjproject/branches/1.x/pjmedia/src/pjmedia/codec.c
r3553 r4329 42 42 43 43 /* 44 * Duplicate codec parameter. 45 */ 46 PJ_DEF(pjmedia_codec_param*) pjmedia_codec_param_clone( 47 pj_pool_t *pool, 48 const pjmedia_codec_param *src) 49 { 50 pjmedia_codec_param *p; 51 unsigned i; 52 53 PJ_ASSERT_RETURN(pool && src, NULL); 54 55 p = PJ_POOL_ZALLOC_T(pool, pjmedia_codec_param); 56 57 /* Update codec param */ 58 pj_memcpy(p, src, sizeof(pjmedia_codec_param)); 59 for (i = 0; i < src->setting.dec_fmtp.cnt; ++i) { 60 pj_strdup(pool, &p->setting.dec_fmtp.param[i].name, 61 &src->setting.dec_fmtp.param[i].name); 62 pj_strdup(pool, &p->setting.dec_fmtp.param[i].val, 63 &src->setting.dec_fmtp.param[i].val); 64 } 65 for (i = 0; i < src->setting.enc_fmtp.cnt; ++i) { 66 pj_strdup(pool, &p->setting.enc_fmtp.param[i].name, 67 &src->setting.enc_fmtp.param[i].name); 68 pj_strdup(pool, &p->setting.enc_fmtp.param[i].val, 69 &src->setting.enc_fmtp.param[i].val); 70 } 71 72 return p; 73 } 74 75 76 /* 44 77 * Initialize codec manager. 45 78 */ -
pjproject/branches/1.x/pjmedia/src/pjmedia/session.c
r3571 r4329 672 672 si->stream_cnt * sizeof(pjmedia_stream_info)); 673 673 674 /* Clone codec param */ 675 for (i=0; i<(int)si->stream_cnt; ++i) { 676 if (session->stream_info[i].param) { 677 session->stream_info[i].param = 678 pjmedia_codec_param_clone(pool, si->stream_info[i].param); 679 } else { 680 pjmedia_codec_param cp; 681 status = pjmedia_codec_mgr_get_default_param( 682 pjmedia_endpt_get_codec_mgr(endpt), 683 &si->stream_info[i].fmt, 684 &cp); 685 if (status != PJ_SUCCESS) 686 return status; 687 688 session->stream_info[i].param = 689 pjmedia_codec_param_clone(pool, &cp); 690 } 691 } 692 674 693 /* 675 694 * Now create and start the stream! -
pjproject/branches/1.x/pjsip/include/pjsua-lib/pjsua.h
r4045 r4329 4434 4434 */ 4435 4435 int snd_auto_close_time; 4436 4437 /** 4438 * Disable smart media update (ticket #1568). The smart media update 4439 * will check for any changes in the media properties after a successful 4440 * SDP negotiation and the media will only be reinitialized when any 4441 * change is found. When it is disabled, media streams will always be 4442 * reinitialized after a successful SDP negotiation. 4443 * 4444 * Default: PJ_FALSE 4445 */ 4446 pj_bool_t no_smart_media_update; 4436 4447 }; 4437 4448 -
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.