2016-06-19 07:56:49 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2016 Edouard Griffiths, F4EXB //
|
|
|
|
// //
|
|
|
|
// 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 04:57:41 +00:00
|
|
|
// (at your option) any later version. //
|
2016-06-19 07:56:49 +00: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/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2019-02-02 23:26:26 +00:00
|
|
|
#ifndef PLUGINS_SAMPLESOURCE_REMOTEINPUT_REMOTEINPUTUDPHANDLER_H_
|
|
|
|
#define PLUGINS_SAMPLESOURCE_REMOTEINPUT_REMOTEINPUTUDPHANDLER_H_
|
2016-06-19 07:56:49 +00:00
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QUdpSocket>
|
|
|
|
#include <QHostAddress>
|
|
|
|
#include <QMutex>
|
|
|
|
#include <QElapsedTimer>
|
|
|
|
|
2019-02-02 23:26:26 +00:00
|
|
|
#include "remoteinputbuffer.h"
|
2016-06-19 07:56:49 +00:00
|
|
|
|
2019-02-02 23:26:26 +00:00
|
|
|
#define REMOTEINPUT_THROTTLE_MS 50
|
2016-06-19 07:56:49 +00:00
|
|
|
|
2016-10-06 17:18:02 +00:00
|
|
|
class SampleSinkFifo;
|
2016-06-19 07:56:49 +00:00
|
|
|
class MessageQueue;
|
|
|
|
class QTimer;
|
2019-05-08 20:11:53 +00:00
|
|
|
class DeviceAPI;
|
2016-06-19 07:56:49 +00:00
|
|
|
|
2019-02-02 23:26:26 +00:00
|
|
|
class RemoteInputUDPHandler : public QObject
|
2016-06-19 07:56:49 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2019-05-08 20:11:53 +00:00
|
|
|
RemoteInputUDPHandler(SampleSinkFifo* sampleFifo, DeviceAPI *deviceAPI);
|
2019-02-02 23:26:26 +00:00
|
|
|
~RemoteInputUDPHandler();
|
2017-09-16 23:23:54 +00:00
|
|
|
void setMessageQueueToGUI(MessageQueue *queue) { m_outputMessageQueueToGUI = queue; }
|
2016-06-19 07:56:49 +00:00
|
|
|
void start();
|
|
|
|
void stop();
|
|
|
|
void configureUDPLink(const QString& address, quint16 port);
|
|
|
|
void getRemoteAddress(QString& s) const { s = m_remoteAddress.toString(); }
|
2019-02-02 21:58:42 +00:00
|
|
|
int getNbOriginalBlocks() const { return RemoteNbOrginalBlocks; }
|
2017-12-26 01:18:30 +00:00
|
|
|
bool isStreaming() const { return m_masterTimerConnected; }
|
|
|
|
int getSampleRate() const { return m_samplerate; }
|
2019-04-26 01:07:50 +00:00
|
|
|
int getCenterFrequency() const { return m_centerFrequency; }
|
2019-02-02 23:26:26 +00:00
|
|
|
int getBufferGauge() const { return m_remoteInputBuffer.getBufferGauge(); }
|
2018-11-13 12:45:55 +00:00
|
|
|
uint64_t getTVmSec() const { return m_tv_msec; }
|
2019-02-02 23:26:26 +00:00
|
|
|
int getMinNbBlocks() { return m_remoteInputBuffer.getMinNbBlocks(); }
|
|
|
|
int getMaxNbRecovery() { return m_remoteInputBuffer.getMaxNbRecovery(); }
|
2016-06-19 07:56:49 +00:00
|
|
|
public slots:
|
|
|
|
void dataReadyRead();
|
|
|
|
|
|
|
|
private:
|
2019-05-08 20:11:53 +00:00
|
|
|
DeviceAPI *m_deviceAPI;
|
2017-12-26 01:18:30 +00:00
|
|
|
const QTimer& m_masterTimer;
|
|
|
|
bool m_masterTimerConnected;
|
|
|
|
bool m_running;
|
2018-02-24 09:29:27 +00:00
|
|
|
uint32_t m_rateDivider;
|
2019-02-02 23:26:26 +00:00
|
|
|
RemoteInputBuffer m_remoteInputBuffer;
|
2016-06-19 07:56:49 +00:00
|
|
|
QUdpSocket *m_dataSocket;
|
|
|
|
QHostAddress m_dataAddress;
|
|
|
|
QHostAddress m_remoteAddress;
|
|
|
|
quint16 m_dataPort;
|
|
|
|
bool m_dataConnected;
|
|
|
|
char *m_udpBuf;
|
|
|
|
qint64 m_udpReadBytes;
|
2016-10-06 17:18:02 +00:00
|
|
|
SampleSinkFifo *m_sampleFifo;
|
2016-06-19 07:56:49 +00:00
|
|
|
uint32_t m_samplerate;
|
2019-04-26 01:07:50 +00:00
|
|
|
uint64_t m_centerFrequency;
|
2018-11-13 12:45:55 +00:00
|
|
|
uint64_t m_tv_msec;
|
2016-06-19 07:56:49 +00:00
|
|
|
MessageQueue *m_outputMessageQueueToGUI;
|
|
|
|
uint32_t m_tickCount;
|
|
|
|
std::size_t m_samplesCount;
|
|
|
|
QTimer *m_timer;
|
|
|
|
|
|
|
|
QElapsedTimer m_elapsedTimer;
|
|
|
|
int m_throttlems;
|
2019-04-30 06:43:55 +00:00
|
|
|
int32_t m_readLengthSamples;
|
2016-06-19 07:56:49 +00:00
|
|
|
uint32_t m_readLength;
|
2018-01-24 07:49:18 +00:00
|
|
|
int32_t *m_converterBuffer;
|
|
|
|
uint32_t m_converterBufferNbSamples;
|
2016-06-19 07:56:49 +00:00
|
|
|
bool m_throttleToggle;
|
|
|
|
bool m_autoCorrBuffer;
|
|
|
|
|
2017-12-26 01:18:30 +00:00
|
|
|
void connectTimer();
|
|
|
|
void disconnectTimer();
|
2016-06-19 07:56:49 +00:00
|
|
|
void processData();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void tick();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-02-02 23:26:26 +00:00
|
|
|
#endif /* PLUGINS_SAMPLESOURCE_REMOTEINPUT_REMOTEINPUTUDPHANDLER_H_ */
|