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 |
11 #include "webrtc/api/webrtcsession.h" | 11 #include "webrtc/api/webrtcsession.h" |
12 | 12 |
13 #include <limits.h> | 13 #include <limits.h> |
14 | 14 |
15 #include <algorithm> | 15 #include <algorithm> |
16 #include <set> | 16 #include <set> |
17 #include <utility> | 17 #include <utility> |
18 #include <vector> | 18 #include <vector> |
19 | 19 |
20 #include "webrtc/api/jsepicecandidate.h" | 20 #include "webrtc/api/jsepicecandidate.h" |
21 #include "webrtc/api/jsepsessiondescription.h" | 21 #include "webrtc/api/jsepsessiondescription.h" |
22 #include "webrtc/api/peerconnectioninterface.h" | 22 #include "webrtc/api/peerconnectioninterface.h" |
23 #include "webrtc/api/sctputils.h" | 23 #include "webrtc/api/sctputils.h" |
24 #include "webrtc/api/webrtcsessiondescriptionfactory.h" | 24 #include "webrtc/api/webrtcsessiondescriptionfactory.h" |
25 #include "webrtc/audio_sink.h" | 25 #include "webrtc/audio_sink.h" |
26 #include "webrtc/base/basictypes.h" | 26 #include "webrtc/base/basictypes.h" |
27 #include "webrtc/base/bind.h" | |
27 #include "webrtc/base/checks.h" | 28 #include "webrtc/base/checks.h" |
28 #include "webrtc/base/helpers.h" | 29 #include "webrtc/base/helpers.h" |
29 #include "webrtc/base/logging.h" | 30 #include "webrtc/base/logging.h" |
30 #include "webrtc/base/stringencode.h" | 31 #include "webrtc/base/stringencode.h" |
31 #include "webrtc/base/stringutils.h" | 32 #include "webrtc/base/stringutils.h" |
32 #include "webrtc/call.h" | 33 #include "webrtc/call.h" |
33 #include "webrtc/media/base/mediaconstants.h" | 34 #include "webrtc/media/base/mediaconstants.h" |
34 #include "webrtc/media/base/videocapturer.h" | 35 #include "webrtc/media/base/videocapturer.h" |
35 #include "webrtc/p2p/base/portallocator.h" | 36 #include "webrtc/p2p/base/portallocator.h" |
36 #include "webrtc/p2p/base/transportchannel.h" | 37 #include "webrtc/p2p/base/transportchannel.h" |
(...skipping 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1728 cricket::GetFirstDataContent(desc); | 1729 cricket::GetFirstDataContent(desc); |
1729 if ((!data_info || data_info->rejected) && data_channel_) { | 1730 if ((!data_info || data_info->rejected) && data_channel_) { |
1730 SignalDataChannelDestroyed(); | 1731 SignalDataChannelDestroyed(); |
1731 channel_manager_->DestroyDataChannel(data_channel_.release()); | 1732 channel_manager_->DestroyDataChannel(data_channel_.release()); |
1732 } | 1733 } |
1733 } | 1734 } |
1734 | 1735 |
1735 // TODO(mallinath) - Add a correct error code if the channels are not created | 1736 // TODO(mallinath) - Add a correct error code if the channels are not created |
1736 // due to BUNDLE is enabled but rtcp-mux is disabled. | 1737 // due to BUNDLE is enabled but rtcp-mux is disabled. |
1737 bool WebRtcSession::CreateChannels(const SessionDescription* desc) { | 1738 bool WebRtcSession::CreateChannels(const SessionDescription* desc) { |
1739 // TODO(mikescarlett): Allow remote peer to negotiate whether to use QUIC | |
1740 // or DTLS, so that the connection doesn't fail when the remote peer won't use | |
1741 // QUIC. Current behavior is to assume either both peers or no peers use QUIC. | |
1742 if (desc->quic() && !transport_controller_->quic()) { | |
1743 transport_controller_->set_quic(true); | |
Taylor Brandstetter
2016/04/01 23:23:42
This should fail if a transport channel has alread
| |
1744 data_channel_type_ = cricket::DCT_QUIC; | |
1745 } | |
1738 // Creating the media channels and transport proxies. | 1746 // Creating the media channels and transport proxies. |
1739 const cricket::ContentInfo* voice = cricket::GetFirstAudioContent(desc); | 1747 const cricket::ContentInfo* voice = cricket::GetFirstAudioContent(desc); |
1740 if (voice && !voice->rejected && !voice_channel_) { | 1748 if (voice && !voice->rejected && !voice_channel_) { |
1741 if (!CreateVoiceChannel(voice)) { | 1749 if (!CreateVoiceChannel(voice)) { |
1742 LOG(LS_ERROR) << "Failed to create voice channel."; | 1750 LOG(LS_ERROR) << "Failed to create voice channel."; |
1743 return false; | 1751 return false; |
1744 } | 1752 } |
1745 } | 1753 } |
1746 | 1754 |
1747 const cricket::ContentInfo* video = cricket::GetFirstVideoContent(desc); | 1755 const cricket::ContentInfo* video = cricket::GetFirstVideoContent(desc); |
1748 if (video && !video->rejected && !video_channel_) { | 1756 if (video && !video->rejected && !video_channel_) { |
1749 if (!CreateVideoChannel(video)) { | 1757 if (!CreateVideoChannel(video)) { |
1750 LOG(LS_ERROR) << "Failed to create video channel."; | 1758 LOG(LS_ERROR) << "Failed to create video channel."; |
1751 return false; | 1759 return false; |
1752 } | 1760 } |
1753 } | 1761 } |
1754 | 1762 |
1755 const cricket::ContentInfo* data = cricket::GetFirstDataContent(desc); | 1763 const cricket::ContentInfo* data = cricket::GetFirstDataContent(desc); |
1756 if (data_channel_type_ != cricket::DCT_NONE && | 1764 if (data_channel_type_ != cricket::DCT_NONE && |
1757 data && !data->rejected && !data_channel_) { | 1765 data_channel_type_ != cricket::DCT_QUIC && data && !data->rejected && |
1766 !data_channel_) { | |
1758 if (!CreateDataChannel(data)) { | 1767 if (!CreateDataChannel(data)) { |
1759 LOG(LS_ERROR) << "Failed to create data channel."; | 1768 LOG(LS_ERROR) << "Failed to create data channel."; |
1760 return false; | 1769 return false; |
1761 } | 1770 } |
1762 } | 1771 } |
1763 | 1772 |
1764 if (rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire) { | 1773 if (rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire) { |
1765 if (voice_channel()) { | 1774 if (voice_channel()) { |
1766 voice_channel()->ActivateRtcpMux(); | 1775 voice_channel()->ActivateRtcpMux(); |
1767 } | 1776 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1818 video_channel_->SignalDtlsSetupFailure.connect( | 1827 video_channel_->SignalDtlsSetupFailure.connect( |
1819 this, &WebRtcSession::OnDtlsSetupFailure); | 1828 this, &WebRtcSession::OnDtlsSetupFailure); |
1820 | 1829 |
1821 SignalVideoChannelCreated(); | 1830 SignalVideoChannelCreated(); |
1822 video_channel_->transport_channel()->SignalSentPacket.connect( | 1831 video_channel_->transport_channel()->SignalSentPacket.connect( |
1823 this, &WebRtcSession::OnSentPacket_w); | 1832 this, &WebRtcSession::OnSentPacket_w); |
1824 return true; | 1833 return true; |
1825 } | 1834 } |
1826 | 1835 |
1827 bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content) { | 1836 bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content) { |
1837 if (data_channel_type_ == cricket::DCT_QUIC) { | |
1838 transport_controller_->CreateTransportChannel_w(content->name, 0); | |
1839 return true; | |
1840 } | |
1828 bool sctp = (data_channel_type_ == cricket::DCT_SCTP); | 1841 bool sctp = (data_channel_type_ == cricket::DCT_SCTP); |
1829 data_channel_.reset(channel_manager_->CreateDataChannel( | 1842 data_channel_.reset(channel_manager_->CreateDataChannel( |
1830 transport_controller_.get(), content->name, !sctp, data_channel_type_)); | 1843 transport_controller_.get(), content->name, !sctp, data_channel_type_)); |
1831 if (!data_channel_) { | 1844 if (!data_channel_) { |
1832 return false; | 1845 return false; |
1833 } | 1846 } |
1834 | 1847 |
1835 if (sctp) { | 1848 if (sctp) { |
1836 data_channel_->SignalDataReceived.connect( | 1849 data_channel_->SignalDataReceived.connect( |
1837 this, &WebRtcSession::OnDataChannelMessageReceived); | 1850 this, &WebRtcSession::OnDataChannelMessageReceived); |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2159 ssl_cipher_suite); | 2172 ssl_cipher_suite); |
2160 } | 2173 } |
2161 } | 2174 } |
2162 | 2175 |
2163 void WebRtcSession::OnSentPacket_w(cricket::TransportChannel* channel, | 2176 void WebRtcSession::OnSentPacket_w(cricket::TransportChannel* channel, |
2164 const rtc::SentPacket& sent_packet) { | 2177 const rtc::SentPacket& sent_packet) { |
2165 RTC_DCHECK(worker_thread()->IsCurrent()); | 2178 RTC_DCHECK(worker_thread()->IsCurrent()); |
2166 media_controller_->call_w()->OnSentPacket(sent_packet); | 2179 media_controller_->call_w()->OnSentPacket(sent_packet); |
2167 } | 2180 } |
2168 | 2181 |
2182 cricket::QuicTransportChannel* WebRtcSession::quic_transport_channel() const { | |
2183 return transport_controller_->quic_transport_channel(); | |
2184 } | |
pthatcher1
2016/03/30 20:34:49
And does this need the ifdef as well?
| |
2185 | |
2169 } // namespace webrtc | 2186 } // namespace webrtc |
OLD | NEW |