| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2023-11-18 10:07:41 +01:00
										 |  |  | // Copyright (C) 2020, 2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com>         //
 | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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                  //
 | 
					
						
							|  |  |  | // (at your option) any later version.                                           //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef INCLUDE_SIGMFFILEINPUT_H
 | 
					
						
							|  |  |  | #define INCLUDE_SIGMFFILEINPUT_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <ctime>
 | 
					
						
							|  |  |  | #include <iostream>
 | 
					
						
							|  |  |  | #include <fstream>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <QString>
 | 
					
						
							|  |  |  | #include <QByteArray>
 | 
					
						
							|  |  |  | #include <QTimer>
 | 
					
						
							|  |  |  | #include <QThread>
 | 
					
						
							|  |  |  | #include <QNetworkRequest>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "dsp/sigmf_forward.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "dsp/devicesamplesource.h"
 | 
					
						
							|  |  |  | #include "sigmffileinputsettings.h"
 | 
					
						
							|  |  |  | #include "sigmffiledata.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class QNetworkAccessManager; | 
					
						
							|  |  |  | class QNetworkReply; | 
					
						
							|  |  |  | class SigMFFileInputWorker; | 
					
						
							|  |  |  | class DeviceAPI; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class SigMFFileInput : public DeviceSampleSource { | 
					
						
							|  |  |  | 	Q_OBJECT | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * Communicate settings | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  | 	class MsgConfigureSigMFFileInput : public Message { | 
					
						
							|  |  |  | 		MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public: | 
					
						
							|  |  |  | 		const SigMFFileInputSettings& getSettings() const { return m_settings; } | 
					
						
							| 
									
										
										
										
											2022-10-29 03:21:45 +02:00
										 |  |  |         const QList<QString>& getSettingsKeys() const { return m_settingsKeys; } | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 		bool getForce() const { return m_force; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-29 03:21:45 +02:00
										 |  |  | 		static MsgConfigureSigMFFileInput* create(const SigMFFileInputSettings& settings, const QList<QString>& settingsKeys, bool force) { | 
					
						
							|  |  |  | 			return new MsgConfigureSigMFFileInput(settings, settingsKeys, force); | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	private: | 
					
						
							|  |  |  | 		SigMFFileInputSettings m_settings; | 
					
						
							| 
									
										
										
										
											2022-10-29 03:21:45 +02:00
										 |  |  |         QList<QString> m_settingsKeys; | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  |         bool m_force; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-29 03:21:45 +02:00
										 |  |  | 		MsgConfigureSigMFFileInput(const SigMFFileInputSettings& settings, const QList<QString>& settingsKeys, bool force) : | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 			Message(), | 
					
						
							|  |  |  | 			m_settings(settings), | 
					
						
							| 
									
										
										
										
											2022-10-29 03:21:45 +02:00
										 |  |  |             m_settingsKeys(settingsKeys), | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 			m_force(force) | 
					
						
							|  |  |  | 		{ } | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * Start/stop track play | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  | 	class MsgConfigureTrackWork : public Message { | 
					
						
							|  |  |  | 		MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public: | 
					
						
							|  |  |  | 		bool isWorking() const { return m_working; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		static MsgConfigureTrackWork* create(bool working) { | 
					
						
							|  |  |  | 			return new MsgConfigureTrackWork(working); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	private: | 
					
						
							|  |  |  | 		bool m_working; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  | 		explicit MsgConfigureTrackWork(bool working) : | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 			Message(), | 
					
						
							|  |  |  | 			m_working(working) | 
					
						
							|  |  |  | 		{ } | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * Start/stop full file play | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  | 	class MsgConfigureFileWork : public Message { | 
					
						
							|  |  |  | 		MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public: | 
					
						
							|  |  |  | 		bool isWorking() const { return m_working; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		static MsgConfigureFileWork* create(bool working) { | 
					
						
							|  |  |  | 			return new MsgConfigureFileWork(working); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	private: | 
					
						
							|  |  |  | 		bool m_working; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  | 		explicit MsgConfigureFileWork(bool working) : | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 			Message(), | 
					
						
							|  |  |  | 			m_working(working) | 
					
						
							|  |  |  | 		{ } | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * Move to track | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  | 	class MsgConfigureTrackIndex : public Message { | 
					
						
							|  |  |  | 		MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public: | 
					
						
							|  |  |  |         int getTrackIndex() const { return m_trackIndex; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		static MsgConfigureTrackIndex* create(int trackIndex) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			return new MsgConfigureTrackIndex(trackIndex); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	private: | 
					
						
							|  |  |  |         int m_trackIndex; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  | 		explicit MsgConfigureTrackIndex(int trackIndex) : | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 			Message(), | 
					
						
							|  |  |  |             m_trackIndex(trackIndex) | 
					
						
							|  |  |  | 		{ } | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * Seek position in track | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  | 	class MsgConfigureTrackSeek : public Message { | 
					
						
							|  |  |  | 		MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public: | 
					
						
							|  |  |  | 		int getMillis() const { return m_seekMillis; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		static MsgConfigureTrackSeek* create(int seekMillis) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			return new MsgConfigureTrackSeek(seekMillis); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  | 	private: | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 		int m_seekMillis; //!< millis of seek position from the beginning 0..1000
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  | 		explicit MsgConfigureTrackSeek(int seekMillis) : | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 			Message(), | 
					
						
							|  |  |  | 			m_seekMillis(seekMillis) | 
					
						
							|  |  |  | 		{ } | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * Seek position in full file | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  | 	class MsgConfigureFileSeek : public Message { | 
					
						
							|  |  |  | 		MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public: | 
					
						
							|  |  |  | 		int getMillis() const { return m_seekMillis; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		static MsgConfigureFileSeek* create(int seekMillis) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			return new MsgConfigureFileSeek(seekMillis); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  | 	private: | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 		int m_seekMillis; //!< millis of seek position from the beginning 0..1000
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  | 		explicit MsgConfigureFileSeek(int seekMillis) : | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 			Message(), | 
					
						
							|  |  |  | 			m_seekMillis(seekMillis) | 
					
						
							|  |  |  | 		{ } | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * Pull stram timing information | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  | 	class MsgConfigureFileInputStreamTiming : public Message { | 
					
						
							|  |  |  | 		MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		static MsgConfigureFileInputStreamTiming* create() | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			return new MsgConfigureFileInputStreamTiming(); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	private: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		MsgConfigureFileInputStreamTiming() : | 
					
						
							|  |  |  | 			Message() | 
					
						
							|  |  |  | 		{ } | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * Start/stop plugin | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     class MsgStartStop : public Message { | 
					
						
							|  |  |  |         MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public: | 
					
						
							|  |  |  |         bool getStartStop() const { return m_startStop; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         static MsgStartStop* create(bool startStop) { | 
					
						
							|  |  |  |             return new MsgStartStop(startStop); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  |     private: | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  |         bool m_startStop; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  |         explicit MsgStartStop(bool startStop) : | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  |             Message(), | 
					
						
							|  |  |  |             m_startStop(startStop) | 
					
						
							|  |  |  |         { } | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * Push start/stop information | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  | 	class MsgReportStartStop : public Message { | 
					
						
							|  |  |  | 		MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public: | 
					
						
							|  |  |  | 		bool getStartStop() const { return m_startStop; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		static MsgReportStartStop* create(bool startStop) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			return new MsgReportStartStop(startStop); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  | 	private: | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 		bool m_startStop; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  | 		explicit MsgReportStartStop(bool startStop) : | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 			Message(), | 
					
						
							|  |  |  | 			m_startStop(startStop) | 
					
						
							|  |  |  | 		{ } | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * Push meta data information | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     class MsgReportMetaData : public Message { | 
					
						
							|  |  |  |         MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public: | 
					
						
							|  |  |  |         const SigMFFileMetaInfo& getMetaInfo() const { return m_metaInfo; } | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  |         const QList<SigMFFileCapture>& getCaptures() const { return m_captures; } | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         static MsgReportMetaData* create(const SigMFFileMetaInfo& metaInfo, const QList<SigMFFileCapture>& captures) { | 
					
						
							|  |  |  |             return new MsgReportMetaData(metaInfo, captures); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  |     private: | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  |         SigMFFileMetaInfo m_metaInfo; | 
					
						
							|  |  |  |         QList<SigMFFileCapture> m_captures; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         MsgReportMetaData(const SigMFFileMetaInfo& metaInfo, const QList<SigMFFileCapture>& captures) : | 
					
						
							|  |  |  |             Message(), | 
					
						
							|  |  |  |             m_metaInfo(metaInfo), | 
					
						
							|  |  |  |             m_captures(captures) | 
					
						
							|  |  |  |         {} | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * Push track change | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     class MsgReportTrackChange : public Message { | 
					
						
							|  |  |  |         MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public: | 
					
						
							|  |  |  |         int getTrackIndex() const { return m_trackIndex; } | 
					
						
							|  |  |  |         static MsgReportTrackChange* create(int trackIndex) { | 
					
						
							|  |  |  |             return new MsgReportTrackChange(trackIndex); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private: | 
					
						
							|  |  |  |         int m_trackIndex; | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  |         explicit MsgReportTrackChange(int trackIndex) : | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  |             Message(), | 
					
						
							|  |  |  |             m_trackIndex(trackIndex) | 
					
						
							|  |  |  |         { } | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * Push stream timing information | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  | 	class MsgReportFileInputStreamTiming : public Message { | 
					
						
							|  |  |  | 		MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public: | 
					
						
							|  |  |  |         quint64 getSamplesCount() const { return m_samplesCount; } | 
					
						
							|  |  |  |         quint64 getTrackSamplesCount() const { return m_trackSamplesCount; } | 
					
						
							|  |  |  |         quint64 getTrackTimeStart() const { return m_trackTimeStart; } | 
					
						
							|  |  |  |         int getTrackNumber() const { return m_trackNumber; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         static MsgReportFileInputStreamTiming* create( | 
					
						
							|  |  |  |             quint64 samplesCount, | 
					
						
							|  |  |  |             quint64 trackSamplesCount, | 
					
						
							|  |  |  |             quint64 trackTimeStart, | 
					
						
							|  |  |  |             int trackNumber | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			return new MsgReportFileInputStreamTiming( | 
					
						
							|  |  |  |                 samplesCount, | 
					
						
							|  |  |  |                 trackSamplesCount, | 
					
						
							|  |  |  |                 trackTimeStart, | 
					
						
							|  |  |  |                 trackNumber | 
					
						
							|  |  |  |             ); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  | 	private: | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  |         quint64 m_samplesCount; | 
					
						
							|  |  |  |         quint64 m_trackSamplesCount; | 
					
						
							|  |  |  |         quint64 m_trackTimeStart; | 
					
						
							|  |  |  |         int m_trackNumber; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         MsgReportFileInputStreamTiming( | 
					
						
							|  |  |  |             quint64 samplesCount, | 
					
						
							|  |  |  |             quint64 trackSamplesCount, | 
					
						
							|  |  |  |             quint64 trackTimeStart, | 
					
						
							|  |  |  |             int trackNumber | 
					
						
							|  |  |  |         ) : | 
					
						
							|  |  |  | 			Message(), | 
					
						
							|  |  |  | 			m_samplesCount(samplesCount), | 
					
						
							|  |  |  |             m_trackSamplesCount(trackSamplesCount), | 
					
						
							|  |  |  |             m_trackTimeStart(trackTimeStart), | 
					
						
							|  |  |  |             m_trackNumber(trackNumber) | 
					
						
							|  |  |  | 		{ } | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * Push CRC (SHA512) information | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  | 	class MsgReportCRC : public Message { | 
					
						
							|  |  |  | 		MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public: | 
					
						
							|  |  |  | 		bool isOK() const { return m_ok; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		static MsgReportCRC* create(bool ok) { | 
					
						
							|  |  |  | 			return new MsgReportCRC(ok); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  | 	private: | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 		bool m_ok; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  | 		explicit MsgReportCRC(bool ok) : | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 			Message(), | 
					
						
							|  |  |  | 			m_ok(ok) | 
					
						
							|  |  |  | 		{ } | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * Push record total check information | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  | 	class MsgReportTotalSamplesCheck : public Message { | 
					
						
							|  |  |  | 		MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public: | 
					
						
							|  |  |  | 		bool isOK() const { return m_ok; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		static MsgReportTotalSamplesCheck* create(bool ok) { | 
					
						
							|  |  |  | 			return new MsgReportTotalSamplesCheck(ok); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  | 	private: | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 		bool m_ok; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  | 		explicit MsgReportTotalSamplesCheck(bool ok) : | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 			Message(), | 
					
						
							|  |  |  | 			m_ok(ok) | 
					
						
							|  |  |  | 		{ } | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  | 	explicit SigMFFileInput(DeviceAPI *deviceAPI); | 
					
						
							|  |  |  | 	~SigMFFileInput() final; | 
					
						
							|  |  |  | 	void destroy() final; | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  |     void init() final; | 
					
						
							|  |  |  | 	bool start() final; | 
					
						
							|  |  |  | 	void stop() final; | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  |     QByteArray serialize() const final; | 
					
						
							|  |  |  |     bool deserialize(const QByteArray& data) final; | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  |     void setMessageQueueToGUI(MessageQueue *queue) final { m_guiMessageQueue = queue; } | 
					
						
							|  |  |  | 	const QString& getDeviceDescription() const final; | 
					
						
							|  |  |  | 	int getSampleRate() const final; | 
					
						
							|  |  |  |     void setSampleRate(int sampleRate) final { (void) sampleRate; } | 
					
						
							|  |  |  | 	quint64 getCenterFrequency() const final; | 
					
						
							|  |  |  |     void setCenterFrequency(qint64 centerFrequency) final; | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  |     quint64 getStartingTimeStamp() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  | 	bool handleMessage(const Message& message) final; | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  | 	int webapiSettingsGet( | 
					
						
							|  |  |  |         SWGSDRangel::SWGDeviceSettings& response, | 
					
						
							|  |  |  |         QString& errorMessage) final; | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  | 	int webapiSettingsPutPatch( | 
					
						
							|  |  |  |         bool force, | 
					
						
							|  |  |  |         const QStringList& deviceSettingsKeys, | 
					
						
							|  |  |  |         SWGSDRangel::SWGDeviceSettings& response, // query + response
 | 
					
						
							|  |  |  |         QString& errorMessage) final; | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  |     int webapiRunGet( | 
					
						
							|  |  |  |         SWGSDRangel::SWGDeviceState& response, | 
					
						
							|  |  |  |         QString& errorMessage) final; | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  |     int webapiActionsPost( | 
					
						
							|  |  |  |         const QStringList& deviceActionsKeys, | 
					
						
							|  |  |  |         SWGSDRangel::SWGDeviceActions& query, | 
					
						
							|  |  |  |         QString& errorMessage) final; | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  |     int webapiRun( | 
					
						
							|  |  |  |         bool run, | 
					
						
							|  |  |  |         SWGSDRangel::SWGDeviceState& response, | 
					
						
							|  |  |  |         QString& errorMessage) final; | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  |     int webapiReportGet( | 
					
						
							|  |  |  |         SWGSDRangel::SWGDeviceReport& response, | 
					
						
							|  |  |  |         QString& errorMessage) final; | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     static void webapiFormatDeviceSettings( | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  |         SWGSDRangel::SWGDeviceSettings& response, | 
					
						
							|  |  |  |         const SigMFFileInputSettings& settings); | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     static void webapiUpdateDeviceSettings( | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  |         SigMFFileInputSettings& settings, | 
					
						
							|  |  |  |         const QStringList& deviceSettingsKeys, | 
					
						
							|  |  |  |         SWGSDRangel::SWGDeviceSettings& response); | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	DeviceAPI *m_deviceAPI; | 
					
						
							|  |  |  | 	QMutex m_mutex; | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  |     bool m_running = false; | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 	SigMFFileInputSettings m_settings; | 
					
						
							|  |  |  | 	std::ifstream m_metaStream; | 
					
						
							|  |  |  |     std::ifstream m_dataStream; | 
					
						
							|  |  |  |     SigMFFileMetaInfo m_metaInfo; | 
					
						
							|  |  |  |     QList<SigMFFileCapture> m_captures; | 
					
						
							|  |  |  |     std::vector<uint64_t> m_captureStarts; | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  |     bool m_trackMode = false; | 
					
						
							|  |  |  |     int m_currentTrackIndex = 0; | 
					
						
							|  |  |  |     bool m_recordOpen = false; | 
					
						
							|  |  |  |     bool m_crcAvailable = false; | 
					
						
							|  |  |  |     bool m_crcOK = false; | 
					
						
							|  |  |  |     bool m_recordLengthOK = false; | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  |     QString m_recordSummary; | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  | 	SigMFFileInputWorker* m_fileInputWorker = nullptr; | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  |     QThread m_fileInputWorkerThread; | 
					
						
							| 
									
										
										
										
											2024-08-25 23:36:46 +02:00
										 |  |  | 	QString m_deviceDescription = "SigMFFileInput"; | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  | 	int m_sampleRate = 48000; | 
					
						
							|  |  |  | 	unsigned int m_sampleBytes = 1; | 
					
						
							|  |  |  | 	quint64 m_centerFrequency = 0; | 
					
						
							|  |  |  |     quint64 m_recordLength = 0; //!< record length in seconds computed from file size
 | 
					
						
							|  |  |  |     quint64 m_startingTimeStamp = 0; | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | 	QTimer m_masterTimer; | 
					
						
							|  |  |  |     QNetworkAccessManager *m_networkManager; | 
					
						
							|  |  |  |     QNetworkRequest m_networkRequest; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     void startWorker(); | 
					
						
							|  |  |  |     void stopWorker(); | 
					
						
							|  |  |  | 	bool openFileStreams(const QString& fileName); | 
					
						
							|  |  |  |     void extractMeta( | 
					
						
							|  |  |  |         sigmf::SigMF<sigmf::Global<core::DescrT, sdrangel::DescrT>, | 
					
						
							|  |  |  |         sigmf::Capture<core::DescrT, sdrangel::DescrT>, | 
					
						
							|  |  |  |         sigmf::Annotation<core::DescrT> >* metaRecord, | 
					
						
							|  |  |  |         uint64_t dataFileSize | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     void extractCaptures( | 
					
						
							|  |  |  |         sigmf::SigMF<sigmf::Global<core::DescrT, sdrangel::DescrT>, | 
					
						
							|  |  |  |         sigmf::Capture<core::DescrT, sdrangel::DescrT>, | 
					
						
							|  |  |  |         sigmf::Annotation<core::DescrT> >* metaRecord | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     static void analyzeDataType(const std::string& dataTypeString, SigMFFileDataType& dataType); | 
					
						
							| 
									
										
										
										
											2020-11-15 12:02:04 +01:00
										 |  |  |     uint64_t getTrackSampleStart(unsigned int trackIndex); | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  |     int getTrackIndex(uint64_t sampleIndex); | 
					
						
							|  |  |  | 	void seekFileStream(uint64_t sampleIndex); | 
					
						
							|  |  |  | 	void seekTrackMillis(int seekMillis); | 
					
						
							|  |  |  |     void seekFileMillis(int seekMillis); | 
					
						
							| 
									
										
										
										
											2022-10-29 03:21:45 +02:00
										 |  |  | 	bool applySettings(const SigMFFileInputSettings& settings, const QList<QString>& settingsKeys, bool force = false); | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  |     void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response); | 
					
						
							| 
									
										
										
										
											2022-10-29 03:21:45 +02:00
										 |  |  |     void webapiReverseSendSettings(const QList<QString>& deviceSettingsKeys, const SigMFFileInputSettings& settings, bool force); | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  |     void webapiReverseSendStartStop(bool start); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private slots: | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  |     void networkManagerFinished(QNetworkReply *reply) const; | 
					
						
							| 
									
										
										
										
											2020-11-10 02:09:21 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif // INCLUDE_SIGMFFILEINPUT_H
 |