From f656a01407f50b7403f977d304b065f92a58e8a5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micka=C3=ABl=20Turnel?=
 <mickael.turnel@belledonne-communications.com>
Date: Tue, 11 Oct 2022 12:13:00 +0200
Subject: [PATCH] Set a max video size when in video conference

---
 src/conference/session/video-stream.cpp | 25 ++++++++++++++-----------
 tester/local_conference_tester.cpp      |  2 +-
 2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/src/conference/session/video-stream.cpp b/src/conference/session/video-stream.cpp
index 4faa959173..934cc0300b 100644
--- a/src/conference/session/video-stream.cpp
+++ b/src/conference/session/video-stream.cpp
@@ -326,17 +326,20 @@ void MS2VideoStream::render(const OfferAnswerContext & ctx, CallSession::State t
 		mStream->staticimage_webcam_fps_optimization = false;
 
 	LinphoneVideoDefinition *max_vdef = nullptr;
-	if (this->getMediaSessionPrivate().getParams()->getConferenceVideoLayout() == ConferenceLayout::Grid) {
-		const char *str = linphone_config_get_string(linphone_core_get_config(getCCore()), "video", "max_mosaic_size", nullptr);
-		if (str != NULL && str[0] != 0) {
-			max_vdef = linphone_factory_find_supported_video_definition_by_name(linphone_factory_get(), str);
-			if (max_vdef == NULL) {
-				lError() << "Cannot set max video size in mosaic (video definition '" << str << "' not supported)";
-			} else {
-				MSVideoSize max;
-				max.width = static_cast<int>(linphone_video_definition_get_width(max_vdef));
-				max.height = static_cast<int>(linphone_video_definition_get_height(max_vdef));
-				video_stream_set_sent_video_size_max(mStream, max);
+	if (listener) {
+		const auto conference = listener->getCallSessionConference(getMediaSession().getSharedFromThis());
+		if (conference) {
+			const char *str = linphone_config_get_string(linphone_core_get_config(getCCore()), "video", "max_conference_size", nullptr);
+			if (str != NULL && str[0] != 0) {
+				max_vdef = linphone_factory_find_supported_video_definition_by_name(linphone_factory_get(), str);
+				if (max_vdef == NULL) {
+					lError() << "Cannot set max video size in mosaic (video definition '" << str << "' not supported)";
+				} else {
+					MSVideoSize max;
+					max.width = static_cast<int>(linphone_video_definition_get_width(max_vdef));
+					max.height = static_cast<int>(linphone_video_definition_get_height(max_vdef));
+					video_stream_set_sent_video_size_max(mStream, max);
+				}
 			}
 		}
 	}
diff --git a/tester/local_conference_tester.cpp b/tester/local_conference_tester.cpp
index b386dff44c..0e20aeef30 100644
--- a/tester/local_conference_tester.cpp
+++ b/tester/local_conference_tester.cpp
@@ -3381,7 +3381,7 @@ static void create_conference_base (time_t start_time, int duration, bool_t unin
 
 				if (layout == LinphoneConferenceLayoutGrid) {
 					linphone_core_set_preferred_video_definition_by_name(mgr->lc, "720p");
-					linphone_config_set_string(linphone_core_get_config(mgr->lc), "video", "max_mosaic_size", "vga");
+					linphone_config_set_string(linphone_core_get_config(mgr->lc), "video", "max_conference_size", "vga");
 				}
 			}
 
-- 
GitLab