mirror of
https://github.com/aler9/gortsplib
synced 2025-10-05 07:06:58 +08:00
check SPS/PPS of H264/H265 SDPs (#394)
This commit is contained in:
@@ -26,9 +26,16 @@ import (
|
|||||||
var testH264Media = &description.Media{
|
var testH264Media = &description.Media{
|
||||||
Type: description.MediaTypeVideo,
|
Type: description.MediaTypeVideo,
|
||||||
Formats: []format.Format{&format.H264{
|
Formats: []format.Format{&format.H264{
|
||||||
PayloadTyp: 96,
|
PayloadTyp: 96,
|
||||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
SPS: []byte{
|
||||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
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,
|
PacketizationMode: 1,
|
||||||
}},
|
}},
|
||||||
}
|
}
|
||||||
|
@@ -43,6 +43,12 @@ func (f *H264) unmarshal(ctx *unmarshalContext) error {
|
|||||||
return fmt.Errorf("invalid sprop-parameter-sets (%v)", val)
|
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.SPS = sps
|
||||||
f.PPS = pps
|
f.PPS = pps
|
||||||
}
|
}
|
||||||
|
@@ -43,6 +43,12 @@ func (f *H265) unmarshal(ctx *unmarshalContext) error {
|
|||||||
return fmt.Errorf("invalid sprop-sps (%v)", ctx.fmtp)
|
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":
|
case "sprop-pps":
|
||||||
var err error
|
var err error
|
||||||
f.PPS, err = base64.StdEncoding.DecodeString(val)
|
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)
|
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":
|
case "sprop-max-don-diff":
|
||||||
tmp, err := strconv.ParseUint(val, 10, 31)
|
tmp, err := strconv.ParseUint(val, 10, 31)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -586,8 +586,8 @@ func TestServerRecord(t *testing.T) {
|
|||||||
Type: description.MediaTypeVideo,
|
Type: description.MediaTypeVideo,
|
||||||
Formats: []format.Format{&format.H264{
|
Formats: []format.Format{&format.H264{
|
||||||
PayloadTyp: 96,
|
PayloadTyp: 96,
|
||||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
SPS: testH264Media.Formats[0].(*format.H264).SPS,
|
||||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
PPS: testH264Media.Formats[0].(*format.H264).PPS,
|
||||||
PacketizationMode: 1,
|
PacketizationMode: 1,
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
@@ -595,8 +595,8 @@ func TestServerRecord(t *testing.T) {
|
|||||||
Type: description.MediaTypeVideo,
|
Type: description.MediaTypeVideo,
|
||||||
Formats: []format.Format{&format.H264{
|
Formats: []format.Format{&format.H264{
|
||||||
PayloadTyp: 96,
|
PayloadTyp: 96,
|
||||||
SPS: []byte{0x01, 0x02, 0x03, 0x04},
|
SPS: testH264Media.Formats[0].(*format.H264).SPS,
|
||||||
PPS: []byte{0x01, 0x02, 0x03, 0x04},
|
PPS: testH264Media.Formats[0].(*format.H264).PPS,
|
||||||
PacketizationMode: 1,
|
PacketizationMode: 1,
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user