VirtualBox

Changeset 96545 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Aug 29, 2022 5:41:05 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
153411
Message:

Recording/Main: Made recording file name construction more deterministic (also required for testcase handling in Validation Kit), by only letting the recording screen settings to construct + alter the actual file name(s). ​bugref:10275

Location:
trunk/src/VBox/Main/src-server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/RecordingScreenSettingsImpl.cpp

    r96407 r96545  
    458458    if (m->bd->File.strName != aFilename)
    459459    {
    460         m->bd.backup();
    461         m->bd->File.strName = aFilename;
    462 
    463         alock.release();
    464 
    465         m->pParent->i_onSettingsChanged();
     460        Utf8Str strName;
     461        int vrc = m->pParent->i_getFilename(strName, m->uScreenId, aFilename);
     462        if (RT_SUCCESS(vrc))
     463        {
     464            m->bd.backup();
     465            m->bd->File.strName = strName;
     466
     467            alock.release();
     468
     469            m->pParent->i_onSettingsChanged();
     470        }
     471        else
     472            return setErrorBoth(E_ACCESSDENIED, vrc, tr("Could not set file name for recording screen"));
    466473    }
    467474
  • trunk/src/VBox/Main/src-server/RecordingSettingsImpl.cpp

    r96407 r96545  
    723723/**
    724724 * Returns the full path to the default recording file.
     725 *
     726 * @returns VBox status code.
     727 * @param   strFile             Where to return the final file name on success.
     728 * @param   idScreen            Screen ID the file is associated to.
     729 * @param   fWithFileExtension  Whether to include the default file extension ('.webm') or not.
    725730 */
    726731int RecordingSettings::i_getDefaultFilename(Utf8Str &strFile, uint32_t idScreen, bool fWithFileExtension)
     
    738743
    739744/**
     745 * Gets a standardized file name from a given template file name.
     746 *
     747 * @returns VBox status code.
     748 * @param   strFile             Where to return the final file name on success.
     749 * @param   idScreen            Screen ID the file is associated to.
     750 * @param   strTemplate         Template file name to use.
     751 *                              A default file name will be used when empty.
     752 */
     753int RecordingSettings::i_getFilename(Utf8Str &strFile, uint32_t idScreen, const Utf8Str &strTemplate)
     754{
     755    strFile = strTemplate;
     756
     757    if (strFile.isEmpty())
     758        return i_getDefaultFilename(strFile, idScreen, true /* fWithFileExtension */);
     759
     760    /* We force adding a .webm suffix to (hopefully) not let the user overwrite other important stuff. */
     761    strFile.stripSuffix();
     762
     763    Utf8Str strDotExt = ".webm";
     764
     765    /* We also force adding the screen id suffix, at least for the moment, as FE/Qt only offers settings a single file name
     766     * for *all* enabled screens. */
     767    char szSuffScreen[] = "-screen";
     768    Utf8Str strSuff = Utf8StrFmt("%s%RU32", szSuffScreen, idScreen);
     769    if (!strFile.endsWith(strSuff, Utf8Str::CaseInsensitive))
     770    {
     771        /** @todo The following line checks whether there already is a screen suffix, as FE/Qt currently always works with
     772         *        screen 0 as the file name. Remove the following if block when FE/Qt supports this properly. */
     773        Utf8Str strSuffScreen0 = Utf8StrFmt("%s%RU32", szSuffScreen, 0);
     774        if (strFile.endsWith(strSuffScreen0, Utf8Str::CaseInsensitive))
     775            strFile.truncate(strFile.length() - strSuffScreen0.length());
     776
     777        strFile += strSuff; /* Add the suffix with the correct screen ID. */
     778    }
     779
     780    strFile += strDotExt;
     781
     782    LogRel2(("Recording: File name '%s' -> '%s'\n", strTemplate.c_str(), strFile.c_str()));
     783
     784    return VINF_SUCCESS;
     785}
     786
     787/**
    740788 * Determines whether the recording settings currently can be changed or not.
    741789 *
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette