add possibility to do things after thread start.. but before setting the thread to...
[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 #include <lib/base/rawfile.h>
9
10 class iFilePushScatterGather
11 {
12 public:
13         virtual void getNextSourceSpan(off_t current_offset, size_t bytes_read, off_t &start, size_t &size)=0;
14         virtual ~iFilePushScatterGather() {}
15 };
16
17 class eFilePushThread: public eThread, public Object
18 {
19 public:
20         eFilePushThread();
21         void thread();
22         void stop();
23         void start(int sourcefd, int destfd);
24         int start(const char *filename, int destfd);
25         
26         void pause();
27         void seek(int whence, off_t where);
28         void resume();
29         
30                 /* flushes the internal readbuffer */ 
31         void flush();
32         void enablePVRCommit(int);
33         
34         void setScatterGather(iFilePushScatterGather *);
35         
36         enum { evtEOF, evtReadError, evtWriteError, evtUser };
37         Signal1<void,int> m_event;
38
39         void installSigUSR1Handler();
40         void before_set_thread_alive();
41
42                 /* you can send private events if you want */
43         void sendEvent(int evt);
44 protected:
45         virtual void filterRecordData(const unsigned char *data, int len);
46 private:
47         iFilePushScatterGather *m_sg;
48         int m_stop;
49         unsigned char m_buffer[65536];
50         int m_buf_start, m_buf_end;
51         int m_fd_dest;
52         int m_send_pvr_commit;
53         
54         eRawFile m_raw_source;
55         
56         eFixedMessagePump<int> m_messagepump;
57         
58         void recvEvent(const int &evt);
59 };
60
61 #endif