don't crash if time is *really* invalid
[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 createTSRecorder(ePtr<iDVBTSRecorder> &recorder);
22         RESULT getMPEGDecoder(ePtr<iTSMPEGDecoder> &reader, int primary);
23         RESULT getSTC(pts_t &pts, int num);
24         RESULT getCADemuxID(uint8_t &id) { id = demux; return 0; }
25         RESULT flush();
26         RESULT connectEvent(const Slot1<void,int> &event, ePtr<eConnection> &conn);
27         
28         int getRefCount() { return ref; }
29 private:
30         int adapter, demux;
31         
32         int m_dvr_busy;
33         friend class eDVBSectionReader;
34         friend class eDVBAudio;
35         friend class eDVBVideo;
36         friend class eDVBPCR;
37         friend class eDVBTText;
38         friend class eDVBTSRecorder;
39         friend class eDVBCAService;
40         Signal1<void, int> m_event;
41         
42         int openDemux(void);
43 };
44
45 class eDVBSectionReader: public iDVBSectionReader, public Object
46 {
47         DECLARE_REF(eDVBSectionReader);
48 private:
49         int fd;
50         Signal1<void, const __u8*> read;
51         ePtr<eDVBDemux> demux;
52         int active;
53         int checkcrc;
54         void data(int);
55         eSocketNotifier *notifier;
56 public:
57         
58         eDVBSectionReader(eDVBDemux *demux, eMainloop *context, RESULT &res);
59         virtual ~eDVBSectionReader();
60         RESULT start(const eDVBSectionFilterMask &mask);
61         RESULT stop();
62         RESULT connectRead(const Slot1<void,const __u8*> &read, ePtr<eConnection> &conn);
63 };
64
65 class eDVBRecordFileThread;
66
67 class eDVBTSRecorder: public iDVBTSRecorder, public Object
68 {
69         DECLARE_REF(eDVBTSRecorder);
70 public:
71         eDVBTSRecorder(eDVBDemux *demux);
72         ~eDVBTSRecorder();
73
74         RESULT start();
75         RESULT addPID(int pid);
76         RESULT removePID(int pid);
77         
78         RESULT setTimingPID(int pid);
79         
80         RESULT setTargetFD(int fd);
81         RESULT setTargetFilename(const char *filename);
82         RESULT setBoundary(off_t max);
83         
84         RESULT stop();
85         
86         RESULT connectEvent(const Slot1<void,int> &event, ePtr<eConnection> &conn);
87 private:
88         RESULT startPID(int pid);
89         void stopPID(int pid);
90         
91         eDVBRecordFileThread *m_thread;
92         
93         std::map<int,int> m_pids;
94         Signal1<void,int> m_event;
95         
96         ePtr<eDVBDemux> m_demux;
97         
98         int m_running, m_target_fd, m_source_fd;
99         std::string m_target_filename;
100 };
101
102 #endif