VirtualBox

Changeset 75313 in vbox for trunk/src/VBox/Main/src-client


Ignore:
Timestamp:
Nov 7, 2018 5:13:56 PM (6 years ago)
Author:
vboxsync
Message:

Recording: More bugfixes for Main and FE/Qt.

Location:
trunk/src/VBox/Main/src-client
Files:
3 edited

Legend:

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

    r75307 r75313  
    56295629                vrc = i_videoRecCreate();
    56305630                if (RT_SUCCESS(vrc))
    5631                     vrc = i_videoRecStart();
    5632 
    5633                 if (RT_SUCCESS(vrc))
    56345631                {
    56355632# ifdef VBOX_WITH_AUDIO_VIDEOREC
     
    68996896    Assert(mMachine.isNotNull());
    69006897
     6898    Settings.applyDefaults();
     6899
    69016900    ComPtr<ICaptureSettings> pCaptureSettings;
    69026901    HRESULT hrc = mMachine->COMGETTER(CaptureSettings)(pCaptureSettings.asOutParam());
    69036902    AssertComRCReturn(hrc, VERR_INVALID_PARAMETER);
    69046903
     6904    BOOL fTemp;
     6905    hrc = pCaptureSettings->COMGETTER(Enabled)(&fTemp);
     6906    AssertComRCReturn(hrc, VERR_INVALID_PARAMETER);
     6907    Settings.fEnabled = RT_BOOL(fTemp);
     6908
    69056909    SafeIfaceArray<ICaptureScreenSettings> paCaptureScreens;
    69066910    hrc = pCaptureSettings->COMGETTER(Screens)(ComSafeArrayAsOutParam(paCaptureScreens));
    69076911    AssertComRCReturn(hrc, VERR_INVALID_PARAMETER);
    69086912
    6909     Settings.applyDefaults();
    6910 
    69116913    for (unsigned long i = 0; i < (unsigned long)paCaptureScreens.size(); ++i)
    69126914    {
     
    69146916        ComPtr<ICaptureScreenSettings> pCaptureScreenSettings = paCaptureScreens[i];
    69156917
     6918        hrc = pCaptureScreenSettings->COMGETTER(Enabled)(&fTemp);
     6919        AssertComRCReturn(hrc, VERR_INVALID_PARAMETER);
     6920        CaptureScreenSettings.fEnabled = RT_BOOL(fTemp);
    69166921        hrc = pCaptureScreenSettings->COMGETTER(MaxTime)((ULONG *)&CaptureScreenSettings.ulMaxTimeS);
    69176922        AssertComRCReturn(hrc, VERR_INVALID_PARAMETER);
     
    70067011    LogRel(("VideoRec: Starting ...\n"));
    70077012
    7008     int rc = VINF_SUCCESS;
    7009 
    7010     for (unsigned uScreen = 0; uScreen < Capture.mpVideoRecCtx->GetStreamCount(); uScreen++)
    7011         mDisplay->i_videoRecScreenChanged(uScreen);
     7013    int rc = Capture.mpVideoRecCtx->Start();
     7014    if (RT_SUCCESS(rc))
     7015    {
     7016        for (unsigned uScreen = 0; uScreen < Capture.mpVideoRecCtx->GetStreamCount(); uScreen++)
     7017            mDisplay->i_videoRecScreenChanged(uScreen);
     7018    }
    70127019
    70137020    if (RT_FAILURE(rc))
     
    70297036    LogRel(("VideoRec: Stopping ...\n"));
    70307037
    7031     const size_t cStreams = Capture.mpVideoRecCtx->GetStreamCount();
    7032     for (unsigned uScreen = 0; uScreen < cStreams; ++uScreen)
    7033         mDisplay->i_videoRecScreenChanged(uScreen);
    7034 
    7035     ComPtr<ICaptureSettings> pCaptureSettings;
    7036     HRESULT hrc = mMachine->COMGETTER(CaptureSettings)(pCaptureSettings.asOutParam());
    7037     ComAssertComRC(hrc);
    7038     hrc = pCaptureSettings->COMSETTER(Enabled)(false);
    7039     ComAssertComRC(hrc);
    7040 
    7041     LogRel(("VideoRec: Stopped\n"));
    7042 
    7043     LogFlowFuncLeaveRC(VINF_SUCCESS);
    7044     return VINF_SUCCESS;
     7038    int rc = Capture.mpVideoRecCtx->Stop();
     7039    if (RT_SUCCESS(rc))
     7040    {
     7041        const size_t cStreams = Capture.mpVideoRecCtx->GetStreamCount();
     7042        for (unsigned uScreen = 0; uScreen < cStreams; ++uScreen)
     7043            mDisplay->i_videoRecScreenChanged(uScreen);
     7044
     7045        ComPtr<ICaptureSettings> pCaptureSettings;
     7046        HRESULT hrc = mMachine->COMGETTER(CaptureSettings)(pCaptureSettings.asOutParam());
     7047        ComAssertComRC(hrc);
     7048        hrc = pCaptureSettings->COMSETTER(Enabled)(false);
     7049        ComAssertComRC(hrc);
     7050
     7051        LogRel(("VideoRec: Stopped\n"));
     7052    }
     7053    else
     7054        LogRel(("VideoRec: Failed to stop video recording (%Rrc)\n", rc));
     7055
     7056    LogFlowFuncLeaveRC(rc);
     7057    return rc;
    70457058}
    70467059#endif /* VBOX_WITH_VIDEOREC */
  • trunk/src/VBox/Main/src-client/VideoRec.cpp

    r75307 r75313  
    5656//# define VBOX_VIDEOREC_DUMP
    5757#endif
    58 
    59 /**
    60  * Enumeration for a recording state.
    61  */
    62 enum VIDEORECSTS
    63 {
    64     /** Not initialized. */
    65     VIDEORECSTS_UNINITIALIZED = 0,
    66     /** Created. */
    67     VIDEORECSTS_CREATED       = 1,
    68     /** Started. */
    69     VIDEORECSTS_STARTED       = 2,
    70     /** The usual 32-bit hack. */
    71     VIDEORECSTS_32BIT_HACK    = 0x7fffffff
    72 };
    73 
    7458
    7559#ifdef VBOX_VIDEOREC_DUMP
     
    205189        try
    206190        {
    207             pStream = new CaptureStream(itScreen->first /* Screen ID */, itScreen->second);
     191            pStream = new CaptureStream(this, itScreen->first /* Screen ID */, itScreen->second);
    208192            this->vecStreams.push_back(pStream);
    209193        }
     
    213197            break;
    214198        }
     199
     200        ++itScreen;
    215201    }
    216202
     
    219205        this->tsStartMs = RTTimeMilliTS();
    220206        this->enmState  = VIDEORECSTS_CREATED;
    221         this->fStarted  = false;
    222207        this->fShutdown = false;
    223208
     
    246231
    247232    int rc = RTThreadCreate(&this->Thread, CaptureContext::threadMain, (void *)this, 0,
    248                             RTTHREADTYPE_MAIN_WORKER, RTTHREADFLAGS_WAITABLE, "VideoRec");
     233                            RTTHREADTYPE_MAIN_WORKER, RTTHREADFLAGS_WAITABLE, "Record");
    249234
    250235    if (RT_SUCCESS(rc)) /* Wait for the thread to start. */
     
    254239    {
    255240        this->enmState = VIDEORECSTS_STARTED;
    256         this->fStarted = true;
    257241    }
    258242
     
    265249        return VINF_SUCCESS;
    266250
    267     LogFunc(("Shutting down thread ...\n"));
     251    LogThisFunc(("Shutting down thread ...\n"));
    268252
    269253    /* Set shutdown indicator. */
     
    275259        rc = RTThreadWait(this->Thread, 30 * 1000 /* 10s timeout */, NULL);
    276260
     261    if (RT_SUCCESS(rc))
     262    {
     263        this->enmState = VIDEORECSTS_CREATED;
     264    }
     265
     266    LogFlowThisFunc(("%Rrc\n", rc));
    277267    return rc;
    278268}
     
    283273int CaptureContext::destroyInternal(void)
    284274{
    285     int rc = VINF_SUCCESS;
    286 
    287     if (this->enmState == VIDEORECSTS_STARTED)
    288     {
    289         rc = stopInternal();
    290         if (RT_SUCCESS(rc))
    291         {
    292             /* Disable the context. */
    293             ASMAtomicWriteBool(&this->fStarted, false);
    294 
    295             int rc2 = RTSemEventDestroy(this->WaitEvent);
    296             AssertRC(rc2);
    297 
    298             this->WaitEvent = NIL_RTSEMEVENT;
    299         }
    300     }
    301 
     275    int rc = stopInternal();
    302276    if (RT_FAILURE(rc))
    303     {
    304         AssertRC(rc);
    305277        return rc;
    306     }
     278
     279    rc = RTSemEventDestroy(this->WaitEvent);
     280    AssertRC(rc);
     281
     282    this->WaitEvent = NIL_RTSEMEVENT;
    307283
    308284    rc = RTCritSectEnter(&this->CritSect);
     
    338314    }
    339315
     316    LogFlowThisFunc(("%Rrc\n", rc));
    340317    return rc;
    341318}
     
    411388}
    412389
     390/**
     391 * Returns if this recording context is ready to start recording.
     392 *
     393 * @returns @c true if recording context is ready, @c false if not.
     394 */
    413395bool CaptureContext::IsReady(void) const
    414396{
    415     return this->fStarted;
    416 }
    417 
    418 /**
    419  * Checks if recording engine is ready to accept new recording data for a given screen.
    420  *
    421  * @returns true if recording engine is ready, false if not.
     397    return (this->enmState >= VIDEORECSTS_CREATED);
     398}
     399
     400/**
     401 * Returns if this recording context is ready to accept new recording data for a given screen.
     402 *
     403 * @returns @c true if the specified screen is ready, @c false if not.
    422404 * @param   uScreen             Screen ID.
    423405 * @param   uTimeStampMs        Current time stamp (in ms). Currently not being used.
     
    450432bool CaptureContext::IsStarted(void) const
    451433{
    452     return this->fStarted;
     434    return (this->enmState == VIDEORECSTS_STARTED);
    453435}
    454436
  • trunk/src/VBox/Main/src-client/VideoRecStream.cpp

    r75307 r75313  
    4242
    4343
    44 CaptureStream::CaptureStream(void)
    45     : tsStartMs(0)
     44CaptureStream::CaptureStream(CaptureContext *a_pCtx)
     45    : pCtx(a_pCtx)
     46    , enmState(RECORDINGSTREAMSTATE_UNINITIALIZED)
     47    , tsStartMs(0)
    4648{
    4749    File.pWEBM = NULL;
     
    4951}
    5052
    51 CaptureStream::CaptureStream(uint32_t uScreen, const settings::CaptureScreenSettings &Settings)
    52     : tsStartMs(0)
     53CaptureStream::CaptureStream(CaptureContext *a_pCtx, uint32_t uScreen, const settings::CaptureScreenSettings &Settings)
     54    : enmState(RECORDINGSTREAMSTATE_UNINITIALIZED)
     55    , tsStartMs(0)
    5356{
    5457    File.pWEBM = NULL;
    5558    File.hFile = NIL_RTFILE;
    5659
    57     int rc2 = initInternal(uScreen, Settings);
     60    int rc2 = initInternal(a_pCtx, uScreen, Settings);
    5861    if (RT_FAILURE(rc2))
    5962        throw rc2;
     
    645648        VideoRecVideoFrameFree(pFrame);
    646649
    647     lock();
     650    unlock();
    648651
    649652    return rc;
    650653}
    651654
    652 int CaptureStream::Init(uint32_t uScreen, const settings::CaptureScreenSettings &Settings)
    653 {
    654     return initInternal(uScreen, Settings);
    655 }
    656 
    657655/**
    658656 * Initializes a recording stream.
    659657 *
    660658 * @returns IPRT status code.
     659 * @param   a_pCtx              Pointer to recording context.
    661660 * @param   uScreen             Screen number to use for this recording stream.
    662661 * @param   Settings            Capturing configuration to use for initialization.
    663662 */
    664 int CaptureStream::initInternal(uint32_t uScreen, const settings::CaptureScreenSettings &Settings)
     663int CaptureStream::Init(CaptureContext *a_pCtx, uint32_t uScreen, const settings::CaptureScreenSettings &Settings)
     664{
     665    return initInternal(a_pCtx, uScreen, Settings);
     666}
     667
     668/**
     669 * Initializes a recording stream, internal version.
     670 *
     671 * @returns IPRT status code.
     672 * @param   a_pCtx              Pointer to recording context.
     673 * @param   uScreen             Screen number to use for this recording stream.
     674 * @param   Settings            Capturing configuration to use for initialization.
     675 */
     676int CaptureStream::initInternal(CaptureContext *a_pCtx, uint32_t uScreen, const settings::CaptureScreenSettings &Settings)
    665677{
    666678    int rc = parseOptionsString(Settings.strOptions);
     
    770782    if (RT_SUCCESS(rc))
    771783    {
     784        this->pCtx           = a_pCtx;
     785        this->enmState       = RECORDINGSTREAMSTATE_INITIALIZED;
    772786        this->fEnabled       = true;
    773787        this->uScreenID      = uScreen;
     
    870884int CaptureStream::uninitInternal(void)
    871885{
     886    if (this->enmState != RECORDINGSTREAMSTATE_INITIALIZED)
     887        return VINF_SUCCESS;
     888
    872889    int rc = close();
    873890    if (RT_FAILURE(rc))
     
    883900    RTCritSectDelete(&this->CritSect);
    884901
     902    this->enmState = RECORDINGSTREAMSTATE_UNINITIALIZED;
    885903    this->fEnabled = false;
    886904
     
    911929int CaptureStream::uninitVideoVPX(void)
    912930{
    913     vpx_img_free(&this->Video.Codec.VPX.RawImage);
     931    PVIDEORECVIDEOCODEC pCodec = &this->Video.Codec;
     932    vpx_img_free(&pCodec->VPX.RawImage);
     933    pCodec->VPX.pu8YuvBuf = NULL; /* Was pointing to VPX.RawImage. */
     934
    914935    vpx_codec_err_t rcv = vpx_codec_destroy(&this->Video.Codec.VPX.Ctx);
    915936    Assert(rcv == VPX_CODEC_OK); RT_NOREF(rcv);
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