From 2194c9636de8f7343cb0c39e79eae1debdf9cd59 Mon Sep 17 00:00:00 2001 From: Alexey <78480736+Olex1313@users.noreply.github.com> Date: Thu, 9 Jan 2025 18:07:52 +0300 Subject: [PATCH] Fix fmtp parsing with spaces inside (#192) --- util.go | 2 +- util_test.go | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/util.go b/util.go index 0f14f15..f0cc33e 100644 --- a/util.go +++ b/util.go @@ -140,7 +140,7 @@ func parseFmtp(fmtp string) (Codec, error) { parsingFailed := errExtractCodecFmtp // a=fmtp: - split := strings.Split(fmtp, " ") + split := strings.SplitN(fmtp, " ", 2) if len(split) != 2 { return codec, parsingFailed } diff --git a/util_test.go b/util_test.go index 286e0f8..486664c 100644 --- a/util_test.go +++ b/util_test.go @@ -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", ""), @@ -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{