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 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1032 return transport_controller_->GetRemoteSSLCertificate(transport_name); | 1032 return transport_controller_->GetRemoteSSLCertificate(transport_name); |
1033 } | 1033 } |
1034 | 1034 |
1035 bool WebRtcSession::EnableBundle(const cricket::ContentGroup& bundle) { | 1035 bool WebRtcSession::EnableBundle(const cricket::ContentGroup& bundle) { |
1036 const std::string* first_content_name = bundle.FirstContentName(); | 1036 const std::string* first_content_name = bundle.FirstContentName(); |
1037 if (!first_content_name) { | 1037 if (!first_content_name) { |
1038 LOG(LS_WARNING) << "Tried to BUNDLE with no contents."; | 1038 LOG(LS_WARNING) << "Tried to BUNDLE with no contents."; |
1039 return false; | 1039 return false; |
1040 } | 1040 } |
1041 const std::string& transport_name = *first_content_name; | 1041 const std::string& transport_name = *first_content_name; |
1042 cricket::BaseChannel* first_channel = GetChannel(transport_name); | |
1043 | 1042 |
1044 #ifdef HAVE_QUIC | 1043 #ifdef HAVE_QUIC |
1045 if (quic_data_transport_ && | 1044 if (quic_data_transport_ && |
1046 bundle.HasContentName(quic_data_transport_->content_name()) && | 1045 bundle.HasContentName(quic_data_transport_->content_name()) && |
1047 quic_data_transport_->transport_name() != transport_name) { | 1046 quic_data_transport_->transport_name() != transport_name) { |
1048 LOG(LS_ERROR) << "Unable to BUNDLE " << quic_data_transport_->content_name() | 1047 LOG(LS_ERROR) << "Unable to BUNDLE " << quic_data_transport_->content_name() |
1049 << " on " << transport_name << "with QUIC."; | 1048 << " on " << transport_name << "with QUIC."; |
1050 } | 1049 } |
1051 #endif | 1050 #endif |
1052 | 1051 |
1053 auto maybe_set_transport = [this, bundle, transport_name, | 1052 auto maybe_set_transport = [this, bundle, |
1054 first_channel](cricket::BaseChannel* ch) { | 1053 transport_name](cricket::BaseChannel* ch) { |
1055 if (!ch || !bundle.HasContentName(ch->content_name())) { | 1054 if (!ch || !bundle.HasContentName(ch->content_name())) { |
1056 return true; | 1055 return true; |
1057 } | 1056 } |
1058 | 1057 |
1059 if (ch->transport_name() == transport_name) { | 1058 if (ch->transport_name() == transport_name) { |
1060 LOG(LS_INFO) << "BUNDLE already enabled for " << ch->content_name() | 1059 LOG(LS_INFO) << "BUNDLE already enabled for " << ch->content_name() |
1061 << " on " << transport_name << "."; | 1060 << " on " << transport_name << "."; |
1062 return true; | 1061 return true; |
1063 } | 1062 } |
1064 | 1063 |
1065 if (!ch->SetTransport(transport_name)) { | 1064 cricket::TransportChannel* rtp_transport = |
1065 transport_controller_->CreateTransportChannel( | |
1066 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTP); | |
1067 cricket::TransportChannel* rtcp_transport = nullptr; | |
1068 if (ch->ShouldCreateRtcpTransport()) { | |
1069 rtcp_transport = transport_controller_->CreateTransportChannel( | |
1070 transport_name, cricket::ICE_CANDIDATE_COMPONENT_RTCP); | |
1071 } | |
1072 if (!ch->SetTransport(rtp_transport, rtcp_transport)) { | |
Taylor Brandstetter
2017/01/09 22:50:42
I think there's an opportunity here to reduce some
| |
1066 LOG(LS_WARNING) << "Failed to enable BUNDLE for " << ch->content_name(); | 1073 LOG(LS_WARNING) << "Failed to enable BUNDLE for " << ch->content_name(); |
1067 return false; | 1074 return false; |
1068 } | 1075 } |
1069 LOG(LS_INFO) << "Enabled BUNDLE for " << ch->content_name() << " on " | 1076 LOG(LS_INFO) << "Enabled BUNDLE for " << ch->content_name() << " on " |
1070 << transport_name << "."; | 1077 << transport_name << "."; |
1071 return true; | 1078 return true; |
1072 }; | 1079 }; |
1073 | 1080 |
1074 if (!maybe_set_transport(voice_channel()) || | 1081 if (!maybe_set_transport(voice_channel()) || |
1075 !maybe_set_transport(video_channel()) || | 1082 !maybe_set_transport(video_channel()) || |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1663 if (require_rtcp_mux) { | 1670 if (require_rtcp_mux) { |
1664 voice_channel_->ActivateRtcpMux(); | 1671 voice_channel_->ActivateRtcpMux(); |
1665 } | 1672 } |
1666 | 1673 |
1667 voice_channel_->SignalDtlsSetupFailure.connect( | 1674 voice_channel_->SignalDtlsSetupFailure.connect( |
1668 this, &WebRtcSession::OnDtlsSetupFailure); | 1675 this, &WebRtcSession::OnDtlsSetupFailure); |
1669 | 1676 |
1670 SignalVoiceChannelCreated(); | 1677 SignalVoiceChannelCreated(); |
1671 voice_channel_->SignalSentPacket.connect(this, | 1678 voice_channel_->SignalSentPacket.connect(this, |
1672 &WebRtcSession::OnSentPacket_w); | 1679 &WebRtcSession::OnSentPacket_w); |
1680 voice_channel_->SignalDestroyTransport.connect( | |
1681 this, &WebRtcSession::OnDestroyTransport); | |
Taylor Brandstetter
2017/01/09 22:50:42
It would be nice if the creation *and* destruction
Zhi Huang
2017/01/12 03:47:46
Done.
| |
1673 return true; | 1682 return true; |
1674 } | 1683 } |
1675 | 1684 |
1676 bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content, | 1685 bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content, |
1677 const std::string* bundle_transport) { | 1686 const std::string* bundle_transport) { |
1678 bool require_rtcp_mux = | 1687 bool require_rtcp_mux = |
1679 rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire; | 1688 rtcp_mux_policy_ == PeerConnectionInterface::kRtcpMuxPolicyRequire; |
1680 bool create_rtcp_transport_channel = !require_rtcp_mux; | 1689 bool create_rtcp_transport_channel = !require_rtcp_mux; |
1681 video_channel_.reset(channel_manager_->CreateVideoChannel( | 1690 video_channel_.reset(channel_manager_->CreateVideoChannel( |
1682 media_controller_, transport_controller_.get(), content->name, | 1691 media_controller_, transport_controller_.get(), content->name, |
1683 bundle_transport, create_rtcp_transport_channel, SrtpRequired(), | 1692 bundle_transport, create_rtcp_transport_channel, SrtpRequired(), |
1684 video_options_)); | 1693 video_options_)); |
1685 if (!video_channel_) { | 1694 if (!video_channel_) { |
1686 return false; | 1695 return false; |
1687 } | 1696 } |
1688 if (require_rtcp_mux) { | 1697 if (require_rtcp_mux) { |
1689 video_channel_->ActivateRtcpMux(); | 1698 video_channel_->ActivateRtcpMux(); |
1690 } | 1699 } |
1691 video_channel_->SignalDtlsSetupFailure.connect( | 1700 video_channel_->SignalDtlsSetupFailure.connect( |
1692 this, &WebRtcSession::OnDtlsSetupFailure); | 1701 this, &WebRtcSession::OnDtlsSetupFailure); |
1693 | 1702 |
1694 SignalVideoChannelCreated(); | 1703 SignalVideoChannelCreated(); |
1695 video_channel_->SignalSentPacket.connect(this, | 1704 video_channel_->SignalSentPacket.connect(this, |
1696 &WebRtcSession::OnSentPacket_w); | 1705 &WebRtcSession::OnSentPacket_w); |
1706 video_channel_->SignalDestroyTransport.connect( | |
1707 this, &WebRtcSession::OnDestroyTransport); | |
1697 return true; | 1708 return true; |
1698 } | 1709 } |
1699 | 1710 |
1700 bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content, | 1711 bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content, |
1701 const std::string* bundle_transport) { | 1712 const std::string* bundle_transport) { |
1702 #ifdef HAVE_QUIC | 1713 #ifdef HAVE_QUIC |
1703 if (data_channel_type_ == cricket::DCT_QUIC) { | 1714 if (data_channel_type_ == cricket::DCT_QUIC) { |
1704 RTC_DCHECK(transport_controller_->quic()); | 1715 RTC_DCHECK(transport_controller_->quic()); |
1705 const std::string transport_name = | 1716 const std::string transport_name = |
1706 bundle_transport ? *bundle_transport : content->name; | 1717 bundle_transport ? *bundle_transport : content->name; |
(...skipping 19 matching lines...) Expand all Loading... | |
1726 if (sctp) { | 1737 if (sctp) { |
1727 data_channel_->SignalDataReceived.connect( | 1738 data_channel_->SignalDataReceived.connect( |
1728 this, &WebRtcSession::OnDataChannelMessageReceived); | 1739 this, &WebRtcSession::OnDataChannelMessageReceived); |
1729 } | 1740 } |
1730 | 1741 |
1731 data_channel_->SignalDtlsSetupFailure.connect( | 1742 data_channel_->SignalDtlsSetupFailure.connect( |
1732 this, &WebRtcSession::OnDtlsSetupFailure); | 1743 this, &WebRtcSession::OnDtlsSetupFailure); |
1733 | 1744 |
1734 SignalDataChannelCreated(); | 1745 SignalDataChannelCreated(); |
1735 data_channel_->SignalSentPacket.connect(this, &WebRtcSession::OnSentPacket_w); | 1746 data_channel_->SignalSentPacket.connect(this, &WebRtcSession::OnSentPacket_w); |
1747 data_channel_->SignalDestroyTransport.connect( | |
1748 this, &WebRtcSession::OnDestroyTransport); | |
1736 return true; | 1749 return true; |
1737 } | 1750 } |
1738 | 1751 |
1739 std::unique_ptr<SessionStats> WebRtcSession::GetStats_n( | 1752 std::unique_ptr<SessionStats> WebRtcSession::GetStats_n( |
1740 const ChannelNamePairs& channel_name_pairs) { | 1753 const ChannelNamePairs& channel_name_pairs) { |
1741 ASSERT(network_thread()->IsCurrent()); | 1754 ASSERT(network_thread()->IsCurrent()); |
1742 std::unique_ptr<SessionStats> session_stats(new SessionStats()); | 1755 std::unique_ptr<SessionStats> session_stats(new SessionStats()); |
1743 for (const auto channel_name_pair : { &channel_name_pairs.voice, | 1756 for (const auto channel_name_pair : { &channel_name_pairs.voice, |
1744 &channel_name_pairs.video, | 1757 &channel_name_pairs.video, |
1745 &channel_name_pairs.data }) { | 1758 &channel_name_pairs.data }) { |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2100 return channel->transport_name(); | 2113 return channel->transport_name(); |
2101 } | 2114 } |
2102 | 2115 |
2103 void WebRtcSession::OnDtlsHandshakeError(rtc::SSLHandshakeError error) { | 2116 void WebRtcSession::OnDtlsHandshakeError(rtc::SSLHandshakeError error) { |
2104 if (metrics_observer_) { | 2117 if (metrics_observer_) { |
2105 metrics_observer_->IncrementEnumCounter( | 2118 metrics_observer_->IncrementEnumCounter( |
2106 webrtc::kEnumCounterDtlsHandshakeError, static_cast<int>(error), | 2119 webrtc::kEnumCounterDtlsHandshakeError, static_cast<int>(error), |
2107 static_cast<int>(rtc::SSLHandshakeError::MAX_VALUE)); | 2120 static_cast<int>(rtc::SSLHandshakeError::MAX_VALUE)); |
2108 } | 2121 } |
2109 } | 2122 } |
2123 | |
2124 void WebRtcSession::OnDestroyTransport(const std::string& transport_name, | |
2125 int component) { | |
2126 transport_controller_->DestroyTransportChannel(transport_name, component); | |
2127 } | |
2110 } // namespace webrtc | 2128 } // namespace webrtc |
OLD | NEW |