SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
filerecord.h
Go to the documentation of this file.
1 // Copyright (C) 2015-2018 Edouard Griffiths, F4EXB //
3 // //
4 // This program is free software; you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation as version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // This program is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License V3 for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
17 
18 #ifndef INCLUDE_FILERECORD_H
19 #define INCLUDE_FILERECORD_H
20 
21 #include <dsp/basebandsamplesink.h>
22 #include <string>
23 #include <iostream>
24 #include <fstream>
25 
26 #include <ctime>
27 #include "export.h"
28 
29 class Message;
30 
32 public:
33 
34 #pragma pack(push, 1)
35  struct Header
36  {
37  quint32 sampleRate;
38  quint64 centerFrequency;
39  quint64 startTimeStamp;
40  quint32 sampleSize;
41  quint32 filler;
42  quint32 crc32;
43  };
44 #pragma pack(pop)
45 
46  FileRecord();
47  FileRecord(const QString& filename);
48  virtual ~FileRecord();
49 
50  quint64 getByteCount() const { return m_byteCount; }
51 
52  void setFileName(const QString& filename);
53  void genUniqueFileName(uint deviceUID, int istream = -1);
54 
55  virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
56  virtual void start();
57  virtual void stop();
58  virtual bool handleMessage(const Message& message);
59  void startRecording();
60  void stopRecording();
61  bool isRecording() const { return m_recordOn; }
62  static bool readHeader(std::ifstream& samplefile, Header& header);
63  static void writeHeader(std::ofstream& samplefile, Header& header);
64 
65 private:
66  QString m_fileName;
67  quint32 m_sampleRate;
69  bool m_recordOn;
71  std::ofstream m_sampleFile;
72  quint64 m_byteCount;
73 
74  void handleConfigure(const QString& fileName);
75  void writeHeader();
76 };
77 
78 #endif // INCLUDE_FILERECORD_H
quint64 m_byteCount
Definition: filerecord.h:72
bool m_recordStart
Definition: filerecord.h:70
quint32 m_sampleRate
Definition: filerecord.h:67
quint64 centerFrequency
Definition: filerecord.h:38
quint64 m_centerFrequency
Definition: filerecord.h:68
std::ofstream m_sampleFile
Definition: filerecord.h:71
quint32 sampleRate
Definition: filerecord.h:37
quint32 sampleSize
Definition: filerecord.h:40
bool isRecording() const
Definition: filerecord.h:61
bool m_recordOn
Definition: filerecord.h:69
#define SDRBASE_API
Definition: export.h:40
QString m_fileName
Definition: filerecord.h:66
quint64 getByteCount() const
Definition: filerecord.h:50
quint64 startTimeStamp
Definition: filerecord.h:39