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

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

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