import { ByteVector, StringType } from "../../byteVector"; import { Id3v2FrameFlags, Id3v2FrameHeader } from "./frameHeader"; import { FrameIdentifier } from "../frameIdentifiers"; /** * Enumeration of types of frames. */ export declare enum FrameClassType { /** * Indicates the frame is an attachment frame. */ AttachmentFrame = 0, /** * Indicates the frame is a comments frame. */ CommentsFrame = 1, /** * Indicates the frame is an event time code frame. */ EventTimeCodeFrame = 2, /** * Indicates the frame is a music CD identifier frame. */ MusicCdIdentifierFrame = 3, /** * Indicates the frame is a play count frame. */ PlayCountFrame = 4, /** * Indicates the frame is a popularimeter frame. */ PopularimeterFrame = 5, /** * Indicates the frame is a private frame. */ PrivateFrame = 6, /** * Indicates the frame is relative volume frame. */ RelativeVolumeFrame = 7, /** * Indicates the frame is a synchronized lyrics frame. */ SynchronizedLyricsFrame = 8, /** * Indicates the frame is a terms of use frame. */ TermsOfUseFrame = 9, /** * Indicates the frame is a text information frame. */ TextInformationFrame = 10, /** * Indicates the frame is an unique file identifier frame. */ UniqueFileIdentifierFrame = 11, /** * Indicates the frame is an unknown frame. */ UnknownFrame = 12, /** * Indicates the frame is an attachment frame. */ UnsynchronizedLyricsFrame = 13, /** * Indicates the frame is a URL link frame. */ UrlLinkFrame = 14, /** * Indicates the frame is a user text information frame. */ UserTextInformationFrame = 15, /** * Indicates the frame is a user URL link frame. */ UserUrlLinkFrame = 16 } /** * Abstract class that represents an ID3v2 frame. Frames are the unit for storing information in * an ID3v2 tag. There are various types of frames that store differently structured information. */ export declare abstract class Frame { private _encryptionId; private _header; private _groupId; /** * Constructs and initializes a new instance with a frame header. * @param header Header for the frame. * @protected */ protected constructor(header: Id3v2FrameHeader); /** * Gets the encryption ID applied to the current instance. * @returns * Value containing the encryption identifier for the current instance or * `undefined` if not set. */ get encryptionId(): number | undefined; /** * Sets the encryption ID applied to the current instance. * @param value Value containing the encryption identifier for the current instance. Must be an * 8-bit unsigned integer. Setting to `undefined` will remove the encryption header and ID */ set encryptionId(value: number | undefined); /** * Gets the frame flags applied to the current instance. */ get flags(): Id3v2FrameFlags; /** * Sets the frame flags applied to the current instance. * If the value includes either {@link Id3v2FrameFlags.Encryption} or * {@link Id3v2FrameFlags.Compression}, {@link render} will throw. */ set flags(value: Id3v2FrameFlags); /** * Gets the header for the frame. For new frames this should not exist. * @protected */ protected get header(): Id3v2FrameHeader; /** * Sets the header for the frame. * @param value Header for the frame * @protected */ protected set header(value: Id3v2FrameHeader); /** * Gets a flag indicating which type of frame the current instance is. */ abstract get frameClassType(): FrameClassType; /** * Gets the frame ID for the current instance. * @returns Object representing of the identifier of the frame */ get frameId(): FrameIdentifier; /** * Gets the grouping ID applied to the current instance. * @returns * Value containing the grouping identifier for the current instance, or * `undefined` if not set. */ get groupId(): number | undefined; /** * Sets the grouping ID applied to the current instance. * @param value Grouping identifier for the current instance. Must be an 8-bit unsigned integer. * Setting to `undefined` will remove the grouping identity header and ID */ set groupId(value: number | undefined); /** * Gets the size of the current instance as it was last stored on disk. * NOTE: This value is not used outside of reading a frame from disk, so newly created frames * should not have this value set. */ get size(): number; /** * Creates a deep copy of the current instance. * This method is implemented by rendering the current instance as an ID3v2.4 frame and using * the frame factory to create a new frame. As such, this method should be overridden by child * classes. */ abstract clone(): Frame; /** * Renders the current instance, encoded in a specified ID3v2 version. * @param version Version of ID3v2 to use when encoding the current instance */ render(version: number): ByteVector; /** * Converts an encoding to be a supported encoding for a specified tag version. * @param type Value containing the original encoding * @param version Value containing the ID3v2 version to be encoded. * @returns * Value containing the correct encoding to use, based on * {@link Id3v2Settings.forceDefaultEncoding} and what is supported by * `version` */ protected static correctEncoding(type: StringType, version: number): StringType; /** * Extracts the field data from the raw portion of an ID3v2 frame. * This method is necessary for extracting extra data prepended to the frame such the as * grouping ID. * @param frameData Raw frame data * @param offset Index at which the data is contained * @param version Version of the ID3v2 tag the data was originally encoded with * @param dataIncludesHeader `true` if `frameData` includes the header, `false` * otherwise */ protected fieldData(frameData: ByteVector, offset: number, version: number, dataIncludesHeader: boolean): ByteVector; /** * Populates the values in this frame by parsing its field data in a specified version. * @param data Extracted field data * @param version ID3v2 version the field data is encoded in */ protected abstract parseFields(data: ByteVector, version: number): void; /** * Renders the values in the current instance into field data for a specified version. * @param version ID3v2 version the field data is to be encoded in. */ protected abstract renderFields(version: number): ByteVector; /** * Populates the current instance by reading the raw frame from disk, optionally reading the * header. * @param data Raw ID3v2 frame * @param offset Offset in `data` at which the frame begins. * @param readHeader Whether or not to read the reader into the current instance. * @param version Version of the ID3v2 tag the data was encoded with */ protected setData(data: ByteVector, offset: number, readHeader: boolean, version: number): void; }