diff --git a/codec/codecutil/helpers.go b/codec/codecutil/helpers.go new file mode 100644 index 00000000..770d3790 --- /dev/null +++ b/codec/codecutil/helpers.go @@ -0,0 +1,51 @@ +/* +DESCRIPTIONS + helpers.go provides general codec related helper functions. + +AUTHORS + Saxon A. Nelson-Milton + +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") + } +}