Commit 6d5e4c7d authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Philippe Gorley

audio: bind to audio metering api

Change-Id: I1b88605c4dd058babe98b323b5c247cb63b4a676
Reviewed-by: Philippe Gorley's avatarPhilippe Gorley <philippe.gorley@savoirfairelinux.com>
parent fce17764
......@@ -124,6 +124,24 @@ public:
* @return current input device
*/
std::string getInputDevice() const;
/**
* Get current state of the audio meter
* @return current state of the audio meter
*/
bool isAudioMeterActive(const std::string& id="") const;
/**
* Turn on/off the audio metering feature
* @param the new state of the meter
*/
void setAudioMeterState(bool active, const std::string& id="") const;
/**
* Starts audio device. Should only be invoked when outside of a call.
*/
void startAudioDevice() const;
/**
* Stops audio device. Should only be invoked when outside of a call.
*/
void stopAudioDevice() const;
/**
* Set current audio manager
* @param name of the new audio manager
......@@ -223,6 +241,12 @@ Q_SIGNALS:
* Emitted when a device is plugged or unplugged
*/
void deviceEvent();
/**
* Audio volume level
* @param id Ringbuffer id
* @param level Volume in range [0, 1]
*/
void audioMeter(const std::string& id, float level);
private:
std::unique_ptr<AVModelPimpl> pimpl_;
......
......@@ -95,6 +95,10 @@ Q_SIGNALS:
* Emitted debugMessageReceived
*/
void debugMessageReceived(const std::string& message);
/**
* Emitted audioMeter
*/
void audioMeter(const std::string& id, float level);
};
......
......@@ -114,6 +114,12 @@ public Q_SLOTS:
* Detect when a device is plugged or unplugged
*/
void slotDeviceEvent();
/**
* Audio volume level
* @param id Ringbuffer id
* @param level Volume in range [0, 1]
*/
void slotAudioMeter(const std::string& id, float level);
};
......@@ -301,6 +307,30 @@ AVModel::getInputDevice() const
return pimpl_->getDevice(INPUT_IDX);
}
bool
AVModel::isAudioMeterActive(const std::string& id) const
{
return ConfigurationManager::instance().isAudioMeterActive(id.c_str());
}
void
AVModel::setAudioMeterState(bool active, const std::string& id) const
{
ConfigurationManager::instance().setAudioMeterState(id.c_str(), active);
}
void
AVModel::startAudioDevice() const
{
VideoManager::instance().startAudioDevice();
}
void
AVModel::stopAudioDevice() const
{
VideoManager::instance().stopAudioDevice();
}
bool
AVModel::setAudioManager(const std::string& name)
{
......@@ -487,6 +517,8 @@ AVModelPimpl::init()
#endif
connect(&callbacksHandler, &CallbacksHandler::deviceEvent,
this, &AVModelPimpl::slotDeviceEvent);
connect(&callbacksHandler, &CallbacksHandler::audioMeter,
this, &AVModelPimpl::slotAudioMeter);
connect(&callbacksHandler, &CallbacksHandler::startedDecoding,
this, &AVModelPimpl::startedDecoding);
connect(&callbacksHandler, &CallbacksHandler::stoppedDecoding,
......@@ -696,6 +728,12 @@ AVModelPimpl::slotDeviceEvent()
emit linked_.deviceEvent();
}
void
AVModelPimpl::slotAudioMeter(const std::string& id, float level)
{
emit linked_.audioMeter(id, level);
}
} // namespace lrc
#include "api/moc_avmodel.cpp"
......
......@@ -206,6 +206,12 @@ CallbacksHandler::CallbacksHandler(const Lrc& parent)
this,
&CallbacksHandler::slotDeviceEvent,
Qt::QueuedConnection);
connect(&ConfigurationManager::instance(),
&ConfigurationManagerInterface::audioMeter,
this,
&CallbacksHandler::slotAudioMeterReceived,
Qt::QueuedConnection);
}
CallbacksHandler::~CallbacksHandler()
......@@ -493,5 +499,10 @@ CallbacksHandler::slotDeviceEvent()
emit deviceEvent();
}
void
CallbacksHandler::slotAudioMeterReceived(const QString& id, float level)
{
emit audioMeter(id.toStdString(), level);
}
} // namespace lrc
......@@ -176,7 +176,6 @@ Q_SIGNALS:
void transferStatusTimeoutExpired(long long dringId, api::datatransfer::Info info);
void transferStatusUnjoinable(long long dringId, api::datatransfer::Info info);
/**
* Connect this signal to get when a device name changed or a device is added
* @param accountId interaction receiver.
......@@ -253,6 +252,13 @@ Q_SIGNALS:
*/
void deviceEvent();
/**
* Emitted when an audio level is received
* @param id of the ringbuffer level
* @param level
*/
void audioMeter(const std::string& id, float level);
private Q_SLOTS:
/**
* Emit newAccountMessage
......@@ -433,8 +439,6 @@ private Q_SLOTS:
void slotDebugMessageReceived(const QString& message);
#endif
/**
* Renderer is started
* @param id
......@@ -456,6 +460,12 @@ private Q_SLOTS:
*/
void slotDeviceEvent();
/**
* Called when an audio meter level is received
* @param id of the ringbuffer level
* @param level
*/
void slotAudioMeterReceived(const QString& id, float level);
private:
const api::Lrc& parent;
......
......@@ -226,7 +226,6 @@ NewAccountModel::getAccountConfig(const std::string& accountId) const
return accountInfo->second.confProperties;
}
void
NewAccountModel::enableAccount(const std::string& accountId, bool enabled)
{
......
......@@ -152,6 +152,10 @@ public:
[this] () {
Q_EMIT this->audioDeviceEvent();
}),
exportable_callback<AudioSignal::AudioMeter>(
[this](const std::string& id, float level) {
Q_EMIT this->audioMeter(QString(id.c_str()), level);
}),
exportable_callback<ConfigurationSignal::MigrationEnded>(
[this] (const std::string& account_id, const std::string& result) {
Q_EMIT this->migrationEnded(QString(account_id.c_str()), QString(result.c_str()));
......@@ -509,6 +513,14 @@ public Q_SLOTS: // METHODS
DRing::setNoiseSuppressState(state);
}
bool isAudioMeterActive(const std::string& id) {
return DRing::isAudioMeterActive(id);
}
void setAudioMeterState(const std::string& id, bool state) {
DRing::setAudioMeterState(id, state);
}
void setRecordPath(const QString& rec) {
DRing::setRecordPath(rec.toStdString());
}
......@@ -697,6 +709,7 @@ Q_SIGNALS: // SIGNALS
void incomingAccountMessage(const QString& accountId, const QString& from, const MapStringString& payloads);
void mediaParametersChanged(const QString& accountId);
void audioDeviceEvent();
void audioMeter(const QString& id, float level);
void accountMessageStatusChanged(const QString& accountId, const uint64_t id, const QString& to, int status);
void nameRegistrationEnded(const QString& accountId, int status, const QString& name);
void registeredNameFound(const QString& accountId, int status, const QString& address, const QString& name);
......
......@@ -189,6 +189,16 @@ public Q_SLOTS: // METHODS
#endif
}
void startAudioDevice()
{
DRing::startAudioDevice();
}
void stopAudioDevice()
{
DRing::stopAudioDevice();
}
bool switchInput(const QString &resource)
{
#ifdef ENABLE_VIDEO
......
......@@ -819,6 +819,10 @@ public Q_SLOTS: // METHODS
void stopProxyClient(const std::string& /*accountID*/) { }
bool isAudioMeterActive(const std::string& /*id*/) { return false; }
void setAudioMeterState(const std::string& /*id*/, bool /*state*/) { }
Q_SIGNALS: // SIGNALS
void volumeChanged(const QString& device, double value);
void accountsChanged();
......@@ -839,6 +843,7 @@ Q_SIGNALS: // SIGNALS
void incomingAccountMessage(const QString& accountId, const QString& from, const MapStringString& payloads);
void mediaParametersChanged(const QString& accountId);
void audioDeviceEvent();
void audioMeter(const QString& id, float level);
void accountMessageStatusChanged(const QString& accountId, const uint64_t id, const QString& to, int status);
void nameRegistrationEnded(const QString& accountId, int status, const QString& name);
void registeredNameFound(const QString& accountId, int status, const QString& address, const QString& name); // used by conversationModel
......
......@@ -155,6 +155,14 @@ public Q_SLOTS: // METHODS
{
}
void startAudioDevice()
{
}
void stopAudioDevice()
{
}
bool switchInput(const QString &resource)
{
Q_UNUSED(resource)
......
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