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
Type type = Type::INVALID;
QString peerUri;
bool isOutgoing;
bool audioMuted = false;
bool videoMuted = false;
bool audioMuted = false; // this flag is used to check main audio status
bool videoMuted = false; // this flag is used to check main video status
bool isAudioOnly = false;
Layout layout = Layout::GRID;
VectorMapStringString participantsInfos = {};
......
......@@ -79,7 +79,7 @@ public:
* @param isAudioOnly, set to false by default
* @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.
......
......@@ -314,20 +314,23 @@ NewCallModel::updateCallMediaList(const QString& callId, bool acceptVideo)
}
QString
NewCallModel::createCall(const QString& uri, bool isAudioOnly)
NewCallModel::createCall(const QString& uri, bool isAudioOnly, VectorMapStringString mediaList)
{
VectorMapStringString mediaList {};
MapStringString mediaAttribute = {{MediaAttributeKey::MEDIA_TYPE, MediaAttributeValue::AUDIO},
if (mediaList.isEmpty()) {
MapStringString mediaAttribute = {{MediaAttributeKey::MEDIA_TYPE,
MediaAttributeValue::AUDIO},
{MediaAttributeKey::ENABLED, "true"},
{MediaAttributeKey::MUTED, "false"},
{MediaAttributeKey::SOURCE, ""},
{MediaAttributeKey::LABEL, "audio_0"}};
mediaList.push_back(mediaAttribute);
if (!isAudioOnly) {
mediaAttribute[MediaAttributeKey::MEDIA_TYPE] = MediaAttributeValue::VIDEO;
mediaAttribute[MediaAttributeKey::MEDIA_TYPE]
= MediaAttributeValue::VIDEO;
mediaAttribute[MediaAttributeKey::LABEL] = "video_0";
mediaList.push_back(mediaAttribute);
}
}
#ifdef ENABLE_LIBWRAP
auto callId = CallManager::instance().placeCallWithMedia(owner.id, uri, mediaList);
#else // dbus
......@@ -410,7 +413,13 @@ NewCallModel::requestMediaChange(const QString& callId, const QString& mediaLabe
// mediaNegotiationStatus
if (found < callInfo->mediaList.size()) {
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)
emit callInfosChanged(owner.id, callId);
}
......@@ -620,7 +629,7 @@ NewCallModel::joinCalls(const QString& callIdA, const QString& callIdB) const
QString
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);
pimpl_->pendingConferencees_.prepend({uri, newCallId, callId});
Q_EMIT endInsertPendingConferenceesRows();
......@@ -1042,11 +1051,20 @@ NewCallModelPimpl::slotMediaChangeRequested(const QString& accountId,
auto& callInfo = calls[callId];
if (!callInfo)
return;
QList<QString> currentMediaLabels {};
for (auto& currentItem : callInfo->mediaList)
currentMediaLabels.append(currentItem[MediaAttributeKey::LABEL]);
auto answerMedia = QList<MapStringString>::fromVector(mediaList);
for (auto& item : answerMedia) {
if (item[MediaAttributeKey::MEDIA_TYPE] == MediaAttributeValue::VIDEO) {
item[MediaAttributeKey::MUTED] = callInfo->videoMuted ? "true" : "false";
int index = currentMediaLabels.indexOf(item[MediaAttributeKey::LABEL]);
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";
}
}
......@@ -1235,12 +1253,22 @@ NewCallModelPimpl::slotOnConferenceInfosUpdated(const QString& 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
// For now, the rendez-vous account can see ongoing calls
// And must be notified when a new
QStringList callList = CallManager::instance().getParticipantList(confId);
foreach (const auto& call, callList) {
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