Changeset 75313 in vbox for trunk/src/VBox/Main/src-client
- Timestamp:
- Nov 7, 2018 5:13:56 PM (6 years ago)
- Location:
- trunk/src/VBox/Main/src-client
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r75307 r75313 5629 5629 vrc = i_videoRecCreate(); 5630 5630 if (RT_SUCCESS(vrc)) 5631 vrc = i_videoRecStart();5632 5633 if (RT_SUCCESS(vrc))5634 5631 { 5635 5632 # ifdef VBOX_WITH_AUDIO_VIDEOREC … … 6899 6896 Assert(mMachine.isNotNull()); 6900 6897 6898 Settings.applyDefaults(); 6899 6901 6900 ComPtr<ICaptureSettings> pCaptureSettings; 6902 6901 HRESULT hrc = mMachine->COMGETTER(CaptureSettings)(pCaptureSettings.asOutParam()); 6903 6902 AssertComRCReturn(hrc, VERR_INVALID_PARAMETER); 6904 6903 6904 BOOL fTemp; 6905 hrc = pCaptureSettings->COMGETTER(Enabled)(&fTemp); 6906 AssertComRCReturn(hrc, VERR_INVALID_PARAMETER); 6907 Settings.fEnabled = RT_BOOL(fTemp); 6908 6905 6909 SafeIfaceArray<ICaptureScreenSettings> paCaptureScreens; 6906 6910 hrc = pCaptureSettings->COMGETTER(Screens)(ComSafeArrayAsOutParam(paCaptureScreens)); 6907 6911 AssertComRCReturn(hrc, VERR_INVALID_PARAMETER); 6908 6912 6909 Settings.applyDefaults();6910 6911 6913 for (unsigned long i = 0; i < (unsigned long)paCaptureScreens.size(); ++i) 6912 6914 { … … 6914 6916 ComPtr<ICaptureScreenSettings> pCaptureScreenSettings = paCaptureScreens[i]; 6915 6917 6918 hrc = pCaptureScreenSettings->COMGETTER(Enabled)(&fTemp); 6919 AssertComRCReturn(hrc, VERR_INVALID_PARAMETER); 6920 CaptureScreenSettings.fEnabled = RT_BOOL(fTemp); 6916 6921 hrc = pCaptureScreenSettings->COMGETTER(MaxTime)((ULONG *)&CaptureScreenSettings.ulMaxTimeS); 6917 6922 AssertComRCReturn(hrc, VERR_INVALID_PARAMETER); … … 7006 7011 LogRel(("VideoRec: Starting ...\n")); 7007 7012 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 } 7012 7019 7013 7020 if (RT_FAILURE(rc)) … … 7029 7036 LogRel(("VideoRec: Stopping ...\n")); 7030 7037 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; 7045 7058 } 7046 7059 #endif /* VBOX_WITH_VIDEOREC */ -
trunk/src/VBox/Main/src-client/VideoRec.cpp
r75307 r75313 56 56 //# define VBOX_VIDEOREC_DUMP 57 57 #endif 58 59 /**60 * Enumeration for a recording state.61 */62 enum VIDEORECSTS63 {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 = 0x7fffffff72 };73 74 58 75 59 #ifdef VBOX_VIDEOREC_DUMP … … 205 189 try 206 190 { 207 pStream = new CaptureStream( itScreen->first /* Screen ID */, itScreen->second);191 pStream = new CaptureStream(this, itScreen->first /* Screen ID */, itScreen->second); 208 192 this->vecStreams.push_back(pStream); 209 193 } … … 213 197 break; 214 198 } 199 200 ++itScreen; 215 201 } 216 202 … … 219 205 this->tsStartMs = RTTimeMilliTS(); 220 206 this->enmState = VIDEORECSTS_CREATED; 221 this->fStarted = false;222 207 this->fShutdown = false; 223 208 … … 246 231 247 232 int rc = RTThreadCreate(&this->Thread, CaptureContext::threadMain, (void *)this, 0, 248 RTTHREADTYPE_MAIN_WORKER, RTTHREADFLAGS_WAITABLE, " VideoRec");233 RTTHREADTYPE_MAIN_WORKER, RTTHREADFLAGS_WAITABLE, "Record"); 249 234 250 235 if (RT_SUCCESS(rc)) /* Wait for the thread to start. */ … … 254 239 { 255 240 this->enmState = VIDEORECSTS_STARTED; 256 this->fStarted = true;257 241 } 258 242 … … 265 249 return VINF_SUCCESS; 266 250 267 Log Func(("Shutting down thread ...\n"));251 LogThisFunc(("Shutting down thread ...\n")); 268 252 269 253 /* Set shutdown indicator. */ … … 275 259 rc = RTThreadWait(this->Thread, 30 * 1000 /* 10s timeout */, NULL); 276 260 261 if (RT_SUCCESS(rc)) 262 { 263 this->enmState = VIDEORECSTS_CREATED; 264 } 265 266 LogFlowThisFunc(("%Rrc\n", rc)); 277 267 return rc; 278 268 } … … 283 273 int CaptureContext::destroyInternal(void) 284 274 { 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(); 302 276 if (RT_FAILURE(rc)) 303 {304 AssertRC(rc);305 277 return rc; 306 } 278 279 rc = RTSemEventDestroy(this->WaitEvent); 280 AssertRC(rc); 281 282 this->WaitEvent = NIL_RTSEMEVENT; 307 283 308 284 rc = RTCritSectEnter(&this->CritSect); … … 338 314 } 339 315 316 LogFlowThisFunc(("%Rrc\n", rc)); 340 317 return rc; 341 318 } … … 411 388 } 412 389 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 */ 413 395 bool CaptureContext::IsReady(void) const 414 396 { 415 return this->fStarted;416 } 417 418 /** 419 * Checks if recording engineis 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. 422 404 * @param uScreen Screen ID. 423 405 * @param uTimeStampMs Current time stamp (in ms). Currently not being used. … … 450 432 bool CaptureContext::IsStarted(void) const 451 433 { 452 return this->fStarted;434 return (this->enmState == VIDEORECSTS_STARTED); 453 435 } 454 436 -
trunk/src/VBox/Main/src-client/VideoRecStream.cpp
r75307 r75313 42 42 43 43 44 CaptureStream::CaptureStream(void) 45 : tsStartMs(0) 44 CaptureStream::CaptureStream(CaptureContext *a_pCtx) 45 : pCtx(a_pCtx) 46 , enmState(RECORDINGSTREAMSTATE_UNINITIALIZED) 47 , tsStartMs(0) 46 48 { 47 49 File.pWEBM = NULL; … … 49 51 } 50 52 51 CaptureStream::CaptureStream(uint32_t uScreen, const settings::CaptureScreenSettings &Settings) 52 : tsStartMs(0) 53 CaptureStream::CaptureStream(CaptureContext *a_pCtx, uint32_t uScreen, const settings::CaptureScreenSettings &Settings) 54 : enmState(RECORDINGSTREAMSTATE_UNINITIALIZED) 55 , tsStartMs(0) 53 56 { 54 57 File.pWEBM = NULL; 55 58 File.hFile = NIL_RTFILE; 56 59 57 int rc2 = initInternal( uScreen, Settings);60 int rc2 = initInternal(a_pCtx, uScreen, Settings); 58 61 if (RT_FAILURE(rc2)) 59 62 throw rc2; … … 645 648 VideoRecVideoFrameFree(pFrame); 646 649 647 lock();650 unlock(); 648 651 649 652 return rc; 650 653 } 651 654 652 int CaptureStream::Init(uint32_t uScreen, const settings::CaptureScreenSettings &Settings)653 {654 return initInternal(uScreen, Settings);655 }656 657 655 /** 658 656 * Initializes a recording stream. 659 657 * 660 658 * @returns IPRT status code. 659 * @param a_pCtx Pointer to recording context. 661 660 * @param uScreen Screen number to use for this recording stream. 662 661 * @param Settings Capturing configuration to use for initialization. 663 662 */ 664 int CaptureStream::initInternal(uint32_t uScreen, const settings::CaptureScreenSettings &Settings) 663 int 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 */ 676 int CaptureStream::initInternal(CaptureContext *a_pCtx, uint32_t uScreen, const settings::CaptureScreenSettings &Settings) 665 677 { 666 678 int rc = parseOptionsString(Settings.strOptions); … … 770 782 if (RT_SUCCESS(rc)) 771 783 { 784 this->pCtx = a_pCtx; 785 this->enmState = RECORDINGSTREAMSTATE_INITIALIZED; 772 786 this->fEnabled = true; 773 787 this->uScreenID = uScreen; … … 870 884 int CaptureStream::uninitInternal(void) 871 885 { 886 if (this->enmState != RECORDINGSTREAMSTATE_INITIALIZED) 887 return VINF_SUCCESS; 888 872 889 int rc = close(); 873 890 if (RT_FAILURE(rc)) … … 883 900 RTCritSectDelete(&this->CritSect); 884 901 902 this->enmState = RECORDINGSTREAMSTATE_UNINITIALIZED; 885 903 this->fEnabled = false; 886 904 … … 911 929 int CaptureStream::uninitVideoVPX(void) 912 930 { 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 914 935 vpx_codec_err_t rcv = vpx_codec_destroy(&this->Video.Codec.VPX.Ctx); 915 936 Assert(rcv == VPX_CODEC_OK); RT_NOREF(rcv);
Note:
See TracChangeset
for help on using the changeset viewer.