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 1709 matching lines...) Loading... | |
1720 } | 1720 } |
1721 | 1721 |
1722 const cricket::ContentInfo* data_info = | 1722 const cricket::ContentInfo* data_info = |
1723 cricket::GetFirstDataContent(desc); | 1723 cricket::GetFirstDataContent(desc); |
1724 if ((!data_info || data_info->rejected) && data_channel_) { | 1724 if ((!data_info || data_info->rejected) && data_channel_) { |
1725 SignalDataChannelDestroyed(); | 1725 SignalDataChannelDestroyed(); |
1726 channel_manager_->DestroyDataChannel(data_channel_.release()); | 1726 channel_manager_->DestroyDataChannel(data_channel_.release()); |
1727 } | 1727 } |
1728 } | 1728 } |
1729 | 1729 |
1730 // TODO(mallinath) - Add a correct error code if the channels are not created | 1730 // Returns the name of the transport channel when BUNDLE is enabled, or nullptr |
1731 // due to BUNDLE is enabled but rtcp-mux is disabled. | 1731 // if the channel is not part of any bundle. |
1732 const std::string* WebRtcSession::GetBundleTransportName( | |
1733 const cricket::ContentInfo* content, | |
1734 const cricket::ContentGroup* bundle) { | |
1735 if (!bundle) { | |
1736 return nullptr; | |
1737 } | |
1738 const std::string* first_content_name = bundle->FirstContentName(); | |
1739 if (!first_content_name) { | |
1740 LOG(LS_WARNING) << "Tried to BUNDLE with no contents."; | |
1741 return nullptr; | |
1742 } | |
1743 if (!bundle->HasContentName(content->name)) { | |
1744 LOG(LS_WARNING) << content->name << " is not part of any bundle group"; | |
1745 return nullptr; | |
1746 } | |
1747 LOG(LS_INFO) << "Bundling " << content->name << " on " << *first_content_name; | |
1748 return first_content_name; | |
1749 } | |
1750 | |
1732 bool WebRtcSession::CreateChannels(const SessionDescription* desc) { | 1751 bool WebRtcSession::CreateChannels(const SessionDescription* desc) { |
1752 const cricket::ContentGroup* bundle_group = nullptr; | |
1753 if (bundle_policy_ == PeerConnectionInterface::kBundlePolicyMaxBundle) { | |
1754 bundle_group = desc->GetGroupByName(cricket::GROUP_TYPE_BUNDLE); | |
1755 if (!bundle_group) { | |
1756 LOG(LS_WARNING) << "max-bundle specified without BUNDLE specified"; | |
1757 return false; | |
1758 } | |
1759 } | |
1733 // Creating the media channels and transport proxies. | 1760 // Creating the media channels and transport proxies. |
1734 const cricket::ContentInfo* voice = cricket::GetFirstAudioContent(desc); | 1761 const cricket::ContentInfo* voice = cricket::GetFirstAudioContent(desc); |
1735 if (voice && !voice->rejected && !voice_channel_) { | 1762 if (voice && !voice->rejected && !voice_channel_) { |
1736 if (!CreateVoiceChannel(voice)) { | 1763 if (!CreateVoiceChannel(voice, |
1764 GetBundleTransportName(voice, bundle_group))) { | |
1737 LOG(LS_ERROR) << "Failed to create voice channel."; | 1765 LOG(LS_ERROR) << "Failed to create voice channel."; |
1738 return false; | 1766 return false; |
1739 } | 1767 } |
1740 } | 1768 } |
1741 | 1769 |
1742 const cricket::ContentInfo* video = cricket::GetFirstVideoContent(desc); | 1770 const cricket::ContentInfo* video = cricket::GetFirstVideoContent(desc); |
1743 if (video && !video->rejected && !video_channel_) { | 1771 if (video && !video->rejected && !video_channel_) { |
1744 if (!CreateVideoChannel(video)) { | 1772 if (!CreateVideoChannel(video, |
1773 GetBundleTransportName(video, bundle_group))) { | |
1745 LOG(LS_ERROR) << "Failed to create video channel."; | 1774 LOG(LS_ERROR) << "Failed to create video channel."; |
1746 return false; | 1775 return false; |
1747 } | 1776 } |
1748 } | 1777 } |
1749 | 1778 |
1750 const cricket::ContentInfo* data = cricket::GetFirstDataContent(desc); | 1779 const cricket::ContentInfo* data = cricket::GetFirstDataContent(desc); |
1751 if (data_channel_type_ != cricket::DCT_NONE && | 1780 if (data_channel_type_ != cricket::DCT_NONE && |
1752 data && !data->rejected && !data_channel_) { | 1781 data && !data->rejected && !data_channel_) { |
1753 if (!CreateDataChannel(data)) { | 1782 if (!CreateDataChannel(data, GetBundleTransportName(data, bundle_group))) { |
1754 LOG(LS_ERROR) << "Failed to create data channel."; | 1783 LOG(LS_ERROR) << "Failed to create data channel."; |
1755 return false; | 1784 return false; |
1756 } | 1785 } |
1757 } | 1786 } |
1758 | 1787 |
1759 if (rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire) { | |
1760 if (voice_channel()) { | |
1761 voice_channel()->ActivateRtcpMux(); | |
1762 } | |
1763 if (video_channel()) { | |
1764 video_channel()->ActivateRtcpMux(); | |
1765 } | |
1766 if (data_channel()) { | |
1767 data_channel()->ActivateRtcpMux(); | |
1768 } | |
1769 } | |
1770 | |
1771 // Enable BUNDLE immediately when kBundlePolicyMaxBundle is in effect. | |
1772 if (bundle_policy_ == PeerConnectionInterface::kBundlePolicyMaxBundle) { | |
1773 const cricket::ContentGroup* bundle_group = desc->GetGroupByName( | |
1774 cricket::GROUP_TYPE_BUNDLE); | |
1775 if (!bundle_group) { | |
1776 LOG(LS_WARNING) << "max-bundle specified without BUNDLE specified"; | |
1777 return false; | |
1778 } | |
1779 if (!EnableBundle(*bundle_group)) { | |
1780 LOG(LS_WARNING) << "max-bundle failed to enable bundling."; | |
1781 return false; | |
1782 } | |
1783 } | |
1784 | |
1785 return true; | 1788 return true; |
1786 } | 1789 } |
1787 | 1790 |
1788 bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content) { | 1791 bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content, |
1792 const std::string* bundle_transport) { | |
1793 bool rtcp_mux = | |
1794 rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire; | |
pthatcher1
2016/05/12 03:56:52
This might be a little more clear as:
bool requir
skvlad
2016/05/13 19:17:51
Done.
| |
1789 voice_channel_.reset(channel_manager_->CreateVoiceChannel( | 1795 voice_channel_.reset(channel_manager_->CreateVoiceChannel( |
1790 media_controller_, transport_controller_.get(), content->name, true, | 1796 media_controller_, transport_controller_.get(), content->name, |
1791 audio_options_)); | 1797 bundle_transport, !rtcp_mux /* rtcp */, audio_options_)); |
1792 if (!voice_channel_) { | 1798 if (!voice_channel_) { |
1793 return false; | 1799 return false; |
1794 } | 1800 } |
1801 if (rtcp_mux) { | |
1802 voice_channel_->ActivateRtcpMux(); | |
1803 } | |
1795 | 1804 |
1796 voice_channel_->SignalDtlsSetupFailure.connect( | 1805 voice_channel_->SignalDtlsSetupFailure.connect( |
1797 this, &WebRtcSession::OnDtlsSetupFailure); | 1806 this, &WebRtcSession::OnDtlsSetupFailure); |
1798 | 1807 |
1799 SignalVoiceChannelCreated(); | 1808 SignalVoiceChannelCreated(); |
1800 voice_channel_->SignalSentPacket.connect(this, | 1809 voice_channel_->SignalSentPacket.connect(this, |
1801 &WebRtcSession::OnSentPacket_w); | 1810 &WebRtcSession::OnSentPacket_w); |
1802 return true; | 1811 return true; |
1803 } | 1812 } |
1804 | 1813 |
1805 bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content) { | 1814 bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content, |
1815 const std::string* bundle_transport) { | |
1816 bool rtcp_mux = | |
1817 rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire; | |
1806 video_channel_.reset(channel_manager_->CreateVideoChannel( | 1818 video_channel_.reset(channel_manager_->CreateVideoChannel( |
1807 media_controller_, transport_controller_.get(), content->name, true, | 1819 media_controller_, transport_controller_.get(), content->name, |
1808 video_options_)); | 1820 bundle_transport, !rtcp_mux /* rtcp */, video_options_)); |
1809 if (!video_channel_) { | 1821 if (!video_channel_) { |
1810 return false; | 1822 return false; |
1811 } | 1823 } |
1812 | 1824 if (rtcp_mux) { |
1825 video_channel_->ActivateRtcpMux(); | |
1826 } | |
1813 video_channel_->SignalDtlsSetupFailure.connect( | 1827 video_channel_->SignalDtlsSetupFailure.connect( |
1814 this, &WebRtcSession::OnDtlsSetupFailure); | 1828 this, &WebRtcSession::OnDtlsSetupFailure); |
1815 | 1829 |
1816 SignalVideoChannelCreated(); | 1830 SignalVideoChannelCreated(); |
1817 video_channel_->SignalSentPacket.connect(this, | 1831 video_channel_->SignalSentPacket.connect(this, |
1818 &WebRtcSession::OnSentPacket_w); | 1832 &WebRtcSession::OnSentPacket_w); |
1819 return true; | 1833 return true; |
1820 } | 1834 } |
1821 | 1835 |
1822 bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content) { | 1836 bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content, |
1837 const std::string* bundle_transport) { | |
1823 bool sctp = (data_channel_type_ == cricket::DCT_SCTP); | 1838 bool sctp = (data_channel_type_ == cricket::DCT_SCTP); |
1839 bool rtcp_mux = | |
1840 rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire; | |
1824 data_channel_.reset(channel_manager_->CreateDataChannel( | 1841 data_channel_.reset(channel_manager_->CreateDataChannel( |
1825 transport_controller_.get(), content->name, !sctp, data_channel_type_)); | 1842 transport_controller_.get(), content->name, bundle_transport, |
1843 !sctp && !rtcp_mux /* rtcp */, data_channel_type_)); | |
1826 if (!data_channel_) { | 1844 if (!data_channel_) { |
1827 return false; | 1845 return false; |
1828 } | 1846 } |
1847 if (rtcp_mux) { | |
1848 data_channel_->ActivateRtcpMux(); | |
1849 } | |
1829 | 1850 |
1830 if (sctp) { | 1851 if (sctp) { |
1831 data_channel_->SignalDataReceived.connect( | 1852 data_channel_->SignalDataReceived.connect( |
1832 this, &WebRtcSession::OnDataChannelMessageReceived); | 1853 this, &WebRtcSession::OnDataChannelMessageReceived); |
1833 } | 1854 } |
1834 | 1855 |
1835 data_channel_->SignalDtlsSetupFailure.connect( | 1856 data_channel_->SignalDtlsSetupFailure.connect( |
1836 this, &WebRtcSession::OnDtlsSetupFailure); | 1857 this, &WebRtcSession::OnDtlsSetupFailure); |
1837 | 1858 |
1838 SignalDataChannelCreated(); | 1859 SignalDataChannelCreated(); |
(...skipping 92 matching lines...) Loading... | |
1931 | 1952 |
1932 // Verify ice-ufrag and ice-pwd. | 1953 // Verify ice-ufrag and ice-pwd. |
1933 if (!VerifyIceUfragPwdPresent(sdesc->description())) { | 1954 if (!VerifyIceUfragPwdPresent(sdesc->description())) { |
1934 return BadSdp(source, type, kSdpWithoutIceUfragPwd, err_desc); | 1955 return BadSdp(source, type, kSdpWithoutIceUfragPwd, err_desc); |
1935 } | 1956 } |
1936 | 1957 |
1937 if (!ValidateBundleSettings(sdesc->description())) { | 1958 if (!ValidateBundleSettings(sdesc->description())) { |
1938 return BadSdp(source, type, kBundleWithoutRtcpMux, err_desc); | 1959 return BadSdp(source, type, kBundleWithoutRtcpMux, err_desc); |
1939 } | 1960 } |
1940 | 1961 |
1962 // TODO(skvlad): Verify that when the local RTCP mux policy is Require, the | |
1963 // remote description enables RTCP mux. | |
pthatcher1
2016/05/12 03:56:52
Or, rather, reject any m= sections that do not hav
skvlad
2016/05/13 19:17:51
Done.
| |
1964 | |
1941 // Verify m-lines in Answer when compared against Offer. | 1965 // Verify m-lines in Answer when compared against Offer. |
1942 if (action == kAnswer) { | 1966 if (action == kAnswer) { |
1943 const cricket::SessionDescription* offer_desc = | 1967 const cricket::SessionDescription* offer_desc = |
1944 (source == cricket::CS_LOCAL) ? remote_desc_->description() | 1968 (source == cricket::CS_LOCAL) ? remote_desc_->description() |
1945 : local_desc_->description(); | 1969 : local_desc_->description(); |
1946 if (!VerifyMediaDescriptions(sdesc->description(), offer_desc)) { | 1970 if (!VerifyMediaDescriptions(sdesc->description(), offer_desc)) { |
1947 return BadAnswerSdp(source, kMlineMismatch, err_desc); | 1971 return BadAnswerSdp(source, kMlineMismatch, err_desc); |
1948 } | 1972 } |
1949 } | 1973 } |
1950 | 1974 |
(...skipping 202 matching lines...) Loading... | |
2153 ssl_cipher_suite); | 2177 ssl_cipher_suite); |
2154 } | 2178 } |
2155 } | 2179 } |
2156 | 2180 |
2157 void WebRtcSession::OnSentPacket_w(const rtc::SentPacket& sent_packet) { | 2181 void WebRtcSession::OnSentPacket_w(const rtc::SentPacket& sent_packet) { |
2158 RTC_DCHECK(worker_thread()->IsCurrent()); | 2182 RTC_DCHECK(worker_thread()->IsCurrent()); |
2159 media_controller_->call_w()->OnSentPacket(sent_packet); | 2183 media_controller_->call_w()->OnSentPacket(sent_packet); |
2160 } | 2184 } |
2161 | 2185 |
2162 } // namespace webrtc | 2186 } // namespace webrtc |
OLD | NEW |