Skip to content

Commit

Permalink
sdp: fix parsing SDP from UDP technology cameras (#474)
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed Dec 2, 2023
1 parent 28c4452 commit c2b446e
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/sdp/sdp.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@ func (s *SessionDescription) unmarshalMediaDescription(value string) error {
if fields[0] != "video" &&
fields[0] != "audio" &&
fields[0] != "application" &&
!strings.HasPrefix(fields[0], "application/") {
!strings.HasPrefix(fields[0], "application/") &&
fields[0] != "metadata" {
return fmt.Errorf("%w `%v`", errSDPInvalidValue, fields[0])
}
newMediaDesc.MediaName.Media = fields[0]
Expand Down
57 changes: 57 additions & 0 deletions pkg/sdp/sdp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2600,6 +2600,63 @@ var cases = []struct {
}},
},
},
{
"issue gortsplib/474",
[]byte("m=metadata 0 RTP/AVP 98\r\n" +
"c=IN IP4 0.0.0.0\r\n" +
"b=AS:1000\r\n" +
"a=rtpmap:98 METADATA/90000\r\n" +
"a=control:track2\r\n" +
"a=x-onvif-track:track2\r\n" +
"a=x-bufferdelay:1.000000\r\n"),
[]byte("v=0\r\n" +
"o= 0 0 \r\n" +
"m=metadata 0 RTP/AVP 98\r\n" +
"c=IN IP4 0.0.0.0\r\n" +
"b=AS:1000\r\n" +
"a=rtpmap:98 METADATA/90000\r\n" +
"a=control:track2\r\n" +
"a=x-onvif-track:track2\r\n" +
"a=x-bufferdelay:1.000000\r\n"),
SessionDescription{
MediaDescriptions: []*psdp.MediaDescription{{
MediaName: psdp.MediaName{
Media: "metadata",
Protos: []string{"RTP", "AVP"},
Formats: []string{"98"},
},
ConnectionInformation: &psdp.ConnectionInformation{
NetworkType: "IN",
AddressType: "IP4",
Address: &psdp.Address{
Address: "0.0.0.0",
},
},
Bandwidth: []psdp.Bandwidth{{
Type: "AS",
Bandwidth: 1000,
}},
Attributes: []psdp.Attribute{
{
Key: "rtpmap",
Value: "98 METADATA/90000",
},
{
Key: "control",
Value: "track2",
},
{
Key: "x-onvif-track",
Value: "track2",
},
{
Key: "x-bufferdelay",
Value: "1.000000",
},
},
}},
},
},
}

func TestUnmarshal(t *testing.T) {
Expand Down

0 comments on commit c2b446e

Please sign in to comment.