mirror of
https://github.com/aler9/gortsplib
synced 2025-10-16 04:00:46 +08:00
fix parsing of H264 tracks with empty sprop-parameter-sets
This commit is contained in:
@@ -443,6 +443,30 @@ func TestNewFromMediaDescription(t *testing.T) {
|
|||||||
PacketizationMode: 1,
|
PacketizationMode: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"h264 empty sprop-parameter-sets",
|
||||||
|
&psdp.MediaDescription{
|
||||||
|
MediaName: psdp.MediaName{
|
||||||
|
Media: "video",
|
||||||
|
Protos: []string{"RTP", "AVP"},
|
||||||
|
Formats: []string{"96"},
|
||||||
|
},
|
||||||
|
Attributes: []psdp.Attribute{
|
||||||
|
{
|
||||||
|
Key: "rtpmap",
|
||||||
|
Value: "96 H264/90000",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Key: "fmtp",
|
||||||
|
Value: "96 packetization-mode=1; sprop-parameter-sets=",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
&H264{
|
||||||
|
PayloadTyp: 96,
|
||||||
|
PacketizationMode: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"video h265",
|
"video h265",
|
||||||
&psdp.MediaDescription{
|
&psdp.MediaDescription{
|
||||||
|
@@ -117,23 +117,21 @@ func (t *H264) unmarshal(payloadType uint8, clock string, codec string, rtpmap s
|
|||||||
switch tmp[0] {
|
switch tmp[0] {
|
||||||
case "sprop-parameter-sets":
|
case "sprop-parameter-sets":
|
||||||
tmp := strings.Split(tmp[1], ",")
|
tmp := strings.Split(tmp[1], ",")
|
||||||
if len(tmp) < 2 {
|
if len(tmp) >= 2 {
|
||||||
return fmt.Errorf("invalid sprop-parameter-sets (%v)", fmtp)
|
sps, err := base64.StdEncoding.DecodeString(tmp[0])
|
||||||
}
|
if err != nil {
|
||||||
|
return fmt.Errorf("invalid sprop-parameter-sets (%v)", fmtp)
|
||||||
|
}
|
||||||
|
|
||||||
sps, err := base64.StdEncoding.DecodeString(tmp[0])
|
pps, err := base64.StdEncoding.DecodeString(tmp[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("invalid sprop-parameter-sets (%v)", fmtp)
|
return fmt.Errorf("invalid sprop-parameter-sets (%v)", fmtp)
|
||||||
}
|
}
|
||||||
|
|
||||||
pps, err := base64.StdEncoding.DecodeString(tmp[1])
|
t.SPS = sps
|
||||||
if err != nil {
|
t.PPS = pps
|
||||||
return fmt.Errorf("invalid sprop-parameter-sets (%v)", fmtp)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
t.SPS = sps
|
|
||||||
t.PPS = pps
|
|
||||||
|
|
||||||
case "packetization-mode":
|
case "packetization-mode":
|
||||||
tmp, err := strconv.ParseInt(tmp[1], 10, 64)
|
tmp, err := strconv.ParseInt(tmp[1], 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user