Skip to content

Commit

Permalink
Merge pull request #641 from paullouisageneau/fix-sdp-removed-groups
Browse files Browse the repository at this point in the history
Fix removed media in SDP groups
  • Loading branch information
paullouisageneau authored Jun 3, 2022
2 parents 9b73996 + 6037b86 commit 8c49774
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/description.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,12 @@ string Description::typeString() const { return typeToString(mType); }
Description::Role Description::role() const { return mRole; }

string Description::bundleMid() const {
// Get the mid of the first media
return !mEntries.empty() ? mEntries[0]->mid() : "0";
// Get the mid of the first non-removed media
for (const auto &entry : mEntries)
if (!entry->isRemoved())
return entry->mid();

return "0";
}

optional<string> Description::iceUfrag() const { return mIceUfrag; }
Expand Down Expand Up @@ -275,15 +279,18 @@ string Description::generateSdp(string_view eol) const {

// BUNDLE (RFC 8843 Negotiating Media Multiplexing Using the Session Description Protocol)
// https://www.rfc-editor.org/rfc/rfc8843.html
sdp << "a=group:BUNDLE";
std::ostringstream bundleGroup;
for (const auto &entry : mEntries)
sdp << ' ' << entry->mid();
sdp << eol;
if (!entry->isRemoved())
bundleGroup << ' ' << entry->mid();

if (!bundleGroup.str().empty())
sdp << "a=group:BUNDLE" << bundleGroup.str() << eol;

// Lip-sync
std::ostringstream lsGroup;
for (const auto &entry : mEntries)
if (entry != mApplication)
if (!entry->isRemoved() && entry != mApplication)
lsGroup << ' ' << entry->mid();

if (!lsGroup.str().empty())
Expand Down Expand Up @@ -318,7 +325,7 @@ string Description::generateSdp(string_view eol) const {
for (const auto &entry : mEntries) {
sdp << entry->generateSdp(eol, addr, port);

if (std::exchange(first, false)) {
if (!entry->isRemoved() && std::exchange(first, false)) {
// Candidates
for (const auto &candidate : mCandidates)
sdp << string(candidate) << eol;
Expand Down

0 comments on commit 8c49774

Please sign in to comment.