diff --git a/pkg/format/format.go b/pkg/format/format.go index ac5fa2fc..c88a3cf6 100644 --- a/pkg/format/format.go +++ b/pkg/format/format.go @@ -54,6 +54,16 @@ type Format interface { // Unmarshal decodes a format from a media description. func Unmarshal(md *psdp.MediaDescription, payloadTypeStr string) (Format, error) { + if payloadTypeStr == "smart/1/90000" { + attr, ok := md.Attribute("rtpmap") + if ok { + i := strings.Index(attr, " TP-LINK/90000") + if i >= 0 { + payloadTypeStr = attr[:i] + } + } + } + tmp, err := strconv.ParseInt(payloadTypeStr, 10, 8) if err != nil { return nil, err diff --git a/pkg/format/format_test.go b/pkg/format/format_test.go index 6039130b..455480e2 100644 --- a/pkg/format/format_test.go +++ b/pkg/format/format_test.go @@ -613,7 +613,7 @@ func TestNewFromMediaDescription(t *testing.T) { }, }, { - "generic invalid rtpmap", + "application invalid rtpmap", &psdp.MediaDescription{ MediaName: psdp.MediaName{ Media: "application", @@ -633,7 +633,7 @@ func TestNewFromMediaDescription(t *testing.T) { }, }, { - "generic invalid rtpmap 2", + "application invalid rtpmap 2", &psdp.MediaDescription{ MediaName: psdp.MediaName{ Media: "application", @@ -652,6 +652,27 @@ func TestNewFromMediaDescription(t *testing.T) { RTPMap: "custom/aaa", }, }, + { + "application tp-link", + &psdp.MediaDescription{ + MediaName: psdp.MediaName{ + Media: "application", + Protos: []string{"RTP", "AVP"}, + Formats: []string{"smart/1/90000"}, + }, + Attributes: []psdp.Attribute{ + { + Key: "rtpmap", + Value: "95 TP-LINK/90000", + }, + }, + }, + &Generic{ + PayloadTyp: 95, + RTPMap: "TP-LINK/90000", + ClockRat: 90000, + }, + }, } { t.Run(ca.name, func(t *testing.T) { format, err := Unmarshal(ca.md, ca.md.MediaName.Formats[0])