Changeset 75251 in vbox for trunk/src/VBox/Main/xml
- Timestamp:
- Nov 5, 2018 5:55:29 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 126353
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/xml/Settings.cpp
r74474 r75251 2371 2371 } 2372 2372 2373 CaptureScreenSettings::CaptureScreenSettings(void) 2374 { 2375 applyDefaults(); 2376 } 2377 2378 CaptureScreenSettings::~CaptureScreenSettings() 2379 { 2380 2381 } 2382 2383 void CaptureScreenSettings::applyDefaults(void) 2384 { 2385 /* 2386 * Set sensible defaults. 2387 */ 2388 2389 fEnabled = true; 2390 enmDest = CaptureDestination_File; 2391 ulMaxTimeS = 0; 2392 strOptions = ""; 2393 File.ulMaxSizeMB = 0; 2394 Video.enmCodec = CaptureVideoCodec_VP8; 2395 Video.ulWidth = 1024; 2396 Video.ulHeight = 768; 2397 Video.ulRate = 512; 2398 Video.ulFPS = 25; 2399 Audio.enmAudioCodec = CaptureAudioCodec_Opus; 2400 Audio.cBits = 16; 2401 Audio.cChannels = 2; 2402 Audio.uHz = 22050; 2403 2404 featureMap[CaptureFeature_Video] = true; 2405 featureMap[CaptureFeature_Audio] = false; 2406 2407 //i_calculateFullPath 2408 } 2409 2410 /** 2411 * Check if all settings have default values. 2412 */ 2413 bool CaptureScreenSettings::areDefaultSettings(void) const 2414 { 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; 2431 } 2432 2433 bool CaptureScreenSettings::isFeatureEnabled(CaptureFeature_T enmFeature) const 2434 { 2435 CaptureFeatureMap::const_iterator itFeature = featureMap.find(enmFeature); 2436 if (itFeature != featureMap.end()) 2437 return itFeature->second; 2438 2439 return false; 2440 } 2441 2442 /** 2443 * Comparison operator. This gets called from MachineConfigFile::operator==, 2444 * which in turn gets called from Machine::saveSettings to figure out whether 2445 * machine settings have really changed and thus need to be written out to disk. 2446 */ 2447 bool CaptureScreenSettings::operator==(const CaptureScreenSettings &d) const 2448 { 2449 return fEnabled == d.fEnabled 2450 && enmDest == d.enmDest 2451 && featureMap == d.featureMap 2452 && ulMaxTimeS == d.ulMaxTimeS 2453 && strOptions == d.strOptions 2454 && File.ulMaxSizeMB == d.File.ulMaxSizeMB 2455 && Video.enmCodec == d.Video.enmCodec 2456 && Video.ulWidth == d.Video.ulWidth 2457 && Video.ulHeight == d.Video.ulHeight 2458 && Video.ulRate == d.Video.ulRate 2459 && Video.ulFPS == d.Video.ulFPS 2460 && Audio.enmAudioCodec == d.Audio.enmAudioCodec 2461 && Audio.cBits == d.Audio.cBits 2462 && Audio.cChannels == d.Audio.cChannels 2463 && Audio.uHz == d.Audio.uHz; 2464 } 2465 2466 /** 2467 * Constructor. Needs to set sane defaults which stand the test of time. 2468 */ 2469 CaptureSettings::CaptureSettings() 2470 { 2471 applyDefaults(); 2472 } 2473 2474 void CaptureSettings::applyDefaults(void) 2475 { 2476 fEnabled = false; 2477 2478 mapScreens.clear(); 2479 2480 CaptureScreenSettings screenSettings; /* Apply default settings. */ 2481 for (unsigned long l = 0; l < SchemaDefs::MaxGuestMonitors; l++) 2482 { 2483 mapScreens[l] = screenSettings; 2484 } 2485 } 2486 2487 /** 2488 * Check if all settings have default values. 2489 */ 2490 bool CaptureSettings::areDefaultSettings() const 2491 { 2492 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; 2502 } 2503 2504 /** 2505 * Comparison operator. This gets called from MachineConfigFile::operator==, 2506 * which in turn gets called from Machine::saveSettings to figure out whether 2507 * machine settings have really changed and thus need to be written out to disk. 2508 */ 2509 bool CaptureSettings::operator==(const CaptureSettings &d) const 2510 { 2511 if (this == &d) 2512 return true; 2513 2514 if ( fEnabled != d.fEnabled 2515 || mapScreens.size() != d.mapScreens.size()) 2516 return false; 2517 2518 CaptureScreenMap::const_iterator itScreen = mapScreens.begin(); 2519 size_t i = 0; 2520 while (itScreen != mapScreens.end()) 2521 { 2522 CaptureScreenMap::const_iterator itScreenThat = d.mapScreens.find(i); 2523 if (itScreen->second == itScreenThat->second) 2524 { 2525 /* Nothing to do in here (yet). */ 2526 } 2527 else 2528 return false; 2529 2530 ++itScreen; 2531 ++i; 2532 } 2533 2534 return true; 2535 } 2536 2373 2537 /** 2374 2538 * Constructor. Needs to set sane defaults which stand the test of time. … … 2901 3065 fAccelerate3D(false), 2902 3066 fAccelerate2DVideo(false), 2903 ulVideoCaptureHorzRes(1024),2904 ulVideoCaptureVertRes(768),2905 ulVideoCaptureRate(512),2906 ulVideoCaptureFPS(25),2907 ulVideoCaptureMaxTime(0),2908 ulVideoCaptureMaxSize(0),2909 fVideoCaptureEnabled(false),2910 u64VideoCaptureScreens(UINT64_C(0xffffffffffffffff)),2911 strVideoCaptureFile(""),2912 3067 firmwareType(FirmwareType_BIOS), 2913 3068 pointingHIDType(PointingHIDType_PS2Mouse), … … 2986 3141 && !fAccelerate3D 2987 3142 && !fAccelerate2DVideo; 2988 }2989 2990 /**2991 * Check if all Video Capture settings have default values.2992 */2993 bool Hardware::areVideoCaptureDefaultSettings() const2994 {2995 return !fVideoCaptureEnabled2996 && u64VideoCaptureScreens == UINT64_C(0xffffffffffffffff)2997 && strVideoCaptureFile.isEmpty()2998 && ulVideoCaptureHorzRes == 10242999 && ulVideoCaptureVertRes == 7683000 && ulVideoCaptureRate == 5123001 && ulVideoCaptureFPS == 253002 && ulVideoCaptureMaxTime == 03003 && ulVideoCaptureMaxSize == 03004 && strVideoCaptureOptions.isEmpty();3005 3143 } 3006 3144 … … 3062 3200 && fAccelerate3D == h.fAccelerate3D 3063 3201 && fAccelerate2DVideo == h.fAccelerate2DVideo 3064 && fVideoCaptureEnabled == h.fVideoCaptureEnabled3065 && u64VideoCaptureScreens == h.u64VideoCaptureScreens3066 && strVideoCaptureFile == h.strVideoCaptureFile3067 && ulVideoCaptureHorzRes == h.ulVideoCaptureHorzRes3068 && ulVideoCaptureVertRes == h.ulVideoCaptureVertRes3069 && ulVideoCaptureRate == h.ulVideoCaptureRate3070 && ulVideoCaptureFPS == h.ulVideoCaptureFPS3071 && ulVideoCaptureMaxTime == h.ulVideoCaptureMaxTime3072 && ulVideoCaptureMaxSize == h.ulVideoCaptureMaxTime3073 && strVideoCaptureOptions == h.strVideoCaptureOptions3074 3202 && firmwareType == h.firmwareType 3075 3203 && pointingHIDType == h.pointingHIDType … … 4276 4404 else if (pelmHwChild->nameEquals("VideoCapture")) 4277 4405 { 4278 pelmHwChild->getAttributeValue("enabled", hw.fVideoCaptureEnabled); 4279 pelmHwChild->getAttributeValue("screens", hw.u64VideoCaptureScreens); 4280 pelmHwChild->getAttributeValuePath("file", hw.strVideoCaptureFile); 4281 pelmHwChild->getAttributeValue("horzRes", hw.ulVideoCaptureHorzRes); 4282 pelmHwChild->getAttributeValue("vertRes", hw.ulVideoCaptureVertRes); 4283 pelmHwChild->getAttributeValue("rate", hw.ulVideoCaptureRate); 4284 pelmHwChild->getAttributeValue("fps", hw.ulVideoCaptureFPS); 4285 pelmHwChild->getAttributeValue("maxTime", hw.ulVideoCaptureMaxTime); 4286 pelmHwChild->getAttributeValue("maxSize", hw.ulVideoCaptureMaxSize); 4287 pelmHwChild->getAttributeValue("options", hw.strVideoCaptureOptions); 4406 pelmHwChild->getAttributeValue("enabled", hw.captureSettings.fEnabled); 4407 4408 /* Right now I don't want to bump the settings version, so just convert the enabled 4409 * screens to the former uint6t_t bit array and vice versa. */ 4410 uint64_t u64VideoCaptureScreens; 4411 pelmHwChild->getAttributeValue("screens", u64VideoCaptureScreens); 4412 4413 /* At the moment we only support one capturing configuration, that is, all screens 4414 * have the same configuration. So load/save to/from screen 0. */ 4415 CaptureScreenSettings &screen0Settings = hw.captureSettings.mapScreens[0]; 4416 4417 pelmHwChild->getAttributeValue("maxTime", screen0Settings.ulMaxTimeS); 4418 pelmHwChild->getAttributeValue("options", screen0Settings.strOptions); 4419 pelmHwChild->getAttributeValuePath("file", screen0Settings.File.strName); 4420 pelmHwChild->getAttributeValue("maxSize", screen0Settings.File.ulMaxSizeMB); 4421 pelmHwChild->getAttributeValue("horzRes", screen0Settings.Video.ulWidth); 4422 pelmHwChild->getAttributeValue("vertRes", screen0Settings.Video.ulHeight); 4423 pelmHwChild->getAttributeValue("rate", screen0Settings.Video.ulRate); 4424 pelmHwChild->getAttributeValue("fps", screen0Settings.Video.ulFPS); 4425 4426 for (unsigned i = 0; i < 64; i++) 4427 { 4428 if (u64VideoCaptureScreens & RT_BIT(i)) /* Screen i enabled? */ 4429 { 4430 hw.captureSettings.mapScreens[i] = screen0Settings; 4431 hw.captureSettings.mapScreens[i].fEnabled = true; 4432 } 4433 } 4288 4434 } 4289 4435 else if (pelmHwChild->nameEquals("RemoteDisplay")) … … 5668 5814 } 5669 5815 5670 if (m->sv >= SettingsVersion_v1_14 && !hw. areVideoCaptureDefaultSettings())5816 if (m->sv >= SettingsVersion_v1_14 && !hw.captureSettings.areDefaultSettings()) 5671 5817 { 5672 5818 xml::ElementNode *pelmVideoCapture = pelmHardware->createChild("VideoCapture"); 5673 if (hw.fVideoCaptureEnabled) 5674 pelmVideoCapture->setAttribute("enabled", hw.fVideoCaptureEnabled); 5675 if (hw.u64VideoCaptureScreens != UINT64_C(0xffffffffffffffff)) 5676 pelmVideoCapture->setAttribute("screens", hw.u64VideoCaptureScreens); 5677 if (!hw.strVideoCaptureFile.isEmpty()) 5678 pelmVideoCapture->setAttributePath("file", hw.strVideoCaptureFile); 5679 if (hw.ulVideoCaptureHorzRes != 1024 || hw.ulVideoCaptureVertRes != 768) 5680 { 5681 pelmVideoCapture->setAttribute("horzRes", hw.ulVideoCaptureHorzRes); 5682 pelmVideoCapture->setAttribute("vertRes", hw.ulVideoCaptureVertRes); 5683 } 5684 if (hw.ulVideoCaptureRate != 512) 5685 pelmVideoCapture->setAttribute("rate", hw.ulVideoCaptureRate); 5686 if (hw.ulVideoCaptureFPS) 5687 pelmVideoCapture->setAttribute("fps", hw.ulVideoCaptureFPS); 5688 if (hw.ulVideoCaptureMaxTime) 5689 pelmVideoCapture->setAttribute("maxTime", hw.ulVideoCaptureMaxTime); 5690 if (hw.ulVideoCaptureMaxSize) 5691 pelmVideoCapture->setAttribute("maxSize", hw.ulVideoCaptureMaxSize); 5692 if (!hw.strVideoCaptureOptions.isEmpty()) 5693 pelmVideoCapture->setAttributePath("options", hw.strVideoCaptureOptions); 5819 5820 if (hw.captureSettings.fEnabled) 5821 pelmVideoCapture->setAttribute("enabled", hw.captureSettings.fEnabled); 5822 5823 /* Right now I don't want to bump the settings version, so just convert the enabled 5824 * screens to the former uint6t_t bit array and vice versa. */ 5825 uint64_t u64VideoCaptureScreens = 0; 5826 CaptureScreenMap::const_iterator itScreen = hw.captureSettings.mapScreens.begin(); 5827 while (itScreen != hw.captureSettings.mapScreens.end()) 5828 { 5829 if (itScreen->second.fEnabled) 5830 u64VideoCaptureScreens |= RT_BIT(itScreen->first); 5831 ++itScreen; 5832 } 5833 5834 if (u64VideoCaptureScreens) 5835 pelmVideoCapture->setAttribute("screens", u64VideoCaptureScreens); 5836 5837 /* At the moment we only support one capturing configuration, that is, all screens 5838 * have the same configuration. So load/save to/from screen 0. */ 5839 Assert(hw.captureSettings.mapScreens.size()); 5840 const CaptureScreenMap::const_iterator itScreen0Settings = hw.captureSettings.mapScreens.find(0); 5841 5842 if (itScreen0Settings->second.ulMaxTimeS) 5843 pelmVideoCapture->setAttribute("maxTime", itScreen0Settings->second.ulMaxTimeS); 5844 if (itScreen0Settings->second.strOptions.isNotEmpty()) 5845 pelmVideoCapture->setAttributePath("options", itScreen0Settings->second.strOptions); 5846 5847 if (!itScreen0Settings->second.File.strName.isEmpty()) 5848 pelmVideoCapture->setAttributePath("file", itScreen0Settings->second.File.strName); 5849 if (itScreen0Settings->second.File.ulMaxSizeMB) 5850 pelmVideoCapture->setAttribute("maxSize", itScreen0Settings->second.File.ulMaxSizeMB); 5851 5852 if ( itScreen0Settings->second.Video.ulWidth != 1024 5853 || itScreen0Settings->second.Video.ulHeight != 768) 5854 { 5855 pelmVideoCapture->setAttribute("horzRes", itScreen0Settings->second.Video.ulWidth); 5856 pelmVideoCapture->setAttribute("vertRes", itScreen0Settings->second.Video.ulHeight); 5857 } 5858 if (itScreen0Settings->second.Video.ulRate != 512) 5859 pelmVideoCapture->setAttribute("rate", itScreen0Settings->second.Video.ulRate); 5860 if (itScreen0Settings->second.Video.ulFPS) 5861 pelmVideoCapture->setAttribute("fps", itScreen0Settings->second.Video.ulFPS); 5694 5862 } 5695 5863 … … 7262 7430 { 7263 7431 // VirtualBox 4.3 adds default frontend setting, graphics controller 7264 // setting, explicit long mode setting, videocapturing and NAT networking.7432 // setting, explicit long mode setting, (video) capturing and NAT networking. 7265 7433 if ( !hardwareMachine.strDefaultFrontend.isEmpty() 7266 7434 || hardwareMachine.graphicsControllerType != GraphicsControllerType_VBoxVGA 7267 7435 || hardwareMachine.enmLongMode != Hardware::LongMode_Legacy 7268 7436 || machineUserData.ovIcon.size() > 0 7269 || hardwareMachine. fVideoCaptureEnabled)7437 || hardwareMachine.captureSettings.fEnabled) 7270 7438 { 7271 7439 m->sv = SettingsVersion_v1_14;
Note:
See TracChangeset
for help on using the changeset viewer.