2018-10-09 07:26:28 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// 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 //
|
2019-04-11 12:32:15 +00:00
|
|
|
// (at your option) any later version. //
|
2018-10-09 07:26:28 +00:00
|
|
|
// //
|
|
|
|
// 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 21:54:17 +00:00
|
|
|
|
2016-10-02 20:29:04 +00:00
|
|
|
#include <dsp/basebandsamplesink.h>
|
2015-07-28 21:54:17 +00:00
|
|
|
#include <string>
|
|
|
|
#include <iostream>
|
|
|
|
#include <fstream>
|
|
|
|
#include <ctime>
|
2020-08-06 08:46:49 +00:00
|
|
|
|
|
|
|
#include "dsp/filerecordinterface.h"
|
2018-03-20 12:49:21 +00:00
|
|
|
#include "export.h"
|
2016-05-12 08:31:57 +00:00
|
|
|
|
|
|
|
class Message;
|
2015-07-28 21:54:17 +00:00
|
|
|
|
2020-08-06 08:46:49 +00:00
|
|
|
class SDRBASE_API FileRecord : public FileRecordInterface {
|
2015-07-28 21:54:17 +00:00
|
|
|
public:
|
|
|
|
|
2018-10-09 14:40:57 +00:00
|
|
|
#pragma pack(push, 1)
|
2015-07-28 21:54:17 +00:00
|
|
|
struct Header
|
|
|
|
{
|
2018-10-09 14:40:57 +00:00
|
|
|
quint32 sampleRate;
|
2018-10-09 07:26:28 +00:00
|
|
|
quint64 centerFrequency;
|
|
|
|
quint64 startTimeStamp;
|
|
|
|
quint32 sampleSize;
|
|
|
|
quint32 filler;
|
|
|
|
quint32 crc32;
|
2015-07-28 21:54:17 +00:00
|
|
|
};
|
2018-10-09 14:40:57 +00:00
|
|
|
#pragma pack(pop)
|
2015-07-28 21:54:17 +00:00
|
|
|
|
2016-10-02 08:30:58 +00:00
|
|
|
FileRecord();
|
2020-08-06 08:46:49 +00:00
|
|
|
FileRecord(const QString& fileBase);
|
2016-10-02 08:30:58 +00:00
|
|
|
virtual ~FileRecord();
|
2016-05-12 08:31:57 +00:00
|
|
|
|
2015-07-28 21:54:17 +00:00
|
|
|
quint64 getByteCount() const { return m_byteCount; }
|
2020-08-06 08:46:49 +00:00
|
|
|
void setMsShift(int shift) { m_msShift = shift; }
|
|
|
|
const QString& getCurrentFileName() { return m_curentFileName; }
|
2015-07-28 21:54:17 +00:00
|
|
|
|
2019-05-28 06:56:36 +00:00
|
|
|
void genUniqueFileName(uint deviceUID, int istream = -1);
|
2015-07-28 21:54:17 +00:00
|
|
|
|
2015-08-25 06:24:23 +00:00
|
|
|
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
|
2015-08-13 06:51:33 +00:00
|
|
|
virtual void start();
|
|
|
|
virtual void stop();
|
2015-08-14 03:00:28 +00:00
|
|
|
virtual bool handleMessage(const Message& message);
|
2020-08-06 08:46:49 +00:00
|
|
|
|
|
|
|
virtual void setFileName(const QString& fileBase);
|
|
|
|
virtual void startRecording();
|
|
|
|
virtual void stopRecording();
|
|
|
|
virtual bool isRecording() const { return m_recordOn; }
|
|
|
|
|
2018-10-09 07:26:28 +00:00
|
|
|
static bool readHeader(std::ifstream& samplefile, Header& header); //!< returns true if CRC checksum is correct else false
|
2018-10-10 12:05:21 +00:00
|
|
|
static void writeHeader(std::ofstream& samplefile, Header& header);
|
2015-07-28 21:54:17 +00:00
|
|
|
|
|
|
|
private:
|
2020-08-06 08:46:49 +00:00
|
|
|
QString m_fileBase;
|
2018-10-09 07:26:28 +00:00
|
|
|
quint32 m_sampleRate;
|
2015-07-28 21:54:17 +00:00
|
|
|
quint64 m_centerFrequency;
|
|
|
|
bool m_recordOn;
|
|
|
|
bool m_recordStart;
|
|
|
|
std::ofstream m_sampleFile;
|
2020-08-06 08:46:49 +00:00
|
|
|
QString m_curentFileName;
|
2015-07-28 21:54:17 +00:00
|
|
|
quint64 m_byteCount;
|
2020-08-06 08:46:49 +00:00
|
|
|
int m_msShift;
|
2015-07-28 21:54:17 +00:00
|
|
|
|
|
|
|
void writeHeader();
|
|
|
|
};
|
|
|
|
|
2018-10-09 07:26:28 +00:00
|
|
|
#endif // INCLUDE_FILERECORD_H
|