Bug 1337810: use sender SSRC for receivers r=drno a=gchang
authorRandell Jesup <rjesup@jesup.org>
Tue, 07 Mar 2017 16:24:00 -0500
changeset 395223 637d3f09f285e4631ee4a94e41524a94d3d04a11
parent 395222 f7f9c208a9bdfda14e4b9feaf425468cc6d7ee3a
child 395224 9e4c49409f40e7155da323a9d845b69f4212f170
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdrno, gchang
bugs1337810
milestone54.0a2
Bug 1337810: use sender SSRC for receivers r=drno a=gchang MozReview-Commit-ID: 1ErpaFbU6pZ
media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
--- a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
+++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
@@ -831,16 +831,18 @@ bool WebrtcVideoConduit::GetRTCPReceiver
     *bytesReceived = stats.rtp_stats.MediaPayloadBytes();
     *packetsReceived = stats.rtp_stats.transmitted.packets;
     // Note: timestamp is not correct per the spec... should be time the rtcp
     // was received (remote) or sent (local)
     *timestamp = webrtc::Clock::GetRealTimeClock()->TimeInMilliseconds();
     int64_t rtt = mRecvStream->GetRtt();
     if (rtt >= 0) {
       *rttMs = rtt;
+    } else {
+      *rttMs = 0;
     }
   }
   return true;
 }
 
 bool
 WebrtcVideoConduit::GetRTCPSenderReport(DOMHighResTimeStamp* timestamp,
                                         unsigned int* packetsSent,
@@ -1172,32 +1174,40 @@ WebrtcVideoConduit::ConfigureRecvMediaCo
         SECStatus rv = PK11_GenerateRandom(reinterpret_cast<unsigned char*>(&ssrc), sizeof(ssrc));
         if (rv != SECSuccess) {
           return kMediaConduitUnknownError;
         }
       } while (ssrc == 0); // webrtc.org code has fits if you select an SSRC of 0
 
       mRecvStreamConfig.rtp.remote_ssrc = ssrc;
     }
-    // FIXME(jesup) - Bug 1325447 -- SSRCs configured here are a problem.
-    // 0 isn't allowed.  Would be best to ask for a random SSRC from the RTP code.
-    // Would need to call rtp_sender.cc -- GenerateSSRC(), which isn't exposed.  It's called on
-    // collision, or when we decide to send.  it should be called on receiver creation.
-    // Here, we're generating the SSRC value - but this causes ssrc_forced in set in rtp_sender,
-    // which locks us into the SSRC - even a collision won't change it!!!
-    auto ssrc = mRecvStreamConfig.rtp.remote_ssrc;
-    do {
+    // 0 isn't allowed.  Would be best to ask for a random SSRC from the
+    // RTP code.  Would need to call rtp_sender.cc -- GenerateNewSSRC(),
+    // which isn't exposed.  It's called on collision, or when we decide to
+    // send.  it should be called on receiver creation.  Here, we're
+    // generating the SSRC value - but this causes ssrc_forced in set in
+    // rtp_sender, which locks us into the SSRC - even a collision won't
+    // change it!!!
+    MOZ_ASSERT(!mSendStreamConfig.rtp.ssrcs.empty());
+    auto ssrc = mSendStreamConfig.rtp.ssrcs.front();
+    Unused << NS_WARN_IF(ssrc == mRecvStreamConfig.rtp.remote_ssrc);
+
+    while (ssrc == mRecvStreamConfig.rtp.remote_ssrc || ssrc == 0) {
       SECStatus rv = PK11_GenerateRandom(reinterpret_cast<unsigned char*>(&ssrc), sizeof(ssrc));
       if (rv != SECSuccess) {
         return kMediaConduitUnknownError;
       }
-    } while (ssrc == mRecvStreamConfig.rtp.remote_ssrc || ssrc == 0);
+    }
     // webrtc.org code has fits if you select an SSRC of 0
 
     mRecvStreamConfig.rtp.local_ssrc = ssrc;
+    CSFLogDebug(logTag, "%s (%p): Local SSRC 0x%08x (of %u), remote SSRC 0x%08x",
+                __FUNCTION__, (void*) this, ssrc,
+                (uint32_t) mSendStreamConfig.rtp.ssrcs.size(),
+                mRecvStreamConfig.rtp.remote_ssrc);
 
     // XXX Copy over those that are the same and don't rebuild them
     mRecvCodecList.SwapElements(recv_codecs);
     recv_codecs.Clear();
     mRecvStreamConfig.rtp.rtx.clear();
 
     {
       MutexAutoLock lock(mCodecMutex);