You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
2.2 KiB
100 lines
2.2 KiB
4 years ago
|
#ifndef QUEUEWRITER_H
|
||
|
#define QUEUEWRITER_H
|
||
|
|
||
|
#include <QThread>
|
||
|
#include <QSemaphore>
|
||
|
#include <QMutex>
|
||
|
#include <QQueue>
|
||
|
#include <QDebug>
|
||
|
|
||
|
#include "model/ultrasoundModule/UsPacket.h"
|
||
|
#include "model/player/metadata/PlayerMetadata.h"
|
||
|
#include "model/player/type/EDirection.h"
|
||
|
#include "model/ultrasoundModule/UsHelper.h"
|
||
|
|
||
|
/*****************************************************************************/
|
||
|
/**
|
||
|
* @brief This class is writer part of player engine. This class push frame
|
||
|
* into player buffer.
|
||
|
* @author Mohammad Mohsen Talaie
|
||
|
* @date 14 nov 2020
|
||
|
*/
|
||
|
/*****************************************************************************/
|
||
|
class QueueWriter : public QThread
|
||
|
{
|
||
|
Q_OBJECT
|
||
|
SINGLETON(QueueWriter)
|
||
|
|
||
|
private:
|
||
|
static QMutex _locker;
|
||
|
bool* _playOriginal;
|
||
|
bool _feedBuffer;
|
||
|
bool* _repeat;
|
||
|
bool* _play;
|
||
|
int _circleBufferSize;
|
||
|
int _iteration;
|
||
|
int* _start;
|
||
|
int _index;
|
||
|
int* _end;
|
||
|
int* _fps;
|
||
|
int* _step;
|
||
|
|
||
|
EDirection::eDirection* _playDirection;
|
||
|
UsPacket* _circleBuffer;
|
||
|
QSemaphore* _usedCells;
|
||
|
QSemaphore* _freeCells;
|
||
|
QMutex* _bufferMutex;
|
||
|
const QList<QQueue<UsPacket> >* _buffer;
|
||
|
|
||
|
UsPacket getPacketFromBuffer();
|
||
|
|
||
|
PlayerMetadata createPlayerMetadata();
|
||
|
|
||
|
void AppendMetaDataToPacket(UsPacket* packet, const PlayerMetadata& playerMetadata);
|
||
|
|
||
|
void putPacketIntoCircleBuffer(const UsPacket& packet);
|
||
|
|
||
|
void waitForPlayAndFeedBufferChanges();
|
||
|
|
||
|
void putPacketIntoQueue();
|
||
|
|
||
|
void fillCircleBuffer();
|
||
|
|
||
|
void updateIndex();
|
||
|
|
||
|
bool checkIndexBetweenBorders();
|
||
|
|
||
|
public:
|
||
|
QueueWriter(QObject* parent = NULL) : QThread(parent)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
void initParams(QSemaphore* used,
|
||
|
QSemaphore* free,
|
||
|
UsPacket* circleBuffer,
|
||
|
const int circleBufferSize,
|
||
|
const QList<QQueue<UsPacket> >* buffer,
|
||
|
int* step,
|
||
|
int* start,
|
||
|
int* end,
|
||
|
int* fps,
|
||
|
bool* play,
|
||
|
bool* playOriginal,
|
||
|
bool* repeat,
|
||
|
EDirection::eDirection* playMode);
|
||
|
|
||
|
void run() override;
|
||
|
|
||
|
void fetchImage(int index);
|
||
|
|
||
|
void setFeedBuffer(const bool feedBuffer);
|
||
|
|
||
|
void setIndex(int index);
|
||
|
|
||
|
void resetIteration();
|
||
|
|
||
|
bool getFeedBuffer() const;
|
||
|
};
|
||
|
|
||
|
#endif //QUEUEWRITER_H
|