VirtualBox

Changeset 50313 in vbox for trunk/src/VBox/Main/src-client


Ignore:
Timestamp:
Feb 3, 2014 6:46:27 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
92022
Message:

crOpenGL: video recording working

Location:
trunk/src/VBox/Main/src-client
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/DisplayImpl.cpp

    r50260 r50313  
    5252# include <iprt/path.h>
    5353# include "VideoRec.h"
     54#endif
     55
     56#ifdef VBOX_WITH_CROGL
     57typedef enum
     58{
     59    CRVREC_STATE_IDLE,
     60    CRVREC_STATE_SUBMITTED
     61} CRVREC_STATE;
    5462#endif
    5563
     
    137145    for (unsigned i = 0; i < RT_ELEMENTS(maVideoRecEnabled); i++)
    138146        maVideoRecEnabled[i] = true;
     147#endif
     148
     149#ifdef VBOX_WITH_CRHGSMI
     150    mhCrOglSvc = NULL;
     151#endif
     152#ifdef VBOX_WITH_CROGL
     153    RT_ZERO(mCrOglCallbacks);
     154    mfCrOglVideoRecState = CRVREC_STATE_IDLE;
     155    mCrOglScreenshotData.u32Screen = CRSCREEN_ALL;
     156    mCrOglScreenshotData.pvContext = this;
     157    mCrOglScreenshotData.pfnScreenshot = displayCrVRecScreenshot;
    139158#endif
    140159
     
    34033422        Assert(mhCrOglSvc);
    34043423        /* setup command completion callback */
    3405         VBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP_COMPLETION Completion;
    3406         Completion.Hdr.enmType = VBOXVDMACMD_CHROMIUM_CTL_TYPE_CRHGSMI_SETUP_COMPLETION;
     3424        VBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP_MAINCB Completion;
     3425        Completion.Hdr.enmType = VBOXVDMACMD_CHROMIUM_CTL_TYPE_CRHGSMI_SETUP_MAINCB;
    34073426        Completion.Hdr.cbCmd = sizeof (Completion);
    34083427        Completion.hCompletion = mpDrv->pVBVACallbacks;
     
    34283447                pFb->pendingViewportInfo.fPending = false;
    34293448            }
     3449
     3450            mCrOglCallbacks = Completion.MainInterface;
    34303451
    34313452            return;
     
    36543675    if (VideoRecIsEnabled(pDisplay->mpVideoRecCtx))
    36553676    {
    3656         uint64_t u64Now = RTTimeProgramMilliTS();
    3657         for (uScreenId = 0; uScreenId < pDisplay->mcMonitors; uScreenId++)
    3658         {
    3659             if (!pDisplay->maVideoRecEnabled[uScreenId])
    3660                 continue;
    3661 
    3662             DISPLAYFBINFO *pFBInfo = &pDisplay->maFramebuffers[uScreenId];
    3663 
    3664             if (   !pFBInfo->pFramebuffer.isNull()
    3665                 && !pFBInfo->fDisabled
    3666                 && pFBInfo->u32ResizeStatus == ResizeStatus_Void)
     3677        do {
     3678#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
     3679            BOOL is3denabled;
     3680            pDisplay->mParent->machine()->COMGETTER(Accelerate3DEnabled)(&is3denabled);
     3681            if (is3denabled)
    36673682            {
    3668                 int rc;
    3669                 if (   pFBInfo->fVBVAEnabled
    3670                     && pFBInfo->pu8FramebufferVRAM)
     3683                if (ASMAtomicCmpXchgU32(&pDisplay->mfCrOglVideoRecState, CRVREC_STATE_SUBMITTED, CRVREC_STATE_IDLE))
    36713684                {
    3672                     rc = VideoRecCopyToIntBuf(pDisplay->mpVideoRecCtx, uScreenId, 0, 0,
    3673                                               FramebufferPixelFormat_FOURCC_RGB,
    3674                                               pFBInfo->u16BitsPerPixel,
    3675                                               pFBInfo->u32LineSize, pFBInfo->w, pFBInfo->h,
    3676                                               pFBInfo->pu8FramebufferVRAM, u64Now);
     3685                    if (pDisplay->mCrOglCallbacks.pfnHasData())
     3686                    {
     3687                        /* submit */
     3688
     3689                        VBOXHGCMSVCPARM parm;
     3690
     3691                        parm.type = VBOX_HGCM_SVC_PARM_PTR;
     3692                        parm.u.pointer.addr = &pDisplay->mCrOglScreenshotData;
     3693                        parm.u.pointer.size = sizeof (pDisplay->mCrOglScreenshotData);
     3694
     3695                        VMMDev *pVMMDev = pDisplay->mParent->getVMMDev();
     3696                        if (pVMMDev)
     3697                        {
     3698                            int rc = pVMMDev->hgcmHostFastCallAsync(pDisplay->mhCrOglSvc, SHCRGL_HOST_FN_TAKE_SCREENSHOT, &parm, displayVRecCompletion, pDisplay);
     3699                            if (RT_SUCCESS(rc))
     3700                                break;
     3701                            else
     3702                                AssertMsgFailed(("hgcmHostFastCallAsync failed %f\n", rc));
     3703                        }
     3704                        else
     3705                            AssertMsgFailed(("no VMMDev\n"));
     3706                    }
     3707
     3708                    /* no 3D data available, or error has occured,
     3709                     * go the straight way */
     3710                    ASMAtomicWriteU32(&pDisplay->mfCrOglVideoRecState, CRVREC_STATE_IDLE);
    36773711                }
    36783712                else
    36793713                {
    3680                     rc = VideoRecCopyToIntBuf(pDisplay->mpVideoRecCtx, uScreenId, 0, 0,
    3681                                               FramebufferPixelFormat_FOURCC_RGB,
    3682                                               pDrv->IConnector.cBits,
    3683                                               pDrv->IConnector.cbScanline, pDrv->IConnector.cx,
    3684                                               pDrv->IConnector.cy, pDrv->IConnector.pu8Data, u64Now);
     3714                    /* record request is still in progress, don't do anything */
     3715                    break;
    36853716                }
    3686                 if (rc == VINF_TRY_AGAIN)
    3687                     break;
    36883717            }
    3689         }
     3718#endif
     3719            uint64_t u64Now = RTTimeProgramMilliTS();
     3720            for (uScreenId = 0; uScreenId < pDisplay->mcMonitors; uScreenId++)
     3721            {
     3722                if (!pDisplay->maVideoRecEnabled[uScreenId])
     3723                    continue;
     3724
     3725                DISPLAYFBINFO *pFBInfo = &pDisplay->maFramebuffers[uScreenId];
     3726
     3727                if (   !pFBInfo->pFramebuffer.isNull()
     3728                    && !pFBInfo->fDisabled
     3729                    && pFBInfo->u32ResizeStatus == ResizeStatus_Void)
     3730                {
     3731                    int rc;
     3732                    if (   pFBInfo->fVBVAEnabled
     3733                        && pFBInfo->pu8FramebufferVRAM)
     3734                    {
     3735                        rc = VideoRecCopyToIntBuf(pDisplay->mpVideoRecCtx, uScreenId, 0, 0,
     3736                                                  FramebufferPixelFormat_FOURCC_RGB,
     3737                                                  pFBInfo->u16BitsPerPixel,
     3738                                                  pFBInfo->u32LineSize, pFBInfo->w, pFBInfo->h,
     3739                                                  pFBInfo->pu8FramebufferVRAM, u64Now);
     3740                    }
     3741                    else
     3742                    {
     3743                        rc = VideoRecCopyToIntBuf(pDisplay->mpVideoRecCtx, uScreenId, 0, 0,
     3744                                                  FramebufferPixelFormat_FOURCC_RGB,
     3745                                                  pDrv->IConnector.cBits,
     3746                                                  pDrv->IConnector.cbScanline, pDrv->IConnector.cx,
     3747                                                  pDrv->IConnector.cy, pDrv->IConnector.pu8Data, u64Now);
     3748                    }
     3749                    if (rc == VINF_TRY_AGAIN)
     3750                        break;
     3751                }
     3752            }
     3753        } while (0);
    36903754    }
    36913755#endif
     
    41394203    if (pParam->type == VBOX_HGCM_SVC_PARM_PTR && pParam->u.pointer.addr)
    41404204        RTMemFree(pParam->u.pointer.addr);
     4205}
     4206
     4207
     4208void  Display::handleCrVRecScreenshot(uint32_t uScreen,
     4209                uint32_t x, uint32_t y, uint32_t uPixelFormat, uint32_t uBitsPerPixel,
     4210                uint32_t uBytesPerLine, uint32_t uGuestWidth, uint32_t uGuestHeight,
     4211                uint8_t *pu8BufferAddress, uint64_t u64TimeStamp)
     4212{
     4213    Assert(mfCrOglVideoRecState == CRVREC_STATE_SUBMITTED);
     4214    int rc = VideoRecCopyToIntBuf(mpVideoRecCtx, uScreen, x, y,
     4215                              uPixelFormat,
     4216                              uBitsPerPixel, uBytesPerLine,
     4217                              uGuestWidth, uGuestHeight,
     4218                              pu8BufferAddress, u64TimeStamp);
     4219    Assert(rc == VINF_SUCCESS || rc == VERR_TRY_AGAIN || rc == VINF_TRY_AGAIN);
     4220}
     4221
     4222void  Display::handleVRecCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam, void *pvContext)
     4223{
     4224    Assert(mfCrOglVideoRecState == CRVREC_STATE_SUBMITTED);
     4225    ASMAtomicWriteU32(&mfCrOglVideoRecState, CRVREC_STATE_IDLE);
     4226}
     4227
     4228DECLCALLBACK(void) Display::displayCrVRecScreenshot(void *pvCtx, uint32_t uScreen,
     4229                uint32_t x, uint32_t y, uint32_t uBitsPerPixel,
     4230                uint32_t uBytesPerLine, uint32_t uGuestWidth, uint32_t uGuestHeight,
     4231                uint8_t *pu8BufferAddress, uint64_t u64TimeStamp)
     4232{
     4233    Display *pDisplay = (Display *)pvCtx;
     4234    pDisplay->handleCrVRecScreenshot(uScreen,
     4235            x, y, FramebufferPixelFormat_FOURCC_RGB, uBitsPerPixel,
     4236            uBytesPerLine, uGuestWidth, uGuestHeight,
     4237            pu8BufferAddress, u64TimeStamp);
     4238}
     4239
     4240DECLCALLBACK(void)  Display::displayVRecCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam, void *pvContext)
     4241{
     4242    Display *pDisplay = (Display *)pvContext;
     4243    pDisplay->handleVRecCompletion(result, u32Function, pParam, pvContext);
    41414244}
    41424245
  • trunk/src/VBox/Main/src-client/VideoRec.h

    r50041 r50313  
    3232int  VideoRecCopyToIntBuf(PVIDEORECCONTEXT pCtx, uint32_t uScreen,
    3333                          uint32_t x, uint32_t y, uint32_t uPixelFormat, uint32_t uBitsPerPixel,
    34                           uint32_t uBytesPerLine, uint32_t uGuestHeight, uint32_t uGuestWidth,
     34                          uint32_t uBytesPerLine, uint32_t uGuestWidth, uint32_t uGuestHeight,
    3535                          uint8_t *pu8BufferAddress, uint64_t u64TimeStamp);
    3636
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette