Bug 1339246 - Force rebuild of Send/RecvStream if the SSRCs have been changed. r=bwc, a=gchang
☠☠ backed out by 9e4af5282696 ☠ ☠
authorRandell Jesup <rjesup@jesup.org>
Wed, 08 Mar 2017 00:24:21 -0500
changeset 379017 6bdac526f998b0e7d45a754ea93be7a61e99e35c
parent 379016 fc832b9c1e62f84fbadd57954fec7e9cb49688d0
child 379018 20b587aa00a89dbf245a53ee2495b94132000d9c
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwc, gchang
bugs1339246
milestone53.0
Bug 1339246 - Force rebuild of Send/RecvStream if the SSRCs have been changed. r=bwc, a=gchang MozReview-Commit-ID: HWZ8MXjtWzg
media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
media/webrtc/signaling/src/media-conduit/VideoConduit.h
--- a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
+++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
@@ -269,19 +269,21 @@ bool WebrtcVideoConduit::SetLocalSSRCs(c
   // Update the value of the ssrcs in the config structure.
   mSendStreamConfig.rtp.ssrcs = aSSRCs;
 
   bool wasTransmitting = mEngineTransmitting;
   if (StopTransmitting() != kMediaConduitNoError) {
     return false;
   }
 
+  MutexAutoLock lock(mCodecMutex);
+  // On the next StartTransmitting() or ConfigureSendMediaCodec, force
+  // building a new SendStream to switch SSRCs.
+  DeleteSendStream();
   if (wasTransmitting) {
-    MutexAutoLock lock(mCodecMutex);
-    DeleteSendStream();
     if (StartTransmitting() != kMediaConduitNoError) {
       return false;
     }
   }
 
   return true;
 }
 
@@ -699,31 +701,37 @@ WebrtcVideoConduit::SetRemoteSSRC(unsign
   mRecvStreamConfig.rtp.remote_ssrc = ssrc;
 
   unsigned int current_ssrc;
   if (!GetRemoteSSRC(&current_ssrc)) {
     return false;
   }
   mRecvSSRCSet = true;
 
-  if (current_ssrc == ssrc || !mEngineReceiving) {
+  if (current_ssrc == ssrc) {
     return true;
   }
 
+  bool wasReceiving = mEngineReceiving;
   if (StopReceiving() != kMediaConduitNoError) {
     return false;
   }
 
   // This will destroy mRecvStream and create a new one (argh, why can't we change
   // it without a full destroy?)
   // We're going to modify mRecvStream, we must lock.  Only modified on MainThread.
   // All non-MainThread users must lock before reading/using
   {
     MutexAutoLock lock(mCodecMutex);
+    // On the next StartReceiving() or ConfigureRecvMediaCodec, force
+    // building a new RecvStream to switch SSRCs.
     DeleteRecvStream();
+    if (!wasReceiving) {
+      return true;
+    }
     MediaConduitErrorCode rval = CreateRecvStream();
     if (rval != kMediaConduitNoError) {
       CSFLogError(logTag, "%s Start Receive Error %d ", __FUNCTION__, rval);
       return false;
     }
   }
   return (StartReceiving() == kMediaConduitNoError);
 }
--- a/media/webrtc/signaling/src/media-conduit/VideoConduit.h
+++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.h
@@ -451,17 +451,17 @@ private:
   // Engine state we are concerned with.
   mozilla::Atomic<bool> mEngineTransmitting; // If true ==> Transmit Subsystem is up and running
   mozilla::Atomic<bool> mEngineReceiving;    // if true ==> Receive Subsystem up and running
 
   int mCapId;   // Capturer for this conduit
   //Local database of currently applied receive codecs
   nsTArray<UniquePtr<VideoCodecConfig>> mRecvCodecList;
 
-  // protects mCurrSendCodecConfig, mInReconfig,mVideoSend/RecvStreamStats, mSend/RecvStreams
+  // protects mCurSendCodecConfig, mInReconfig,mVideoSend/RecvStreamStats, mSend/RecvStreams
   Mutex mCodecMutex;
   nsAutoPtr<VideoCodecConfig> mCurSendCodecConfig;
   bool mInReconfig;
   SendStreamStatistics mSendStreamStats;
   ReceiveStreamStatistics mRecvStreamStats;
   // Must call webrtc::Call::DestroyVideoReceive/SendStream to delete these:
   webrtc::VideoReceiveStream* mRecvStream;
   webrtc::VideoSendStream* mSendStream;