Documentation
¶
Overview ¶
Package audioprobe reads what an audio file's container says about it, a few kilobytes at a time: which container it really is, whatever its extension says, and whether its audio is locked to a store's player. The server's own probe names the codec, and a FairPlay book from the iTunes store reads there as plain AAC: the lock shows only in the container, as the sample description "drms" where a playable file says "mp4a".
It never decodes anything and needs no ffmpeg. A file is read through a Fetch, which the caller points at the server's file route with byte ranges, so a long book costs its header and, when the header sits at the end, a few more small reads.
Index ¶
Constants ¶
const ( MP4 = "mp4" // MPEG-4 / QuickTime: m4a, m4b, mp4, aax MP3 = "mp3" // MPEG audio, with or without an ID3 tag in front AAC = "aac" // raw AAC in ADTS frames FLAC = "flac" // FLAC Ogg = "ogg" // Ogg: Vorbis, Opus, or FLAC in Ogg WAV = "wav" // RIFF WAVE ASF = "asf" // Windows Media: wma MKV = "mkv" // Matroska / WebM AIFF = "aiff" // AIFF CAF = "caf" // Apple Core Audio Format )
Containers, as Report names them.
Variables ¶
var ErrMalformed = errors.New("the file cannot be read as audio")
ErrMalformed is what every error the file itself causes wraps: a header that makes no sense, or one this reading cannot follow. Any other error is the read failing, which says nothing of the file.
var ErrTooScattered = fmt.Errorf("%w: its header is scattered past what a readable file needs", ErrMalformed)
ErrTooScattered is returned when a file's header needs more reads than a sane one does.
Functions ¶
This section is empty.
Types ¶
type Fetch ¶
Fetch reads up to n bytes of a file from off, and says how long the whole file is. Fewer bytes come back only at the end of the file.
type Report ¶
type Report struct {
// Container is what the file holds, read from its first bytes; "" when
// they match nothing known.
Container string
// Locked says how the audio is locked, and is "" for audio any player
// can play: "Apple FairPlay (drms)".
Locked string
// Size is the file's length in bytes, and Want what its container says
// it should be when that is more: a download or a copy that broke off.
// Want is 0 for a file that is whole, or whose container does not say.
Size, Want int64
}
Report is what a file's container says.