Merge branch 'bug_713_fix_timerlist_sort'
[enigma2.git] / lib / dvb / demux.h
1 #ifndef __dvb_demux_h
2 #define __dvb_demux_h
3
4 #include <lib/dvb/idvb.h>
5 #include <lib/dvb/idemux.h>
6
7 class eDVBDemux: public iDVBDemux
8 {
9         DECLARE_REF(eDVBDemux);
10 public:
11         enum {
12                 evtFlush
13         };
14         eDVBDemux(int adapter, int demux);
15         virtual ~eDVBDemux();
16         
17         RESULT setSourceFrontend(int fenum);
18         int getSource() { return source; }
19         RESULT setSourcePVR(int pvrnum);
20         
21         RESULT createSectionReader(eMainloop *context, ePtr<iDVBSectionReader> &reader);
22         RESULT createPESReader(eMainloop *context, ePtr<iDVBPESReader> &reader);
23         RESULT createTSRecorder(ePtr<iDVBTSRecorder> &recorder);
24         RESULT getMPEGDecoder(ePtr<iTSMPEGDecoder> &reader, int primary);
25         RESULT getSTC(pts_t &pts, int num);
26         RESULT getCADemuxID(uint8_t &id) { id = demux; return 0; }
27         RESULT flush();
28         RESULT connectEvent(const Slot1<void,int> &event, ePtr<eConnection> &conn);
29         int openDVR(int flags);
30
31         int getRefCount() { return ref; }
32 private:
33         int adapter, demux, source;
34         
35         int m_dvr_busy;
36         friend class eDVBSectionReader;
37         friend class eDVBPESReader;
38         friend class eDVBAudio;
39         friend class eDVBVideo;
40         friend class eDVBPCR;
41         friend class eDVBTText;
42         friend class eDVBTSRecorder;
43         friend class eDVBCAService;
44         Signal1<void, int> m_event;
45         
46         int openDemux(void);
47 };
48
49 class eDVBSectionReader: public iDVBSectionReader, public Object
50 {
51         DECLARE_REF(eDVBSectionReader);
52         int fd;
53         Signal1<void, const __u8*> read;
54         ePtr<eDVBDemux> demux;
55         int active;
56         int checkcrc;
57         void data(int);
58         ePtr<eSocketNotifier> notifier;
59 public:
60         eDVBSectionReader(eDVBDemux *demux, eMainloop *context, RESULT &res);
61         virtual ~eDVBSectionReader();
62         RESULT setBufferSize(int size);
63         RESULT start(const eDVBSectionFilterMask &mask);
64         RESULT stop();
65         RESULT connectRead(const Slot1<void,const __u8*> &read, ePtr<eConnection> &conn);
66 };
67
68 class eDVBPESReader: public iDVBPESReader, public Object
69 {
70         DECLARE_REF(eDVBPESReader);
71         int m_fd;
72         Signal2<void, const __u8*, int> m_read;
73         ePtr<eDVBDemux> m_demux;
74         int m_active;
75         void data(int);
76         ePtr<eSocketNotifier> m_notifier;
77 public:
78         eDVBPESReader(eDVBDemux *demux, eMainloop *context, RESULT &res);
79         virtual ~eDVBPESReader();
80         RESULT setBufferSize(int size);
81         RESULT start(int pid);
82         RESULT stop();
83         RESULT connectRead(const Slot2<void,const __u8*, int> &read, ePtr<eConnection> &conn);
84 };
85
86 class eDVBRecordFileThread;
87
88 class eDVBTSRecorder: public iDVBTSRecorder, public Object
89 {
90         DECLARE_REF(eDVBTSRecorder);
91 public:
92         eDVBTSRecorder(eDVBDemux *demux);
93         ~eDVBTSRecorder();
94
95         RESULT setBufferSize(int size);
96         RESULT start();
97         RESULT addPID(int pid);
98         RESULT removePID(int pid);
99         
100         RESULT setTimingPID(int pid, int type);
101         
102         RESULT setTargetFD(int fd);
103         RESULT setTargetFilename(const char *filename);
104         RESULT setBoundary(off_t max);
105         
106         RESULT stop();
107
108         RESULT getCurrentPCR(pts_t &pcr);
109
110         RESULT connectEvent(const Slot1<void,int> &event, ePtr<eConnection> &conn);
111 private:
112         RESULT startPID(int pid);
113         void stopPID(int pid);
114         
115         eDVBRecordFileThread *m_thread;
116         void filepushEvent(int event);
117         
118         std::map<int,int> m_pids;
119         Signal1<void,int> m_event;
120         
121         ePtr<eDVBDemux> m_demux;
122         
123         int m_running, m_target_fd, m_source_fd;
124         std::string m_target_filename;
125 };
126
127 #endif