From 72c1b0a5254f676e654eeaec28bbf93a0a921510 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Fri, 12 Oct 2018 16:48:07 +0200 Subject: [PATCH] feat(CallModel): speaker and microphone can be muted --- src/components/call/CallModel.cpp | 45 ++++++++++++++++--------------- src/components/call/CallModel.hpp | 12 ++++----- ui/views/App/Calls/Incall.qml | 4 +-- 3 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/components/call/CallModel.cpp b/src/components/call/CallModel.cpp index d5d695c0e..6effeff1a 100644 --- a/src/components/call/CallModel.cpp +++ b/src/components/call/CallModel.cpp @@ -147,7 +147,7 @@ float CallModel::getSpeakerVolumeGain () const { void CallModel::setSpeakerVolumeGain (float volume) { Q_ASSERT(volume >= 0.0f && volume <= 1.0f); mCall->setSpeakerVolumeGain(volume); - emit speakerVolumeGainChanged(mCall->getSpeakerVolumeGain()); + emit speakerVolumeGainChanged(getSpeakerVolumeGain()); } float CallModel::getMicroVolumeGain () const { @@ -157,7 +157,7 @@ float CallModel::getMicroVolumeGain () const { void CallModel::setMicroVolumeGain (float volume) { Q_ASSERT(volume >= 0.0f && volume <= 1.0f); mCall->setMicrophoneVolumeGain(volume); - emit microVolumeGainChanged(mCall->getMicrophoneVolumeGain()); + emit microVolumeGainChanged(getMicroVolumeGain()); } // ----------------------------------------------------------------------------- @@ -468,39 +468,40 @@ float CallModel::getQuality () const { // ----------------------------------------------------------------------------- +float CallModel::getSpeakerVu () const { + return LinphoneUtils::computeVu(mCall->getPlayVolume()); +} + float CallModel::getMicroVu () const { return LinphoneUtils::computeVu(mCall->getRecordVolume()); } -float CallModel::getSpeakerVu () const { - return LinphoneUtils::computeVu(mCall->getPlayVolume()); +// ----------------------------------------------------------------------------- + +bool CallModel::getSpeakerMuted () const { + return mCall->getSpeakerMuted(); +} + +void CallModel::setSpeakerMuted (bool status) { + if (status == getSpeakerMuted()) + return; + + mCall->setSpeakerMuted(status); + emit speakerMutedChanged(getSpeakerMuted()); } // ----------------------------------------------------------------------------- bool CallModel::getMicroMuted () const { - return !CoreManager::getInstance()->getCore()->micEnabled(); + return mCall->getMicrophoneMuted(); } void CallModel::setMicroMuted (bool status) { - shared_ptr core = CoreManager::getInstance()->getCore(); + if (status == getMicroMuted()) + return; - if (status == core->micEnabled()) { - core->enableMic(!status); - emit microMutedChanged(status); - } -} - -// ----------------------------------------------------------------------------- - -bool CallModel::getAudioMuted () const { - // TODO - return false; -} - -void CallModel::setAudioMuted (bool status) { - // TODO - emit audioMutedChanged(status); + mCall->setMicrophoneMuted(status); + emit microMutedChanged(getMicroMuted()); } // ----------------------------------------------------------------------------- diff --git a/src/components/call/CallModel.hpp b/src/components/call/CallModel.hpp index 8536743dd..a8b394349 100644 --- a/src/components/call/CallModel.hpp +++ b/src/components/call/CallModel.hpp @@ -43,11 +43,11 @@ class CallModel : public QObject { Q_PROPERTY(int duration READ getDuration CONSTANT); // Constants but called with a timer in qml. Q_PROPERTY(float quality READ getQuality CONSTANT); - Q_PROPERTY(float microVu READ getMicroVu CONSTANT); Q_PROPERTY(float speakerVu READ getSpeakerVu CONSTANT); + Q_PROPERTY(float microVu READ getMicroVu CONSTANT); + Q_PROPERTY(bool speakerMuted READ getSpeakerMuted WRITE setSpeakerMuted NOTIFY speakerMutedChanged); Q_PROPERTY(bool microMuted READ getMicroMuted WRITE setMicroMuted NOTIFY microMutedChanged); - Q_PROPERTY(bool audioMuted READ getAudioMuted WRITE setAudioMuted NOTIFY audioMutedChanged); Q_PROPERTY(bool pausedByUser READ getPausedByUser WRITE setPausedByUser NOTIFY statusChanged); Q_PROPERTY(bool videoEnabled READ getVideoEnabled WRITE setVideoEnabled NOTIFY statusChanged); @@ -131,8 +131,8 @@ public: signals: void callErrorChanged (const QString &callError); void isInConferenceChanged (bool status); + void speakerMutedChanged (bool status); void microMutedChanged (bool status); - void audioMutedChanged (bool status); void recordingChanged (bool status); void statsUpdated (); void statusChanged (CallStatus status); @@ -169,12 +169,12 @@ private: float getMicroVu () const; float getSpeakerVu () const; + bool getSpeakerMuted () const; + void setSpeakerMuted (bool status); + bool getMicroMuted () const; void setMicroMuted (bool status); - bool getAudioMuted () const; - void setAudioMuted (bool status); - bool getPausedByUser () const; void setPausedByUser (bool status); diff --git a/ui/views/App/Calls/Incall.qml b/ui/views/App/Calls/Incall.qml index 2b454e378..0e6d9c9af 100644 --- a/ui/views/App/Calls/Incall.qml +++ b/ui/views/App/Calls/Incall.qml @@ -336,11 +336,11 @@ Rectangle { ActionSwitch { id: speaker - enabled: !call.audioMuted + enabled: !call.speakerMuted icon: 'speaker' iconSize: CallStyle.actionArea.iconSize - onClicked: incall.call.audioMuted = enabled + onClicked: incall.call.speakerMuted = enabled } }