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