AbstractCodecsModel.hpp 2.51 KB
Newer Older
1 2
/*
 * AbstractCodecsModel.hpp
3
 * Copyright (C) 2017-2018  Belledonne Communications, Grenoble, France
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
 *
 * 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 4, 2017
 *      Author: Ronan Abhamon
 */

#ifndef ABSTRACT_CODECS_MODEL_H_
#define ABSTRACT_CODECS_MODEL_H_

26 27 28
#include <memory>

#include <QAbstractListModel>
29 30 31

// =============================================================================

32 33 34 35 36
namespace linphone {
  class PayloadType;
}

class AbstractCodecsModel : public QAbstractListModel {
37 38
  Q_OBJECT;

39 40
  Q_PROPERTY(QString codecsFolder READ getCodecsFolder CONSTANT);

41 42 43
public:
  AbstractCodecsModel (QObject *parent = Q_NULLPTR);

44 45 46 47 48
  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;

49 50
  Q_INVOKABLE void enableCodec (int id, bool status);
  Q_INVOKABLE void moveCodec (int source, int destination);
51

52
  Q_INVOKABLE void setBitrate (int id, int bitrate);
53
  Q_INVOKABLE void setRecvFmtp (int id, const QString &recvFmtp);
54

55 56 57 58
  Q_INVOKABLE virtual void reload () {};

  Q_INVOKABLE QVariantMap getCodecInfo (const QString &mime) const;

59
protected:
60
  bool moveRows (
61 62
    const QModelIndex &sourceParent,
    int sourceRow,
63
    int count,
64 65
    const QModelIndex &destinationParent,
    int destinationChild
66 67 68
  ) override;

  void addCodec (std::shared_ptr<linphone::PayloadType> &codec);
69 70 71 72 73 74
  void addDownloadableCodec (
    const QString &mime,
    const QString &encoderDescription,
    const QString &downloadUrl,
    const QString &installName
  );
75 76

  QString getCodecsFolder () const;
77

78
  virtual void updateCodecs (std::list<std::shared_ptr<linphone::PayloadType>> &codecs) = 0;
79

80
  QList<QVariantMap> mCodecs;
81 82
};

83
Q_DECLARE_METATYPE(std::shared_ptr<linphone::PayloadType>);
84

85
#endif // ABSTRACT_CODECS_MODEL_H_