1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-08-04 14:55:43 +02:00

callmodel: don't turn video on when accepting a call in audio

The function which is responsible for muting the camera when accepting
a call in audio assumes that the call's mediaList has already been
initialized, but this wasn't actually the case. This caused a bug where
the 'Accept in audio' button behaved exactly like the 'Accept in video'
button.

GitLab: #1621
Change-Id: I26251f51862cf5cd9b6d4daaf15270943c0e3c4e
This commit is contained in:
François-Simon Fauteux-Chapleau 2024-02-02 15:27:45 -05:00
parent 04c71d02e0
commit a676ad395a
5 changed files with 45 additions and 44 deletions

View file

@ -389,16 +389,13 @@ CallAdapter::hangUpACall(const QString& accountId, const QString& convUid)
} }
void void
CallAdapter::setCallMedia(const QString& accountId, const QString& convUid, bool video) CallAdapter::setCallMedia(const QString& accountId, const QString& convUid, bool videoMuted)
{ {
const auto& convInfo = lrcInstance_->getConversationFromConvUid(convUid, accountId); const auto& convInfo = lrcInstance_->getConversationFromConvUid(convUid, accountId);
if (convInfo.uid.isEmpty()) if (convInfo.uid.isEmpty())
return; return;
try {
lrcInstance_->getAccountInfo(accountId).callModel->updateCallMediaList(convInfo.callId, lrcInstance_->getAccountInfo(accountId).callModel->setVideoMuted(convInfo.callId, videoMuted);
video);
} catch (...) {
}
} }
void void

View file

@ -67,7 +67,7 @@ public:
Q_INVOKABLE void placeAudioOnlyCall(); Q_INVOKABLE void placeAudioOnlyCall();
Q_INVOKABLE void placeCall(); Q_INVOKABLE void placeCall();
Q_INVOKABLE void hangUpACall(const QString& accountId, const QString& convUid); Q_INVOKABLE void hangUpACall(const QString& accountId, const QString& convUid);
Q_INVOKABLE void setCallMedia(const QString& accountId, const QString& convUid, bool video); Q_INVOKABLE void setCallMedia(const QString& accountId, const QString& convUid, bool videoMuted);
Q_INVOKABLE void acceptACall(const QString& accountId, const QString& convUid); Q_INVOKABLE void acceptACall(const QString& accountId, const QString& convUid);
Q_INVOKABLE void connectCallModel(const QString& accountId); Q_INVOKABLE void connectCallModel(const QString& accountId);

View file

@ -213,12 +213,8 @@ Rectangle {
onClicked: { onClicked: {
if (type === "cam" || type === "mic") { if (type === "cam" || type === "mic") {
var acceptVideoMedia = true; var muteVideo = (type === "mic");
if (type === "cam") CallAdapter.setCallMedia(CurrentAccount.id, CurrentConversation.id, muteVideo);
acceptVideoMedia = true;
else if (type === "mic")
acceptVideoMedia = false;
CallAdapter.setCallMedia(CurrentAccount.id, CurrentConversation.id, acceptVideoMedia);
callAccepted(); callAccepted();
} else { } else {
callCanceled(); callCanceled();

View file

@ -287,12 +287,12 @@ public:
void setCurrentCall(const QString& callId) const; void setCurrentCall(const QString& callId) const;
/** /**
* Update call mediaList to be used in the call answering * Set whether the user's video media should be muted
* *
* @param callId * @param callId
* @param acceptVideo * @param videoMuted
*/ */
void updateCallMediaList(const QString& callId, bool acceptVideo); void setVideoMuted(const QString& callId, bool videoMuted);
/** /**
* Change the conference layout * Change the conference layout

View file

@ -348,42 +348,47 @@ CallModel::getParticipantsInfos(const QString& callId)
} }
void void
CallModel::updateCallMediaList(const QString& callId, bool acceptVideo) CallModel::setVideoMuted(const QString& callId, bool videoMuted)
{ {
try { auto call = pimpl_->calls.find(callId);
auto callInfos = pimpl_->calls.find(callId); if (call == pimpl_->calls.end())
if (callInfos != pimpl_->calls.end()) { return;
for (auto it = callInfos->second->mediaList.begin();
it != callInfos->second->mediaList.end(); auto& callInfo = call->second;
it++) { callInfo->videoMuted = videoMuted;
if ((*it)[MediaAttributeKey::MEDIA_TYPE] == MediaAttributeValue::VIDEO
&& !acceptVideo) { for (auto& media : callInfo->mediaList) {
(*it)[MediaAttributeKey::ENABLED] = TRUE_STR; if (!media.contains(MediaAttributeKey::MEDIA_TYPE))
(*it)[MediaAttributeKey::MUTED] = TRUE_STR; continue;
callInfos->second->videoMuted = !acceptVideo;
} if (media[MediaAttributeKey::MEDIA_TYPE] == MediaAttributeValue::VIDEO) {
} media[MediaAttributeKey::MUTED] = videoMuted ? TRUE_STR : FALSE_STR;
} }
} catch (...) {
} }
} }
static void
initializeMediaList(VectorMapStringString& mediaList, bool audioOnly)
{
mediaList.push_back({{MediaAttributeKey::MEDIA_TYPE, MediaAttributeValue::AUDIO},
{MediaAttributeKey::ENABLED, TRUE_STR},
{MediaAttributeKey::MUTED, FALSE_STR},
{MediaAttributeKey::SOURCE, ""},
{MediaAttributeKey::LABEL, "audio_0"}});
if (audioOnly)
return;
mediaList.push_back({{MediaAttributeKey::MEDIA_TYPE, MediaAttributeValue::VIDEO},
{MediaAttributeKey::ENABLED, TRUE_STR},
{MediaAttributeKey::MUTED, FALSE_STR},
{MediaAttributeKey::SOURCE, ""},
{MediaAttributeKey::LABEL, "video_0"}});
}
QString QString
CallModel::createCall(const QString& uri, bool isAudioOnly, VectorMapStringString mediaList) CallModel::createCall(const QString& uri, bool isAudioOnly, VectorMapStringString mediaList)
{ {
if (mediaList.isEmpty()) { if (mediaList.isEmpty()) {
MapStringString mediaAttribute = {{MediaAttributeKey::MEDIA_TYPE, initializeMediaList(mediaList, isAudioOnly);
MediaAttributeValue::AUDIO},
{MediaAttributeKey::ENABLED, TRUE_STR},
{MediaAttributeKey::MUTED, FALSE_STR},
{MediaAttributeKey::SOURCE, ""},
{MediaAttributeKey::LABEL, "audio_0"}};
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);
@ -1456,7 +1461,10 @@ CallModelPimpl::slotCallStateChanged(const QString& accountId,
callInfo->type = call::Type::DIALOG; callInfo->type = call::Type::DIALOG;
callInfo->isAudioOnly = details["AUDIO_ONLY"] == TRUE_STR; callInfo->isAudioOnly = details["AUDIO_ONLY"] == TRUE_STR;
callInfo->videoMuted = details["VIDEO_MUTED"] == TRUE_STR; callInfo->videoMuted = details["VIDEO_MUTED"] == TRUE_STR;
callInfo->mediaList = {}; // NOTE: The CallModel::setVideoMuted function currently relies on callInfo->mediaList
// having been initialized. Not doing so leads to a bug where the user's camera wrongly
// gets turned on when they receive a call and click on "Answer in audio".
initializeMediaList(callInfo->mediaList, callInfo->isAudioOnly);
calls.emplace(callId, std::move(callInfo)); calls.emplace(callId, std::move(callInfo));
if (!(details["CALL_TYPE"] == "1") && !linked.owner.confProperties.allowIncoming if (!(details["CALL_TYPE"] == "1") && !linked.owner.confProperties.allowIncoming