| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 1684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1695 } | 1695 } |
| 1696 | 1696 |
| 1697 const cricket::ContentInfo* data_info = | 1697 const cricket::ContentInfo* data_info = |
| 1698 cricket::GetFirstDataContent(desc); | 1698 cricket::GetFirstDataContent(desc); |
| 1699 if ((!data_info || data_info->rejected) && data_channel_) { | 1699 if ((!data_info || data_info->rejected) && data_channel_) { |
| 1700 SignalDataChannelDestroyed(); | 1700 SignalDataChannelDestroyed(); |
| 1701 channel_manager_->DestroyDataChannel(data_channel_.release()); | 1701 channel_manager_->DestroyDataChannel(data_channel_.release()); |
| 1702 } | 1702 } |
| 1703 } | 1703 } |
| 1704 | 1704 |
| 1705 // TODO(mallinath) - Add a correct error code if the channels are not created | 1705 // Returns the name of the transport channel when BUNDLE is enabled, or nullptr |
| 1706 // due to BUNDLE is enabled but rtcp-mux is disabled. | 1706 // if the channel is not part of any bundle. |
| 1707 const std::string* WebRtcSession::GetBundleTransportName( |
| 1708 const cricket::ContentInfo* content, |
| 1709 const cricket::ContentGroup* bundle) { |
| 1710 if (!bundle) { |
| 1711 return nullptr; |
| 1712 } |
| 1713 const std::string* first_content_name = bundle->FirstContentName(); |
| 1714 if (!first_content_name) { |
| 1715 LOG(LS_WARNING) << "Tried to BUNDLE with no contents."; |
| 1716 return nullptr; |
| 1717 } |
| 1718 if (!bundle->HasContentName(content->name)) { |
| 1719 LOG(LS_WARNING) << content->name << " is not part of any bundle group"; |
| 1720 return nullptr; |
| 1721 } |
| 1722 LOG(LS_INFO) << "Bundling " << content->name << " on " << *first_content_name; |
| 1723 return first_content_name; |
| 1724 } |
| 1725 |
| 1707 bool WebRtcSession::CreateChannels(const SessionDescription* desc) { | 1726 bool WebRtcSession::CreateChannels(const SessionDescription* desc) { |
| 1727 const cricket::ContentGroup* bundle_group = nullptr; |
| 1728 if (bundle_policy_ == PeerConnectionInterface::kBundlePolicyMaxBundle) { |
| 1729 bundle_group = desc->GetGroupByName(cricket::GROUP_TYPE_BUNDLE); |
| 1730 if (!bundle_group) { |
| 1731 LOG(LS_WARNING) << "max-bundle specified without BUNDLE specified"; |
| 1732 return false; |
| 1733 } |
| 1734 } |
| 1708 // Creating the media channels and transport proxies. | 1735 // Creating the media channels and transport proxies. |
| 1709 const cricket::ContentInfo* voice = cricket::GetFirstAudioContent(desc); | 1736 const cricket::ContentInfo* voice = cricket::GetFirstAudioContent(desc); |
| 1710 if (voice && !voice->rejected && !voice_channel_) { | 1737 if (voice && !voice->rejected && !voice_channel_) { |
| 1711 if (!CreateVoiceChannel(voice)) { | 1738 if (!CreateVoiceChannel(voice, |
| 1739 GetBundleTransportName(voice, bundle_group))) { |
| 1712 LOG(LS_ERROR) << "Failed to create voice channel."; | 1740 LOG(LS_ERROR) << "Failed to create voice channel."; |
| 1713 return false; | 1741 return false; |
| 1714 } | 1742 } |
| 1715 } | 1743 } |
| 1716 | 1744 |
| 1717 const cricket::ContentInfo* video = cricket::GetFirstVideoContent(desc); | 1745 const cricket::ContentInfo* video = cricket::GetFirstVideoContent(desc); |
| 1718 if (video && !video->rejected && !video_channel_) { | 1746 if (video && !video->rejected && !video_channel_) { |
| 1719 if (!CreateVideoChannel(video)) { | 1747 if (!CreateVideoChannel(video, |
| 1748 GetBundleTransportName(video, bundle_group))) { |
| 1720 LOG(LS_ERROR) << "Failed to create video channel."; | 1749 LOG(LS_ERROR) << "Failed to create video channel."; |
| 1721 return false; | 1750 return false; |
| 1722 } | 1751 } |
| 1723 } | 1752 } |
| 1724 | 1753 |
| 1725 const cricket::ContentInfo* data = cricket::GetFirstDataContent(desc); | 1754 const cricket::ContentInfo* data = cricket::GetFirstDataContent(desc); |
| 1726 if (data_channel_type_ != cricket::DCT_NONE && | 1755 if (data_channel_type_ != cricket::DCT_NONE && |
| 1727 data && !data->rejected && !data_channel_) { | 1756 data && !data->rejected && !data_channel_) { |
| 1728 if (!CreateDataChannel(data)) { | 1757 if (!CreateDataChannel(data, GetBundleTransportName(data, bundle_group))) { |
| 1729 LOG(LS_ERROR) << "Failed to create data channel."; | 1758 LOG(LS_ERROR) << "Failed to create data channel."; |
| 1730 return false; | 1759 return false; |
| 1731 } | 1760 } |
| 1732 } | 1761 } |
| 1733 | 1762 |
| 1734 if (rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire) { | |
| 1735 if (voice_channel()) { | |
| 1736 voice_channel()->ActivateRtcpMux(); | |
| 1737 } | |
| 1738 if (video_channel()) { | |
| 1739 video_channel()->ActivateRtcpMux(); | |
| 1740 } | |
| 1741 if (data_channel()) { | |
| 1742 data_channel()->ActivateRtcpMux(); | |
| 1743 } | |
| 1744 } | |
| 1745 | |
| 1746 // Enable BUNDLE immediately when kBundlePolicyMaxBundle is in effect. | |
| 1747 if (bundle_policy_ == PeerConnectionInterface::kBundlePolicyMaxBundle) { | |
| 1748 const cricket::ContentGroup* bundle_group = desc->GetGroupByName( | |
| 1749 cricket::GROUP_TYPE_BUNDLE); | |
| 1750 if (!bundle_group) { | |
| 1751 LOG(LS_WARNING) << "max-bundle specified without BUNDLE specified"; | |
| 1752 return false; | |
| 1753 } | |
| 1754 if (!EnableBundle(*bundle_group)) { | |
| 1755 LOG(LS_WARNING) << "max-bundle failed to enable bundling."; | |
| 1756 return false; | |
| 1757 } | |
| 1758 } | |
| 1759 | |
| 1760 return true; | 1763 return true; |
| 1761 } | 1764 } |
| 1762 | 1765 |
| 1763 bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content) { | 1766 bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content, |
| 1767 const std::string* bundle_transport) { |
| 1768 bool require_rtcp_mux = |
| 1769 rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire; |
| 1770 bool create_rtcp_transport_channel = !require_rtcp_mux; |
| 1764 voice_channel_.reset(channel_manager_->CreateVoiceChannel( | 1771 voice_channel_.reset(channel_manager_->CreateVoiceChannel( |
| 1765 media_controller_, transport_controller_.get(), content->name, true, | 1772 media_controller_, transport_controller_.get(), content->name, |
| 1766 audio_options_)); | 1773 bundle_transport, create_rtcp_transport_channel, audio_options_)); |
| 1767 if (!voice_channel_) { | 1774 if (!voice_channel_) { |
| 1768 return false; | 1775 return false; |
| 1769 } | 1776 } |
| 1777 if (require_rtcp_mux) { |
| 1778 voice_channel_->ActivateRtcpMux(); |
| 1779 } |
| 1770 | 1780 |
| 1771 voice_channel_->SignalDtlsSetupFailure.connect( | 1781 voice_channel_->SignalDtlsSetupFailure.connect( |
| 1772 this, &WebRtcSession::OnDtlsSetupFailure); | 1782 this, &WebRtcSession::OnDtlsSetupFailure); |
| 1773 | 1783 |
| 1774 SignalVoiceChannelCreated(); | 1784 SignalVoiceChannelCreated(); |
| 1775 voice_channel_->SignalSentPacket.connect(this, | 1785 voice_channel_->SignalSentPacket.connect(this, |
| 1776 &WebRtcSession::OnSentPacket_w); | 1786 &WebRtcSession::OnSentPacket_w); |
| 1777 return true; | 1787 return true; |
| 1778 } | 1788 } |
| 1779 | 1789 |
| 1780 bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content) { | 1790 bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content, |
| 1791 const std::string* bundle_transport) { |
| 1792 bool require_rtcp_mux = |
| 1793 rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire; |
| 1794 bool create_rtcp_transport_channel = !require_rtcp_mux; |
| 1781 video_channel_.reset(channel_manager_->CreateVideoChannel( | 1795 video_channel_.reset(channel_manager_->CreateVideoChannel( |
| 1782 media_controller_, transport_controller_.get(), content->name, true, | 1796 media_controller_, transport_controller_.get(), content->name, |
| 1783 video_options_)); | 1797 bundle_transport, create_rtcp_transport_channel, video_options_)); |
| 1784 if (!video_channel_) { | 1798 if (!video_channel_) { |
| 1785 return false; | 1799 return false; |
| 1786 } | 1800 } |
| 1787 | 1801 if (require_rtcp_mux) { |
| 1802 video_channel_->ActivateRtcpMux(); |
| 1803 } |
| 1788 video_channel_->SignalDtlsSetupFailure.connect( | 1804 video_channel_->SignalDtlsSetupFailure.connect( |
| 1789 this, &WebRtcSession::OnDtlsSetupFailure); | 1805 this, &WebRtcSession::OnDtlsSetupFailure); |
| 1790 | 1806 |
| 1791 SignalVideoChannelCreated(); | 1807 SignalVideoChannelCreated(); |
| 1792 video_channel_->SignalSentPacket.connect(this, | 1808 video_channel_->SignalSentPacket.connect(this, |
| 1793 &WebRtcSession::OnSentPacket_w); | 1809 &WebRtcSession::OnSentPacket_w); |
| 1794 return true; | 1810 return true; |
| 1795 } | 1811 } |
| 1796 | 1812 |
| 1797 bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content) { | 1813 bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content, |
| 1814 const std::string* bundle_transport) { |
| 1798 bool sctp = (data_channel_type_ == cricket::DCT_SCTP); | 1815 bool sctp = (data_channel_type_ == cricket::DCT_SCTP); |
| 1816 bool require_rtcp_mux = |
| 1817 rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire; |
| 1818 bool create_rtcp_transport_channel = !sctp && !require_rtcp_mux; |
| 1799 data_channel_.reset(channel_manager_->CreateDataChannel( | 1819 data_channel_.reset(channel_manager_->CreateDataChannel( |
| 1800 transport_controller_.get(), content->name, !sctp, data_channel_type_)); | 1820 transport_controller_.get(), content->name, bundle_transport, |
| 1821 create_rtcp_transport_channel, data_channel_type_)); |
| 1801 if (!data_channel_) { | 1822 if (!data_channel_) { |
| 1802 return false; | 1823 return false; |
| 1803 } | 1824 } |
| 1825 if (require_rtcp_mux) { |
| 1826 data_channel_->ActivateRtcpMux(); |
| 1827 } |
| 1804 | 1828 |
| 1805 if (sctp) { | 1829 if (sctp) { |
| 1806 data_channel_->SignalDataReceived.connect( | 1830 data_channel_->SignalDataReceived.connect( |
| 1807 this, &WebRtcSession::OnDataChannelMessageReceived); | 1831 this, &WebRtcSession::OnDataChannelMessageReceived); |
| 1808 } | 1832 } |
| 1809 | 1833 |
| 1810 data_channel_->SignalDtlsSetupFailure.connect( | 1834 data_channel_->SignalDtlsSetupFailure.connect( |
| 1811 this, &WebRtcSession::OnDtlsSetupFailure); | 1835 this, &WebRtcSession::OnDtlsSetupFailure); |
| 1812 | 1836 |
| 1813 SignalDataChannelCreated(); | 1837 SignalDataChannelCreated(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1906 | 1930 |
| 1907 // Verify ice-ufrag and ice-pwd. | 1931 // Verify ice-ufrag and ice-pwd. |
| 1908 if (!VerifyIceUfragPwdPresent(sdesc->description())) { | 1932 if (!VerifyIceUfragPwdPresent(sdesc->description())) { |
| 1909 return BadSdp(source, type, kSdpWithoutIceUfragPwd, err_desc); | 1933 return BadSdp(source, type, kSdpWithoutIceUfragPwd, err_desc); |
| 1910 } | 1934 } |
| 1911 | 1935 |
| 1912 if (!ValidateBundleSettings(sdesc->description())) { | 1936 if (!ValidateBundleSettings(sdesc->description())) { |
| 1913 return BadSdp(source, type, kBundleWithoutRtcpMux, err_desc); | 1937 return BadSdp(source, type, kBundleWithoutRtcpMux, err_desc); |
| 1914 } | 1938 } |
| 1915 | 1939 |
| 1940 // TODO(skvlad): When the local rtcp-mux policy is Require, reject any |
| 1941 // m-lines that do not rtcp-mux enabled. |
| 1942 |
| 1916 // Verify m-lines in Answer when compared against Offer. | 1943 // Verify m-lines in Answer when compared against Offer. |
| 1917 if (action == kAnswer) { | 1944 if (action == kAnswer) { |
| 1918 const cricket::SessionDescription* offer_desc = | 1945 const cricket::SessionDescription* offer_desc = |
| 1919 (source == cricket::CS_LOCAL) ? remote_desc_->description() | 1946 (source == cricket::CS_LOCAL) ? remote_desc_->description() |
| 1920 : local_desc_->description(); | 1947 : local_desc_->description(); |
| 1921 if (!VerifyMediaDescriptions(sdesc->description(), offer_desc)) { | 1948 if (!VerifyMediaDescriptions(sdesc->description(), offer_desc)) { |
| 1922 return BadAnswerSdp(source, kMlineMismatch, err_desc); | 1949 return BadAnswerSdp(source, kMlineMismatch, err_desc); |
| 1923 } | 1950 } |
| 1924 } | 1951 } |
| 1925 | 1952 |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2128 ssl_cipher_suite); | 2155 ssl_cipher_suite); |
| 2129 } | 2156 } |
| 2130 } | 2157 } |
| 2131 | 2158 |
| 2132 void WebRtcSession::OnSentPacket_w(const rtc::SentPacket& sent_packet) { | 2159 void WebRtcSession::OnSentPacket_w(const rtc::SentPacket& sent_packet) { |
| 2133 RTC_DCHECK(worker_thread()->IsCurrent()); | 2160 RTC_DCHECK(worker_thread()->IsCurrent()); |
| 2134 media_controller_->call_w()->OnSentPacket(sent_packet); | 2161 media_controller_->call_w()->OnSentPacket(sent_packet); |
| 2135 } | 2162 } |
| 2136 | 2163 |
| 2137 } // namespace webrtc | 2164 } // namespace webrtc |
| OLD | NEW |