From 1f4cd3d548dd4b15ce8083bbfbc81903dc72ebdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= Date: Fri, 17 Nov 2023 10:57:50 -0500 Subject: [PATCH] conference: improve audio-only handling 1. When a audio-only participant leaves, the video mixer is updated and all audio-only streams are now removed. 2. If a audio-only calls try to join a swarm-call, it was hanging due to a bad number of medias. So ignore video for audio-only calls. GitLab: #917 Change-Id: Ifdd66e2ab138c078ef9e9c1402a07a6ae6a36b00 --- src/conference.cpp | 14 +++++++++----- src/jamidht/jamiaccount.cpp | 9 ++++++++- test/unitTest/call/conference.cpp | 27 +++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/src/conference.cpp b/src/conference.cpp index 17a030073..7132ae033 100644 --- a/src/conference.cpp +++ b/src/conference.cpp @@ -925,13 +925,17 @@ Conference::removeParticipant(const std::string& participant_id) participantsMuted_.erase(call->getCallId()); if (auto* transport = call->getTransport()) handsRaised_.erase(std::string(transport->deviceId())); + if (videoMixer_) { + for (auto const& rtpSession : call->getRtpSessionList()) { + if (rtpSession->getMediaType() == MediaType::MEDIA_AUDIO) + videoMixer_->removeAudioOnlySource(participant_id, rtpSession->streamId()); + if (videoMixer_->verifyActive(rtpSession->streamId())) + videoMixer_->resetActiveStream(); + } + } + #ifdef ENABLE_VIDEO auto sinkId = getConfId() + peerId; - // Remove if active - // TODO all streams - if (videoMixer_->verifyActive( - sip_utils::streamId(participant_id, sip_utils::DEFAULT_VIDEO_STREAMID))) - videoMixer_->resetActiveStream(); call->exitConference(); if (call->isPeerRecording()) call->peerRecording(false); diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp index 3aa1900e6..ec5529762 100644 --- a/src/jamidht/jamiaccount.cpp +++ b/src/jamidht/jamiaccount.cpp @@ -34,6 +34,7 @@ #include "sync_channel_handler.h" #include "transfer_channel_handler.h" #include "swarm/swarm_channel_handler.h" +#include "jami/media_const.h" #include "sip/sdp.h" #include "sip/sipvoiplink.h" @@ -542,7 +543,13 @@ JamiAccount::handleIncomingConversationCall(const std::string& callId, JAMI_ERROR("Conference {} not found", confId); return; } - currentMediaList = conf->currentMediaList(); + for (const auto& m: conf->currentMediaList()) { + if (m.at(libjami::Media::MediaAttributeKey::MEDIA_TYPE) == libjami::Media::MediaAttributeValue::VIDEO + && !call->hasVideo()) { + continue; + } + currentMediaList.emplace_back(m); + } } Manager::instance().answerCall(*call, currentMediaList); diff --git a/test/unitTest/call/conference.cpp b/test/unitTest/call/conference.cpp index 4bd9816b6..7eec8468a 100644 --- a/test/unitTest/call/conference.cpp +++ b/test/unitTest/call/conference.cpp @@ -107,6 +107,7 @@ private: void testPropagateRecording(); void testBrokenParticipantAudioAndVideo(); void testBrokenParticipantAudioOnly(); + void testAudioOnlyLeaveLayout(); void testRemoveConferenceInOneOne(); CPPUNIT_TEST_SUITE(ConferenceTest); @@ -131,6 +132,7 @@ private: CPPUNIT_TEST(testPropagateRecording); CPPUNIT_TEST(testBrokenParticipantAudioAndVideo); CPPUNIT_TEST(testBrokenParticipantAudioOnly); + CPPUNIT_TEST(testAudioOnlyLeaveLayout); CPPUNIT_TEST(testRemoveConferenceInOneOne); CPPUNIT_TEST_SUITE_END(); @@ -1079,6 +1081,31 @@ ConferenceTest::testBrokenParticipantAudioOnly() libjami::unregisterSignalHandlers(); } +void +ConferenceTest::testAudioOnlyLeaveLayout() +{ + registerSignalHandlers(); + + // Start conference with four participants + startConference(true, true); + auto expectedNumberOfParticipants = 4u; + + // Check participants number + CPPUNIT_ASSERT( + cv.wait_for(lk, 30s, [&] { return pInfos_.size() == expectedNumberOfParticipants; })); + + // Carla Leave + Manager::instance().hangupCall(carlaId, carlaCall.callId); + + // Check participants number + // It should have one less participant than in the conference start + CPPUNIT_ASSERT( + cv.wait_for(lk, 30s, [&] { return expectedNumberOfParticipants - 1 == pInfos_.size(); })); + + hangupConference(); + libjami::unregisterSignalHandlers(); +} + void ConferenceTest::testRemoveConferenceInOneOne() {