MythTV  master
programs/mythbackend/filetransfer.h
Go to the documentation of this file.
1 #ifndef FILETRANSFER_H_
2 #define FILETRANSFER_H_
3 
4 // C++ headers
5 #include <cstdint>
6 #include <vector>
7 using namespace std;
8 
9 // Qt headers
10 #include <QMutex>
11 #include <QWaitCondition>
12 
13 // MythTV headers
14 #include "referencecounter.h"
15 
16 class ProgramInfo;
17 class RingBuffer;
18 class MythSocket;
19 class QString;
20 
21 class FileTransfer : public ReferenceCounter
22 {
23  friend class QObject; // quiet OSX gcc warning
24 
25  public:
26  FileTransfer(QString &filename, MythSocket *remote,
27  bool usereadahead, int timeout_ms);
28  FileTransfer(QString &filename, MythSocket *remote, bool write);
29 
30  MythSocket *getSocket() { return m_sock; }
31 
32  bool isOpen(void);
33  bool ReOpen(QString newFilename = "");
34 
35  void Stop(void);
36 
37  void Pause(void);
38  void Unpause(void);
39  int RequestBlock(int size);
40  int WriteBlock(int size);
41 
42  long long Seek(long long curpos, long long pos, int whence);
43 
44  uint64_t GetFileSize(void);
45  QString GetFileName(void);
46 
47  void SetTimeout(bool fast);
48 
49  private:
50  ~FileTransfer();
51 
52  volatile bool m_readthreadlive {true};
53  bool m_readsLocked {false};
54  QWaitCondition m_readsUnlockedCond;
55 
56  ProgramInfo *m_pginfo {nullptr};
57  RingBuffer *m_rbuffer {nullptr};
58  MythSocket *m_sock {nullptr};
59  bool m_ateof {false};
60 
61  vector<char> m_requestBuffer;
62 
63  QMutex m_lock {QMutex::NonRecursive};
64 
65  bool m_writemode {false};
66 };
67 
68 #endif
def write(text, progress=True)
Definition: mythburn.py:279
General purpose reference counter.
Holds information on recordings and videos.
Definition: programinfo.h:66
Class for communcating between myth backends and frontends.
Definition: mythsocket.h:26
Implements a file/stream reader/writer.
static qint64 GetFileSize(ProgramInfo *program_info)