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