Changeset 75307 in vbox for trunk/src/VBox/Main/src-client
- Timestamp:
- Nov 7, 2018 1:56:14 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 126417
- Location:
- trunk/src/VBox/Main/src-client
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r75287 r75307 5616 5616 if (pDisplay) 5617 5617 { 5618 const bool f Enabled = Capture.mpVideoRecCtx5619 && Capture.mpVideoRecCtx->IsStarted();5620 5621 if (RT_BOOL(fEnable) != f Enabled)5618 const bool fIsEnabled = Capture.mpVideoRecCtx 5619 && Capture.mpVideoRecCtx->IsStarted(); 5620 5621 if (RT_BOOL(fEnable) != fIsEnabled) 5622 5622 { 5623 5623 LogRel(("VideoRec: %s\n", fEnable ? "Enabling" : "Disabling")); … … 5628 5628 { 5629 5629 vrc = i_videoRecCreate(); 5630 if (RT_SUCCESS(vrc)) 5631 vrc = i_videoRecStart(); 5632 5630 5633 if (RT_SUCCESS(vrc)) 5631 5634 { … … 6904 6907 AssertComRCReturn(hrc, VERR_INVALID_PARAMETER); 6905 6908 6906 Settings. mapScreens.clear();6909 Settings.applyDefaults(); 6907 6910 6908 6911 for (unsigned long i = 0; i < (unsigned long)paCaptureScreens.size(); ++i) … … 6934 6937 } 6935 6938 6939 Assert(Settings.mapScreens.size() == paCaptureScreens.size()); 6940 6936 6941 return VINF_SUCCESS; 6937 6942 } … … 6961 6966 } 6962 6967 6968 settings::CaptureSettings Settings; 6969 rc = i_videoRecGetSettings(Settings); 6970 if (RT_SUCCESS(rc)) 6971 { 6972 AssertPtr(Capture.mpVideoRecCtx); 6973 rc = Capture.mpVideoRecCtx->Create(Settings); 6974 } 6975 6976 LogFlowFuncLeaveRC(rc); 6963 6977 return rc; 6964 6978 } … … 6970 6984 { 6971 6985 if (Capture.mpVideoRecCtx) 6986 { 6972 6987 delete Capture.mpVideoRecCtx; 6988 Capture.mpVideoRecCtx = NULL; 6989 } 6990 6991 LogFlowThisFuncLeave(); 6973 6992 } 6974 6993 … … 6987 7006 LogRel(("VideoRec: Starting ...\n")); 6988 7007 6989 settings::CaptureSettings Settings; 6990 int rc = i_videoRecGetSettings(Settings); 6991 if (RT_SUCCESS(rc)) 6992 { 6993 rc = Capture.mpVideoRecCtx->Create(Settings); 6994 if (RT_SUCCESS(rc)) 6995 { 6996 for (unsigned uScreen = 0; uScreen < Capture.mpVideoRecCtx->GetStreamCount(); uScreen++) 6997 mDisplay->i_videoRecScreenChanged(uScreen); 6998 } 6999 } 7008 int rc = VINF_SUCCESS; 7009 7010 for (unsigned uScreen = 0; uScreen < Capture.mpVideoRecCtx->GetStreamCount(); uScreen++) 7011 mDisplay->i_videoRecScreenChanged(uScreen); 7000 7012 7001 7013 if (RT_FAILURE(rc)) 7002 7014 LogRel(("VideoRec: Failed to start video recording (%Rrc)\n", rc)); 7003 7015 7016 LogFlowFuncLeaveRC(rc); 7004 7017 return rc; 7005 7018 } … … 7010 7023 int Console::i_videoRecStop(void) 7011 7024 { 7012 AssertPtrReturn(Capture.mpVideoRecCtx, VERR_WRONG_ORDER); 7013 7014 if (!Capture.mpVideoRecCtx->IsStarted()) 7025 if ( !Capture.mpVideoRecCtx 7026 || !Capture.mpVideoRecCtx->IsStarted()) 7015 7027 return VINF_SUCCESS; 7016 7028 … … 7020 7032 for (unsigned uScreen = 0; uScreen < cStreams; ++uScreen) 7021 7033 mDisplay->i_videoRecScreenChanged(uScreen); 7022 7023 delete Capture.mpVideoRecCtx;7024 Capture.mpVideoRecCtx = NULL;7025 7034 7026 7035 ComPtr<ICaptureSettings> pCaptureSettings; … … 7032 7041 LogRel(("VideoRec: Stopped\n")); 7033 7042 7043 LogFlowFuncLeaveRC(VINF_SUCCESS); 7034 7044 return VINF_SUCCESS; 7035 7045 } -
trunk/src/VBox/Main/src-client/VideoRec.cpp
r75254 r75307 58 58 59 59 /** 60 * Enumeration for a videorecording state.60 * Enumeration for a recording state. 61 61 */ 62 62 enum VIDEORECSTS … … 64 64 /** Not initialized. */ 65 65 VIDEORECSTS_UNINITIALIZED = 0, 66 /** Initialized. */ 67 VIDEORECSTS_INITIALIZED = 1, 66 /** Created. */ 67 VIDEORECSTS_CREATED = 1, 68 /** Started. */ 69 VIDEORECSTS_STARTED = 2, 68 70 /** The usual 32-bit hack. */ 69 71 VIDEORECSTS_32BIT_HACK = 0x7fffffff … … 105 107 106 108 CaptureContext::CaptureContext(Console *a_pConsole) 107 : pConsole(a_pConsole) { } 109 : pConsole(a_pConsole) 110 , enmState(VIDEORECSTS_UNINITIALIZED) { } 108 111 109 112 CaptureContext::CaptureContext(Console *a_pConsole, const settings::CaptureSettings &a_Settings) 110 113 : pConsole(a_pConsole) 114 , enmState(VIDEORECSTS_UNINITIALIZED) 111 115 { 112 116 int rc = CaptureContext::createInternal(a_Settings); … … 214 218 { 215 219 this->tsStartMs = RTTimeMilliTS(); 216 this->enmState = VIDEORECSTS_ UNINITIALIZED;220 this->enmState = VIDEORECSTS_CREATED; 217 221 this->fStarted = false; 218 222 this->fShutdown = false; … … 223 227 rc = RTSemEventCreate(&this->WaitEvent); 224 228 AssertRCReturn(rc, rc); 225 226 rc = RTThreadCreate(&this->Thread, CaptureContext::threadMain, (void *)this, 0,227 RTTHREADTYPE_MAIN_WORKER, RTTHREADFLAGS_WAITABLE, "VideoRec");228 229 if (RT_SUCCESS(rc)) /* Wait for the thread to start. */230 rc = RTThreadUserWait(this->Thread, 30 * RT_MS_1SEC /* 30s timeout */);231 232 if (RT_SUCCESS(rc))233 {234 this->enmState = VIDEORECSTS_INITIALIZED;235 this->fStarted = true;236 }237 229 } 238 230 … … 246 238 } 247 239 240 int CaptureContext::startInternal(void) 241 { 242 if (this->enmState == VIDEORECSTS_STARTED) 243 return VINF_SUCCESS; 244 245 Assert(this->enmState == VIDEORECSTS_CREATED); 246 247 int rc = RTThreadCreate(&this->Thread, CaptureContext::threadMain, (void *)this, 0, 248 RTTHREADTYPE_MAIN_WORKER, RTTHREADFLAGS_WAITABLE, "VideoRec"); 249 250 if (RT_SUCCESS(rc)) /* Wait for the thread to start. */ 251 rc = RTThreadUserWait(this->Thread, 30 * RT_MS_1SEC /* 30s timeout */); 252 253 if (RT_SUCCESS(rc)) 254 { 255 this->enmState = VIDEORECSTS_STARTED; 256 this->fStarted = true; 257 } 258 259 return rc; 260 } 261 262 int CaptureContext::stopInternal(void) 263 { 264 if (this->enmState != VIDEORECSTS_STARTED) 265 return VINF_SUCCESS; 266 267 LogFunc(("Shutting down thread ...\n")); 268 269 /* Set shutdown indicator. */ 270 ASMAtomicWriteBool(&this->fShutdown, true); 271 272 /* Signal the thread and wait for it to shut down. */ 273 int rc = threadNotify(); 274 if (RT_SUCCESS(rc)) 275 rc = RTThreadWait(this->Thread, 30 * 1000 /* 10s timeout */, NULL); 276 277 return rc; 278 } 279 248 280 /** 249 281 * Destroys a video recording context. … … 253 285 int rc = VINF_SUCCESS; 254 286 255 if (this->enmState == VIDEORECSTS_INITIALIZED) 256 { 257 LogFunc(("Shutting down thread ...\n")); 258 259 /* Set shutdown indicator. */ 260 ASMAtomicWriteBool(&this->fShutdown, true); 261 262 /* Signal the thread and wait for it to shut down. */ 263 rc = threadNotify(); 264 if (RT_SUCCESS(rc)) 265 rc = RTThreadWait(this->Thread, 30 * 1000 /* 10s timeout */, NULL); 266 287 if (this->enmState == VIDEORECSTS_STARTED) 288 { 289 rc = stopInternal(); 267 290 if (RT_SUCCESS(rc)) 268 291 { … … 365 388 } 366 389 390 int CaptureContext::Start(void) 391 { 392 return startInternal(); 393 } 394 395 int CaptureContext::Stop(void) 396 { 397 return stopInternal(); 398 } 399 367 400 bool CaptureContext::IsFeatureEnabled(CaptureFeature_T enmFeature) const 368 401 { … … 394 427 RT_NOREF(uTimeStampMs); 395 428 396 if (this->enmState != VIDEORECSTS_ INITIALIZED)429 if (this->enmState != VIDEORECSTS_STARTED) 397 430 return false; 398 431 -
trunk/src/VBox/Main/src-client/VideoRecStream.cpp
r75256 r75307 45 45 : tsStartMs(0) 46 46 { 47 File.pWEBM = NULL; 48 File.hFile = NIL_RTFILE; 47 49 } 48 50 … … 50 52 : tsStartMs(0) 51 53 { 54 File.pWEBM = NULL; 55 File.hFile = NIL_RTFILE; 56 52 57 int rc2 = initInternal(uScreen, Settings); 53 58 if (RT_FAILURE(rc2)) … … 66 71 * @returns IPRT status code. 67 72 */ 68 int CaptureStream::open(void) 69 { 70 Assert(ScreenSettings.enmDest == CaptureDestination_None); 73 int CaptureStream::open(const settings::CaptureScreenSettings &Settings) 74 { 75 /* Sanity. */ 76 Assert(Settings.enmDest != CaptureDestination_None); 71 77 72 78 int rc; 73 79 74 switch (S creenSettings.enmDest)80 switch (Settings.enmDest) 75 81 { 76 82 case CaptureDestination_File: 77 83 { 78 Assert(S creenSettings.File.strName.isNotEmpty());79 80 char *pszAbsPath = RTPathAbsDup(S creenSettings.File.strName.c_str());84 Assert(Settings.File.strName.isNotEmpty()); 85 86 char *pszAbsPath = RTPathAbsDup(Settings.File.strName.c_str()); 81 87 AssertPtrReturn(pszAbsPath, VERR_NO_MEMORY); 82 88 … … 132 138 if (RT_SUCCESS(rc)) 133 139 rc = RTFileOpen(&hFile, pszFile, fOpen); 140 } 141 142 try 143 { 144 Assert(File.pWEBM == NULL); 145 File.pWEBM = new WebMWriter(); 146 } 147 catch (std::bad_alloc &) 148 { 149 rc = VERR_NO_MEMORY; 134 150 } 135 151 … … 656 672 return rc; 657 673 658 rc = open( );674 rc = open(Settings); 659 675 if (RT_FAILURE(rc)) 660 676 return rc; … … 675 691 const char *pszFile = this->ScreenSettings.File.strName.c_str(); 676 692 693 AssertPtr(File.pWEBM); 677 694 rc = File.pWEBM->OpenEx(pszFile, &this->File.hFile, 678 695 #ifdef VBOX_WITH_AUDIO_VIDEOREC
Note:
See TracChangeset
for help on using the changeset viewer.