2023-02-22 01:48:49 +03:00
|
|
|
// SPDX-FileCopyrightText: Nheko Contributors
|
2021-08-28 01:38:33 +03:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QBuffer>
|
|
|
|
#include <QMediaPlayer>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QPointer>
|
2023-06-19 02:38:40 +03:00
|
|
|
#include <QQuickItem>
|
2021-08-28 01:38:33 +03:00
|
|
|
#include <QString>
|
2023-06-02 02:37:53 +03:00
|
|
|
#include <QUrl>
|
|
|
|
#include <QVideoSink>
|
2021-08-28 01:38:33 +03:00
|
|
|
|
|
|
|
#include "Logging.h"
|
|
|
|
|
|
|
|
class TimelineModel;
|
|
|
|
|
|
|
|
// I failed to get my own buffer into the MediaPlayer in qml, so just make our own. For that we just
|
|
|
|
// need the videoSurface property, so that part is really easy!
|
|
|
|
class MxcMediaProxy : public QMediaPlayer
|
|
|
|
{
|
2021-09-18 01:22:33 +03:00
|
|
|
Q_OBJECT
|
2023-06-19 02:38:40 +03:00
|
|
|
QML_NAMED_ELEMENT(MxcMedia)
|
|
|
|
|
2021-09-18 01:22:33 +03:00
|
|
|
Q_PROPERTY(TimelineModel *roomm READ room WRITE setRoom NOTIFY roomChanged REQUIRED)
|
|
|
|
Q_PROPERTY(QString eventId READ eventId WRITE setEventId NOTIFY eventIdChanged)
|
|
|
|
Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
|
2021-11-15 05:35:35 +03:00
|
|
|
Q_PROPERTY(int orientation READ orientation NOTIFY orientationChanged)
|
|
|
|
|
2021-08-28 01:38:33 +03:00
|
|
|
public:
|
2021-11-15 05:35:35 +03:00
|
|
|
MxcMediaProxy(QObject *parent = nullptr);
|
2021-08-28 01:38:33 +03:00
|
|
|
|
2021-09-18 01:22:33 +03:00
|
|
|
bool loaded() const { return buffer.size() > 0; }
|
|
|
|
QString eventId() const { return eventId_; }
|
|
|
|
TimelineModel *room() const { return room_; }
|
|
|
|
void setEventId(QString newEventId)
|
|
|
|
{
|
|
|
|
eventId_ = newEventId;
|
|
|
|
emit eventIdChanged();
|
|
|
|
}
|
|
|
|
void setRoom(TimelineModel *room)
|
|
|
|
{
|
|
|
|
room_ = room;
|
|
|
|
emit roomChanged();
|
|
|
|
}
|
2021-11-15 05:35:35 +03:00
|
|
|
int orientation() const;
|
|
|
|
|
2021-08-28 01:38:33 +03:00
|
|
|
signals:
|
2021-09-18 01:22:33 +03:00
|
|
|
void roomChanged();
|
|
|
|
void eventIdChanged();
|
|
|
|
void loadedChanged();
|
2023-06-02 01:24:26 +03:00
|
|
|
void newBuffer(QUrl, QIODevice *buf);
|
2021-08-28 01:38:33 +03:00
|
|
|
|
2021-11-15 05:35:35 +03:00
|
|
|
void orientationChanged();
|
2021-12-29 00:30:12 +03:00
|
|
|
void videoSurfaceChanged();
|
2021-11-15 05:35:35 +03:00
|
|
|
|
2021-08-28 01:38:33 +03:00
|
|
|
private slots:
|
2021-09-18 01:22:33 +03:00
|
|
|
void startDownload();
|
2021-08-28 01:38:33 +03:00
|
|
|
|
|
|
|
private:
|
2021-09-18 01:22:33 +03:00
|
|
|
TimelineModel *room_ = nullptr;
|
|
|
|
QString eventId_;
|
|
|
|
QString filename_;
|
|
|
|
QBuffer buffer;
|
2023-06-02 01:24:26 +03:00
|
|
|
QObject *m_surface = nullptr;
|
2021-08-28 01:38:33 +03:00
|
|
|
};
|