From 13daa796e5b58d9ee554a4a37ed95cba64bb9aec Mon Sep 17 00:00:00 2001 From: William Pfeffer Date: Sun, 26 May 2024 22:10:57 -0700 Subject: [PATCH] Moves session-level attributes for `a=setup`, `a=ice-ufrag` and `a=ice-pwd` to the media-level in `Description::generateSdp(...)`. The goal here is to have better general compatibility as RFC 8829 recommends using the media-level attributes even if the information is identical. --- src/description.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/description.cpp b/src/description.cpp index c6aafb2f8..df3e91f61 100644 --- a/src/description.cpp +++ b/src/description.cpp @@ -310,12 +310,7 @@ string Description::generateSdp(string_view eol) const { // Session-level attributes sdp << "a=msid-semantic:WMS *" << eol; - sdp << "a=setup:" << mRole << eol; - if (mIceUfrag) - sdp << "a=ice-ufrag:" << *mIceUfrag << eol; - if (mIcePwd) - sdp << "a=ice-pwd:" << *mIcePwd << eol; if (!mIceOptions.empty()) sdp << "a=ice-options:" << utils::implode(mIceOptions, ',') << eol; if (mFingerprint) @@ -339,6 +334,14 @@ string Description::generateSdp(string_view eol) const { for (const auto &entry : mEntries) { sdp << entry->generateSdp(eol, addr, port); + // RFC 8829: Attributes that SDP permits to be at either the session level or the media level + // SHOULD generally be at the media level even if they are identical. + sdp << "a=setup:" << mRole << eol; + if (mIceUfrag) + sdp << "a=ice-ufrag:" << *mIceUfrag << eol; + if (mIcePwd) + sdp << "a=ice-pwd:" << *mIcePwd << eol; + if (!entry->isRemoved() && std::exchange(first, false)) { // Candidates for (const auto &candidate : mCandidates)