add possibliity to filter recorded data
[openblackhole/openblackhole-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(off_t current_offset, size_t bytes_read, off_t &start, size_t &size)=0;
13         virtual ~iFilePushScatterGather() {}
14 };
15
16 class eFilePushThread: public eThread, public Object
17 {
18 public:
19         eFilePushThread();
20         void thread();
21         void stop();
22         void start(int sourcefd, int destfd);
23         
24         void pause();
25         void seek(int whence, off_t where);
26         void resume();
27         
28                 /* flushes the internal readbuffer */ 
29         void flush();
30         void enablePVRCommit(int);
31         
32         void setScatterGather(iFilePushScatterGather *);
33         
34         enum { evtEOF, evtReadError, evtWriteError, evtUser };
35         Signal1<void,int> m_event;
36         
37                 /* you can send private events if you want */
38         void sendEvent(int evt);
39 protected:
40         virtual void filterRecordData(const char *data, int len);
41 private:
42         iFilePushScatterGather *m_sg;
43         int m_stop;
44         unsigned char m_buffer[65536];
45         int m_buf_start, m_buf_end;
46         int m_fd_source, m_fd_dest;
47         int m_send_pvr_commit;
48         
49         eFixedMessagePump<int> m_messagepump;
50         
51         void recvEvent(const int &evt);
52 };
53
54 #endif