fix python refcounting
[vuplus_dvbapp] / 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 class eDVBCISlot;
14
15 class eDVBCISlot: public iObject, public Object
16 {
17 DECLARE_REF(eDVBCISlot);
18 private:
19         int slotid;
20         int fd;
21         void data(int);
22         eSocketNotifier *notifier;
23
24         int state;
25         enum {stateRemoved, stateInserted};
26         uint8_t prev_sent_capmt_version;
27         eDVBCIApplicationManagerSession *application_manager;
28         eDVBCICAManagerSession *ca_manager;
29         eDVBCIMMISession *mmi_session;
30 public:
31         int use_count;
32
33         eDVBCISlot(eMainloop *context, int nr);
34         ~eDVBCISlot();
35         
36         int send(const unsigned char *data, size_t len);
37
38         void setAppManager( eDVBCIApplicationManagerSession *session );
39         void setMMIManager( eDVBCIMMISession *session );
40         void setCAManager( eDVBCICAManagerSession *session );
41
42         eDVBCIApplicationManagerSession *getAppManager() { return application_manager; }
43         eDVBCIMMISession *getMMIManager() { return mmi_session; }
44         eDVBCICAManagerSession *getCAManager() { return ca_manager; }
45
46         int getSlotID();
47         int reset();
48         int initialize();
49         int startMMI();
50         int stopMMI();
51         int answerText(int answer);
52         int answerEnq(char *value);
53         int cancelEnq();
54         int getMMIState();
55         void resendCAPMT();
56         int sendCAPMT(eDVBServicePMTHandler *ptr, const std::vector<uint16_t> &caids=std::vector<uint16_t>());
57         uint8_t getPrevSentCAPMTVersion() const { return prev_sent_capmt_version; }
58         void resetPrevSentCAPMTVersion() { prev_sent_capmt_version = 0xFF; }
59         
60         int enableTS(int enable);
61
62 };
63
64 struct CIPmtHandler
65 {
66         eDVBServicePMTHandler *pmthandler;
67         eDVBCISlot *cislot;
68         CIPmtHandler()
69                 :pmthandler(NULL), cislot(NULL)
70         {}
71         CIPmtHandler( const CIPmtHandler &x )
72                 :pmthandler(x.pmthandler), cislot(x.cislot)
73         {}
74         CIPmtHandler( eDVBServicePMTHandler *ptr )
75                 :pmthandler(ptr), cislot(NULL)
76         {}
77         bool operator==(const CIPmtHandler &x) const { return x.pmthandler == pmthandler; }
78 };
79
80 typedef std::list<CIPmtHandler> PMTHandlerList;
81
82 class eDVBCIInterfaces
83 {
84 DECLARE_REF(eDVBCIInterfaces);
85         static eDVBCIInterfaces *instance;
86 private:
87         eSmartPtrList<eDVBCISlot>       m_slots;
88         eDVBCISlot *getSlot(int slotid);
89
90         PMTHandlerList m_pmt_handlers; 
91 public:
92         eDVBCIInterfaces();
93         ~eDVBCIInterfaces();
94
95         void addPMTHandler(eDVBServicePMTHandler *pmthandler);
96         void removePMTHandler(eDVBServicePMTHandler *pmthandler);
97         void gotPMT(eDVBServicePMTHandler *pmthandler);
98
99         static eDVBCIInterfaces *getInstance();
100         
101         int reset(int slot);
102         int initialize(int slot);
103         int startMMI(int slot);
104         int stopMMI(int slot);
105         int answerText(int slot, int answer);
106         int answerEnq(int slot, char *value);
107         int cancelEnq(int slot);
108         int getMMIState(int slot);
109         int enableTS(int slot, int enable);
110         int sendCAPMT(int slot);
111 };
112
113 #endif