| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | // 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                  //
 | 
					
						
							| 
									
										
										
										
											2019-04-11 06:39:30 +02:00
										 |  |  | // (at your option) any later version.                                           //
 | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02: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/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-12 09:42:33 +02:00
										 |  |  | #ifndef INCLUDE_REMOTEOUTPUTWORKER_H
 | 
					
						
							|  |  |  | #define INCLUDE_REMOTEOUTPUTWORKER_H
 | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-04 08:43:07 +02:00
										 |  |  | #include <iostream>
 | 
					
						
							|  |  |  | #include <fstream>
 | 
					
						
							|  |  |  | #include <cstdlib>
 | 
					
						
							|  |  |  | #include <stdint.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-12 09:42:33 +02:00
										 |  |  | #include <QObject>
 | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | #include <QTimer>
 | 
					
						
							|  |  |  | #include <QElapsedTimer>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "dsp/inthalfbandfilter.h"
 | 
					
						
							|  |  |  | #include "dsp/interpolators.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-21 04:41:47 +02:00
										 |  |  | #include "udpsinkfec.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-02 22:58:42 +01:00
										 |  |  | #define REMOTEOUTPUT_THROTTLE_MS 50
 | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  | class SampleSourceFifo; | 
					
						
							| 
									
										
										
										
											2018-09-04 08:43:07 +02:00
										 |  |  | struct timeval; | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-12 09:42:33 +02:00
										 |  |  | class RemoteOutputWorker : public QObject { | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 	Q_OBJECT | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2020-07-12 09:42:33 +02:00
										 |  |  | 	RemoteOutputWorker(SampleSourceFifo* sampleFifo, QObject* parent = 0); | 
					
						
							|  |  |  | 	~RemoteOutputWorker(); | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void startWork(); | 
					
						
							|  |  |  | 	void stopWork(); | 
					
						
							| 
									
										
										
										
											2017-05-21 20:13:17 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 	void setSamplerate(int samplerate); | 
					
						
							| 
									
										
										
										
											2017-05-21 04:41:47 +02:00
										 |  |  |     void setNbBlocksFEC(uint32_t nbBlocksFEC) { m_udpSinkFEC.setNbBlocksFEC(nbBlocksFEC); }; | 
					
						
							| 
									
										
										
										
											2018-09-11 01:01:43 +02:00
										 |  |  |     void setTxDelay(float txDelay) { m_udpSinkFEC.setTxDelay(txDelay); }; | 
					
						
							| 
									
										
										
										
											2018-08-29 18:39:40 +02:00
										 |  |  |     void setDataAddress(const QString& address, uint16_t port) { m_udpSinkFEC.setRemoteAddress(address, port); } | 
					
						
							| 
									
										
										
										
											2017-05-21 20:13:17 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     bool isRunning() const { return m_running; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-13 14:21:36 +01:00
										 |  |  |     uint32_t getSamplesCount(uint64_t& ts_usecs) const; | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  |     void setSamplesCount(int samplesCount) { m_samplesCount = samplesCount; } | 
					
						
							| 
									
										
										
										
											2017-06-05 01:18:35 +02:00
										 |  |  |     void setChunkCorrection(int chunkCorrection) { m_chunkCorrection = chunkCorrection; } | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void connectTimer(const QTimer& timer); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2018-02-24 10:29:27 +01:00
										 |  |  | 	volatile bool m_running; | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-05 01:18:35 +02:00
										 |  |  | 	int m_samplesChunkSize; | 
					
						
							| 
									
										
										
										
											2019-11-15 01:04:24 +01:00
										 |  |  | 	SampleSourceFifo* m_sampleFifo; | 
					
						
							| 
									
										
										
										
											2018-08-31 07:38:30 +02:00
										 |  |  |     uint32_t m_samplesCount; | 
					
						
							| 
									
										
										
										
											2017-06-05 01:18:35 +02:00
										 |  |  |     int m_chunkCorrection; | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	int m_samplerate; | 
					
						
							|  |  |  |     int m_throttlems; | 
					
						
							|  |  |  |     int m_maxThrottlems; | 
					
						
							|  |  |  |     QElapsedTimer m_elapsedTimer; | 
					
						
							|  |  |  |     bool m_throttleToggle; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-21 04:41:47 +02:00
										 |  |  |     UDPSinkFEC m_udpSinkFEC; | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | private slots: | 
					
						
							|  |  |  | 	void tick(); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-02 22:58:42 +01:00
										 |  |  | #endif // INCLUDE_REMOTEOUTPUTTHREAD_H
 |