av/codec/codecutil/helpers.go

52 lines
1.3 KiB
Go

/*
DESCRIPTIONS
helpers.go provides general codec related helper functions.
AUTHORS
Saxon A. Nelson-Milton <saxon@ausocean.org>
LICENSE
Copyright (C) 2019 the Australian Ocean Lab (AusOcean).
It is free software: you can redistribute it and/or modify them
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
It is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
in gpl.txt. If not, see http://www.gnu.org/licenses.
*/
package codecutil
import "errors"
// Stream types
const (
H264SID = 27
H265SID = 36
MJPEGSID = 28
ADPCMSID = 192
)
// SIDToMIMEType will return the corresponding MIME type for passed stream ID.
func SIDToMIMEType(id int) (string, error) {
switch id {
case H264SID:
return "video/h264", nil
case H265SID:
return "video/h265", nil
case MJPEGSID:
return "video/x-motion-jpeg", nil
case ADPCMSID:
return "audio/adpcm", nil
default:
return "", errors.New("unkown stream ID")
}
}