From bf00b3baba29b5f8c9856c55d92fc8b5d23049eb Mon Sep 17 00:00:00 2001
From: Andrea Gianarda <andrea.gianarda@belledonne-communications.com>
Date: Thu, 8 Feb 2024 12:00:41 +0100
Subject: [PATCH] Create only as many streams as the offer has even if the
 local media description was bigger

---
 src/conference/session/streams-group.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/conference/session/streams-group.cpp b/src/conference/session/streams-group.cpp
index 14c9a148a1..9403864333 100644
--- a/src/conference/session/streams-group.cpp
+++ b/src/conference/session/streams-group.cpp
@@ -111,8 +111,10 @@ void StreamsGroup::fillLocalMediaDescription(OfferAnswerContext &params) {
 
 void StreamsGroup::createStreams(const OfferAnswerContext &params) {
 	size_t index;
-	const auto &localMd = params.localMediaDescription;
-	for (index = 0; index < localMd->streams.size(); ++index) {
+	// If the offer answer context has a remote media description, it means that we are replying to an INVITE, therefore
+	// we need to create only as many streams as the offer has
+	const auto &md = params.remoteMediaDescription ? params.remoteMediaDescription : params.localMediaDescription;
+	for (index = 0; index < md->streams.size(); ++index) {
 		Stream *s = nullptr;
 		params.scopeStreamToIndexWithDiff(index, mCurrentOfferAnswerState);
 
-- 
GitLab