Skip to content

Commit

Permalink
Fix fmtp parsing with spaces inside
Browse files Browse the repository at this point in the history
  • Loading branch information
Olex1313 committed Jan 9, 2025
1 parent d518314 commit f198008
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion util.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func parseFmtp(fmtp string) (Codec, error) {
parsingFailed := errExtractCodecFmtp

// a=fmtp:<format> <format specific parameters>
split := strings.Split(fmtp, " ")
split := strings.SplitN(fmtp, " ", 2)
if len(split) != 2 {
return codec, parsingFailed
}
Expand Down
16 changes: 15 additions & 1 deletion util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ func getTestSessionDescription() SessionDescription {
Value: 51372,
},
Protos: []string{"RTP", "AVP"},
Formats: []string{"120", "121", "126", "97"},
Formats: []string{"120", "121", "126", "97", "98"},
},
Attributes: []Attribute{
NewAttribute("fmtp:126 profile-level-id=42e01f;level-asymmetry-allowed=1;packetization-mode=1", ""),
NewAttribute("fmtp:97 profile-level-id=42e01f;level-asymmetry-allowed=1", ""),
NewAttribute("fmtp:98 profile-level-id=42e01e; packetization-mode=1", ""),
NewAttribute("fmtp:120 max-fs=12288;max-fr=60", ""),
NewAttribute("fmtp:121 max-fs=12288;max-fr=60", ""),
NewAttribute("rtpmap:120 VP8/90000", ""),
NewAttribute("rtpmap:121 VP9/90000", ""),
NewAttribute("rtpmap:126 H264/90000", ""),
NewAttribute("rtpmap:97 H264/90000", ""),
NewAttribute("rtpmap:98 H264/90000", ""),
NewAttribute("rtcp-fb:97 ccm fir", ""),
NewAttribute("rtcp-fb:97 nack", ""),
NewAttribute("rtcp-fb:97 nack pli", ""),
Expand Down Expand Up @@ -148,6 +150,18 @@ func TestGetCodecForPayloadType(t *testing.T) {
RTCPFeedback: []string{"ccm fir", "nack", "nack pli", "transport-cc"},
},
},
{
"h264 98",
getTestSessionDescription(),
98,
Codec{
PayloadType: 98,
Name: "H264",
ClockRate: 90000,
Fmtp: "profile-level-id=42e01e; packetization-mode=1",
RTCPFeedback: []string{"transport-cc", "nack"},
},
},
{
"pcmu without rtpmap",
SessionDescription{
Expand Down

0 comments on commit f198008

Please sign in to comment.