mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-21 13:48:08 +00:00
feat(src/components/codecs): in progress
This commit is contained in:
parent
d38c41cf33
commit
b146db243f
12 changed files with 309 additions and 34 deletions
|
|
@ -86,12 +86,15 @@ set(SOURCES
|
|||
src/app/providers/AvatarProvider.cpp
|
||||
src/app/providers/ThumbnailProvider.cpp
|
||||
src/app/translator/DefaultTranslator.cpp
|
||||
src/components/camera/Camera.cpp
|
||||
src/components/camera/MSFunctions.cpp
|
||||
src/components/call/CallModel.cpp
|
||||
src/components/calls/CallsListModel.cpp
|
||||
src/components/camera/Camera.cpp
|
||||
src/components/camera/MSFunctions.cpp
|
||||
src/components/chat/ChatModel.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/VcardModel.cpp
|
||||
src/components/contacts/ContactsListModel.cpp
|
||||
|
|
@ -126,6 +129,9 @@ set(HEADERS
|
|||
src/components/calls/CallsListModel.hpp
|
||||
src/components/chat/ChatModel.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/VcardModel.hpp
|
||||
src/components/contacts/ContactsListModel.hpp
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
#include "../components/calls/CallsListModel.hpp"
|
||||
#include "../components/camera/Camera.hpp"
|
||||
#include "../components/chat/ChatProxyModel.hpp"
|
||||
#include "../components/codecs/AudioCodecsModel.hpp"
|
||||
#include "../components/codecs/VideoCodecsModel.hpp"
|
||||
#include "../components/contacts/ContactsListProxyModel.hpp"
|
||||
#include "../components/core/CoreManager.hpp"
|
||||
#include "../components/presence/OwnPresenceModel.hpp"
|
||||
|
|
@ -290,6 +292,8 @@ void App::registerTypes () {
|
|||
registerSingletonType<OwnPresenceModel>("OwnPresenceModel");
|
||||
registerSingletonType<Presence>("Presence");
|
||||
registerSingletonType<TimelineModel>("TimelineModel");
|
||||
registerSingletonType<AudioCodecsModel>("AudioCodecsModel");
|
||||
registerSingletonType<VideoCodecsModel>("VideoCodecsModel");
|
||||
|
||||
registerSharedSingletonType(App, "App", App::getInstance);
|
||||
registerSharedSingletonType(CoreManager, "CoreManager", CoreManager::getInstance);
|
||||
|
|
|
|||
36
linphone-desktop/src/components/codecs/AudioCodecsModel.cpp
Normal file
36
linphone-desktop/src/components/codecs/AudioCodecsModel.cpp
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* 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;
|
||||
}
|
||||
41
linphone-desktop/src/components/codecs/AudioCodecsModel.hpp
Normal file
41
linphone-desktop/src/components/codecs/AudioCodecsModel.hpp
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* 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_
|
||||
82
linphone-desktop/src/components/codecs/CodecsModel.cpp
Normal file
82
linphone-desktop/src/components/codecs/CodecsModel.cpp
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* 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();
|
||||
}
|
||||
54
linphone-desktop/src/components/codecs/CodecsModel.hpp
Normal file
54
linphone-desktop/src/components/codecs/CodecsModel.hpp
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* 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_
|
||||
36
linphone-desktop/src/components/codecs/VideoCodecsModel.cpp
Normal file
36
linphone-desktop/src/components/codecs/VideoCodecsModel.cpp
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* 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;
|
||||
}
|
||||
41
linphone-desktop/src/components/codecs/VideoCodecsModel.hpp
Normal file
41
linphone-desktop/src/components/codecs/VideoCodecsModel.hpp
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* 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
|
|||
m_instance->m_calls_list_model = new CallsListModel(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_codecs_model = new CodecsModel(m_instance);
|
||||
m_instance->m_settings_model = new SettingsModel(m_instance);
|
||||
|
||||
emit m_instance->linphoneCoreCreated();
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#define CORE_MANAGER_H_
|
||||
|
||||
#include "../calls/CallsListModel.hpp"
|
||||
#include "../codecs/CodecsModel.hpp"
|
||||
#include "../contacts/ContactsListModel.hpp"
|
||||
#include "../settings/SettingsModel.hpp"
|
||||
#include "../sip-addresses/SipAddressesModel.hpp"
|
||||
|
|
@ -82,6 +83,10 @@ public:
|
|||
return m_sip_addresses_model;
|
||||
}
|
||||
|
||||
CodecsModel *getCodecsModel () const {
|
||||
return m_codecs_model;
|
||||
}
|
||||
|
||||
SettingsModel *getSettingsModel () const {
|
||||
return m_settings_model;
|
||||
}
|
||||
|
|
@ -124,6 +129,7 @@ private:
|
|||
CallsListModel *m_calls_list_model;
|
||||
ContactsListModel *m_contacts_list_model;
|
||||
SipAddressesModel *m_sip_addresses_model;
|
||||
CodecsModel *m_codecs_model;
|
||||
SettingsModel *m_settings_model;
|
||||
|
||||
QTimer *m_cbs_timer;
|
||||
|
|
|
|||
|
|
@ -42,31 +42,6 @@ SettingsModel::SettingsModel (QObject *parent) : QObject(parent) {
|
|||
// 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 list;
|
||||
|
||||
|
|
|
|||
|
|
@ -37,8 +37,6 @@ class SettingsModel : public QObject {
|
|||
|
||||
// Audio. --------------------------------------------------------------------
|
||||
|
||||
Q_PROPERTY(QVariantList audioCodecs READ getAudioCodecs WRITE setAudioCodecs NOTIFY audioCodecsChanged);
|
||||
|
||||
Q_PROPERTY(QStringList audioDevices READ getAudioDevices CONSTANT);
|
||||
|
||||
Q_PROPERTY(QString captureDevice READ getCaptureDevice WRITE setCaptureDevice NOTIFY captureDeviceChanged);
|
||||
|
|
@ -136,9 +134,6 @@ public:
|
|||
|
||||
// Audio. --------------------------------------------------------------------
|
||||
|
||||
QVariantList getAudioCodecs () const;
|
||||
void setAudioCodecs (const QVariantList &codecs);
|
||||
|
||||
QStringList getAudioDevices () const;
|
||||
|
||||
QString getCaptureDevice () const;
|
||||
|
|
@ -261,8 +256,6 @@ public:
|
|||
signals:
|
||||
// Audio. --------------------------------------------------------------------
|
||||
|
||||
void audioCodecsChanged (const QVariantList &codecs);
|
||||
|
||||
void captureDeviceChanged (const QString &device);
|
||||
void playbackDeviceChanged (const QString &device);
|
||||
void ringerDeviceChanged (const QString &device);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue