work on ci support
[enigma2.git] / lib / dvb_ci / dvbci.h
1 #ifndef __dvbci_dvbci_h
2 #define __dvbci_dvbci_h
3
4 #include <lib/base/ebase.h>
5
6 #include <set>
7
8 class eDVBCISession;
9 class eDVBCIApplicationManagerSession;
10 class eDVBCICAManagerSession;
11 class eDVBCIMMISession;
12 class eDVBServicePMTHandler;
13
14 class eDVBCISlot: public iObject, public Object
15 {
16 DECLARE_REF(eDVBCISlot);
17 private:
18         int slotid;
19         int fd;
20         void data(int);
21         eSocketNotifier *notifier;
22
23         int state;
24         enum {stateRemoved, stateInserted};
25         uint8_t prev_sent_capmt_version;
26 public:
27         eDVBCISlot(eMainloop *context, int nr);
28         ~eDVBCISlot();
29         
30         int send(const unsigned char *data, size_t len);
31         
32         eDVBCIApplicationManagerSession *application_manager;
33         eDVBCICAManagerSession *ca_manager;
34         eDVBCIMMISession *mmi_session;
35         
36         int getSlotID();
37         int reset();
38         int initialize();
39         int startMMI();
40         int stopMMI();
41         int answerText(int answer);
42         int answerEnq(int answer, char *value);
43         int getMMIState();
44         int sendCAPMT(eDVBServicePMTHandler *ptr, const std::vector<uint16_t> &caids=std::vector<uint16_t>());
45         uint8_t getPrevSentCAPMTVersion() const { return prev_sent_capmt_version; }
46         void resetPrevSentCAPMTVersion() { prev_sent_capmt_version = 0xFF; }
47 };
48
49 struct CIPmtHandler
50 {
51         eDVBServicePMTHandler *pmthandler;
52         eDVBCISlot *usedby;
53         CIPmtHandler()
54                 :pmthandler(NULL), usedby(NULL)
55         {}
56         CIPmtHandler( const CIPmtHandler &x )
57                 :pmthandler(x.pmthandler), usedby(x.usedby)
58         {}
59         CIPmtHandler( eDVBServicePMTHandler *ptr )
60                 :pmthandler(ptr), usedby(NULL)
61         {}
62         bool operator<(const CIPmtHandler &x) const { return x.pmthandler < pmthandler; }
63 };
64
65 typedef std::set<CIPmtHandler> PMTHandlerSet;
66
67 class eDVBCIInterfaces
68 {
69 DECLARE_REF(eDVBCIInterfaces);
70         static eDVBCIInterfaces *instance;
71 private:
72         eSmartPtrList<eDVBCISlot>       m_slots;
73         eDVBCISlot *getSlot(int slotid);
74
75         PMTHandlerSet m_pmt_handlers; 
76 public:
77         eDVBCIInterfaces();
78         ~eDVBCIInterfaces();
79
80         void addPMTHandler(eDVBServicePMTHandler *pmthandler);
81         void removePMTHandler(eDVBServicePMTHandler *pmthandler);
82         void gotPMT(eDVBServicePMTHandler *pmthandler);
83
84         static eDVBCIInterfaces *getInstance();
85         
86         int reset(int slot);
87         int initialize(int slot);
88         int startMMI(int slot);
89         int stopMMI(int slot);
90         int answerText(int slot, int answer);
91         int answerEnq(int slot, int answer, char *value);
92         int getMMIState(int slot);
93 };
94
95 #endif