MythTV  master
mythfilerecorder.h
Go to the documentation of this file.
1 #ifndef MYTH_FILE_RECORDER_H
2 #define MYTH_FILE_RECORDER_H
3 
4 #include <QObject>
5 #include <QFile>
6 #include <QString>
7 
8 #include <cstdint>
9 #include <sys/types.h>
10 #include <unistd.h>
11 
12 #include "libmythbase/mythdate.h"
13 
14 class Commands;
15 
16 class Streamer : public QObject
17 {
18  Q_OBJECT
19 
20  public slots:
21  void CloseFile(void);
22  void SendBytes(void);
23 
24  public:
25  Streamer(Commands *parent, QString fname, int data_rate,
26  bool loopinput);
27  ~Streamer(void) override;
28  void BlockSize(int val) { m_blockSize = val; }
29  bool IsOpen(void) const { return m_file; }
30  QString ErrorString(void) const { return m_error; }
31 
32  protected:
33  void OpenFile(void);
34 
35  private:
36  Commands *m_parent { nullptr };
37  QString m_fileName;
38  QFile *m_file { nullptr };
39  bool m_loop;
40 
41  QString m_error;
42 
43  QByteArray m_buffer;
44  int m_bufferMax { 188 * 100000 };
45  QAtomicInt m_blockSize { m_bufferMax / 4 };
46 
47  // Regulate data rate
48  uint m_dataRate; // bytes per second
49  QDateTime m_startTime; // When the first packet was processed
50  quint64 m_dataRead { 0 }; // How many bytes have been sent
51 };
52 
53 class Commands : public QObject
54 {
55  Q_OBJECT
56 
57  signals:
58  void CloseFile(void);
59  void SendBytes(void);
60 
61  public:
62  Commands(void);
63  ~Commands(void) override = default;
64  bool Run(const QString & filename, int data_rate, bool loopinput);
65  void setEoF(void) { m_eof = 1; }
66 
67  protected:
68  bool send_status(const QString & status) const;
69  bool process_command(QString & cmd);
70 
71  private:
72  QString m_fileName;
73  Streamer *m_streamer { nullptr };
74  int m_timeout { 10 };
75  bool m_run { true };
76  QAtomicInt m_eof { 0 };
77 };
78 
79 #endif // MYTH_FILE_RECORDER_H
Streamer::m_buffer
QByteArray m_buffer
Definition: mythfilerecorder.h:43
Commands::process_command
bool process_command(QString &cmd)
Definition: mythfilerecorder.cpp:185
Streamer::OpenFile
void OpenFile(void)
Definition: mythfilerecorder.cpp:48
Streamer::m_dataRate
uint m_dataRate
Definition: mythfilerecorder.h:48
Streamer::m_bufferMax
int m_bufferMax
Definition: mythfilerecorder.h:44
Streamer::ErrorString
QString ErrorString(void) const
Definition: mythfilerecorder.h:30
Commands::send_status
bool send_status(const QString &status) const
Definition: mythfilerecorder.cpp:170
Commands::~Commands
~Commands(void) override=default
Streamer
Definition: mythfilerecorder.h:16
Commands::Run
void Run(void)
Definition: MythExternControl.cpp:443
mythdate.h
Commands::SendBytes
void SendBytes(void)
Streamer::IsOpen
bool IsOpen(void) const
Definition: mythfilerecorder.h:29
Streamer::m_dataRead
quint64 m_dataRead
Definition: mythfilerecorder.h:50
Streamer::m_error
QString m_error
Definition: mythfilerecorder.h:41
Streamer::SendBytes
void SendBytes(void)
Definition: mythfilerecorder.cpp:71
Commands::m_timeout
int m_timeout
Definition: mythfilerecorder.h:74
Commands::setEoF
void setEoF(void)
Definition: mythfilerecorder.h:65
Streamer::m_loop
bool m_loop
Definition: mythfilerecorder.h:39
Streamer::m_fileName
QString m_fileName
Definition: mythfilerecorder.h:37
Streamer::m_file
QFile * m_file
Definition: mythfilerecorder.h:38
Streamer::m_parent
Commands * m_parent
Definition: mythfilerecorder.h:36
Commands::m_fileName
QString m_fileName
Definition: mythfilerecorder.h:72
uint
unsigned int uint
Definition: compat.h:81
Commands::CloseFile
void CloseFile(void)
Commands::m_streamer
Streamer * m_streamer
Definition: mythfilerecorder.h:73
Commands::m_eof
QAtomicInt m_eof
Definition: mythfilerecorder.h:76
Streamer::~Streamer
~Streamer(void) override
Definition: mythfilerecorder.cpp:41
Commands
Definition: MythExternControl.h:74
Streamer::m_blockSize
QAtomicInt m_blockSize
Definition: mythfilerecorder.h:45
Commands::m_run
bool m_run
Definition: mythfilerecorder.h:75
Streamer::m_startTime
QDateTime m_startTime
Definition: mythfilerecorder.h:49
Streamer::Streamer
Streamer(Commands *parent, QString fname, int data_rate, bool loopinput)
Definition: mythfilerecorder.cpp:31
Streamer::CloseFile
void CloseFile(void)
Definition: mythfilerecorder.cpp:58
build_compdb.filename
filename
Definition: build_compdb.py:21
Commands::Commands
Commands(void)
Definition: mythfilerecorder.cpp:165
Streamer::BlockSize
void BlockSize(int val)
Definition: mythfilerecorder.h:28