Documentation
¶
Index ¶
- Constants
- Variables
- func GetFileType(filepath string) (*string, error)
- func ReadAtoms(r io.ReadSeeker) (metadataMP4, error)
- func ReadFromMP4(r io.ReadSeeker) (metadataMP4, error)
- func SaveTag(tag *IDTag) error
- type ErrBadCrc
- type IDTag
- func (tag *IDTag) AdditionalTags() map[string]string
- func (tag *IDTag) Album() string
- func (tag *IDTag) AlbumArt() *image.Image
- func (tag *IDTag) AlbumArtist() string
- func (tag *IDTag) Artist() string
- func (tag *IDTag) BPM() string
- func (tag *IDTag) ClearAllAdditionalTags()
- func (tag *IDTag) ClearAllTags(preserveUnknown ...bool)
- func (tag *IDTag) Comments() string
- func (tag *IDTag) Composer() string
- func (tag *IDTag) CopyrightMsg() string
- func (tag *IDTag) Date() string
- func (tag *IDTag) EncodedBy() string
- func (tag *IDTag) FileType() string
- func (tag *IDTag) Genre() string
- func (tag *IDTag) Language() string
- func (tag *IDTag) Length() string
- func (tag *IDTag) Lyricist() string
- func (tag *IDTag) PartOfSet() string
- func (tag *IDTag) Publisher() string
- func (tag *IDTag) Save() error
- func (tag *IDTag) SetAdditionalTag(id string, value string)
- func (tag *IDTag) SetAlbum(album string)
- func (tag *IDTag) SetAlbumArtFromByteArray(albumArt []byte) error
- func (tag *IDTag) SetAlbumArtFromFilePath(filePath string) error
- func (tag *IDTag) SetAlbumArtFromImage(albumArt *image.Image)
- func (tag *IDTag) SetAlbumArtist(albumArtist string)
- func (tag *IDTag) SetAllAdditionalTags(set map[string]string)
- func (tag *IDTag) SetArtist(artist string)
- func (tag *IDTag) SetBPM(bpm string)
- func (tag *IDTag) SetComments(comments string)
- func (tag *IDTag) SetComposer(composer string)
- func (tag *IDTag) SetCopyrightMsg(copyrightMsg string)
- func (tag *IDTag) SetDate(date string)
- func (tag *IDTag) SetEncodedBy(encodedBy string)
- func (tag *IDTag) SetFileType(fileType string)
- func (tag *IDTag) SetGenre(genre string)
- func (tag *IDTag) SetLanguage(language string)
- func (tag *IDTag) SetLength(length string)
- func (tag *IDTag) SetLyricist(lyricist string)
- func (tag *IDTag) SetPartOfSet(partOfSet string)
- func (tag *IDTag) SetPublisher(publisher string)
- func (tag *IDTag) SetTitle(title string)
- func (tag *IDTag) SetYear(year string)
- func (tag *IDTag) Title() string
- func (tag *IDTag) Year() string
- type IDTagExtended
- type OGGDecoder
- type OGGEncoder
- type OGGPage
- type Picture
Constants ¶
const ( // Continuation of packet COP byte = 1 << iota // Beginning of stream BOS = 1 << iota // End of stream EOS = 1 << iota )
const MIMEType = "application/ogg"
The MIME type as defined in RFC 3534.
Variables ¶
var ErrBadSegs = errors.New("invalid segment table size")
ErrBadSegs error is thrown when an attempt is made to decode a page with a segment table size less than 1.
Functions ¶
func GetFileType ¶ added in v1.2.3
func ReadAtoms ¶
func ReadAtoms(r io.ReadSeeker) (metadataMP4, error)
ReadAtoms reads MP4 metadata atoms from the io.ReadSeeker into a Metadata, returning non-nil error if there was a problem.
func ReadFromMP4 ¶
func ReadFromMP4(r io.ReadSeeker) (metadataMP4, error)
Types ¶
type ErrBadCrc ¶ added in v1.2.0
ErrBadCrc error occurs when the CRC field in an ogg page doesn't match the CRC calculated by the Decoder.
type IDTag ¶
type IDTag struct {
// contains filtered or unexported fields
}
The IDTag represents all of the metadata that can be retrieved from a file. The IDTag contains all tags for both mp3 and mp4. Some tags may not be applicable to all types. Only the valid types are written to the respective data files. Although a tag may be set, if the function to write that tag attribute doesn't exist, the tag attribute will be ignored and the save function will not produce an error.
func OpenTag ¶
Opens the ID tag for the corresponding file as long as it is a supported filetype Use the OpenTag command and you will be able to access all metadata associated with the file
func ReadOGGTags ¶ added in v1.2.0
ReadOGGTags reads OGG metadata from the io.ReadSeeker, returning the resulting metadata in a Metadata implementation, or non-nil error if there was a problem.
func (*IDTag) AdditionalTags ¶ added in v1.2.1
Get all additional (unmapped) tags
func (*IDTag) ClearAllAdditionalTags ¶ added in v1.2.1
func (tag *IDTag) ClearAllAdditionalTags()
func (*IDTag) ClearAllTags ¶
clears all tags except the fileUrl tag which is used to reference the file, takes an optional parameter "preserveUnkown": when this is true passThroughMap is not cleared and unknown tags are preserved
func (*IDTag) CopyrightMsg ¶
Get the Copyright Messgae for a tag
func (*IDTag) Save ¶
This operation saves the corresponding IDTag to the mp3/mp4 file that it references and returns an error if the saving process fails
func (*IDTag) SetAdditionalTag ¶ added in v1.2.1
Set an additional (unmapped) tag
func (*IDTag) SetAlbumArtFromByteArray ¶
Set the album art by passing a byte array for the album art
func (*IDTag) SetAlbumArtFromFilePath ¶
Set the album art by passing a filepath as a string
func (*IDTag) SetAlbumArtFromImage ¶
Set the album art by passing an *image.Image as the album art
func (*IDTag) SetAlbumArtist ¶
Set teh album artist for a tag
func (*IDTag) SetAllAdditionalTags ¶ added in v1.2.1
Set a map for all additional tags
func (*IDTag) SetComments ¶
Set the comments for a tag
func (*IDTag) SetComposer ¶
Set the composer for a tag
func (*IDTag) SetCopyrightMsg ¶
Set the Copyright Message for a tag
func (*IDTag) SetEncodedBy ¶
Set who encoded the tag
func (*IDTag) SetFileType ¶
Set the filtype of the tag
func (*IDTag) SetLanguage ¶
Set the lanuguage of the tag
func (*IDTag) SetLyricist ¶
Set the lyricist for the tag
func (*IDTag) SetPartOfSet ¶
Set if the tag is part of a set
func (*IDTag) SetPublisher ¶
Set publihser for the tag
type IDTagExtended ¶ added in v1.2.1
type IDTagExtended struct {
// contains filtered or unexported fields
}
type OGGDecoder ¶ added in v1.2.0
type OGGDecoder struct {
// contains filtered or unexported fields
}
OGGDecoder is a structure that facilitates the page-by-page decoding of an ogg stream.
func NewOGGDecoder ¶ added in v1.2.0
func NewOGGDecoder(r io.Reader) *OGGDecoder
NewOGGDecoder is a constructor that initializes an ogg Decoder.
func (*OGGDecoder) DecodeOGG ¶ added in v1.2.0
func (d *OGGDecoder) DecodeOGG() (OGGPage, error)
/ Decode reads from the Reader of the Decoder until the next ogg page is found, then decodes and returns the Page or an error. An io.EOF error can be returned if that's what the Reader returns.
The memory for the returned Page's Packets' bytes is managed by the Decoder. It can be overwritten by subsequent calls to Decode.
It's safe to call Decode concurrently on different Decoders, provided their Readers are distinct. Otherwise, the outcome is not defined.
type OGGEncoder ¶ added in v1.2.0
type OGGEncoder struct {
// contains filtered or unexported fields
}
Encoder converts raw bytes into an ogg stream.
func NewOGGEncoder ¶ added in v1.2.0
func NewOGGEncoder(id uint32, w io.Writer) *OGGEncoder
NewEncoder initializes an ogg encoder with a given serial ID. When using multiple Encoders for multiplexed logical streams, ensure unique IDs. Encode streams as per ogg RFC for Grouping and Chaining.
func (*OGGEncoder) Encode ¶ added in v1.2.0
func (w *OGGEncoder) Encode(granule int64, packets [][]byte) error
Encode writes a data packet to the ogg stream with a given granule position. Large packets are split across multiple pages with continuation-of-packet flag set. Packets can be empty or nil, resulting in a single segment of size 0.
func (*OGGEncoder) EncodeBOS ¶ added in v1.2.0
func (w *OGGEncoder) EncodeBOS(granule int64, packets [][]byte) error
EncodeBOS writes a beginning-of-stream packet to the ogg stream with a given granule position. Large packets are split across multiple pages with continuation-of-packet flag set. Packets can be empty or nil, resulting in a single segment of size 0.
type OGGPage ¶ added in v1.2.0
type OGGPage struct {
// Type is a bitmask of COP, BOS, and/or EOS.
Type byte
// Serial represents the bitstream serial number.
Serial uint32
// Granule represents the granule position, its interpretation depends on the encapsulated codec.
Granule int64
// Packets are the actual packet data.
// If Type & COP != 0, the first element is
// a continuation of the previous page's last packet.
Packets [][]byte
}
Page struct represents a logical unit of an ogg page.