VirtualBox

Changeset 42878 in vbox for trunk


Ignore:
Timestamp:
Aug 20, 2012 10:00:07 AM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
80158
Message:

Main/VideoRec: a few fixes

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

Legend:

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

    r42248 r42878  
    2828
    2929class Console;
     30struct VIDEORECCONTEXT;
    3031
    3132enum {
     
    294295    volatile uint32_t mu32UpdateVBVAFlags;
    295296#endif
     297
     298#ifdef VBOX_WITH_VPX
     299    VIDEORECCONTEXT *mpVideoRecContext;
     300#endif
    296301};
    297302
  • trunk/src/VBox/Main/src-client/DisplayImpl.cpp

    r42861 r42878  
    5050#ifdef VBOX_WITH_VPX
    5151# include "VideoRec.h"
    52   PVIDEORECCONTEXT pVideoRecContext;
    5352#endif
     53
    5454/**
    5555 * Display driver instance data.
     
    428428 * @param qemuConsoleData address of common console data structure
    429429 */
    430 HRESULT Display::init (Console *aParent)
     430HRESULT Display::init(Console *aParent)
    431431{
    432432    ComAssertRet(aParent, E_INVALIDARG);
    433     HRESULT res;
    434433    /* Enclose the state transition NotReady->InInit->Ready */
    435434    AutoInitSpan autoInitSpan(this);
     
    444443    ULONG ul;
    445444    mParent->machine()->COMGETTER(MonitorCount)(&ul);
     445
    446446#ifdef VBOX_WITH_VPX
    447     ULONG ulVideoCaptureHorzRes;
    448     ULONG ulVideoCaptureVertRes;
    449     BSTR strVideoCaptureFile;
    450447    BOOL fEnabled = false;
    451     if (VideoRecContextCreate(&pVideoRecContext))
    452     {
    453         LogFlow(("Failed to create Video Recording Context \n"));
     448    if (VideoRecContextCreate(&mpVideoRecContext))
     449    {
     450        LogFlow(("Failed to create Video Recording Context\n"));
    454451        return E_FAIL;
    455452    }
    456     res = RTCritSectInit(&pVideoRecContext->CritSect);
    457     AssertReturn(res == S_OK, E_UNEXPECTED);
    458     pVideoRecContext->fEnabled = false;
    459     mParent->machine()->COMGETTER(VideoCaptureWidth)(&ulVideoCaptureHorzRes);
    460     mParent->machine()->COMGETTER(VideoCaptureHeight)(&ulVideoCaptureVertRes);
    461     mParent->machine()->COMGETTER(VideoCaptureFile)(&strVideoCaptureFile);
     453    int rc = RTCritSectInit(&mpVideoRecContext->CritSect);
     454    AssertRCReturn(rc, E_UNEXPECTED);
     455
     456    mpVideoRecContext->fEnabled = false;
    462457    mParent->machine()->COMGETTER(VideoCaptureEnabled)(&fEnabled);
    463458    if (fEnabled)
    464459    {
    465         LogFlow(("VidoeRecording VPX enabled \n"));
    466         if (VideoRecContextInit(pVideoRecContext,strVideoCaptureFile,
    467                                   ulVideoCaptureHorzRes, ulVideoCaptureVertRes))
    468         {
    469             LogFlow(("Failed to initialize video recording context \n"));
     460        ULONG ulVideoCaptureHorzRes;
     461        mParent->machine()->COMGETTER(VideoCaptureWidth)(&ulVideoCaptureHorzRes);
     462        ULONG ulVideoCaptureVertRes;
     463        mParent->machine()->COMGETTER(VideoCaptureHeight)(&ulVideoCaptureVertRes);
     464        BSTR strVideoCaptureFile;
     465        mParent->machine()->COMGETTER(VideoCaptureFile)(&strVideoCaptureFile);
     466        LogFlow(("VidoeRecording VPX enabled\n"));
     467        if (VideoRecContextInit(mpVideoRecContext,strVideoCaptureFile,
     468                                ulVideoCaptureHorzRes, ulVideoCaptureVertRes))
     469        {
     470            LogFlow(("Failed to initialize video recording context\n"));
    470471            return E_FAIL;
    471472        }
    472         pVideoRecContext->fEnabled = true;
     473        mpVideoRecContext->fEnabled = true;
    473474    }
    474475#endif
     476
    475477    mcMonitors = ul;
    476478
     
    562564
    563565#ifdef VBOX_WITH_VPX
    564     VideoRecContextClose(pVideoRecContext);
     566    if (   mpVideoRecContext
     567        && mpVideoRecContext->fEnabled)
     568        VideoRecContextClose(mpVideoRecContext);
    565569#endif
    566570}
     
    32043208    unsigned uScreenId;
    32053209
    3206     LogFlow(("DisplayRefreshCallback \n"));
     3210    LogFlow(("DisplayRefreshCallback\n"));
    32073211    for (uScreenId = 0; uScreenId < pDisplay->mcMonitors; uScreenId++)
    32083212    {
     
    32773281
    32783282#ifdef VBOX_WITH_VPX
    3279     uint32_t u32VideoRecImgFormat = VPX_IMG_FMT_NONE;
    3280     DISPLAYFBINFO *pFBInfo = &pDisplay->maFramebuffers[VBOX_VIDEO_PRIMARY_SCREEN];
    3281     int rc;
    3282 
    3283     if (!pFBInfo->pFramebuffer.isNull() && !(pFBInfo->fDisabled)
    3284          && pFBInfo->u32ResizeStatus==ResizeStatus_Void)
    3285     {
    3286         HRESULT rc;
    3287         ULONG ulPixelFormat = 0;
    3288         rc = pFBInfo->pFramebuffer->COMGETTER(PixelFormat)(&ulPixelFormat);
    3289         AssertComRC (rc);
    3290 
    3291         ULONG ulBitsPerPixel;
    3292         rc = pFBInfo->pFramebuffer->COMGETTER(BitsPerPixel)(&ulBitsPerPixel);
    3293         AssertComRC (rc);
    3294 
    3295         ULONG ulGuestHeight = 0;
    3296         rc = pFBInfo->pFramebuffer->COMGETTER(Height)(&ulGuestHeight);
    3297         AssertComRC (rc);
    3298 
    3299         ULONG ulGuestWidth = 0;
    3300         rc = pFBInfo->pFramebuffer->COMGETTER(Width)(&ulGuestWidth);
    3301         AssertComRC (rc);
    3302 
    3303         BYTE *address = NULL;
    3304         rc = pFBInfo->pFramebuffer->COMGETTER(Address) (&address);
    3305         AssertComRC (rc);
    3306 
    3307         ULONG ulBytesPerLine = 0;
    3308         rc = pFBInfo->pFramebuffer->COMGETTER(BytesPerLine) (&ulBytesPerLine);
    3309         AssertComRC (rc);
    3310 
    3311         if(ulPixelFormat == FramebufferPixelFormat_FOURCC_RGB)
    3312         {
    3313             switch (ulBitsPerPixel)
     3283    if (pDisplay->mpVideoRecContext->fEnabled)
     3284    {
     3285        uint32_t u32VideoRecImgFormat = VPX_IMG_FMT_NONE;
     3286        DISPLAYFBINFO *pFBInfo = &pDisplay->maFramebuffers[VBOX_VIDEO_PRIMARY_SCREEN];
     3287
     3288        if (    !pFBInfo->pFramebuffer.isNull()
     3289            && !(pFBInfo->fDisabled)
     3290            && pFBInfo->u32ResizeStatus == ResizeStatus_Void)
     3291        {
     3292            HRESULT rc;
     3293            ULONG ulPixelFormat = 0;
     3294            rc = pFBInfo->pFramebuffer->COMGETTER(PixelFormat)(&ulPixelFormat);
     3295            AssertComRC(rc);
     3296
     3297            ULONG ulBitsPerPixel;
     3298            rc = pFBInfo->pFramebuffer->COMGETTER(BitsPerPixel)(&ulBitsPerPixel);
     3299            AssertComRC(rc);
     3300
     3301            ULONG ulGuestHeight = 0;
     3302            rc = pFBInfo->pFramebuffer->COMGETTER(Height)(&ulGuestHeight);
     3303            AssertComRC(rc);
     3304
     3305            ULONG ulGuestWidth = 0;
     3306            rc = pFBInfo->pFramebuffer->COMGETTER(Width)(&ulGuestWidth);
     3307            AssertComRC(rc);
     3308
     3309            BYTE *address = NULL;
     3310            rc = pFBInfo->pFramebuffer->COMGETTER(Address)(&address);
     3311            AssertComRC(rc);
     3312
     3313            ULONG ulBytesPerLine = 0;
     3314            rc = pFBInfo->pFramebuffer->COMGETTER(BytesPerLine)(&ulBytesPerLine);
     3315            AssertComRC(rc);
     3316
     3317            if (ulPixelFormat == FramebufferPixelFormat_FOURCC_RGB)
    33143318            {
    3315                 case 32:
    3316                     u32VideoRecImgFormat = VPX_IMG_FMT_RGB32;
    3317                     Log2(("FFmpeg::RequestResize: setting ffmpeg pixel format to VPX_IMG_FMT_RGB32\n"));
    3318                     break;
    3319                 case 24:
    3320                     u32VideoRecImgFormat = VPX_IMG_FMT_RGB24;
    3321                     Log2(("FFmpeg::RequestResize: setting ffmpeg pixel format to VPX_IMG_FMT_RGB24\n"));
    3322                     break;
    3323                 case 16:
    3324                     u32VideoRecImgFormat = VPX_IMG_FMT_RGB565;
    3325                     Log2(("FFmpeg::RequestResize: setting ffmpeg pixel format to VPX_IMG_FMT_RGB565\n"));
    3326                     break;
    3327                 default:
    3328                     Log2(("No Proper Format detected\n"));
    3329 
     3319                switch (ulBitsPerPixel)
     3320                {
     3321                    case 32:
     3322                        u32VideoRecImgFormat = VPX_IMG_FMT_RGB32;
     3323                        Log2(("FFmpeg::RequestResize: setting ffmpeg pixel format to VPX_IMG_FMT_RGB32\n"));
     3324                        break;
     3325                    case 24:
     3326                        u32VideoRecImgFormat = VPX_IMG_FMT_RGB24;
     3327                        Log2(("FFmpeg::RequestResize: setting ffmpeg pixel format to VPX_IMG_FMT_RGB24\n"));
     3328                        break;
     3329                    case 16:
     3330                        u32VideoRecImgFormat = VPX_IMG_FMT_RGB565;
     3331                        Log2(("FFmpeg::RequestResize: setting ffmpeg pixel format to VPX_IMG_FMT_RGB565\n"));
     3332                        break;
     3333                    default:
     3334                        Log2(("No Proper Format detected\n"));
     3335                        break;
     3336                }
    33303337            }
    3331         }
    3332 
    3333         if (u32VideoRecImgFormat != VPX_IMG_FMT_NONE && address != NULL
    3334             && pVideoRecContext->fEnabled)
    3335         {
    3336             VideoRecCopyToIntBuffer(pVideoRecContext, pFBInfo->xOrigin, pFBInfo->yOrigin,
    3337                               ulPixelFormat, ulBitsPerPixel, ulBytesPerLine,
    3338                               ulGuestWidth, ulGuestHeight, address);
    3339 
    3340             VideoRecDoRGBToYUV(pVideoRecContext, u32VideoRecImgFormat);
    3341             VideoRecEncodeAndWrite(pVideoRecContext, ulGuestWidth, ulGuestHeight);
     3338
     3339            if (   u32VideoRecImgFormat != VPX_IMG_FMT_NONE
     3340                && address)
     3341            {
     3342                VideoRecCopyToIntBuffer(pDisplay->mpVideoRecContext, pFBInfo->xOrigin, pFBInfo->yOrigin,
     3343                                        ulPixelFormat, ulBitsPerPixel, ulBytesPerLine,
     3344                                        ulGuestWidth, ulGuestHeight, address);
     3345
     3346                VideoRecDoRGBToYUV(pDisplay->mpVideoRecContext, u32VideoRecImgFormat);
     3347                VideoRecEncodeAndWrite(pDisplay->mpVideoRecContext, ulGuestWidth, ulGuestHeight);
     3348            }
    33423349        }
    33433350    }
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