Commit b146db24 authored by Wescoeur's avatar Wescoeur

feat(src/components/codecs): in progress

parent d38c41cf
...@@ -86,12 +86,15 @@ set(SOURCES ...@@ -86,12 +86,15 @@ set(SOURCES
src/app/providers/AvatarProvider.cpp src/app/providers/AvatarProvider.cpp
src/app/providers/ThumbnailProvider.cpp src/app/providers/ThumbnailProvider.cpp
src/app/translator/DefaultTranslator.cpp src/app/translator/DefaultTranslator.cpp
src/components/camera/Camera.cpp
src/components/camera/MSFunctions.cpp
src/components/call/CallModel.cpp src/components/call/CallModel.cpp
src/components/calls/CallsListModel.cpp src/components/calls/CallsListModel.cpp
src/components/camera/Camera.cpp
src/components/camera/MSFunctions.cpp
src/components/chat/ChatModel.cpp src/components/chat/ChatModel.cpp
src/components/chat/ChatProxyModel.cpp src/components/chat/ChatProxyModel.cpp
src/components/codecs/CodecsModel.cpp
src/components/codecs/AudioCodecsModel.cpp
src/components/codecs/VideoCodecsModel.cpp
src/components/contact/ContactModel.cpp src/components/contact/ContactModel.cpp
src/components/contact/VcardModel.cpp src/components/contact/VcardModel.cpp
src/components/contacts/ContactsListModel.cpp src/components/contacts/ContactsListModel.cpp
...@@ -126,6 +129,9 @@ set(HEADERS ...@@ -126,6 +129,9 @@ set(HEADERS
src/components/calls/CallsListModel.hpp src/components/calls/CallsListModel.hpp
src/components/chat/ChatModel.hpp src/components/chat/ChatModel.hpp
src/components/chat/ChatProxyModel.hpp src/components/chat/ChatProxyModel.hpp
src/components/codecs/CodecsModel.cpp
src/components/codecs/AudioCodecsModel.cpp
src/components/codecs/VideoCodecsModel.cpp
src/components/contact/ContactModel.hpp src/components/contact/ContactModel.hpp
src/components/contact/VcardModel.hpp src/components/contact/VcardModel.hpp
src/components/contacts/ContactsListModel.hpp src/components/contacts/ContactsListModel.hpp
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#include "../components/calls/CallsListModel.hpp" #include "../components/calls/CallsListModel.hpp"
#include "../components/camera/Camera.hpp" #include "../components/camera/Camera.hpp"
#include "../components/chat/ChatProxyModel.hpp" #include "../components/chat/ChatProxyModel.hpp"
#include "../components/codecs/AudioCodecsModel.hpp"
#include "../components/codecs/VideoCodecsModel.hpp"
#include "../components/contacts/ContactsListProxyModel.hpp" #include "../components/contacts/ContactsListProxyModel.hpp"
#include "../components/core/CoreManager.hpp" #include "../components/core/CoreManager.hpp"
#include "../components/presence/OwnPresenceModel.hpp" #include "../components/presence/OwnPresenceModel.hpp"
...@@ -290,6 +292,8 @@ void App::registerTypes () { ...@@ -290,6 +292,8 @@ void App::registerTypes () {
registerSingletonType<OwnPresenceModel>("OwnPresenceModel"); registerSingletonType<OwnPresenceModel>("OwnPresenceModel");
registerSingletonType<Presence>("Presence"); registerSingletonType<Presence>("Presence");
registerSingletonType<TimelineModel>("TimelineModel"); registerSingletonType<TimelineModel>("TimelineModel");
registerSingletonType<AudioCodecsModel>("AudioCodecsModel");
registerSingletonType<VideoCodecsModel>("VideoCodecsModel");
registerSharedSingletonType(App, "App", App::getInstance); registerSharedSingletonType(App, "App", App::getInstance);
registerSharedSingletonType(CoreManager, "CoreManager", CoreManager::getInstance); registerSharedSingletonType(CoreManager, "CoreManager", CoreManager::getInstance);
......
/*
* AudioCodecsModel.cpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: April 3, 2017
* Author: Ronan Abhamon
*/
#include "../core/CoreManager.hpp"
#include "AudioCodecsModel.hpp"
// =============================================================================
AudioCodecsModel::AudioCodecsModel (QObject *parent) : QSortFilterProxyModel(parent) {
setSourceModel(CoreManager::getInstance()->getCodecsModel());
}
bool AudioCodecsModel::filterAcceptsRow (int source_row, const QModelIndex &source_parent) const {
const QModelIndex &index = sourceModel()->index(source_row, 0, source_parent);
return index.data().toMap()["type"] == CodecsModel::AudioCodec;
}
/*
* AudioCodecsModel.hpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: April 3, 2017
* Author: Ronan Abhamon
*/
#ifndef AUDIO_CODECS_MODEL_H_
#define AUDIO_CODECS_MODEL_H_
#include <QSortFilterProxyModel>
// =============================================================================
class AudioCodecsModel : public QSortFilterProxyModel {
Q_OBJECT;
public:
AudioCodecsModel (QObject *parent = Q_NULLPTR);
~AudioCodecsModel () = default;
protected:
bool filterAcceptsRow (int source_row, const QModelIndex &source_parent) const override;
};
#endif // AUDIO_CODECS_MODEL_H_
/*
* CodecsModel.cpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: April 3, 2017
* Author: Ronan Abhamon
*/
#include "../../utils.hpp"
#include "../core/CoreManager.hpp"
#include "CodecsModel.hpp"
// ============================================================================
template<typename T>
inline void addCodecToList (QVariantList &list, const T &codec, CodecsModel::CodecType type) {
QVariantMap map;
map["bitrate"] = codec->getNormalBitrate();
map["channels"] = codec->getChannels();
map["clockRate"] = codec->getClockRate();
map["description"] = ::Utils::linphoneStringToQString(codec->getDescription());
map["enabled"] = codec->enabled();
map["encoderDescription"] = ::Utils::linphoneStringToQString(codec->getEncoderDescription());
map["isUsable"] = codec->isUsable();
map["isVbr"] = codec->isVbr();
map["mime"] = ::Utils::linphoneStringToQString(codec->getMimeType());
map["number"] = codec->getNumber();
map["type"] = type;
list << map;
}
// -----------------------------------------------------------------------------
CodecsModel::CodecsModel (QObject *parent) : QAbstractListModel(parent) {
for (const auto &codec : CoreManager::getInstance()->getCore()->getAudioPayloadTypes())
addCodecToList(m_codecs, codec, AudioCodec);
for (const auto &codec : CoreManager::getInstance()->getCore()->getVideoPayloadTypes())
addCodecToList(m_codecs, codec, VideoCodec);
for (const auto &codec : CoreManager::getInstance()->getCore()->getTextPayloadTypes())
addCodecToList(m_codecs, codec, TextCodec);
}
int CodecsModel::rowCount (const QModelIndex &) const {
return m_codecs.count();
}
QHash<int, QByteArray> CodecsModel::roleNames () const {
QHash<int, QByteArray> roles;
roles[Qt::DisplayRole] = "$codec";
return roles;
}
QVariant CodecsModel::data (const QModelIndex &index, int role) const {
int row = index.row();
if (!index.isValid() || row < 0 || row >= m_codecs.count())
return QVariant();
if (role == Qt::DisplayRole)
return m_codecs[row];
return QVariant();
}
/*
* CodecsModel.hpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: April 3, 2017
* Author: Ronan Abhamon
*/
#ifndef CODECS_MODEL_H_
#define CODECS_MODEL_H_
#include <QAbstractListModel>
// =============================================================================
class CodecsModel : public QAbstractListModel {
Q_OBJECT;
public:
enum CodecType {
AudioCodec,
VideoCodec,
TextCodec
};
Q_ENUMS(CodecType);
CodecsModel (QObject *parent = Q_NULLPTR);
~CodecsModel () = default;
int rowCount (const QModelIndex &index = QModelIndex()) const override;
QHash<int, QByteArray> roleNames () const override;
QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const override;
private:
QVariantList m_codecs;
};
#endif // CODECS_MODEL_H_
/*
* VideoCodecsModel.cpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: April 3, 2017
* Author: Ronan Abhamon
*/
#include "../core/CoreManager.hpp"
#include "VideoCodecsModel.hpp"
// =============================================================================
VideoCodecsModel::VideoCodecsModel (QObject *parent) : QSortFilterProxyModel(parent) {
setSourceModel(CoreManager::getInstance()->getCodecsModel());
}
bool VideoCodecsModel::filterAcceptsRow (int source_row, const QModelIndex &source_parent) const {
const QModelIndex &index = sourceModel()->index(source_row, 0, source_parent);
return index.data().toMap()["type"] == CodecsModel::VideoCodec;
}
/*
* VideoCodecsModel.hpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: April 3, 2017
* Author: Ronan Abhamon
*/
#ifndef VIDEO_CODECS_MODEL_H_
#define VIDEO_CODECS_MODEL_H_
#include <QSortFilterProxyModel>
// =============================================================================
class VideoCodecsModel : public QSortFilterProxyModel {
Q_OBJECT;
public:
VideoCodecsModel (QObject *parent = Q_NULLPTR);
~VideoCodecsModel () = default;
protected:
bool filterAcceptsRow (int source_row, const QModelIndex &source_parent) const override;
};
#endif // VIDEO_CODECS_MODEL_H_
...@@ -44,6 +44,7 @@ CoreManager::CoreManager (QObject *parent, const QString &config_path) : QObject ...@@ -44,6 +44,7 @@ CoreManager::CoreManager (QObject *parent, const QString &config_path) : QObject
m_instance->m_calls_list_model = new CallsListModel(m_instance); m_instance->m_calls_list_model = new CallsListModel(m_instance);
m_instance->m_contacts_list_model = new ContactsListModel(m_instance); m_instance->m_contacts_list_model = new ContactsListModel(m_instance);
m_instance->m_sip_addresses_model = new SipAddressesModel(m_instance); m_instance->m_sip_addresses_model = new SipAddressesModel(m_instance);
m_instance->m_codecs_model = new CodecsModel(m_instance);
m_instance->m_settings_model = new SettingsModel(m_instance); m_instance->m_settings_model = new SettingsModel(m_instance);
emit m_instance->linphoneCoreCreated(); emit m_instance->linphoneCoreCreated();
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#define CORE_MANAGER_H_ #define CORE_MANAGER_H_
#include "../calls/CallsListModel.hpp" #include "../calls/CallsListModel.hpp"
#include "../codecs/CodecsModel.hpp"
#include "../contacts/ContactsListModel.hpp" #include "../contacts/ContactsListModel.hpp"
#include "../settings/SettingsModel.hpp" #include "../settings/SettingsModel.hpp"
#include "../sip-addresses/SipAddressesModel.hpp" #include "../sip-addresses/SipAddressesModel.hpp"
...@@ -82,6 +83,10 @@ public: ...@@ -82,6 +83,10 @@ public:
return m_sip_addresses_model; return m_sip_addresses_model;
} }
CodecsModel *getCodecsModel () const {
return m_codecs_model;
}
SettingsModel *getSettingsModel () const { SettingsModel *getSettingsModel () const {
return m_settings_model; return m_settings_model;
} }
...@@ -124,6 +129,7 @@ private: ...@@ -124,6 +129,7 @@ private:
CallsListModel *m_calls_list_model; CallsListModel *m_calls_list_model;
ContactsListModel *m_contacts_list_model; ContactsListModel *m_contacts_list_model;
SipAddressesModel *m_sip_addresses_model; SipAddressesModel *m_sip_addresses_model;
CodecsModel *m_codecs_model;
SettingsModel *m_settings_model; SettingsModel *m_settings_model;
QTimer *m_cbs_timer; QTimer *m_cbs_timer;
......
...@@ -42,31 +42,6 @@ SettingsModel::SettingsModel (QObject *parent) : QObject(parent) { ...@@ -42,31 +42,6 @@ SettingsModel::SettingsModel (QObject *parent) : QObject(parent) {
// Audio. // Audio.
// ============================================================================= // =============================================================================
QVariantList SettingsModel::getAudioCodecs () const {
QVariantList list;
// for (const auto &codec : CoreManager::getInstance()->getCore()->getAudioCodecs()) {
// QVariantMap map;
//
// map["mime"] = ::Utils::linphoneStringToQString(codec->getMimeType());
// map["channels"] = codec->getChannels();
// map["bitrate"] = codec->getNormalBitrate();
// map["type"] = codec->getType();
// map["isVbr"] = codec->isVbr();
//
// list << map;
// }
return list;
}
void SettingsModel::setAudioCodecs (const QVariantList &codecs) {
// TODO
emit audioCodecsChanged(codecs);
}
// -----------------------------------------------------------------------------
QStringList SettingsModel::getAudioDevices () const { QStringList SettingsModel::getAudioDevices () const {
QStringList list; QStringList list;
......
...@@ -37,8 +37,6 @@ class SettingsModel : public QObject { ...@@ -37,8 +37,6 @@ class SettingsModel : public QObject {
// Audio. -------------------------------------------------------------------- // Audio. --------------------------------------------------------------------
Q_PROPERTY(QVariantList audioCodecs READ getAudioCodecs WRITE setAudioCodecs NOTIFY audioCodecsChanged);
Q_PROPERTY(QStringList audioDevices READ getAudioDevices CONSTANT); Q_PROPERTY(QStringList audioDevices READ getAudioDevices CONSTANT);
Q_PROPERTY(QString captureDevice READ getCaptureDevice WRITE setCaptureDevice NOTIFY captureDeviceChanged); Q_PROPERTY(QString captureDevice READ getCaptureDevice WRITE setCaptureDevice NOTIFY captureDeviceChanged);
...@@ -136,9 +134,6 @@ public: ...@@ -136,9 +134,6 @@ public:
// Audio. -------------------------------------------------------------------- // Audio. --------------------------------------------------------------------
QVariantList getAudioCodecs () const;
void setAudioCodecs (const QVariantList &codecs);
QStringList getAudioDevices () const; QStringList getAudioDevices () const;
QString getCaptureDevice () const; QString getCaptureDevice () const;
...@@ -261,8 +256,6 @@ public: ...@@ -261,8 +256,6 @@ public:
signals: signals:
// Audio. -------------------------------------------------------------------- // Audio. --------------------------------------------------------------------
void audioCodecsChanged (const QVariantList &codecs);
void captureDeviceChanged (const QString &device); void captureDeviceChanged (const QString &device);
void playbackDeviceChanged (const QString &device); void playbackDeviceChanged (const QString &device);
void ringerDeviceChanged (const QString &device); void ringerDeviceChanged (const QString &device);
......
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