Bug 1136252 - Part 5: Fix bug where candidates could be trickled before setRemote during renegotiation. r=mt
authorByron Campen [:bwc] <docfaraday@gmail.com>
Fri, 06 Mar 2015 15:16:38 -0800
changeset 233554 856f851dcb5d21591eb242c218ae8cddc178d1a7
parent 233553 6519a9e7d3d8c14b1fe173859fae4615ed6648f6
child 233555 8878cee7f4fc96a13bcab63b6972e5a16bd69f75
push id28417
push userryanvm@gmail.com
push dateFri, 13 Mar 2015 19:52:44 +0000
treeherdermozilla-central@977add19414a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmt
bugs1136252
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1136252 - Part 5: Fix bug where candidates could be trickled before setRemote during renegotiation. r=mt
media/webrtc/signaling/test/signaling_unittests.cpp
--- a/media/webrtc/signaling/test/signaling_unittests.cpp
+++ b/media/webrtc/signaling/test/signaling_unittests.cpp
@@ -904,17 +904,18 @@ class SignalingAgent {
     const std::string stun_addr = g_stun_server_address,
     uint16_t stun_port = g_stun_server_port) :
     pc(nullptr),
     name(aName),
     mBundleEnabled(true),
     mExpectedFrameRequestType(VideoSessionConduit::FrameRequestPli),
     mExpectNack(true),
     mExpectRtcpMuxAudio(true),
-    mExpectRtcpMuxVideo(true) {
+    mExpectRtcpMuxVideo(true),
+    mRemoteDescriptionSet(false) {
     cfg_.addStunServer(stun_addr, stun_port);
 
     PeerConnectionImpl *pcImpl =
       PeerConnectionImpl::CreatePeerConnection();
     EXPECT_TRUE(pcImpl);
     pcImpl->SetAllowIceLoopback(true);
     pc = new PCDispatchWrapper(pcImpl);
   }
@@ -1362,16 +1363,17 @@ class SignalingAgent {
 
     pObserver->state = TestObserver::stateNoResponse;
     ASSERT_EQ(pc->SetRemoteDescription(action, remote.c_str()), NS_OK);
     ASSERT_EQ(signaling_state(), endState);
     if (!ignoreError) {
       ASSERT_EQ(pObserver->state, TestObserver::stateSuccess);
     }
 
+    mRemoteDescriptionSet = true;
     for (auto i = deferredCandidates_.begin();
          i != deferredCandidates_.end();
          ++i) {
       AddIceCandidate(i->candidate.c_str(),
                       i->mid.c_str(),
                       i->level,
                       i->expectSuccess);
     }
@@ -1403,17 +1405,17 @@ class SignalingAgent {
   } TrickleEncoding;
 
   bool IceCompleted() {
     return pc->IceConnectionState() == PCImplIceConnectionState::Connected;
   }
 
   void AddIceCandidateStr(const std::string& candidate, const std::string& mid,
                           unsigned short level) {
-    if (getRemoteDescription().empty()) {
+    if (!mRemoteDescriptionSet) {
       // Not time to add this, because the unit-test code hasn't set the
       // description yet.
       DeferredCandidate candidateStruct = {candidate, mid, level, true};
       deferredCandidates_.push_back(candidateStruct);
     } else {
       AddIceCandidate(candidate, mid, level, true);
     }
   }
@@ -1545,16 +1547,17 @@ public:
   std::vector<nsRefPtr<DOMMediaStream>> domMediaStreams_;
   IceConfiguration cfg_;
   const std::string name;
   bool mBundleEnabled;
   VideoSessionConduit::FrameRequestType mExpectedFrameRequestType;
   bool mExpectNack;
   bool mExpectRtcpMuxAudio;
   bool mExpectRtcpMuxVideo;
+  bool mRemoteDescriptionSet;
 
   std::map<Msid, SdpMediaSection::MediaType> mAddedTracks;
 
   typedef struct {
     std::string candidate;
     std::string mid;
     uint16_t level;
     bool expectSuccess;
@@ -1814,16 +1817,17 @@ public:
              uint32_t offerAnswerFlags,
              TrickleType trickleType = BOTH_TRICKLE) {
     EnsureInit();
     a1_->CreateOffer(options, offerAnswerFlags);
     bool trickle = !!(trickleType & OFFERER_TRICKLES);
     if (!trickle) {
       a1_->pObserver->trickleCandidates = false;
     }
+    a2_->mRemoteDescriptionSet = false;
     a1_->SetLocal(TestObserver::OFFER, a1_->offer());
     if (!trickle) {
       a1_->WaitForGather();
       a1_->UpdateOffer();
       SDPSanityCheck(a1_->getLocalDescription(), HAS_ALL_CANDIDATES, true);
     }
     a2_->SetRemote(TestObserver::OFFER, a1_->offer());
   }
@@ -1832,16 +1836,17 @@ public:
               uint32_t offerAnswerFlags,
               TrickleType trickleType = BOTH_TRICKLE) {
 
     a2_->CreateAnswer(offerAnswerFlags);
     bool trickle = !!(trickleType & ANSWERER_TRICKLES);
     if (!trickle) {
       a2_->pObserver->trickleCandidates = false;
     }
+    a1_->mRemoteDescriptionSet = false;
     a2_->SetLocal(TestObserver::ANSWER, a2_->answer());
     if (!trickle) {
       a2_->WaitForGather();
       a2_->UpdateAnswer();
       SDPSanityCheck(a2_->getLocalDescription(), HAS_ALL_CANDIDATES, false);
     }
     a1_->SetRemote(TestObserver::ANSWER, a2_->answer());
   }