From 2b4960882f1246d4da6bb81ac7948a5bb3d9cfc1 Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Fri, 4 Oct 2024 16:28:38 +0200 Subject: [PATCH] fix #LINQT-1323 fix display name account list close #LINQT-1324 display loss rate/ jitter buffer in call stats + use the correct stats (audio/video) --- Linphone/core/account/AccountCore.cpp | 10 +- Linphone/core/call/CallCore.cpp | 117 ++++++++++-------- Linphone/core/call/CallCore.hpp | 54 ++++---- .../participant/ParticipantDeviceCore.cpp | 3 +- Linphone/model/account/AccountModel.cpp | 12 +- .../Page/Form/Contact/ContactDescription.qml | 3 +- .../view/Page/Window/Call/CallsWindow.qml | 29 ++++- 7 files changed, 144 insertions(+), 84 deletions(-) diff --git a/Linphone/core/account/AccountCore.cpp b/Linphone/core/account/AccountCore.cpp index 2a95f53cc..7c2f3a281 100644 --- a/Linphone/core/account/AccountCore.cpp +++ b/Linphone/core/account/AccountCore.cpp @@ -20,6 +20,8 @@ #include "AccountCore.hpp" #include "core/App.hpp" +#include "model/object/VariantObject.hpp" +#include "model/tool/ToolModel.hpp" #include "tool/Utils.hpp" #include "tool/thread/SafeConnection.hpp" #include @@ -49,10 +51,16 @@ AccountCore::AccountCore(const std::shared_ptr &account) : QO // mUnreadNotifications = account->getUnreadChatMessageCount() + account->getMissedCallsCount(); // TODO mUnreadNotifications = account->getMissedCallsCount(); mDisplayName = Utils::coreStringToAppString(identityAddress->getDisplayName()); + if (mDisplayName.isEmpty()) { + mDisplayName = ToolModel::getDisplayName(mIdentityAddress); + } mRegisterEnabled = params->registerEnabled(); mMwiServerAddress = params->getMwiServerAddress() ? Utils::coreStringToAppString(params->getMwiServerAddress()->asString()) : ""; - mTransports << "TCP" << "UDP" << "TLS" << "DTLS"; + mTransports << "TCP" + << "UDP" + << "TLS" + << "DTLS"; mTransport = LinphoneEnums::toString(LinphoneEnums::fromLinphone(params->getTransport())); mServerAddress = params->getServerAddress() ? Utils::coreStringToAppString(params->getServerAddress()->asString()) : ""; diff --git a/Linphone/core/call/CallCore.cpp b/Linphone/core/call/CallCore.cpp index 9b62d3572..cc6342537 100644 --- a/Linphone/core/call/CallCore.cpp +++ b/Linphone/core/call/CallCore.cpp @@ -31,52 +31,59 @@ DEFINE_ABSTRACT_OBJECT(CallCore) /***********************************************************************/ ZrtpStats ZrtpStats::operator=(ZrtpStats s) { - cipherAlgorithm = s.cipherAlgorithm; - keyAgreementAlgorithm = s.keyAgreementAlgorithm; - hashAlgorithm = s.hashAlgorithm; - authenticationAlgorithm = s.authenticationAlgorithm; - sasAlgorithm = s.sasAlgorithm; - isPostQuantum = s.isPostQuantum; + mCipherAlgorithm = s.mCipherAlgorithm; + mKeyAgreementAlgorithm = s.mKeyAgreementAlgorithm; + mHashAlgorithm = s.mHashAlgorithm; + mAuthenticationAlgorithm = s.mAuthenticationAlgorithm; + mSasAlgorithm = s.mSasAlgorithm; + mIsPostQuantum = s.mIsPostQuantum; return *this; } bool ZrtpStats::operator==(ZrtpStats s) { - return s.cipherAlgorithm == cipherAlgorithm && s.keyAgreementAlgorithm == keyAgreementAlgorithm && - s.hashAlgorithm == hashAlgorithm && s.authenticationAlgorithm == authenticationAlgorithm && - s.sasAlgorithm == sasAlgorithm && s.isPostQuantum == isPostQuantum; + return s.mCipherAlgorithm == mCipherAlgorithm && s.mKeyAgreementAlgorithm == mKeyAgreementAlgorithm && + s.mHashAlgorithm == mHashAlgorithm && s.mAuthenticationAlgorithm == mAuthenticationAlgorithm && + s.mSasAlgorithm == mSasAlgorithm && s.mIsPostQuantum == mIsPostQuantum; } bool ZrtpStats::operator!=(ZrtpStats s) { - return s.cipherAlgorithm != cipherAlgorithm || s.keyAgreementAlgorithm != keyAgreementAlgorithm || - s.hashAlgorithm != hashAlgorithm || s.authenticationAlgorithm != authenticationAlgorithm || - s.sasAlgorithm != sasAlgorithm || s.isPostQuantum != isPostQuantum; + return s.mCipherAlgorithm != mCipherAlgorithm || s.mKeyAgreementAlgorithm != mKeyAgreementAlgorithm || + s.mHashAlgorithm != mHashAlgorithm || s.mAuthenticationAlgorithm != mAuthenticationAlgorithm || + s.mSasAlgorithm != mSasAlgorithm || s.mIsPostQuantum != mIsPostQuantum; } AudioStats AudioStats::operator=(AudioStats s) { - codec = s.codec; - bandwidth = s.bandwidth; + mCodec = s.mCodec; + mBandwidth = s.mBandwidth; + mJitterBufferSize = s.mJitterBufferSize; + mLossRate = s.mLossRate; return *this; } bool AudioStats::operator==(AudioStats s) { - return s.codec == codec && s.bandwidth == bandwidth; + return s.mCodec == mCodec && s.mBandwidth == mBandwidth && s.mLossRate == mLossRate && + s.mJitterBufferSize == mJitterBufferSize; } bool AudioStats::operator!=(AudioStats s) { - return s.codec != codec || s.bandwidth != bandwidth; + return s.mCodec != mCodec || s.mBandwidth != mBandwidth || s.mLossRate != mLossRate || + s.mJitterBufferSize != mJitterBufferSize; } VideoStats VideoStats::operator=(VideoStats s) { - codec = s.codec; - bandwidth = s.bandwidth; - resolution = s.resolution; - fps = s.fps; + mCodec = s.mCodec; + mBandwidth = s.mBandwidth; + mResolution = s.mResolution; + mFps = s.mFps; + mLossRate = s.mLossRate; return *this; } bool VideoStats::operator==(VideoStats s) { - return s.codec == codec && s.bandwidth == bandwidth && s.resolution == resolution && s.fps == fps; + return s.mCodec == mCodec && s.mBandwidth == mBandwidth && s.mResolution == mResolution && s.mFps == mFps && + s.mLossRate == mLossRate; } bool VideoStats::operator!=(VideoStats s) { - return s.codec != codec || s.bandwidth != bandwidth || s.resolution != resolution || s.fps != fps; + return s.mCodec != mCodec || s.mBandwidth != mBandwidth || s.mResolution != mResolution || s.mFps != mFps || + s.mLossRate != mLossRate; } /***********************************************************************/ @@ -128,11 +135,11 @@ CallCore::CallCore(const std::shared_ptr &call) : QObject(nullpt if (mEncryption == LinphoneEnums::MediaEncryption::Zrtp) { auto stats = call->getStats(linphone::StreamType::Audio); if (stats) { - mZrtpStats.cipherAlgorithm = Utils::coreStringToAppString(stats->getZrtpCipherAlgo()); - mZrtpStats.keyAgreementAlgorithm = Utils::coreStringToAppString(stats->getZrtpKeyAgreementAlgo()); - mZrtpStats.hashAlgorithm = Utils::coreStringToAppString(stats->getZrtpHashAlgo()); - mZrtpStats.authenticationAlgorithm = Utils::coreStringToAppString(stats->getZrtpAuthTagAlgo()); - mZrtpStats.sasAlgorithm = Utils::coreStringToAppString(stats->getZrtpSasAlgo()); + mZrtpStats.mCipherAlgorithm = Utils::coreStringToAppString(stats->getZrtpCipherAlgo()); + mZrtpStats.mKeyAgreementAlgorithm = Utils::coreStringToAppString(stats->getZrtpKeyAgreementAlgo()); + mZrtpStats.mHashAlgorithm = Utils::coreStringToAppString(stats->getZrtpHashAlgo()); + mZrtpStats.mAuthenticationAlgorithm = Utils::coreStringToAppString(stats->getZrtpAuthTagAlgo()); + mZrtpStats.mSasAlgorithm = Utils::coreStringToAppString(stats->getZrtpSasAlgo()); } } auto conference = call->getConference(); @@ -320,11 +327,11 @@ void CallCore::setSelf(QSharedPointer me) { if (mediaEncryption == linphone::MediaEncryption::ZRTP) { auto stats = call->getAudioStats(); ZrtpStats zrtpStats; - zrtpStats.cipherAlgorithm = Utils::coreStringToAppString(stats->getZrtpCipherAlgo()); - zrtpStats.keyAgreementAlgorithm = Utils::coreStringToAppString(stats->getZrtpKeyAgreementAlgo()); - zrtpStats.hashAlgorithm = Utils::coreStringToAppString(stats->getZrtpHashAlgo()); - zrtpStats.authenticationAlgorithm = Utils::coreStringToAppString(stats->getZrtpAuthTagAlgo()); - zrtpStats.sasAlgorithm = Utils::coreStringToAppString(stats->getZrtpSasAlgo()); + zrtpStats.mCipherAlgorithm = Utils::coreStringToAppString(stats->getZrtpCipherAlgo()); + zrtpStats.mKeyAgreementAlgorithm = Utils::coreStringToAppString(stats->getZrtpKeyAgreementAlgo()); + zrtpStats.mHashAlgorithm = Utils::coreStringToAppString(stats->getZrtpHashAlgo()); + zrtpStats.mAuthenticationAlgorithm = Utils::coreStringToAppString(stats->getZrtpAuthTagAlgo()); + zrtpStats.mSasAlgorithm = Utils::coreStringToAppString(stats->getZrtpSasAlgo()); mCallModelConnection->invokeToCore([this, zrtpStats]() { setZrtpStats(zrtpStats); }); } }); @@ -403,13 +410,20 @@ void CallCore::setSelf(QSharedPointer me) { auto playloadType = call->getCurrentParams()->getUsedAudioPayloadType(); auto codecType = playloadType ? playloadType->getMimeType() : ""; auto codecRate = playloadType ? playloadType->getClockRate() / 1000 : 0; - audioStats.codec = tr("Codec: %1 / %2 kHz").arg(Utils::coreStringToAppString(codecType)).arg(codecRate); - if (stats) { - audioStats.bandwidth = tr("Bande passante : %1 %2 %3 %4") - .arg("↑") - .arg(stats->getUploadBandwidth()) - .arg("↓") - .arg(stats->getDownloadBandwidth()); + audioStats.mCodec = + tr("Codec: %1 / %2 kHz").arg(Utils::coreStringToAppString(codecType)).arg(codecRate); + auto linAudioStats = call->getAudioStats(); + if (linAudioStats) { + audioStats.mBandwidth = tr("Bande passante : %1 %2 %3 %4") + .arg("↑") + .arg(linAudioStats->getUploadBandwidth()) + .arg("↓") + .arg(linAudioStats->getDownloadBandwidth()); + audioStats.mLossRate = tr("Taux de perte: %1 \% %2 \%") + .arg(linAudioStats->getSenderLossRate()) + .arg(linAudioStats->getReceiverLossRate()); + audioStats.mJitterBufferSize = + tr("Tampon de gigue: %1 ms").arg(linAudioStats->getJitterBufferSizeMs()); } setAudioStats(audioStats); } else if (stats->getType() == linphone::StreamType::Video) { @@ -418,24 +432,29 @@ void CallCore::setSelf(QSharedPointer me) { auto playloadType = params->getUsedVideoPayloadType(); auto codecType = playloadType ? playloadType->getMimeType() : ""; auto codecRate = playloadType ? playloadType->getClockRate() / 1000 : 0; - videoStats.codec = tr("Codec: %1 / %2 kHz").arg(Utils::coreStringToAppString(codecType)).arg(codecRate); + videoStats.mCodec = + tr("Codec: %1 / %2 kHz").arg(Utils::coreStringToAppString(codecType)).arg(codecRate); + auto linVideoStats = call->getVideoStats(); if (stats) { - videoStats.bandwidth = tr("Bande passante : %1 %2 %3 %4") - .arg("↑") - .arg(stats->getUploadBandwidth()) - .arg("↓") - .arg(stats->getDownloadBandwidth()); + videoStats.mBandwidth = tr("Bande passante : %1 %2 %3 %4") + .arg("↑") + .arg(linVideoStats->getUploadBandwidth()) + .arg("↓") + .arg(linVideoStats->getDownloadBandwidth()); + videoStats.mLossRate = tr("Taux de perte: %1 \% %2 \%") + .arg(linVideoStats->getSenderLossRate()) + .arg(linVideoStats->getReceiverLossRate()); } auto sentResolution = params->getSentVideoDefinition() ? params->getSentVideoDefinition()->getName() : ""; auto receivedResolution = params->getReceivedVideoDefinition() ? params->getReceivedVideoDefinition()->getName() : ""; - videoStats.resolution = tr("Définition vidéo : %1 %2 %3 %4") - .arg("↑", Utils::coreStringToAppString(sentResolution), "↓", - Utils::coreStringToAppString(receivedResolution)); + videoStats.mResolution = tr("Définition vidéo : %1 %2 %3 %4") + .arg("↑", Utils::coreStringToAppString(sentResolution), "↓", + Utils::coreStringToAppString(receivedResolution)); auto sentFps = params->getSentFramerate(); auto receivedFps = params->getReceivedFramerate(); - videoStats.fps = tr("FPS : %1 %2 %3 %4").arg("↑").arg(sentFps).arg("↓").arg(receivedFps); + videoStats.mFps = tr("FPS : %1 %2 %3 %4").arg("↑").arg(sentFps).arg("↓").arg(receivedFps); setVideoStats(videoStats); } }); diff --git a/Linphone/core/call/CallCore.hpp b/Linphone/core/call/CallCore.hpp index 71eab460a..38cad83d2 100644 --- a/Linphone/core/call/CallCore.hpp +++ b/Linphone/core/call/CallCore.hpp @@ -34,19 +34,19 @@ struct ZrtpStats { Q_GADGET - Q_PROPERTY(QString cipherAlgo MEMBER cipherAlgorithm) - Q_PROPERTY(QString keyAgreementAlgo MEMBER keyAgreementAlgorithm) - Q_PROPERTY(QString hashAlgo MEMBER hashAlgorithm) - Q_PROPERTY(QString authenticationAlgo MEMBER authenticationAlgorithm) - Q_PROPERTY(QString sasAlgo MEMBER sasAlgorithm) - Q_PROPERTY(bool isPostQuantum MEMBER isPostQuantum) + Q_PROPERTY(QString cipherAlgo MEMBER mCipherAlgorithm) + Q_PROPERTY(QString keyAgreementAlgo MEMBER mKeyAgreementAlgorithm) + Q_PROPERTY(QString hashAlgo MEMBER mHashAlgorithm) + Q_PROPERTY(QString authenticationAlgo MEMBER mAuthenticationAlgorithm) + Q_PROPERTY(QString sasAlgo MEMBER mSasAlgorithm) + Q_PROPERTY(bool isPostQuantum MEMBER mIsPostQuantum) public: - bool isPostQuantum = false; - QString cipherAlgorithm; - QString keyAgreementAlgorithm; - QString hashAlgorithm; - QString authenticationAlgorithm; - QString sasAlgorithm; + bool mIsPostQuantum = false; + QString mCipherAlgorithm; + QString mKeyAgreementAlgorithm; + QString mHashAlgorithm; + QString mAuthenticationAlgorithm; + QString mSasAlgorithm; ZrtpStats operator=(ZrtpStats s); bool operator==(ZrtpStats s); @@ -55,12 +55,16 @@ public: struct AudioStats { Q_GADGET - Q_PROPERTY(QString codec MEMBER codec) - Q_PROPERTY(QString bandwidth MEMBER bandwidth) + Q_PROPERTY(QString codec MEMBER mCodec) + Q_PROPERTY(QString bandwidth MEMBER mBandwidth) + Q_PROPERTY(QString lossRate MEMBER mLossRate) + Q_PROPERTY(QString jitterBufferSize MEMBER mJitterBufferSize) public: - QString codec; - QString bandwidth; + QString mCodec; + QString mBandwidth; + QString mLossRate; + QString mJitterBufferSize; AudioStats operator=(AudioStats s); @@ -70,16 +74,18 @@ public: struct VideoStats { Q_GADGET - Q_PROPERTY(QString codec MEMBER codec) - Q_PROPERTY(QString bandwidth MEMBER bandwidth) - Q_PROPERTY(QString resolution MEMBER resolution) - Q_PROPERTY(QString fps MEMBER fps) + Q_PROPERTY(QString codec MEMBER mCodec) + Q_PROPERTY(QString bandwidth MEMBER mBandwidth) + Q_PROPERTY(QString resolution MEMBER mResolution) + Q_PROPERTY(QString fps MEMBER mFps) + Q_PROPERTY(QString lossRate MEMBER mLossRate) public: - QString codec; - QString bandwidth; - QString resolution; - QString fps; + QString mCodec; + QString mBandwidth; + QString mResolution; + QString mFps; + QString mLossRate; VideoStats operator=(VideoStats s); bool operator==(VideoStats s); diff --git a/Linphone/core/participant/ParticipantDeviceCore.cpp b/Linphone/core/participant/ParticipantDeviceCore.cpp index d104b72d1..42b70319b 100644 --- a/Linphone/core/participant/ParticipantDeviceCore.cpp +++ b/Linphone/core/participant/ParticipantDeviceCore.cpp @@ -48,8 +48,7 @@ ParticipantDeviceCore::ParticipantDeviceCore(const std::shared_ptrasStringUriOnly()); mDisplayName = Utils::coreStringToAppString(deviceAddress->getDisplayName()); if (mDisplayName.isEmpty()) { - auto name = Utils::getDisplayName(mAddress); - if (name) mDisplayName = name->getValue().toString(); + mDisplayName = ToolModel::getDisplayName(mAddress); } mIsMuted = device->getIsMuted(); mIsMe = isMe; diff --git a/Linphone/model/account/AccountModel.cpp b/Linphone/model/account/AccountModel.cpp index 871e5a7e2..7c8f15919 100644 --- a/Linphone/model/account/AccountModel.cpp +++ b/Linphone/model/account/AccountModel.cpp @@ -36,8 +36,11 @@ AccountModel::AccountModel(const std::shared_ptr &account, QO &AccountModel::onDefaultAccountChanged); // Hack because Account doesn't provide callbacks on updated data - connect(this, &AccountModel::defaultAccountChanged, this, - [this]() { emit pictureUriChanged(Utils::coreStringToAppString(mMonitor->getParams()->getPictureUri())); }); + connect(this, &AccountModel::defaultAccountChanged, this, [this]() { + emit pictureUriChanged(Utils::coreStringToAppString(mMonitor->getParams()->getPictureUri())); + emit displayNameChanged( + Utils::coreStringToAppString(mMonitor->getParams()->getIdentityAddress()->getDisplayName())); + }); connect(CoreModel::getInstance().get(), &CoreModel::unreadNotificationsChanged, this, [this]() { emit unreadNotificationsChanged(0 /*mMonitor->getUnreadChatMessageCount()*/, @@ -132,7 +135,10 @@ void AccountModel::setDisplayName(QString displayName) { address->setDisplayName(Utils::appStringToCoreString(displayName)); params->setIdentityAddress(address); mMonitor->setParams(params); - emit displayNameChanged(displayName); + // Hack because Account doesn't provide callbacks on updated data + // emit displayNameChanged(displayName); + auto core = CoreModel::getInstance()->getCore(); + emit CoreModel::getInstance()->defaultAccountChanged(core, core->getDefaultAccount()); } void AccountModel::setDialPlan(int index) { diff --git a/Linphone/view/Page/Form/Contact/ContactDescription.qml b/Linphone/view/Page/Form/Contact/ContactDescription.qml index 89e562fc7..83261a26a 100644 --- a/Linphone/view/Page/Form/Contact/ContactDescription.qml +++ b/Linphone/view/Page/Form/Contact/ContactDescription.qml @@ -9,8 +9,7 @@ import SettingsCpp ColumnLayout{ id: mainItem property AccountGui account: null - property var displayName: account ? UtilsCpp.getDisplayName(account.core.identityAddress) : "" - property string topText: displayName ? displayName.value : "" + property string topText: account ? account.core.displayName : "" property string bottomText: account ? SettingsCpp.onlyDisplaySipUriUsername ? UtilsCpp.getUsername(account.core.identityAddress) : account.core.identityAddress : "" spacing: 0 width: topTextItem.implicitWidth diff --git a/Linphone/view/Page/Window/Call/CallsWindow.qml b/Linphone/view/Page/Window/Call/CallsWindow.qml index 2eebdc5dd..4865c0f61 100644 --- a/Linphone/view/Page/Window/Call/CallsWindow.qml +++ b/Linphone/view/Page/Window/Call/CallsWindow.qml @@ -1189,7 +1189,7 @@ AbstractWindow { } } ColumnLayout { - spacing: 7 * DefaultStyle.dp + spacing: 8 * DefaultStyle.dp Layout.alignment: Qt.AlignHCenter Text { text: mainWindow.call ? mainWindow.call.core.audioStats.codec : "" @@ -1207,6 +1207,22 @@ AbstractWindow { weight: 500 * DefaultStyle.dp } } + Text { + text: mainWindow.call ? mainWindow.call.core.audioStats.lossRate : "" + Layout.alignment: Qt.AlignHCenter + font { + pixelSize: 12 * DefaultStyle.dp + weight: 500 * DefaultStyle.dp + } + } + Text { + text: mainWindow.call ? mainWindow.call.core.audioStats.jitterBufferSize : "" + Layout.alignment: Qt.AlignHCenter + font { + pixelSize: 12 * DefaultStyle.dp + weight: 500 * DefaultStyle.dp + } + } } } } @@ -1217,7 +1233,6 @@ AbstractWindow { topPadding: 13 * DefaultStyle.dp bottomPadding: 13 * DefaultStyle.dp - Layout.topMargin: 13 * DefaultStyle.dp Layout.leftMargin: 16 * DefaultStyle.dp Layout.rightMargin: 16 * DefaultStyle.dp @@ -1235,7 +1250,7 @@ AbstractWindow { } } ColumnLayout { - spacing: 7 * DefaultStyle.dp + spacing: 8 * DefaultStyle.dp Layout.alignment: Qt.AlignHCenter Text { text: mainWindow.call ? mainWindow.call.core.videoStats.codec : "" @@ -1253,6 +1268,14 @@ AbstractWindow { weight: 500 * DefaultStyle.dp } } + Text { + text: mainWindow.call ? mainWindow.call.core.videoStats.lossRate : "" + Layout.alignment: Qt.AlignHCenter + font { + pixelSize: 12 * DefaultStyle.dp + weight: 500 * DefaultStyle.dp + } + } Text { text: mainWindow.call ? mainWindow.call.core.videoStats.resolution : "" Layout.alignment: Qt.AlignHCenter