fix dvd hotplug: stop assuming dvd for every other medium. in case of multiple ISO...
[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         
30         int getRefCount() { return ref; }
31 private:
32         int adapter, demux, source;
33         
34         int m_dvr_busy;
35         friend class eDVBSectionReader;
36         friend class eDVBPESReader;
37         friend class eDVBAudio;
38         friend class eDVBVideo;
39         friend class eDVBPCR;
40         friend class eDVBTText;
41         friend class eDVBTSRecorder;
42         friend class eDVBCAService;
43         Signal1<void, int> m_event;
44         
45         int openDemux(void);
46 };
47
48 class eDVBSectionReader: public iDVBSectionReader, public Object
49 {
50         DECLARE_REF(eDVBSectionReader);
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         int m_fd;
71         Signal2<void, const __u8*, int> m_read;
72         ePtr<eDVBDemux> m_demux;
73         int m_active;
74         void data(int);
75         eSocketNotifier *m_notifier;
76 public:
77         eDVBPESReader(eDVBDemux *demux, eMainloop *context, RESULT &res);
78         virtual ~eDVBPESReader();
79         RESULT start(int pid);
80         RESULT stop();
81         RESULT connectRead(const Slot2<void,const __u8*, int> &read, ePtr<eConnection> &conn);
82 };
83
84 class eDVBRecordFileThread;
85
86 class eDVBTSRecorder: public iDVBTSRecorder, public Object
87 {
88         DECLARE_REF(eDVBTSRecorder);
89 public:
90         eDVBTSRecorder(eDVBDemux *demux);
91         ~eDVBTSRecorder();
92
93         RESULT start();
94         RESULT addPID(int pid);
95         RESULT removePID(int pid);
96         
97         RESULT setTimingPID(int pid);
98         
99         RESULT setTargetFD(int fd);
100         RESULT setTargetFilename(const char *filename);
101         RESULT setBoundary(off_t max);
102         
103         RESULT stop();
104         
105         RESULT connectEvent(const Slot1<void,int> &event, ePtr<eConnection> &conn);
106 private:
107         RESULT startPID(int pid);
108         void stopPID(int pid);
109         
110         eDVBRecordFileThread *m_thread;
111         void filepushEvent(int event);
112         
113         std::map<int,int> m_pids;
114         Signal1<void,int> m_event;
115         
116         ePtr<eDVBDemux> m_demux;
117         
118         int m_running, m_target_fd, m_source_fd;
119         std::string m_target_filename;
120 };
121
122 #endif