mirror of
https://github.com/aler9/gortsplib
synced 2025-10-06 07:37:07 +08:00
@@ -746,6 +746,35 @@ var casesFormat = []struct {
|
||||
"packetization-mode": "1",
|
||||
},
|
||||
},
|
||||
{
|
||||
"video h264 annexb",
|
||||
"video",
|
||||
96,
|
||||
"H264/90000",
|
||||
map[string]string{
|
||||
"sprop-parameter-sets": "AAAAAWdNAB6NjUBaHtCAAAOEAACvyAI=,AAAAAWjuOIA=",
|
||||
"packetization-mode": "1",
|
||||
"profile-level-id": "4DE028",
|
||||
},
|
||||
&H264{
|
||||
PayloadTyp: 96,
|
||||
SPS: []byte{
|
||||
0x67, 0x4d, 0x00, 0x1e, 0x8d, 0x8d, 0x40, 0x5a,
|
||||
0x1e, 0xd0, 0x80, 0x00, 0x03, 0x84, 0x00, 0x00,
|
||||
0xaf, 0xc8, 0x02,
|
||||
},
|
||||
PPS: []byte{
|
||||
0x68, 0xee, 0x38, 0x80,
|
||||
},
|
||||
PacketizationMode: 1,
|
||||
},
|
||||
"H264/90000",
|
||||
map[string]string{
|
||||
"packetization-mode": "1",
|
||||
"profile-level-id": "4D001E",
|
||||
"sprop-parameter-sets": "Z00AHo2NQFoe0IAAA4QAAK/IAg==,aO44gA==",
|
||||
},
|
||||
},
|
||||
{
|
||||
"video h265",
|
||||
"video",
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package format
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
@@ -33,24 +34,28 @@ func (f *H264) unmarshal(ctx *unmarshalContext) error {
|
||||
case "sprop-parameter-sets":
|
||||
tmp := strings.Split(val, ",")
|
||||
if len(tmp) >= 2 {
|
||||
sps, err := base64.StdEncoding.DecodeString(tmp[0])
|
||||
var err error
|
||||
f.SPS, err = base64.StdEncoding.DecodeString(tmp[0])
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid sprop-parameter-sets (%v)", val)
|
||||
}
|
||||
|
||||
pps, err := base64.StdEncoding.DecodeString(tmp[1])
|
||||
// some cameras ship parameters with Annex-B prefix
|
||||
f.SPS = bytes.TrimPrefix(f.SPS, []byte{0, 0, 0, 1})
|
||||
|
||||
f.PPS, err = base64.StdEncoding.DecodeString(tmp[1])
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid sprop-parameter-sets (%v)", val)
|
||||
}
|
||||
|
||||
// some cameras ship parameters with Annex-B prefix
|
||||
f.PPS = bytes.TrimPrefix(f.PPS, []byte{0, 0, 0, 1})
|
||||
|
||||
var spsp h264.SPS
|
||||
err = spsp.Unmarshal(sps)
|
||||
err = spsp.Unmarshal(f.SPS)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid SPS: %v", err)
|
||||
}
|
||||
|
||||
f.SPS = sps
|
||||
f.PPS = pps
|
||||
}
|
||||
|
||||
case "packetization-mode":
|
||||
|
@@ -37,7 +37,7 @@ func (f *H265) unmarshal(ctx *unmarshalContext) error {
|
||||
return fmt.Errorf("invalid sprop-vps (%v)", ctx.fmtp)
|
||||
}
|
||||
|
||||
// some cameras ships parameters with Annex-B prefix
|
||||
// some cameras ship parameters with Annex-B prefix
|
||||
f.VPS = bytes.TrimPrefix(f.VPS, []byte{0, 0, 0, 1})
|
||||
|
||||
case "sprop-sps":
|
||||
@@ -47,7 +47,7 @@ func (f *H265) unmarshal(ctx *unmarshalContext) error {
|
||||
return fmt.Errorf("invalid sprop-sps (%v)", ctx.fmtp)
|
||||
}
|
||||
|
||||
// some cameras ships parameters with Annex-B prefix
|
||||
// some cameras ship parameters with Annex-B prefix
|
||||
f.SPS = bytes.TrimPrefix(f.SPS, []byte{0, 0, 0, 1})
|
||||
|
||||
var spsp h265.SPS
|
||||
@@ -63,7 +63,7 @@ func (f *H265) unmarshal(ctx *unmarshalContext) error {
|
||||
return fmt.Errorf("invalid sprop-pps (%v)", ctx.fmtp)
|
||||
}
|
||||
|
||||
// some cameras ships parameters with Annex-B prefix
|
||||
// some cameras ship parameters with Annex-B prefix
|
||||
f.PPS = bytes.TrimPrefix(f.PPS, []byte{0, 0, 0, 1})
|
||||
|
||||
var ppsp h265.PPS
|
||||
|
Reference in New Issue
Block a user