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...) Expand 10 before | Expand all | Expand 10 after 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 // Returns the name of the transport channel when BUNDLE is enabled. | |
1731 const std::string& WebRtcSession::GetTransportForChannel( | |
pthatcher1
2016/05/11 06:20:39
Why not, instead, return a const pointer that is N
| |
1732 const cricket::ContentInfo* content, | |
1733 const cricket::ContentGroup* bundle) { | |
1734 if (!bundle) { | |
1735 return content->name; | |
1736 } | |
1737 const std::string* first_content_name = bundle->FirstContentName(); | |
1738 if (!first_content_name) { | |
1739 LOG(LS_WARNING) << "Tried to BUNDLE with no contents."; | |
1740 return content->name; | |
1741 } | |
1742 | |
1743 const std::string& transport_name = *first_content_name; | |
1744 if (bundle->HasContentName(content->name)) { | |
1745 LOG(LS_INFO) << "Bundling " << content->name << " on " << transport_name; | |
1746 return transport_name; | |
1747 } | |
1748 return content->name; | |
1749 } | |
1750 | |
1730 // TODO(mallinath) - Add a correct error code if the channels are not created | 1751 // TODO(mallinath) - Add a correct error code if the channels are not created |
skvlad
2016/05/11 22:24:19
This TODO seems to not apply - there is a check fo
| |
1731 // due to BUNDLE is enabled but rtcp-mux is disabled. | 1752 // due to BUNDLE is enabled but rtcp-mux is disabled. |
1732 bool WebRtcSession::CreateChannels(const SessionDescription* desc) { | 1753 bool WebRtcSession::CreateChannels(const SessionDescription* desc) { |
1754 const cricket::ContentGroup* bundle_group = nullptr; | |
1755 if (bundle_policy_ == PeerConnectionInterface::kBundlePolicyMaxBundle) { | |
pthatcher1
2016/05/11 06:20:39
If the policy is max bundle, then all the channels
Taylor Brandstetter
2016/05/11 15:32:23
JSEP does say the application can't munge BUNDLE g
pthatcher1
2016/05/11 22:23:47
If we are in max-bundle mode, we already reject de
skvlad
2016/05/11 22:24:19
Added a TODO to reject the offer in this case when
Taylor Brandstetter
2016/05/11 22:35:55
I'm of the opposite opinion... I think we should d
| |
1756 bundle_group = desc->GetGroupByName(cricket::GROUP_TYPE_BUNDLE); | |
1757 if (!bundle_group) { | |
1758 LOG(LS_WARNING) << "max-bundle specified without BUNDLE specified"; | |
1759 return false; | |
1760 } | |
1761 } | |
1762 | |
1733 // Creating the media channels and transport proxies. | 1763 // Creating the media channels and transport proxies. |
1734 const cricket::ContentInfo* voice = cricket::GetFirstAudioContent(desc); | 1764 const cricket::ContentInfo* voice = cricket::GetFirstAudioContent(desc); |
1735 if (voice && !voice->rejected && !voice_channel_) { | 1765 if (voice && !voice->rejected && !voice_channel_) { |
1736 if (!CreateVoiceChannel(voice)) { | 1766 if (!CreateVoiceChannel(voice, |
1767 GetTransportForChannel(voice, bundle_group))) { | |
1737 LOG(LS_ERROR) << "Failed to create voice channel."; | 1768 LOG(LS_ERROR) << "Failed to create voice channel."; |
1738 return false; | 1769 return false; |
1739 } | 1770 } |
1740 } | 1771 } |
1741 | 1772 |
1742 const cricket::ContentInfo* video = cricket::GetFirstVideoContent(desc); | 1773 const cricket::ContentInfo* video = cricket::GetFirstVideoContent(desc); |
1743 if (video && !video->rejected && !video_channel_) { | 1774 if (video && !video->rejected && !video_channel_) { |
1744 if (!CreateVideoChannel(video)) { | 1775 if (!CreateVideoChannel(video, |
1776 GetTransportForChannel(video, bundle_group))) { | |
1745 LOG(LS_ERROR) << "Failed to create video channel."; | 1777 LOG(LS_ERROR) << "Failed to create video channel."; |
1746 return false; | 1778 return false; |
1747 } | 1779 } |
1748 } | 1780 } |
1749 | 1781 |
1750 const cricket::ContentInfo* data = cricket::GetFirstDataContent(desc); | 1782 const cricket::ContentInfo* data = cricket::GetFirstDataContent(desc); |
1751 if (data_channel_type_ != cricket::DCT_NONE && | 1783 if (data_channel_type_ != cricket::DCT_NONE && |
1752 data && !data->rejected && !data_channel_) { | 1784 data && !data->rejected && !data_channel_) { |
1753 if (!CreateDataChannel(data)) { | 1785 if (!CreateDataChannel(data, GetTransportForChannel(data, bundle_group))) { |
1754 LOG(LS_ERROR) << "Failed to create data channel."; | 1786 LOG(LS_ERROR) << "Failed to create data channel."; |
1755 return false; | 1787 return false; |
1756 } | 1788 } |
1757 } | 1789 } |
1758 | 1790 |
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; | 1791 return true; |
1786 } | 1792 } |
1787 | 1793 |
1788 bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content) { | 1794 bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content, |
1795 const std::string& transport_name) { | |
1789 voice_channel_.reset(channel_manager_->CreateVoiceChannel( | 1796 voice_channel_.reset(channel_manager_->CreateVoiceChannel( |
1790 media_controller_, transport_controller_.get(), content->name, true, | 1797 media_controller_, transport_controller_.get(), content->name, |
1798 transport_name, | |
1799 rtcp_mux_policy_ != | |
1800 PeerConnectionInterface::kRtcpMuxPolicyRequire /* rtcp */, | |
pthatcher1
2016/05/11 06:20:39
Can you put this on a separate line?
bool rtcp_mu
Taylor Brandstetter
2016/05/11 15:32:23
This means that if we receive a remote description
pthatcher1
2016/05/11 22:23:47
The "rtcp" parameter here ultimately gets passed i
skvlad
2016/05/11 22:24:19
Done.
skvlad
2016/05/11 22:24:20
Added a comment in ValidateSessionDescription.
| |
1791 audio_options_)); | 1801 audio_options_)); |
1792 if (!voice_channel_) { | 1802 if (!voice_channel_) { |
1793 return false; | 1803 return false; |
1794 } | 1804 } |
1805 if (rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire) { | |
1806 voice_channel_->ActivateRtcpMux(); | |
1807 } | |
1795 | 1808 |
1796 voice_channel_->SignalDtlsSetupFailure.connect( | 1809 voice_channel_->SignalDtlsSetupFailure.connect( |
1797 this, &WebRtcSession::OnDtlsSetupFailure); | 1810 this, &WebRtcSession::OnDtlsSetupFailure); |
1798 | 1811 |
1799 SignalVoiceChannelCreated(); | 1812 SignalVoiceChannelCreated(); |
1800 voice_channel_->transport_channel()->SignalSentPacket.connect( | 1813 voice_channel_->transport_channel()->SignalSentPacket.connect( |
1801 this, &WebRtcSession::OnSentPacket_w); | 1814 this, &WebRtcSession::OnSentPacket_w); |
1802 return true; | 1815 return true; |
1803 } | 1816 } |
1804 | 1817 |
1805 bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content) { | 1818 bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content, |
1819 const std::string& transport_name) { | |
1806 video_channel_.reset(channel_manager_->CreateVideoChannel( | 1820 video_channel_.reset(channel_manager_->CreateVideoChannel( |
1807 media_controller_, transport_controller_.get(), content->name, true, | 1821 media_controller_, transport_controller_.get(), content->name, |
1822 transport_name, | |
1823 rtcp_mux_policy_ != | |
1824 PeerConnectionInterface::kRtcpMuxPolicyRequire /* rtcp */, | |
pthatcher1
2016/05/11 06:20:39
Same thing here.
skvlad
2016/05/11 22:24:20
Acknowledged.
| |
1808 video_options_)); | 1825 video_options_)); |
1809 if (!video_channel_) { | 1826 if (!video_channel_) { |
1810 return false; | 1827 return false; |
1811 } | 1828 } |
1812 | 1829 if (rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire) { |
1830 video_channel_->ActivateRtcpMux(); | |
1831 } | |
1813 video_channel_->SignalDtlsSetupFailure.connect( | 1832 video_channel_->SignalDtlsSetupFailure.connect( |
1814 this, &WebRtcSession::OnDtlsSetupFailure); | 1833 this, &WebRtcSession::OnDtlsSetupFailure); |
1815 | 1834 |
1816 SignalVideoChannelCreated(); | 1835 SignalVideoChannelCreated(); |
1817 video_channel_->transport_channel()->SignalSentPacket.connect( | 1836 video_channel_->transport_channel()->SignalSentPacket.connect( |
1818 this, &WebRtcSession::OnSentPacket_w); | 1837 this, &WebRtcSession::OnSentPacket_w); |
1819 return true; | 1838 return true; |
1820 } | 1839 } |
1821 | 1840 |
1822 bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content) { | 1841 bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content, |
1842 const std::string& transport_name) { | |
1823 bool sctp = (data_channel_type_ == cricket::DCT_SCTP); | 1843 bool sctp = (data_channel_type_ == cricket::DCT_SCTP); |
1824 data_channel_.reset(channel_manager_->CreateDataChannel( | 1844 data_channel_.reset(channel_manager_->CreateDataChannel( |
1825 transport_controller_.get(), content->name, !sctp, data_channel_type_)); | 1845 transport_controller_.get(), content->name, transport_name, |
1846 !sctp && | |
1847 rtcp_mux_policy_ != | |
1848 PeerConnectionInterface::kRtcpMuxPolicyRequire /* rtcp */, | |
1849 data_channel_type_)); | |
pthatcher1
2016/05/11 06:20:39
And here.
skvlad
2016/05/11 22:24:19
Done.
| |
1826 if (!data_channel_) { | 1850 if (!data_channel_) { |
1827 return false; | 1851 return false; |
1828 } | 1852 } |
1853 if (rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire) { | |
1854 data_channel_->ActivateRtcpMux(); | |
1855 } | |
1829 | 1856 |
1830 if (sctp) { | 1857 if (sctp) { |
1831 data_channel_->SignalDataReceived.connect( | 1858 data_channel_->SignalDataReceived.connect( |
1832 this, &WebRtcSession::OnDataChannelMessageReceived); | 1859 this, &WebRtcSession::OnDataChannelMessageReceived); |
1833 } | 1860 } |
1834 | 1861 |
1835 data_channel_->SignalDtlsSetupFailure.connect( | 1862 data_channel_->SignalDtlsSetupFailure.connect( |
1836 this, &WebRtcSession::OnDtlsSetupFailure); | 1863 this, &WebRtcSession::OnDtlsSetupFailure); |
1837 | 1864 |
1838 SignalDataChannelCreated(); | 1865 SignalDataChannelCreated(); |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2155 } | 2182 } |
2156 } | 2183 } |
2157 | 2184 |
2158 void WebRtcSession::OnSentPacket_w(cricket::TransportChannel* channel, | 2185 void WebRtcSession::OnSentPacket_w(cricket::TransportChannel* channel, |
2159 const rtc::SentPacket& sent_packet) { | 2186 const rtc::SentPacket& sent_packet) { |
2160 RTC_DCHECK(worker_thread()->IsCurrent()); | 2187 RTC_DCHECK(worker_thread()->IsCurrent()); |
2161 media_controller_->call_w()->OnSentPacket(sent_packet); | 2188 media_controller_->call_w()->OnSentPacket(sent_packet); |
2162 } | 2189 } |
2163 | 2190 |
2164 } // namespace webrtc | 2191 } // namespace webrtc |
OLD | NEW |