From f764cf4677ae9e6868143ed322d9d5faa3b0716e Mon Sep 17 00:00:00 2001 From: Steve Anton Date: Tue, 1 May 2018 14:32:17 -0700 Subject: [PATCH] Don't transition ICE to Checking if there are no transports This attempts to make it more clear that an offer or answer with no transports will no start ICE. Bug: None Change-Id: Ifb8d9e445b8fbef1fb1590477dd6bdb4fc651a90 Reviewed-on: https://webrtc-review.googlesource.com/73640 Reviewed-by: Taylor Brandstetter Commit-Queue: Steve Anton Cr-Commit-Position: refs/heads/master@{#23070} --- pc/peerconnection.cc | 1 + pc/peerconnection_ice_unittest.cc | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/pc/peerconnection.cc b/pc/peerconnection.cc index b7fe2e3ad3..572816c218 100644 --- a/pc/peerconnection.cc +++ b/pc/peerconnection.cc @@ -2348,6 +2348,7 @@ RTCError PeerConnection::ApplyRemoteDescription( // read to determine the current checking state. The existing SignalConnecting // actually means "gathering candidates", so cannot be be used here. if (remote_description()->GetType() != SdpType::kOffer && + remote_description()->number_of_mediasections() > 0u && ice_connection_state() == PeerConnectionInterface::kIceConnectionNew) { SetIceConnectionState(PeerConnectionInterface::kIceConnectionChecking); } diff --git a/pc/peerconnection_ice_unittest.cc b/pc/peerconnection_ice_unittest.cc index 3911a58646..1f8213ec29 100644 --- a/pc/peerconnection_ice_unittest.cc +++ b/pc/peerconnection_ice_unittest.cc @@ -351,6 +351,21 @@ TEST_P(PeerConnectionIceTest, SetRemoteDescriptionFailsIfNoIceCredentials) { EXPECT_FALSE(callee->SetRemoteDescription(std::move(offer))); } +// Test that doing an offer/answer exchange with no transport (i.e., no data +// channel or media) results in the ICE connection state staying at New. +TEST_P(PeerConnectionIceTest, + OfferAnswerWithNoTransportsDoesNotChangeIceConnectionState) { + auto caller = CreatePeerConnection(); + auto callee = CreatePeerConnection(); + + ASSERT_TRUE(caller->ExchangeOfferAnswerWith(callee.get())); + + EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, + caller->pc()->ice_connection_state()); + EXPECT_EQ(PeerConnectionInterface::kIceConnectionNew, + callee->pc()->ice_connection_state()); +} + // The following group tests that ICE candidates are not generated before // SetLocalDescription is called on a PeerConnection.