/////////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2017 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 // // // // 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 . // /////////////////////////////////////////////////////////////////////////////////// #ifndef PLUGINS_CHANNELTX_UDPSINK_UDPSINKUDPHANDLER_H_ #define PLUGINS_CHANNELTX_UDPSINK_UDPSINKUDPHANDLER_H_ #include #include #include #include #include "dsp/dsptypes.h" class UDPSinkUDPHandler : public QObject { Q_OBJECT public: UDPSinkUDPHandler(); virtual ~UDPSinkUDPHandler(); void start(); void stop(); void configureUDPLink(const QString& address, quint16 port); void resetReadIndex(); void readSample(Real &t); void readSample(Sample &s); static const int m_udpBlockSize = 512; // UDP block size in number of bytes static const int m_nbUDPFrames = 32; // number of frames of block size in the UDP buffer public slots: void dataReadyRead(); private: void moveData(); void advanceReadPointer(int nbBytes); QUdpSocket *m_dataSocket; QHostAddress m_dataAddress; QHostAddress m_remoteAddress; quint16 m_dataPort; bool m_dataConnected; char m_udpTmpBuf[m_udpBlockSize]; qint64 m_udpReadBytes; char m_udpBuf[m_nbUDPFrames][m_udpBlockSize]; int m_writeIndex; int m_readFrameIndex; int m_readIndex; }; #endif /* PLUGINS_CHANNELTX_UDPSINK_UDPSINKUDPHANDLER_H_ */