Skip to content

Commit

Permalink
support SDPs without leading version (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
langhuihui authored and aler9 committed Oct 23, 2023
1 parent 7632ae5 commit 6450ff6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/sdp/sdp.go
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,11 @@ func (s *SessionDescription) Unmarshal(byts []byte) error {
state = stateSession

default:
return fmt.Errorf("invalid key: %c (%s)", key, line)
state = stateSession
err := s.unmarshalSession(&state, key, val)
if err != nil {
return err
}
}

case stateSession:
Expand Down
30 changes: 30 additions & 0 deletions pkg/sdp/sdp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2525,6 +2525,36 @@ var cases = []struct {
},
},
},
{
"issue gortsplib/448",
[]byte("m=video 0 RTP/AVP 96\r\n" +
"a=rtpmap:96 H264/90000\r\n" +
"a=control:trackID=0\r\n"),
[]byte("v=0\r\n" +
"o= 0 0 \r\n" +
"m=video 0 RTP/AVP 96\r\n" +
"a=rtpmap:96 H264/90000\r\n" +
"a=control:trackID=0\r\n"),
SessionDescription{
MediaDescriptions: []*psdp.MediaDescription{{
MediaName: psdp.MediaName{
Media: "video",
Protos: []string{"RTP", "AVP"},
Formats: []string{"96"},
},
Attributes: []psdp.Attribute{
{
Key: "rtpmap",
Value: "96 H264/90000",
},
{
Key: "control",
Value: "trackID=0",
},
},
}},
},
},
}

func TestUnmarshal(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/sdp/testdata/fuzz/FuzzUnmarshal/2fe9aff6f8340ce4
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
go test fuzz v1
string("0=")

0 comments on commit 6450ff6

Please sign in to comment.