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

Unified Diff: webrtc/api/webrtcsession.cc

Issue 1788703003: Reland the CL to 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/api/webrtcsession.h ('k') | webrtc/api/webrtcsession_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/webrtcsession.cc
diff --git a/webrtc/api/webrtcsession.cc b/webrtc/api/webrtcsession.cc
index 9ed5640c509fb1d6d0808719c9db43455c52f7bf..3d9b6fbc89ede844416fd3d85558a1a19b01eca2 100644
--- a/webrtc/api/webrtcsession.cc
+++ b/webrtc/api/webrtcsession.cc
@@ -501,6 +501,8 @@ WebRtcSession::WebRtcSession(webrtc::MediaControllerInterface* media_controller,
this, &WebRtcSession::OnTransportControllerGatheringState);
transport_controller_->SignalCandidatesGathered.connect(
this, &WebRtcSession::OnTransportControllerCandidatesGathered);
+ transport_controller_->SignalCandidatesRemoved.connect(
+ this, &WebRtcSession::OnTransportControllerCandidatesRemoved);
}
WebRtcSession::~WebRtcSession() {
@@ -1086,7 +1088,7 @@ bool WebRtcSession::ProcessIceMessage(const IceCandidateInterface* candidate) {
if (!remote_desc_) {
LOG(LS_ERROR) << "ProcessIceMessage: ICE candidates can't be added "
<< "without any remote session description.";
- return false;
+ return false;
}
if (!candidate) {
@@ -1114,6 +1116,35 @@ bool WebRtcSession::ProcessIceMessage(const IceCandidateInterface* candidate) {
}
}
+bool WebRtcSession::RemoveRemoteIceCandidates(
+ const std::vector<cricket::Candidate>& candidates) {
+ if (!remote_desc_) {
+ LOG(LS_ERROR) << "RemoveRemoteIceCandidates: ICE candidates can't be "
+ << "removed without any remote session description.";
+ return false;
+ }
+
+ if (candidates.empty()) {
+ LOG(LS_ERROR) << "RemoveRemoteIceCandidates: candidates are empty.";
+ return false;
+ }
+
+ size_t number_removed = remote_desc_->RemoveCandidates(candidates);
+ if (number_removed != candidates.size()) {
+ LOG(LS_ERROR) << "RemoveRemoteIceCandidates: Failed to remove candidates. "
+ << "Requested " << candidates.size() << " but only "
+ << number_removed << " are removed.";
+ }
+
+ // Remove the candidates from the transport controller.
+ std::string error;
+ bool res = transport_controller_->RemoveRemoteCandidates(candidates, &error);
+ if (!res && !error.empty()) {
+ LOG(LS_ERROR) << "Error when removing remote candidates: " << error;
+ }
+ return true;
+}
+
bool WebRtcSession::SetIceTransports(
PeerConnectionInterface::IceTransportsType type) {
return port_allocator()->set_candidate_filter(
@@ -1523,6 +1554,27 @@ void WebRtcSession::OnTransportControllerCandidatesGathered(
}
}
+void WebRtcSession::OnTransportControllerCandidatesRemoved(
+ const std::vector<cricket::Candidate>& candidates) {
+ ASSERT(signaling_thread()->IsCurrent());
+ // Sanity check.
+ for (const cricket::Candidate& candidate : candidates) {
+ if (candidate.transport_name().empty()) {
+ LOG(LS_ERROR) << "OnTransportControllerCandidatesRemoved: "
+ << "empty content name in candidate "
+ << candidate.ToString();
+ return;
+ }
+ }
+
+ if (local_desc_) {
+ local_desc_->RemoveCandidates(candidates);
+ }
+ if (ice_observer_) {
+ ice_observer_->OnIceCandidatesRemoved(candidates);
+ }
+}
+
// Enabling voice and video channel.
void WebRtcSession::EnableChannels() {
if (voice_channel_ && !voice_channel_->enabled())
@@ -1582,14 +1634,11 @@ bool WebRtcSession::UseCandidatesInSessionDescription(
return ret;
}
-bool WebRtcSession::UseCandidate(
- const IceCandidateInterface* candidate) {
-
+bool WebRtcSession::UseCandidate(const IceCandidateInterface* candidate) {
size_t mediacontent_index = static_cast<size_t>(candidate->sdp_mline_index());
size_t remote_content_size = remote_desc_->description()->contents().size();
if (mediacontent_index >= remote_content_size) {
- LOG(LS_ERROR)
- << "UseRemoteCandidateInSession: Invalid candidate media index.";
+ LOG(LS_ERROR) << "UseCandidate: Invalid candidate media index.";
return false;
}
@@ -1930,8 +1979,8 @@ bool WebRtcSession::ReadyToUseRemoteCandidate(
size_t remote_content_size =
current_remote_desc->description()->contents().size();
if (mediacontent_index >= remote_content_size) {
- LOG(LS_ERROR)
- << "ReadyToUseRemoteCandidate: Invalid candidate media index.";
+ LOG(LS_ERROR) << "ReadyToUseRemoteCandidate: Invalid candidate media index "
+ << mediacontent_index;
*valid = false;
return false;
« 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