Split format description into encoder/decoder ones
This commit is contained in:
parent
f28e82b5aa
commit
0da1f28874
|
@ -26,10 +26,14 @@ func (f Format) Name() string {
|
|||
return "aac"
|
||||
}
|
||||
|
||||
func (f Format) Description() string {
|
||||
func (f Format) DecoderDescription() string {
|
||||
return fmt.Sprintf("libfdk-aac %s (S.O.N.G/go-fdkaac)", fdkaac.EncoderVersion())
|
||||
}
|
||||
|
||||
func (f Format) EncoderDescription() string {
|
||||
return f.DecoderDescription()
|
||||
}
|
||||
|
||||
func decodeFrame(decoder *fdkaac.AacDecoder, r io.Reader) ([]int16, error) {
|
||||
pcm, err := tryDecodeFrame(decoder)
|
||||
if err != nil {
|
||||
|
|
|
@ -20,7 +20,7 @@ func (f Format) Name() string {
|
|||
return "aac"
|
||||
}
|
||||
|
||||
func (f Format) Description() string {
|
||||
func (f Format) EncoderDescription() string {
|
||||
return "vo-aacenc (gen2brain/aac-go)"
|
||||
}
|
||||
|
||||
|
|
|
@ -24,10 +24,14 @@ func (f Format) Name() string {
|
|||
return "alac"
|
||||
}
|
||||
|
||||
func (f Format) Description() string {
|
||||
func (f Format) DecoderDescription() string {
|
||||
return "libalac (S.O.N.G/go-alac)"
|
||||
}
|
||||
|
||||
func (f Format) EncoderDescription() string {
|
||||
return f.DecoderDescription()
|
||||
}
|
||||
|
||||
func (f Format) Open(r io.ReadSeekCloser) (audio.Source, error) {
|
||||
mp4Demuxer, err := tryDecodeMP4(r)
|
||||
if err != nil {
|
||||
|
|
|
@ -21,7 +21,7 @@ func (f Format) Name() string {
|
|||
return "flac"
|
||||
}
|
||||
|
||||
func (f Format) Description() string {
|
||||
func (f Format) DecoderDescription() string {
|
||||
return "mewkiz/flac"
|
||||
}
|
||||
|
||||
|
|
|
@ -22,10 +22,14 @@ func (f Format) Name() string {
|
|||
return "flac"
|
||||
}
|
||||
|
||||
func (f Format) Description() string {
|
||||
func (f Format) DecoderDescription() string {
|
||||
return fmt.Sprintf("%s (S.O.N.G/goflac)", libflac.Vendor())
|
||||
}
|
||||
|
||||
func (f Format) EncoderDescription() string {
|
||||
return f.DecoderDescription()
|
||||
}
|
||||
|
||||
func (f Format) Open(r io.ReadSeekCloser) (audio.Source, error) {
|
||||
currentPosition, _ := r.Seek(0, io.SeekCurrent)
|
||||
decoder, err := libflac.NewDecoderReader(r)
|
||||
|
|
|
@ -10,8 +10,6 @@ type Format interface {
|
|||
Identify(peek []byte, extension string) bool
|
||||
// Name returns the name of the codec or format
|
||||
Name() string
|
||||
// Description returns a longer description of the backing libraries or versions
|
||||
Description() string
|
||||
}
|
||||
|
||||
type WriteSeekCloser interface {
|
||||
|
@ -24,10 +22,16 @@ 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
|
||||
}
|
||||
|
|
|
@ -17,7 +17,11 @@ func (f NullFormat) Name() string {
|
|||
return f.name
|
||||
}
|
||||
|
||||
func (f NullFormat) Description() string {
|
||||
func (f NullFormat) DecoderDescription() string {
|
||||
return "null"
|
||||
}
|
||||
|
||||
func (f NullFormat) EncoderDescription() string {
|
||||
return "null"
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,10 @@ func (f Format) Name() string {
|
|||
return "mp3"
|
||||
}
|
||||
|
||||
func (f Format) DecoderDescription() string {
|
||||
return "kvark128/minimp3"
|
||||
}
|
||||
|
||||
func (f Format) Open(r io.ReadSeekCloser) (audio.Source, error) {
|
||||
decoder := mp3Lib.NewDecoder(r)
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@ import (
|
|||
"unsafe"
|
||||
)
|
||||
|
||||
func (f Format) Description() string {
|
||||
func (f Format) EncoderDescription() string {
|
||||
//TODO: move version fetch to viert/go-lame
|
||||
return fmt.Sprintf("kvark128/minimp3, LAME %s (viert/go-lame)", C.GoString(C.get_lame_version()))
|
||||
return fmt.Sprintf("LAME %s (viert/go-lame)", C.GoString(C.get_lame_version()))
|
||||
}
|
||||
|
||||
func (f Format) Encode(source audio.Source, writer io.WriteCloser, options map[string]interface{}) error {
|
||||
|
|
|
@ -22,7 +22,8 @@ func NewFormat() Format {
|
|||
func (f Format) Name() string {
|
||||
return "mp3"
|
||||
}
|
||||
func (f Format) Description() string {
|
||||
|
||||
func (f Format) DecoderDescription() string {
|
||||
return "hajimehoshi/go-mp3"
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
//go:build !disable_format_mp3 && disable_codec_lame && cgo
|
||||
|
||||
package mp3
|
||||
|
||||
func (f Format) Description() string {
|
||||
return "kvark128/minimp3"
|
||||
}
|
|
@ -25,10 +25,14 @@ func (f Format) Name() string {
|
|||
return "opus"
|
||||
}
|
||||
|
||||
func (f Format) Description() string {
|
||||
func (f Format) DecoderDescription() string {
|
||||
return fmt.Sprintf("%s (S.O.N.G/go-pus)", libopus.Version())
|
||||
}
|
||||
|
||||
func (f Format) EncoderDescription() string {
|
||||
return f.DecoderDescription()
|
||||
}
|
||||
|
||||
func (f Format) Open(r io.ReadSeekCloser) (audio.Source, error) {
|
||||
stream, err := libopus.NewStream(r)
|
||||
if err != nil {
|
||||
|
|
|
@ -23,10 +23,14 @@ func (f Format) Name() string {
|
|||
return "tta"
|
||||
}
|
||||
|
||||
func (f Format) Description() string {
|
||||
func (f Format) DecoderDescription() string {
|
||||
return "S.O.N.G/go-tta"
|
||||
}
|
||||
|
||||
func (f Format) EncoderDescription() string {
|
||||
return f.DecoderDescription()
|
||||
}
|
||||
|
||||
func NewFormat() Format {
|
||||
return Format{}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ func (f Format) Name() string {
|
|||
return "vorbis"
|
||||
}
|
||||
|
||||
func (f Format) Description() string {
|
||||
func (f Format) DecoderDescription() string {
|
||||
return "jfreymuth/oggvorvis"
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue