Kirika/audio/format/format.go

40 lines
1.1 KiB
Go

package format
import (
"git.gammaspectra.live/S.O.N.G/Kirika/audio"
"io"
)
const IdentifyPeekBytes = 16
type Format interface {
// Identify checks whether a format is of a type. peek includes a few first bytes, extension is the lowercase file extension without a dot.
Identify(peek [IdentifyPeekBytes]byte, extension string) bool
// Name returns the name of the codec or format
Name() string
}
type WriteSeekCloser interface {
io.Writer
io.Closer
io.Seeker
}
type Decoder interface {
Format
// Open a stream and decodes it into an audio.Source
Open(r io.ReadSeekCloser) (audio.Source, error)
// DecoderDescription returns a longer description of the backing libraries or versions
DecoderDescription() string
}
type Encoder interface {
Format
// Encode Receives an audio.Source and encodes it into a writer. Some formats can do special operations if writer is also an io.Seeker
Encode(source audio.Source, writer io.WriteCloser, options map[string]interface{}) error
// EncoderDescription returns a longer description of the backing libraries or versions
EncoderDescription() string
}