Commit c006d526 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(src/utils/LinphoneUtils): provide a `computeVu` function

parent 8a888707
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <QTimer> #include <QTimer>
#include "../../app/App.hpp" #include "../../app/App.hpp"
#include "../../utils/LinphoneUtils.hpp"
#include "../../utils/Utils.hpp" #include "../../utils/Utils.hpp"
#include "../core/CoreManager.hpp" #include "../core/CoreManager.hpp"
...@@ -376,27 +377,12 @@ float CallModel::getQuality () const { ...@@ -376,27 +377,12 @@ float CallModel::getQuality () const {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#define VU_MIN (-20.f)
#define VU_MAX (4.f)
inline float computeVu (float volume) {
if (volume < VU_MIN)
return 0.f;
if (volume > VU_MAX)
return 1.f;
return (volume - VU_MIN) / (VU_MAX - VU_MIN);
}
#undef VU_MIN
#undef VU_MAX
float CallModel::getMicroVu () const { float CallModel::getMicroVu () const {
return computeVu(mCall->getRecordVolume()); return LinphoneUtils::computeVu(mCall->getRecordVolume());
} }
float CallModel::getSpeakerVu () const { float CallModel::getSpeakerVu () const {
return computeVu(mCall->getPlayVolume()); return LinphoneUtils::computeVu(mCall->getPlayVolume());
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <QDateTime> #include <QDateTime>
#include "../../utils/LinphoneUtils.hpp"
#include "../../utils/Utils.hpp" #include "../../utils/Utils.hpp"
#include "../core/CoreManager.hpp" #include "../core/CoreManager.hpp"
...@@ -123,35 +124,20 @@ bool ConferenceModel::getRecording () const { ...@@ -123,35 +124,20 @@ bool ConferenceModel::getRecording () const {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#define VU_MIN (-20.f)
#define VU_MAX (4.f)
inline float computeVu (float volume) {
if (volume < VU_MIN)
return 0.f;
if (volume > VU_MAX)
return 1.f;
return (volume - VU_MIN) / (VU_MAX - VU_MIN);
}
#undef VU_MIN
#undef VU_MAX
float ConferenceModel::getMicroVu () const { float ConferenceModel::getMicroVu () const {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
return computeVu(core->getConferenceLocalInputVolume()); return LinphoneUtils::computeVu(core->getConferenceLocalInputVolume());
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void ConferenceModel::leave() { void ConferenceModel::leave () {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
core->leaveConference(); core->leaveConference();
emit conferenceChanged(); emit conferenceChanged();
} }
void ConferenceModel::join() { void ConferenceModel::join () {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore(); shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
core->enterConference(); core->enterConference();
emit conferenceChanged(); emit conferenceChanged();
......
...@@ -28,8 +28,23 @@ ...@@ -28,8 +28,23 @@
// ============================================================================= // =============================================================================
#define VU_MIN (-20.f)
#define VU_MAX (4.f)
namespace LinphoneUtils { namespace LinphoneUtils {
inline float computeVu (float volume) {
if (volume < VU_MIN)
return 0.f;
if (volume > VU_MAX)
return 1.f;
return (volume - VU_MIN) / (VU_MAX - VU_MIN);
}
linphone::TransportType stringToTransportType (const QString &transport); linphone::TransportType stringToTransportType (const QString &transport);
} }
#undef VU_MIN
#undef VU_MAX
#endif // ifndef LINPHONE_UTILS_H_ #endif // ifndef LINPHONE_UTILS_H_
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