|
id3dev 26.01
An ID3 metadata library
|
Function definitions of ID3v2 tag header and tag structure creation, manipulation, serialization, and JSON conversion. More...
#include "id3v2Types.h"

Go to the source code of this file.
Functions | |
| Id3v2TagHeader * | id3v2CreateTagHeader (uint8_t majorVersion, uint8_t minorVersion, uint8_t flags, Id3v2ExtendedTagHeader *extendedHeader) |
| Creates and allocates an ID3v2 tag header structure. | |
| void | id3v2DestroyTagHeader (Id3v2TagHeader **toDelete) |
| Frees an ID3v2 tag header and nullifies the pointer. | |
| bool | id3v2WriteUnsynchronisationIndicator (Id3v2TagHeader *header, bool bit) |
| Sets or clears the unsynchronisation flag in the tag header. | |
| bool | id3v2WriteCompressionIndicator (Id3v2TagHeader *header, bool bit) |
| Sets or clears the compression flag in ID3v2.2 tag headers. | |
| bool | id3v2WriteExtendedHeaderIndicator (Id3v2TagHeader *header, bool bit) |
| Sets or clears the extended header flag in ID3v2.3/ID3v2.4 tag headers. | |
| bool | id3v2WriteExperimentalIndicator (Id3v2TagHeader *header, bool bit) |
| Sets or clears the experimental indicator flag in ID3v2.3/ID3v2.4 tag headers. | |
| bool | id3v2WriteFooterIndicator (Id3v2TagHeader *header, bool bit) |
| Sets or clears the footer presence flag in ID3v2.4 tag headers. | |
| int | id3v2ReadUnsynchronisationIndicator (Id3v2TagHeader *header) |
| Reads the unsynchronisation flag from a tag header. | |
| int | id3v2ReadCompressionIndicator (Id3v2TagHeader *header) |
| Reads the compression flag from an ID3v2.2 tag header. | |
| int | id3v2ReadExtendedHeaderIndicator (Id3v2TagHeader *header) |
| Reads the extended header flag from an ID3v2.3/ID3v2.4 tag header. | |
| int | id3v2ReadExperimentalIndicator (Id3v2TagHeader *header) |
| Reads the experimental indicator flag from an ID3v2.3/ID3v2.4 tag header. | |
| int | id3v2ReadFooterIndicator (Id3v2TagHeader *header) |
| Reads the footer presence flag from an ID3v2.4 tag header. | |
| Id3v2ExtendedTagHeader * | id3v2CreateExtendedTagHeader (uint32_t padding, uint32_t crc, bool update, bool tagRestrictions, uint8_t restrictions) |
| Creates and allocates an ID3v2 extended tag header structure. | |
| void | id3v2DestroyExtendedTagHeader (Id3v2ExtendedTagHeader **toDelete) |
| Frees an ID3v2 extended tag header and nullifies the pointer. | |
| bool | id3v2WriteTagSizeRestriction (Id3v2TagHeader *header, uint8_t bits) |
| Sets the tag size restriction in an ID3v2.4 extended header. | |
| bool | id3v2WriteTextEncodingRestriction (Id3v2TagHeader *header, bool bit) |
| Sets the text encoding restriction in an ID3v2.4 extended header. | |
| bool | id3v2WriteTextFieldsSizeRestriction (Id3v2TagHeader *header, uint8_t bits) |
| Sets the text encoding restriction in an ID3v2.4 extended header. | |
| bool | id3v2WriteImageEncodingRestriction (Id3v2TagHeader *header, bool bit) |
| Sets the image encoding restriction in an ID3v2.4 extended header. | |
| bool | id3v2WriteImageSizeRestriction (Id3v2TagHeader *header, uint8_t bits) |
| Sets the image size restriction in an ID3v2.4 extended header. | |
| int | id3v2ReadTagSizeRestriction (Id3v2TagHeader *header) |
| Reads the tag size restriction from an ID3v2.4 extended header. | |
| int | id3v2ReadTextEncodingRestriction (Id3v2TagHeader *header) |
| Reads the text encoding restriction from an ID3v2.4 extended header. | |
| int | id3v2ReadTextFieldsSizeRestriction (Id3v2TagHeader *header) |
| Reads the text fields size restriction from an ID3v2.4 extended header. | |
| int | id3v2ReadImageEncodingRestriction (Id3v2TagHeader *header) |
| Reads the image encoding restriction from an ID3v2.4 extended header. | |
| int | id3v2ReadImageSizeRestriction (Id3v2TagHeader *header) |
| Reads the image size restriction from an ID3v2.4 extended header. | |
| bool | id3v2ClearTagRestrictions (Id3v2TagHeader *header) |
| Clears all tag restrictions from an ID3v2.4 extended header. | |
| Id3v2Tag * | id3v2CreateTag (Id3v2TagHeader *header, List *frames) |
| Creates and allocates an ID3v2 tag structure. | |
| void | id3v2DestroyTag (Id3v2Tag **toDelete) |
| Frees an ID3v2 tag and all associated resources, nullifying the pointer. | |
| uint8_t * | id3v2ExtendedTagHeaderSerialize (Id3v2ExtendedTagHeader *ext, uint8_t version, size_t *outl) |
| Serializes an ID3v2 extended tag header into a byte stream. | |
| char * | id3v2ExtendedTagHeaderToJSON (const Id3v2ExtendedTagHeader *ext, uint8_t version) |
| Converts an ID3v2 extended tag header structure to JSON string representation. | |
| uint8_t * | id3v2TagHeaderSerialize (Id3v2TagHeader *header, uint32_t uintSize, size_t *outl) |
| Serializes an ID3v2 tag header into a byte stream. | |
| char * | id3v2TagHeaderToJSON (const Id3v2TagHeader *header) |
| Converts an ID3v2 tag header structure to JSON string representation. | |
Function definitions of ID3v2 tag header and tag structure creation, manipulation, serialization, and JSON conversion.
Definition in file id3v2TagIdentity.h.
| bool id3v2ClearTagRestrictions | ( | Id3v2TagHeader * | header | ) |
Clears all tag restrictions from an ID3v2.4 extended header.
Resets the tagRestrictions flag to false and zeroes the restrictions byte, removing all tag size, text encoding, text field size, image encoding, and image size restrictions. Requires a valid extended header to be present. Only applicable to ID3v2.4 tags as earlier versions do not support restrictions.
| header | - The tag header to modify. |
Definition at line 606 of file id3v2TagIdentity.c.
| Id3v2ExtendedTagHeader * id3v2CreateExtendedTagHeader | ( | uint32_t | padding, |
| uint32_t | crc, | ||
| bool | update, | ||
| bool | tagRestrictions, | ||
| uint8_t | restrictions ) |
Creates and allocates an ID3v2 extended tag header structure.
Allocates memory and initializes extended header members with provided padding, CRC, update flag, and restrictions. Extended headers contain optional metadata used in ID3v2.3 and ID3v2.4 tags. Caller must free with id3v2DestroyExtendedTagHeader.
| padding | - Padding size in bytes (ID3v2.3) or unused (ID3v2.4). |
| crc | - CRC-32 checksum value for data integrity verification (0 if not used). |
| update | - Update flag indicating tag is an update of previous tag (ID3v2.4 only). |
| tagRestrictions | - Whether tag restrictions are present (ID3v2.4 only). |
| restrictions | - Restrictions byte defining tag size, text encoding, and image limitations. |
Definition at line 280 of file id3v2TagIdentity.c.
| Id3v2Tag * id3v2CreateTag | ( | Id3v2TagHeader * | header, |
| List * | frames ) |
Creates and allocates an ID3v2 tag structure.
Allocates memory and initializes a complete ID3v2 tag with the provided header and frame list while taking ownership. The tag structure combines the tag header with the list of data frames. Caller must free with id3v2DestroyTag.
| header | - Pointer to an initialized tag header structure. |
| frames | - Pointer to a list containing ID3v2 frame structures. |
Definition at line 630 of file id3v2TagIdentity.c.
| Id3v2TagHeader * id3v2CreateTagHeader | ( | uint8_t | majorVersion, |
| uint8_t | minorVersion, | ||
| uint8_t | flags, | ||
| Id3v2ExtendedTagHeader * | extendedHeader ) |
Creates and allocates an ID3v2 tag header structure.
Allocates memory and initializes header fields with provided version, flags, and optional extended header. Caller must free with id3v2DestroyTagHeader.
| majorVersion | - Major version number (2, 3, or 4) |
| minorVersion | - Minor version/revision number |
| flags | - Tag header flags byte (abcd0000) |
| extendedHeader | - Pointer to extended header structure. |
Definition at line 29 of file id3v2TagIdentity.c.
| void id3v2DestroyExtendedTagHeader | ( | Id3v2ExtendedTagHeader ** | toDelete | ) |
Frees an ID3v2 extended tag header and nullifies the pointer.
Deallocates extended header memory and sets pointer to NULL to prevent dangling pointer issues.
| toDelete | - Pointer to the extended tag header pointer to free. |
Definition at line 301 of file id3v2TagIdentity.c.
| void id3v2DestroyTag | ( | Id3v2Tag ** | toDelete | ) |
Frees an ID3v2 tag and all associated resources, nullifying the pointer.
Recursively destroys the tag header (including extended header if present), frees the frames list and all frame contents, deallocates the tag structure memory, and sets the pointer to NULL to prevent dangling pointer issues.
| toDelete | - Pointer to the tag pointer to free. |
Definition at line 646 of file id3v2TagIdentity.c.
| void id3v2DestroyTagHeader | ( | Id3v2TagHeader ** | toDelete | ) |
Frees an ID3v2 tag header and nullifies the pointer.
Recursively destroys extended header if present, deallocates header memory, and sets pointer to NULL to prevent dangling pointer issues.
| toDelete | - Pointer to the tag header pointer to free. |
Definition at line 47 of file id3v2TagIdentity.c.
| uint8_t * id3v2ExtendedTagHeaderSerialize | ( | Id3v2ExtendedTagHeader * | ext, |
| uint8_t | version, | ||
| size_t * | outl ) |
Serializes an ID3v2 extended tag header into a byte stream.
Converts an extended header structure into its binary representation according to the ID3v2 specification. Returns a dynamically allocated byte array that must be freed by the caller. Handles version-specific formats:
ID3v2.2 does not support extended headers and returns NULL.
| ext | - Pointer to the extended header structure to serialize. |
| version | - ID3v2 version (ID3V2_TAG_VERSION_2, ID3V2_TAG_VERSION_3, or ID3V2_TAG_VERSION_4) determining serialization format. |
| outl | - Output parameter receiving the size of the returned byte array. |
Definition at line 676 of file id3v2TagIdentity.c.
| char * id3v2ExtendedTagHeaderToJSON | ( | const Id3v2ExtendedTagHeader * | ext, |
| uint8_t | version ) |
Converts an ID3v2 extended tag header structure to JSON string representation.
Creates a dynamically allocated JSON string containing the extended header's fields according to the specified ID3v2 version. Returns an empty JSON object "{}" if the header is NULL or the version is unsupported. The caller must free the returned string.
| ext | - Pointer to the extended header structure to convert (may be NULL). |
| version | - ID3v2 version (ID3V2_TAG_VERSION_2, ID3V2_TAG_VERSION_3, or ID3V2_TAG_VERSION_4) determining which fields to include. |
Definition at line 804 of file id3v2TagIdentity.c.
| int id3v2ReadCompressionIndicator | ( | Id3v2TagHeader * | header | ) |
Reads the compression flag from an ID3v2.2 tag header.
Extracts bit 6 of the header flags byte. Only valid for ID3v2.2 tags.
| header | - The tag header to read from. |
Definition at line 190 of file id3v2TagIdentity.c.
| int id3v2ReadExperimentalIndicator | ( | Id3v2TagHeader * | header | ) |
Reads the experimental indicator flag from an ID3v2.3/ID3v2.4 tag header.
Extracts bit 5 of the header flags byte. The experimental indicator marks a tag as being in an experimental or testing state. Only valid for ID3v2.3 and ID3v2.4 tags as this flag is not available in ID3v2.2.
| header | - The tag header to read from. |
Definition at line 233 of file id3v2TagIdentity.c.
| int id3v2ReadExtendedHeaderIndicator | ( | Id3v2TagHeader * | header | ) |
Reads the extended header flag from an ID3v2.3/ID3v2.4 tag header.
Extracts bit 6 of the header flags byte. Only valid for ID3v2.3 and ID3v2.4 tags as ID3v2.2 does not support extended headers.
| header | - The tag header to read from. |
Definition at line 209 of file id3v2TagIdentity.c.
| int id3v2ReadFooterIndicator | ( | Id3v2TagHeader * | header | ) |
Reads the footer presence flag from an ID3v2.4 tag header.
Extracts bit 4 of the header flags byte. Only valid for ID3v2.4 tags as earlier versions do not support footers.
| header | - The tag header to read from. |
Definition at line 256 of file id3v2TagIdentity.c.
| int id3v2ReadImageEncodingRestriction | ( | Id3v2TagHeader * | header | ) |
Reads the image encoding restriction from an ID3v2.4 extended header.
Extracts bit 2 from the restrictions byte. When set (1), embedded images are restricted to PNG [PNG] or JPEG [JFIF] format only. Requires a valid extended header with restrictions enabled.
| header | - The tag header to read from. |
Definition at line 558 of file id3v2TagIdentity.c.
| int id3v2ReadImageSizeRestriction | ( | Id3v2TagHeader * | header | ) |
Reads the image size restriction from an ID3v2.4 extended header.
Extracts bits 0-1 from the restrictions byte and combines them into a 2-bit value (0x00-0x03) indicating the maximum image dimension restriction level. Requires a valid extended header with restrictions enabled.
| header | - The tag header to read from. |
Definition at line 578 of file id3v2TagIdentity.c.
| int id3v2ReadTagSizeRestriction | ( | Id3v2TagHeader * | header | ) |
Reads the tag size restriction from an ID3v2.4 extended header.
Extracts bits 6-7 from the restrictions byte and combines them into a 2-bit value (0x00-0x03) indicating the maximum tag size restriction level. Requires a valid extended header with restrictions enabled.
| header | - The tag header to read from. |
Definition at line 483 of file id3v2TagIdentity.c.
| int id3v2ReadTextEncodingRestriction | ( | Id3v2TagHeader * | header | ) |
Reads the text encoding restriction from an ID3v2.4 extended header.
Extracts bit 5 from the restrictions byte. When set (1), text encodings are restricted to ISO-8859-1 or UTF-8 only. Requires a valid extended header with restrictions enabled.
| header | - The tag header to read from. |
Definition at line 510 of file id3v2TagIdentity.c.
| int id3v2ReadTextFieldsSizeRestriction | ( | Id3v2TagHeader * | header | ) |
Reads the text fields size restriction from an ID3v2.4 extended header.
Extracts bits 3-4 from the restrictions byte and combines them into a 2-bit value (0x00-0x03) indicating the maximum text field size restriction level. Requires a valid extended header with restrictions enabled.
| header | - The tag header to read from. |
Definition at line 530 of file id3v2TagIdentity.c.
| int id3v2ReadUnsynchronisationIndicator | ( | Id3v2TagHeader * | header | ) |
Reads the unsynchronisation flag from a tag header.
Extracts bit 7 of the header flags byte. Valid for all ID3v2 versions (2.2, 2.3, 2.4).
| header | - The tag header to read from. |
Definition at line 176 of file id3v2TagIdentity.c.
| uint8_t * id3v2TagHeaderSerialize | ( | Id3v2TagHeader * | header, |
| uint32_t | uintSize, | ||
| size_t * | outl ) |
Serializes an ID3v2 tag header into a byte stream.
Converts a tag header structure into its binary representation per the ID3v2 specification. Returns a dynamically allocated byte array containing:
"ID3" identifier (3) + major version (1) + minor version (1) + flags (1) + syncsafe tag size (4) + optional extended header (variable).
Version-specific flags written: v2.2 (unsync, compression), v2.3 (unsync, extended header, experimental), v2.4 (unsync, extended header, experimental, footer). Returns NULL for versions > 2.4 or NULL input.
| header | - Pointer to the tag header structure to serialize. |
| uintSize | - Tag size in bytes (excluding 10-byte header), encoded as syncsafe integer. |
| outl | - Output parameter receiving total size of returned byte array. |
Definition at line 883 of file id3v2TagIdentity.c.
| char * id3v2TagHeaderToJSON | ( | const Id3v2TagHeader * | header | ) |
Converts an ID3v2 tag header structure to JSON string representation.
Creates a dynamically allocated JSON string containing the tag header's version, flags, and extended header fields according to the ID3v2 version. Returns an empty JSON object "{}" if the header is NULL or the version is unsupported. The caller must free the returned string.
| header | - Pointer to the tag header structure to convert (may be NULL). |
Definition at line 980 of file id3v2TagIdentity.c.
| bool id3v2WriteCompressionIndicator | ( | Id3v2TagHeader * | header, |
| bool | bit ) |
Sets or clears the compression flag in ID3v2.2 tag headers.
Modifies bit 6 of the header flags byte. Only applicable to ID3v2.2 tags; returns failure for other versions as compression moved to frame-level in v2.3+.
| header | - The tag header to modify. |
| bit | - true to set compression flag, false to clear it. |
Definition at line 81 of file id3v2TagIdentity.c.
| bool id3v2WriteExperimentalIndicator | ( | Id3v2TagHeader * | header, |
| bool | bit ) |
Sets or clears the experimental indicator flag in ID3v2.3/ID3v2.4 tag headers.
Modifies bit 5 of the header flags byte. Marks tag as experimental/testing. Only applicable to ID3v2.3 and ID3v2.4 tags; returns failure for other versions.
| header | - The tag header to modify. |
| bit | - true to set experimental flag, false to clear it. |
Definition at line 128 of file id3v2TagIdentity.c.
| bool id3v2WriteExtendedHeaderIndicator | ( | Id3v2TagHeader * | header, |
| bool | bit ) |
Sets or clears the extended header flag in ID3v2.3/ID3v2.4 tag headers.
Modifies bit 6 of the header flags byte. Only applicable to ID3v2.3 and ID3v2.4 tags; returns failure for other versions as ID3v2.2 does not support extended headers.
| header | - The tag header to modify. |
| bit | - true to set extended header flag, false to clear it. |
Definition at line 102 of file id3v2TagIdentity.c.
| bool id3v2WriteFooterIndicator | ( | Id3v2TagHeader * | header, |
| bool | bit ) |
Sets or clears the footer presence flag in ID3v2.4 tag headers.
Modifies bit 4 of the header flags byte. Footer is a 10-byte structure at tag end mirroring the header with reversed "3DI" identifier. Only applicable to ID3v2.4 tags.
| header | - The tag header to modify. |
| bit | - true to set footer flag, false to clear it. |
Definition at line 154 of file id3v2TagIdentity.c.
| bool id3v2WriteImageEncodingRestriction | ( | Id3v2TagHeader * | header, |
| bool | bit ) |
Sets the image encoding restriction in an ID3v2.4 extended header.
Modifies bit 2 of the restrictions byte to limit allowed image formats. When set, restricts embedded images to PNG [PNG] or JPEG [JFIF] format only. Only applicable to ID3v2.4 tags. Automatically creates an extended header if not present and enables the tagRestrictions flag.
| header | - The tag header to modify. |
| bit | - true to enable image encoding restriction, false to disable. |
Definition at line 419 of file id3v2TagIdentity.c.
| bool id3v2WriteImageSizeRestriction | ( | Id3v2TagHeader * | header, |
| uint8_t | bits ) |
Sets the image size restriction in an ID3v2.4 extended header.
Modifies bits 0-1 of the restrictions byte to set maximum image dimension limitations. The 2-bit value defines four restriction levels (0x00-0x03) for embedded image sizes. Only applicable to ID3v2.4 tags. Automatically creates an extended header if not present and enables the tagRestrictions flag.
| header | - The tag header to modify. |
| bits | - Restriction level (0x00-0x03): defines maximum allowed image dimensions. |
Definition at line 451 of file id3v2TagIdentity.c.
| bool id3v2WriteTagSizeRestriction | ( | Id3v2TagHeader * | header, |
| uint8_t | bits ) |
Sets the tag size restriction in an ID3v2.4 extended header.
Modifies bits 6-7 of the restrictions byte to set maximum tag size limitations. The 2-bit value defines four restriction levels (0x00-0x03). Only applicable to ID3v2.4 tags. Automatically creates an extended header if not present and enables the tagRestrictions flag.
| header | - The tag header to modify. |
| bits | - Restriction level (0x00-0x03): defines maximum allowed tag size. |
Definition at line 319 of file id3v2TagIdentity.c.
| bool id3v2WriteTextEncodingRestriction | ( | Id3v2TagHeader * | header, |
| bool | bit ) |
Sets the text encoding restriction in an ID3v2.4 extended header.
Modifies bit 5 of the restrictions byte to limit allowed text encodings. When set, restricts text encoding to ISO-8859-1 or UTF-8 only. Only applicable to ID3v2.4 tags. Automatically creates an extended header if not present and enables the tagRestrictions flag.
| header | - The tag header to modify. |
| bit | - true to enable text encoding restriction, false to disable. |
Definition at line 353 of file id3v2TagIdentity.c.
| bool id3v2WriteTextFieldsSizeRestriction | ( | Id3v2TagHeader * | header, |
| uint8_t | bits ) |
Sets the text encoding restriction in an ID3v2.4 extended header.
Modifies bit 5 of the restrictions byte to limit allowed text encodings. When set, restricts text encoding to ISO-8859-1 or UTF-8 only. Only applicable to ID3v2.4 tags. Automatically creates an extended header if not present and enables the tagRestrictions flag.
| header | - The tag header to modify. |
| bit | - true to enable text encoding restriction, false to disable. |
Definition at line 385 of file id3v2TagIdentity.c.
| bool id3v2WriteUnsynchronisationIndicator | ( | Id3v2TagHeader * | header, |
| bool | bit ) |
Sets or clears the unsynchronisation flag in the tag header.
Modifies bit 7 of the header flags byte. Unsynchronisation prevents false sync patterns in tag data.
| header | - The tag header to modify. |
| bit | - true to set unsynchronisation flag, false to clear it. |
Definition at line 63 of file id3v2TagIdentity.c.