move codec-related constants into formatprocessor (#3595)

This commit is contained in:
Alessandro Ros 2024-08-01 16:42:53 +02:00 committed by GitHub
parent 0230aa0a9c
commit 59ae3add7e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 72 additions and 39 deletions

View file

@ -13,6 +13,13 @@ import (
"github.com/bluenviron/mediamtx/internal/unit"
)
// AV1-related parameters
var (
AV1DefaultSequenceHeader = []byte{
8, 0, 0, 0, 66, 167, 191, 228, 96, 13, 0, 64,
}
)
type formatProcessorAV1 struct {
udpMaxPayloadSize int
format *format.AV1

View file

@ -14,6 +14,17 @@ import (
"github.com/bluenviron/mediamtx/internal/unit"
)
// H264-related parameters
var (
H264DefaultSPS = []byte{ // 1920x1080 baseline
0x67, 0x42, 0xc0, 0x28, 0xd9, 0x00, 0x78, 0x02,
0x27, 0xe5, 0x84, 0x00, 0x00, 0x03, 0x00, 0x04,
0x00, 0x00, 0x03, 0x00, 0xf0, 0x3c, 0x60, 0xc9, 0x20,
}
H264DefaultPPS = []byte{0x08, 0x06, 0x07, 0x08}
)
// extract SPS and PPS without decoding RTP packets
func rtpH264ExtractParams(payload []byte) ([]byte, []byte) {
if len(payload) < 1 {

View file

@ -14,6 +14,30 @@ import (
"github.com/bluenviron/mediamtx/internal/unit"
)
// H265-related parameters
var (
H265DefaultVPS = []byte{
0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x02, 0x20,
0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03,
0x00, 0x00, 0x03, 0x00, 0x7b, 0x18, 0xb0, 0x24,
}
H265DefaultSPS = []byte{
0x42, 0x01, 0x01, 0x02, 0x20, 0x00, 0x00, 0x03,
0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03,
0x00, 0x7b, 0xa0, 0x07, 0x82, 0x00, 0x88, 0x7d,
0xb6, 0x71, 0x8b, 0x92, 0x44, 0x80, 0x53, 0x88,
0x88, 0x92, 0xcf, 0x24, 0xa6, 0x92, 0x72, 0xc9,
0x12, 0x49, 0x22, 0xdc, 0x91, 0xaa, 0x48, 0xfc,
0xa2, 0x23, 0xff, 0x00, 0x01, 0x00, 0x01, 0x6a,
0x02, 0x02, 0x02, 0x01,
}
H265DefaultPPS = []byte{
0x44, 0x01, 0xc0, 0x25, 0x2f, 0x05, 0x32, 0x40,
}
)
// extract VPS, SPS and PPS without decoding RTP packets
func rtpH265ExtractParams(payload []byte) ([]byte, []byte, []byte) {
if len(payload) < 2 {

View file

@ -13,6 +13,15 @@ import (
"github.com/bluenviron/mediamtx/internal/unit"
)
// MPEG-1 video related parameters
var (
MPEG1VideoDefaultConfig = []byte{
0x00, 0x00, 0x01, 0xb3, 0x78, 0x04, 0x38, 0x35,
0xff, 0xff, 0xe0, 0x18, 0x00, 0x00, 0x01, 0xb5,
0x14, 0x4a, 0x00, 0x01, 0x00, 0x00,
}
)
type formatProcessorMPEG1Video struct {
udpMaxPayloadSize int
format *format.MPEG1Video

View file

@ -15,6 +15,18 @@ import (
"github.com/bluenviron/mediamtx/internal/unit"
)
// MPEG-4 video related parameters
var (
MPEG4VideoDefaultConfig = []byte{
0x00, 0x00, 0x01, 0xb0, 0x01, 0x00, 0x00, 0x01,
0xb5, 0x89, 0x13, 0x00, 0x00, 0x01, 0x00, 0x00,
0x00, 0x01, 0x20, 0x00, 0xc4, 0x8d, 0x88, 0x00,
0xf5, 0x3c, 0x04, 0x87, 0x14, 0x63, 0x00, 0x00,
0x01, 0xb2, 0x4c, 0x61, 0x76, 0x63, 0x35, 0x38,
0x2e, 0x31, 0x33, 0x34, 0x2e, 0x31, 0x30, 0x30,
}
)
type formatProcessorMPEG4Video struct {
udpMaxPayloadSize int
format *format.MPEG4Video