2017-06-04 01:04:42 +02:00
|
|
|
#ifndef RECORDINGCONTROLLER_HPP
|
|
|
|
#define RECORDINGCONTROLLER_HPP
|
|
|
|
|
|
|
|
#include "recordingpreview.hpp"
|
|
|
|
|
2017-06-04 22:58:29 +02:00
|
|
|
#include <QFile>
|
2017-06-04 01:04:42 +02:00
|
|
|
#include <QImage>
|
2017-06-06 01:26:26 +02:00
|
|
|
#include <QMutex>
|
2017-06-06 12:51:16 +02:00
|
|
|
#include <QQueue>
|
2017-06-04 01:04:42 +02:00
|
|
|
#include <QRect>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <functional>
|
|
|
|
#include <memory>
|
|
|
|
|
2017-06-06 17:05:34 +02:00
|
|
|
struct RecordingContext {
|
2017-06-04 01:04:42 +02:00
|
|
|
QImage::Format format;
|
|
|
|
std::function<void(QImage)> consumer;
|
2017-06-13 00:38:32 +02:00
|
|
|
std::function<bool(QSize)> validator;
|
2017-06-04 23:04:35 +02:00
|
|
|
std::function<QByteArray()> finalizer;
|
2017-06-06 17:05:34 +02:00
|
|
|
QString anotherFormat;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _QueueContext {
|
|
|
|
QByteArray arr;
|
|
|
|
QString format;
|
2017-06-04 01:04:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class RecordingController : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
RecordingController();
|
|
|
|
bool isRunning();
|
|
|
|
public slots:
|
|
|
|
// Returns false if isRunning
|
|
|
|
bool start(RecordingContext *context);
|
|
|
|
// Returns false if not running
|
|
|
|
bool end();
|
2017-06-06 17:05:34 +02:00
|
|
|
void queue(_QueueContext arr);
|
2017-06-04 01:04:42 +02:00
|
|
|
private slots:
|
|
|
|
void timeout();
|
|
|
|
void startWithArea(QRect newArea);
|
|
|
|
|
|
|
|
private:
|
2017-06-06 01:26:26 +02:00
|
|
|
QMutex lock;
|
2017-06-06 17:05:34 +02:00
|
|
|
QQueue<_QueueContext> uploadQueue;
|
2017-06-04 01:04:42 +02:00
|
|
|
QRect area;
|
|
|
|
RecordingContext *_context = 0;
|
|
|
|
QTimer timer;
|
|
|
|
RecordingPreview *preview = nullptr;
|
|
|
|
unsigned int frame = 0;
|
|
|
|
unsigned int time = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // RECORDINGCONTROLLER_HPP
|