Support turbo2.
[vuplus_dvbapp] / lib / base / filepush.h
1 #ifndef __lib_base_filepush_h
2 #define __lib_base_filepush_h
3
4 #include <lib/base/thread.h>
5 #include <lib/base/ioprio.h>
6 #include <libsig_comp.h>
7 #include <lib/base/message.h>
8 #include <sys/types.h>
9 #include <lib/base/rawfile.h>
10
11 class iFilePushScatterGather
12 {
13 public:
14         virtual void getNextSourceSpan(off_t current_offset, size_t bytes_read, off_t &start, size_t &size)=0;
15         virtual ~iFilePushScatterGather() {}
16 };
17
18 class eFilePushThread: public eThread, public Object
19 {
20         int prio_class, prio;
21 public:
22         eFilePushThread(int prio_class=IOPRIO_CLASS_BE, int prio_level=0, int blocksize=188);
23         void thread();
24         void stop();
25         void start(int sourcefd, int destfd);
26         int start(const char *filename, int destfd);
27
28         void start(ePtr<iTsSource> &source, int destfd);
29
30         void pause();
31         void resume();
32         
33                 /* flushes the internal readbuffer */ 
34         void flush();
35         void enablePVRCommit(int);
36         
37                 /* stream mode will wait on EOF until more data is available. */
38         void setStreamMode(int);
39         void setTimeshift(bool);
40         void setTSPath(const std::string);
41         
42         void setScatterGather(iFilePushScatterGather *);
43         
44         enum { evtEOF, evtReadError, evtWriteError, evtUser };
45         Signal1<void,int> m_event;
46
47         void installSigUSR1Handler();
48         void before_set_thread_alive();
49
50                 /* you can send private events if you want */
51         void sendEvent(int evt);
52 protected:
53         virtual int filterRecordData(const unsigned char *data, int len, size_t &current_span_remaining);
54 private:
55         iFilePushScatterGather *m_sg;
56         int m_stop;
57         unsigned char m_buffer[65536];
58         int m_buf_start, m_buf_end, m_filter_end;
59         int m_fd_dest;
60         int m_send_pvr_commit;
61         int m_stream_mode;
62         int m_blocksize;
63         off_t m_current_position;
64
65         ePtr<iTsSource> m_source;
66
67         eFixedMessagePump<int> m_messagepump;
68         std::string m_tspath;
69         bool m_is_timeshift;
70         bool m_hdd_connected;
71
72         void recvEvent(const int &evt);
73         void defaultTSPath(bool);
74 };
75
76 #endif