Index: /trunk/src/VBox/Main/src-client/DisplayImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/DisplayImpl.cpp	(revision 45940)
+++ /trunk/src/VBox/Main/src-client/DisplayImpl.cpp	(revision 45941)
@@ -479,35 +479,4 @@
     }
 
-#ifdef VBOX_WITH_VPX
-    if (VideoRecContextCreate(&mpVideoRecCtx))
-    {
-        LogFlow(("Failed to create Video Recording Context\n"));
-        return E_FAIL;
-    }
-
-    BOOL fEnabled = false;
-    mParent->machine()->COMGETTER(VideoCaptureEnabled)(&fEnabled);
-    if (fEnabled)
-    {
-        ULONG ulWidth;
-        mParent->machine()->COMGETTER(VideoCaptureWidth)(&ulWidth);
-        ULONG ulHeight;
-        mParent->machine()->COMGETTER(VideoCaptureHeight)(&ulHeight);
-        ULONG ulRate;
-        mParent->machine()->COMGETTER(VideoCaptureRate)(&ulRate);
-        ULONG ulFps;
-        mParent->machine()->COMGETTER(VideoCaptureFps)(&ulFps);
-        BSTR strFile;
-        mParent->machine()->COMGETTER(VideoCaptureFile)(&strFile);
-        if (VideoRecContextInit(mpVideoRecCtx, strFile, ulWidth, ulHeight, ulRate, ulFps))
-        {
-            LogFlow(("Failed to initialize video recording context!\n"));
-            return E_FAIL;
-        }
-        LogFlow(("Video recording as VPX with %lux%lu @ %lukbps to '%ls' enabled!\n",
-                  ulWidth, ulHeight, ulRate, strFile));
-    }
-#endif
-
     {
         // register listener for state change events
@@ -662,5 +631,5 @@
     if (!finished)
     {
-        LogRelFlowFunc (("External framebuffer wants us to wait!\n"));
+        LogRelFlowFunc(("External framebuffer wants us to wait!\n"));
         return VINF_VGA_RESIZE_IN_PROGRESS;
     }
@@ -684,7 +653,7 @@
                                   uint32_t cbLine, int w, int h, uint16_t flags)
 {
-    LogRel (("Display::handleDisplayResize(): uScreenId = %d, pvVRAM=%p "
-             "w=%d h=%d bpp=%d cbLine=0x%X, flags=0x%X\n",
-             uScreenId, pvVRAM, w, h, bpp, cbLine, flags));
+    LogRel(("Display::handleDisplayResize(): uScreenId = %d, pvVRAM=%p "
+            "w=%d h=%d bpp=%d cbLine=0x%X, flags=0x%X\n",
+            uScreenId, pvVRAM, w, h, bpp, cbLine, flags));
 
     /* If there is no framebuffer, this call is not interesting. */
@@ -732,5 +701,5 @@
          * Note: the resize information is only accessed on EMT so no serialization is required.
          */
-        LogRel (("Display::handleDisplayResize(): Warning: resize postponed.\n"));
+        LogRel(("Display::handleDisplayResize(): Warning: resize postponed.\n"));
 
         maFramebuffers[uScreenId].pendingResize.fPending    = true;
@@ -866,5 +835,5 @@
 
         /* Inform VRDP server about the change of display parameters. */
-        LogRelFlowFunc (("Calling VRDP\n"));
+        LogRelFlowFunc(("Calling VRDP\n"));
         mParent->consoleVRDPServer()->SendResize();
 
@@ -927,8 +896,8 @@
     DISPLAYFBINFO *pInfo = pInfos;
     unsigned uScreenId;
-    LogSunlover (("mapCoordsToScreen: %d,%d %dx%d\n", *px, *py, *pw, *ph));
+    LogSunlover(("mapCoordsToScreen: %d,%d %dx%d\n", *px, *py, *pw, *ph));
     for (uScreenId = 0; uScreenId < cInfos; uScreenId++, pInfo++)
     {
-        LogSunlover (("    [%d] %d,%d %dx%d\n", uScreenId, pInfo->xOrigin, pInfo->yOrigin, pInfo->w, pInfo->h));
+        LogSunlover(("    [%d] %d,%d %dx%d\n", uScreenId, pInfo->xOrigin, pInfo->yOrigin, pInfo->w, pInfo->h));
         if (   (pInfo->xOrigin <= *px && *px < pInfo->xOrigin + (int)pInfo->w)
             && (pInfo->yOrigin <= *py && *py < pInfo->yOrigin + (int)pInfo->h))
@@ -937,5 +906,5 @@
             *px -= pInfo->xOrigin;
             *py -= pInfo->yOrigin;
-            LogSunlover (("    -> %d,%d", *px, *py));
+            LogSunlover(("    -> %d,%d", *px, *py));
             break;
         }
@@ -946,5 +915,5 @@
         uScreenId = 0;
     }
-    LogSunlover ((" scr %d\n", uScreenId));
+    LogSunlover((" scr %d\n", uScreenId));
     return uScreenId;
 }
@@ -966,5 +935,5 @@
 
 #ifdef DEBUG_sunlover
-    LogFlowFunc (("%d,%d %dx%d (checked)\n", x, y, w, h));
+    LogFlowFunc(("%d,%d %dx%d (checked)\n", x, y, w, h));
 #endif /* DEBUG_sunlover */
 
@@ -980,6 +949,6 @@
 
 #ifdef DEBUG_sunlover
-    LogFlowFunc (("[%d] %d,%d %dx%d (%d,%d)\n",
-                  uScreenId, x, y, w, h, mpDrv->IConnector.cx, mpDrv->IConnector.cy));
+    LogFlowFunc(("[%d] %d,%d %dx%d (%d,%d)\n",
+                 uScreenId, x, y, w, h, mpDrv->IConnector.cx, mpDrv->IConnector.cy));
 #endif /* DEBUG_sunlover */
 
@@ -1219,6 +1188,6 @@
 static void vbvaRgnDirtyRect (VBVADIRTYREGION *prgn, unsigned uScreenId, VBVACMDHDR *phdr)
 {
-    LogSunlover (("x = %d, y = %d, w = %d, h = %d\n",
-                  phdr->x, phdr->y, phdr->w, phdr->h));
+    LogSunlover(("x = %d, y = %d, w = %d, h = %d\n",
+                 phdr->x, phdr->y, phdr->w, phdr->h));
 
     /*
@@ -1420,5 +1389,5 @@
      * acceleration after a mode change.
      */
-    LogRelFlowFunc (("mfVideoAccelEnabled = %d, fEnable = %d, pVbvaMemory = %p\n",
+    LogRelFlowFunc(("mfVideoAccelEnabled = %d, fEnable = %d, pVbvaMemory = %p\n",
                   mfVideoAccelEnabled, fEnable, pVbvaMemory));
 
@@ -1437,5 +1406,5 @@
         Assert (!mfVideoAccelEnabled);
 
-        LogRelFlowFunc (("Machine is not yet running.\n"));
+        LogRelFlowFunc(("Machine is not yet running.\n"));
 
         if (fEnable)
@@ -1505,5 +1474,5 @@
     }
 
-    LogRelFlowFunc (("VideoAccelEnable: rc = %Rrc.\n", rc));
+    LogRelFlowFunc(("VideoAccelEnable: rc = %Rrc.\n", rc));
 
     return rc;
@@ -1660,6 +1629,6 @@
 
 #ifdef DEBUG_sunlover
-    LogFlowFunc (("first = %d, free = %d\n",
-                  indexRecordFirst, indexRecordFree));
+    LogFlowFunc(("first = %d, free = %d\n",
+                 indexRecordFirst, indexRecordFree));
 #endif /* DEBUG_sunlover */
 
@@ -1678,5 +1647,5 @@
 
 #ifdef DEBUG_sunlover
-    LogFlowFunc (("cbRecord = 0x%08X\n", pRecord->cbRecord));
+    LogFlowFunc(("cbRecord = 0x%08X\n", pRecord->cbRecord));
 #endif /* DEBUG_sunlover */
 
@@ -1689,5 +1658,5 @@
         Assert (mpu8VbvaPartial);
 
-        LogFlowFunc (("continue partial record mcbVbvaPartial = %d cbRecord 0x%08X, first = %d, free = %d\n",
+        LogFlowFunc(("continue partial record mcbVbvaPartial = %d cbRecord 0x%08X, first = %d, free = %d\n",
                       mcbVbvaPartial, pRecord->cbRecord, indexRecordFirst, indexRecordFree));
 
@@ -1714,5 +1683,5 @@
 
 #ifdef DEBUG_sunlover
-            LogFlowFunc (("partial done ok, data = %d, free = %d\n",
+            LogFlowFunc(("partial done ok, data = %d, free = %d\n",
                           mpVbvaMemory->off32Data, mpVbvaMemory->off32Free));
 #endif /* DEBUG_sunlover */
@@ -1734,5 +1703,5 @@
             }
 
-            LogFlowFunc (("started partial record mcbVbvaPartial = 0x%08X cbRecord 0x%08X, first = %d, free = %d\n",
+            LogFlowFunc(("started partial record mcbVbvaPartial = 0x%08X cbRecord 0x%08X, first = %d, free = %d\n",
                           mcbVbvaPartial, pRecord->cbRecord, indexRecordFirst, indexRecordFree));
         }
@@ -1769,5 +1738,5 @@
             if (!dst)
             {
-                LogRelFlowFunc (("could not allocate %d bytes from heap!!!\n", cbRecord));
+                LogRelFlowFunc(("could not allocate %d bytes from heap!!!\n", cbRecord));
                 mpVbvaMemory->off32Data = (mpVbvaMemory->off32Data + cbRecord) % VBVA_RING_BUFFER_SIZE;
                 return false;
@@ -1779,5 +1748,5 @@
 
 #ifdef DEBUG_sunlover
-            LogFlowFunc (("Allocated from heap %p\n", dst));
+            LogFlowFunc(("Allocated from heap %p\n", dst));
 #endif /* DEBUG_sunlover */
         }
@@ -1790,6 +1759,6 @@
 
 #ifdef DEBUG_sunlover
-    LogFlowFunc (("done ok, data = %d, free = %d\n",
-                  mpVbvaMemory->off32Data, mpVbvaMemory->off32Free));
+    LogFlowFunc(("done ok, data = %d, free = %d\n",
+                 mpVbvaMemory->off32Data, mpVbvaMemory->off32Free));
 #endif /* DEBUG_sunlover */
 
@@ -1816,5 +1785,5 @@
 
 #ifdef DEBUG_sunlover
-        LogFlowFunc (("Free heap %p\n", pHdr));
+        LogFlowFunc(("Free heap %p\n", pHdr));
 #endif /* DEBUG_sunlover */
 
@@ -1853,5 +1822,5 @@
 {
 #ifdef DEBUG_sunlover_2
-    LogFlowFunc (("mfVideoAccelEnabled = %d\n", mfVideoAccelEnabled));
+    LogFlowFunc(("mfVideoAccelEnabled = %d\n", mfVideoAccelEnabled));
 #endif /* DEBUG_sunlover_2 */
 
@@ -1866,5 +1835,5 @@
 
 #ifdef DEBUG_sunlover_2
-    LogFlowFunc (("indexRecordFirst = %d, indexRecordFree = %d, off32Data = %d, off32Free = %d\n",
+    LogFlowFunc(("indexRecordFirst = %d, indexRecordFree = %d, off32Data = %d, off32Free = %d\n",
                   mpVbvaMemory->indexRecordFirst, mpVbvaMemory->indexRecordFree, mpVbvaMemory->off32Data, mpVbvaMemory->off32Free));
 #endif /* DEBUG_sunlover_2 */
@@ -1909,6 +1878,6 @@
         {
 #ifdef DEBUG_sunlover
-            LogFlowFunc (("hdr: cbCmd = %d, x=%d, y=%d, w=%d, h=%d\n",
-                          cbCmd, phdr->x, phdr->y, phdr->w, phdr->h));
+            LogFlowFunc(("hdr: cbCmd = %d, x=%d, y=%d, w=%d, h=%d\n",
+                         cbCmd, phdr->x, phdr->y, phdr->w, phdr->h));
 #endif /* DEBUG_sunlover */
 
@@ -2024,5 +1993,5 @@
     ULONG *aWidth, ULONG *aHeight, ULONG *aBitsPerPixel)
 {
-    LogRelFlowFunc (("aScreenId = %d\n", aScreenId));
+    LogRelFlowFunc(("aScreenId = %d\n", aScreenId));
 
     AutoCaller autoCaller(this);
@@ -2068,5 +2037,5 @@
 STDMETHODIMP Display::SetFramebuffer(ULONG aScreenId, IFramebuffer *aFramebuffer)
 {
-    LogRelFlowFunc (("\n"));
+    LogRelFlowFunc(("\n"));
 
     if (aFramebuffer != NULL)
@@ -2129,8 +2098,8 @@
 }
 
-STDMETHODIMP Display::GetFramebuffer (ULONG aScreenId,
-    IFramebuffer **aFramebuffer, LONG *aXOrigin, LONG *aYOrigin)
-{
-    LogRelFlowFunc (("aScreenId = %d\n", aScreenId));
+STDMETHODIMP Display::GetFramebuffer(ULONG aScreenId,
+                                     IFramebuffer **aFramebuffer, LONG *aXOrigin, LONG *aYOrigin)
+{
+    LogRelFlowFunc(("aScreenId = %d\n", aScreenId));
 
     CheckComArgOutPointerValid(aFramebuffer);
@@ -2305,13 +2274,13 @@
 
                 rc = pDisplay->mpDrv->pUpPort->pfnCopyRect(pDisplay->mpDrv->pUpPort,
-                                                      width, height,
-                                                      pu8Src,
-                                                      xSrc, ySrc,
-                                                      u32SrcWidth, u32SrcHeight,
-                                                      u32SrcLineSize, u32SrcBitsPerPixel,
-                                                      pu8Dst,
-                                                      xDst, yDst,
-                                                      u32DstWidth, u32DstHeight,
-                                                      u32DstLineSize, u32DstBitsPerPixel);
+                                                           width, height,
+                                                           pu8Src,
+                                                           xSrc, ySrc,
+                                                           u32SrcWidth, u32SrcHeight,
+                                                           u32SrcLineSize, u32SrcBitsPerPixel,
+                                                           pu8Dst,
+                                                           xDst, yDst,
+                                                           u32DstWidth, u32DstHeight,
+                                                           u32DstLineSize, u32DstBitsPerPixel);
                 if (RT_SUCCESS(rc))
                 {
@@ -2747,5 +2716,5 @@
     //  within the Console lock to make it atomic).
 
-    LogRelFlowFunc (("address=%p, x=%d, y=%d, width=%d, height=%d\n",
+    LogRelFlowFunc(("address=%p, x=%d, y=%d, width=%d, height=%d\n",
                   (void *)address, x, y, width, height));
 
@@ -2795,5 +2764,5 @@
 //    }
 
-    LogRelFlowFunc (("rc=%08X\n", rc));
+    LogRelFlowFunc(("rc=%08X\n", rc));
     return rc;
 }
@@ -2903,5 +2872,5 @@
     HRESULT rc = S_OK;
 
-    LogRelFlowFunc (("Sending DPYUPDATE request\n"));
+    LogRelFlowFunc(("Sending DPYUPDATE request\n"));
 
     /* Have to release the lock when calling EMT.  */
@@ -2917,5 +2886,5 @@
                       tr("Could not invalidate and update the screen (%Rrc)"), rcVBox);
 
-    LogRelFlowFunc (("rc=%08X\n", rc));
+    LogRelFlowFunc(("rc=%08X\n", rc));
     return rc;
 }
@@ -2929,5 +2898,5 @@
 STDMETHODIMP Display::ResizeCompleted(ULONG aScreenId)
 {
-    LogRelFlowFunc (("\n"));
+    LogRelFlowFunc(("\n"));
 
     /// @todo (dmik) can we AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); here?
@@ -3010,5 +2979,5 @@
 void Display::updateDisplayData(void)
 {
-    LogRelFlowFunc (("\n"));
+    LogRelFlowFunc(("\n"));
 
     /* the driver might not have been constructed yet */
@@ -3070,5 +3039,5 @@
         mpDrv->IConnector.cy = 0;
     }
-    LogRelFlowFunc (("leave\n"));
+    LogRelFlowFunc(("leave\n"));
 }
 
@@ -3124,5 +3093,5 @@
                                               unsigned uScreenId)
 {
-    LogRelFlowFunc (("uScreenId = %d\n", uScreenId));
+    LogRelFlowFunc(("uScreenId = %d\n", uScreenId));
 
     AssertReturn(that, VERR_INVALID_PARAMETER);
@@ -3182,5 +3151,5 @@
     }
 
-    LogRelFlowFunc (("leave\n"));
+    LogRelFlowFunc(("leave\n"));
     return VINF_SUCCESS;
 }
@@ -3196,5 +3165,5 @@
     PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
 
-    LogRelFlowFunc (("bpp %d, pvVRAM %p, cbLine %d, cx %d, cy %d\n",
+    LogRelFlowFunc(("bpp %d, pvVRAM %p, cbLine %d, cx %d, cy %d\n",
                   bpp, pvVRAM, cbLine, cx, cy));
 
@@ -3213,6 +3182,6 @@
 
 #ifdef DEBUG_sunlover
-    LogFlowFunc (("mfVideoAccelEnabled = %d, %d,%d %dx%d\n",
-                  pDrv->pDisplay->mfVideoAccelEnabled, x, y, cx, cy));
+    LogFlowFunc(("mfVideoAccelEnabled = %d, %d,%d %dx%d\n",
+                 pDrv->pDisplay->mfVideoAccelEnabled, x, y, cx, cy));
 #endif /* DEBUG_sunlover */
 
@@ -3239,6 +3208,6 @@
 
 #ifdef DEBUG_sunlover_2
-    LogFlowFunc (("pDrv->pDisplay->mfVideoAccelEnabled = %d\n",
-                  pDrv->pDisplay->mfVideoAccelEnabled));
+    LogFlowFunc(("pDrv->pDisplay->mfVideoAccelEnabled = %d\n",
+                 pDrv->pDisplay->mfVideoAccelEnabled));
 #endif /* DEBUG_sunlover_2 */
 
@@ -3259,5 +3228,5 @@
         if (u32ResizeStatus == ResizeStatus_UpdateDisplayData)
         {
-            LogRelFlowFunc (("ResizeStatus_UpdateDisplayData %d\n", uScreenId));
+            LogRelFlowFunc(("ResizeStatus_UpdateDisplayData %d\n", uScreenId));
             fNoUpdate = true; /* Always set it here, because pfnUpdateDisplayAll can cause a new resize. */
             /* The framebuffer was resized and display data need to be updated. */
@@ -3276,5 +3245,5 @@
         {
             /* The framebuffer is being resized. Do not call the VGA device back. Immediately return. */
-            LogRelFlowFunc (("ResizeStatus_InProcess\n"));
+            LogRelFlowFunc(("ResizeStatus_InProcess\n"));
             fNoUpdate = true;
             continue;
@@ -3320,6 +3289,5 @@
 
 #ifdef VBOX_WITH_VPX
-    if (   pDisplay->mpVideoRecCtx
-        && VideoRecIsEnabled(pDisplay->mpVideoRecCtx))
+    if (VideoRecIsEnabled(pDisplay->mpVideoRecCtx))
     {
         DISPLAYFBINFO *pFBInfo = &pDisplay->maFramebuffers[VBOX_VIDEO_PRIMARY_SCREEN];
@@ -3356,5 +3324,5 @@
 #endif /* DEBUG_sunlover */
 #ifdef DEBUG_sunlover_2
-    LogFlowFunc (("leave\n"));
+    LogFlowFunc(("leave\n"));
 #endif /* DEBUG_sunlover_2 */
 }
@@ -3369,5 +3337,5 @@
     PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
 
-    LogRelFlowFunc (("\n"));
+    LogRelFlowFunc(("\n"));
 
    /* Disable VBVA mode. */
@@ -3384,5 +3352,5 @@
     PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
 
-    LogRelFlowFunc (("fEnabled=%d\n", fEnabled));
+    LogRelFlowFunc(("fEnabled=%d\n", fEnabled));
 
     NOREF(fEnabled);
@@ -4193,5 +4161,5 @@
         {
             /* VRDP server still need this notification. */
-            LogRelFlowFunc (("Calling VRDP\n"));
+            LogRelFlowFunc(("Calling VRDP\n"));
             pThis->mParent->consoleVRDPServer()->SendResize();
         }
@@ -4306,15 +4274,15 @@
      * Init Interfaces.
      */
-    pDrvIns->IBase.pfnQueryInterface        = Display::drvQueryInterface;
-
-    pThis->IConnector.pfnResize             = Display::displayResizeCallback;
-    pThis->IConnector.pfnUpdateRect         = Display::displayUpdateCallback;
-    pThis->IConnector.pfnRefresh            = Display::displayRefreshCallback;
-    pThis->IConnector.pfnReset              = Display::displayResetCallback;
-    pThis->IConnector.pfnLFBModeChange      = Display::displayLFBModeChangeCallback;
-    pThis->IConnector.pfnProcessAdapterData = Display::displayProcessAdapterDataCallback;
-    pThis->IConnector.pfnProcessDisplayData = Display::displayProcessDisplayDataCallback;
+    pDrvIns->IBase.pfnQueryInterface           = Display::drvQueryInterface;
+
+    pThis->IConnector.pfnResize                = Display::displayResizeCallback;
+    pThis->IConnector.pfnUpdateRect            = Display::displayUpdateCallback;
+    pThis->IConnector.pfnRefresh               = Display::displayRefreshCallback;
+    pThis->IConnector.pfnReset                 = Display::displayResetCallback;
+    pThis->IConnector.pfnLFBModeChange         = Display::displayLFBModeChangeCallback;
+    pThis->IConnector.pfnProcessAdapterData    = Display::displayProcessAdapterDataCallback;
+    pThis->IConnector.pfnProcessDisplayData    = Display::displayProcessDisplayDataCallback;
 #ifdef VBOX_WITH_VIDEOHWACCEL
-    pThis->IConnector.pfnVHWACommandProcess = Display::displayVHWACommandProcess;
+    pThis->IConnector.pfnVHWACommandProcess    = Display::displayVHWACommandProcess;
 #endif
 #ifdef VBOX_WITH_CRHGSMI
@@ -4323,10 +4291,10 @@
 #endif
 #ifdef VBOX_WITH_HGSMI
-    pThis->IConnector.pfnVBVAEnable         = Display::displayVBVAEnable;
-    pThis->IConnector.pfnVBVADisable        = Display::displayVBVADisable;
-    pThis->IConnector.pfnVBVAUpdateBegin    = Display::displayVBVAUpdateBegin;
-    pThis->IConnector.pfnVBVAUpdateProcess  = Display::displayVBVAUpdateProcess;
-    pThis->IConnector.pfnVBVAUpdateEnd      = Display::displayVBVAUpdateEnd;
-    pThis->IConnector.pfnVBVAResize         = Display::displayVBVAResize;
+    pThis->IConnector.pfnVBVAEnable            = Display::displayVBVAEnable;
+    pThis->IConnector.pfnVBVADisable           = Display::displayVBVADisable;
+    pThis->IConnector.pfnVBVAUpdateBegin       = Display::displayVBVAUpdateBegin;
+    pThis->IConnector.pfnVBVAUpdateProcess     = Display::displayVBVAUpdateProcess;
+    pThis->IConnector.pfnVBVAUpdateEnd         = Display::displayVBVAUpdateEnd;
+    pThis->IConnector.pfnVBVAResize            = Display::displayVBVAResize;
     pThis->IConnector.pfnVBVAMousePointerShape = Display::displayVBVAMousePointerShape;
 #endif
@@ -4359,11 +4327,11 @@
         return rc;
     }
-    pThis->pDisplay = (Display *)pv;        /** @todo Check this cast! */
+    Display *pDisplay = (Display *)pv;      /** @todo Check this cast! */
+    pThis->pDisplay = pDisplay;
     pThis->pDisplay->mpDrv = pThis;
-
     /*
      * Update our display information according to the framebuffer
      */
-    pThis->pDisplay->updateDisplayData();
+    pDisplay->updateDisplayData();
 
     /*
@@ -4373,5 +4341,43 @@
 
 #ifdef VBOX_WITH_CRHGSMI
-    pThis->pDisplay->setupCrHgsmiData();
+    pDisplay->setupCrHgsmiData();
+#endif
+
+#ifdef VBOX_WITH_VPX
+    rc = VideoRecContextCreate(&pDisplay->mpVideoRecCtx);
+    if (RT_FAILURE(rc))
+    {
+        LogFlow(("Failed to create video recording context (%Rrc)!\n", rc));
+        return E_FAIL;
+    }
+
+    ComPtr<IMachine> pMachine = pDisplay->mParent->machine();
+    BOOL fEnabled = false;
+    pMachine->COMGETTER(VideoCaptureEnabled)(&fEnabled);
+    if (fEnabled)
+    {
+        ULONG ulWidth;
+        int hrc = pMachine->COMGETTER(VideoCaptureWidth)(&ulWidth);
+        AssertComRCReturnRC(hrc);
+        ULONG ulHeight;
+        hrc = pMachine->COMGETTER(VideoCaptureHeight)(&ulHeight);
+        AssertComRCReturnRC(hrc);
+        ULONG ulRate;
+        hrc = pMachine->COMGETTER(VideoCaptureRate)(&ulRate);
+        AssertComRCReturnRC(hrc);
+        ULONG ulFps;
+        hrc = pMachine->COMGETTER(VideoCaptureFps)(&ulFps);
+        AssertComRCReturnRC(hrc);
+        BSTR strFile;
+        hrc = pMachine->COMGETTER(VideoCaptureFile)(&strFile);
+        AssertComRCReturnRC(hrc);
+        rc = VideoRecContextInit(pDisplay->mpVideoRecCtx, com::Utf8Str(strFile).c_str(),
+                                 ulWidth, ulHeight, ulRate, ulFps);
+        if (RT_SUCCESS(rc))
+            LogRel(("WebM/VP8 video recording with %ux%u @ %u kbps, %u fps to '%s' enabled!\n",
+                   ulWidth, ulHeight, ulRate, ulFps, com::Utf8Str(strFile).c_str()));
+        else
+            LogRel(("Failed to initialize video recording context (%Rrc)!\n", rc));
+    }
 #endif
 
Index: /trunk/src/VBox/Main/src-client/VideoRec.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/VideoRec.cpp	(revision 45940)
+++ /trunk/src/VBox/Main/src-client/VideoRec.cpp	(revision 45941)
@@ -39,13 +39,4 @@
 static int videoRecEncodeAndWrite(PVIDEORECCONTEXT pVideoRecCtx);
 static int videoRecRGBToYUV(PVIDEORECCONTEXT pVideoRecCtx);
-
-/* RGB buffer */
-enum
-{
-    /* RGB buffer empty */
-    VIDREC_RGB_EMPTY = 0,
-    /* RGB buffer filled */
-    VIDREC_RGB_FILLED
-};
 
 /* encoding */
@@ -97,6 +88,7 @@
     /* pixel format of the current frame */
     uint32_t            u32PixelFormat;
-    /* maximum number of frames per second */
+    /* minimal delay between two frames */
     uint32_t            uDelay;
+    /* time stamp of the last frame we encoded */
     uint64_t            u64LastTimeStamp;
     /* time stamp of the current frame */
@@ -428,5 +420,5 @@
  * @param   uTargetHeight       Height of the target image in video recording file.
  */
-int VideoRecContextInit(PVIDEORECCONTEXT pVideoRecCtx, com::Bstr strFile,
+int VideoRecContextInit(PVIDEORECCONTEXT pVideoRecCtx, const char *pszFile,
                         uint32_t uWidth, uint32_t uHeight, uint32_t uRate, uint32_t uFps)
 {
@@ -436,11 +428,10 @@
     AssertReturn(pVideoRecCtx->pu8RgbBuf, VERR_NO_MEMORY);
 
-    int rc = RTFileOpen(&pVideoRecCtx->ebml.file,
-                        com::Utf8Str(strFile).c_str(),
+    int rc = RTFileOpen(&pVideoRecCtx->ebml.file, pszFile,
                         RTFILE_O_CREATE_REPLACE | RTFILE_O_WRITE | RTFILE_O_DENY_NONE);
     if (RT_FAILURE(rc))
     {
-        LogFlow(("Failed to open the output File \n"));
-        return VERR_GENERAL_FAILURE;
+        LogFlow(("Failed to open the output File\n"));
+        return rc;
     }
 
@@ -448,6 +439,6 @@
     if (rcv != VPX_CODEC_OK)
     {
-        LogFlow(("Failed to configure codec \n", vpx_codec_err_to_string(rcv)));
-        return VERR_GENERAL_FAILURE;
+        LogFlow(("Failed to configure codec\n", vpx_codec_err_to_string(rcv)));
+        return rc;
     }
 
@@ -487,11 +478,11 @@
     pVideoRecCtx->pu8YuvBuf = pVideoRecCtx->VpxRawImage.planes[0];
 
-    int vrc = RTSemEventCreate(&pVideoRecCtx->WaitEvent);
-    AssertRCReturn(vrc, vrc);
-
-    vrc = RTThreadCreate(&pVideoRecCtx->Thread, VideoRecThread,
-                         (void*)pVideoRecCtx, 0,
-                         RTTHREADTYPE_MAIN_WORKER, 0, "VideoRec");
-    AssertRCReturn(vrc, vrc);
+    rc = RTSemEventCreate(&pVideoRecCtx->WaitEvent);
+    AssertRCReturn(rc, rc);
+
+    rc = RTThreadCreate(&pVideoRecCtx->Thread, VideoRecThread,
+                        (void*)pVideoRecCtx, 0,
+                        RTTHREADTYPE_MAIN_WORKER, 0, "VideoRec");
+    AssertRCReturn(rc, rc);
 
     pVideoRecCtx->fEnabled = true;
@@ -542,5 +533,7 @@
 bool VideoRecIsEnabled(PVIDEORECCONTEXT pVideoRecCtx)
 {
-    AssertPtr(pVideoRecCtx);
+    if (!pVideoRecCtx)
+        return false;
+
     return pVideoRecCtx->fEnabled;
 }
Index: /trunk/src/VBox/Main/src-client/VideoRec.h
===================================================================
--- /trunk/src/VBox/Main/src-client/VideoRec.h	(revision 45940)
+++ /trunk/src/VBox/Main/src-client/VideoRec.h	(revision 45941)
@@ -23,5 +23,5 @@
 
 int  VideoRecContextCreate(PVIDEORECCONTEXT *ppVideoRecContext);
-int  VideoRecContextInit(PVIDEORECCONTEXT pVideoRecContext, com::Bstr mFileName,
+int  VideoRecContextInit(PVIDEORECCONTEXT pVideoRecContext, const char *pszFile,
                          uint32_t uWidth, uint32_t uHeight, uint32_t uRate, uint32_t uFps);
 void VideoRecContextClose(PVIDEORECCONTEXT pVideoRecContext);
