VirtualBox

Changeset 72014 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Apr 25, 2018 1:28:31 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
122275
Message:

VideoRec/Main: Simplified recoding state checking by only using the IMachine::VideoCaptureEnabled getter. A bit of renaming.

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

Legend:

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

    r71626 r72014  
    209209#ifdef VBOX_WITH_VIDEOREC
    210210    PVIDEORECCFG             i_videoRecGetConfig(void) { return &mVideoRecCfg; }
    211     VIDEORECFEATURES         i_videoRecGetEnabled(void);
     211    VIDEORECFEATURES         i_videoRecGetFeatures(void);
    212212    bool                     i_videoRecStarted(void);
    213213    void                     i_videoRecInvalidate();
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r70773 r72014  
    56605660            pDisplay->i_videoRecInvalidate();
    56615661
     5662            BOOL fEnabled;
     5663            rc = mMachine->COMGETTER(VideoCaptureEnabled)(&fEnabled);
     5664            AssertComRCReturnRC(rc);
     5665
    56625666            int vrc;
    56635667
    5664             if (!mDisplay->i_videoRecStarted())
     5668            if (fEnabled)
    56655669            {
    56665670# ifdef VBOX_WITH_AUDIO_VIDEOREC
    56675671                /* Attach the video recording audio driver if required. */
    5668                 if (mDisplay->i_videoRecGetEnabled() & VIDEORECFEATURE_AUDIO)
     5672                if (mDisplay->i_videoRecGetFeatures() & VIDEORECFEATURE_AUDIO)
    56695673                    mAudioVideoRec->doAttachDriverViaEmt(mpUVM, &alock);
    56705674# endif
     
    99949998        if (pDisplay)
    99959999        {
    9996             pDisplay->i_videoRecInvalidate();
    9997 
    9998             /* If video recording fails for whatever reason here, this is
    9999              * non-critical and should not be returned at this point -- otherwise
    10000              * the display driver construction fails completely. */
    10001             int vrc2 = VINF_SUCCESS;
     10000            BOOL fVideoRecEnabled = FALSE;
     10001            rc = pConsole->mMachine->COMGETTER(VideoCaptureEnabled)(&fVideoRecEnabled);
     10002            AssertComRCReturnVoid(rc);
     10003
     10004            if (fVideoRecEnabled)
     10005            {
     10006                pDisplay->i_videoRecInvalidate();
     10007
     10008                /* If video recording fails for whatever reason here, this is
     10009                 * non-critical and should not be returned at this point -- otherwise
     10010                 * the display driver construction fails completely. */
     10011                int vrc2 = VINF_SUCCESS;
    1000210012
    1000310013#ifdef VBOX_WITH_AUDIO_VIDEOREC
    10004             /* Attach the video recording audio driver if required. */
    10005             if (   pDisplay->i_videoRecGetEnabled() & VIDEORECFEATURE_AUDIO
    10006                 && pConsole->mAudioVideoRec)
    10007                 vrc2 = pConsole->mAudioVideoRec->doAttachDriverViaEmt(pConsole->mpUVM, &alock);
     10014                /* Attach the video recording audio driver if required. */
     10015                if (   pDisplay->i_videoRecGetFeatures() & VIDEORECFEATURE_AUDIO
     10016                    && pConsole->mAudioVideoRec)
     10017                    vrc2 = pConsole->mAudioVideoRec->doAttachDriverViaEmt(pConsole->mpUVM, &alock);
    1000810018#endif
    10009             if (   RT_SUCCESS(vrc2)
    10010                 && pDisplay->i_videoRecGetEnabled()) /* Any video recording (audio and/or video) feature enabled? */
    10011             {
    10012                 vrc2 = pDisplay->i_videoRecStart();
    10013                 if (RT_SUCCESS(vrc2))
    10014                     fireVideoCaptureChangedEvent(pConsole->i_getEventSource());
     10019                if (   RT_SUCCESS(vrc2)
     10020                    && pDisplay->i_videoRecGetFeatures()) /* Any video recording (audio and/or video) feature enabled? */
     10021                {
     10022                    vrc2 = pDisplay->i_videoRecStart();
     10023                    if (RT_SUCCESS(vrc2))
     10024                        fireVideoCaptureChangedEvent(pConsole->i_getEventSource());
     10025                }
    1001510026            }
    1001610027        }
  • trunk/src/VBox/Main/src-client/DisplayImpl.cpp

    r71651 r72014  
    24022402 * @returns Enables video capturing features.
    24032403 */
    2404 VIDEORECFEATURES Display::i_videoRecGetEnabled(void)
    2405 {
    2406     return VideoRecGetEnabled(&mVideoRecCfg);
     2404VIDEORECFEATURES Display::i_videoRecGetFeatures(void)
     2405{
     2406    return VideoRecGetFeatures(&mVideoRecCfg);
    24072407}
    24082408
     
    24142414bool Display::i_videoRecStarted(void)
    24152415{
    2416     return VideoRecIsActive(mpVideoRecCtx);
     2416    return VideoRecIsStarted(mpVideoRecCtx);
    24172417}
    24182418
     
    24312431     * Cache parameters from API.
    24322432     */
    2433     BOOL fEnabled;
    2434     HRESULT hrc = pMachine->COMGETTER(VideoCaptureEnabled)(&fEnabled);
    2435     AssertComRCReturnVoid(hrc);
    2436     mVideoRecCfg.fEnabled = RT_BOOL(fEnabled);
    2437 
    24382433    com::SafeArray<BOOL> aScreens;
    2439     hrc = pMachine->COMGETTER(VideoCaptureScreens)(ComSafeArrayAsOutParam(aScreens));
     2434    HRESULT hrc = pMachine->COMGETTER(VideoCaptureScreens)(ComSafeArrayAsOutParam(aScreens));
    24402435    AssertComRCReturnVoid(hrc);
    24412436
     
    24652460     * Set sensible defaults.
    24662461     */
    2467     mVideoRecCfg.Video.fEnabled = mVideoRecCfg.fEnabled;
     2462    mVideoRecCfg.Video.fEnabled = true; /* Enabled by default. */
    24682463
    24692464    if (!mVideoRecCfg.Video.uFPS) /* Prevent division by zero. */
     
    24742469#endif
    24752470
    2476     /* Note: Audio support is considered as being experimental, thus it's disabled by default.
    2477      * There be dragons! */
    24782471#ifdef VBOX_WITH_AUDIO_VIDEOREC
    2479     mVideoRecCfg.Audio.fEnabled  = false;
     2472    mVideoRecCfg.Audio.fEnabled  = false; /* Disabled by default, unless set otherwise below. */
    24802473    /* By default we use 48kHz, 16-bit, stereo for the audio track. */
    24812474    mVideoRecCfg.Audio.uHz       = 48000;
     
    25822575int Display::i_videoRecSendAudio(const void *pvData, size_t cbData, uint64_t uTimestampMs)
    25832576{
    2584     if (   VideoRecIsActive(mpVideoRecCtx)
    2585         && VideoRecGetEnabled(&mVideoRecCfg) & VIDEORECFEATURE_AUDIO)
     2577    if (   VideoRecIsStarted(mpVideoRecCtx)
     2578        && VideoRecGetFeatures(&mVideoRecCfg) & VIDEORECFEATURE_AUDIO)
    25862579    {
    25872580        return VideoRecSendAudioFrame(mpVideoRecCtx, pvData, cbData, uTimestampMs);
     
    25992592int Display::i_videoRecStart(void)
    26002593{
    2601     if (VideoRecIsActive(mpVideoRecCtx))
     2594    if (VideoRecIsStarted(mpVideoRecCtx))
    26022595        return VINF_SUCCESS;
     2596
     2597    LogRel(("VideoRec: Starting ...\n"));
    26032598
    26042599    int rc = VideoRecContextCreate(mcMonitors, &mVideoRecCfg, &mpVideoRecCtx);
     
    26312626void Display::i_videoRecStop(void)
    26322627{
    2633     if (!VideoRecIsActive(mpVideoRecCtx))
     2628    if (!VideoRecIsStarted(mpVideoRecCtx))
    26342629        return;
     2630
     2631    LogRel(("VideoRec: Stopping ...\n"));
    26352632
    26362633    VideoRecContextDestroy(mpVideoRecCtx);
     
    26442641void Display::i_videoRecScreenChanged(unsigned uScreenId)
    26452642{
    2646     if (   !VideoRecIsActive(mpVideoRecCtx)
     2643    if (   !VideoRecIsStarted(mpVideoRecCtx)
    26472644        || !maVideoRecEnabled[uScreenId])
    26482645    {
     
    33663363
    33673364#ifdef VBOX_WITH_VIDEOREC
    3368     if (   VideoRecIsActive(pDisplay->mpVideoRecCtx)
    3369         && VideoRecGetEnabled(&pDisplay->mVideoRecCfg) & VIDEORECFEATURE_VIDEO)
     3365    if (   VideoRecIsStarted(pDisplay->mpVideoRecCtx)
     3366        && VideoRecGetFeatures(&pDisplay->mVideoRecCfg) & VIDEORECFEATURE_VIDEO)
    33703367    {
    33713368        do {
     
    38323829    Assert(mfCrOglVideoRecState == CRVREC_STATE_SUBMITTED);
    38333830# ifdef VBOX_WITH_VIDEOREC
    3834     if (   VideoRecIsActive(mpVideoRecCtx)
    3835         && VideoRecGetEnabled(&mVideoRecCfg) & VIDEORECFEATURE_VIDEO)
     3831    if (   VideoRecIsStarted(mpVideoRecCtx)
     3832        && VideoRecGetFeatures(&mVideoRecCfg) & VIDEORECFEATURE_VIDEO)
    38363833    {
    38373834        int rc2 = VideoRecSendVideoFrame(mpVideoRecCtx, uScreen, x, y,
  • trunk/src/VBox/Main/src-client/VideoRec.cpp

    r71164 r72014  
    227227    /** Semaphore to signal the encoding worker thread. */
    228228    RTSEMEVENT          WaitEvent;
    229     /** Whether this conext is enabled or not. */
    230     bool                fEnabled;
     229    /** Whether this conext is in started state or not. */
     230    bool                fStarted;
    231231    /** Shutdown indicator. */
    232232    bool                fShutdown;
     
    721721        pCtx->tsStartMs = RTTimeMilliTS();
    722722        pCtx->enmState  = VIDEORECSTS_UNINITIALIZED;
     723        pCtx->fStarted  = false;
    723724        pCtx->fShutdown = false;
    724725
     
    738739        {
    739740            pCtx->enmState = VIDEORECSTS_INITIALIZED;
    740             pCtx->fEnabled = true;
     741            pCtx->fStarted = true;
    741742
    742743            if (ppCtx)
     
    763764    if (!pCtx)
    764765        return VINF_SUCCESS;
    765 
    766     /* First, disable the context. */
    767     ASMAtomicWriteBool(&pCtx->fEnabled, false);
    768766
    769767    if (pCtx->enmState == VIDEORECSTS_INITIALIZED)
     
    778776        if (RT_FAILURE(rc))
    779777            return rc;
     778
     779        /* Disable the context. */
     780        ASMAtomicWriteBool(&pCtx->fStarted, false);
    780781
    781782        rc = RTSemEventDestroy(pCtx->WaitEvent);
     
    10651066    PVIDEORECCFG pCfg = &pCtx->Cfg;
    10661067
    1067     pStream->pCtx          = pCtx;
     1068    pStream->pCtx = pCtx;
    10681069
    10691070    /** @todo Make the following parameters configurable on a per-stream basis? */
     
    12261227 * @param   pCfg                Pointer to recording configuration.
    12271228 */
    1228 VIDEORECFEATURES VideoRecGetEnabled(PVIDEORECCFG pCfg)
    1229 {
    1230     if (   !pCfg
    1231         || !pCfg->fEnabled)
    1232     {
     1229VIDEORECFEATURES VideoRecGetFeatures(PVIDEORECCFG pCfg)
     1230{
     1231    if (!pCfg)
    12331232        return VIDEORECFEATURE_NONE;
    1234     }
    12351233
    12361234    VIDEORECFEATURES fFeatures = VIDEORECFEATURE_NONE;
     
    12781276
    12791277/**
    1280  * Returns whether video recording for a given recording context is active or not.
     1278 * Returns whether a given recording context has been started or not.
    12811279 *
    12821280 * @returns true if active, false if not.
    12831281 * @param   pCtx                 Pointer to video recording context.
    12841282 */
    1285 bool VideoRecIsActive(PVIDEORECCONTEXT pCtx)
     1283bool VideoRecIsStarted(PVIDEORECCONTEXT pCtx)
    12861284{
    12871285    if (!pCtx)
    12881286        return false;
    12891287
    1290     return ASMAtomicReadBool(&pCtx->fEnabled);
     1288    return ASMAtomicReadBool(&pCtx->fStarted);
    12911289}
    12921290
  • trunk/src/VBox/Main/src-client/VideoRec.h

    r70035 r72014  
    5858{
    5959    VIDEORECCFG(void)
    60         : fEnabled(false)
    61         , enmDst(VIDEORECDEST_INVALID)
     60        :  enmDst(VIDEORECDEST_INVALID)
    6261        , uMaxTimeS(0)
    6362    {
     
    6968
    7069    /** Whether recording is enabled or not (as a whole). */
    71     bool                    fEnabled;
     70    //bool                    fEnabled;
    7271    /** Array of all screens containing whether they're enabled
    7372     *  for recording or not.  */
     
    143142    VIDEORECCFG& operator=(const VIDEORECCFG &that)
    144143    {
    145         fEnabled = that.fEnabled;
    146 
    147144        aScreens.resize(that.aScreens.size());
    148145        for (size_t i = 0; i < that.aScreens.size(); ++i)
     
    179176int VideoRecStreamUninit(PVIDEORECCONTEXT pCtx, uint32_t uScreen);
    180177
    181 VIDEORECFEATURES VideoRecGetEnabled(PVIDEORECCFG pCfg);
     178VIDEORECFEATURES VideoRecGetFeatures(PVIDEORECCFG pCfg);
    182179
    183180int VideoRecSendAudioFrame(PVIDEORECCONTEXT pCtx, const void *pvData, size_t cbData, uint64_t uTimestampMs);
     
    187184                            uint8_t *puSrcData, uint64_t uTimeStampMs);
    188185bool VideoRecIsReady(PVIDEORECCONTEXT pCtx, uint32_t uScreen, uint64_t uTimeStampMs);
    189 bool VideoRecIsActive(PVIDEORECCONTEXT pCtx);
     186bool VideoRecIsStarted(PVIDEORECCONTEXT pCtx);
    190187bool VideoRecIsLimitReached(PVIDEORECCONTEXT pCtx, uint32_t uScreen, uint64_t tsNowMs);
    191188
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