Commit 39a8ee9f authored by Ronan Abhamon's avatar Ronan Abhamon

feat(src/components/codecs): supports codecs ordering

parent 71d2c9aa
......@@ -23,6 +23,7 @@
#include <linphone++/linphone.hh>
#include "../../utils.hpp"
#include "../core/CoreManager.hpp"
#include "AbstractCodecsModel.hpp"
......@@ -96,6 +97,7 @@ bool AbstractCodecsModel::moveRows (
beginMoveRows(source_parent, source_row, limit, destination_parent, destination_child);
// Update UI.
if (destination_child > source_row) {
--destination_child;
for (int i = source_row; i <= limit; ++i) {
......@@ -106,6 +108,12 @@ bool AbstractCodecsModel::moveRows (
m_codecs.move(source_row + i - source_row, destination_child + i - source_row);
}
// Update linphone codecs list.
list<shared_ptr<linphone::PayloadType> > codecs;
for (const auto &map : m_codecs)
codecs.push_back(map.value("__codec").value<shared_ptr<linphone::PayloadType> >());
updateCodecs(codecs);
endMoveRows();
return true;
......
......@@ -59,6 +59,8 @@ protected:
void addCodec (std::shared_ptr<linphone::PayloadType> &codec);
virtual void updateCodecs (std::list<std::shared_ptr<linphone::PayloadType> > &codecs) = 0;
private:
QList<QVariantMap> m_codecs;
};
......
......@@ -24,9 +24,15 @@
#include "AudioCodecsModel.hpp"
using namespace std;
// =============================================================================
AudioCodecsModel::AudioCodecsModel (QObject *parent) : AbstractCodecsModel(parent) {
for (auto &codec : CoreManager::getInstance()->getCore()->getAudioPayloadTypes())
addCodec(codec);
}
void AudioCodecsModel::updateCodecs (list<shared_ptr<linphone::PayloadType> > &codecs) {
CoreManager::getInstance()->getCore()->setAudioPayloadTypes(codecs);
}
......@@ -33,6 +33,9 @@ class AudioCodecsModel : public AbstractCodecsModel {
public:
AudioCodecsModel (QObject *parent = Q_NULLPTR);
~AudioCodecsModel () = default;
protected:
void updateCodecs (std::list<std::shared_ptr<linphone::PayloadType> > &codecs) override;
};
#endif // AUDIO_CODECS_MODEL_H_
......@@ -24,9 +24,15 @@
#include "VideoCodecsModel.hpp"
using namespace std;
// =============================================================================
VideoCodecsModel::VideoCodecsModel (QObject *parent) : AbstractCodecsModel(parent) {
for (auto &codec : CoreManager::getInstance()->getCore()->getVideoPayloadTypes())
addCodec(codec);
}
void VideoCodecsModel::updateCodecs (list<shared_ptr<linphone::PayloadType> > &codecs) {
CoreManager::getInstance()->getCore()->setVideoPayloadTypes(codecs);
}
......@@ -33,6 +33,9 @@ class VideoCodecsModel : public AbstractCodecsModel {
public:
VideoCodecsModel (QObject *parent = Q_NULLPTR);
~VideoCodecsModel () = default;
protected:
void updateCodecs (std::list<std::shared_ptr<linphone::PayloadType> > &codecs) override;
};
#endif // VIDEO_CODECS_MODEL_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