OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1549 return true; | 1549 return true; |
1550 } | 1550 } |
1551 | 1551 |
1552 bool MediaSessionDescriptionFactory::AddAudioContentForOffer( | 1552 bool MediaSessionDescriptionFactory::AddAudioContentForOffer( |
1553 const MediaSessionOptions& options, | 1553 const MediaSessionOptions& options, |
1554 const SessionDescription* current_description, | 1554 const SessionDescription* current_description, |
1555 const RtpHeaderExtensions& audio_rtp_extensions, | 1555 const RtpHeaderExtensions& audio_rtp_extensions, |
1556 const AudioCodecs& audio_codecs, | 1556 const AudioCodecs& audio_codecs, |
1557 StreamParamsVec* current_streams, | 1557 StreamParamsVec* current_streams, |
1558 SessionDescription* desc) const { | 1558 SessionDescription* desc) const { |
| 1559 const ContentInfo* current_audio_content = |
| 1560 GetFirstAudioContent(current_description); |
| 1561 std::string content_name = |
| 1562 current_audio_content ? current_audio_content->name : CN_AUDIO; |
| 1563 |
1559 cricket::SecurePolicy sdes_policy = | 1564 cricket::SecurePolicy sdes_policy = |
1560 IsDtlsActive(CN_AUDIO, current_description) ? | 1565 IsDtlsActive(content_name, current_description) ? cricket::SEC_DISABLED |
1561 cricket::SEC_DISABLED : secure(); | 1566 : secure(); |
1562 | 1567 |
1563 scoped_ptr<AudioContentDescription> audio(new AudioContentDescription()); | 1568 scoped_ptr<AudioContentDescription> audio(new AudioContentDescription()); |
1564 std::vector<std::string> crypto_suites; | 1569 std::vector<std::string> crypto_suites; |
1565 GetSupportedAudioCryptoSuiteNames(&crypto_suites); | 1570 GetSupportedAudioCryptoSuiteNames(&crypto_suites); |
1566 if (!CreateMediaContentOffer( | 1571 if (!CreateMediaContentOffer( |
1567 options, | 1572 options, |
1568 audio_codecs, | 1573 audio_codecs, |
1569 sdes_policy, | 1574 sdes_policy, |
1570 GetCryptos(GetFirstAudioContentDescription(current_description)), | 1575 GetCryptos(GetFirstAudioContentDescription(current_description)), |
1571 crypto_suites, | 1576 crypto_suites, |
(...skipping 15 matching lines...) Expand all Loading... |
1587 audio->set_direction(MD_SENDONLY); | 1592 audio->set_direction(MD_SENDONLY); |
1588 } | 1593 } |
1589 } else { | 1594 } else { |
1590 if (options.recv_audio) { | 1595 if (options.recv_audio) { |
1591 audio->set_direction(MD_RECVONLY); | 1596 audio->set_direction(MD_RECVONLY); |
1592 } else { | 1597 } else { |
1593 audio->set_direction(MD_INACTIVE); | 1598 audio->set_direction(MD_INACTIVE); |
1594 } | 1599 } |
1595 } | 1600 } |
1596 | 1601 |
1597 desc->AddContent(CN_AUDIO, NS_JINGLE_RTP, audio.release()); | 1602 desc->AddContent(content_name, NS_JINGLE_RTP, audio.release()); |
1598 if (!AddTransportOffer(CN_AUDIO, options.transport_options, | 1603 if (!AddTransportOffer(content_name, options.transport_options, |
1599 current_description, desc)) { | 1604 current_description, desc)) { |
1600 return false; | 1605 return false; |
1601 } | 1606 } |
1602 | 1607 |
1603 return true; | 1608 return true; |
1604 } | 1609 } |
1605 | 1610 |
1606 bool MediaSessionDescriptionFactory::AddVideoContentForOffer( | 1611 bool MediaSessionDescriptionFactory::AddVideoContentForOffer( |
1607 const MediaSessionOptions& options, | 1612 const MediaSessionOptions& options, |
1608 const SessionDescription* current_description, | 1613 const SessionDescription* current_description, |
1609 const RtpHeaderExtensions& video_rtp_extensions, | 1614 const RtpHeaderExtensions& video_rtp_extensions, |
1610 const VideoCodecs& video_codecs, | 1615 const VideoCodecs& video_codecs, |
1611 StreamParamsVec* current_streams, | 1616 StreamParamsVec* current_streams, |
1612 SessionDescription* desc) const { | 1617 SessionDescription* desc) const { |
| 1618 const ContentInfo* current_video_content = |
| 1619 GetFirstVideoContent(current_description); |
| 1620 std::string content_name = |
| 1621 current_video_content ? current_video_content->name : CN_VIDEO; |
| 1622 |
1613 cricket::SecurePolicy sdes_policy = | 1623 cricket::SecurePolicy sdes_policy = |
1614 IsDtlsActive(CN_VIDEO, current_description) ? | 1624 IsDtlsActive(content_name, current_description) ? cricket::SEC_DISABLED |
1615 cricket::SEC_DISABLED : secure(); | 1625 : secure(); |
1616 | 1626 |
1617 scoped_ptr<VideoContentDescription> video(new VideoContentDescription()); | 1627 scoped_ptr<VideoContentDescription> video(new VideoContentDescription()); |
1618 std::vector<std::string> crypto_suites; | 1628 std::vector<std::string> crypto_suites; |
1619 GetSupportedVideoCryptoSuiteNames(&crypto_suites); | 1629 GetSupportedVideoCryptoSuiteNames(&crypto_suites); |
1620 if (!CreateMediaContentOffer( | 1630 if (!CreateMediaContentOffer( |
1621 options, | 1631 options, |
1622 video_codecs, | 1632 video_codecs, |
1623 sdes_policy, | 1633 sdes_policy, |
1624 GetCryptos(GetFirstVideoContentDescription(current_description)), | 1634 GetCryptos(GetFirstVideoContentDescription(current_description)), |
1625 crypto_suites, | 1635 crypto_suites, |
(...skipping 16 matching lines...) Expand all Loading... |
1642 video->set_direction(MD_SENDONLY); | 1652 video->set_direction(MD_SENDONLY); |
1643 } | 1653 } |
1644 } else { | 1654 } else { |
1645 if (options.recv_video) { | 1655 if (options.recv_video) { |
1646 video->set_direction(MD_RECVONLY); | 1656 video->set_direction(MD_RECVONLY); |
1647 } else { | 1657 } else { |
1648 video->set_direction(MD_INACTIVE); | 1658 video->set_direction(MD_INACTIVE); |
1649 } | 1659 } |
1650 } | 1660 } |
1651 | 1661 |
1652 desc->AddContent(CN_VIDEO, NS_JINGLE_RTP, video.release()); | 1662 desc->AddContent(content_name, NS_JINGLE_RTP, video.release()); |
1653 if (!AddTransportOffer(CN_VIDEO, options.transport_options, | 1663 if (!AddTransportOffer(content_name, options.transport_options, |
1654 current_description, desc)) { | 1664 current_description, desc)) { |
1655 return false; | 1665 return false; |
1656 } | 1666 } |
1657 | 1667 |
1658 return true; | 1668 return true; |
1659 } | 1669 } |
1660 | 1670 |
1661 bool MediaSessionDescriptionFactory::AddDataContentForOffer( | 1671 bool MediaSessionDescriptionFactory::AddDataContentForOffer( |
1662 const MediaSessionOptions& options, | 1672 const MediaSessionOptions& options, |
1663 const SessionDescription* current_description, | 1673 const SessionDescription* current_description, |
1664 DataCodecs* data_codecs, | 1674 DataCodecs* data_codecs, |
1665 StreamParamsVec* current_streams, | 1675 StreamParamsVec* current_streams, |
1666 SessionDescription* desc) const { | 1676 SessionDescription* desc) const { |
1667 bool secure_transport = (transport_desc_factory_->secure() != SEC_DISABLED); | 1677 bool secure_transport = (transport_desc_factory_->secure() != SEC_DISABLED); |
1668 | 1678 |
1669 scoped_ptr<DataContentDescription> data(new DataContentDescription()); | 1679 scoped_ptr<DataContentDescription> data(new DataContentDescription()); |
1670 bool is_sctp = (options.data_channel_type == DCT_SCTP); | 1680 bool is_sctp = (options.data_channel_type == DCT_SCTP); |
1671 | 1681 |
1672 FilterDataCodecs(data_codecs, is_sctp); | 1682 FilterDataCodecs(data_codecs, is_sctp); |
1673 | 1683 |
| 1684 const ContentInfo* current_data_content = |
| 1685 GetFirstDataContent(current_description); |
| 1686 std::string content_name = |
| 1687 current_data_content ? current_data_content->name : CN_DATA; |
| 1688 |
1674 cricket::SecurePolicy sdes_policy = | 1689 cricket::SecurePolicy sdes_policy = |
1675 IsDtlsActive(CN_DATA, current_description) ? | 1690 IsDtlsActive(content_name, current_description) ? cricket::SEC_DISABLED |
1676 cricket::SEC_DISABLED : secure(); | 1691 : secure(); |
1677 std::vector<std::string> crypto_suites; | 1692 std::vector<std::string> crypto_suites; |
1678 if (is_sctp) { | 1693 if (is_sctp) { |
1679 // SDES doesn't make sense for SCTP, so we disable it, and we only | 1694 // SDES doesn't make sense for SCTP, so we disable it, and we only |
1680 // get SDES crypto suites for RTP-based data channels. | 1695 // get SDES crypto suites for RTP-based data channels. |
1681 sdes_policy = cricket::SEC_DISABLED; | 1696 sdes_policy = cricket::SEC_DISABLED; |
1682 // Unlike SetMediaProtocol below, we need to set the protocol | 1697 // Unlike SetMediaProtocol below, we need to set the protocol |
1683 // before we call CreateMediaContentOffer. Otherwise, | 1698 // before we call CreateMediaContentOffer. Otherwise, |
1684 // CreateMediaContentOffer won't know this is SCTP and will | 1699 // CreateMediaContentOffer won't know this is SCTP and will |
1685 // generate SSRCs rather than SIDs. | 1700 // generate SSRCs rather than SIDs. |
1686 data->set_protocol( | 1701 data->set_protocol( |
1687 secure_transport ? kMediaProtocolDtlsSctp : kMediaProtocolSctp); | 1702 secure_transport ? kMediaProtocolDtlsSctp : kMediaProtocolSctp); |
1688 } else { | 1703 } else { |
1689 GetSupportedDataCryptoSuiteNames(&crypto_suites); | 1704 GetSupportedDataCryptoSuiteNames(&crypto_suites); |
1690 } | 1705 } |
1691 | 1706 |
1692 if (!CreateMediaContentOffer( | 1707 if (!CreateMediaContentOffer( |
1693 options, | 1708 options, |
1694 *data_codecs, | 1709 *data_codecs, |
1695 sdes_policy, | 1710 sdes_policy, |
1696 GetCryptos(GetFirstDataContentDescription(current_description)), | 1711 GetCryptos(GetFirstDataContentDescription(current_description)), |
1697 crypto_suites, | 1712 crypto_suites, |
1698 RtpHeaderExtensions(), | 1713 RtpHeaderExtensions(), |
1699 add_legacy_, | 1714 add_legacy_, |
1700 current_streams, | 1715 current_streams, |
1701 data.get())) { | 1716 data.get())) { |
1702 return false; | 1717 return false; |
1703 } | 1718 } |
1704 | 1719 |
1705 if (is_sctp) { | 1720 if (is_sctp) { |
1706 desc->AddContent(CN_DATA, NS_JINGLE_DRAFT_SCTP, data.release()); | 1721 desc->AddContent(content_name, NS_JINGLE_DRAFT_SCTP, data.release()); |
1707 } else { | 1722 } else { |
1708 data->set_bandwidth(options.data_bandwidth); | 1723 data->set_bandwidth(options.data_bandwidth); |
1709 SetMediaProtocol(secure_transport, data.get()); | 1724 SetMediaProtocol(secure_transport, data.get()); |
1710 desc->AddContent(CN_DATA, NS_JINGLE_RTP, data.release()); | 1725 desc->AddContent(content_name, NS_JINGLE_RTP, data.release()); |
1711 } | 1726 } |
1712 if (!AddTransportOffer(CN_DATA, options.transport_options, | 1727 if (!AddTransportOffer(content_name, options.transport_options, |
1713 current_description, desc)) { | 1728 current_description, desc)) { |
1714 return false; | 1729 return false; |
1715 } | 1730 } |
1716 return true; | 1731 return true; |
1717 } | 1732 } |
1718 | 1733 |
1719 bool MediaSessionDescriptionFactory::AddAudioContentForAnswer( | 1734 bool MediaSessionDescriptionFactory::AddAudioContentForAnswer( |
1720 const SessionDescription* offer, | 1735 const SessionDescription* offer, |
1721 const MediaSessionOptions& options, | 1736 const MediaSessionOptions& options, |
1722 const SessionDescription* current_description, | 1737 const SessionDescription* current_description, |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1972 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); | 1987 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_VIDEO)); |
1973 } | 1988 } |
1974 | 1989 |
1975 const DataContentDescription* GetFirstDataContentDescription( | 1990 const DataContentDescription* GetFirstDataContentDescription( |
1976 const SessionDescription* sdesc) { | 1991 const SessionDescription* sdesc) { |
1977 return static_cast<const DataContentDescription*>( | 1992 return static_cast<const DataContentDescription*>( |
1978 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); | 1993 GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA)); |
1979 } | 1994 } |
1980 | 1995 |
1981 } // namespace cricket | 1996 } // namespace cricket |
OLD | NEW |