2015-09-06 19:57:33 +02:00
|
|
|
#include "./id3v2frameids.h"
|
2015-09-06 15:42:18 +02:00
|
|
|
|
2015-09-06 19:57:33 +02:00
|
|
|
#include "../exceptions.h"
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2018-03-07 01:17:50 +01:00
|
|
|
namespace TagParser {
|
2015-04-22 19:22:01 +02:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Encapsulates the most common ID3v2 frame IDs and related functions.
|
|
|
|
*
|
|
|
|
* There are short frame IDs (used by the first version of ID3v2) and long
|
|
|
|
* frame IDs (used by newer versions of ID3v2).
|
|
|
|
*
|
|
|
|
* The short IDs start with "s" and the long IDs with "l". To convert between
|
|
|
|
* these IDs the functions convertToShortId() and convertToLongId() can be
|
|
|
|
* used.
|
2020-04-22 18:43:41 +02:00
|
|
|
*
|
|
|
|
* \sa
|
|
|
|
* - See https://id3.org/id3v2.3.0 for the specification of ID3v2.3.0 frame IDs.
|
|
|
|
* - See https://id3.org/id3v2.4.0-frames for the specification of ID3v2.4.0 frame IDs.
|
2015-04-22 19:22:01 +02:00
|
|
|
*/
|
2018-03-07 01:17:50 +01:00
|
|
|
namespace Id3v2FrameIds {
|
2015-04-22 19:22:01 +02:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Converts the specified long frame ID to the equivalent short frame ID.
|
|
|
|
* \returns Returns the short ID if available; otherwise returns 0.
|
|
|
|
*/
|
2019-03-13 19:06:42 +01:00
|
|
|
std::uint32_t convertToShortId(std::uint32_t id)
|
2015-04-22 19:22:01 +02:00
|
|
|
{
|
2018-03-07 01:17:50 +01:00
|
|
|
switch (id) {
|
|
|
|
case lAlbum:
|
|
|
|
return sAlbum;
|
|
|
|
case lArtist:
|
|
|
|
return sArtist;
|
|
|
|
case lComment:
|
|
|
|
return sComment;
|
|
|
|
case lYear:
|
|
|
|
return sYear;
|
2020-04-22 19:14:34 +02:00
|
|
|
case lOriginalYear:
|
|
|
|
return sOriginalYear;
|
|
|
|
case lRecordingDates:
|
|
|
|
return sRecordingDates;
|
|
|
|
case lDate:
|
|
|
|
return sDate;
|
|
|
|
case lTime:
|
|
|
|
return sTime;
|
2018-03-07 01:17:50 +01:00
|
|
|
case lTitle:
|
|
|
|
return sTitle;
|
|
|
|
case lGenre:
|
|
|
|
return sGenre;
|
|
|
|
case lTrackPosition:
|
|
|
|
return sTrackPosition;
|
2018-06-02 23:08:14 +02:00
|
|
|
case lDiskPosition:
|
|
|
|
return sDiskPosition;
|
2018-03-07 01:17:50 +01:00
|
|
|
case lEncoder:
|
|
|
|
return sEncoder;
|
|
|
|
case lBpm:
|
|
|
|
return sBpm;
|
|
|
|
case lCover:
|
|
|
|
return sCover;
|
|
|
|
case lWriter:
|
|
|
|
return sWriter;
|
|
|
|
case lLength:
|
|
|
|
return sLength;
|
|
|
|
case lLanguage:
|
|
|
|
return sLanguage;
|
|
|
|
case lEncoderSettings:
|
|
|
|
return sEncoderSettings;
|
|
|
|
case lUnsynchronizedLyrics:
|
|
|
|
return sUnsynchronizedLyrics;
|
2019-06-16 17:45:49 +02:00
|
|
|
case lAlbumArtist:
|
|
|
|
return sAlbumArtist;
|
2019-01-01 23:38:39 +01:00
|
|
|
case lContentGroupDescription:
|
|
|
|
return sContentGroupDescription;
|
2018-03-07 01:17:50 +01:00
|
|
|
case lRecordLabel:
|
|
|
|
return sRecordLabel;
|
|
|
|
case lUserDefinedText:
|
|
|
|
return sUserDefinedText;
|
|
|
|
default:
|
|
|
|
return 0;
|
2015-04-22 19:22:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Converts the specified short frame ID to the equivalent long frame ID.
|
|
|
|
* \returns Returns the long ID if available; otherwise returns 0.
|
|
|
|
*/
|
2019-03-13 19:06:42 +01:00
|
|
|
std::uint32_t convertToLongId(std::uint32_t id)
|
2015-04-22 19:22:01 +02:00
|
|
|
{
|
2018-03-07 01:17:50 +01:00
|
|
|
switch (id) {
|
|
|
|
case sAlbum:
|
|
|
|
return lAlbum;
|
|
|
|
case sArtist:
|
|
|
|
return lArtist;
|
|
|
|
case sComment:
|
|
|
|
return lComment;
|
|
|
|
case sYear:
|
|
|
|
return lYear;
|
2020-04-22 19:14:34 +02:00
|
|
|
case sOriginalYear:
|
|
|
|
return lOriginalYear;
|
|
|
|
case sRecordingDates:
|
|
|
|
return lRecordingDates;
|
|
|
|
case sDate:
|
|
|
|
return lDate;
|
|
|
|
case sTime:
|
|
|
|
return lTime;
|
2018-03-07 01:17:50 +01:00
|
|
|
case sTitle:
|
|
|
|
return lTitle;
|
|
|
|
case sGenre:
|
|
|
|
return lGenre;
|
|
|
|
case sTrackPosition:
|
|
|
|
return lTrackPosition;
|
2018-06-02 23:08:14 +02:00
|
|
|
case sDiskPosition:
|
|
|
|
return lDiskPosition;
|
2018-03-07 01:17:50 +01:00
|
|
|
case sEncoder:
|
|
|
|
return lEncoder;
|
|
|
|
case sBpm:
|
|
|
|
return lBpm;
|
|
|
|
case sCover:
|
|
|
|
return lCover;
|
|
|
|
case sWriter:
|
|
|
|
return lWriter;
|
|
|
|
case sLength:
|
|
|
|
return lLength;
|
|
|
|
case sLanguage:
|
|
|
|
return lLanguage;
|
|
|
|
case sEncoderSettings:
|
|
|
|
return lEncoderSettings;
|
|
|
|
case sUnsynchronizedLyrics:
|
|
|
|
return lUnsynchronizedLyrics;
|
2019-06-16 17:45:49 +02:00
|
|
|
case sAlbumArtist:
|
|
|
|
return lAlbumArtist;
|
2019-01-01 23:38:39 +01:00
|
|
|
case sContentGroupDescription:
|
|
|
|
return lContentGroupDescription;
|
2018-03-07 01:17:50 +01:00
|
|
|
case sRecordLabel:
|
|
|
|
return lRecordLabel;
|
|
|
|
case sUserDefinedText:
|
|
|
|
return lUserDefinedText;
|
|
|
|
default:
|
|
|
|
return 0;
|
2015-04-22 19:22:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-22 19:48:27 +02:00
|
|
|
/*!
|
|
|
|
* \brief Returns whether \a id is only supported in ID3v2.3.x and older and therefore can not be used in an ID3v2.4.x tag.
|
|
|
|
* \remarks
|
|
|
|
* - This function is intended to show warnings. Unknown IDs will be treated as supported everywhere.
|
|
|
|
* - Any short ID is obviously not ID3v2.4.x compatible. Only long IDs are considered here. Short IDs need to be converted to
|
|
|
|
* long IDs before passing them to this function.
|
|
|
|
*/
|
|
|
|
bool isPreId3v24Id(uint32_t id)
|
|
|
|
{
|
|
|
|
switch (id) {
|
|
|
|
case lYear:
|
|
|
|
case lOriginalYear:
|
|
|
|
case lRecordingDates:
|
|
|
|
case lDate:
|
|
|
|
case lTime:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns whether \a id is only supported inID3v2.4.x and therefore can not be used in older versions.
|
|
|
|
* \remarks This function is intended to show warnings. Unknown IDs will be treated as supported everywhere.
|
|
|
|
*/
|
|
|
|
bool isOnlyId3v24Id(uint32_t id)
|
|
|
|
{
|
|
|
|
switch (id) {
|
|
|
|
case lRecordingTime:
|
|
|
|
case lReleaseTime:
|
|
|
|
case lOriginalReleaseTime:
|
|
|
|
case lTaggingTime:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-07 01:17:50 +01:00
|
|
|
} // namespace Id3v2FrameIds
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2018-03-07 01:17:50 +01:00
|
|
|
} // namespace TagParser
|