From 54b8407ee59360b1744a8db5958437e7ca566d9d Mon Sep 17 00:00:00 2001 From: Steve Anton Date: Tue, 20 Feb 2018 15:19:52 -0800 Subject: [PATCH] Clear current_direction when the RtpTransceiver is stopped This is specified in the WebRTC specification: https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-currentdirection Bug: webrtc:7600 Change-Id: I4c3d434528f8c2aecad9d86dce38f13cf4fee560 Reviewed-on: https://webrtc-review.googlesource.com/55900 Reviewed-by: Seth Hampson Commit-Queue: Steve Anton Cr-Commit-Position: refs/heads/master@{#22112} --- pc/peerconnection_jsep_unittest.cc | 15 +++++++++++++++ pc/rtptransceiver.cc | 1 + 2 files changed, 16 insertions(+) diff --git a/pc/peerconnection_jsep_unittest.cc b/pc/peerconnection_jsep_unittest.cc index ac17df28c2..f77579bc51 100644 --- a/pc/peerconnection_jsep_unittest.cc +++ b/pc/peerconnection_jsep_unittest.cc @@ -1228,4 +1228,19 @@ TEST_F(PeerConnectionJsepTest, // TODO(bugs.webrtc.org/7932): Also test multi-stream case. +// Test that if an RtpTransceiver with a current_direction set is stopped, then +// current_direction is changed to null. +TEST_F(PeerConnectionJsepTest, CurrentDirectionResetWhenRtpTransceiverStopped) { + auto caller = CreatePeerConnection(); + auto callee = CreatePeerConnection(); + + auto transceiver = caller->AddTransceiver(cricket::MEDIA_TYPE_AUDIO); + + ASSERT_TRUE(caller->ExchangeOfferAnswerWith(callee.get())); + + ASSERT_TRUE(transceiver->current_direction()); + transceiver->Stop(); + EXPECT_FALSE(transceiver->current_direction()); +} + } // namespace webrtc diff --git a/pc/rtptransceiver.cc b/pc/rtptransceiver.cc index 1f1a850c9f..d4a67883c3 100644 --- a/pc/rtptransceiver.cc +++ b/pc/rtptransceiver.cc @@ -207,6 +207,7 @@ void RtpTransceiver::Stop() { receiver->internal()->Stop(); } stopped_ = true; + current_direction_ = rtc::nullopt; } void RtpTransceiver::SetCodecPreferences(