Changeset 75307 in vbox
- Timestamp:
- Nov 7, 2018 1:56:14 PM (6 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 13 edited
-
Frontends/VirtualBox/src/runtime/UIIndicatorsPool.cpp (modified) (1 diff)
-
Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp (modified) (3 diffs)
-
Main/include/CaptureScreenSettingsImpl.h (modified) (1 diff)
-
Main/include/CaptureSettingsImpl.h (modified) (2 diffs)
-
Main/include/MachineImpl.h (modified) (1 diff)
-
Main/include/VideoRec.h (modified) (2 diffs)
-
Main/include/VideoRecStream.h (modified) (1 diff)
-
Main/src-client/ConsoleImpl.cpp (modified) (10 diffs)
-
Main/src-client/VideoRec.cpp (modified) (9 diffs)
-
Main/src-client/VideoRecStream.cpp (modified) (6 diffs)
-
Main/src-server/CaptureScreenSettingsImpl.cpp (modified) (25 diffs)
-
Main/src-server/CaptureSettingsImpl.cpp (modified) (11 diffs)
-
Main/xml/Settings.cpp (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.cpp
r75291 r75307 957 957 /* For now all screens have the same config: */ 958 958 CCaptureScreenSettings recordingScreen0Settings = recordingSettings.GetScreenSettings(0); 959 960 QStringList strOptionsPairList = recordingScreen0Settings.GetOptions().split(",", QString::SkipEmptyParts); 961 962 for (int i = 0; i < strOptionsPairList.size(); ++i) 963 { 964 if (strOptionsPairList.at(i).contains("vc_enabled", Qt::CaseInsensitive) && 965 strOptionsPairList.at(i).contains("true", Qt::CaseInsensitive)) 966 m_eRecordingMode = (UIIndicatorStateRecordingMode)((int)m_eRecordingMode | (int)UIIndicatorStateRecordingMode_Video); 967 968 if (strOptionsPairList.at(i).contains("ac_enabled", Qt::CaseInsensitive) && 969 strOptionsPairList.at(i).contains("true", Qt::CaseInsensitive)) 970 m_eRecordingMode = (UIIndicatorStateRecordingMode)((int)m_eRecordingMode | (int)UIIndicatorStateRecordingMode_Audio); 971 } 959 if (recordingScreen0Settings.IsFeatureEnabled(KCaptureFeature_Video)) 960 m_eRecordingMode = (UIIndicatorStateRecordingMode)((int)m_eRecordingMode | (int)UIIndicatorStateRecordingMode_Video); 961 962 if (recordingScreen0Settings.IsFeatureEnabled(KCaptureFeature_Audio)) 963 m_eRecordingMode = (UIIndicatorStateRecordingMode)((int)m_eRecordingMode | (int)UIIndicatorStateRecordingMode_Audio); 972 964 } 973 965 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp
r75296 r75307 370 370 371 371 /* Check whether remote display server is valid: */ 372 const CVRDEServer & comServer = m_machine.GetVRDEServer();373 oldDisplayData.m_fRemoteDisplayServerSupported = ! comServer.isNull();374 if (! comServer.isNull())372 const CVRDEServer &vrdeServer = m_machine.GetVRDEServer(); 373 oldDisplayData.m_fRemoteDisplayServerSupported = !vrdeServer.isNull(); 374 if (!vrdeServer.isNull()) 375 375 { 376 376 /* Gather old 'Remote Display' data: */ 377 oldDisplayData.m_fRemoteDisplayServerEnabled = comServer.GetEnabled();378 oldDisplayData.m_strRemoteDisplayPort = comServer.GetVRDEProperty("TCP/Ports");379 oldDisplayData.m_remoteDisplayAuthType = comServer.GetAuthType();380 oldDisplayData.m_uRemoteDisplayTimeout = comServer.GetAuthTimeout();381 oldDisplayData.m_fRemoteDisplayMultiConnAllowed = comServer.GetAllowMultiConnection();377 oldDisplayData.m_fRemoteDisplayServerEnabled = vrdeServer.GetEnabled(); 378 oldDisplayData.m_strRemoteDisplayPort = vrdeServer.GetVRDEProperty("TCP/Ports"); 379 oldDisplayData.m_remoteDisplayAuthType = vrdeServer.GetAuthType(); 380 oldDisplayData.m_uRemoteDisplayTimeout = vrdeServer.GetAuthTimeout(); 381 oldDisplayData.m_fRemoteDisplayMultiConnAllowed = vrdeServer.GetAllowMultiConnection(); 382 382 } 383 383 384 384 /* Gather old 'Recording' data: */ 385 385 CCaptureSettings recordingSettings = m_machine.GetCaptureSettings(); 386 Assert(recordingSettings.isNotNull()); 386 387 oldDisplayData.m_fRecordingEnabled = recordingSettings.GetEnabled(); 387 388 … … 403 404 for (int iScreenIndex = 0; iScreenIndex < recordingScreenSettingsVector.size(); ++iScreenIndex) 404 405 { 405 CCaptureScreenSettings captureScreenSettings = recordingScreenSettingsVector.at(iScreenIndex); 406 oldDisplayData.m_vecRecordingScreens[iScreenIndex] = captureScreenSettings.GetEnabled(); 406 CCaptureScreenSettings recordingScreenSettings = recordingScreenSettingsVector.at(iScreenIndex); 407 if (!recordingScreenSettings.isNull()) 408 oldDisplayData.m_vecRecordingScreens[iScreenIndex] = recordingScreenSettings.GetEnabled(); 407 409 } 408 410 … … 1510 1512 1511 1513 CCaptureSettings recordingSettings = m_machine.GetCaptureSettings(); 1514 Assert(recordingSettings.isNotNull()); 1512 1515 1513 1516 /* Save new 'Recording' data for online case: */ -
trunk/src/VBox/Main/include/CaptureScreenSettingsImpl.h
r75279 r75307 103 103 // internal methods 104 104 bool i_canChangeSettings(); 105 int i_getDefaultCaptureFile(Utf8Str &strFile); 105 int i_getDefaultFileName(Utf8Str &strFile); 106 int i_initInternal(); 106 107 107 108 private: -
trunk/src/VBox/Main/include/CaptureSettingsImpl.h
r75286 r75307 26 26 { 27 27 struct CaptureSettings; 28 struct CaptureScreenSettings; 28 29 } 29 30 … … 57 58 private: 58 59 60 int i_addScreen(uint32_t uScreenId, const settings::CaptureScreenSettings &data); 61 62 private: 63 59 64 // wrapped ICaptureSettings properties 60 65 HRESULT getEnabled(BOOL *enabled); -
trunk/src/VBox/Main/include/MachineImpl.h
r75251 r75307 494 494 void i_setModified(uint32_t fl, bool fAllowStateModification = true); 495 495 void i_setModifiedLock(uint32_t fl, bool fAllowStateModification = true); 496 497 MachineState_T i_getMachineState() const { return mData->mMachineState; } 496 498 497 499 bool i_isStateModificationAllowed() const { return mData->m_fAllowStateModification; } -
trunk/src/VBox/Main/include/VideoRec.h
r75251 r75307 180 180 int Destroy(void); 181 181 182 int Start(void); 183 int Stop(void); 184 182 185 int SendAudioFrame(const void *pvData, size_t cbData, uint64_t uTimestampMs); 183 186 int SendVideoFrame(uint32_t uScreen, … … 196 199 197 200 int createInternal(const settings::CaptureSettings &a_Settings); 201 int startInternal(void); 202 int stopInternal(void); 198 203 199 204 int destroyInternal(void); -
trunk/src/VBox/Main/include/VideoRecStream.h
r75254 r75307 130 130 protected: 131 131 132 int open( void);132 int open(const settings::CaptureScreenSettings &Settings); 133 133 int close(void); 134 134 -
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 -
trunk/src/VBox/Main/src-server/CaptureScreenSettingsImpl.cpp
r75279 r75307 86 86 m = new Data(); 87 87 88 /* share the parent weakly*/88 /* Share the parent weakly. */ 89 89 unconst(m->pMachine) = aParent; 90 /* mPeer is left null. */ 90 91 91 92 /* Simply copy the settings data. */ … … 94 95 m->bd->operator=(data); 95 96 96 autoInitSpan.setSucceeded(); 97 HRESULT rc = S_OK; 98 99 int vrc = i_initInternal(); 100 if (RT_SUCCESS(vrc)) 101 { 102 autoInitSpan.setSucceeded(); 103 } 104 else 105 { 106 autoInitSpan.setFailed(); 107 rc = E_UNEXPECTED; 108 } 97 109 98 110 LogFlowThisFuncLeave(); 99 return S_OK;111 return rc; 100 112 } 101 113 … … 129 141 m->bd.share(that->m->bd); 130 142 131 autoInitSpan.setSucceeded(); 143 HRESULT rc = S_OK; 144 145 int vrc = i_initInternal(); 146 if (RT_SUCCESS(vrc)) 147 { 148 autoInitSpan.setSucceeded(); 149 } 150 else 151 { 152 autoInitSpan.setFailed(); 153 rc = E_UNEXPECTED; 154 } 132 155 133 156 LogFlowThisFuncLeave(); 134 return S_OK;157 return rc; 135 158 } 136 159 … … 154 177 155 178 unconst(m->pMachine) = aParent; 156 / / mPeer is left null179 /* mPeer is left null. */ 157 180 158 181 AutoWriteLock thatlock(that COMMA_LOCKVAL_SRC_POS); … … 161 184 m->bd.attachCopy(that->m->bd); 162 185 163 autoInitSpan.setSucceeded(); 186 HRESULT rc = S_OK; 187 188 int vrc = i_initInternal(); 189 if (RT_SUCCESS(vrc)) 190 { 191 autoInitSpan.setSucceeded(); 192 } 193 else 194 { 195 autoInitSpan.setFailed(); 196 rc = E_UNEXPECTED; 197 } 164 198 165 199 LogFlowThisFuncLeave(); 166 return S_OK;200 return rc; 167 201 } 168 202 … … 216 250 if (m->bd->fEnabled != RT_BOOL(enabled)) 217 251 { 252 m->bd.backup(); 253 m->bd->fEnabled = RT_BOOL(enabled); 218 254 alock.release(); 255 256 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 257 m->pMachine->i_setModified(Machine::IsModified_Capture); 258 mlock.release(); 219 259 220 260 HRESULT rc = m->pMachine->i_onCaptureChange(); 221 261 if (FAILED(rc)) return rc; 222 223 m->pMachine->i_setModified(Machine::IsModified_Capture);224 225 alock.acquire();226 m->bd->fEnabled = RT_BOOL(enabled);227 alock.release();228 262 229 263 /** Save settings if online - @todo why is this required? -- @bugref{6818} */ … … 263 297 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 264 298 265 m->pMachine->i_setModified(Machine::IsModified_Capture); 266 m->bd.backup(); 267 299 m->bd.backup(); 268 300 m->bd->featureMap.clear(); 269 301 … … 273 305 m->bd->featureMap[CaptureFeature_Video] = true; 274 306 307 alock.release(); 308 309 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 310 m->pMachine->i_setModified(Machine::IsModified_Capture); 311 mlock.release(); 312 275 313 return S_OK; 276 314 } … … 292 330 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 293 331 294 m->pMachine->i_setModified(Machine::IsModified_Capture);295 332 m->bd.backup(); 296 333 m->bd->enmDest = aDestination; 297 334 335 alock.release(); 336 337 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 338 m->pMachine->i_setModified(Machine::IsModified_Capture); 339 mlock.release(); 340 298 341 return S_OK; 299 342 } … … 303 346 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 304 347 305 if (m->bd->File.strName.isEmpty()) 306 i_getDefaultCaptureFile(aFileName); 307 else 308 aFileName = m->bd->File.strName; 348 aFileName = m->bd->File.strName; 309 349 310 350 return S_OK; … … 323 363 return setError(E_INVALIDARG, tr("Capture file name '%s' is not absolute"), strFile.c_str()); 324 364 325 if (!strFile.isEmpty())326 {327 Utf8Str defaultFile;328 i_getDefaultCaptureFile(defaultFile);329 if (!RTPathCompare(strFile.c_str(), defaultFile.c_str()))330 strFile.setNull();331 }332 333 m->pMachine->i_setModified(Machine::IsModified_Capture);334 365 m->bd.backup(); 335 366 m->bd->File.strName = strFile; 336 367 368 alock.release(); 369 370 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 371 m->pMachine->i_setModified(Machine::IsModified_Capture); 372 mlock.release(); 373 337 374 return S_OK; 338 375 } … … 354 391 return setError(E_INVALIDARG, tr("Cannot change maximum time while capturing is enabled")); 355 392 356 m->pMachine->i_setModified(Machine::IsModified_Capture); 357 m->bd.backup(); 358 393 m->bd.backup(); 359 394 m->bd->ulMaxTimeS = aMaxTimeS; 360 395 396 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 397 m->pMachine->i_setModified(Machine::IsModified_Capture); 398 mlock.release(); 399 361 400 return S_OK; 362 401 } … … 378 417 return setError(E_INVALIDARG, tr("Cannot change maximum file size while capturing is enabled")); 379 418 380 m->pMachine->i_setModified(Machine::IsModified_Capture); 381 m->bd.backup(); 382 419 m->bd.backup(); 383 420 m->bd->File.ulMaxSizeMB = aMaxFileSize; 384 421 422 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 423 m->pMachine->i_setModified(Machine::IsModified_Capture); 424 mlock.release(); 425 385 426 return S_OK; 386 427 } … … 402 443 return setError(E_INVALIDARG, tr("Cannot change options string while capturing is enabled")); 403 444 404 m->pMachine->i_setModified(Machine::IsModified_Capture); 405 m->bd.backup(); 406 445 m->bd.backup(); 407 446 m->bd->strOptions = aOptions; 408 447 448 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 449 m->pMachine->i_setModified(Machine::IsModified_Capture); 450 mlock.release(); 451 409 452 return S_OK; 410 453 } … … 426 469 return setError(E_INVALIDARG, tr("Cannot change audio codec while capturing is enabled")); 427 470 428 m->pMachine->i_setModified(Machine::IsModified_Capture); 429 m->bd.backup(); 430 471 m->bd.backup(); 431 472 m->bd->Audio.enmAudioCodec = aCodec; 432 473 474 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 475 m->pMachine->i_setModified(Machine::IsModified_Capture); 476 mlock.release(); 477 433 478 return S_OK; 434 479 } … … 450 495 return setError(E_INVALIDARG, tr("Cannot change audio Hertz rate while capturing is enabled")); 451 496 452 m->pMachine->i_setModified(Machine::IsModified_Capture); 453 m->bd.backup(); 454 497 m->bd.backup(); 455 498 m->bd->Audio.uHz = (uint16_t)aHz; 456 499 500 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 501 m->pMachine->i_setModified(Machine::IsModified_Capture); 502 mlock.release(); 503 457 504 return S_OK; 458 505 } … … 474 521 return setError(E_INVALIDARG, tr("Cannot change audio bits while capturing is enabled")); 475 522 476 m->pMachine->i_setModified(Machine::IsModified_Capture); 477 m->bd.backup(); 478 523 m->bd.backup(); 479 524 m->bd->Audio.cBits = (uint8_t)aBits; 480 525 526 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 527 m->pMachine->i_setModified(Machine::IsModified_Capture); 528 mlock.release(); 529 481 530 return S_OK; 482 531 } … … 498 547 return setError(E_INVALIDARG, tr("Cannot change audio channels while capturing is enabled")); 499 548 500 m->pMachine->i_setModified(Machine::IsModified_Capture); 501 m->bd.backup(); 502 549 m->bd.backup(); 503 550 m->bd->Audio.cChannels = (uint8_t)aChannels; 504 551 552 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 553 m->pMachine->i_setModified(Machine::IsModified_Capture); 554 mlock.release(); 555 505 556 return S_OK; 506 557 } … … 522 573 return setError(E_INVALIDARG, tr("Cannot change video codec while capturing is enabled")); 523 574 524 m->pMachine->i_setModified(Machine::IsModified_Capture); 525 m->bd.backup(); 526 575 m->bd.backup(); 527 576 m->bd->Video.enmCodec = aCodec; 528 577 578 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 579 m->pMachine->i_setModified(Machine::IsModified_Capture); 580 mlock.release(); 581 529 582 return S_OK; 530 583 } … … 546 599 return setError(E_INVALIDARG, tr("Cannot change video width while capturing is enabled")); 547 600 548 m->pMachine->i_setModified(Machine::IsModified_Capture); 549 m->bd.backup(); 550 601 m->bd.backup(); 551 602 m->bd->Video.ulWidth = aVideoWidth; 552 603 604 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 605 m->pMachine->i_setModified(Machine::IsModified_Capture); 606 mlock.release(); 607 553 608 return S_OK; 554 609 } … … 570 625 return setError(E_INVALIDARG, tr("Cannot change video height while capturing is enabled")); 571 626 572 m->pMachine->i_setModified(Machine::IsModified_Capture); 573 m->bd.backup(); 574 627 m->bd.backup(); 575 628 m->bd->Video.ulHeight = aVideoHeight; 576 629 630 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 631 m->pMachine->i_setModified(Machine::IsModified_Capture); 632 mlock.release(); 633 577 634 return S_OK; 578 635 } … … 594 651 return setError(E_INVALIDARG, tr("Cannot change video rate while capturing is enabled")); 595 652 596 m->pMachine->i_setModified(Machine::IsModified_Capture); 597 m->bd.backup(); 598 653 m->bd.backup(); 599 654 m->bd->Video.ulRate = aVideoRate; 655 656 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 657 m->pMachine->i_setModified(Machine::IsModified_Capture); 658 mlock.release(); 600 659 601 660 return S_OK; … … 640 699 return setError(E_INVALIDARG, tr("Cannot change video FPS while capturing is enabled")); 641 700 642 m->pMachine->i_setModified(Machine::IsModified_Capture); 643 m->bd.backup(); 644 701 m->bd.backup(); 645 702 m->bd->Video.ulFPS = aVideoFPS; 703 704 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 705 m->pMachine->i_setModified(Machine::IsModified_Capture); 706 mlock.release(); 646 707 647 708 return S_OK; … … 685 746 * Returns the full path to the default video capture file. 686 747 */ 687 int CaptureScreenSettings::i_getDefault CaptureFile(Utf8Str &strFile)748 int CaptureScreenSettings::i_getDefaultFileName(Utf8Str &strFile) 688 749 { 689 750 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); … … 696 757 } 697 758 759 /** 760 * Initializes data, internal version. 761 * 762 * @returns IPRT status code. 763 */ 764 int CaptureScreenSettings::i_initInternal(void) 765 { 766 Assert(m); 767 return i_getDefaultFileName(m->bd->File.strName); 768 } 769 -
trunk/src/VBox/Main/src-server/CaptureSettingsImpl.cpp
r75287 r75307 44 44 ComObjPtr<CaptureSettings> pPeer; 45 45 CaptureScreenSettingsMap mapScreenSettings; 46 bool fHasMachineLock; 46 47 47 48 // use the XML settings structure in the members for simplicity … … 84 85 85 86 m->bd.allocate(); 87 m->fHasMachineLock = false; 86 88 87 89 autoInitSpan.setSucceeded(); … … 119 121 m->bd.share(that->m->bd); 120 122 m->mapScreenSettings = that->m->mapScreenSettings; 123 m->fHasMachineLock = false; 121 124 122 125 autoInitSpan.setSucceeded(); … … 151 154 m->bd.attachCopy(that->m->bd); 152 155 m->mapScreenSettings = that->m->mapScreenSettings; 156 m->fHasMachineLock = false; 153 157 154 158 autoInitSpan.setSucceeded(); … … 196 200 HRESULT CaptureSettings::setEnabled(BOOL enable) 197 201 { 198 /* the machine needs to be mutable */199 AutoMutableStateDependency adep(m->pMachine);200 if (FAILED(adep.rc())) return adep.rc();201 202 202 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 203 203 … … 216 216 { 217 217 /* 218 * Normally we would do the actual change _after_ i_on VideoCaptureChange() succeeded.219 * We cannot do this because that function uses Machine::GetVideoCaptureEnabled to218 * Normally we would do the actual change _after_ i_onCaptureChange() succeeded. 219 * We cannot do this because that function uses CaptureSettings::GetEnabled to 220 220 * determine if it should start or stop capturing. Therefore we need to manually 221 221 * undo change. … … 230 230 m->pMachine->i_setModified(Machine::IsModified_Capture); 231 231 232 /* We need to indicate here that we just took the machine lock, as Machine::i_saveSettings() will 233 * call i_commit(), which in turn also wants to lock the machine for writing. */ 234 m->fHasMachineLock = true; 235 232 236 /** Save settings if online - @todo why is this required? -- @bugref{6818} */ 233 if (Global::IsOnline(adep.machineState())) 234 m->pMachine->i_saveSettings(NULL); 237 if (Global::IsOnline(m->pMachine->i_getMachineState())) 238 rc = m->pMachine->i_saveSettings(NULL); 239 240 m->fHasMachineLock = false; 235 241 } 236 242 } … … 251 257 { 252 258 itScreenSettings->second.queryInterfaceTo(aCaptureScreenSettings[i].asOutParam()); 259 Assert(aCaptureScreenSettings[i].isNotNull()); 253 260 ++i; 254 261 ++itScreenSettings; 255 262 } 256 263 264 Assert(aCaptureScreenSettings.size() == m->mapScreenSettings.size()); 265 257 266 return S_OK; 258 267 } … … 280 289 281 290 /** 291 * Adds a screen settings object to the recording settings. 292 * 293 * @returns IPRT status code. VERR_ALREADY_EXISTS if the object in question already exists. 294 * @param uScreenId Screen ID to add settings for. 295 * @param data Recording screen settings to use for that screen. 296 */ 297 int CaptureSettings::i_addScreen(uint32_t uScreenId, const settings::CaptureScreenSettings &data) 298 { 299 if (m->mapScreenSettings.find(uScreenId) != m->mapScreenSettings.end()) 300 { 301 AssertFailed(); 302 return VERR_ALREADY_EXISTS; 303 } 304 305 int vrc = VINF_SUCCESS; 306 307 ComObjPtr<CaptureScreenSettings> captureScreenSettings; 308 HRESULT rc = captureScreenSettings.createObject(); 309 if (SUCCEEDED(rc)) 310 { 311 rc = captureScreenSettings->init(m->pMachine, uScreenId, data); 312 if (SUCCEEDED(rc)) 313 { 314 try 315 { 316 m->mapScreenSettings[uScreenId] = captureScreenSettings; 317 } 318 catch (std::bad_alloc &) 319 { 320 vrc = VERR_NO_MEMORY; 321 } 322 } 323 } 324 325 return vrc; 326 } 327 328 /** 282 329 * Loads settings from the given settings. 283 330 * May be called once right after this object creation. … … 301 348 while (itScreen != data.mapScreens.end()) 302 349 { 303 ComObjPtr<CaptureScreenSettings> captureScreenSettings; 304 rc = captureScreenSettings.createObject(); 305 if (FAILED(rc)) 350 int vrc = i_addScreen(itScreen->first /* uScreenId */, itScreen->second /* Settings */); 351 if (RT_FAILURE(vrc)) 352 { 353 rc = E_OUTOFMEMORY; 306 354 break; 307 308 rc = captureScreenSettings->init(m->pMachine, itScreen->first /* uScreenId */, itScreen->second /* Settings */); 309 if (FAILED(rc)) 310 break; 311 312 m->mapScreenSettings[itScreen->first] = captureScreenSettings; 355 } 313 356 314 357 ++itScreen; 315 358 } 359 360 if (FAILED(rc)) 361 return rc; 316 362 317 363 ComAssertComRC(rc); … … 378 424 { 379 425 /* attach new data to the peer and reshare it */ 380 AutoWriteLock peerlock(m->pPeer COMMA_LOCKVAL_SRC_POS); 426 AutoWriteLock peerlock(RT_SRC_POS); 427 if (!m->fHasMachineLock) 428 peerlock.attach(m->pPeer); 381 429 m->pPeer->m->bd.attach(m->bd); 382 430 } -
trunk/src/VBox/Main/xml/Settings.cpp
r75283 r75307 2387 2387 */ 2388 2388 2389 fEnabled = true;2389 fEnabled = false; 2390 2390 enmDest = CaptureDestination_File; 2391 2391 ulMaxTimeS = 0; 2392 2392 strOptions = ""; 2393 2393 File.ulMaxSizeMB = 0; 2394 File.strName = ""; 2394 2395 Video.enmCodec = CaptureVideoCodec_VP8; 2395 2396 Video.ulWidth = 1024; … … 2404 2405 featureMap[CaptureFeature_Video] = true; 2405 2406 featureMap[CaptureFeature_Audio] = false; 2406 2407 //i_calculateFullPath2408 2407 } 2409 2408 … … 2413 2412 bool CaptureScreenSettings::areDefaultSettings(void) const 2414 2413 { 2415 const bool fDefault = fEnabled == true 2416 && enmDest == CaptureDestination_File 2417 && ulMaxTimeS == 0 2418 && strOptions == "" 2419 && File.ulMaxSizeMB == 0 2420 && Video.enmCodec == CaptureVideoCodec_VP8 2421 && Video.ulWidth == 1024 2422 && Video.ulHeight == 768 2423 && Video.ulRate == 512 2424 && Video.ulFPS == 25 2425 && Audio.enmAudioCodec == CaptureAudioCodec_Opus 2426 && Audio.cBits == 16 2427 && Audio.cChannels == 2 2428 && Audio.uHz == 22050; 2429 2430 return fDefault; 2414 return fEnabled == false 2415 && enmDest == CaptureDestination_File 2416 && ulMaxTimeS == 0 2417 && strOptions == "" 2418 && File.ulMaxSizeMB == 0 2419 && File.strName == "" 2420 && Video.enmCodec == CaptureVideoCodec_VP8 2421 && Video.ulWidth == 1024 2422 && Video.ulHeight == 768 2423 && Video.ulRate == 512 2424 && Video.ulFPS == 25 2425 && Audio.enmAudioCodec == CaptureAudioCodec_Opus 2426 && Audio.cBits == 16 2427 && Audio.cChannels == 2 2428 && Audio.uHz == 22050; 2431 2429 } 2432 2430 … … 2472 2470 } 2473 2471 2472 /** 2473 * Applies the default settings. 2474 */ 2474 2475 void CaptureSettings::applyDefaults(void) 2475 2476 { … … 2478 2479 mapScreens.clear(); 2479 2480 2480 CaptureScreenSettings screenSettings; /* Apply default settings. */ 2481 for (uint32_t l = 0; l < SchemaDefs::MaxGuestMonitors; l++) 2482 { 2483 mapScreens[l] = screenSettings; 2481 try 2482 { 2483 /* Always add screen 0 to the default configuration. */ 2484 CaptureScreenSettings screenSettings; /* Apply default settings for screen 0. */ 2485 mapScreens[0] = screenSettings; 2486 } 2487 catch (std::bad_alloc &) 2488 { 2489 AssertFailed(); 2484 2490 } 2485 2491 } … … 2490 2496 bool CaptureSettings::areDefaultSettings() const 2491 2497 { 2498 const bool fDefault = fEnabled == false 2499 && mapScreens.size() == 1; 2500 if (!fDefault) 2501 return false; 2502 2492 2503 CaptureScreenMap::const_iterator itScreen = mapScreens.begin(); 2493 while (itScreen != mapScreens.end()) 2494 { 2495 if (!itScreen->second.areDefaultSettings()) 2496 return false; 2497 2498 ++itScreen; 2499 } 2500 2501 return true; 2504 return itScreen->first == 0 2505 && itScreen->second.areDefaultSettings(); 2502 2506 } 2503 2507 … … 4413 4417 /* At the moment we only support one capturing configuration, that is, all screens 4414 4418 * have the same configuration. So load/save to/from screen 0. */ 4419 Assert(hw.captureSettings.mapScreens.size()); /* At least screen must be present. */ 4415 4420 CaptureScreenSettings &screen0Settings = hw.captureSettings.mapScreens[0]; 4416 4421 … … 4424 4429 pelmHwChild->getAttributeValue("fps", screen0Settings.Video.ulFPS); 4425 4430 4426 for (unsigned i = 0; i < 64; i++)4431 for (unsigned i = 0; i < hw.cMonitors; i++) /* Don't add more settings than we have monitors configured. */ 4427 4432 { 4428 4433 if (u64VideoCaptureScreens & RT_BIT_64(i)) /* Screen i enabled? */ … … 5839 5844 Assert(hw.captureSettings.mapScreens.size()); 5840 5845 const CaptureScreenMap::const_iterator itScreen0Settings = hw.captureSettings.mapScreens.find(0); 5846 Assert(itScreen0Settings != hw.captureSettings.mapScreens.end()); 5841 5847 5842 5848 if (itScreen0Settings->second.ulMaxTimeS)
Note:
See TracChangeset
for help on using the changeset viewer.

