Index: trunk/src/VBox/Main/src-server/MachineImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-server/MachineImpl.cpp	(revision 46460)
+++ trunk/src/VBox/Main/src-server/MachineImpl.cpp	(revision 46465)
@@ -1721,10 +1721,19 @@
 STDMETHODIMP Machine::COMSETTER(VideoCaptureEnabled)(BOOL fEnabled)
 {
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
+    HRESULT rc = S_OK;
+
+    AutoCaller autoCaller(this);
+    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
+
+    rc = checkStateDependency(MutableStateDep);
+    if (FAILED(rc)) return rc;
+
+    setModified(IsModified_MachineData);
+    mHWData.backup();
+
     mHWData->mVideoCaptureEnabled = fEnabled;
-    return S_OK;
+
+    return rc;
 }
 
@@ -1732,4 +1741,9 @@
 {
     CheckComArgOutSafeArrayPointerValid(aScreens);
+
+    AutoCaller autoCaller(this);
+    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+
+    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
 
     SafeArray<BOOL> screens(mHWData->mMonitorCount);
@@ -1744,6 +1758,27 @@
     SafeArray<BOOL> screens(ComSafeArrayInArg(aScreens));
     AssertReturn(screens.size() <= RT_ELEMENTS(mHWData->maVideoCaptureScreens), E_INVALIDARG);
+    bool fChanged = false;
+
+    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
+
     for (unsigned i = 0; i < screens.size(); i++)
-        mHWData->maVideoCaptureScreens[i] = RT_BOOL(screens[i]);
+    {
+        if (mHWData->maVideoCaptureScreens[i] != RT_BOOL(screens[i]))
+        {
+            mHWData->maVideoCaptureScreens[i] = RT_BOOL(screens[i]);
+            fChanged = true;
+        }
+    }
+    if (fChanged)
+    {
+        alock.release();
+        HRESULT rc = onVideoCaptureChange();
+        alock.acquire();
+        if (FAILED(rc)) return rc;
+        setModified(IsModified_MachineData);
+        if (Global::IsOnline(mData->mMachineState))
+            saveSettings(NULL);
+    }
+
     return S_OK;
 }
@@ -1766,7 +1801,15 @@
 
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
+
+    HRESULT rc = checkStateDependency(MutableStateDep);
+    if (FAILED(rc)) return rc; 
+
     if (strFile.isEmpty())
        strFile = "VideoCap.webm";
+
+    setModified(IsModified_MachineData);
+    mHWData.backup();
     mHWData->mVideoCaptureFile = strFile;
+
     return S_OK;
 }
@@ -1785,12 +1828,15 @@
 {
     AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc()))
-    {
-        LogFlow(("Autolocked failed\n"));
-        return autoCaller.rc();
-    }
+    if (FAILED(autoCaller.rc())) return autoCaller.rc();
 
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
+
+    HRESULT rc = checkStateDependency(MutableStateDep);
+    if (FAILED(rc)) return rc; 
+
+    setModified(IsModified_MachineData);
+    mHWData.backup();
     mHWData->mVideoCaptureWidth = aHorzRes;
+
     return S_OK;
 }
@@ -1811,6 +1857,13 @@
     if (FAILED(autoCaller.rc())) return autoCaller.rc();
 
-    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
+    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
+
+    HRESULT rc = checkStateDependency(MutableStateDep);
+    if (FAILED(rc)) return rc; 
+
+    setModified(IsModified_MachineData);
+    mHWData.backup();
     mHWData->mVideoCaptureHeight = aVertRes;
+
     return S_OK;
 }
@@ -1831,6 +1884,13 @@
     if (FAILED(autoCaller.rc())) return autoCaller.rc();
 
-    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
+    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
+
+    HRESULT rc = checkStateDependency(MutableStateDep);
+    if (FAILED(rc)) return rc;
+
+    setModified(IsModified_MachineData);
+    mHWData.backup();
     mHWData->mVideoCaptureRate = aRate;
+
     return S_OK;
 }
@@ -1851,6 +1911,13 @@
     if (FAILED(autoCaller.rc())) return autoCaller.rc();
 
-    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
+    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
+
+    HRESULT rc = checkStateDependency(MutableStateDep);
+    if (FAILED(rc)) return rc;
+
+    setModified(IsModified_MachineData);
+    mHWData.backup();
     mHWData->mVideoCaptureFps = aFps;
+
     return S_OK;
 }
@@ -13798,4 +13865,27 @@
 
 /**
+ * @note Locks this object for reading.
+ */
+HRESULT SessionMachine::onVideoCaptureChange()
+{
+    LogFlowThisFunc(("\n"));
+
+    AutoCaller autoCaller(this);
+    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
+
+    ComPtr<IInternalSessionControl> directControl;
+    {
+        AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
+        directControl = mData->mSession.mDirectControl;
+    }
+
+    /* ignore notifications sent after #OnSessionEnd() is called */
+    if (!directControl)
+        return S_OK;
+
+    return directControl->OnVideoCaptureChange();
+}
+
+/**
  *  @note Locks this object for reading.
  */
