From 814eebf35ce6d63e85e4a97bbe9326861bc6ef4a Mon Sep 17 00:00:00 2001 From: Yutaka Takeda Date: Wed, 27 Apr 2022 15:35:38 -0700 Subject: [PATCH] Fix ice-lite attribute Fixes #2195 --- sdp.go | 2 +- sdp_test.go | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/sdp.go b/sdp.go index 843bcb7f398..090f27dbb02 100644 --- a/sdp.go +++ b/sdp.go @@ -538,7 +538,7 @@ func populateSDP(d *sdp.SessionDescription, isPlanB bool, dtlsFingerprints []DTL if isICELite { // RFC 5245 S15.3 - d = d.WithValueAttribute(sdp.AttrKeyICELite, sdp.AttrKeyICELite) + d = d.WithValueAttribute(sdp.AttrKeyICELite, "") } return d.WithValueAttribute(sdp.AttrKeyGroup, bundleValue), nil diff --git a/sdp_test.go b/sdp_test.go index 1d74426680c..017f04e403d 100644 --- a/sdp_test.go +++ b/sdp_test.go @@ -449,6 +449,26 @@ func TestPopulateSDP(t *testing.T) { } assert.Equal(t, true, foundVP8, "vp8 should be present in sdp") }) + t.Run("ice-lite", func(t *testing.T) { + se := SettingEngine{} + se.SetLite(true) + + offerSdp, err := populateSDP(&sdp.SessionDescription{}, false, []DTLSFingerprint{}, se.sdpMediaLevelFingerprints, se.candidates.ICELite, &MediaEngine{}, connectionRoleFromDtlsRole(defaultDtlsRoleOffer), []ICECandidate{}, ICEParameters{}, []mediaSection{}, ICEGatheringStateComplete) + assert.Nil(t, err) + + var found bool + // ice-lite is an session-level attribute + for _, a := range offerSdp.Attributes { + if a.Key == sdp.AttrKeyICELite { + // ice-lite does not have value (e.g. ":") and it should be an empty string + if a.Value == "" { + found = true + break + } + } + } + assert.Equal(t, true, found, "ICELite key should be present") + }) } func TestGetRIDs(t *testing.T) {