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

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

Issue 1785613011: Revert of Remove candidates when doing continual gathering (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 4 years, 9 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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 metrics_observer_(NULL) { 494 metrics_observer_(NULL) {
495 transport_controller_->SetIceRole(cricket::ICEROLE_CONTROLLED); 495 transport_controller_->SetIceRole(cricket::ICEROLE_CONTROLLED);
496 transport_controller_->SignalConnectionState.connect( 496 transport_controller_->SignalConnectionState.connect(
497 this, &WebRtcSession::OnTransportControllerConnectionState); 497 this, &WebRtcSession::OnTransportControllerConnectionState);
498 transport_controller_->SignalReceiving.connect( 498 transport_controller_->SignalReceiving.connect(
499 this, &WebRtcSession::OnTransportControllerReceiving); 499 this, &WebRtcSession::OnTransportControllerReceiving);
500 transport_controller_->SignalGatheringState.connect( 500 transport_controller_->SignalGatheringState.connect(
501 this, &WebRtcSession::OnTransportControllerGatheringState); 501 this, &WebRtcSession::OnTransportControllerGatheringState);
502 transport_controller_->SignalCandidatesGathered.connect( 502 transport_controller_->SignalCandidatesGathered.connect(
503 this, &WebRtcSession::OnTransportControllerCandidatesGathered); 503 this, &WebRtcSession::OnTransportControllerCandidatesGathered);
504 transport_controller_->SignalCandidatesRemoved.connect(
505 this, &WebRtcSession::OnTransportControllerCandidatesRemoved);
506 } 504 }
507 505
508 WebRtcSession::~WebRtcSession() { 506 WebRtcSession::~WebRtcSession() {
509 ASSERT(signaling_thread()->IsCurrent()); 507 ASSERT(signaling_thread()->IsCurrent());
510 // Destroy video_channel_ first since it may have a pointer to the 508 // Destroy video_channel_ first since it may have a pointer to the
511 // voice_channel_. 509 // voice_channel_.
512 if (video_channel_) { 510 if (video_channel_) {
513 SignalVideoChannelDestroyed(); 511 SignalVideoChannelDestroyed();
514 channel_manager_->DestroyVideoChannel(video_channel_.release()); 512 channel_manager_->DestroyVideoChannel(video_channel_.release());
515 } 513 }
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 return false; 1079 return false;
1082 } 1080 }
1083 1081
1084 return true; 1082 return true;
1085 } 1083 }
1086 1084
1087 bool WebRtcSession::ProcessIceMessage(const IceCandidateInterface* candidate) { 1085 bool WebRtcSession::ProcessIceMessage(const IceCandidateInterface* candidate) {
1088 if (!remote_desc_) { 1086 if (!remote_desc_) {
1089 LOG(LS_ERROR) << "ProcessIceMessage: ICE candidates can't be added " 1087 LOG(LS_ERROR) << "ProcessIceMessage: ICE candidates can't be added "
1090 << "without any remote session description."; 1088 << "without any remote session description.";
1091 return false; 1089 return false;
1092 } 1090 }
1093 1091
1094 if (!candidate) { 1092 if (!candidate) {
1095 LOG(LS_ERROR) << "ProcessIceMessage: Candidate is NULL."; 1093 LOG(LS_ERROR) << "ProcessIceMessage: Candidate is NULL.";
1096 return false; 1094 return false;
1097 } 1095 }
1098 1096
1099 bool valid = false; 1097 bool valid = false;
1100 bool ready = ReadyToUseRemoteCandidate(candidate, NULL, &valid); 1098 bool ready = ReadyToUseRemoteCandidate(candidate, NULL, &valid);
1101 if (!valid) { 1099 if (!valid) {
1102 return false; 1100 return false;
1103 } 1101 }
1104 1102
1105 // Add this candidate to the remote session description. 1103 // Add this candidate to the remote session description.
1106 if (!remote_desc_->AddCandidate(candidate)) { 1104 if (!remote_desc_->AddCandidate(candidate)) {
1107 LOG(LS_ERROR) << "ProcessIceMessage: Candidate cannot be used."; 1105 LOG(LS_ERROR) << "ProcessIceMessage: Candidate cannot be used.";
1108 return false; 1106 return false;
1109 } 1107 }
1110 1108
1111 if (ready) { 1109 if (ready) {
1112 return UseCandidate(candidate); 1110 return UseCandidate(candidate);
1113 } else { 1111 } else {
1114 LOG(LS_INFO) << "ProcessIceMessage: Not ready to use candidate."; 1112 LOG(LS_INFO) << "ProcessIceMessage: Not ready to use candidate.";
1115 return true; 1113 return true;
1116 } 1114 }
1117 } 1115 }
1118 1116
1119 bool WebRtcSession::RemoveRemoteIceCandidates(
1120 const std::vector<cricket::Candidate>& candidates) {
1121 if (!remote_desc_) {
1122 LOG(LS_ERROR) << "RemoveRemoteIceCandidates: ICE candidates can't be "
1123 << "removed without any remote session description.";
1124 return false;
1125 }
1126
1127 if (candidates.empty()) {
1128 LOG(LS_ERROR) << "RemoveRemoteIceCandidates: candidates are empty.";
1129 return false;
1130 }
1131
1132 size_t number_removed = remote_desc_->RemoveCandidates(candidates);
1133 if (number_removed != candidates.size()) {
1134 LOG(LS_ERROR) << "RemoveRemoteIceCandidates: Failed to remove candidates. "
1135 << "Requested " << candidates.size() << " but only "
1136 << number_removed << " are removed.";
1137 }
1138
1139 // Remove the candidates from the transport controller.
1140 std::string error;
1141 bool res = transport_controller_->RemoveRemoteCandidates(candidates, &error);
1142 if (!res && !error.empty()) {
1143 LOG(LS_ERROR) << "Error when removing remote candidates: " << error;
1144 }
1145 return true;
1146 }
1147
1148 bool WebRtcSession::SetIceTransports( 1117 bool WebRtcSession::SetIceTransports(
1149 PeerConnectionInterface::IceTransportsType type) { 1118 PeerConnectionInterface::IceTransportsType type) {
1150 return port_allocator()->set_candidate_filter( 1119 return port_allocator()->set_candidate_filter(
1151 ConvertIceTransportTypeToCandidateFilter(type)); 1120 ConvertIceTransportTypeToCandidateFilter(type));
1152 } 1121 }
1153 1122
1154 cricket::IceConfig WebRtcSession::ParseIceConfig( 1123 cricket::IceConfig WebRtcSession::ParseIceConfig(
1155 const PeerConnectionInterface::RTCConfiguration& config) const { 1124 const PeerConnectionInterface::RTCConfiguration& config) const {
1156 cricket::IceConfig ice_config; 1125 cricket::IceConfig ice_config;
1157 ice_config.receiving_timeout = config.ice_connection_receiving_timeout; 1126 ice_config.receiving_timeout = config.ice_connection_receiving_timeout;
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
1547 JsepIceCandidate candidate(transport_name, sdp_mline_index, *citer); 1516 JsepIceCandidate candidate(transport_name, sdp_mline_index, *citer);
1548 if (ice_observer_) { 1517 if (ice_observer_) {
1549 ice_observer_->OnIceCandidate(&candidate); 1518 ice_observer_->OnIceCandidate(&candidate);
1550 } 1519 }
1551 if (local_desc_) { 1520 if (local_desc_) {
1552 local_desc_->AddCandidate(&candidate); 1521 local_desc_->AddCandidate(&candidate);
1553 } 1522 }
1554 } 1523 }
1555 } 1524 }
1556 1525
1557 void WebRtcSession::OnTransportControllerCandidatesRemoved(
1558 const std::vector<cricket::Candidate>& candidates) {
1559 ASSERT(signaling_thread()->IsCurrent());
1560 // Sanity check.
1561 for (const cricket::Candidate& candidate : candidates) {
1562 if (candidate.transport_name().empty()) {
1563 LOG(LS_ERROR) << "OnTransportControllerCandidatesRemoved: "
1564 << "empty content name in candidate "
1565 << candidate.ToString();
1566 return;
1567 }
1568 }
1569
1570 if (local_desc_) {
1571 local_desc_->RemoveCandidates(candidates);
1572 }
1573 if (ice_observer_) {
1574 ice_observer_->OnIceCandidatesRemoved(candidates);
1575 }
1576 }
1577
1578 // Enabling voice and video channel. 1526 // Enabling voice and video channel.
1579 void WebRtcSession::EnableChannels() { 1527 void WebRtcSession::EnableChannels() {
1580 if (voice_channel_ && !voice_channel_->enabled()) 1528 if (voice_channel_ && !voice_channel_->enabled())
1581 voice_channel_->Enable(true); 1529 voice_channel_->Enable(true);
1582 1530
1583 if (video_channel_ && !video_channel_->enabled()) 1531 if (video_channel_ && !video_channel_->enabled())
1584 video_channel_->Enable(true); 1532 video_channel_->Enable(true);
1585 1533
1586 if (data_channel_ && !data_channel_->enabled()) 1534 if (data_channel_ && !data_channel_->enabled())
1587 data_channel_->Enable(true); 1535 data_channel_->Enable(true);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1627 } 1575 }
1628 ret = UseCandidate(candidate); 1576 ret = UseCandidate(candidate);
1629 if (!ret) { 1577 if (!ret) {
1630 break; 1578 break;
1631 } 1579 }
1632 } 1580 }
1633 } 1581 }
1634 return ret; 1582 return ret;
1635 } 1583 }
1636 1584
1637 bool WebRtcSession::UseCandidate(const IceCandidateInterface* candidate) { 1585 bool WebRtcSession::UseCandidate(
1586 const IceCandidateInterface* candidate) {
1587
1638 size_t mediacontent_index = static_cast<size_t>(candidate->sdp_mline_index()); 1588 size_t mediacontent_index = static_cast<size_t>(candidate->sdp_mline_index());
1639 size_t remote_content_size = remote_desc_->description()->contents().size(); 1589 size_t remote_content_size = remote_desc_->description()->contents().size();
1640 if (mediacontent_index >= remote_content_size) { 1590 if (mediacontent_index >= remote_content_size) {
1641 LOG(LS_ERROR) << "UseCandidate: Invalid candidate media index."; 1591 LOG(LS_ERROR)
1592 << "UseRemoteCandidateInSession: Invalid candidate media index.";
1642 return false; 1593 return false;
1643 } 1594 }
1644 1595
1645 cricket::ContentInfo content = 1596 cricket::ContentInfo content =
1646 remote_desc_->description()->contents()[mediacontent_index]; 1597 remote_desc_->description()->contents()[mediacontent_index];
1647 std::vector<cricket::Candidate> candidates; 1598 std::vector<cricket::Candidate> candidates;
1648 candidates.push_back(candidate->candidate()); 1599 candidates.push_back(candidate->candidate());
1649 // Invoking BaseSession method to handle remote candidates. 1600 // Invoking BaseSession method to handle remote candidates.
1650 std::string error; 1601 std::string error;
1651 if (transport_controller_->AddRemoteCandidates(content.name, candidates, 1602 if (transport_controller_->AddRemoteCandidates(content.name, candidates,
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1972 1923
1973 if (!current_remote_desc) { 1924 if (!current_remote_desc) {
1974 return false; 1925 return false;
1975 } 1926 }
1976 1927
1977 size_t mediacontent_index = 1928 size_t mediacontent_index =
1978 static_cast<size_t>(candidate->sdp_mline_index()); 1929 static_cast<size_t>(candidate->sdp_mline_index());
1979 size_t remote_content_size = 1930 size_t remote_content_size =
1980 current_remote_desc->description()->contents().size(); 1931 current_remote_desc->description()->contents().size();
1981 if (mediacontent_index >= remote_content_size) { 1932 if (mediacontent_index >= remote_content_size) {
1982 LOG(LS_ERROR) << "ReadyToUseRemoteCandidate: Invalid candidate media index " 1933 LOG(LS_ERROR)
1983 << mediacontent_index; 1934 << "ReadyToUseRemoteCandidate: Invalid candidate media index.";
1984 1935
1985 *valid = false; 1936 *valid = false;
1986 return false; 1937 return false;
1987 } 1938 }
1988 1939
1989 cricket::ContentInfo content = 1940 cricket::ContentInfo content =
1990 current_remote_desc->description()->contents()[mediacontent_index]; 1941 current_remote_desc->description()->contents()[mediacontent_index];
1991 cricket::BaseChannel* channel = GetChannel(content.name); 1942 cricket::BaseChannel* channel = GetChannel(content.name);
1992 if (!channel) { 1943 if (!channel) {
1993 return false; 1944 return false;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
2126 } 2077 }
2127 } 2078 }
2128 2079
2129 void WebRtcSession::OnSentPacket_w(cricket::TransportChannel* channel, 2080 void WebRtcSession::OnSentPacket_w(cricket::TransportChannel* channel,
2130 const rtc::SentPacket& sent_packet) { 2081 const rtc::SentPacket& sent_packet) {
2131 RTC_DCHECK(worker_thread()->IsCurrent()); 2082 RTC_DCHECK(worker_thread()->IsCurrent());
2132 media_controller_->call_w()->OnSentPacket(sent_packet); 2083 media_controller_->call_w()->OnSentPacket(sent_packet);
2133 } 2084 }
2134 2085
2135 } // namespace webrtc 2086 } // 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