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