DataHoarder
883dad8b84
All checks were successful
continuous-integration/drone/push Build is passing
41 lines
792 B
Go
41 lines
792 B
Go
package main
|
|
|
|
import (
|
|
"git.gammaspectra.live/S.O.N.G/Ignite/decoder"
|
|
"io"
|
|
"slices"
|
|
)
|
|
|
|
const (
|
|
DecoderFFMPEG = "ffmpeg"
|
|
DecoderY4M = "y4m"
|
|
DecoderDav1d = "libdav1d"
|
|
)
|
|
|
|
type DecoderEntry struct {
|
|
Name string
|
|
Version func() string
|
|
MimeType string
|
|
New func(w io.Reader, settings map[string]any) (decoder.Decoder, error)
|
|
}
|
|
|
|
var Decoders []DecoderEntry
|
|
|
|
func GetDecoderByName(name string) *DecoderEntry {
|
|
if i := slices.IndexFunc(Decoders, func(entry DecoderEntry) bool {
|
|
return entry.Name == name
|
|
}); i != -1 {
|
|
return &Decoders[i]
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func GetDecoderByMimeType(mimeType string) *DecoderEntry {
|
|
if i := slices.IndexFunc(Decoders, func(entry DecoderEntry) bool {
|
|
return entry.MimeType == mimeType
|
|
}); i != -1 {
|
|
return &Decoders[i]
|
|
}
|
|
return nil
|
|
}
|