Bug 1339246: force rebuild of Send/RecvStream if the SSRCs have been changed r=bwc a=gchang
authorRandell Jesup <rjesup@jesup.org>
Wed, 08 Mar 2017 00:24:21 -0500
changeset 395090 3d46587f5dbedf38e8d45e88b021d12a35b25bf5
parent 395089 a7744be94bea4581220cfce7c48e22fb96ac2bf3
child 395091 9df289352cbe8510274ca466523f981be44feb75
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)
reviewersbwc, gchang
bugs1339246
milestone54.0a2
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
@@ -266,19 +266,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;
 }
 
@@ -694,31 +696,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
@@ -452,17 +452,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;