- add ts recorder
[vuplus_dvbapp] / 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         int adapter, demux;
10         
11         int m_dvr_busy;
12         friend class eDVBSectionReader;
13         friend class eDVBAudio;
14         friend class eDVBVideo;
15         friend class eDVBTSRecorder;
16 public:
17         DECLARE_REF(eDVBDemux);
18         eDVBDemux(int adapter, int demux);
19         virtual ~eDVBDemux();
20         RESULT createSectionReader(eMainloop *context, ePtr<iDVBSectionReader> &reader);
21         RESULT createTSRecorder(ePtr<iDVBTSRecorder> &recorder);
22         RESULT getMPEGDecoder(ePtr<iTSMPEGDecoder> &reader);
23 };
24
25 class eDVBSectionReader: public iDVBSectionReader, public Object
26 {
27         DECLARE_REF(eDVBSectionReader);
28 private:
29         int fd;
30         Signal1<void, const __u8*> read;
31         ePtr<eDVBDemux> demux;
32         int active;
33         int checkcrc;
34         void data(int);
35         eSocketNotifier *notifier;
36 public:
37         
38         eDVBSectionReader(eDVBDemux *demux, eMainloop *context, RESULT &res);
39         virtual ~eDVBSectionReader();
40         RESULT start(const eDVBSectionFilterMask &mask);
41         RESULT stop();
42         RESULT connectRead(const Slot1<void,const __u8*> &read, ePtr<eConnection> &conn);
43 };
44
45 class eDVBTSRecorderThread;
46
47 class eDVBTSRecorder: public iDVBTSRecorder, public Object
48 {
49         DECLARE_REF(eDVBTSRecorder);
50 public:
51         eDVBTSRecorder(eDVBDemux *demux);
52         ~eDVBTSRecorder();
53
54         RESULT start();
55         RESULT addPID(int pid);
56         RESULT removePID(int pid);
57         
58         RESULT setFormat(int pid);
59         
60         RESULT setTargetFD(int fd);
61         RESULT setBoundary(off_t max);
62         
63         RESULT stop();
64         
65         RESULT connectEvent(const Slot1<void,int> &event, ePtr<eConnection> &conn);
66 private:
67         RESULT startPID(int pid);
68         void stopPID(int pid);
69         
70         eDVBTSRecorderThread *m_thread;
71         
72         std::map<int,int> m_pids;
73         Signal1<void,int> m_event;
74         
75         ePtr<eDVBDemux> m_demux;
76         
77         int m_running, m_format, m_target_fd, m_source_fd;
78 };
79
80 #endif