check SPS/PPS of H264/H265 SDPs (#394)

This commit is contained in:
Alessandro Ros
2023-09-01 18:31:52 +02:00
committed by GitHub
parent 2ea1bf97dd
commit 8f18a0d83b
4 changed files with 32 additions and 7 deletions

View File

@@ -26,9 +26,16 @@ import (
var testH264Media = &description.Media{
Type: description.MediaTypeVideo,
Formats: []format.Format{&format.H264{
PayloadTyp: 96,
SPS: []byte{0x01, 0x02, 0x03, 0x04},
PPS: []byte{0x01, 0x02, 0x03, 0x04},
PayloadTyp: 96,
SPS: []byte{
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,
},
PPS: []byte{
0x44, 0x01, 0xc0, 0x25, 0x2f, 0x05, 0x32, 0x40,
},
PacketizationMode: 1,
}},
}

View File

@@ -43,6 +43,12 @@ func (f *H264) unmarshal(ctx *unmarshalContext) error {
return fmt.Errorf("invalid sprop-parameter-sets (%v)", val)
}
var spsp h264.SPS
err = spsp.Unmarshal(sps)
if err != nil {
return fmt.Errorf("invalid SPS: %v", err)
}
f.SPS = sps
f.PPS = pps
}

View File

@@ -43,6 +43,12 @@ func (f *H265) unmarshal(ctx *unmarshalContext) error {
return fmt.Errorf("invalid sprop-sps (%v)", ctx.fmtp)
}
var spsp h265.SPS
err = spsp.Unmarshal(f.SPS)
if err != nil {
return fmt.Errorf("invalid SPS: %v", err)
}
case "sprop-pps":
var err error
f.PPS, err = base64.StdEncoding.DecodeString(val)
@@ -50,6 +56,12 @@ func (f *H265) unmarshal(ctx *unmarshalContext) error {
return fmt.Errorf("invalid sprop-pps (%v)", ctx.fmtp)
}
var ppsp h265.PPS
err = ppsp.Unmarshal(f.PPS)
if err != nil {
return fmt.Errorf("invalid PPS: %v", err)
}
case "sprop-max-don-diff":
tmp, err := strconv.ParseUint(val, 10, 31)
if err != nil {

View File

@@ -586,8 +586,8 @@ func TestServerRecord(t *testing.T) {
Type: description.MediaTypeVideo,
Formats: []format.Format{&format.H264{
PayloadTyp: 96,
SPS: []byte{0x01, 0x02, 0x03, 0x04},
PPS: []byte{0x01, 0x02, 0x03, 0x04},
SPS: testH264Media.Formats[0].(*format.H264).SPS,
PPS: testH264Media.Formats[0].(*format.H264).PPS,
PacketizationMode: 1,
}},
},
@@ -595,8 +595,8 @@ func TestServerRecord(t *testing.T) {
Type: description.MediaTypeVideo,
Formats: []format.Format{&format.H264{
PayloadTyp: 96,
SPS: []byte{0x01, 0x02, 0x03, 0x04},
PPS: []byte{0x01, 0x02, 0x03, 0x04},
SPS: testH264Media.Formats[0].(*format.H264).SPS,
PPS: testH264Media.Formats[0].(*format.H264).PPS,
PacketizationMode: 1,
}},
},