| 
									
										
										
										
											2016-06-19 09:56:49 +02: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                  //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-09 13:58:27 +02:00
										 |  |  | #ifndef PLUGINS_SAMPLESOURCE_SDRDAEMONSOURCE_SDRDAEMONSOURCEUDPHANDLER_H_
 | 
					
						
							|  |  |  | #define PLUGINS_SAMPLESOURCE_SDRDAEMONSOURCE_SDRDAEMONSOURCEUDPHANDLER_H_
 | 
					
						
							| 
									
										
										
										
											2016-06-19 09:56:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <QObject>
 | 
					
						
							|  |  |  | #include <QUdpSocket>
 | 
					
						
							|  |  |  | #include <QHostAddress>
 | 
					
						
							|  |  |  | #include <QMutex>
 | 
					
						
							|  |  |  | #include <QElapsedTimer>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-09 13:58:27 +02:00
										 |  |  | #include "sdrdaemonsourcebuffer.h"
 | 
					
						
							| 
									
										
										
										
											2016-06-19 09:56:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-09 14:14:32 +02:00
										 |  |  | #define SDRDAEMONSOURCE_THROTTLE_MS 50
 | 
					
						
							| 
									
										
										
										
											2016-06-19 09:56:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-06 19:18:02 +02:00
										 |  |  | class SampleSinkFifo; | 
					
						
							| 
									
										
										
										
											2016-06-19 09:56:49 +02:00
										 |  |  | class MessageQueue; | 
					
						
							|  |  |  | class QTimer; | 
					
						
							| 
									
										
										
										
											2016-10-11 01:17:55 +02:00
										 |  |  | class DeviceSourceAPI; | 
					
						
							| 
									
										
										
										
											2016-06-19 09:56:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-09 14:14:32 +02:00
										 |  |  | class SDRdaemonSourceUDPHandler : public QObject | 
					
						
							| 
									
										
										
										
											2016-06-19 09:56:49 +02:00
										 |  |  | { | 
					
						
							|  |  |  | 	Q_OBJECT | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2017-06-09 14:14:32 +02:00
										 |  |  | 	SDRdaemonSourceUDPHandler(SampleSinkFifo* sampleFifo, MessageQueue *outputMessageQueueToGUI, DeviceSourceAPI *deviceAPI); | 
					
						
							|  |  |  | 	~SDRdaemonSourceUDPHandler(); | 
					
						
							| 
									
										
										
										
											2017-09-17 01:23:54 +02:00
										 |  |  | 	void setMessageQueueToGUI(MessageQueue *queue) { m_outputMessageQueueToGUI = queue; } | 
					
						
							| 
									
										
										
										
											2016-06-19 09:56:49 +02:00
										 |  |  | 	void connectTimer(const QTimer* timer); | 
					
						
							|  |  |  | 	void start(); | 
					
						
							|  |  |  | 	void stop(); | 
					
						
							|  |  |  | 	void configureUDPLink(const QString& address, quint16 port); | 
					
						
							|  |  |  | 	void getRemoteAddress(QString& s) const { s = m_remoteAddress.toString(); } | 
					
						
							| 
									
										
										
										
											2017-06-09 14:14:32 +02:00
										 |  |  |     int getNbOriginalBlocks() const { return SDRdaemonSourceBuffer::m_nbOriginalBlocks; } | 
					
						
							| 
									
										
										
										
											2016-06-19 09:56:49 +02:00
										 |  |  | public slots: | 
					
						
							|  |  |  | 	void dataReadyRead(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2016-10-11 01:17:55 +02:00
										 |  |  | 	DeviceSourceAPI *m_deviceAPI; | 
					
						
							| 
									
										
										
										
											2017-06-09 14:14:32 +02:00
										 |  |  | 	SDRdaemonSourceBuffer m_sdrDaemonBuffer; | 
					
						
							| 
									
										
										
										
											2016-06-19 09:56:49 +02: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 19:18:02 +02:00
										 |  |  | 	SampleSinkFifo *m_sampleFifo; | 
					
						
							| 
									
										
										
										
											2016-06-19 09:56:49 +02:00
										 |  |  | 	uint32_t m_samplerate; | 
					
						
							|  |  |  | 	uint32_t m_centerFrequency; | 
					
						
							|  |  |  | 	uint32_t m_tv_sec; | 
					
						
							|  |  |  | 	uint32_t m_tv_usec; | 
					
						
							|  |  |  | 	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; | 
					
						
							|  |  |  |     bool m_throttleToggle; | 
					
						
							| 
									
										
										
										
											2017-05-25 20:13:34 +02:00
										 |  |  |     uint32_t m_rateDivider; | 
					
						
							| 
									
										
										
										
											2016-06-19 09:56:49 +02:00
										 |  |  |     bool m_autoCorrBuffer; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void processData(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private slots: | 
					
						
							|  |  |  | 	void tick(); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-09 13:58:27 +02:00
										 |  |  | #endif /* PLUGINS_SAMPLESOURCE_SDRDAEMONSOURCE_SDRDAEMONSOURCEUDPHANDLER_H_ */
 |