From 9d0c33b24d2abb337ed273f0a74c4b104fa49659 Mon Sep 17 00:00:00 2001 From: agsantos <aline.gondimsantos@savoirfairelinux.com> Date: Fri, 22 Oct 2021 16:46:19 -0400 Subject: [PATCH] conference: improve media handling + set initial rdv conference as muted (a/v) + update a/v mute state when joining or detaching host participant Change-Id: I38d2dc219446ba526e6a3fc40e53ee73a2e87785 --- src/conference.cpp | 51 ++++++++++++++-------------------------------- 1 file changed, 15 insertions(+), 36 deletions(-) diff --git a/src/conference.cpp b/src/conference.cpp index b92093ba1d..5206471576 100644 --- a/src/conference.cpp +++ b/src/conference.cpp @@ -73,6 +73,7 @@ Conference::Conference(bool enableVideo) return; ConfInfo newInfo; auto subCalls = shared->participants_; + auto hostAdded = false; // Handle participants showing their video std::unique_lock<std::mutex> lk(shared->videoToCallMtx_); for (const auto& info : infos) { @@ -100,6 +101,7 @@ Conference::Conference(bool enableVideo) std::string_view peerId = string_remove_suffix(uri, '@'); auto isModerator = shared->isModerator(peerId); if (uri.empty()) { + hostAdded = true; peerId = "host"sv; isLocalMuted = shared->isMediaSourceMuted(MediaType::MEDIA_AUDIO); } @@ -123,30 +125,11 @@ Conference::Conference(bool enableVideo) newInfo.w = videoMixer->getWidth(); } lk.unlock(); - // Handle participants not present in the video mixer - for (const auto& subCall : subCalls) { - std::string uri {}; - if (auto call = getCall(subCall)) - uri = call->getPeerNumber(); - auto isModerator = shared->isModerator(uri); - auto sinkId = shared->getConfID() + string_remove_suffix(uri, '@'); - newInfo.emplace_back(ParticipantInfo {std::move(uri), - {}, - std::move(sinkId), - false, - 0, - 0, - 0, - 0, - true, - false, - false, - isModerator}); + if (!hostAdded) { + auto audioLocalMuted = shared->isMediaSourceMuted(MediaType::MEDIA_AUDIO); + newInfo.emplace_back(ParticipantInfo { + "", "", "", false, 0, 0, 0, 0, true, audioLocalMuted, false, true}); } - // Add host in confInfo with audio and video muted if detached - if (shared->getState() == State::ACTIVE_DETACHED) - newInfo.emplace_back( - ParticipantInfo {"", "", "", false, 0, 0, 0, 0, true, true, false, true}); shared->updateConferenceInfo(std::move(newInfo)); }); @@ -347,6 +330,9 @@ Conference::takeOverMediaSourceControl(const std::string& callId) // If the source state for the specified media type is not set // yet, the state will initialized using the state of the first // participant with a valid media source. + if (call->getAccount().lock()->isRendezVous()) { + iter->muted_ = true; + } setMediaSourceState(iter->type_, iter->muted_); } else { // To mute the local source, all the sources of the participating @@ -623,6 +609,8 @@ Conference::attachLocalParticipant() } } #endif + setMediaSourceState(MediaType::MEDIA_AUDIO, false); + setMediaSourceState(MediaType::MEDIA_VIDEO, false); setState(State::ACTIVE_ATTACHED); } else { JAMI_WARN( @@ -649,6 +637,8 @@ Conference::detachLocalParticipant() } } #endif + setMediaSourceState(MediaType::MEDIA_AUDIO, true); + setMediaSourceState(MediaType::MEDIA_VIDEO, true); setState(State::ACTIVE_DETACHED); } else { JAMI_WARN( @@ -1138,6 +1128,7 @@ Conference::muteLocalHost(bool is_muted, const std::string& mediaType) JAMI_DBG("Local video source already in [%s] state", is_muted ? "muted" : "un-muted"); return; } + setMediaSourceState(MediaType::MEDIA_VIDEO, is_muted); if (is_muted) { if (auto mixer = getVideoMixer()) { JAMI_DBG("Muting local video source"); @@ -1146,21 +1137,9 @@ Conference::muteLocalHost(bool is_muted, const std::string& mediaType) } else { if (auto mixer = getVideoMixer()) { JAMI_DBG("Un-muting local video source"); - mixer->switchInput(mediaInput_); -#ifdef ENABLE_PLUGIN - // Preview - if (auto& videoPreview = mixer->getVideoLocal()) { - auto previewSubject = std::make_shared<MediaStreamSubject>(pluginVideoMap_); - StreamData previewStreamData {getConfID(), - false, - StreamType::video, - getConfID()}; - createConfAVStream(previewStreamData, *videoPreview, previewSubject, true); - } -#endif + switchInput(mediaInput_); } } - setMediaSourceState(MediaType::MEDIA_VIDEO, is_muted); emitSignal<DRing::CallSignal::VideoMuted>(id_, is_muted); return; #endif -- GitLab