2018-02-22 16:52:49 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
2023-11-18 06:02:48 -05:00
|
|
|
// Copyright (C) 2018-2019, 2021 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
|
2018-02-22 16:52:49 -05:00
|
|
|
// Copyright (C) 2018 F4HKW //
|
|
|
|
// for F4EXB / SDRAngel //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
2019-04-11 00:39:30 -04:00
|
|
|
// (at your option) any later version. //
|
2018-02-22 16:52:49 -05:00
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef DATVIDEOSTREAM_H
|
|
|
|
#define DATVIDEOSTREAM_H
|
|
|
|
|
|
|
|
#include <QIODevice>
|
|
|
|
#include <QQueue>
|
|
|
|
#include <QByteArray>
|
|
|
|
#include <QEventLoop>
|
|
|
|
#include <QMutex>
|
|
|
|
#include <QThread>
|
|
|
|
|
|
|
|
class DATVideostream : public QIODevice
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
DATVideostream();
|
2021-04-05 07:13:57 -04:00
|
|
|
virtual ~DATVideostream();
|
2018-02-22 16:52:49 -05:00
|
|
|
|
|
|
|
int pushData(const char * chrData, int intSize);
|
2021-03-14 01:57:55 -05:00
|
|
|
void resetTotalReceived();
|
2021-04-01 00:14:56 -04:00
|
|
|
void cleanUp();
|
2021-04-04 20:42:36 -04:00
|
|
|
void setMultiThreaded(bool multiThreaded);
|
|
|
|
void setThreadTimeout(int timeOut) { m_threadTimeout = timeOut; }
|
2018-02-22 16:52:49 -05:00
|
|
|
|
|
|
|
virtual bool isSequential() const;
|
|
|
|
virtual qint64 bytesAvailable() const;
|
|
|
|
virtual void close();
|
|
|
|
virtual bool open(OpenMode mode);
|
|
|
|
|
2021-04-05 07:13:57 -04:00
|
|
|
static const int m_defaultMemoryLimit = 2820000;
|
|
|
|
static const int m_minStackSize = 4;
|
2018-02-22 16:52:49 -05:00
|
|
|
|
|
|
|
signals:
|
2021-04-05 07:13:57 -04:00
|
|
|
void dataAvailable();
|
2021-04-11 18:31:47 -04:00
|
|
|
void fifoData(int intDataBytes, int intPercentBuffer, qint64 intTotalReceived);
|
2018-02-22 16:52:49 -05:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual qint64 readData(char *data, qint64 len);
|
|
|
|
virtual qint64 writeData(const char *data, qint64 len);
|
|
|
|
virtual qint64 readLineData(char *data, qint64 maxSize);
|
|
|
|
|
|
|
|
private:
|
2021-04-05 07:13:57 -04:00
|
|
|
QQueue<QByteArray> m_fifo;
|
2021-04-04 20:42:36 -04:00
|
|
|
bool m_multiThreaded;
|
|
|
|
int m_threadTimeout;
|
2018-02-22 16:52:49 -05:00
|
|
|
|
2021-04-05 07:13:57 -04:00
|
|
|
QEventLoop m_eventLoop;
|
|
|
|
QMutex m_mutex;
|
|
|
|
int m_memoryLimit;
|
|
|
|
int m_bytesAvailable;
|
|
|
|
int m_bytesWaiting;
|
|
|
|
int m_percentBuffer;
|
|
|
|
qint64 m_totalReceived;
|
|
|
|
qint64 m_packetReceived;
|
2018-02-22 16:52:49 -05:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DATVIDEOSTREAM_H
|