From febbfa4e0d82a016fde15501c143f083e6a3a35a Mon Sep 17 00:00:00 2001 From: Paul-Louis Ageneau Date: Sat, 16 Sep 2023 14:08:12 +0200 Subject: [PATCH] Pick correct ICE ufrag and pwd --- src/description.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/description.cpp b/src/description.cpp index f153e6f0e..d3368badc 100644 --- a/src/description.cpp +++ b/src/description.cpp @@ -128,11 +128,22 @@ Description::Description(const string &sdp, Type type, Role role) PLOG_WARNING << "Unknown SDP fingerprint format: " << value; } } else if (key == "ice-ufrag") { - mIceUfrag = value; + // RFC 8839: The "ice-pwd" and "ice-ufrag" attributes can appear at either the + // session-level or media-level. When present in both, the value in the media-level + // takes precedence. + if (!mIceUfrag || index == 0) // media-level for first media overrides session-level + mIceUfrag = value; } else if (key == "ice-pwd") { - mIcePwd = value; + // RFC 8839: The "ice-pwd" and "ice-ufrag" attributes can appear at either the + // session-level or media-level. When present in both, the value in the media-level + // takes precedence. + if (!mIcePwd || index == 0) // media-level for first media overrides session-level + mIcePwd = value; } else if (key == "ice-options") { - mIceOptions = utils::explode(string(value), ','); + // RFC 8839: The "ice-options" attribute is a session-level and media-level + // attribute. + if (mIceOptions.empty()) + mIceOptions = utils::explode(string(value), ','); } else if (key == "candidate") { addCandidate(Candidate(attr, bundleMid())); } else if (key == "end-of-candidates") {