Skip to content
Snippets Groups Projects
Commit 18abbce0 authored by Pierre Lespagnol's avatar Pierre Lespagnol Committed by Albert Babí Oller
Browse files

conference: add mute participant for moderator

Change-Id: I9bb1f7476fcbd4d2830ee2b73b6984f607e5395a
parent 0c3b2df6
No related branches found
No related tags found
No related merge requests found
...@@ -331,6 +331,7 @@ CallAdapter::connectCallModel(const QString& accountId) ...@@ -331,6 +331,7 @@ CallAdapter::connectCallModel(const QString& accountId)
auto& callModel = accInfo.callModel; auto& callModel = accInfo.callModel;
auto call = callModel->getCall(confId); auto call = callModel->getCall(confId);
const auto convInfo = LRCInstance::getConversationFromCallId(confId); const auto convInfo = LRCInstance::getConversationFromCallId(confId);
bool currentMuted = false;
if (!convInfo.uid.isEmpty()) { if (!convInfo.uid.isEmpty()) {
// Convert to QML // Convert to QML
QVariantList map; QVariantList map;
...@@ -350,6 +351,7 @@ CallAdapter::connectCallModel(const QString& accountId) ...@@ -350,6 +351,7 @@ CallAdapter::connectCallModel(const QString& accountId)
if (bestName == accInfo.profileInfo.uri) { if (bestName == accInfo.profileInfo.uri) {
bestName = tr("me"); bestName = tr("me");
data["isLocal"] = true; data["isLocal"] = true;
currentMuted = participant["audioMuted"] == "true";
if (participant["videoMuted"] == "true") if (participant["videoMuted"] == "true")
data["avatar"] = accInfo.profileInfo.avatar; data["avatar"] = accInfo.profileInfo.avatar;
} else { } else {
...@@ -366,6 +368,19 @@ CallAdapter::connectCallModel(const QString& accountId) ...@@ -366,6 +368,19 @@ CallAdapter::connectCallModel(const QString& accountId)
data["bestName"] = bestName; data["bestName"] = bestName;
map.push_back(QVariant(data)); map.push_back(QVariant(data));
} }
// Link local mute to conference mute
auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(convUid_);
if (!convInfo.uid.isEmpty()) {
auto call = LRCInstance::getCallInfoForConversation(convInfo);
if (call) {
if (currentMuted != call->audioMuted) {
muteThisCallToggle();
updateCallOverlay(convInfo);
}
}
}
emit updateParticipantsInfos(map, accountId, confId); emit updateParticipantsInfos(map, accountId, confId);
} }
}); });
...@@ -700,6 +715,68 @@ CallAdapter::setModerator(const QString& uri, const bool state) ...@@ -700,6 +715,68 @@ CallAdapter::setModerator(const QString& uri, const bool state)
} catch (...) {} } catch (...) {}
} }
void
CallAdapter::muteParticipant(const QString& uri, const bool state) {
auto* callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
auto* convModel = LRCInstance::getCurrentConversationModel();
const auto conversation = convModel->getConversationForUID(LRCInstance::getCurrentConvUid());
auto confId = conversation.confId;
if (confId.isEmpty())
confId = conversation.callId;
try {
const auto call = callModel->getCall(confId);
callModel->muteParticipant(confId, uri, state);
} catch (...) {}
}
bool
CallAdapter::isMuted(const QString& uri) const
{
auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(convUid_);
auto* callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
auto confId = convInfo.confId.isEmpty() ? convInfo.callId : convInfo.confId;
try {
auto call = callModel->getCall(confId);
if (call.participantsInfos.size() == 0) {
return false;
} else {
for (const auto& participant : call.participantsInfos) {
if (participant["uri"] == uri)
return participant["audioMuted"] == "true";
}
}
return false;
} catch (...) {
}
return false;
}
bool
CallAdapter::isCurrentMuted() const
{
auto* convModel = LRCInstance::getCurrentConversationModel();
const auto convInfo = convModel->getConversationForUID(convUid_);
if (!convInfo.uid.isEmpty()) {
auto* callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
try {
auto call = callModel->getCall(convInfo.callId);
if (call.participantsInfos.size() == 0) {
return false;
} else {
auto& accInfo = LRCInstance::accountModel().getAccountInfo(accountId_);
for (const auto& participant : call.participantsInfos) {
if (participant["uri"] == accInfo.profileInfo.uri)
return participant["audioMuted"] == "true";
}
}
return false;
} catch (...) {
}
}
return true;
}
int int
CallAdapter::getCurrentLayoutType() const CallAdapter::getCurrentLayoutType() const
......
...@@ -68,6 +68,9 @@ public: ...@@ -68,6 +68,9 @@ public:
Q_INVOKABLE void videoPauseThisCallToggle(); Q_INVOKABLE void videoPauseThisCallToggle();
Q_INVOKABLE bool isRecordingThisCall(); Q_INVOKABLE bool isRecordingThisCall();
Q_INVOKABLE QVariantList getConferencesInfos(); Q_INVOKABLE QVariantList getConferencesInfos();
Q_INVOKABLE void muteParticipant(const QString& uri, const bool state);
Q_INVOKABLE bool isMuted(const QString& uri) const;
Q_INVOKABLE bool isCurrentMuted() const;
signals: signals:
void callStatusChanged(int index, const QString& accountId, const QString& convUid); void callStatusChanged(int index, const QString& accountId, const QString& convUid);
......
...@@ -74,7 +74,7 @@ Rectangle { ...@@ -74,7 +74,7 @@ Rectangle {
function closePotentialMediaHandlerPicker() { function closePotentialMediaHandlerPicker() {
MediaHandlerPickerCreation.closeMediaHandlerPicker() MediaHandlerPickerCreation.closeMediaHandlerPicker()
} }
function handleParticipantsInfo(infos) { function handleParticipantsInfo(infos) {
videoCallOverlay.updateMenu() videoCallOverlay.updateMenu()
var isModerator = CallAdapter.isCurrentModerator() var isModerator = CallAdapter.isCurrentModerator()
......
...@@ -37,6 +37,8 @@ Item { ...@@ -37,6 +37,8 @@ Item {
property var showMinimize: false property var showMinimize: false
property var showSetModerator: false property var showSetModerator: false
property var showUnsetModerator: false property var showUnsetModerator: false
property var showMute: false
property var showUnmute: false
function openMenu(){ function openMenu(){
ContextMenuGenerator.initMenu() ContextMenuGenerator.initMenu()
...@@ -74,6 +76,21 @@ Item { ...@@ -74,6 +76,21 @@ Item {
CallAdapter.setModerator(uri, false) CallAdapter.setModerator(uri, false)
}) })
if (showMute)
ContextMenuGenerator.addMenuItem(qsTr("Mute participant"),
"qrc:/images/icons/mic_off-24px.svg",
function (){
CallAdapter.muteParticipant(uri, true)
})
if (showUnmute)
ContextMenuGenerator.addMenuItem(qsTr("Unmute participant"),
"qrc:/images/icons/mic-24px.svg",
function (){
CallAdapter.muteParticipant(uri, false)
})
root.height = ContextMenuGenerator.getMenu().height root.height = ContextMenuGenerator.getMenu().height
root.width = ContextMenuGenerator.getMenu().width root.width = ContextMenuGenerator.getMenu().width
ContextMenuGenerator.getMenu().open() ContextMenuGenerator.getMenu().open()
......
...@@ -158,6 +158,7 @@ Rectangle { ...@@ -158,6 +158,7 @@ Rectangle {
var isModerator = CallAdapter.isModerator(uri) var isModerator = CallAdapter.isModerator(uri)
var isHost = CallAdapter.isCurrentHost() var isHost = CallAdapter.isCurrentHost()
var participantIsHost = CallAdapter.participantIsHost(uri) var participantIsHost = CallAdapter.participantIsHost(uri)
var isMuted = CallAdapter.isMuted(uri)
injectedContextMenu.showHangup = !root.isLocal && showEndCall injectedContextMenu.showHangup = !root.isLocal && showEndCall
injectedContextMenu.showMaximize = showMaximized injectedContextMenu.showMaximize = showMaximized
injectedContextMenu.showMinimize = showMinimized injectedContextMenu.showMinimize = showMinimized
...@@ -167,6 +168,8 @@ Rectangle { ...@@ -167,6 +168,8 @@ Rectangle {
injectedContextMenu.y = mousePos.y - injectedContextMenu.height injectedContextMenu.y = mousePos.y - injectedContextMenu.height
injectedContextMenu.showSetModerator = (isHost && !participantIsHost && !isModerator) injectedContextMenu.showSetModerator = (isHost && !participantIsHost && !isModerator)
injectedContextMenu.showUnsetModerator = (isHost && !participantIsHost && isModerator) injectedContextMenu.showUnsetModerator = (isHost && !participantIsHost && isModerator)
injectedContextMenu.showMute = !isMuted
injectedContextMenu.showUnmute = isMuted && root.isLocal
injectedContextMenu.openMenu() injectedContextMenu.openMenu()
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment