Skip to content
Snippets Groups Projects
Unverified Commit 3e6e9038 authored by Sébastien Blin's avatar Sébastien Blin
Browse files

newcodecmodel: reload active codecs after setActiveCodecs

Change-Id: I5d245f6d6841ed3f856a09f799e7d6b047062a35
parent 95271254
No related branches found
No related tags found
No related merge requests found
...@@ -44,6 +44,9 @@ public: ...@@ -44,6 +44,9 @@ public:
NewCodecModelPimpl(const NewCodecModel& linked, const CallbacksHandler& callbacksHandler); NewCodecModelPimpl(const NewCodecModel& linked, const CallbacksHandler& callbacksHandler);
~NewCodecModelPimpl(); ~NewCodecModelPimpl();
void loadFromDaemon();
QVector<unsigned int> codecsList_;
std::list<Codec> videoCodecs; std::list<Codec> videoCodecs;
std::mutex audioCodecsMtx; std::mutex audioCodecsMtx;
std::list<Codec> audioCodecs; std::list<Codec> audioCodecs;
...@@ -144,11 +147,6 @@ NewCodecModel::enable(const unsigned int& codecId, bool enabled) ...@@ -144,11 +147,6 @@ NewCodecModel::enable(const unsigned int& codecId, bool enabled)
} }
if (allDisabled) { if (allDisabled) {
redraw = true; redraw = true;
// Disabling all codecs is not possible and the daemon set enabled all codecs here
// So, set all codecs enabled
for (auto& codec : pimpl_->videoCodecs) {
codec.enabled = true;
}
} }
} }
if (isAudio) { if (isAudio) {
...@@ -165,11 +163,6 @@ NewCodecModel::enable(const unsigned int& codecId, bool enabled) ...@@ -165,11 +163,6 @@ NewCodecModel::enable(const unsigned int& codecId, bool enabled)
} }
if (allDisabled) { if (allDisabled) {
redraw = true; redraw = true;
// Disabling all codecs is not possible and the daemon set enabled all codecs here
// So, set all codecs enabled
for (auto& codec : pimpl_->audioCodecs) {
codec.enabled = true;
}
} }
} }
pimpl_->setActiveCodecs(); pimpl_->setActiveCodecs();
...@@ -275,22 +268,36 @@ NewCodecModelPimpl::NewCodecModelPimpl(const NewCodecModel& linked, const Callba ...@@ -275,22 +268,36 @@ NewCodecModelPimpl::NewCodecModelPimpl(const NewCodecModel& linked, const Callba
: linked(linked) : linked(linked)
, callbacksHandler(callbacksHandler) , callbacksHandler(callbacksHandler)
{ {
QVector<unsigned int> codecsList = ConfigurationManager::instance().getCodecList(); codecsList_ = ConfigurationManager::instance().getCodecList();
loadFromDaemon();
}
NewCodecModelPimpl::~NewCodecModelPimpl()
{
}
void
NewCodecModelPimpl::loadFromDaemon()
{
{
std::unique_lock<std::mutex> lock(audioCodecsMtx);
audioCodecs.clear();
}
{
std::unique_lock<std::mutex> lock(videoCodecsMtx);
videoCodecs.clear();
}
QVector<unsigned int> activeCodecs = ConfigurationManager::instance().getActiveCodecList(linked.owner.id.c_str()); QVector<unsigned int> activeCodecs = ConfigurationManager::instance().getActiveCodecList(linked.owner.id.c_str());
for (const auto& id : activeCodecs) { for (const auto& id : activeCodecs) {
addCodec(id, activeCodecs); addCodec(id, activeCodecs);
} }
for (const auto& id : codecsList) { for (const auto& id : codecsList_) {
if (activeCodecs.indexOf(id) != -1) continue; if (activeCodecs.indexOf(id) != -1) continue;
addCodec(id, activeCodecs); addCodec(id, activeCodecs);
} }
} }
NewCodecModelPimpl::~NewCodecModelPimpl()
{
}
void void
NewCodecModelPimpl::setActiveCodecs() NewCodecModelPimpl::setActiveCodecs()
{ {
...@@ -312,6 +319,8 @@ NewCodecModelPimpl::setActiveCodecs() ...@@ -312,6 +319,8 @@ NewCodecModelPimpl::setActiveCodecs()
} }
} }
ConfigurationManager::instance().setActiveCodecList(linked.owner.id.c_str(), enabledCodecs); ConfigurationManager::instance().setActiveCodecList(linked.owner.id.c_str(), enabledCodecs);
// Refresh list from daemon
loadFromDaemon();
} }
void void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment