av/container/mts/pes/helpers.go

58 lines
1.5 KiB
Go
Raw Normal View History

/*
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 pes
import "errors"
// Stream types AKA stream IDs as per ITU-T Rec. H.222.0 / ISO/IEC 13818-1 [1], tables 2-22 and 2-34.
const (
H264SID = 27
H265SID = 36
MJPEGSID = 136
JPEGSID = 137
2020-12-22 05:35:11 +03:00
PCMSID = 192
ADPCMSID = 193
)
// 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 JPEGSID:
return "image/jpeg", nil
2020-12-21 13:25:14 +03:00
case PCMSID:
return "audio/pcm", nil
case ADPCMSID:
return "audio/adpcm", nil
default:
2020-12-21 13:25:14 +03:00
return "", errors.New("unknown stream ID")
}
}