Commit 86bac766 authored by Aline Gondim Santos's avatar Aline Gondim Santos Committed by Aline Gondim Santos

mutistream: fix audio video mute status for conference

Fix audio video device mute status when creating a conference
from an audio and/or video muted call.

+ fix automatic camera opening with mediaChangeRequested.

GitLab: #483
GitLab: #484
Change-Id: Ib8cd331ebd056d3846cdbf8f19902f859fd2f1ca
parent 813326df
...@@ -133,8 +133,8 @@ struct Info ...@@ -133,8 +133,8 @@ struct Info
Type type = Type::INVALID; Type type = Type::INVALID;
QString peerUri; QString peerUri;
bool isOutgoing; bool isOutgoing;
bool audioMuted = false; bool audioMuted = false; // this flag is used to check main audio status
bool videoMuted = false; bool videoMuted = false; // this flag is used to check main video status
bool isAudioOnly = false; bool isAudioOnly = false;
Layout layout = Layout::GRID; Layout layout = Layout::GRID;
VectorMapStringString participantsInfos = {}; VectorMapStringString participantsInfos = {};
......
...@@ -79,7 +79,7 @@ public: ...@@ -79,7 +79,7 @@ public:
* @param isAudioOnly, set to false by default * @param isAudioOnly, set to false by default
* @return the call uid created. Empty string is returned if call couldn't be created. * @return the call uid created. Empty string is returned if call couldn't be created.
*/ */
QString createCall(const QString& uri, bool isAudioOnly = false); QString createCall(const QString& uri, bool isAudioOnly = false, VectorMapStringString mediaList = {});
/** /**
* Request a media change in a ongoing call. * Request a media change in a ongoing call.
......
...@@ -314,19 +314,22 @@ NewCallModel::updateCallMediaList(const QString& callId, bool acceptVideo) ...@@ -314,19 +314,22 @@ NewCallModel::updateCallMediaList(const QString& callId, bool acceptVideo)
} }
QString QString
NewCallModel::createCall(const QString& uri, bool isAudioOnly) NewCallModel::createCall(const QString& uri, bool isAudioOnly, VectorMapStringString mediaList)
{ {
VectorMapStringString mediaList {}; if (mediaList.isEmpty()) {
MapStringString mediaAttribute = {{MediaAttributeKey::MEDIA_TYPE, MediaAttributeValue::AUDIO}, MapStringString mediaAttribute = {{MediaAttributeKey::MEDIA_TYPE,
{MediaAttributeKey::ENABLED, "true"}, MediaAttributeValue::AUDIO},
{MediaAttributeKey::MUTED, "false"}, {MediaAttributeKey::ENABLED, "true"},
{MediaAttributeKey::SOURCE, ""}, {MediaAttributeKey::MUTED, "false"},
{MediaAttributeKey::LABEL, "audio_0"}}; {MediaAttributeKey::SOURCE, ""},
mediaList.push_back(mediaAttribute); {MediaAttributeKey::LABEL, "audio_0"}};
if (!isAudioOnly) {
mediaAttribute[MediaAttributeKey::MEDIA_TYPE] = MediaAttributeValue::VIDEO;
mediaAttribute[MediaAttributeKey::LABEL] = "video_0";
mediaList.push_back(mediaAttribute); mediaList.push_back(mediaAttribute);
if (!isAudioOnly) {
mediaAttribute[MediaAttributeKey::MEDIA_TYPE]
= MediaAttributeValue::VIDEO;
mediaAttribute[MediaAttributeKey::LABEL] = "video_0";
mediaList.push_back(mediaAttribute);
}
} }
#ifdef ENABLE_LIBWRAP #ifdef ENABLE_LIBWRAP
auto callId = CallManager::instance().placeCallWithMedia(owner.id, uri, mediaList); auto callId = CallManager::instance().placeCallWithMedia(owner.id, uri, mediaList);
...@@ -410,7 +413,13 @@ NewCallModel::requestMediaChange(const QString& callId, const QString& mediaLabe ...@@ -410,7 +413,13 @@ NewCallModel::requestMediaChange(const QString& callId, const QString& mediaLabe
// mediaNegotiationStatus // mediaNegotiationStatus
if (found < callInfo->mediaList.size()) { if (found < callInfo->mediaList.size()) {
callInfo->mediaList[found][MediaAttributeKey::MUTED] callInfo->mediaList[found][MediaAttributeKey::MUTED]
= callInfo->mediaList[found][MediaAttributeKey::MUTED] == "true" ? "false" : "true"; = callInfo->mediaList[found][MediaAttributeKey::MUTED] == "true" ? "false"
: "true";
if (mediaLabel.contains("audio_0")) {
callInfo->audioMuted = !callInfo->audioMuted;
} else if (mediaLabel.contains("video_0")) {
callInfo->videoMuted = !callInfo->videoMuted;
}
if (callInfo->status == call::Status::IN_PROGRESS) if (callInfo->status == call::Status::IN_PROGRESS)
emit callInfosChanged(owner.id, callId); emit callInfosChanged(owner.id, callId);
} }
...@@ -620,7 +629,7 @@ NewCallModel::joinCalls(const QString& callIdA, const QString& callIdB) const ...@@ -620,7 +629,7 @@ NewCallModel::joinCalls(const QString& callIdA, const QString& callIdB) const
QString QString
NewCallModel::callAndAddParticipant(const QString uri, const QString& callId, bool audioOnly) NewCallModel::callAndAddParticipant(const QString uri, const QString& callId, bool audioOnly)
{ {
auto newCallId = createCall(uri, audioOnly); auto newCallId = createCall(uri, audioOnly, pimpl_->calls[callId]->mediaList);
Q_EMIT beginInsertPendingConferenceesRows(0); Q_EMIT beginInsertPendingConferenceesRows(0);
pimpl_->pendingConferencees_.prepend({uri, newCallId, callId}); pimpl_->pendingConferencees_.prepend({uri, newCallId, callId});
Q_EMIT endInsertPendingConferenceesRows(); Q_EMIT endInsertPendingConferenceesRows();
...@@ -1042,11 +1051,20 @@ NewCallModelPimpl::slotMediaChangeRequested(const QString& accountId, ...@@ -1042,11 +1051,20 @@ NewCallModelPimpl::slotMediaChangeRequested(const QString& accountId,
auto& callInfo = calls[callId]; auto& callInfo = calls[callId];
if (!callInfo) if (!callInfo)
return; return;
QList<QString> currentMediaLabels {};
for (auto& currentItem : callInfo->mediaList)
currentMediaLabels.append(currentItem[MediaAttributeKey::LABEL]);
auto answerMedia = QList<MapStringString>::fromVector(mediaList); auto answerMedia = QList<MapStringString>::fromVector(mediaList);
for (auto& item : answerMedia) { for (auto& item : answerMedia) {
if (item[MediaAttributeKey::MEDIA_TYPE] == MediaAttributeValue::VIDEO) { int index = currentMediaLabels.indexOf(item[MediaAttributeKey::LABEL]);
item[MediaAttributeKey::MUTED] = callInfo->videoMuted ? "true" : "false"; if (index >= 0) {
item[MediaAttributeKey::MUTED] = callInfo->mediaList[index][MediaAttributeKey::MUTED];
item[MediaAttributeKey::ENABLED] = callInfo->mediaList[index][MediaAttributeKey::ENABLED];
} else {
item[MediaAttributeKey::MUTED] = "true";
item[MediaAttributeKey::ENABLED] = "true"; item[MediaAttributeKey::ENABLED] = "true";
} }
} }
...@@ -1235,12 +1253,22 @@ NewCallModelPimpl::slotOnConferenceInfosUpdated(const QString& confId, ...@@ -1235,12 +1253,22 @@ NewCallModelPimpl::slotOnConferenceInfosUpdated(const QString& confId,
emit linked.onParticipantsChanged(confId); emit linked.onParticipantsChanged(confId);
for (auto& info : infos) {
if (info["uri"].isEmpty()) {
it->second->videoMuted = info["videoMuted"] == "true";
it->second->audioMuted = info["audioLocalMuted"] == "true";
}
}
// TODO: remove when the rendez-vous UI will be done // TODO: remove when the rendez-vous UI will be done
// For now, the rendez-vous account can see ongoing calls // For now, the rendez-vous account can see ongoing calls
// And must be notified when a new // And must be notified when a new
QStringList callList = CallManager::instance().getParticipantList(confId); QStringList callList = CallManager::instance().getParticipantList(confId);
foreach (const auto& call, callList) { foreach (const auto& call, callList) {
emit linked.callAddedToConference(call, confId); emit linked.callAddedToConference(call, confId);
calls[call]->videoMuted = it->second->videoMuted;
calls[call]->audioMuted = it->second->audioMuted;
Q_EMIT linked.callInfosChanged(linked.owner.id, call);
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment