Commit c006d526 authored by Ronan Abhamon's avatar Ronan Abhamon

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

parent 8a888707
......@@ -25,6 +25,7 @@
#include <QTimer>
#include "../../app/App.hpp"
#include "../../utils/LinphoneUtils.hpp"
#include "../../utils/Utils.hpp"
#include "../core/CoreManager.hpp"
......@@ -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 {
return computeVu(mCall->getRecordVolume());
return LinphoneUtils::computeVu(mCall->getRecordVolume());
}
float CallModel::getSpeakerVu () const {
return computeVu(mCall->getPlayVolume());
return LinphoneUtils::computeVu(mCall->getPlayVolume());
}
// -----------------------------------------------------------------------------
......
......@@ -22,6 +22,7 @@
#include <QDateTime>
#include "../../utils/LinphoneUtils.hpp"
#include "../../utils/Utils.hpp"
#include "../core/CoreManager.hpp"
......@@ -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 {
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();
core->leaveConference();
emit conferenceChanged();
}
void ConferenceModel::join() {
void ConferenceModel::join () {
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
core->enterConference();
emit conferenceChanged();
......@@ -167,4 +153,4 @@ bool ConferenceModel::isInConference () const {
void ConferenceModel::handleCallStateChanged (const shared_ptr<linphone::Call> &call, linphone::CallState state) {
emit conferenceChanged();
}
\ No newline at end of file
}
......@@ -28,8 +28,23 @@
// =============================================================================
#define VU_MIN (-20.f)
#define VU_MAX (4.f)
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);
}
#undef VU_MIN
#undef VU_MAX
#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