Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: webrtc/api/webrtcsession.cc

Issue 1972493002: Do not create a temporary transport channel when using max-bundle (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/api/webrtcsession.h ('k') | webrtc/api/webrtcsession_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1721 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 } 1732 }
1733 1733
1734 const cricket::ContentInfo* data_info = 1734 const cricket::ContentInfo* data_info =
1735 cricket::GetFirstDataContent(desc); 1735 cricket::GetFirstDataContent(desc);
1736 if ((!data_info || data_info->rejected) && data_channel_) { 1736 if ((!data_info || data_info->rejected) && data_channel_) {
1737 SignalDataChannelDestroyed(); 1737 SignalDataChannelDestroyed();
1738 channel_manager_->DestroyDataChannel(data_channel_.release()); 1738 channel_manager_->DestroyDataChannel(data_channel_.release());
1739 } 1739 }
1740 } 1740 }
1741 1741
1742 // TODO(mallinath) - Add a correct error code if the channels are not created 1742 // Returns the name of the transport channel when BUNDLE is enabled, or nullptr
1743 // due to BUNDLE is enabled but rtcp-mux is disabled. 1743 // if the channel is not part of any bundle.
1744 const std::string* WebRtcSession::GetBundleTransportName(
1745 const cricket::ContentInfo* content,
1746 const cricket::ContentGroup* bundle) {
1747 if (!bundle) {
1748 return nullptr;
1749 }
1750 const std::string* first_content_name = bundle->FirstContentName();
1751 if (!first_content_name) {
1752 LOG(LS_WARNING) << "Tried to BUNDLE with no contents.";
1753 return nullptr;
1754 }
1755 if (!bundle->HasContentName(content->name)) {
1756 LOG(LS_WARNING) << content->name << " is not part of any bundle group";
1757 return nullptr;
1758 }
1759 LOG(LS_INFO) << "Bundling " << content->name << " on " << *first_content_name;
1760 return first_content_name;
1761 }
1762
1744 bool WebRtcSession::CreateChannels(const SessionDescription* desc) { 1763 bool WebRtcSession::CreateChannels(const SessionDescription* desc) {
1764 const cricket::ContentGroup* bundle_group = nullptr;
1765 if (bundle_policy_ == PeerConnectionInterface::kBundlePolicyMaxBundle) {
1766 bundle_group = desc->GetGroupByName(cricket::GROUP_TYPE_BUNDLE);
1767 if (!bundle_group) {
1768 LOG(LS_WARNING) << "max-bundle specified without BUNDLE specified";
1769 return false;
1770 }
1771 }
1745 // Creating the media channels and transport proxies. 1772 // Creating the media channels and transport proxies.
1746 const cricket::ContentInfo* voice = cricket::GetFirstAudioContent(desc); 1773 const cricket::ContentInfo* voice = cricket::GetFirstAudioContent(desc);
1747 if (voice && !voice->rejected && !voice_channel_) { 1774 if (voice && !voice->rejected && !voice_channel_) {
1748 if (!CreateVoiceChannel(voice)) { 1775 if (!CreateVoiceChannel(voice,
1776 GetBundleTransportName(voice, bundle_group))) {
1749 LOG(LS_ERROR) << "Failed to create voice channel."; 1777 LOG(LS_ERROR) << "Failed to create voice channel.";
1750 return false; 1778 return false;
1751 } 1779 }
1752 } 1780 }
1753 1781
1754 const cricket::ContentInfo* video = cricket::GetFirstVideoContent(desc); 1782 const cricket::ContentInfo* video = cricket::GetFirstVideoContent(desc);
1755 if (video && !video->rejected && !video_channel_) { 1783 if (video && !video->rejected && !video_channel_) {
1756 if (!CreateVideoChannel(video)) { 1784 if (!CreateVideoChannel(video,
1785 GetBundleTransportName(video, bundle_group))) {
1757 LOG(LS_ERROR) << "Failed to create video channel."; 1786 LOG(LS_ERROR) << "Failed to create video channel.";
1758 return false; 1787 return false;
1759 } 1788 }
1760 } 1789 }
1761 1790
1762 const cricket::ContentInfo* data = cricket::GetFirstDataContent(desc); 1791 const cricket::ContentInfo* data = cricket::GetFirstDataContent(desc);
1763 if (data_channel_type_ != cricket::DCT_NONE && 1792 if (data_channel_type_ != cricket::DCT_NONE &&
1764 data && !data->rejected && !data_channel_) { 1793 data && !data->rejected && !data_channel_) {
1765 if (!CreateDataChannel(data)) { 1794 if (!CreateDataChannel(data, GetBundleTransportName(data, bundle_group))) {
1766 LOG(LS_ERROR) << "Failed to create data channel."; 1795 LOG(LS_ERROR) << "Failed to create data channel.";
1767 return false; 1796 return false;
1768 } 1797 }
1769 } 1798 }
1770 1799
1771 if (rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire) {
1772 if (voice_channel()) {
1773 voice_channel()->ActivateRtcpMux();
1774 }
1775 if (video_channel()) {
1776 video_channel()->ActivateRtcpMux();
1777 }
1778 if (data_channel()) {
1779 data_channel()->ActivateRtcpMux();
1780 }
1781 }
1782
1783 // Enable BUNDLE immediately when kBundlePolicyMaxBundle is in effect.
1784 if (bundle_policy_ == PeerConnectionInterface::kBundlePolicyMaxBundle) {
1785 const cricket::ContentGroup* bundle_group = desc->GetGroupByName(
1786 cricket::GROUP_TYPE_BUNDLE);
1787 if (!bundle_group) {
1788 LOG(LS_WARNING) << "max-bundle specified without BUNDLE specified";
1789 return false;
1790 }
1791 if (!EnableBundle(*bundle_group)) {
1792 LOG(LS_WARNING) << "max-bundle failed to enable bundling.";
1793 return false;
1794 }
1795 }
1796
1797 return true; 1800 return true;
1798 } 1801 }
1799 1802
1800 bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content) { 1803 bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content,
1804 const std::string* bundle_transport) {
1805 bool require_rtcp_mux =
1806 rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire;
1807 bool create_rtcp_transport_channel = !require_rtcp_mux;
1801 voice_channel_.reset(channel_manager_->CreateVoiceChannel( 1808 voice_channel_.reset(channel_manager_->CreateVoiceChannel(
1802 media_controller_, transport_controller_.get(), content->name, true, 1809 media_controller_, transport_controller_.get(), content->name,
1803 audio_options_)); 1810 bundle_transport, create_rtcp_transport_channel, audio_options_));
1804 if (!voice_channel_) { 1811 if (!voice_channel_) {
1805 return false; 1812 return false;
1806 } 1813 }
1814 if (require_rtcp_mux) {
1815 voice_channel_->ActivateRtcpMux();
1816 }
1807 1817
1808 voice_channel_->SignalDtlsSetupFailure.connect( 1818 voice_channel_->SignalDtlsSetupFailure.connect(
1809 this, &WebRtcSession::OnDtlsSetupFailure); 1819 this, &WebRtcSession::OnDtlsSetupFailure);
1810 1820
1811 SignalVoiceChannelCreated(); 1821 SignalVoiceChannelCreated();
1812 voice_channel_->SignalSentPacket.connect(this, 1822 voice_channel_->SignalSentPacket.connect(this,
1813 &WebRtcSession::OnSentPacket_w); 1823 &WebRtcSession::OnSentPacket_w);
1814 return true; 1824 return true;
1815 } 1825 }
1816 1826
1817 bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content) { 1827 bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content,
1828 const std::string* bundle_transport) {
1829 bool require_rtcp_mux =
1830 rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire;
1831 bool create_rtcp_transport_channel = !require_rtcp_mux;
1818 video_channel_.reset(channel_manager_->CreateVideoChannel( 1832 video_channel_.reset(channel_manager_->CreateVideoChannel(
1819 media_controller_, transport_controller_.get(), content->name, true, 1833 media_controller_, transport_controller_.get(), content->name,
1820 video_options_)); 1834 bundle_transport, create_rtcp_transport_channel, video_options_));
1821 if (!video_channel_) { 1835 if (!video_channel_) {
1822 return false; 1836 return false;
1823 } 1837 }
1824 1838 if (require_rtcp_mux) {
1839 video_channel_->ActivateRtcpMux();
1840 }
1825 video_channel_->SignalDtlsSetupFailure.connect( 1841 video_channel_->SignalDtlsSetupFailure.connect(
1826 this, &WebRtcSession::OnDtlsSetupFailure); 1842 this, &WebRtcSession::OnDtlsSetupFailure);
1827 1843
1828 SignalVideoChannelCreated(); 1844 SignalVideoChannelCreated();
1829 video_channel_->SignalSentPacket.connect(this, 1845 video_channel_->SignalSentPacket.connect(this,
1830 &WebRtcSession::OnSentPacket_w); 1846 &WebRtcSession::OnSentPacket_w);
1831 return true; 1847 return true;
1832 } 1848 }
1833 1849
1834 bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content) { 1850 bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content,
1851 const std::string* bundle_transport) {
1835 bool sctp = (data_channel_type_ == cricket::DCT_SCTP); 1852 bool sctp = (data_channel_type_ == cricket::DCT_SCTP);
1853 bool require_rtcp_mux =
1854 rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire;
1855 bool create_rtcp_transport_channel = !sctp && !require_rtcp_mux;
1836 data_channel_.reset(channel_manager_->CreateDataChannel( 1856 data_channel_.reset(channel_manager_->CreateDataChannel(
1837 transport_controller_.get(), content->name, !sctp, data_channel_type_)); 1857 transport_controller_.get(), content->name, bundle_transport,
1858 create_rtcp_transport_channel, data_channel_type_));
1838 if (!data_channel_) { 1859 if (!data_channel_) {
1839 return false; 1860 return false;
1840 } 1861 }
1862 if (require_rtcp_mux) {
1863 data_channel_->ActivateRtcpMux();
1864 }
1841 1865
1842 if (sctp) { 1866 if (sctp) {
1843 data_channel_->SignalDataReceived.connect( 1867 data_channel_->SignalDataReceived.connect(
1844 this, &WebRtcSession::OnDataChannelMessageReceived); 1868 this, &WebRtcSession::OnDataChannelMessageReceived);
1845 } 1869 }
1846 1870
1847 data_channel_->SignalDtlsSetupFailure.connect( 1871 data_channel_->SignalDtlsSetupFailure.connect(
1848 this, &WebRtcSession::OnDtlsSetupFailure); 1872 this, &WebRtcSession::OnDtlsSetupFailure);
1849 1873
1850 SignalDataChannelCreated(); 1874 SignalDataChannelCreated();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 1967
1944 // Verify ice-ufrag and ice-pwd. 1968 // Verify ice-ufrag and ice-pwd.
1945 if (!VerifyIceUfragPwdPresent(sdesc->description())) { 1969 if (!VerifyIceUfragPwdPresent(sdesc->description())) {
1946 return BadSdp(source, type, kSdpWithoutIceUfragPwd, err_desc); 1970 return BadSdp(source, type, kSdpWithoutIceUfragPwd, err_desc);
1947 } 1971 }
1948 1972
1949 if (!ValidateBundleSettings(sdesc->description())) { 1973 if (!ValidateBundleSettings(sdesc->description())) {
1950 return BadSdp(source, type, kBundleWithoutRtcpMux, err_desc); 1974 return BadSdp(source, type, kBundleWithoutRtcpMux, err_desc);
1951 } 1975 }
1952 1976
1977 // TODO(skvlad): When the local rtcp-mux policy is Require, reject any
1978 // m-lines that do not rtcp-mux enabled.
1979
1953 // Verify m-lines in Answer when compared against Offer. 1980 // Verify m-lines in Answer when compared against Offer.
1954 if (action == kAnswer) { 1981 if (action == kAnswer) {
1955 const cricket::SessionDescription* offer_desc = 1982 const cricket::SessionDescription* offer_desc =
1956 (source == cricket::CS_LOCAL) ? remote_desc_->description() 1983 (source == cricket::CS_LOCAL) ? remote_desc_->description()
1957 : local_desc_->description(); 1984 : local_desc_->description();
1958 if (!VerifyMediaDescriptions(sdesc->description(), offer_desc)) { 1985 if (!VerifyMediaDescriptions(sdesc->description(), offer_desc)) {
1959 return BadAnswerSdp(source, kMlineMismatch, err_desc); 1986 return BadAnswerSdp(source, kMlineMismatch, err_desc);
1960 } 1987 }
1961 } 1988 }
1962 1989
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
2165 ssl_cipher_suite); 2192 ssl_cipher_suite);
2166 } 2193 }
2167 } 2194 }
2168 2195
2169 void WebRtcSession::OnSentPacket_w(const rtc::SentPacket& sent_packet) { 2196 void WebRtcSession::OnSentPacket_w(const rtc::SentPacket& sent_packet) {
2170 RTC_DCHECK(worker_thread()->IsCurrent()); 2197 RTC_DCHECK(worker_thread()->IsCurrent());
2171 media_controller_->call_w()->OnSentPacket(sent_packet); 2198 media_controller_->call_w()->OnSentPacket(sent_packet);
2172 } 2199 }
2173 2200
2174 } // namespace webrtc 2201 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/api/webrtcsession.h ('k') | webrtc/api/webrtcsession_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698