VirtualBox

Ignore:
Timestamp:
Nov 5, 2018 6:25:50 PM (6 years ago)
Author:
vboxsync
Message:

Capturing/VBoxHeadless: A bit of cleanup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp

    r75252 r75253  
    484484 * @param ppszFileName may be updated with a desired file name
    485485 */
    486 static void parse_environ(unsigned long *pulFrameWidth, unsigned long *pulFrameHeight,
    487                           unsigned long *pulBitRate, const char **ppszFileName)
     486static void parse_environ(uint32_t *pulFrameWidth, uint32_t *pulFrameHeight,
     487                          uint32_t *pulBitRate, const char **ppszFileName)
    488488{
    489489    const char *pszEnvTemp;
     
    627627    unsigned fPaused = 0;
    628628#ifdef VBOX_WITH_VIDEOREC
    629     bool fVideoRec = false;
    630     unsigned long ulFrameWidth = 800;
    631     unsigned long ulFrameHeight = 600;
    632     unsigned long ulBitRate = 300000; /** @todo r=bird: The COM type ULONG isn't unsigned long, it's 32-bit unsigned int. */
    633     char szMpegFile[RTPATH_MAX];
    634     const char *pszFileNameParam = "VBox-%d.vob";
     629    bool fCaptureEnabled = false;
     630    uint32_t ulCaptureVideoWidth = 800;
     631    uint32_t ulCaptureVideoHeight = 600;
     632    uint32_t ulCaptureVideoRate = 300000;
     633    char szCaptureFileName[RTPATH_MAX];
     634    const char *pszCaptureFileNameTemplate = "VBox-%d.webm"; /* .webm container by default. */
    635635#endif /* VBOX_WITH_VIDEOREC */
    636636#ifdef RT_OS_WINDOWS
     
    645645#ifdef VBOX_WITH_VIDEOREC
    646646    /* Parse the environment */
    647     parse_environ(&ulFrameWidth, &ulFrameHeight, &ulBitRate, &pszFileNameParam);
     647    parse_environ(&ulCaptureVideoWidth, &ulCaptureVideoHeight, &ulCaptureVideoRate, &pszCaptureFileNameTemplate);
    648648#endif
    649649
     
    782782#ifdef VBOX_WITH_VIDEOREC
    783783            case 'c':
    784                 fVideoRec = true;
     784                fCaptureEnabled = true;
    785785                break;
    786786            case 'w':
    787                 ulFrameWidth = ValueUnion.u32;
     787                ulCaptureVideoWidth = ValueUnion.u32;
    788788                break;
    789789            case 'r':
    790                 ulBitRate = ValueUnion.u32;
     790                ulCaptureVideoRate = ValueUnion.u32;
    791791                break;
    792792            case 'f':
    793                 pszFileNameParam = ValueUnion.psz;
     793                pszCaptureFileNameTemplate = ValueUnion.psz;
    794794                break;
    795795#endif /* VBOX_WITH_VIDEOREC defined */
     
    798798                if ((GetState.pDef->fFlags & RTGETOPT_REQ_MASK) != RTGETOPT_REQ_NOTHING)
    799799                {
    800                     ulFrameHeight = ValueUnion.u32;
     800                    ulCaptureVideoHeight = ValueUnion.u32;
    801801                    break;
    802802                }
     
    818818
    819819#ifdef VBOX_WITH_VIDEOREC
    820     if (ulFrameWidth < 512 || ulFrameWidth > 2048 || ulFrameWidth % 2)
     820    if (ulCaptureVideoWidth < 512 || ulCaptureVideoWidth > 2048 || ulCaptureVideoWidth % 2)
    821821    {
    822822        LogError("VBoxHeadless: ERROR: please specify an even frame width between 512 and 2048", 0);
    823823        return 1;
    824824    }
    825     if (ulFrameHeight < 384 || ulFrameHeight > 1536 || ulFrameHeight % 2)
     825    if (ulCaptureVideoHeight < 384 || ulCaptureVideoHeight > 1536 || ulCaptureVideoHeight % 2)
    826826    {
    827827        LogError("VBoxHeadless: ERROR: please specify an even frame height between 384 and 1536", 0);
    828828        return 1;
    829829    }
    830     if (ulBitRate < 300000 || ulBitRate > 1000000)
     830    if (ulCaptureVideoRate < 300000 || ulCaptureVideoRate > 1000000)
    831831    {
    832832        LogError("VBoxHeadless: ERROR: please specify an even bitrate between 300000 and 1000000", 0);
     
    834834    }
    835835    /* Make sure we only have %d or %u (or none) in the file name specified */
    836     char *pcPercent = (char*)strchr(pszFileNameParam, '%');
     836    char *pcPercent = (char*)strchr(pszCaptureFileNameTemplate, '%');
    837837    if (pcPercent != 0 && *(pcPercent + 1) != 'd' && *(pcPercent + 1) != 'u')
    838838    {
     
    846846        return 1;
    847847    }
    848     RTStrPrintf(&szMpegFile[0], RTPATH_MAX, pszFileNameParam, RTProcSelf());
     848    RTStrPrintf(&szCaptureFileName[0], RTPATH_MAX, pszCaptureFileNameTemplate, RTProcSelf());
    849849#endif /* defined VBOX_WITH_VIDEOREC */
    850850
     
    959959
    960960#ifdef VBOX_WITH_VIDEOREC
    961         if (fVideoRec)
     961        if (fCaptureEnabled)
    962962        {
    963963            ComPtr<ICaptureSettings> captureSettings;
     
    972972            {
    973973                CHECK_ERROR_BREAK(saCaptureScreenScreens[i], COMSETTER(Enabled)(TRUE));
    974                 CHECK_ERROR_BREAK(saCaptureScreenScreens[i], COMSETTER(FileName)(Bstr(szMpegFile).raw()));
    975                 CHECK_ERROR_BREAK(saCaptureScreenScreens[i], COMSETTER(VideoWidth)(ulFrameWidth));
    976                 CHECK_ERROR_BREAK(saCaptureScreenScreens[i], COMSETTER(VideoHeight)(ulFrameHeight));
    977                 CHECK_ERROR_BREAK(saCaptureScreenScreens[i], COMSETTER(VideoRate)(ulBitRate));
     974                CHECK_ERROR_BREAK(saCaptureScreenScreens[i], COMSETTER(FileName)(Bstr(szCaptureFileName).raw()));
     975                CHECK_ERROR_BREAK(saCaptureScreenScreens[i], COMSETTER(VideoWidth)(ulCaptureVideoWidth));
     976                CHECK_ERROR_BREAK(saCaptureScreenScreens[i], COMSETTER(VideoHeight)(ulCaptureVideoHeight));
     977                CHECK_ERROR_BREAK(saCaptureScreenScreens[i], COMSETTER(VideoRate)(ulCaptureVideoRate));
    978978            }
    979979        }
     
    12281228
    12291229#ifdef VBOX_WITH_VIDEOREC
    1230         if (fVideoRec)
     1230        if (fCaptureEnabled)
    12311231        {
    12321232            if (!machine.isNull())
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