VirtualBox

Changeset 65221 in vbox for trunk/src


Ignore:
Timestamp:
Jan 10, 2017 11:43:13 AM (8 years ago)
Author:
vboxsync
Message:

Main/VideoRec: Be more gentle for CaseInsensitive options, renamed key "quality" to "vc_quality", added options "ac_enabled" and "vc_enabled" options to enable/disable recording of audio/video separately.

File:
1 edited

Legend:

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

    r65216 r65221  
    4343static int videoRecEncodeAndWrite(PVIDEORECSTREAM pStrm);
    4444static int videoRecRGBToYUV(PVIDEORECSTREAM pStrm);
     45
     46using namespace com;
    4547
    4648/**
     
    647649     * other important file, causing unintentional data loss. */
    648650
    649     /** @todo Make mode configurable. */
     651    vpx_codec_err_t rcv = vpx_codec_enc_config_default(DEFAULTCODEC, &pStream->Codec.VPX.Config, 0);
     652    if (rcv != VPX_CODEC_OK)
     653    {
     654        LogRel(("VideoRec: Failed to get default configuration for VPX codec: %s\n", vpx_codec_err_to_string(rcv)));
     655        return VERR_INVALID_PARAMETER;
     656    }
     657
     658    com::Utf8Str options(pszOptions);
     659    size_t pos = 0;
     660
     661    /* By default we enable both, video and audio recording (if available). */
    650662#ifdef VBOX_WITH_AUDIO_VIDEOREC
    651663    WebMWriter::Mode enmMode = WebMWriter::Mode_AudioVideo;
     
    654666#endif
    655667
    656     uint64_t fOpen = RTFILE_O_WRITE | RTFILE_O_DENY_WRITE;
    657 #ifdef DEBUG
    658     fOpen |= RTFILE_O_CREATE_REPLACE;
    659 #else
    660     fOpen |= RTFILE_O_CREATE;
    661 #endif
    662 
    663     int rc = pStream->pEBML->create(pszFile, fOpen, enmMode,
    664                                     WebMWriter::AudioCodec_Opus, WebMWriter::VideoCodec_VP8);
    665     if (RT_FAILURE(rc))
    666     {
    667         LogRel(("VideoRec: Failed to create the video capture output file '%s' (%Rrc)\n", pszFile, rc));
    668         return rc;
    669     }
    670 
    671     vpx_codec_err_t rcv = vpx_codec_enc_config_default(DEFAULTCODEC, &pStream->Codec.VPX.Config, 0);
    672     if (rcv != VPX_CODEC_OK)
    673     {
    674         LogFlow(("Failed to configure codec: %s\n", vpx_codec_err_to_string(rcv)));
    675         return VERR_INVALID_PARAMETER;
    676     }
    677 
    678     com::Utf8Str options(pszOptions);
    679     size_t pos = 0;
    680 
    681668    do {
    682669
     
    684671        pos = options.parseKeyValue(key, value, pos);
    685672
    686         if (key == "quality")
    687         {
    688             if (value == "realtime")
     673        if (key.compare("vc_quality", Utf8Str::CaseInsensitive))
     674        {
     675            if (value.compare("realtime", Utf8Str::CaseInsensitive))
    689676            {
    690677                pStream->uEncoderDeadline = VPX_DL_REALTIME;
    691678            }
    692             else if (value == "good")
     679            else if (value.compare("good", Utf8Str::CaseInsensitive))
    693680            {
    694681                pStream->uEncoderDeadline = 1000000 / uFps;
    695682            }
    696             else if (value == "best")
     683            else if (value.compare("best", Utf8Str::CaseInsensitive))
    697684            {
    698685                pStream->uEncoderDeadline = VPX_DL_BEST_QUALITY;
     
    704691            }
    705692        }
     693        if (key.compare("vc_enabled", Utf8Str::CaseInsensitive))
     694        {
     695#ifdef VBOX_WITH_AUDIO_VIDEOREC
     696            if (value.compare("false", Utf8Str::CaseInsensitive)) /* Disable audio. */
     697            {
     698                enmMode = WebMWriter::Mode_Audio;
     699                LogRel(("VideoRec: Only audio will be recorded\n"));
     700            }
     701#endif
     702        }
     703        if (key.compare("ac_enabled", Utf8Str::CaseInsensitive))
     704        {
     705#ifdef VBOX_WITH_AUDIO_VIDEOREC
     706            if (value.compare("false", Utf8Str::CaseInsensitive)) /* Disable audio. */
     707            {
     708                enmMode = WebMWriter::Mode_Video;
     709                LogRel(("VideoRec: Only video will be recorded\n"));
     710            }
     711#endif
     712        }
    706713        else
    707714            LogRel(("VideoRec: Unknown option '%s' (value '%s'), skipping\n", key.c_str(), value.c_str()));
    708715
    709716    } while(pos != com::Utf8Str::npos);
     717
     718    uint64_t fOpen = RTFILE_O_WRITE | RTFILE_O_DENY_WRITE;
     719#ifdef DEBUG
     720    fOpen |= RTFILE_O_CREATE_REPLACE;
     721#else
     722    fOpen |= RTFILE_O_CREATE;
     723#endif
     724
     725    int rc = pStream->pEBML->create(pszFile, fOpen, enmMode,
     726                                    WebMWriter::AudioCodec_Opus, WebMWriter::VideoCodec_VP8);
     727    if (RT_FAILURE(rc))
     728    {
     729        LogRel(("VideoRec: Failed to create the video capture output file '%s' (%Rrc)\n", pszFile, rc));
     730        return rc;
     731    }
    710732
    711733    /* target bitrate in kilobits per second */
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