filepush: scatter/gather support
[enigma2.git] / 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 <libsig_comp.h>
6 #include <lib/base/message.h>
7 #include <sys/types.h>
8
9 class iFilePushScatterGather
10 {
11 public:
12         virtual void getNextSourceSpan(size_t bytes_read, off_t &start, size_t &size)=0;
13 };
14
15 class eFilePushThread: public eThread, public Object
16 {
17 public:
18         eFilePushThread();
19         void thread();
20         void stop();
21         void start(int sourcefd, int destfd);
22         
23         void pause();
24         void seek(int whence, off_t where);
25         void resume();
26         
27                 /* flushes the internal readbuffer */ 
28         void flush();
29         void enablePVRCommit(int);
30         
31         void setSG(iFilePushScatterGather *);
32         
33         enum { evtEOF, evtReadError, evtWriteError };
34         Signal1<void,int> m_event;
35         
36 private:
37         iFilePushScatterGather *m_sg;
38         int m_stop;
39         unsigned char m_buffer[65536];
40         int m_buf_start, m_buf_end;
41         int m_fd_source, m_fd_dest;
42         int m_send_pvr_commit;
43         
44         eFixedMessagePump<int> m_messagepump;
45         
46         void sendEvent(int evt);
47         void recvEvent(const int &evt);
48 };
49
50 #endif