From b0fdb4b77daa5c3d81862f58da51697fb7c1b473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Thu, 29 Feb 2024 14:47:17 -0500 Subject: [PATCH] call-swarm: start detached by default This avoid complex setup GitLab: #958 Change-Id: Ia142bc8582f41b5db82d3b9a8043fcac874c65a8 --- src/conference.cpp | 54 ++--------------------------- src/conference.h | 8 ++--- src/jamidht/conversation_module.cpp | 4 +-- src/manager.cpp | 6 ++-- src/media/video/video_mixer.h | 2 +- 5 files changed, 12 insertions(+), 62 deletions(-) diff --git a/src/conference.cpp b/src/conference.cpp index fce992ddef..ea86ef2906 100644 --- a/src/conference.cpp +++ b/src/conference.cpp @@ -55,56 +55,18 @@ using namespace std::literals; namespace jami { Conference::Conference(const std::shared_ptr<Account>& account, - const std::string& confId, - bool attachHost, - const std::vector<MediaAttribute>& hostAttr) + const std::string& confId) : id_(confId.empty() ? Manager::instance().callFactory.getNewCallID() : confId) , account_(account) #ifdef ENABLE_VIDEO , videoEnabled_(account->isVideoEnabled()) - , attachHost_(attachHost) #endif { - /** NOTE: - * - *** Handling mute state of the local host. - * - * When a call is added to a conference, the media source of the - * call is set to the audio/video mixers output, and the host media - * source (e.g. camera), is added as a source for the mixer. - * Note that, by design, the mixers are never muted, but the mixer - * can produce audio/video frames with no content (silence or black - * video frames) if all the participants are muted. - * - * The mute state of the local host is set as follows: - * - * 1. If the video is disabled, the mute state is irrelevant. - * 2. If the local is not attached, the mute state is irrelevant. - * 3. When the conference is created from existing calls: - * the mute state is set to true if the local mute state of - * all participating calls are true. - * 4. Attaching the local host to an existing conference: - * the audio and video is set to the default capture device - * (microphone and/or camera), and set to un-muted state. - */ - - JAMI_INFO("Create new conference %s", id_.c_str()); - if (hostAttr.empty()) { - setLocalHostDefaultMediaSource(); - } else { - hostSources_ = hostAttr; - reportMediaNegotiationStatus(); - } + JAMI_LOG("Create new conference {}", id_); duration_start_ = clock::now(); #ifdef ENABLE_VIDEO - auto itVideo = std::find_if(hostSources_.begin(), hostSources_.end(), [&](auto attr) { - return attr.type_ == MediaType::MEDIA_VIDEO; - }); - // Only set host source if creating conference from joining calls - auto hasVideo = videoEnabled_ && itVideo != hostSources_.end() && attachHost_; - auto source = hasVideo ? itVideo->sourceUri_ : ""; - videoMixer_ = std::make_shared<video::VideoMixer>(id_, source, hasVideo); + videoMixer_ = std::make_shared<video::VideoMixer>(id_); videoMixer_->setOnSourcesUpdated([this](std::vector<video::SourceInfo>&& infos) { runOnMainThread([w = weak(), infos = std::move(infos)] { auto shared = w.lock(); @@ -228,16 +190,6 @@ Conference::Conference(const std::shared_ptr<Account>& account, shared->updateConferenceInfo(std::move(newInfo)); }); }); - - if (attachHost && itVideo == hostSources_.end()) { - // If no video, we still want to attach outself - videoMixer_->addAudioOnlySource("", "host_audio_0"); - } - if (attachHost) { - setState(State::ACTIVE_ATTACHED); - } else { - setState(State::ACTIVE_DETACHED); - } auto conf_res = split_string_to_unsigned(jami::Manager::instance() .videoPreferences.getConferenceResolution(), 'x'); diff --git a/src/conference.h b/src/conference.h index ceac3498e2..e5de287ac0 100644 --- a/src/conference.h +++ b/src/conference.h @@ -198,9 +198,7 @@ public: * Constructor for this class, increment static counter */ explicit Conference(const std::shared_ptr<Account>&, - const std::string& confId = "", - bool attachHost = true, - const std::vector<MediaAttribute>& hostAttr = {}); + const std::string& confId = ""); /** * Destructor for this class, decrement static counter @@ -418,7 +416,7 @@ private: std::string id_; std::weak_ptr<Account> account_; - State confState_ {State::ACTIVE_ATTACHED}; + State confState_ {State::ACTIVE_DETACHED}; mutable std::mutex subcallsMtx_ {}; CallIdSet subCalls_; std::string mediaPlayerId_ {}; @@ -440,8 +438,6 @@ private: std::set<std::string, std::less<>> participantsMuted_ {}; std::set<std::string, std::less<>> handsRaised_; - bool attachHost_; - // stream IDs std::set<std::string, std::less<>> streamsVoiceActive {}; diff --git a/src/jamidht/conversation_module.cpp b/src/jamidht/conversation_module.cpp index e434c2a502..8c37956eb0 100644 --- a/src/jamidht/conversation_module.cpp +++ b/src/jamidht/conversation_module.cpp @@ -2995,14 +2995,14 @@ ConversationModule::hostConference(const std::string& conversationId, } } if (createConf) { - conf = std::make_shared<Conference>(acc, confId, callId.empty(), callId.empty()? std::vector<MediaAttribute> {} : call->getMediaAttributeList()); + conf = std::make_shared<Conference>(acc, confId); acc->attach(conf); } if (!callId.empty()) conf->addSubCall(callId); - if (!createConf && callId.empty()) // TODO use mediaList + if (callId.empty()) // TODO use mediaList conf->attachHost(); if (createConf) { diff --git a/src/manager.cpp b/src/manager.cpp index a4eb717e55..ede97e9a07 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -1525,7 +1525,8 @@ Manager::joinParticipant(const std::string& accountId, auto mediaAttr = call1->getMediaAttributeList(); if (mediaAttr.empty()) mediaAttr = call2->getMediaAttributeList(); - auto conf = std::make_shared<Conference>(account, "", true, mediaAttr); + auto conf = std::make_shared<Conference>(account); + conf->attachHost(); account->attach(conf); emitSignal<libjami::CallSignal::ConferenceCreated>(account->getAccountID(), "", conf->getConfId()); @@ -1564,6 +1565,7 @@ Manager::createConfFromParticipantList(const std::string& accountId, } auto conf = std::make_shared<Conference>(account); + conf->attachHost(); unsigned successCounter = 0; for (const auto& numberaccount : participantList) { @@ -2617,7 +2619,7 @@ Manager::ManagerPimpl::processIncomingCall(const std::string& accountId, Call& i } // First call - auto conf = std::make_shared<Conference>(account, "", false); + auto conf = std::make_shared<Conference>(account); account->attach(conf); emitSignal<libjami::CallSignal::ConferenceCreated>(account->getAccountID(), "", conf->getConfId()); diff --git a/src/media/video/video_mixer.h b/src/media/video/video_mixer.h index 7d044d7f39..854c371a20 100644 --- a/src/media/video/video_mixer.h +++ b/src/media/video/video_mixer.h @@ -61,7 +61,7 @@ enum class Layout { GRID, ONE_BIG_WITH_SMALL, ONE_BIG }; class VideoMixer : public VideoGenerator, public VideoFramePassiveReader { public: - VideoMixer(const std::string& id, const std::string& localInput = {}, bool attachHost = true); + VideoMixer(const std::string& id, const std::string& localInput = {}, bool attachHost = false); ~VideoMixer(); void setParameters(int width, int height, AVPixelFormat format = AV_PIX_FMT_YUV422P); -- GitLab