no helpable actionmap for RdsActions
[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         RESULT setSourcePVR(int pvrnum);
19         
20         RESULT createSectionReader(eMainloop *context, ePtr<iDVBSectionReader> &reader);
21         RESULT createPESReader(eMainloop *context, ePtr<iDVBPESReader> &reader);
22         RESULT createTSRecorder(ePtr<iDVBTSRecorder> &recorder);
23         RESULT getMPEGDecoder(ePtr<iTSMPEGDecoder> &reader, int primary);
24         RESULT getSTC(pts_t &pts, int num);
25         RESULT getCADemuxID(uint8_t &id) { id = demux; return 0; }
26         RESULT flush();
27         RESULT connectEvent(const Slot1<void,int> &event, ePtr<eConnection> &conn);
28         
29         int getRefCount() { return ref; }
30 private:
31         int adapter, demux;
32         
33         int m_dvr_busy;
34         friend class eDVBSectionReader;
35         friend class eDVBPESReader;
36         friend class eDVBAudio;
37         friend class eDVBVideo;
38         friend class eDVBPCR;
39         friend class eDVBTText;
40         friend class eDVBTSRecorder;
41         friend class eDVBCAService;
42         Signal1<void, int> m_event;
43         
44         int openDemux(void);
45 };
46
47 class eDVBSectionReader: public iDVBSectionReader, public Object
48 {
49         DECLARE_REF(eDVBSectionReader);
50 private:
51         int fd;
52         Signal1<void, const __u8*> read;
53         ePtr<eDVBDemux> demux;
54         int active;
55         int checkcrc;
56         void data(int);
57         eSocketNotifier *notifier;
58 public:
59         
60         eDVBSectionReader(eDVBDemux *demux, eMainloop *context, RESULT &res);
61         virtual ~eDVBSectionReader();
62         RESULT start(const eDVBSectionFilterMask &mask);
63         RESULT stop();
64         RESULT connectRead(const Slot1<void,const __u8*> &read, ePtr<eConnection> &conn);
65 };
66
67 class eDVBPESReader: public iDVBPESReader, public Object
68 {
69         DECLARE_REF(eDVBPESReader);
70 private:
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         eSocketNotifier *m_notifier;
77 public:
78         eDVBPESReader(eDVBDemux *demux, eMainloop *context, RESULT &res);
79         virtual ~eDVBPESReader();
80         RESULT start(int pid);
81         RESULT stop();
82         RESULT connectRead(const Slot2<void,const __u8*, int> &read, ePtr<eConnection> &conn);
83 };
84
85 class eDVBRecordFileThread;
86
87 class eDVBTSRecorder: public iDVBTSRecorder, public Object
88 {
89         DECLARE_REF(eDVBTSRecorder);
90 public:
91         eDVBTSRecorder(eDVBDemux *demux);
92         ~eDVBTSRecorder();
93
94         RESULT start();
95         RESULT addPID(int pid);
96         RESULT removePID(int pid);
97         
98         RESULT setTimingPID(int pid);
99         
100         RESULT setTargetFD(int fd);
101         RESULT setTargetFilename(const char *filename);
102         RESULT setBoundary(off_t max);
103         
104         RESULT stop();
105         
106         RESULT connectEvent(const Slot1<void,int> &event, ePtr<eConnection> &conn);
107 private:
108         RESULT startPID(int pid);
109         void stopPID(int pid);
110         
111         eDVBRecordFileThread *m_thread;
112         void filepushEvent(int event);
113         
114         std::map<int,int> m_pids;
115         Signal1<void,int> m_event;
116         
117         ePtr<eDVBDemux> m_demux;
118         
119         int m_running, m_target_fd, m_source_fd;
120         std::string m_target_filename;
121 };
122
123 #endif