22ab688a79
Implemented a universal encoder based on FFMpeg. I'll get it to work with gif too.
Adding other formats should be easy. In fact, recordingformats can be made into something much shorter. Soon™️
55 lines
1.1 KiB
C++
55 lines
1.1 KiB
C++
#ifndef RECORDINGCONTROLLER_HPP
|
|
#define RECORDINGCONTROLLER_HPP
|
|
|
|
#include "recordingpreview.hpp"
|
|
|
|
#include <QFile>
|
|
#include <QImage>
|
|
#include <QMutex>
|
|
#include <QQueue>
|
|
#include <QRect>
|
|
#include <QTimer>
|
|
#include <functional>
|
|
#include <memory>
|
|
|
|
struct RecordingContext {
|
|
QImage::Format format;
|
|
std::function<void(QImage)> consumer;
|
|
std::function<bool(QSize)> validator;
|
|
std::function<QByteArray()> finalizer;
|
|
QString anotherFormat;
|
|
};
|
|
|
|
struct _QueueContext {
|
|
QByteArray arr;
|
|
QString format;
|
|
};
|
|
|
|
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();
|
|
void queue(_QueueContext arr);
|
|
private slots:
|
|
void timeout();
|
|
void startWithArea(QRect newArea);
|
|
|
|
private:
|
|
QMutex lock;
|
|
QQueue<_QueueContext> uploadQueue;
|
|
QRect area;
|
|
RecordingContext *_context = 0;
|
|
QTimer timer;
|
|
RecordingPreview *preview = nullptr;
|
|
unsigned int frame = 0;
|
|
unsigned int time = 0;
|
|
};
|
|
|
|
#endif // RECORDINGCONTROLLER_HPP
|