MythTV  master
mythfilerecorder.h
Go to the documentation of this file.
1 #ifndef _FILE_RECORDER_H_
2 #define _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 <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, const QString &filename, int data_rate,
26  bool loopinput);
27  virtual ~Streamer(void);
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:
37  QString m_fileName;
38  QFile *m_file;
39  bool m_loop;
40 
41  QString m_error;
42 
43  QByteArray m_buffer;
45  QAtomicInt m_blockSize;
46 
47  // Regulate data rate
48  uint m_data_rate; // bytes per second
49  QDateTime m_start_time; // When the first packet was processed
50  quint64 m_data_read; // 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  virtual ~Commands(void) = default;
64  bool Run(const QString & filename, int data_rate, bool loopinput);
65  void setEoF(void) { m_eof = true; }
66 
67  protected:
68  bool send_status(const QString & status) const;
69  bool process_command(QString & cmd);
70 
71  private:
72  QString m_fileName;
74  int m_timeout;
75  bool m_run;
76  QAtomicInt m_eof;
77 };
78 
79 #endif
void CloseFile(void)
void SendBytes(void)
bool IsOpen(void) const
unsigned int slots[4]
Definition: element.c:38
QAtomicInt m_eof
virtual ~Streamer(void)
QAtomicInt m_blockSize
bool send_status(const QString &status) const
void setEoF(void)
void Run(void)
QByteArray m_buffer
unsigned int uint
Definition: compat.h:140
QDateTime m_start_time
void BlockSize(int val)
QString m_fileName
QString ErrorString(void) const
bool process_command(QString &cmd)
QString m_error
Commands * m_parent
quint64 m_data_read
Streamer(Commands *parent, const QString &filename, int data_rate, bool loopinput)
QFile * m_file
uint m_data_rate
void CloseFile(void)
void SendBytes(void)
Streamer * m_streamer
QString m_fileName
void OpenFile(void)