1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-27 10:19:15 -05:00
sdrangel/include-gpl/dsp/filesink.h
2015-08-30 01:26:51 +02:00

73 lines
1.6 KiB
C++

#ifndef INCLUDE_FILESINK_H
#define INCLUDE_FILESINK_H
#include <string>
#include <iostream>
#include <fstream>
#include <ctime>
#include "dsp/samplesink.h"
#include "util/export.h"
#include "util/message.h"
#include "util/messagequeue.h"
class SDRANGEL_API FileSink : public SampleSink {
public:
struct Header
{
int sampleRate;
quint64 centerFrequency;
std::time_t startTimeStamp;
};
FileSink();
virtual ~FileSink();
quint64 getByteCount() const { return m_byteCount; }
void configure(MessageQueue* msgQueue, const std::string& filename);
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
virtual void start();
virtual void stop();
virtual bool handleMessage(const Message& message);
void startRecording();
void stopRecording();
static void readHeader(std::ifstream& samplefile, Header& header);
private:
class MsgConfigureFileSink : public Message {
MESSAGE_CLASS_DECLARATION
public:
const std::string& getFileName() const { return m_fileName; }
static MsgConfigureFileSink* create(const std::string& fileName)
{
return new MsgConfigureFileSink(fileName);
}
private:
std::string m_fileName;
MsgConfigureFileSink(const std::string& fileName) :
Message(),
m_fileName(fileName)
{ }
};
std::string m_fileName;
int m_sampleRate;
quint64 m_centerFrequency;
bool m_recordOn;
bool m_recordStart;
std::ofstream m_sampleFile;
quint64 m_byteCount;
void handleConfigure(const std::string& fileName);
void writeHeader();
};
#endif // INCLUDE_FILESINK_H