Chromium Code Reviews| Index: webrtc/api/webrtcsession.cc |
| diff --git a/webrtc/api/webrtcsession.cc b/webrtc/api/webrtcsession.cc |
| index 8c83dbbc62a414cd304c44409c9630d4e08887f4..cd8b9b2f2d20086943bdc874aefdd06530e54e70 100644 |
| --- a/webrtc/api/webrtcsession.cc |
| +++ b/webrtc/api/webrtcsession.cc |
| @@ -24,6 +24,7 @@ |
| #include "webrtc/api/webrtcsessiondescriptionfactory.h" |
| #include "webrtc/audio_sink.h" |
| #include "webrtc/base/basictypes.h" |
| +#include "webrtc/base/bind.h" |
| #include "webrtc/base/checks.h" |
| #include "webrtc/base/helpers.h" |
| #include "webrtc/base/logging.h" |
| @@ -38,6 +39,10 @@ |
| #include "webrtc/pc/channelmanager.h" |
| #include "webrtc/pc/mediasession.h" |
| +#ifdef HAVE_QUIC |
| +#include "webrtc/p2p/quic/quictransportchannel.h" |
| +#endif // HAVE_QUIC |
| + |
| using cricket::ContentInfo; |
| using cricket::ContentInfos; |
| using cricket::MediaContentDescription; |
| @@ -458,7 +463,8 @@ WebRtcSession::WebRtcSession(webrtc::MediaControllerInterface* media_controller, |
| rtc::Thread* worker_thread, |
| rtc::Thread* signaling_thread, |
| cricket::PortAllocator* port_allocator) |
| - : worker_thread_(worker_thread), |
| + : network_thread_(network_thread), |
| + worker_thread_(worker_thread), |
| signaling_thread_(signaling_thread), |
| // RFC 3264: The numeric value of the session id and version in the |
| // o line MUST be representable with a "64 bit signed integer". |
| @@ -505,6 +511,11 @@ WebRtcSession::~WebRtcSession() { |
| SignalDataChannelDestroyed(); |
| channel_manager_->DestroyDataChannel(data_channel_.release()); |
| } |
| +#ifdef HAVE_QUIC |
| + if (quic_data_transport_) { |
| + quic_data_transport_.reset(); |
| + } |
| +#endif |
| SignalDestroyed(); |
| LOG(LS_INFO) << "Session: " << id() << " is destroyed."; |
| @@ -545,7 +556,21 @@ bool WebRtcSession::Initialize( |
| // PeerConnectionFactoryInterface::Options. |
| if (rtc_configuration.enable_rtp_data_channel) { |
| data_channel_type_ = cricket::DCT_RTP; |
| - } else { |
| + } |
| +#ifdef HAVE_QUIC |
| + else if (rtc_configuration.enable_quic) { |
| + // Use QUIC instead of DTLS when |enable_quic| is true. |
| + data_channel_type_ = cricket::DCT_QUIC; |
| + transport_controller_->use_quic(); |
| + if (dtls_enabled_) { |
| + LOG(LS_INFO) << "Using QUIC instead of DTLS"; |
| + } |
| + quic_data_transport_.reset( |
| + new QuicDataTransport(signaling_thread(), worker_thread(), |
| + network_thread(), transport_controller_.get())); |
| + } |
| +#endif // HAVE_QUIC |
| + else { |
| // DTLS has to be enabled to use SCTP. |
| if (!options.disable_sctp_data_channels && dtls_enabled_) { |
| data_channel_type_ = cricket::DCT_SCTP; |
| @@ -1035,6 +1060,15 @@ bool WebRtcSession::EnableBundle(const cricket::ContentGroup& bundle) { |
| const std::string& transport_name = *first_content_name; |
| cricket::BaseChannel* first_channel = GetChannel(transport_name); |
| +#ifdef HAVE_QUIC |
| + if (quic_data_transport_ && |
| + bundle.HasContentName(quic_data_transport_->content_name()) && |
| + quic_data_transport_->transport_name() != transport_name) { |
| + LOG(LS_ERROR) << "Unable to BUNDLE " << quic_data_transport_->content_name() |
| + << " on " << transport_name << "with QUIC."; |
| + } |
| +#endif |
| + |
|
Zhi Huang
2016/07/25 23:40:36
If we do not support changing the underneath trans
|
| auto maybe_set_transport = [this, bundle, transport_name, |
| first_channel](cricket::BaseChannel* ch) { |
| if (!ch || !bundle.HasContentName(ch->content_name())) { |
| @@ -1543,9 +1577,17 @@ void WebRtcSession::RemoveUnusedChannels(const SessionDescription* desc) { |
| const cricket::ContentInfo* data_info = |
| cricket::GetFirstDataContent(desc); |
| - if ((!data_info || data_info->rejected) && data_channel_) { |
| - SignalDataChannelDestroyed(); |
| - channel_manager_->DestroyDataChannel(data_channel_.release()); |
| + if (!data_info || data_info->rejected) { |
| + if (data_channel_) { |
| + SignalDataChannelDestroyed(); |
| + channel_manager_->DestroyDataChannel(data_channel_.release()); |
| + } |
| +#ifdef HAVE_QUIC |
| + // Clean up the existing QuicDataTransport and its QuicTransportChannels. |
| + if (quic_data_transport_) { |
| + quic_data_transport_.reset(); |
| + } |
| +#endif |
| } |
| } |
| @@ -1659,6 +1701,16 @@ bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content, |
| bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content, |
| const std::string* bundle_transport) { |
| +#ifdef HAVE_QUIC |
| + if (data_channel_type_ == cricket::DCT_QUIC) { |
| + RTC_DCHECK(transport_controller_->quic()); |
| + const std::string transport_name = |
| + bundle_transport ? *bundle_transport : content->name; |
| + quic_data_transport_->SetTransport(transport_name); |
|
Zhi Huang
2016/07/25 23:40:36
Is it better to make it
"quic_data_transport_->Se
pthatcher1
2016/07/27 23:21:49
Why don't we do this:
quic_data_transport_.reset(
Zhi Huang
2016/08/01 05:12:28
The original design is that the quic_data_transpor
|
| + quic_data_transport_->set_content_name(content->name); |
| + return true; |
| + } |
| +#endif // HAVE_QUIC |
| bool sctp = (data_channel_type_ == cricket::DCT_SCTP); |
| bool require_rtcp_mux = |
| rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire; |
| @@ -1842,7 +1894,7 @@ bool WebRtcSession::ReadyToUseRemoteCandidate( |
| const IceCandidateInterface* candidate, |
| const SessionDescriptionInterface* remote_desc, |
| bool* valid) { |
| - *valid = true;; |
| + *valid = true; |
| const SessionDescriptionInterface* current_remote_desc = |
| remote_desc ? remote_desc : remote_desc_.get(); |
| @@ -1865,13 +1917,12 @@ bool WebRtcSession::ReadyToUseRemoteCandidate( |
| cricket::ContentInfo content = |
| current_remote_desc->description()->contents()[mediacontent_index]; |
| - cricket::BaseChannel* channel = GetChannel(content.name); |
| - if (!channel) { |
| + |
| + const std::string transport_name = GetTransportName(content.name); |
| + if (transport_name.empty()) { |
| return false; |
| } |
| - |
| - return transport_controller_->ReadyForRemoteCandidates( |
| - channel->transport_name()); |
| + return transport_controller_->ReadyForRemoteCandidates(transport_name); |
| } |
| void WebRtcSession::OnTransportControllerGatheringState( |
| @@ -2008,4 +2059,19 @@ void WebRtcSession::OnSentPacket_w(const rtc::SentPacket& sent_packet) { |
| media_controller_->call_w()->OnSentPacket(sent_packet); |
| } |
| +const std::string WebRtcSession::GetTransportName( |
| + const std::string& content_name) { |
| + cricket::BaseChannel* channel = GetChannel(content_name); |
| + if (!channel) { |
| +#ifdef HAVE_QUIC |
| + if (data_channel_type_ == cricket::DCT_QUIC && quic_data_transport_ && |
| + content_name == quic_data_transport_->transport_name()) { |
| + return quic_data_transport_->transport_name(); |
| + } |
| +#endif |
| + // Return an empty string if failed to retrieve the transport name. |
| + return ""; |
| + } |
| + return channel->transport_name(); |
| +} |
| } // namespace webrtc |