Bug 1434538 - Handle kAllocated in UpdateSingleSource. r?jib draft
authorAndreas Pehrson <pehrsons@mozilla.com>
Fri, 09 Feb 2018 10:25:22 +0100
changeset 752986 3e153e241838648dca9c219a3f9b0d780e9c7545
parent 751601 cc7002d074d920a10810c5f34e712dad7258cb93
child 752987 bee1087b1f88e3aa0c4f80b1a37138bad337f18c
child 753091 ac87ee3e5e511658632a50ff7d43b58ad5d1ba76
push id98434
push userbmo:apehrson@mozilla.com
push dateFri, 09 Feb 2018 10:43:43 +0000
reviewersjib
bugs1434538
milestone59.0
Bug 1434538 - Handle kAllocated in UpdateSingleSource. r?jib 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));