VirtualBox

Changeset 62139 in vbox for trunk


Ignore:
Timestamp:
Jul 8, 2016 1:32:43 PM (9 years ago)
Author:
vboxsync
Message:

bugref:8389: Main: fixed video recording with VBoxheadless

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/DisplayImpl.h

    r61564 r62139  
    9595    } pendingViewportInfo;
    9696#endif /* VBOX_WITH_CROGL */
     97
     98#ifdef VBOX_WITH_VPX
     99    struct
     100    {
     101        ComPtr<IDisplaySourceBitmap> pSourceBitmap;
     102    } videoCapture;
     103#endif
    97104} DISPLAYFBINFO;
    98105
     
    195202    void i_VideoCaptureStop();
    196203    int  i_VideoCaptureEnableScreens(ComSafeArrayIn(BOOL, aScreens));
     204#ifdef VBOX_WITH_VPX
     205    void videoCaptureScreenChanged(unsigned uScreenId);
     206#endif
    197207
    198208    void i_notifyPowerDown(void);
     
    449459    /* Serializes access to mVideoAccelLegacy and mfVideoAccelVRDP, etc between VRDP and Display. */
    450460    RTCRITSECT mVideoAccelLock;
     461#ifdef VBOX_WITH_VPX
     462    /* Serializes access to video capture source bitmaps. */
     463    RTCRITSECT mVideoCaptureLock;
     464#endif
    451465
    452466public:
  • trunk/src/VBox/Main/src-client/DisplayImpl.cpp

    r61740 r62139  
    132132#endif
    133133#ifdef VBOX_WITH_VPX
     134    rc = RTCritSectInit(&mVideoCaptureLock);
     135    AssertRC(rc);
     136
    134137    mpVideoRecCtx = NULL;
    135138    for (unsigned i = 0; i < RT_ELEMENTS(maVideoRecEnabled); i++)
     
    159162{
    160163    uninit();
     164
     165#ifdef VBOX_WITH_VPX
     166    if (RTCritSectIsInitialized(&mVideoCaptureLock))
     167    {
     168        RTCritSectDelete(&mVideoCaptureLock);
     169        RT_ZERO(mVideoCaptureLock);
     170    }
     171#endif
    161172
    162173    videoAccelDestroy(&mVideoAccelLegacy);
     
    703714        maFramebuffers[uScreenId].updateImage.cbLine = 0;
    704715        maFramebuffers[uScreenId].pFramebuffer.setNull();
     716#ifdef VBOX_WITH_VPX
     717        maFramebuffers[uScreenId].videoCapture.pSourceBitmap.setNull();
     718#endif
    705719    }
    706720
     
    961975    if (mfSeamlessEnabled)
    962976        i_handleSetVisibleRegion(mcRectVisibleRegion, mpRectVisibleRegion);
     977
     978#ifdef VBOX_WITH_VPX
     979    videoCaptureScreenChanged(uScreenId);
     980#endif
    963981
    964982    LogRelFlowFunc(("[%d]: default format %d\n", uScreenId, pFBInfo->fDefaultFormat));
     
    22212239    com::SafeArray<BOOL> Screens(ComSafeArrayInArg(aScreens));
    22222240    for (unsigned i = 0; i < Screens.size(); i++)
     2241    {
     2242        bool fChanged = maVideoRecEnabled[i] != RT_BOOL(Screens[i]);
     2243
    22232244        maVideoRecEnabled[i] = RT_BOOL(Screens[i]);
     2245
     2246        if (fChanged && i < mcMonitors)
     2247            videoCaptureScreenChanged(i);
     2248
     2249    }
    22242250    return VINF_SUCCESS;
    22252251#else
     
    23302356            LogRel(("Display::VideoCaptureStart: WebM/VP8 video recording screen #%u with %ux%u @ %u kbps, %u fps to '%s' "
    23312357                    "enabled\n", uScreen, ulWidth, ulHeight, ulRate, ulFPS, pszName));
     2358
     2359            videoCaptureScreenChanged(uScreen);
    23322360        }
    23332361        else
     
    23532381    VideoRecContextClose(mpVideoRecCtx);
    23542382    mpVideoRecCtx = NULL;
    2355 #endif
    2356 }
     2383
     2384    unsigned uScreenId;
     2385    for (uScreenId = 0; uScreenId < mcMonitors; ++uScreenId)
     2386        videoCaptureScreenChanged(uScreenId);
     2387#endif
     2388}
     2389
     2390#ifdef VBOX_WITH_VPX
     2391void Display::videoCaptureScreenChanged(unsigned uScreenId)
     2392{
     2393    ComPtr<IDisplaySourceBitmap> pSourceBitmap;
     2394
     2395    if (VideoRecIsEnabled(mpVideoRecCtx) && maVideoRecEnabled[uScreenId])
     2396    {
     2397        /* Get a new source bitmap which will be used by video capture code. */
     2398        QuerySourceBitmap(uScreenId, pSourceBitmap.asOutParam());
     2399    }
     2400
     2401    int rc = RTCritSectEnter(&mVideoCaptureLock);
     2402    if (RT_SUCCESS(rc))
     2403    {
     2404        maFramebuffers[uScreenId].videoCapture.pSourceBitmap = pSourceBitmap;
     2405        RTCritSectLeave(&mVideoCaptureLock);
     2406    }
     2407}
     2408#endif
    23572409
    23582410int Display::i_drawToScreenEMT(Display *pDisplay, ULONG aScreenId, BYTE *address,
     
    31073159
    31083160                DISPLAYFBINFO *pFBInfo = &pDisplay->maFramebuffers[uScreenId];
    3109 
    3110                 if (   !pFBInfo->pFramebuffer.isNull()
    3111                     && !pFBInfo->fDisabled)
     3161                if (!pFBInfo->fDisabled)
    31123162                {
    3113                     rc = VERR_NOT_SUPPORTED;
    3114                     if (   pFBInfo->fVBVAEnabled
    3115                         && pFBInfo->pu8FramebufferVRAM)
     3163                    ComPtr<IDisplaySourceBitmap> pSourceBitmap;
     3164                    int rc2 = RTCritSectEnter(&pDisplay->mVideoCaptureLock);
     3165                    if (RT_SUCCESS(rc2))
    31163166                    {
    3117                         rc = VideoRecCopyToIntBuf(pDisplay->mpVideoRecCtx, uScreenId, 0, 0,
    3118                                                   BitmapFormat_BGR,
    3119                                                   pFBInfo->u16BitsPerPixel,
    3120                                                   pFBInfo->u32LineSize, pFBInfo->w, pFBInfo->h,
    3121                                                   pFBInfo->pu8FramebufferVRAM, u64Now);
     3167                        pSourceBitmap = pFBInfo->videoCapture.pSourceBitmap;
     3168                        RTCritSectLeave(&pDisplay->mVideoCaptureLock);
    31223169                    }
    3123                     else if (uScreenId == VBOX_VIDEO_PRIMARY_SCREEN && pDrv->IConnector.pbData)
     3170
     3171                    if (!pSourceBitmap.isNull())
    31243172                    {
    3125                         rc = VideoRecCopyToIntBuf(pDisplay->mpVideoRecCtx, uScreenId, 0, 0,
    3126                                                   BitmapFormat_BGR,
    3127                                                   pDrv->IConnector.cBits,
    3128                                                   pDrv->IConnector.cbScanline, pDrv->IConnector.cx,
    3129                                                   pDrv->IConnector.cy, pDrv->IConnector.pbData, u64Now);
     3173                        BYTE *pbAddress = NULL;
     3174                        ULONG ulWidth = 0;
     3175                        ULONG ulHeight = 0;
     3176                        ULONG ulBitsPerPixel = 0;
     3177                        ULONG ulBytesPerLine = 0;
     3178                        BitmapFormat_T bitmapFormat = BitmapFormat_Opaque;
     3179                        HRESULT hr = pSourceBitmap->QueryBitmapInfo(&pbAddress,
     3180                                                                    &ulWidth,
     3181                                                                    &ulHeight,
     3182                                                                    &ulBitsPerPixel,
     3183                                                                    &ulBytesPerLine,
     3184                                                                    &bitmapFormat);
     3185                        if (SUCCEEDED(hr) && pbAddress)
     3186                            rc = VideoRecCopyToIntBuf(pDisplay->mpVideoRecCtx, uScreenId, 0, 0,
     3187                                                      BitmapFormat_BGR,
     3188                                                      ulBitsPerPixel, ulBytesPerLine, ulWidth, ulHeight,
     3189                                                      pbAddress, u64Now);
     3190                        else
     3191                            rc = VERR_NOT_SUPPORTED;
     3192
     3193                        pSourceBitmap.setNull();
    31303194                    }
     3195                    else
     3196                        rc = VERR_NOT_SUPPORTED;
     3197
    31313198                    if (rc == VINF_TRY_AGAIN)
    31323199                        break;
Note: See TracChangeset for help on using the changeset viewer.

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