frames

package
v0.0.0-...-a962232 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TextInformationKind            = "text information"
	NonStandardTextInformationKind = "non-standard text information"
	CommentKind                    = "comment"
	AttachedPictureKind            = "attached picture"
	UserDefinedURLKind             = "user defined url"
	PrivateKind                    = "private"
	UnsynchronizedLyricsKind       = "unsynchronized lyrics"
	UserDefinedTextInformationKind = "user defined text information"
	MusicCDIdentifierKind          = "music cd identifier"
	GeneralEncapsulationObjectKind = "general encapsulation object"
	TermsOfUseKind                 = "terms of use"
)
View Source
const (
	FlagTagAlterPreservation  = 0b10000000
	FlagFileAlterPreservation = 0b01000000
	FlagReadOnly              = 0b00100000
	FlagCompression           = 0b00010000
	FlagEncryption            = 0b00001000
	FlagGroupingIdentity      = 0b00000100
)
View Source
const HeaderMinSize = 10

Variables

View Source
var Descriptions = map[string]string{
	"AENC": "Audio encryption",
	"APIC": "Attached picture",
	"COMM": "Comments",
	"COMR": "Commercial frame",
	"ENCR": "Encryption method registration",
	"EQUA": "Equalization",
	"ETCO": "Event timing codes",
	"GEOB": "General encapsulated object",
	"GRID": "Group identification registration",
	"IPLS": "Involved people list",
	"LINK": "Linked information",
	"MCDI": "Music CD identifier",
	"MLLT": "MPEG location lookup table",
	"OWNE": "Ownership frame",
	"PRIV": "Private frame",
	"PCNT": "Play counter",
	"POPM": "Popularimeter",
	"POSS": "Position synchronisation frame",
	"RBUF": "Recommended buffer size",
	"RVAD": "Relative volume adjustment",
	"RVRB": "Reverb",
	"SYLT": "Synchronized lyric/text",
	"SYTC": "Synchronized tempo codes",
	"TALB": "Album/Movie/Show title",
	"TBPM": "BPM (beats per minute)",
	"TCOM": "Composer",
	"TCON": "Content type",
	"TCOP": "Copyright message",
	"TDAT": "Date",
	"TDLY": "Playlist delay",
	"TENC": "Encoded by",
	"TEXT": "Lyricist/Text writer",
	"TFLT": "File type",
	"TIME": "Time",
	"TIT1": "Content group description",
	"TIT2": "Title/songname/content description",
	"TIT3": "Subtitle/Description refinement",
	"TKEY": "Initial key",
	"TLAN": "Language(s)",
	"TLEN": "Length",
	"TMED": "Media type",
	"TOAL": "Original album/movie/show title",
	"TOFN": "Original filename",
	"TOLY": "Original lyricist(s)/text writer(s)",
	"TOPE": "Original artist(s)/performer(s)",
	"TORY": "Original release year",
	"TOWN": "File owner/licensee",
	"TPE1": "Lead performer(s)/Soloist(s)",
	"TPE2": "Band/orchestra/accompaniment",
	"TPE3": "Conductor/performer refinement",
	"TPE4": "Interpreted, remixed, or otherwise modified by",
	"TPOS": "Part of a set",
	"TPUB": "Publisher",
	"TRCK": "Track number/Position in set",
	"TRDA": "Recording dates",
	"TRSN": "Internet radio station name",
	"TRSO": "Internet radio station owner",
	"TSIZ": "Size",
	"TSRC": "ISRC (international standard recording code)",
	"TSSE": "Software/Hardware and settings used for encoding",
	"TYER": "Year",
	"TXXX": "User defined text information frame",
	"UFID": "Unique file identifier",
	"USER": "Terms of use",
	"USLT": "Unsychronized lyric/text transcription",
	"WCOM": "Commercial information",
	"WCOP": "Copyright/Legal information",
	"WOAF": "Official audio file webpage",
	"WOAR": "Official artist/performer webpage",
	"WOAS": "Official audio source webpage",
	"WORS": "Official internet radio station homepage",
	"WPAY": "Payment",
	"WPUB": "Publishers official webpage",
	"WXXX": "User defined URL link frame",
}
View Source
var IDToFrameKind = map[string]string{
	"TALB": TextInformationKind,
	"TBPM": TextInformationKind,
	"TCOM": TextInformationKind,
	"TCON": TextInformationKind,
	"TCOP": TextInformationKind,
	"TDAT": TextInformationKind,
	"TDLY": TextInformationKind,
	"TENC": TextInformationKind,
	"TEXT": TextInformationKind,
	"TFLT": TextInformationKind,
	"TIME": TextInformationKind,
	"TIT1": TextInformationKind,
	"TIT2": TextInformationKind,
	"TIT3": TextInformationKind,
	"TKEY": TextInformationKind,
	"TLAN": TextInformationKind,
	"TLEN": TextInformationKind,
	"TMED": TextInformationKind,
	"TOAL": TextInformationKind,
	"TOFN": TextInformationKind,
	"TOLY": TextInformationKind,
	"TOPE": TextInformationKind,
	"TORY": TextInformationKind,
	"TOWN": TextInformationKind,
	"TPE1": TextInformationKind,
	"TPE2": TextInformationKind,
	"TPE3": TextInformationKind,
	"TPE4": TextInformationKind,
	"TPOS": TextInformationKind,
	"TPUB": TextInformationKind,
	"TRCK": TextInformationKind,
	"TRDA": TextInformationKind,
	"TRSN": TextInformationKind,
	"TRSO": TextInformationKind,
	"TSIZ": TextInformationKind,
	"TSRC": TextInformationKind,
	"TSSE": TextInformationKind,
	"TYER": TextInformationKind,
	"TCMP": NonStandardTextInformationKind,
	"TDRL": NonStandardTextInformationKind,
	"TDRC": NonStandardTextInformationKind,
	"COMM": CommentKind,
	"APIC": AttachedPictureKind,
	"WXXX": UserDefinedURLKind,
	"PRIV": PrivateKind,
	"USLT": UnsynchronizedLyricsKind,
	"TXXX": UserDefinedTextInformationKind,
	"MCDI": MusicCDIdentifierKind,
	"GEOB": GeneralEncapsulationObjectKind,
	"USER": TermsOfUseKind,
}
View Source
var PictureTypes = map[byte]string{
	0x00: "Other",
	0x01: "32x32 pixels 'file icon' (PNG only)",
	0x02: "Other file icon",
	0x03: "Cover (front)",
	0x04: "Cover (back)",
	0x05: "Leaflet page",
	0x06: "Media (e.g. lable side of CD)",
	0x07: "Lead artist/lead performer/soloist",
	0x08: "Artist/performer",
	0x09: "Conductor",
	0x0A: "Band/Orchestra",
	0x0B: "Composer",
	0x0C: "Lyricist/text writer",
	0x0D: "Recording Location",
	0x0E: "During recording",
	0x0F: "During performance",
	0x10: "Movie/video screen capture",
	0x11: "A bright coloured fish",
	0x12: "Illustration",
	0x13: "Band/artist logotype",
	0x14: "Publisher/Studio logotype",
}

Functions

This section is empty.

Types

type AttachedPicture

type AttachedPicture struct {
	TextEncoding byte
	MIMEType     string
	PictureType  byte
	Description  []rune
	PictureData  []byte
}

AttachedPicture are all of the attached picture frames. AttachedPicture frames have an ID of APIC.

func (*AttachedPicture) Equal

func (a *AttachedPicture) Equal(a2 *AttachedPicture) bool

func (*AttachedPicture) ExtractPicture

func (a *AttachedPicture) ExtractPicture()

func (*AttachedPicture) MarshalBinary

func (a *AttachedPicture) MarshalBinary() ([]byte, error)

func (*AttachedPicture) String

func (a *AttachedPicture) String() string

func (*AttachedPicture) UnmarshalBinary

func (a *AttachedPicture) UnmarshalBinary(data []byte) error

func (*AttachedPicture) UnmarshalJSON

func (a *AttachedPicture) UnmarshalJSON(data []byte) error

UnmarshalJSON will be in UTF-8; so decode that and encode it into UTF-16

type Comment

type Comment struct {
	TextEncoding            byte
	Language                string
	ShortContentDescription []rune
	ActualText              []rune
}

Comment are all of the comment frames. Comment frames have an ID of COMM.

func (*Comment) Equal

func (c *Comment) Equal(c2 *Comment) bool

func (*Comment) MarshalBinary

func (c *Comment) MarshalBinary() ([]byte, error)

func (*Comment) String

func (c *Comment) String() string

func (*Comment) UnmarshalBinary

func (c *Comment) UnmarshalBinary(data []byte) error

func (*Comment) UnmarshalJSON

func (c *Comment) UnmarshalJSON(data []byte) error

type Frame

type Frame struct {
	Header *FrameHeader
	Body   FrameBody
}

func NewFrame

func NewFrame(id string, body FrameBody) *Frame

func (*Frame) MarshalBinary

func (f *Frame) MarshalBinary() ([]byte, error)

func (*Frame) UnmarshalBinary

func (f *Frame) UnmarshalBinary(data []byte) error

type FrameBody

type FrameBody interface {
	String() string
	MarshalBinary() ([]byte, error)
	UnmarshalBinary([]byte) error
	UnmarshalJSON([]byte) error
}

type FrameBodyUnpacker

type FrameBodyUnpacker struct {
	FrameBody
}

func (*FrameBodyUnpacker) UnmarshalJSON

func (f *FrameBodyUnpacker) UnmarshalJSON(data []byte) error

UnmarshalJSON will try to unpack the incoming bytes into the correct frame type.

type FrameHeader

type FrameHeader struct {
	ID   string
	Size int

	// PreserveTagOnAlteration: this flag tells the software what to do with this frame if it is
	//   unknown and the tag is altered in any way. This applies to all
	//   kinds of alterations, including adding more padding and reordering
	//   the frames.
	PreserveTagOnAlteration bool

	// PreserveFileOnAlteration: this flag tells the software what to do with this frame if it is
	//   unknown and the file, excluding the tag, is altered. This does not
	//   apply when the audio is completely replaced with other audio data.
	PreserveFileOnAlteration bool

	// ReadOnly: this flag, if set, tells the software that the contents of this
	//   frame is intended to be read only. Changing the contents might
	//   break something, e.g. a signature. If the contents are changed,
	//   without knowledge in why the frame was flagged read only and
	//   without taking the proper means to compensate, e.g. recalculating
	//   the signature, the bit should be cleared.
	ReadOnly bool

	// Compression: this flag indicates whether or not the frame is compressed.
	Compressed bool

	// Encryption: this flag indicates wether or not the frame is encrypted. If set
	// one byte indicating with which method it was encrypted will be
	// appended to the frame header. See section 4.26. for more
	// information about encryption method registration.
	Encrypted bool

	// ContainsGroupingIdentity: this flag indicates whether or not this frame belongs in a group
	// with other frames. If set a group identifier byte is added to the
	// frame header. Every frame with the same group identifier belongs
	// to the same group.
	ContainsGroupingIdentity bool
}

func (*FrameHeader) FlagsAsBytes

func (f *FrameHeader) FlagsAsBytes() [2]byte

func (*FrameHeader) MarshalBinary

func (f *FrameHeader) MarshalBinary() ([]byte, error)

func (*FrameHeader) String

func (f *FrameHeader) String() string

func (*FrameHeader) UnmarshalBinary

func (f *FrameHeader) UnmarshalBinary(data []byte) error

type Frames

type Frames []*Frame

func (*Frames) ApplyFrame

func (f *Frames) ApplyFrame(frame *Frame) error

func (Frames) Len

func (f Frames) Len() int

implement sort on frames

func (Frames) Less

func (f Frames) Less(i, j int) bool

func (*Frames) RemoveFramesWithID

func (f *Frames) RemoveFramesWithID(id string)

func (*Frames) Swap

func (f *Frames) Swap(i, j int)

func (*Frames) UnmarshalBinary

func (f *Frames) UnmarshalBinary(data []byte) error

type GeneralEncapsulationObject

type GeneralEncapsulationObject struct {
	TextEncoding       byte
	MIMEType           string
	Filename           []rune
	ContentDescription []rune
	EncapsulatedObject []byte
}

GeneralEncapsulationObject have the ID GEOB

func (*GeneralEncapsulationObject) Equal

func (*GeneralEncapsulationObject) MarshalBinary

func (g *GeneralEncapsulationObject) MarshalBinary() ([]byte, error)

func (*GeneralEncapsulationObject) String

func (g *GeneralEncapsulationObject) String() string

func (*GeneralEncapsulationObject) UnmarshalBinary

func (g *GeneralEncapsulationObject) UnmarshalBinary(data []byte) error

type MusicCDIdentifier

type MusicCDIdentifier struct {
	TableOfContents []byte
}

MusicCDIdentifier have the ID MCDI

func (*MusicCDIdentifier) Equal

func (*MusicCDIdentifier) MarshalBinary

func (m *MusicCDIdentifier) MarshalBinary() ([]byte, error)

func (*MusicCDIdentifier) String

func (m *MusicCDIdentifier) String() string

func (*MusicCDIdentifier) UnmarshalBinary

func (m *MusicCDIdentifier) UnmarshalBinary(data []byte) error

func (*MusicCDIdentifier) UnmarshalJSON

func (m *MusicCDIdentifier) UnmarshalJSON(data []byte) error

type PrivateData

type PrivateData struct {
	OwnerIdentifier string
	Data            []byte
}

Private Data frames have an ID of PRIV

func (*PrivateData) Equal

func (p *PrivateData) Equal(p2 *PrivateData) bool

func (*PrivateData) MarshalBinary

func (p *PrivateData) MarshalBinary() ([]byte, error)

func (*PrivateData) String

func (p *PrivateData) String() string

func (*PrivateData) UnmarshalBinary

func (p *PrivateData) UnmarshalBinary(data []byte) error

func (*PrivateData) UnmarshalJSON

func (b *PrivateData) UnmarshalJSON(data []byte) error

type TermsOfUse

type TermsOfUse struct {
	TextEncoding byte
	Language     string
	Text         string
}

TermsOfUse have the ID USER

func (*TermsOfUse) Equal

func (t *TermsOfUse) Equal(t2 *TermsOfUse) bool

func (*TermsOfUse) MarshalBinary

func (t *TermsOfUse) MarshalBinary() ([]byte, error)

func (*TermsOfUse) String

func (t *TermsOfUse) String() string

func (*TermsOfUse) UnmarshalBinary

func (t *TermsOfUse) UnmarshalBinary(data []byte) error

type TextInformation

type TextInformation struct {
	TextEncoding byte `json:"-"`
	Information  []rune
}

TextInformation are all of the text frames. Text frames have IDs of T000-TZZZ excluding TXXX.

func NewTextInformation

func NewTextInformation(info string) *TextInformation

func (*TextInformation) Equal

func (t *TextInformation) Equal(t2 *TextInformation) bool

func (*TextInformation) MarshalBinary

func (t *TextInformation) MarshalBinary() ([]byte, error)

func (*TextInformation) String

func (t *TextInformation) String() string

func (*TextInformation) UnmarshalBinary

func (t *TextInformation) UnmarshalBinary(data []byte) error

func (*TextInformation) UnmarshalJSON

func (t *TextInformation) UnmarshalJSON(data []byte) error

JSON comes in as utf-8...

type UnsynchronizedLyrics

type UnsynchronizedLyrics struct {
	TextEncoding      byte
	Language          string
	ContentDescriptor []rune
	Lyrics            string
}

UnsynchronizedLyrics have an ID of USLT.

func (*UnsynchronizedLyrics) Equal

func (*UnsynchronizedLyrics) MarshalBinary

func (u *UnsynchronizedLyrics) MarshalBinary() ([]byte, error)

func (*UnsynchronizedLyrics) String

func (u *UnsynchronizedLyrics) String() string

func (*UnsynchronizedLyrics) UnmarshalBinary

func (u *UnsynchronizedLyrics) UnmarshalBinary(data []byte) error

type UserDefinedTextInformation

type UserDefinedTextInformation struct {
	TextEncoding byte
	Description  []rune
	Value        []rune
}

UserDefinedTextInformation

func (*UserDefinedTextInformation) Equal

func (*UserDefinedTextInformation) MarshalBinary

func (u *UserDefinedTextInformation) MarshalBinary() ([]byte, error)

func (*UserDefinedTextInformation) String

func (u *UserDefinedTextInformation) String() string

func (*UserDefinedTextInformation) UnmarshalBinary

func (u *UserDefinedTextInformation) UnmarshalBinary(data []byte) error

func (*UserDefinedTextInformation) UnmarshalJSON

func (u *UserDefinedTextInformation) UnmarshalJSON(data []byte) error

type UserDefinedURL

type UserDefinedURL struct {
	TextEncoding byte
	Description  []rune
	// URL is always ascii
	URL string
}

UserDefinedURL have the identifier WXXX.

func (*UserDefinedURL) Equal

func (u *UserDefinedURL) Equal(u2 *UserDefinedURL) bool

func (*UserDefinedURL) MarshalBinary

func (u *UserDefinedURL) MarshalBinary() ([]byte, error)

func (*UserDefinedURL) String

func (u *UserDefinedURL) String() string

func (*UserDefinedURL) UnmarshalBinary

func (u *UserDefinedURL) UnmarshalBinary(data []byte) error

func (*UserDefinedURL) UnmarshalJSON

func (u *UserDefinedURL) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL