1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-30 03:38:55 -05:00
sdrangel/sdrbase/dsp/filesink.h

54 lines
1.2 KiB
C
Raw Normal View History

2015-07-28 17:54:17 -04:00
#ifndef INCLUDE_FILESINK_H
#define INCLUDE_FILESINK_H
#include <string>
#include <iostream>
#include <fstream>
#include <ctime>
#include "dsp/samplesink.h"
#include "util/export.h"
class Message;
2015-07-28 17:54:17 -04:00
2015-08-29 19:26:51 -04:00
class SDRANGEL_API FileSink : public SampleSink {
2015-07-28 17:54:17 -04:00
public:
struct Header
{
int sampleRate;
quint64 centerFrequency;
std::time_t startTimeStamp;
};
FileSink();
FileSink(const std::string& filename);
2015-08-13 02:51:33 -04:00
virtual ~FileSink();
2015-07-28 17:54:17 -04:00
quint64 getByteCount() const { return m_byteCount; }
void setFileName(const std::string& filename);
2015-07-28 17:54:17 -04:00
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
2015-08-13 02:51:33 -04:00
virtual void start();
virtual void stop();
2015-08-13 23:00:28 -04:00
virtual bool handleMessage(const Message& message);
2015-07-28 17:54:17 -04: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-13 23:00:28 -04:00
void handleConfigure(const std::string& fileName);
2015-07-28 17:54:17 -04:00
void writeHeader();
};
#endif // INCLUDE_FILESINK_H