Changeset 75251 in vbox for trunk/src/VBox/Main/src-server
- Timestamp:
- Nov 5, 2018 5:55:29 PM (6 years ago)
- Location:
- trunk/src/VBox/Main/src-server
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r74804 r75251 5 5 6 6 /* 7 * Copyright (C) 2004-201 7Oracle Corporation7 * Copyright (C) 2004-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 168 168 mAccelerate2DVideoEnabled = false; 169 169 mMonitorCount = 1; 170 mVideoCaptureWidth = 1024;171 mVideoCaptureHeight = 768;172 mVideoCaptureRate = 512;173 mVideoCaptureFPS = 25;174 mVideoCaptureMaxTime = 0;175 mVideoCaptureMaxFileSize = 0;176 mVideoCaptureEnabled = false;177 for (unsigned i = 0; i < RT_ELEMENTS(maVideoCaptureScreens); ++i)178 maVideoCaptureScreens[i] = true;179 180 170 mHWVirtExEnabled = true; 181 171 mHWVirtExNestedPagingEnabled = true; … … 365 355 } 366 356 367 /* Apply BIOS defaults */357 /* Apply BIOS defaults. */ 368 358 mBIOSSettings->i_applyDefaults(aOsType); 359 360 /* Apply capture defaults. */ 361 mCaptureSettings->i_applyDefaults(); 369 362 370 363 /* Apply network adapters defaults */ … … 1732 1725 } 1733 1726 1734 HRESULT Machine::getVideoCaptureEnabled(BOOL *aVideoCaptureEnabled)1735 {1736 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);1737 1738 *aVideoCaptureEnabled = mHWData->mVideoCaptureEnabled;1739 return S_OK;1740 }1741 1742 HRESULT Machine::setVideoCaptureEnabled(BOOL aVideoCaptureEnabled)1743 {1744 HRESULT rc = S_OK;1745 1746 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);1747 1748 i_setModified(IsModified_MachineData);1749 mHWData.backup();1750 mHWData->mVideoCaptureEnabled = aVideoCaptureEnabled;1751 1752 alock.release();1753 rc = i_onVideoCaptureChange();1754 alock.acquire();1755 if (FAILED(rc))1756 {1757 /*1758 * Normally we would do the actual change _after_ i_onVideoCaptureChange() succeeded.1759 * We cannot do this because that function uses Machine::GetVideoCaptureEnabled to1760 * determine if it should start or stop capturing. Therefore we need to manually1761 * undo change.1762 */1763 mHWData->mVideoCaptureEnabled = mHWData.backedUpData()->mVideoCaptureEnabled;1764 return rc;1765 }1766 1767 /** Save settings if online - @todo why is this required? -- @bugref{6818} */1768 if (Global::IsOnline(mData->mMachineState))1769 i_saveSettings(NULL);1770 1771 return rc;1772 }1773 1774 HRESULT Machine::getVideoCaptureScreens(std::vector<BOOL> &aVideoCaptureScreens)1775 {1776 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);1777 aVideoCaptureScreens.resize(mHWData->mMonitorCount);1778 for (unsigned i = 0; i < mHWData->mMonitorCount; ++i)1779 aVideoCaptureScreens[i] = mHWData->maVideoCaptureScreens[i];1780 return S_OK;1781 }1782 1783 HRESULT Machine::setVideoCaptureScreens(const std::vector<BOOL> &aVideoCaptureScreens)1784 {1785 AssertReturn(aVideoCaptureScreens.size() <= RT_ELEMENTS(mHWData->maVideoCaptureScreens), E_INVALIDARG);1786 bool fChanged = false;1787 1788 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);1789 1790 for (unsigned i = 0; i < aVideoCaptureScreens.size(); ++i)1791 {1792 if (mHWData->maVideoCaptureScreens[i] != RT_BOOL(aVideoCaptureScreens[i]))1793 {1794 mHWData->maVideoCaptureScreens[i] = RT_BOOL(aVideoCaptureScreens[i]);1795 fChanged = true;1796 }1797 }1798 if (fChanged)1799 {1800 alock.release();1801 HRESULT rc = i_onVideoCaptureChange();1802 alock.acquire();1803 if (FAILED(rc)) return rc;1804 i_setModified(IsModified_MachineData);1805 1806 /** Save settings if online - @todo why is this required? -- @bugref{6818} */1807 if (Global::IsOnline(mData->mMachineState))1808 i_saveSettings(NULL);1809 }1810 1811 return S_OK;1812 }1813 1814 HRESULT Machine::getVideoCaptureFile(com::Utf8Str &aVideoCaptureFile)1815 {1816 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);1817 if (mHWData->mVideoCaptureFile.isEmpty())1818 i_getDefaultVideoCaptureFile(aVideoCaptureFile);1819 else1820 aVideoCaptureFile = mHWData->mVideoCaptureFile;1821 return S_OK;1822 }1823 1824 HRESULT Machine::setVideoCaptureFile(const com::Utf8Str &aVideoCaptureFile)1825 {1826 Utf8Str strFile(aVideoCaptureFile);1827 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);1828 1829 if ( Global::IsOnline(mData->mMachineState)1830 && mHWData->mVideoCaptureEnabled)1831 return setError(E_INVALIDARG, tr("Cannot change parameters while capturing is enabled"));1832 1833 if (!RTPathStartsWithRoot(strFile.c_str()))1834 return setError(E_INVALIDARG, tr("Video capture file name '%s' is not absolute"), strFile.c_str());1835 1836 if (!strFile.isEmpty())1837 {1838 Utf8Str defaultFile;1839 i_getDefaultVideoCaptureFile(defaultFile);1840 if (!RTPathCompare(strFile.c_str(), defaultFile.c_str()))1841 strFile.setNull();1842 }1843 1844 i_setModified(IsModified_MachineData);1845 mHWData.backup();1846 mHWData->mVideoCaptureFile = strFile;1847 1848 return S_OK;1849 }1850 1851 HRESULT Machine::getVideoCaptureWidth(ULONG *aVideoCaptureWidth)1852 {1853 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);1854 *aVideoCaptureWidth = mHWData->mVideoCaptureWidth;1855 return S_OK;1856 }1857 1858 HRESULT Machine::setVideoCaptureWidth(ULONG aVideoCaptureWidth)1859 {1860 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);1861 1862 if ( Global::IsOnline(mData->mMachineState)1863 && mHWData->mVideoCaptureEnabled)1864 return setError(E_INVALIDARG, tr("Cannot change parameters while capturing is enabled"));1865 1866 i_setModified(IsModified_MachineData);1867 mHWData.backup();1868 mHWData->mVideoCaptureWidth = aVideoCaptureWidth;1869 1870 return S_OK;1871 }1872 1873 HRESULT Machine::getVideoCaptureHeight(ULONG *aVideoCaptureHeight)1874 {1875 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);1876 *aVideoCaptureHeight = mHWData->mVideoCaptureHeight;1877 return S_OK;1878 }1879 1880 HRESULT Machine::setVideoCaptureHeight(ULONG aVideoCaptureHeight)1881 {1882 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);1883 1884 if ( Global::IsOnline(mData->mMachineState)1885 && mHWData->mVideoCaptureEnabled)1886 return setError(E_INVALIDARG, tr("Cannot change parameters while capturing is enabled"));1887 1888 i_setModified(IsModified_MachineData);1889 mHWData.backup();1890 mHWData->mVideoCaptureHeight = aVideoCaptureHeight;1891 1892 return S_OK;1893 }1894 1895 HRESULT Machine::getVideoCaptureRate(ULONG *aVideoCaptureRate)1896 {1897 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);1898 *aVideoCaptureRate = mHWData->mVideoCaptureRate;1899 return S_OK;1900 }1901 1902 HRESULT Machine::setVideoCaptureRate(ULONG aVideoCaptureRate)1903 {1904 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);1905 1906 if ( Global::IsOnline(mData->mMachineState)1907 && mHWData->mVideoCaptureEnabled)1908 return setError(E_INVALIDARG, tr("Cannot change parameters while capturing is enabled"));1909 1910 i_setModified(IsModified_MachineData);1911 mHWData.backup();1912 mHWData->mVideoCaptureRate = aVideoCaptureRate;1913 1914 return S_OK;1915 }1916 1917 HRESULT Machine::getVideoCaptureFPS(ULONG *aVideoCaptureFPS)1918 {1919 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);1920 *aVideoCaptureFPS = mHWData->mVideoCaptureFPS;1921 return S_OK;1922 }1923 1924 HRESULT Machine::setVideoCaptureFPS(ULONG aVideoCaptureFPS)1925 {1926 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);1927 1928 if ( Global::IsOnline(mData->mMachineState)1929 && mHWData->mVideoCaptureEnabled)1930 return setError(E_INVALIDARG, tr("Cannot change parameters while capturing is enabled"));1931 1932 i_setModified(IsModified_MachineData);1933 mHWData.backup();1934 mHWData->mVideoCaptureFPS = aVideoCaptureFPS;1935 1936 return S_OK;1937 }1938 1939 HRESULT Machine::getVideoCaptureMaxTime(ULONG *aVideoCaptureMaxTime)1940 {1941 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);1942 *aVideoCaptureMaxTime = mHWData->mVideoCaptureMaxTime;1943 return S_OK;1944 }1945 1946 HRESULT Machine::setVideoCaptureMaxTime(ULONG aVideoCaptureMaxTime)1947 {1948 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);1949 1950 if ( Global::IsOnline(mData->mMachineState)1951 && mHWData->mVideoCaptureEnabled)1952 return setError(E_INVALIDARG, tr("Cannot change parameters while capturing is enabled"));1953 1954 i_setModified(IsModified_MachineData);1955 mHWData.backup();1956 mHWData->mVideoCaptureMaxTime = aVideoCaptureMaxTime;1957 1958 return S_OK;1959 }1960 1961 HRESULT Machine::getVideoCaptureMaxFileSize(ULONG *aVideoCaptureMaxFileSize)1962 {1963 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);1964 *aVideoCaptureMaxFileSize = mHWData->mVideoCaptureMaxFileSize;1965 return S_OK;1966 }1967 1968 HRESULT Machine::setVideoCaptureMaxFileSize(ULONG aVideoCaptureMaxFileSize)1969 {1970 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);1971 1972 if ( Global::IsOnline(mData->mMachineState)1973 && mHWData->mVideoCaptureEnabled)1974 return setError(E_INVALIDARG, tr("Cannot change parameters while capturing is enabled"));1975 1976 i_setModified(IsModified_MachineData);1977 mHWData.backup();1978 mHWData->mVideoCaptureMaxFileSize = aVideoCaptureMaxFileSize;1979 1980 return S_OK;1981 }1982 1983 HRESULT Machine::getVideoCaptureOptions(com::Utf8Str &aVideoCaptureOptions)1984 {1985 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);1986 1987 aVideoCaptureOptions = mHWData->mVideoCaptureOptions;1988 return S_OK;1989 }1990 1991 HRESULT Machine::setVideoCaptureOptions(const com::Utf8Str &aVideoCaptureOptions)1992 {1993 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);1994 1995 if ( Global::IsOnline(mData->mMachineState)1996 && mHWData->mVideoCaptureEnabled)1997 return setError(E_INVALIDARG, tr("Cannot change parameters while capturing is enabled"));1998 1999 i_setModified(IsModified_MachineData);2000 mHWData.backup();2001 mHWData->mVideoCaptureOptions = aVideoCaptureOptions;2002 2003 return S_OK;2004 }2005 2006 1727 HRESULT Machine::getGraphicsControllerType(GraphicsControllerType_T *aGraphicsControllerType) 2007 1728 { … … 2215 1936 /* mBIOSSettings is constant during life time, no need to lock */ 2216 1937 aBIOSSettings = mBIOSSettings; 1938 1939 return S_OK; 1940 } 1941 1942 HRESULT Machine::getCaptureSettings(ComPtr<ICaptureSettings> &aCaptureSettings) 1943 { 1944 /* mCaptureSettings is constant during life time, no need to lock */ 1945 aCaptureSettings = mCaptureSettings; 2217 1946 2218 1947 return S_OK; … … 7654 7383 7655 7384 /** 7656 * Returns the full path to the default video capture file.7657 */7658 void Machine::i_getDefaultVideoCaptureFile(Utf8Str &strFile)7659 {7660 AutoCaller autoCaller(this);7661 AssertComRCReturnVoid(autoCaller.rc());7662 7663 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);7664 7665 strFile = mData->m_strConfigFileFull; // path/to/machinesfolder/vmname/vmname.vbox7666 strFile.stripSuffix(); // path/to/machinesfolder/vmname/vmname7667 strFile.append(".webm"); // path/to/machinesfolder/vmname/vmname.webm7668 }7669 7670 /**7671 7385 * Returns whether at least one USB controller is present for the VM. 7672 7386 */ … … 8545 8259 mBIOSSettings->init(this); 8546 8260 8261 /* create associated capture settings object */ 8262 unconst(mCaptureSettings).createObject(); 8263 mCaptureSettings->init(this); 8264 8547 8265 /* create an associated VRDE object (default is disabled) */ 8548 8266 unconst(mVRDEServer).createObject(); … … 8658 8376 mBIOSSettings->uninit(); 8659 8377 unconst(mBIOSSettings).setNull(); 8378 } 8379 8380 if (mCaptureSettings) 8381 { 8382 mCaptureSettings->uninit(); 8383 unconst(mCaptureSettings).setNull(); 8660 8384 } 8661 8385 … … 9157 8881 mHWData->mAccelerate3DEnabled = data.fAccelerate3D; 9158 8882 mHWData->mAccelerate2DVideoEnabled = data.fAccelerate2DVideo; 9159 mHWData->mVideoCaptureWidth = data.ulVideoCaptureHorzRes;9160 mHWData->mVideoCaptureHeight = data.ulVideoCaptureVertRes;9161 mHWData->mVideoCaptureEnabled = data.fVideoCaptureEnabled;9162 for (unsigned i = 0; i < RT_ELEMENTS(mHWData->maVideoCaptureScreens); ++i)9163 mHWData->maVideoCaptureScreens[i] = ASMBitTest(&data.u64VideoCaptureScreens, i);9164 AssertCompile(RT_ELEMENTS(mHWData->maVideoCaptureScreens) == sizeof(data.u64VideoCaptureScreens) * 8);9165 mHWData->mVideoCaptureRate = data.ulVideoCaptureRate;9166 mHWData->mVideoCaptureFPS = data.ulVideoCaptureFPS;9167 if (!data.strVideoCaptureFile.isEmpty())9168 i_calculateFullPath(data.strVideoCaptureFile, mHWData->mVideoCaptureFile);9169 else9170 mHWData->mVideoCaptureFile.setNull();9171 mHWData->mVideoCaptureOptions = data.strVideoCaptureOptions;9172 8883 mHWData->mFirmwareType = data.firmwareType; 9173 8884 mHWData->mPointingHIDType = data.pointingHIDType; … … 9187 8898 if (FAILED(rc)) return rc; 9188 8899 8900 /* Capture settings */ 8901 rc = mCaptureSettings->i_loadSettings(data.captureSettings); 8902 if (FAILED(rc)) return rc; 8903 9189 8904 // Bandwidth control (must come before network adapters) 9190 8905 rc = mBandwidthControl->i_loadSettings(data.ioSettings); 9191 8906 if (FAILED(rc)) return rc; 9192 8907 9193 /* Shared folders */8908 /* USB controllers */ 9194 8909 for (settings::USBControllerList::const_iterator 9195 8910 it = data.usbSettings.llUSBControllers.begin(); … … 10493 10208 data.fAccelerate3D = !!mHWData->mAccelerate3DEnabled; 10494 10209 data.fAccelerate2DVideo = !!mHWData->mAccelerate2DVideoEnabled; 10495 data.ulVideoCaptureHorzRes = mHWData->mVideoCaptureWidth;10496 data.ulVideoCaptureVertRes = mHWData->mVideoCaptureHeight;10497 data.ulVideoCaptureRate = mHWData->mVideoCaptureRate;10498 data.ulVideoCaptureFPS = mHWData->mVideoCaptureFPS;10499 data.fVideoCaptureEnabled = !!mHWData->mVideoCaptureEnabled;10500 for (unsigned i = 0; i < sizeof(data.u64VideoCaptureScreens) * 8; ++i)10501 {10502 if (mHWData->maVideoCaptureScreens[i])10503 ASMBitSet(&data.u64VideoCaptureScreens, i);10504 else10505 ASMBitClear(&data.u64VideoCaptureScreens, i);10506 }10507 /* store relative video capture file if possible */10508 i_copyPathRelativeToMachine(mHWData->mVideoCaptureFile, data.strVideoCaptureFile);10509 data.strVideoCaptureOptions = mHWData->mVideoCaptureOptions;10510 10210 10511 10211 /* VRDEServer settings (optional) */ … … 10513 10213 if (FAILED(rc)) throw rc; 10514 10214 10515 /* BIOS (required) */10215 /* BIOS settings (required) */ 10516 10216 rc = mBIOSSettings->i_saveSettings(data.biosSettings); 10217 if (FAILED(rc)) throw rc; 10218 10219 /* Capture settings (required) */ 10220 rc = mCaptureSettings->i_saveSettings(data.captureSettings); 10517 10221 if (FAILED(rc)) throw rc; 10518 10222 … … 12019 11723 mBIOSSettings->i_rollback(); 12020 11724 11725 if (mCaptureSettings && (mData->flModifications & IsModified_Capture)) 11726 mCaptureSettings->i_rollback(); 11727 12021 11728 if (mVRDEServer && (mData->flModifications & IsModified_VRDEServer)) 12022 11729 mVRDEServer->i_rollback(); … … 12129 11836 12130 11837 mBIOSSettings->i_commit(); 11838 mCaptureSettings->i_commit(); 12131 11839 mVRDEServer->i_commit(); 12132 11840 mAudioAdapter->i_commit(); … … 12381 12089 12382 12090 mBIOSSettings->i_copyFrom(aThat->mBIOSSettings); 12091 mCaptureSettings->i_copyFrom(aThat->mCaptureSettings); 12383 12092 mVRDEServer->i_copyFrom(aThat->mVRDEServer); 12384 12093 mAudioAdapter->i_copyFrom(aThat->mAudioAdapter); … … 12754 12463 unconst(mBIOSSettings).createObject(); 12755 12464 mBIOSSettings->init(this, aMachine->mBIOSSettings); 12465 unconst(mCaptureSettings).createObject(); 12466 mCaptureSettings->init(this, aMachine->mCaptureSettings); 12756 12467 /* create another VRDEServer object that will be mutable */ 12757 12468 unconst(mVRDEServer).createObject(); … … 14387 14098 * @note Locks this object for reading. 14388 14099 */ 14389 HRESULT SessionMachine::i_on VideoCaptureChange()14100 HRESULT SessionMachine::i_onCaptureChange() 14390 14101 { 14391 14102 LogFlowThisFunc(("\n")); … … 14405 14116 return S_OK; 14406 14117 14407 return directControl->On VideoCaptureChange();14118 return directControl->OnCaptureChange(); 14408 14119 } 14409 14120 … … 15339 15050 mBIOSSettings->i_applyDefaults(osType); 15340 15051 15052 /* Initialize default capture settings. */ 15053 mCaptureSettings->i_applyDefaults(); 15054 15341 15055 /* Initialize default BIOS settings here */ 15342 15056 mHWData->mAPIC = osType->i_recommendedIOAPIC();
Note:
See TracChangeset
for help on using the changeset viewer.