1 #ifndef __core_dvb_ci_h
2 #define __core_dvb_ci_h
4 #include <lib/dvb/service.h>
5 #include <lib/base/ebase.h>
6 #include <lib/base/thread.h>
7 #include <lib/base/message.h>
8 #include <lib/system/elock.h>
12 #define PMT_ENTRYS 256
17 unsigned long service_class
;
19 unsigned int internal_state
;
24 int type
; // 0 = version 1=pid 2=descriptor
25 unsigned char *descriptor
;
29 unsigned short version
;
31 unsigned short streamtype
;
34 #define MAXTRANSPORTSESSIONS 32
35 #define PCMCIABUFLEN 255
36 #define LPDUHEADERLEN 2
37 #define LPDUPAYLOADLEN (PCMCIABUFLEN - LPDUHEADERLEN)
39 typedef struct _lpduQueueElem lpduQueueElem
;
40 typedef struct _lpduQueueElem
* ptrlpduQueueElem
;
42 typedef struct _lpduQueueHeader lpduQueueHeader
;
50 queueData( unsigned char tc_id
, unsigned char *data
, unsigned int len
, __u8 prio
= 0 )
51 :prio(prio
), tc_id(tc_id
), data(data
), len(len
)
55 bool operator < ( const struct queueData
&a
) const
63 unsigned char lpduLen
;
64 unsigned char lpdu
[PCMCIABUFLEN
];
65 ptrlpduQueueElem nextElem
;
68 struct _lpduQueueHeader
71 ptrlpduQueueElem firstLPDU
;
74 #define CIServiceMap std::map<int, std::list<tempPMT_t> >
76 class eDVBCI
: private eThread
, public eMainloop
, public Object
78 static int instance_count
;
79 std::priority_queue
<queueData
> sendqueue
;
84 stateInit
, stateError
, statePlaying
, statePause
97 CIServiceMap services
;
98 std::map
<int,int> versions
;
100 struct session_struct sessions
[32];
103 unsigned short caids
[256];
104 unsigned int caidcount
;
106 unsigned char ml_buffer
[1024];
110 //----------------------
111 lpduQueueHeader lpduReceiveQueues
[MAXTRANSPORTSESSIONS
];
113 ptrlpduQueueElem
eDVBCI::AllocLpduQueueElem(unsigned char t_c_id
);
114 int eDVBCI::lpduQueueElemIsMore(ptrlpduQueueElem curElem
);
116 //----------------------
119 void addCAID(int caid
);
121 void addService(int program
);
122 void PMTflush(int program
);
123 void PMTaddPID(int sid
, int pid
,int streamtype
);
124 void PMTaddDescriptor(int sid
, unsigned char *data
);
125 void PMTsetVersion(int sid
, int version
);
127 void create_sessionobject(unsigned char *tag
,unsigned char *data
,unsigned int len
,int session
);
129 bool sendData(unsigned char tc_id
,unsigned char *data
,unsigned int len
);
130 void sendTPDU(unsigned char tpdu_tag
,unsigned int len
,unsigned char tc_id
,unsigned char *data
,bool dontQueue
=false);
131 void help_manager(unsigned int session
);
132 void app_manager(unsigned int session
);
133 void ca_manager(unsigned int session
);
135 void handle_session(unsigned char *data
,int len
);
136 int service_available(unsigned long service_class
);
137 void handle_spdu(unsigned int tpdu_tc_id
,unsigned char *data
,int len
);
138 void receiveTPDU(unsigned char tpdu_tag
,unsigned int len
,unsigned char tpdu_tc_id
,unsigned char *data
);
139 void incoming(unsigned char *buffer
,int len
);
140 void dataAvailable(int what
);
144 void updateCIinfo(unsigned char *buffer
);
148 void mmi_enqansw(unsigned char *answ
);
149 void mmi_menuansw(int);
181 eDVBCIMessage(int type
): type(type
) { }
182 eDVBCIMessage(int type
, int sid
, unsigned char *data
): type(type
),sid(sid
),data(data
) { }
183 eDVBCIMessage(int type
, int sid
): type(type
),sid(sid
) { }
184 eDVBCIMessage(int type
, int sid
, int pid
, int streamtype
): type(type
),sid(sid
),pid(pid
),streamtype(streamtype
) { }
187 eFixedMessagePump
<eDVBCIMessage
> messages
;
189 void gotMessage(const eDVBCIMessage
&message
);
195 Signal1
<void, const char*> ci_progress
;
196 Signal2
<void, const char*, int> ci_mmi_progress
;