File indexing completed on 2024-05-19 04:45:38

0001 /*
0002  * SPDX-FileCopyrightText: 2023 George Florea Bănuș <georgefb899@gmail.com>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005  */
0006 
0007 #ifndef MPVABSTRACTITEM_H
0008 #define MPVABSTRACTITEM_H
0009 
0010 #include "mpvqt_export.h"
0011 
0012 #include <QtQuick/QQuickFramebufferObject>
0013 #include <mpv/client.h>
0014 #include <mpv/render_gl.h>
0015 
0016 class MpvController;
0017 class MpvAbstractItemPrivate;
0018 
0019 class MPVQT_EXPORT MpvAbstractItem : public QQuickFramebufferObject
0020 {
0021     Q_OBJECT
0022 public:
0023     explicit MpvAbstractItem(QQuickItem *parent = nullptr);
0024     ~MpvAbstractItem();
0025 
0026     Renderer *createRenderer() const override;
0027     Q_INVOKABLE int setPropertyBlocking(const QString &property, const QVariant &value);
0028     Q_INVOKABLE void setPropertyAsync(const QString &property, const QVariant &value, int id = 0);
0029     Q_INVOKABLE QVariant getProperty(const QString &property);
0030     Q_INVOKABLE void getPropertyAsync(const QString &property, int id = 0);
0031     Q_INVOKABLE QVariant commandBlocking(const QVariant &params);
0032     Q_INVOKABLE void commandAsync(const QStringList &params, int id = 0);
0033     Q_INVOKABLE QVariant expandText(const QString &text);
0034 
0035     friend class MpvRenderer;
0036 
0037 Q_SIGNALS:
0038     void ready();
0039     void observeProperty(const QString &property, mpv_format format);
0040     void setProperty(const QString &property, const QVariant &value);
0041     void command(const QStringList &params);
0042 
0043 protected:
0044     MpvController *mpvController();
0045 
0046     std::unique_ptr<MpvAbstractItemPrivate> d_ptr;
0047 };
0048 
0049 #endif // MPVABSTRACTITEM_H