2018-03-11 18:57:22 +01:00
|
|
|
#ifndef TAGPARSER_SETTINGS_H
|
|
|
|
#define TAGPARSER_SETTINGS_H
|
|
|
|
|
|
|
|
#include "./tagtarget.h"
|
|
|
|
|
2019-08-12 20:22:57 +02:00
|
|
|
#include <c++utilities/misc/flagenumclass.h>
|
|
|
|
|
2019-03-13 19:06:42 +01:00
|
|
|
#include <cstdint>
|
2018-03-11 18:57:22 +01:00
|
|
|
#include <type_traits>
|
|
|
|
|
|
|
|
namespace TagParser {
|
|
|
|
|
|
|
|
enum class ElementPosition {
|
|
|
|
BeforeData, /**< the element is positioned before the actual data */
|
|
|
|
AfterData, /**< the element is positioned after the actual data */
|
|
|
|
Keep, /**< the element is placed where it was before */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief The TagUsage enum specifies the usage of a certain tag type.
|
|
|
|
*/
|
|
|
|
enum class TagUsage {
|
|
|
|
Always, /**< a tag of the type is always used; a new tag is created if none exists yet */
|
|
|
|
KeepExisting, /**< existing tags of the type are kept and updated but no new tag is created */
|
|
|
|
Never, /**< tags of the type are never used; a possibly existing tag of the type is removed */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief The Flags enum contains options to control the tag creation via MediaFileInfo::createAppropriateTags().
|
|
|
|
*/
|
2019-03-13 19:06:42 +01:00
|
|
|
enum class TagCreationFlags : std::uint64_t {
|
2018-03-11 18:57:22 +01:00
|
|
|
None = 0, /**< no flags present */
|
|
|
|
TreatUnknownFilesAsMp3Files = 1 << 0, /**< treat unknown file formats as MP3 (might make those files unusable) */
|
|
|
|
Id3InitOnCreate = 1 << 1, /**< initialize newly created ID3 tags with the values of the already present ID3 tags */
|
|
|
|
Id3TransferValuesOnRemoval = 1 << 2, /**< transfer values of removed ID3 tags to remaining ID3 tags (no values will be overwritten) */
|
|
|
|
MergeMultipleSuccessiveId3v2Tags = 1 << 3, /**< merge multiple successive ID3v2 tags (see MediaFileInfo::mergeId3v2Tags()) */
|
|
|
|
KeepExistingId3v2Version
|
|
|
|
= 1 << 4, /**< keep version of existing ID3v2 tags so TagSettings::id3v2version is only used when creating a *new* ID3v2 tag */
|
|
|
|
};
|
|
|
|
|
2019-08-12 20:22:57 +02:00
|
|
|
} // namespace TagParser
|
2018-03-11 18:57:22 +01:00
|
|
|
|
2019-08-12 20:22:57 +02:00
|
|
|
CPP_UTILITIES_MARK_FLAG_ENUM_CLASS(TagParser, TagParser::TagCreationFlags);
|
2018-03-11 18:57:22 +01:00
|
|
|
|
2019-08-12 20:22:57 +02:00
|
|
|
namespace TagParser {
|
2018-03-11 18:57:22 +01:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief The TagSettings struct contains settings which can be passed to MediaFileInfo::createAppropriateTags().
|
|
|
|
*/
|
|
|
|
struct TagCreationSettings {
|
|
|
|
/// \brief Specifies the required targets. If targets are not supported by the container an informal notification is added.
|
|
|
|
std::vector<TagTarget> requiredTargets = std::vector<TagTarget>();
|
|
|
|
/// \brief Specifies options to control the tag creation. See TagSettings::Flags.
|
|
|
|
TagCreationFlags flags = TagCreationFlags::Id3TransferValuesOnRemoval | TagCreationFlags::MergeMultipleSuccessiveId3v2Tags
|
|
|
|
| TagCreationFlags::KeepExistingId3v2Version;
|
|
|
|
/// \brief Specifies the usage of ID3v1 when creating tags for MP3 files (has no effect when the file is no MP3 file or not treated as one).
|
|
|
|
TagUsage id3v1usage = TagUsage::KeepExisting;
|
|
|
|
/// \brief Specifies the usage of ID3v2 when creating tags for MP3 files (has no effect when the file is no MP3 file or not treated as one).
|
|
|
|
TagUsage id3v2usage = TagUsage::Always;
|
|
|
|
/// \brief Specifies the ID3v2 version to be used in case an ID3v2 tag present or will be created. Valid values are 2, 3 and 4.
|
2019-03-13 19:06:42 +01:00
|
|
|
std::uint8_t id3v2MajorVersion = 3;
|
2018-03-11 18:57:22 +01:00
|
|
|
|
2018-03-13 22:06:32 +01:00
|
|
|
// workaround for GGC bug 66297 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66297)
|
|
|
|
#if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 2)
|
|
|
|
inline
|
|
|
|
#else
|
|
|
|
constexpr
|
|
|
|
#endif
|
2018-03-14 17:56:37 +01:00
|
|
|
TagCreationSettings &
|
|
|
|
setFlag(TagCreationFlags flag, bool enabled);
|
2018-03-11 18:57:22 +01:00
|
|
|
};
|
|
|
|
|
2018-03-13 22:06:32 +01:00
|
|
|
#if __GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 2)
|
|
|
|
inline
|
|
|
|
#else
|
|
|
|
constexpr
|
|
|
|
#endif
|
2018-03-14 17:56:37 +01:00
|
|
|
TagCreationSettings &
|
|
|
|
TagCreationSettings::setFlag(TagCreationFlags flag, bool enabled)
|
2018-03-11 18:57:22 +01:00
|
|
|
{
|
|
|
|
if (enabled) {
|
2019-08-12 20:22:57 +02:00
|
|
|
flags += flag;
|
2018-03-11 18:57:22 +01:00
|
|
|
} else {
|
|
|
|
flags -= flag;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace TagParser
|
|
|
|
|
|
|
|
#endif // TAGPARSER_SETTINGS_H
|