Changeset 75324 in vbox for trunk/src/VBox/Main/src-server
- Timestamp:
- Nov 8, 2018 3:39:50 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 126445
- Location:
- trunk/src/VBox/Main/src-server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/CaptureScreenSettingsImpl.cpp
r75313 r75324 17 17 */ 18 18 19 #define LOG_GROUP LOG_GROUP_MAIN_CAPTURESCREENSETTINGS 20 #include "LoggingNew.h" 21 19 22 #include "CaptureScreenSettingsImpl.h" 23 #include "CaptureSettingsImpl.h" 20 24 #include "MachineImpl.h" 21 25 … … 27 31 #include "AutoCaller.h" 28 32 #include "Global.h" 29 #include "Logging.h"30 33 31 34 //////////////////////////////////////////////////////////////////////////////// … … 38 41 { 39 42 Data() 40 : p Machine(NULL)43 : pParent(NULL) 41 44 { } 42 45 43 Machine * const pMachine;46 CaptureSettings * const pParent; 44 47 ComObjPtr<CaptureScreenSettings> pPeer; 45 48 uint32_t uScreenId; … … 73 76 * @returns COM result indicator 74 77 */ 75 HRESULT CaptureScreenSettings::init( Machine*aParent, uint32_t uScreenId, const settings::CaptureScreenSettings& data)78 HRESULT CaptureScreenSettings::init(CaptureSettings *aParent, uint32_t uScreenId, const settings::CaptureScreenSettings& data) 76 79 { 77 80 LogFlowThisFuncEnter(); … … 86 89 m = new Data(); 87 90 88 /* Share the parent weakly. */89 unconst(m->p Machine)= aParent;91 /* Share the parent & machine weakly. */ 92 unconst(m->pParent) = aParent; 90 93 /* mPeer is left null. */ 91 94 … … 120 123 * it shares data with is destroyed. 121 124 */ 122 HRESULT CaptureScreenSettings::init( Machine*aParent, CaptureScreenSettings *that)125 HRESULT CaptureScreenSettings::init(CaptureSettings *aParent, CaptureScreenSettings *that) 123 126 { 124 127 LogFlowThisFuncEnter(); … … 133 136 m = new Data(); 134 137 135 unconst(m->p Machine) = aParent;138 unconst(m->pParent) = aParent; 136 139 m->pPeer = that; 137 140 … … 163 166 * of the original object passed as an argument. 164 167 */ 165 HRESULT CaptureScreenSettings::initCopy( Machine*aParent, CaptureScreenSettings *that)168 HRESULT CaptureScreenSettings::initCopy(CaptureSettings *aParent, CaptureScreenSettings *that) 166 169 { 167 170 LogFlowThisFuncEnter(); … … 176 179 m = new Data(); 177 180 178 unconst(m->p Machine) = aParent;181 unconst(m->pParent) = aParent; 179 182 /* mPeer is left null. */ 180 183 … … 217 220 218 221 unconst(m->pPeer) = NULL; 219 unconst(m->p Machine) = NULL;222 unconst(m->pParent) = NULL; 220 223 221 224 delete m; … … 227 230 HRESULT CaptureScreenSettings::isFeatureEnabled(CaptureFeature_T aFeature, BOOL *aEnabled) 228 231 { 232 AutoCaller autoCaller(this); 233 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 234 235 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 236 229 237 settings::CaptureFeatureMap::const_iterator itFeature = m->bd->featureMap.find(aFeature); 230 238 … … 237 245 HRESULT CaptureScreenSettings::getEnabled(BOOL *enabled) 238 246 { 247 AutoCaller autoCaller(this); 248 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 249 239 250 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 240 251 … … 246 257 HRESULT CaptureScreenSettings::setEnabled(BOOL enabled) 247 258 { 259 AutoCaller autoCaller(this); 260 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 261 262 LogFlowThisFunc(("Screen %RU32\n", m->uScreenId)); 263 264 if (!m->pParent->i_canChangeSettings()) 265 return setError(E_INVALIDARG, tr("Cannot change enabled state of screen while capturing is enabled")); 266 248 267 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 249 268 … … 254 273 alock.release(); 255 274 256 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 257 m->pMachine->i_setModified(Machine::IsModified_Capture); 258 mlock.release(); 259 260 HRESULT rc = m->pMachine->i_onCaptureChange(); 261 if (FAILED(rc)) return rc; 262 263 /** Save settings if online - @todo why is this required? -- @bugref{6818} */ 264 AutoAnyStateDependency adep(m->pMachine); 265 AssertComRCReturn(adep.rc(), E_UNEXPECTED); 266 267 if (Global::IsOnline(adep.machineState())) 268 m->pMachine->i_saveSettings(NULL); 275 m->pParent->i_onSettingsChanged(); 269 276 } 270 277 278 LogFlowThisFunc(("Screen %RU32\n", m->uScreenId)); 271 279 return S_OK; 272 280 } … … 274 282 HRESULT CaptureScreenSettings::getFeatures(ULONG *aFeatures) 275 283 { 284 AutoCaller autoCaller(this); 285 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 286 276 287 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 277 288 … … 292 303 HRESULT CaptureScreenSettings::setFeatures(ULONG aFeatures) 293 304 { 294 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 295 296 if (m->bd->fEnabled) 305 AutoCaller autoCaller(this); 306 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 307 308 if (!m->pParent->i_canChangeSettings()) 297 309 return setError(E_INVALIDARG, tr("Cannot change features while capturing is enabled")); 310 311 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 298 312 299 313 m->bd.backup(); … … 307 321 alock.release(); 308 322 309 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);310 m->pMachine->i_setModified(Machine::IsModified_Capture);311 mlock.release();312 313 323 return S_OK; 314 324 } … … 316 326 HRESULT CaptureScreenSettings::getDestination(CaptureDestination_T *aDestination) 317 327 { 328 AutoCaller autoCaller(this); 329 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 330 318 331 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 319 332 … … 325 338 HRESULT CaptureScreenSettings::setDestination(CaptureDestination_T aDestination) 326 339 { 327 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 328 329 if (m->bd->fEnabled) 340 AutoCaller autoCaller(this); 341 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 342 343 if (!m->pParent->i_canChangeSettings()) 330 344 return setError(E_INVALIDARG, tr("Cannot change destination type while capturing is enabled")); 331 345 346 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 347 332 348 m->bd.backup(); 333 349 m->bd->enmDest = aDestination; 334 350 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 341 351 return S_OK; 342 352 } … … 344 354 HRESULT CaptureScreenSettings::getFileName(com::Utf8Str &aFileName) 345 355 { 356 AutoCaller autoCaller(this); 357 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 358 346 359 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 347 360 … … 353 366 HRESULT CaptureScreenSettings::setFileName(const com::Utf8Str &aFileName) 354 367 { 355 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 356 357 if (m->bd->fEnabled) 368 AutoCaller autoCaller(this); 369 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 370 371 if (!m->pParent->i_canChangeSettings()) 358 372 return setError(E_INVALIDARG, tr("Cannot change file name while capturing is enabled")); 373 374 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 359 375 360 376 Utf8Str strFile(aFileName); … … 366 382 m->bd->File.strName = strFile; 367 383 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 374 384 return S_OK; 375 385 } … … 377 387 HRESULT CaptureScreenSettings::getMaxTime(ULONG *aMaxTimeS) 378 388 { 389 AutoCaller autoCaller(this); 390 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 391 379 392 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 380 393 … … 386 399 HRESULT CaptureScreenSettings::setMaxTime(ULONG aMaxTimeS) 387 400 { 388 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 389 390 if (m->bd->fEnabled) 401 AutoCaller autoCaller(this); 402 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 403 404 if (!m->pParent->i_canChangeSettings()) 391 405 return setError(E_INVALIDARG, tr("Cannot change maximum time while capturing is enabled")); 392 406 407 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 408 393 409 m->bd.backup(); 394 410 m->bd->ulMaxTimeS = aMaxTimeS; 395 411 396 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);397 m->pMachine->i_setModified(Machine::IsModified_Capture);398 mlock.release();399 400 412 return S_OK; 401 413 } … … 403 415 HRESULT CaptureScreenSettings::getMaxFileSize(ULONG *aMaxFileSizeMB) 404 416 { 417 AutoCaller autoCaller(this); 418 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 419 405 420 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 406 421 … … 412 427 HRESULT CaptureScreenSettings::setMaxFileSize(ULONG aMaxFileSize) 413 428 { 414 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 415 416 if (m->bd->fEnabled) 429 AutoCaller autoCaller(this); 430 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 431 432 if (!m->pParent->i_canChangeSettings()) 417 433 return setError(E_INVALIDARG, tr("Cannot change maximum file size while capturing is enabled")); 418 434 435 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 436 419 437 m->bd.backup(); 420 438 m->bd->File.ulMaxSizeMB = aMaxFileSize; 421 439 422 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);423 m->pMachine->i_setModified(Machine::IsModified_Capture);424 mlock.release();425 426 440 return S_OK; 427 441 } … … 429 443 HRESULT CaptureScreenSettings::getOptions(com::Utf8Str &aOptions) 430 444 { 445 AutoCaller autoCaller(this); 446 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 447 431 448 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 432 449 … … 438 455 HRESULT CaptureScreenSettings::setOptions(const com::Utf8Str &aOptions) 439 456 { 440 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 441 442 if (m->bd->fEnabled) 457 AutoCaller autoCaller(this); 458 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 459 460 if (!m->pParent->i_canChangeSettings()) 443 461 return setError(E_INVALIDARG, tr("Cannot change options while capturing is enabled")); 444 462 463 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 464 445 465 m->bd.backup(); 446 466 m->bd->strOptions = aOptions; 447 467 448 alock.release();449 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);450 m->pMachine->i_setModified(Machine::IsModified_Capture);451 452 468 return S_OK; 453 469 } … … 455 471 HRESULT CaptureScreenSettings::getAudioCodec(CaptureAudioCodec_T *aCodec) 456 472 { 473 AutoCaller autoCaller(this); 474 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 475 457 476 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 458 477 … … 464 483 HRESULT CaptureScreenSettings::setAudioCodec(CaptureAudioCodec_T aCodec) 465 484 { 466 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 467 468 if (m->bd->fEnabled) 485 AutoCaller autoCaller(this); 486 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 487 488 if (!m->pParent->i_canChangeSettings()) 469 489 return setError(E_INVALIDARG, tr("Cannot change audio codec while capturing is enabled")); 470 490 491 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 492 471 493 m->bd.backup(); 472 494 m->bd->Audio.enmAudioCodec = aCodec; 473 495 474 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);475 m->pMachine->i_setModified(Machine::IsModified_Capture);476 mlock.release();477 478 496 return S_OK; 479 497 } … … 481 499 HRESULT CaptureScreenSettings::getAudioHz(ULONG *aHz) 482 500 { 501 AutoCaller autoCaller(this); 502 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 503 483 504 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 484 505 … … 490 511 HRESULT CaptureScreenSettings::setAudioHz(ULONG aHz) 491 512 { 492 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 493 494 if (m->bd->fEnabled) 513 AutoCaller autoCaller(this); 514 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 515 516 if (!m->pParent->i_canChangeSettings()) 495 517 return setError(E_INVALIDARG, tr("Cannot change audio Hertz rate while capturing is enabled")); 496 518 519 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 520 497 521 m->bd.backup(); 498 522 m->bd->Audio.uHz = (uint16_t)aHz; 499 523 500 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);501 m->pMachine->i_setModified(Machine::IsModified_Capture);502 mlock.release();503 504 524 return S_OK; 505 525 } … … 507 527 HRESULT CaptureScreenSettings::getAudioBits(ULONG *aBits) 508 528 { 529 AutoCaller autoCaller(this); 530 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 531 509 532 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 510 533 … … 516 539 HRESULT CaptureScreenSettings::setAudioBits(ULONG aBits) 517 540 { 518 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 519 520 if (m->bd->fEnabled) 541 AutoCaller autoCaller(this); 542 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 543 544 if (!m->pParent->i_canChangeSettings()) 521 545 return setError(E_INVALIDARG, tr("Cannot change audio bits while capturing is enabled")); 522 546 547 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 548 523 549 m->bd.backup(); 524 550 m->bd->Audio.cBits = (uint8_t)aBits; 525 551 526 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);527 m->pMachine->i_setModified(Machine::IsModified_Capture);528 mlock.release();529 530 552 return S_OK; 531 553 } … … 533 555 HRESULT CaptureScreenSettings::getAudioChannels(ULONG *aChannels) 534 556 { 557 AutoCaller autoCaller(this); 558 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 559 535 560 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 536 561 … … 542 567 HRESULT CaptureScreenSettings::setAudioChannels(ULONG aChannels) 543 568 { 544 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 545 546 if (m->bd->fEnabled) 569 AutoCaller autoCaller(this); 570 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 571 572 if (!m->pParent->i_canChangeSettings()) 547 573 return setError(E_INVALIDARG, tr("Cannot change audio channels while capturing is enabled")); 548 574 575 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 576 549 577 m->bd.backup(); 550 578 m->bd->Audio.cChannels = (uint8_t)aChannels; 551 579 552 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);553 m->pMachine->i_setModified(Machine::IsModified_Capture);554 mlock.release();555 556 580 return S_OK; 557 581 } … … 559 583 HRESULT CaptureScreenSettings::getVideoCodec(CaptureVideoCodec_T *aCodec) 560 584 { 585 AutoCaller autoCaller(this); 586 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 587 561 588 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 562 589 … … 568 595 HRESULT CaptureScreenSettings::setVideoCodec(CaptureVideoCodec_T aCodec) 569 596 { 570 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 571 572 if (m->bd->fEnabled) 597 AutoCaller autoCaller(this); 598 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 599 600 if (!m->pParent->i_canChangeSettings()) 573 601 return setError(E_INVALIDARG, tr("Cannot change video codec while capturing is enabled")); 574 602 603 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 604 575 605 m->bd.backup(); 576 606 m->bd->Video.enmCodec = aCodec; 577 607 578 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);579 m->pMachine->i_setModified(Machine::IsModified_Capture);580 mlock.release();581 582 608 return S_OK; 583 609 } … … 585 611 HRESULT CaptureScreenSettings::getVideoWidth(ULONG *aVideoWidth) 586 612 { 613 AutoCaller autoCaller(this); 614 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 615 587 616 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 588 617 … … 594 623 HRESULT CaptureScreenSettings::setVideoWidth(ULONG aVideoWidth) 595 624 { 596 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 597 598 if (m->bd->fEnabled) 625 AutoCaller autoCaller(this); 626 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 627 628 if (!m->pParent->i_canChangeSettings()) 599 629 return setError(E_INVALIDARG, tr("Cannot change video width while capturing is enabled")); 600 630 631 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 632 601 633 m->bd.backup(); 602 634 m->bd->Video.ulWidth = aVideoWidth; 603 635 604 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);605 m->pMachine->i_setModified(Machine::IsModified_Capture);606 mlock.release();607 608 636 return S_OK; 609 637 } … … 611 639 HRESULT CaptureScreenSettings::getVideoHeight(ULONG *aVideoHeight) 612 640 { 641 AutoCaller autoCaller(this); 642 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 643 613 644 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 614 645 … … 620 651 HRESULT CaptureScreenSettings::setVideoHeight(ULONG aVideoHeight) 621 652 { 622 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 623 624 if (m->bd->fEnabled) 653 AutoCaller autoCaller(this); 654 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 655 656 if (!m->pParent->i_canChangeSettings()) 625 657 return setError(E_INVALIDARG, tr("Cannot change video height while capturing is enabled")); 626 658 659 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 660 627 661 m->bd.backup(); 628 662 m->bd->Video.ulHeight = aVideoHeight; 629 663 630 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);631 m->pMachine->i_setModified(Machine::IsModified_Capture);632 mlock.release();633 634 664 return S_OK; 635 665 } … … 637 667 HRESULT CaptureScreenSettings::getVideoRate(ULONG *aVideoRate) 638 668 { 669 AutoCaller autoCaller(this); 670 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 671 639 672 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 640 673 … … 646 679 HRESULT CaptureScreenSettings::setVideoRate(ULONG aVideoRate) 647 680 { 648 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 649 650 if (m->bd->fEnabled) 681 AutoCaller autoCaller(this); 682 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 683 684 if (!m->pParent->i_canChangeSettings()) 651 685 return setError(E_INVALIDARG, tr("Cannot change video rate while capturing is enabled")); 652 686 687 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 688 653 689 m->bd.backup(); 654 690 m->bd->Video.ulRate = aVideoRate; 655 691 656 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);657 m->pMachine->i_setModified(Machine::IsModified_Capture);658 mlock.release();659 660 692 return S_OK; 661 693 } … … 663 695 HRESULT CaptureScreenSettings::getVideoRateControlMode(CaptureVideoRateControlMode_T *aMode) 664 696 { 697 AutoCaller autoCaller(this); 698 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 699 665 700 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 666 701 … … 672 707 HRESULT CaptureScreenSettings::setVideoRateControlMode(CaptureVideoRateControlMode_T aMode) 673 708 { 674 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 675 676 if (m->bd->fEnabled) 709 AutoCaller autoCaller(this); 710 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 711 712 if (!m->pParent->i_canChangeSettings()) 677 713 return setError(E_INVALIDARG, tr("Cannot change video rate control mode while capturing is enabled")); 714 715 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 678 716 679 717 /** @todo Implement this. */ … … 685 723 HRESULT CaptureScreenSettings::getVideoFPS(ULONG *aVideoFPS) 686 724 { 725 AutoCaller autoCaller(this); 726 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 727 687 728 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 688 729 … … 694 735 HRESULT CaptureScreenSettings::setVideoFPS(ULONG aVideoFPS) 695 736 { 696 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 697 698 if (m->bd->fEnabled) 737 AutoCaller autoCaller(this); 738 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 739 740 if (!m->pParent->i_canChangeSettings()) 699 741 return setError(E_INVALIDARG, tr("Cannot change video FPS while capturing is enabled")); 700 742 743 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 744 701 745 m->bd.backup(); 702 746 m->bd->Video.ulFPS = aVideoFPS; 703 747 704 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS);705 m->pMachine->i_setModified(Machine::IsModified_Capture);706 mlock.release();707 708 748 return S_OK; 709 749 } … … 711 751 HRESULT CaptureScreenSettings::getVideoScalingMethod(CaptureVideoScalingMethod_T *aMode) 712 752 { 753 AutoCaller autoCaller(this); 754 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 755 713 756 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 714 757 … … 720 763 HRESULT CaptureScreenSettings::setVideoScalingMethod(CaptureVideoScalingMethod_T aMode) 721 764 { 722 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 723 724 if (m->bd->fEnabled) 765 AutoCaller autoCaller(this); 766 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 767 768 if (!m->pParent->i_canChangeSettings()) 725 769 return setError(E_INVALIDARG, tr("Cannot change video rate scaling method while capturing is enabled")); 770 771 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 726 772 727 773 /** @todo Implement this. */ … … 729 775 730 776 return E_NOTIMPL; 731 }732 733 /**734 * Returns the full path to the default video capture file.735 */736 int CaptureScreenSettings::i_getDefaultFileName(Utf8Str &strFile)737 {738 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);739 740 strFile = m->pMachine->i_getSettingsFileFull(); // path/to/machinesfolder/vmname/vmname.vbox741 strFile.stripSuffix(); // path/to/machinesfolder/vmname/vmname742 strFile.append(".webm"); // path/to/machinesfolder/vmname/vmname.webm743 744 return VINF_SUCCESS;745 777 } 746 778 … … 753 785 { 754 786 Assert(m); 755 return i_getDefaultFileName(m->bd->File.strName); 756 } 757 787 788 int rc = VINF_SUCCESS; 789 790 switch (m->bd->enmDest) 791 { 792 case CaptureDestination_File: 793 { 794 if (m->bd->File.strName.isEmpty()) 795 rc = m->pParent->i_getDefaultFileName(m->bd->File.strName); 796 break; 797 } 798 799 default: 800 break; 801 } 802 803 return rc; 804 } 805 -
trunk/src/VBox/Main/src-server/CaptureSettingsImpl.cpp
r75308 r75324 17 17 */ 18 18 19 #define LOG_GROUP LOG_GROUP_MAIN_CAPTURESETTINGS 20 #include "LoggingNew.h" 21 19 22 #include "CaptureSettingsImpl.h" 20 23 #include "CaptureScreenSettingsImpl.h" … … 27 30 #include "AutoCaller.h" 28 31 #include "Global.h" 29 #include "Logging.h"30 32 31 33 //////////////////////////////////////////////////////////////////////////////// … … 43 45 Machine * const pMachine; 44 46 ComObjPtr<CaptureSettings> pPeer; 45 CaptureScreenSettingsMap mapScreen Settings;47 CaptureScreenSettingsMap mapScreenObj; 46 48 bool fHasMachineLock; 47 49 … … 120 122 121 123 m->bd.share(that->m->bd); 122 m->mapScreen Settings = that->m->mapScreenSettings;124 m->mapScreenObj = that->m->mapScreenObj; 123 125 m->fHasMachineLock = false; 124 126 … … 153 155 154 156 m->bd.attachCopy(that->m->bd); 155 m->mapScreen Settings = that->m->mapScreenSettings;157 m->mapScreenObj = that->m->mapScreenObj; 156 158 m->fHasMachineLock = false; 157 159 … … 175 177 return; 176 178 179 /* Note: Do *not* call i_reset() here, as the shared recording configuration 180 * otherwise gets destructed when this object goes out of scope or is destroyed. */ 181 177 182 m->bd.free(); 178 183 … … 200 205 HRESULT CaptureSettings::setEnabled(BOOL enable) 201 206 { 207 LogFlowThisFuncEnter(); 208 202 209 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 203 210 … … 223 230 alock.acquire(); 224 231 m->bd->fEnabled = m->bd.backedUpData()->fEnabled; 225 return rc;226 232 } 227 233 else … … 247 253 HRESULT CaptureSettings::getScreens(std::vector<ComPtr<ICaptureScreenSettings> > &aCaptureScreenSettings) 248 254 { 255 LogFlowThisFuncEnter(); 256 257 i_syncToMachineDisplays(); 258 249 259 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 250 260 251 261 aCaptureScreenSettings.clear(); 252 aCaptureScreenSettings.resize(m->mapScreen Settings.size());253 254 CaptureScreenSettingsMap::const_iterator itScreenSettings = m->mapScreen Settings.begin();262 aCaptureScreenSettings.resize(m->mapScreenObj.size()); 263 264 CaptureScreenSettingsMap::const_iterator itScreenSettings = m->mapScreenObj.begin(); 255 265 size_t i = 0; 256 while (itScreenSettings != m->mapScreen Settings.end())266 while (itScreenSettings != m->mapScreenObj.end()) 257 267 { 258 268 itScreenSettings->second.queryInterfaceTo(aCaptureScreenSettings[i].asOutParam()); … … 262 272 } 263 273 264 Assert(aCaptureScreenSettings.size() == m->mapScreen Settings.size());274 Assert(aCaptureScreenSettings.size() == m->mapScreenObj.size()); 265 275 266 276 return S_OK; … … 269 279 HRESULT CaptureSettings::getScreenSettings(ULONG uScreenId, ComPtr<ICaptureScreenSettings> &aCaptureScreenSettings) 270 280 { 271 if (uScreenId + 1 > m->mapScreenSettings.size()) 281 LogFlowThisFuncEnter(); 282 283 i_syncToMachineDisplays(); 284 285 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 286 287 if (uScreenId + 1 > m->mapScreenObj.size()) 272 288 return setError(E_INVALIDARG, tr("Invalid screen ID specified")); 273 289 274 CaptureScreenSettingsMap::const_iterator itScreenSettings = m->mapScreen Settings.find(uScreenId);275 if (itScreenSettings != m->mapScreen Settings.end())290 CaptureScreenSettingsMap::const_iterator itScreenSettings = m->mapScreenObj.find(uScreenId); 291 if (itScreenSettings != m->mapScreenObj.end()) 276 292 { 277 293 itScreenSettings->second.queryInterfaceTo(aCaptureScreenSettings.asOutParam()); … … 289 305 290 306 /** 291 * Adds a screen settings object to the recording settings.307 * Adds a screen settings object to a particular map. 292 308 * 293 309 * @returns IPRT status code. VERR_ALREADY_EXISTS if the object in question already exists. 310 * @param screenSettingsMap Map to add screen settings to. 294 311 * @param uScreenId Screen ID to add settings for. 295 312 * @param data Recording screen settings to use for that screen. 296 313 */ 297 int CaptureSettings::i_addScreen(uint32_t uScreenId, const settings::CaptureScreenSettings &data) 298 { 299 if (m->mapScreenSettings.find(uScreenId) != m->mapScreenSettings.end()) 314 int CaptureSettings::i_createScreenObj(CaptureScreenSettingsMap &screenSettingsMap, 315 uint32_t uScreenId, const settings::CaptureScreenSettings &data) 316 { 317 LogFlowThisFunc(("Screen %RU32\n", uScreenId)); 318 319 if (screenSettingsMap.find(uScreenId) != screenSettingsMap.end()) 300 320 { 301 321 AssertFailed(); … … 309 329 if (SUCCEEDED(rc)) 310 330 { 311 rc = captureScreenSettings->init( m->pMachine, uScreenId, data);331 rc = captureScreenSettings->init(this, uScreenId, data); 312 332 if (SUCCEEDED(rc)) 313 333 { 314 334 try 315 335 { 316 m->mapScreenSettings[uScreenId] = captureScreenSettings;336 screenSettingsMap[uScreenId] = captureScreenSettings; 317 337 } 318 338 catch (std::bad_alloc &) … … 327 347 328 348 /** 349 * Removes a screen settings object from a particular map. 350 * 351 * @returns IPRT status code. VERR_NOT_FOUND if specified screen was not found. 352 * @param screenSettingsMap Map to remove screen settings from. 353 * @param uScreenId ID of screen to remove. 354 */ 355 int CaptureSettings::i_destroyScreenObj(CaptureScreenSettingsMap &screenSettingsMap, uint32_t uScreenId) 356 { 357 LogFlowThisFunc(("Screen %RU32\n", uScreenId)); 358 359 AssertReturn(uScreenId > 0, VERR_INVALID_PARAMETER); /* Removing screen 0 isn't a good idea. */ 360 361 CaptureScreenSettingsMap::iterator itScreen = screenSettingsMap.find(uScreenId); 362 if (itScreen == screenSettingsMap.end()) 363 { 364 AssertFailed(); 365 return VERR_NOT_FOUND; 366 } 367 368 /* Make sure to consume the pointer before the one of the 369 * iterator gets released. */ 370 ComObjPtr<CaptureScreenSettings> pScreenSettings = itScreen->second; 371 372 screenSettingsMap.erase(itScreen); 373 374 pScreenSettings.setNull(); 375 376 return VINF_SUCCESS; 377 } 378 379 /** 380 * Destroys all screen settings objects of a particular map. 381 * 382 * @returns IPRT status code. 383 * @param screenSettingsMap Map to destroy screen settings objects for. 384 */ 385 int CaptureSettings::i_destroyAllScreenObj(CaptureScreenSettingsMap &screenSettingsMap) 386 { 387 LogFlowThisFuncEnter(); 388 389 CaptureScreenSettingsMap::const_iterator itScreen = screenSettingsMap.begin(); 390 if (itScreen != screenSettingsMap.end()) 391 { 392 /* Make sure to consume the pointer before the one of the 393 * iterator gets released. */ 394 ComObjPtr<CaptureScreenSettings> pScreenSettings = itScreen->second; 395 396 screenSettingsMap.erase(itScreen); 397 398 pScreenSettings.setNull(); 399 400 itScreen = screenSettingsMap.begin(); 401 } 402 403 return VINF_SUCCESS; 404 } 405 406 /** 329 407 * Loads settings from the given settings. 330 408 * May be called once right after this object creation. … … 336 414 HRESULT CaptureSettings::i_loadSettings(const settings::CaptureSettings &data) 337 415 { 416 LogFlowThisFuncEnter(); 417 338 418 AutoCaller autoCaller(this); 339 419 AssertComRCReturnRC(autoCaller.rc()); … … 343 423 HRESULT rc = S_OK; 344 424 345 m->mapScreenSettings.clear(); 425 i_reset(); 426 427 LogFlowThisFunc(("Data has %zu screens\n", data.mapScreens.size())); 346 428 347 429 settings::CaptureScreenMap::const_iterator itScreen = data.mapScreens.begin(); 348 430 while (itScreen != data.mapScreens.end()) 349 431 { 350 int vrc = i_addScreen(itScreen->first /* uScreenId */, itScreen->second /* Settings */); 432 int vrc = i_createScreenObj(m->mapScreenObj, 433 itScreen->first /* uScreenId */, itScreen->second /* Settings */); 351 434 if (RT_FAILURE(vrc)) 352 435 { … … 362 445 363 446 ComAssertComRC(rc); 364 Assert(m->mapScreen Settings.size() == data.mapScreens.size());447 Assert(m->mapScreenObj.size() == data.mapScreens.size()); 365 448 366 449 // simply copy 367 450 m->bd.assignCopy(&data); 368 451 452 LogFlowThisFunc(("Returning %Rhrc\n", rc)); 369 453 return rc; 370 454 } 371 455 372 456 /** 457 * Resets the internal object state by destroying all screen settings objects. 458 */ 459 void CaptureSettings::i_reset(void) 460 { 461 LogFlowThisFuncEnter(); 462 463 i_destroyAllScreenObj(m->mapScreenObj); 464 m->bd->mapScreens.clear(); 465 } 466 467 /** 373 468 * Saves settings to the given settings. 374 469 * … … 379 474 HRESULT CaptureSettings::i_saveSettings(settings::CaptureSettings &data) 380 475 { 476 LogFlowThisFuncEnter(); 477 381 478 AutoCaller autoCaller(this); 382 479 AssertComRCReturnRC(autoCaller.rc()); 480 481 int rc2 = i_syncToMachineDisplays(); 482 AssertRC(rc2); 383 483 384 484 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); … … 395 495 } 396 496 497 LogFlowThisFuncLeave(); 397 498 return S_OK; 398 499 } … … 462 563 } 463 564 565 /** 566 * Returns the full path to the default video capture file. 567 */ 568 int CaptureSettings::i_getDefaultFileName(Utf8Str &strFile) 569 { 570 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 571 572 strFile = m->pMachine->i_getSettingsFileFull(); // path/to/machinesfolder/vmname/vmname.vbox 573 strFile.stripSuffix(); // path/to/machinesfolder/vmname/vmname 574 strFile.append(".webm"); // path/to/machinesfolder/vmname/vmname.webm 575 576 return VINF_SUCCESS; 577 } 578 579 /** 580 * Determines whether the recording settings currently can be changed or not. 581 * 582 * @returns \c true if the settings can be changed, \c false if not. 583 */ 584 bool CaptureSettings::i_canChangeSettings(void) 585 { 586 AutoAnyStateDependency adep(m->pMachine); 587 if (FAILED(adep.rc())) 588 return false; 589 590 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 591 592 /* Only allow settings to be changed when recording is disabled. */ 593 return m->bd->fEnabled == false; 594 } 595 596 /** 597 * Gets called when the machine object needs to know that the recording settings 598 * have been changed. 599 */ 600 void CaptureSettings::i_onSettingsChanged(void) 601 { 602 LogFlowThisFuncEnter(); 603 604 AutoWriteLock mlock(m->pMachine COMMA_LOCKVAL_SRC_POS); 605 m->pMachine->i_setModified(Machine::IsModified_Capture); 606 mlock.release(); 607 608 LogFlowThisFuncLeave(); 609 } 610 611 /** 612 * Synchronizes the screen settings (COM) objects and configuration data 613 * to the number of the machine's configured displays. 614 */ 615 int CaptureSettings::i_syncToMachineDisplays(void) 616 { 617 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 618 619 AssertPtr(m->pMachine); 620 const ULONG cMonitors = m->pMachine->i_getMonitorCount(); 621 622 LogFlowThisFunc(("cMonitors=%RU32\n", cMonitors)); 623 LogFlowThisFunc(("Data screen count = %zu, COM object count = %zu\n", m->bd->mapScreens.size(), m->mapScreenObj.size())); 624 625 /* If counts match, take a shortcut. */ 626 if (cMonitors == m->mapScreenObj.size()) 627 return VINF_SUCCESS; 628 629 /* Create all new screen settings objects which are not there yet. */ 630 for (ULONG i = 0; i < cMonitors; i++) 631 { 632 if (m->mapScreenObj.find(i) == m->mapScreenObj.end()) 633 { 634 settings::CaptureScreenMap::const_iterator itScreen = m->bd->mapScreens.find(i); 635 if (itScreen == m->bd->mapScreens.end()) 636 { 637 settings::CaptureScreenSettings defaultScreenSettings; /* Apply default settings. */ 638 m->bd->mapScreens[i] = defaultScreenSettings; 639 } 640 641 int vrc2 = i_createScreenObj(m->mapScreenObj, i /* Screen ID */, m->bd->mapScreens[i]); 642 AssertRC(vrc2); 643 } 644 } 645 646 /* Remove all left over screen settings objects which are not needed anymore. */ 647 const ULONG cSettings = (ULONG)m->mapScreenObj.size(); 648 for (ULONG i = cMonitors; i < cSettings; i++) 649 { 650 m->bd->mapScreens.erase(i); 651 int vrc2 = i_destroyScreenObj(m->mapScreenObj, i /* Screen ID */); 652 AssertRC(vrc2); 653 } 654 655 Assert(m->mapScreenObj.size() == cMonitors); 656 Assert(m->bd->mapScreens.size() == cMonitors); 657 658 LogFlowThisFuncLeave(); 659 return VINF_SUCCESS; 660 } 661
Note:
See TracChangeset
for help on using the changeset viewer.