VirtualBox

Changeset 51504 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jun 3, 2014 8:43:49 AM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
94118
Message:

VBoxHeadless: use VideoCapture API.

Location:
trunk/src/VBox/Frontends/VBoxHeadless
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxHeadless/Makefile.kmk

    r48950 r51504  
    4444#
    4545VBoxHeadless_TEMPLATE  := $(if $(VBOX_WITH_HARDENING),VBOXMAINCLIENTDLL,VBOXMAINCLIENTEXE)
    46 VBoxHeadless_DEFS      += \
    47                  VBOX_WITH_VIDEO_REC
     46VBoxHeadless_DEFS      += $(if $(VBOX_WITH_VPX),VBOX_WITH_VPX,)
    4847VBoxHeadless_SOURCES    = VBoxHeadless.cpp
    4948VBoxHeadless_SOURCES  += Framebuffer.cpp
  • trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp

    r51436 r51504  
    4343#include <VBox/VBoxVideo.h>
    4444
    45 #ifdef VBOX_WITH_VIDEO_REC
    46 #include <cstdlib>
    47 #include <cerrno>
    48 #include "VBoxHeadless.h"
    49 #include <iprt/env.h>
    50 #include <iprt/param.h>
     45#ifdef VBOX_WITH_VPX
    5146#include <iprt/process.h>
    52 #include <VBox/sup.h>
    5347#endif
    5448
     
    510504             "   --settingspw <pw>                     Specify the settings password\n"
    511505             "   --settingspwfile <file>               Specify a file containing the settings password\n"
    512 #ifdef VBOX_WITH_VIDEO_REC
     506#ifdef VBOX_WITH_VPX
    513507             "   -c, -capture, --capture               Record the VM screen output to a file\n"
    514508             "   -w, --width                           Frame width when recording\n"
     
    521515}
    522516
    523 #ifdef VBOX_WITH_VIDEO_REC
     517#ifdef VBOX_WITH_VPX
    524518/**
    525519 * Parse the environment for variables which can influence the VIDEOREC settings.
     
    570564        *ppszFileName = pszEnvTemp;
    571565}
    572 #endif /* VBOX_WITH_VIDEO_REC defined */
     566#endif /* VBOX_WITH_VPX defined */
    573567
    574568static RTEXITCODE readPasswordFile(const char *pszFilename, com::Utf8Str *pPasswd)
     
    656650    unsigned fPATM  = ~0U;
    657651    unsigned fCSAM  = ~0U;
    658 #ifdef VBOX_WITH_VIDEO_REC
     652#ifdef VBOX_WITH_VPX
    659653    bool fVideoRec = 0;
    660654    unsigned long ulFrameWidth = 800;
     
    663657    char szMpegFile[RTPATH_MAX];
    664658    const char *pszFileNameParam = "VBox-%d.vob";
    665 #endif /* VBOX_WITH_VIDEO_REC */
     659#endif /* VBOX_WITH_VPX */
    666660
    667661    LogFlow(("VBoxHeadless STARTED.\n"));
     
    670664             "All rights reserved.\n\n");
    671665
    672 #ifdef VBOX_WITH_VIDEO_REC
     666#ifdef VBOX_WITH_VPX
    673667    /* Parse the environment */
    674668    parse_environ(&ulFrameWidth, &ulFrameHeight, &ulBitRate, &pszFileNameParam);
     
    722716        { "--settingspw", OPT_SETTINGSPW, RTGETOPT_REQ_STRING },
    723717        { "--settingspwfile", OPT_SETTINGSPW_FILE, RTGETOPT_REQ_STRING },
    724 #ifdef VBOX_WITH_VIDEO_REC
     718#ifdef VBOX_WITH_VPX
    725719        { "-capture", 'c', 0 },
    726720        { "--capture", 'c', 0 },
     
    729723        { "--bitrate", 'r', RTGETOPT_REQ_UINT32 },
    730724        { "--filename", 'f', RTGETOPT_REQ_STRING },
    731 #endif /* VBOX_WITH_VIDEO_REC defined */
     725#endif /* VBOX_WITH_VPX defined */
    732726        { "-comment", OPT_COMMENT, RTGETOPT_REQ_STRING },
    733727        { "--comment", OPT_COMMENT, RTGETOPT_REQ_STRING }
     
    797791                pcszSettingsPwFile = ValueUnion.psz;
    798792                break;
    799 #ifdef VBOX_WITH_VIDEO_REC
     793#ifdef VBOX_WITH_VPX
    800794            case 'c':
    801795                fVideoRec = true;
     
    810804                pszFileNameParam = ValueUnion.psz;
    811805                break;
    812 #endif /* VBOX_WITH_VIDEO_REC defined */
     806#endif /* VBOX_WITH_VPX defined */
    813807            case 'h':
    814 #ifdef VBOX_WITH_VIDEO_REC
     808#ifdef VBOX_WITH_VPX
    815809                if ((GetState.pDef->fFlags & RTGETOPT_REQ_MASK) != RTGETOPT_REQ_NOTHING)
    816810                {
     
    834828    }
    835829
    836 #ifdef VBOX_WITH_VIDEO_REC
     830#ifdef VBOX_WITH_VPX
    837831    if (ulFrameWidth < 512 || ulFrameWidth > 2048 || ulFrameWidth % 2)
    838832    {
     
    864858    }
    865859    RTStrPrintf(&szMpegFile[0], RTPATH_MAX, pszFileNameParam, RTProcSelf());
    866 #endif /* defined VBOX_WITH_VIDEO_REC */
     860#endif /* defined VBOX_WITH_VPX */
    867861
    868862    if (!pcszNameOrUUID)
     
    972966        CHECK_ERROR_BREAK(console, COMGETTER(Display)(display.asOutParam()));
    973967
    974 #ifdef VBOX_WITH_VIDEO_REC
    975         IFramebuffer *pFramebuffer = 0;
    976         RTLDRMOD hLdrVideoRecFB;
    977         PFNREGISTERVIDEORECFB pfnRegisterVideoRecFB;
    978 
     968#ifdef VBOX_WITH_VPX
    979969        if (fVideoRec)
    980970        {
    981             HRESULT         rcc = S_OK;
    982             int             rrc = VINF_SUCCESS;
    983             RTERRINFOSTATIC ErrInfo;
    984 
    985             Log2(("VBoxHeadless: loading VBoxVideoRecFB and libvpx shared library\n"));
    986             RTErrInfoInitStatic(&ErrInfo);
    987             rrc = SUPR3HardenedLdrLoadAppPriv("VBoxVideoRecFB", &hLdrVideoRecFB, RTLDRLOAD_FLAGS_LOCAL, &ErrInfo.Core);
    988 
    989             if (RT_SUCCESS(rrc))
    990             {
    991                 Log2(("VBoxHeadless: looking up symbol VBoxRegisterVideoRecFB\n"));
    992                 rrc = RTLdrGetSymbol(hLdrVideoRecFB, "VBoxRegisterVideoRecFB",
    993                                      reinterpret_cast<void **>(&pfnRegisterVideoRecFB));
    994                 if (RT_FAILURE(rrc))
    995                     LogError("Failed to load the video capture extension, possibly due to a damaged file\n", rrc);
    996             }
    997             else
    998                 LogError("Failed to load the video capture extension\n", rrc); /** @todo stupid function, no formatting options. */
    999             if (RT_SUCCESS(rrc))
    1000             {
    1001                 Log2(("VBoxHeadless: calling pfnRegisterVideoRecFB\n"));
    1002                 rcc = pfnRegisterVideoRecFB(ulFrameWidth, ulFrameHeight, ulBitRate,
    1003                                          szMpegFile, &pFramebuffer);
    1004                 if (rcc != S_OK)
    1005                     LogError("Failed to initialise video capturing - make sure that the file format\n"
    1006                              "you wish to use is supported on your system\n", rcc);
    1007             }
    1008             if (RT_SUCCESS(rrc) && rcc == S_OK)
    1009             {
    1010                 Log2(("VBoxHeadless: Registering framebuffer\n"));
    1011                 pFramebuffer->AddRef();
    1012                 display->AttachFramebuffer(VBOX_VIDEO_PRIMARY_SCREEN, pFramebuffer);
    1013             }
    1014             if (!RT_SUCCESS(rrc) || rcc != S_OK)
    1015                 rc = E_FAIL;
    1016         }
    1017         if (rc != S_OK)
    1018         {
    1019             break;
    1020         }
    1021 #endif /* defined(VBOX_WITH_VIDEO_REC) */
     971            CHECK_ERROR_BREAK(machine, COMSETTER(VideoCaptureFile)(Bstr(szMpegFile).raw()));
     972            CHECK_ERROR_BREAK(machine, COMSETTER(VideoCaptureWidth)(ulFrameWidth));
     973            CHECK_ERROR_BREAK(machine, COMSETTER(VideoCaptureHeight)(ulFrameHeight));
     974            CHECK_ERROR_BREAK(machine, COMSETTER(VideoCaptureRate)(ulBitRate));
     975            CHECK_ERROR_BREAK(machine, COMSETTER(VideoCaptureEnabled)(TRUE));
     976        }
     977#endif /* defined(VBOX_WITH_VPX) */
    1022978        ULONG cMonitors = 1;
    1023979        machine->COMGETTER(MonitorCount)(&cMonitors);
     
    1026982        for (uScreenId = 0; uScreenId < cMonitors; uScreenId++)
    1027983        {
    1028 # ifdef VBOX_WITH_VIDEO_REC
    1029             if (fVideoRec && uScreenId == 0)
    1030             {
    1031                 /* Already registered. */
    1032                 continue;
    1033             }
    1034 # endif
    1035984            VRDPFramebuffer *pVRDPFramebuffer = new VRDPFramebuffer();
    1036985            if (!pVRDPFramebuffer)
     
    13161265        Log(("VBoxHeadless: event loop has terminated...\n"));
    13171266
    1318 #ifdef VBOX_WITH_VIDEO_REC
    1319         if (pFramebuffer)
    1320         {
    1321             pFramebuffer->Release();
    1322             Log(("Released framebuffer\n"));
    1323             pFramebuffer = NULL;
    1324         }
    1325 #endif /* defined(VBOX_WITH_VIDEO_REC) */
     1267#ifdef VBOX_WITH_VPX
     1268        if (fVideoRec)
     1269        {
     1270            if (!machine.isNull())
     1271                machine->COMSETTER(VideoCaptureEnabled)(FALSE);
     1272        }
     1273#endif /* defined(VBOX_WITH_VPX) */
    13261274
    13271275        /* we don't have to disable VRDE here because we don't save the settings of the VM */
  • trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.h

    r44528 r51504  
    22 *
    33 * VBox frontends: VRDE (headless Remote Desktop server):
    4  * Header file with registration call for VideoRec framebuffer
    54 */
    65
    76/*
    8  * Copyright (C) 2006-2012 Oracle Corporation
     7 * Copyright (C) 2006-2014 Oracle Corporation
    98 *
    109 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3029#include <iprt/critsect.h>
    3130
    32 /**
    33  * Callback function to register an VideoRec framebuffer.
    34  *
    35  * @returns COM status code.
    36  * @param   width        Framebuffer width.
    37  * @param   height       Framebuffer height.
    38  * @param   bitrate      Bitrate of mpeg file to be created.
    39  * @param   pixelFormat  Framebuffer pixel format
    40  * @param   filename     Name of mpeg file to be created
    41  * @retval  retVal       The new framebuffer
    42  */
    43 typedef DECLCALLBACK(HRESULT) FNREGISTERVIDEORECFB(ULONG width,
    44                                      ULONG height, ULONG bitrate,
    45                                      com::Bstr filename,
    46                                      IFramebuffer **retVal);
    47 typedef FNREGISTERVIDEORECFB *PFNREGISTERVIDEORECFB;
    48 
    4931#endif // __H_VBOXHEADLESS
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