| 
									
										
										
										
											2015-07-28 23:54:17 +02:00
										 |  |  | #ifndef INCLUDE_FILESINK_H
 | 
					
						
							|  |  |  | #define INCLUDE_FILESINK_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-02 22:29:04 +02:00
										 |  |  | #include <dsp/basebandsamplesink.h>
 | 
					
						
							| 
									
										
										
										
											2015-07-28 23:54:17 +02:00
										 |  |  | #include <string>
 | 
					
						
							|  |  |  | #include <iostream>
 | 
					
						
							|  |  |  | #include <fstream>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <ctime>
 | 
					
						
							|  |  |  | #include "util/export.h"
 | 
					
						
							| 
									
										
										
										
											2016-05-12 10:31:57 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | class Message; | 
					
						
							| 
									
										
										
										
											2015-07-28 23:54:17 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-02 22:29:04 +02:00
										 |  |  | class SDRANGEL_API FileRecord : public BasebandSampleSink { | 
					
						
							| 
									
										
										
										
											2015-07-28 23:54:17 +02:00
										 |  |  | public: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     struct Header | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         int         sampleRate; | 
					
						
							|  |  |  |         quint64     centerFrequency; | 
					
						
							|  |  |  |         std::time_t startTimeStamp; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-02 10:30:58 +02:00
										 |  |  | 	FileRecord(); | 
					
						
							|  |  |  |     FileRecord(const std::string& filename); | 
					
						
							|  |  |  | 	virtual ~FileRecord(); | 
					
						
							| 
									
										
										
										
											2016-05-12 10:31:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-28 23:54:17 +02:00
										 |  |  |     quint64 getByteCount() const { return m_byteCount; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-12 10:31:57 +02:00
										 |  |  |     void setFileName(const std::string& filename); | 
					
						
							| 
									
										
										
										
											2015-07-28 23:54:17 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-25 08:24:23 +02:00
										 |  |  | 	virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly); | 
					
						
							| 
									
										
										
										
											2015-08-13 08:51:33 +02:00
										 |  |  | 	virtual void start(); | 
					
						
							|  |  |  | 	virtual void stop(); | 
					
						
							| 
									
										
										
										
											2015-08-14 05:00:28 +02:00
										 |  |  | 	virtual bool handleMessage(const Message& message); | 
					
						
							| 
									
										
										
										
											2015-07-28 23:54:17 +02:00
										 |  |  |     void startRecording(); | 
					
						
							|  |  |  |     void stopRecording(); | 
					
						
							|  |  |  |     static void readHeader(std::ifstream& samplefile, Header& header); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	std::string m_fileName; | 
					
						
							|  |  |  | 	int m_sampleRate; | 
					
						
							|  |  |  | 	quint64 m_centerFrequency; | 
					
						
							|  |  |  | 	bool m_recordOn; | 
					
						
							|  |  |  |     bool m_recordStart; | 
					
						
							|  |  |  |     std::ofstream m_sampleFile; | 
					
						
							|  |  |  |     quint64 m_byteCount; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-14 05:00:28 +02:00
										 |  |  | 	void handleConfigure(const std::string& fileName); | 
					
						
							| 
									
										
										
										
											2015-07-28 23:54:17 +02:00
										 |  |  |     void writeHeader(); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif // INCLUDE_FILESINK_H
 |