2019-09-25 05:46:18 +03:00
|
|
|
/*
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2020-12-22 05:21:20 +03:00
|
|
|
package pes
|
2019-09-25 05:46:18 +03:00
|
|
|
|
|
|
|
import "errors"
|
|
|
|
|
2020-12-22 05:21:20 +03:00
|
|
|
// Stream types AKA stream IDs as per ITU-T Rec. H.222.0 / ISO/IEC 13818-1 [1], tables 2-22 and 2-34.
|
2019-09-25 05:46:18 +03:00
|
|
|
const (
|
|
|
|
H264SID = 27
|
|
|
|
H265SID = 36
|
2021-01-18 07:59:21 +03:00
|
|
|
MJPEGSID = 136
|
2021-01-20 04:19:01 +03:00
|
|
|
JPEGSID = 137
|
2020-12-22 05:35:11 +03:00
|
|
|
PCMSID = 192
|
|
|
|
ADPCMSID = 193
|
2019-09-25 05:46:18 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
// SIDToMIMEType will return the corresponding MIME type for passed stream ID.
|
|
|
|
func SIDToMIMEType(id int) (string, error) {
|
|
|
|
switch id {
|
|
|
|
case H264SID:
|
2019-09-25 14:59:19 +03:00
|
|
|
return "video/h264", nil
|
2019-09-25 05:46:18 +03:00
|
|
|
case H265SID:
|
2019-09-25 14:59:19 +03:00
|
|
|
return "video/h265", nil
|
2019-09-25 05:46:18 +03:00
|
|
|
case MJPEGSID:
|
|
|
|
return "video/x-motion-jpeg", nil
|
2021-01-18 07:59:21 +03:00
|
|
|
case JPEGSID:
|
|
|
|
return "image/jpeg", nil
|
2020-12-21 13:25:14 +03:00
|
|
|
case PCMSID:
|
|
|
|
return "audio/pcm", nil
|
2019-09-25 14:59:19 +03:00
|
|
|
case ADPCMSID:
|
|
|
|
return "audio/adpcm", nil
|
2019-09-25 05:46:18 +03:00
|
|
|
default:
|
2020-12-21 13:25:14 +03:00
|
|
|
return "", errors.New("unknown stream ID")
|
2019-09-25 05:46:18 +03:00
|
|
|
}
|
|
|
|
}
|