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.