60 lines
1.2 KiB
C++
60 lines
1.2 KiB
C++
#ifndef MEDIAPARTICLEGENERATOR_H
|
|
#define MEDIAPARTICLEGENERATOR_H
|
|
|
|
#include <QObject>
|
|
|
|
class Store;
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
class QNetworkAccessManager;
|
|
class QFile;
|
|
class QNetworkReply;
|
|
QT_END_NAMESPACE
|
|
|
|
class MediaParticleGenerator : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit MediaParticleGenerator(Store *, QObject *parent = nullptr);
|
|
|
|
bool isGenerating() const;
|
|
|
|
public slots:
|
|
void generate(const QUrl &url, const QString &mimeType, const QString &networkId, qint64 durationMs, const QString &streamId);
|
|
|
|
signals:
|
|
void isGeneratingChanged();
|
|
void errorOccurred(const QString &message);
|
|
void complete();
|
|
|
|
private:
|
|
bool m_isGenerating = false;
|
|
void setGenerating(bool generating);
|
|
Store *m_store;
|
|
|
|
QNetworkAccessManager *m_qnam;
|
|
|
|
void onUploadUrlReceived(const QJsonDocument &response);
|
|
void onUploadComplete();
|
|
|
|
/// Does not support cancelling in flight, but will clean up after completion or error
|
|
void cleanup();
|
|
|
|
struct UploadInfo
|
|
{
|
|
QString networkId;
|
|
QString streamId;
|
|
QString mimeType;
|
|
qint64 durationMs;
|
|
QFile *file = nullptr;
|
|
|
|
QString objectId;
|
|
QString uploadUrl;
|
|
qint64 bytes;
|
|
};
|
|
UploadInfo *m_uploadInfo = nullptr;
|
|
};
|
|
|
|
#endif //MEDIAPARTICLEGENERATOR_H
|