1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 17:58:43 -05:00
sdrangel/sdrbase/dsp/filerecord.h

79 lines
2.9 KiB
C
Raw Normal View History

///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015-2018 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 //
// (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_FILERECORD_H
#define INCLUDE_FILERECORD_H
2015-07-28 17:54:17 -04:00
#include <dsp/basebandsamplesink.h>
2015-07-28 17:54:17 -04:00
#include <string>
#include <iostream>
#include <fstream>
#include <ctime>
#include "export.h"
class Message;
2015-07-28 17:54:17 -04:00
2018-03-03 14:23:38 -05:00
class SDRBASE_API FileRecord : public BasebandSampleSink {
2015-07-28 17:54:17 -04:00
public:
#pragma pack(push, 1)
2015-07-28 17:54:17 -04:00
struct Header
{
quint32 sampleRate;
quint64 centerFrequency;
quint64 startTimeStamp;
quint32 sampleSize;
quint32 filler;
quint32 crc32;
2015-07-28 17:54:17 -04:00
};
#pragma pack(pop)
2015-07-28 17:54:17 -04:00
FileRecord();
2018-05-08 05:03:09 -04:00
FileRecord(const QString& filename);
virtual ~FileRecord();
2015-07-28 17:54:17 -04:00
quint64 getByteCount() const { return m_byteCount; }
2018-05-08 05:03:09 -04:00
void setFileName(const QString& filename);
void genUniqueFileName(uint deviceUID, int istream = -1);
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();
bool isRecording() const { return m_recordOn; }
static bool readHeader(std::ifstream& samplefile, Header& header); //!< returns true if CRC checksum is correct else false
static void writeHeader(std::ofstream& samplefile, Header& header);
2015-07-28 17:54:17 -04:00
private:
2018-05-08 05:03:09 -04:00
QString m_fileName;
quint32 m_sampleRate;
2015-07-28 17:54:17 -04:00
quint64 m_centerFrequency;
bool m_recordOn;
bool m_recordStart;
std::ofstream m_sampleFile;
quint64 m_byteCount;
2018-05-08 05:03:09 -04:00
void handleConfigure(const QString& fileName);
2015-07-28 17:54:17 -04:00
void writeHeader();
};
#endif // INCLUDE_FILERECORD_H