mirror of
https://github.com/pion/mediadevices.git
synced 2025-09-27 12:52:20 +08:00

Since DecoderFunc is not being used as a public API, there's no need to increase the API surface area.
27 lines
412 B
Go
27 lines
412 B
Go
package frame
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
func NewDecoder(f Format) (Decoder, error) {
|
|
var decoder decoderFunc
|
|
|
|
switch f {
|
|
case FormatI420:
|
|
decoder = decodeI420
|
|
case FormatNV21:
|
|
decoder = decodeNV21
|
|
case FormatYUY2:
|
|
decoder = decodeYUY2
|
|
case FormatUYVY:
|
|
decoder = decodeUYVY
|
|
case FormatMJPEG:
|
|
decoder = decodeMJPEG
|
|
default:
|
|
return nil, fmt.Errorf("%s is not supported", f)
|
|
}
|
|
|
|
return decoder, nil
|
|
}
|