Bug 1434538 - Handle kAllocated in UpdateSingleSource. r=jib a=lizzard
authorAndreas Pehrson <pehrsons@mozilla.com>
Fri, 09 Feb 2018 10:25:22 +0100
changeset 454812 66fc17858fe7b4936b34e80b49a6f6f8ec89af37
parent 454811 ab0beff6b8b082aaa845286cd4ac738ae9fc8ddf
child 454813 38f370417409110b1fc422bb3d4088a3a91f8ff1
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib, lizzard
bugs1434538
milestone59.0
Bug 1434538 - Handle kAllocated in UpdateSingleSource. r=jib a=lizzard This will make us properly process the constraints of an Allocate() happening just after another Allocate(). MozReview-Commit-ID: KHZfuKmJZSG
dom/media/webrtc/MediaEngineRemoteVideoSource.cpp
--- a/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp
+++ b/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp
@@ -312,16 +312,17 @@ MediaEngineRemoteVideoSource::UpdateSing
                                   aHandle->mPrincipalInfo)) {
         return NS_ERROR_FAILURE;
       }
       mState = kAllocated;
       SetLastCapability(mCapability);
       LOG(("Video device %d allocated", mCaptureIndex));
       break;
 
+    case kAllocated:
     case kStarted:
       {
         size_t index = mHandleIds.NoIndex;
         if (aHandle) {
           mHandleId = aHandle->mId;
           index = mHandleIds.IndexOf(mHandleId);
         }
 
@@ -346,23 +347,25 @@ MediaEngineRemoteVideoSource::UpdateSing
         if (!ChooseCapability(aNetConstraints, aPrefs, aDeviceId, mCapability,
                               kFeasibility)) {
           *aOutBadConstraint = FindBadConstraint(aNetConstraints, *this, aDeviceId);
           return NS_ERROR_FAILURE;
         }
         LOG(("ChooseCapability(kFeasibility) for mCapability --"));
 
         if (mCapability != mLastCapability) {
-          camera::GetChildAndCall(&camera::CamerasChild::StopCapture,
-                                  mCapEngine, mCaptureIndex);
-          if (camera::GetChildAndCall(&camera::CamerasChild::StartCapture,
-                                      mCapEngine, mCaptureIndex, mCapability,
-                                      this)) {
-            LOG(("StartCapture failed"));
-            return NS_ERROR_FAILURE;
+          if (mState == kStarted) {
+            camera::GetChildAndCall(&camera::CamerasChild::StopCapture,
+                                    mCapEngine, mCaptureIndex);
+            if (camera::GetChildAndCall(&camera::CamerasChild::StartCapture,
+                                        mCapEngine, mCaptureIndex, mCapability,
+                                        this)) {
+              LOG(("StartCapture failed"));
+              return NS_ERROR_FAILURE;
+            }
           }
           SetLastCapability(mCapability);
         }
         break;
       }
 
     default:
       LOG(("Video device %d in ignored state %d", mCaptureIndex, mState));