1 | #ifdef HAVE_DVBAPI
|
---|
2 |
|
---|
3 | #ifndef MODULEDVBAPI_H_
|
---|
4 | #define MODULEDVBAPI_H_
|
---|
5 |
|
---|
6 |
|
---|
7 | #include <sys/un.h>
|
---|
8 | #include <dirent.h>
|
---|
9 |
|
---|
10 | #define TYPE_ECM 1
|
---|
11 | #define TYPE_EMM 2
|
---|
12 |
|
---|
13 | //api
|
---|
14 | #define DVBAPI_3 0
|
---|
15 | #define DVBAPI_1 1
|
---|
16 | #define STAPI 2
|
---|
17 | #define COOLAPI 3
|
---|
18 |
|
---|
19 | #define TMPDIR "/tmp/"
|
---|
20 | #define STANDBY_FILE "/tmp/.pauseoscam"
|
---|
21 | #define ECMINFO_FILE "/tmp/ecm.info"
|
---|
22 |
|
---|
23 | #ifdef COOL
|
---|
24 | #define MAX_DEMUX 3
|
---|
25 | #else
|
---|
26 | #define MAX_DEMUX 5
|
---|
27 | #endif
|
---|
28 | #define MAX_CAID 50
|
---|
29 | #define ECM_PIDS 20
|
---|
30 | #define MAX_FILTER 10
|
---|
31 |
|
---|
32 | #ifndef FALSE
|
---|
33 | #define FALSE 0
|
---|
34 | #endif
|
---|
35 |
|
---|
36 | #ifndef TRUE
|
---|
37 | #define TRUE 1
|
---|
38 | #endif
|
---|
39 |
|
---|
40 | #define BOX_COUNT 6
|
---|
41 |
|
---|
42 | struct box_devices
|
---|
43 | {
|
---|
44 | char *path;
|
---|
45 | char *ca_device;
|
---|
46 | char *demux_device;
|
---|
47 | char *cam_socket_path;
|
---|
48 | };
|
---|
49 |
|
---|
50 | struct s_ecmpids
|
---|
51 | {
|
---|
52 | unsigned short CAID;
|
---|
53 | unsigned long PROVID;
|
---|
54 | unsigned short ECM_PID;
|
---|
55 | unsigned short EMM_PID;
|
---|
56 | int irdeto_numchids;
|
---|
57 | int irdeto_curchid;
|
---|
58 | int irdeto_chid;
|
---|
59 | int checked;
|
---|
60 | int status;
|
---|
61 | unsigned char table;
|
---|
62 | int index;
|
---|
63 | uint32_t streams;
|
---|
64 | };
|
---|
65 |
|
---|
66 | typedef struct filter_s
|
---|
67 | {
|
---|
68 | uint fd; //FilterHandle
|
---|
69 | int pidindex;
|
---|
70 | int pid;
|
---|
71 | ushort type;
|
---|
72 | int count;
|
---|
73 | #ifdef WITH_STAPI
|
---|
74 | int NumSlots;
|
---|
75 | uint SlotHandle[10];
|
---|
76 | uint BufferHandle[10];
|
---|
77 | #endif
|
---|
78 | } FILTERTYPE;
|
---|
79 |
|
---|
80 | struct s_emmpids
|
---|
81 | {
|
---|
82 | ushort CAID;
|
---|
83 | ulong PROVID;
|
---|
84 | ushort PID;
|
---|
85 | uint8 type;
|
---|
86 | };
|
---|
87 |
|
---|
88 | #ifdef WITH_STAPI
|
---|
89 | struct STDEVICE
|
---|
90 | {
|
---|
91 | char name[20];
|
---|
92 | uint SessionHandle;
|
---|
93 | uint SignalHandle;
|
---|
94 | pthread_t thread;
|
---|
95 | struct filter_s demux_fd[MAX_DEMUX][MAX_FILTER];
|
---|
96 | };
|
---|
97 |
|
---|
98 | struct read_thread_param
|
---|
99 | {
|
---|
100 | int id;
|
---|
101 | struct s_client *cli;
|
---|
102 | };
|
---|
103 |
|
---|
104 | #define BUFFLEN 1024
|
---|
105 | #define PROCDIR "/proc/stpti4_core/"
|
---|
106 | #define PTINUM 10
|
---|
107 | #define SLOTNUM 20
|
---|
108 |
|
---|
109 | pthread_mutex_t filter_lock;
|
---|
110 |
|
---|
111 | struct STDEVICE dev_list[PTINUM];
|
---|
112 | #endif
|
---|
113 |
|
---|
114 | typedef struct demux_s
|
---|
115 | {
|
---|
116 | int demux_index;
|
---|
117 | FILTERTYPE demux_fd[MAX_FILTER];
|
---|
118 | int ca_mask;
|
---|
119 | int adapter_index;
|
---|
120 | int socket_fd;
|
---|
121 | int ECMpidcount;
|
---|
122 | struct s_ecmpids ECMpids[ECM_PIDS];
|
---|
123 | int EMMpidcount;
|
---|
124 | struct s_emmpids EMMpids[ECM_PIDS];
|
---|
125 | int STREAMpidcount;
|
---|
126 | unsigned short STREAMpids[ECM_PIDS];
|
---|
127 | int pidindex;
|
---|
128 | int curindex;
|
---|
129 | int tries;
|
---|
130 | int max_status;
|
---|
131 | unsigned short program_number;
|
---|
132 | unsigned char lastcw[2][8];
|
---|
133 | int emm_filter;
|
---|
134 | uchar hexserial[8];
|
---|
135 | struct s_reader *rdr;
|
---|
136 | char pmt_file[30];
|
---|
137 | int pmt_time;
|
---|
138 | #ifdef WITH_STAPI
|
---|
139 | uint DescramblerHandle[PTINUM];
|
---|
140 | int desc_pidcount;
|
---|
141 | uint slot_assc[PTINUM][SLOTNUM];
|
---|
142 | #endif
|
---|
143 | } DEMUXTYPE;
|
---|
144 |
|
---|
145 | struct s_dvbapi_priority
|
---|
146 | {
|
---|
147 | char type; // p or i
|
---|
148 | ushort caid;
|
---|
149 | ulong provid;
|
---|
150 | ushort srvid;
|
---|
151 | ushort chid;
|
---|
152 | ushort ecmpid;
|
---|
153 | ushort mapcaid;
|
---|
154 | ulong mapprovid;
|
---|
155 | int delay;
|
---|
156 | int force;
|
---|
157 | #ifdef WITH_STAPI
|
---|
158 | char devname[30];
|
---|
159 | char pmtfile[30];
|
---|
160 | int disablefilter;
|
---|
161 | #endif
|
---|
162 | struct s_dvbapi_priority *next;
|
---|
163 | };
|
---|
164 |
|
---|
165 |
|
---|
166 | #define DMX_FILTER_SIZE 16
|
---|
167 |
|
---|
168 |
|
---|
169 | //dvbapi 1
|
---|
170 | typedef struct dmxFilter
|
---|
171 | {
|
---|
172 | uint8_t filter[DMX_FILTER_SIZE];
|
---|
173 | uint8_t mask[DMX_FILTER_SIZE];
|
---|
174 | } dmxFilter_t;
|
---|
175 |
|
---|
176 | struct dmxSctFilterParams
|
---|
177 | {
|
---|
178 | uint16_t pid;
|
---|
179 | dmxFilter_t filter;
|
---|
180 | uint32_t timeout;
|
---|
181 | uint32_t flags;
|
---|
182 | #define DMX_CHECK_CRC 1
|
---|
183 | #define DMX_ONESHOT 2
|
---|
184 | #define DMX_IMMEDIATE_START 4
|
---|
185 | #define DMX_BUCKET 0x1000 /* added in 2005.05.18 */
|
---|
186 | #define DMX_KERNEL_CLIENT 0x8000
|
---|
187 | };
|
---|
188 |
|
---|
189 | #define DMX_START1 _IOW('o',41,int)
|
---|
190 | #define DMX_STOP1 _IOW('o',42,int)
|
---|
191 | #define DMX_SET_FILTER1 _IOW('o',43,struct dmxSctFilterParams *)
|
---|
192 | //------------------------------------------------------------------
|
---|
193 |
|
---|
194 |
|
---|
195 | //dbox2+ufs
|
---|
196 | typedef struct dmx_filter
|
---|
197 | {
|
---|
198 | uint8_t filter[DMX_FILTER_SIZE];
|
---|
199 | uint8_t mask[DMX_FILTER_SIZE];
|
---|
200 | uint8_t mode[DMX_FILTER_SIZE];
|
---|
201 | } dmx_filter_t;
|
---|
202 |
|
---|
203 |
|
---|
204 | struct dmx_sct_filter_params
|
---|
205 | {
|
---|
206 | uint16_t pid;
|
---|
207 | dmx_filter_t filter;
|
---|
208 | uint32_t timeout;
|
---|
209 | uint32_t flags;
|
---|
210 | #define DMX_CHECK_CRC 1
|
---|
211 | #define DMX_ONESHOT 2
|
---|
212 | #define DMX_IMMEDIATE_START 4
|
---|
213 | #define DMX_KERNEL_CLIENT 0x8000
|
---|
214 | };
|
---|
215 |
|
---|
216 | typedef struct ca_descr {
|
---|
217 | unsigned int index;
|
---|
218 | unsigned int parity; /* 0 == even, 1 == odd */
|
---|
219 | unsigned char cw[8];
|
---|
220 | } ca_descr_t;
|
---|
221 |
|
---|
222 | typedef struct ca_pid {
|
---|
223 | unsigned int pid;
|
---|
224 | int index; /* -1 == disable*/
|
---|
225 | } ca_pid_t;
|
---|
226 |
|
---|
227 | #define DMX_START _IO('o', 41)
|
---|
228 | #define DMX_STOP _IO('o', 42)
|
---|
229 | #define DMX_SET_FILTER _IOW('o', 43, struct dmx_sct_filter_params)
|
---|
230 |
|
---|
231 | #define CA_SET_DESCR _IOW('o', 134, ca_descr_t)
|
---|
232 | #define CA_SET_PID _IOW('o', 135, ca_pid_t)
|
---|
233 | // --------------------------------------------------------------------
|
---|
234 |
|
---|
235 | #ifdef AZBOX
|
---|
236 | #include "openxcas/openxcas_api.h"
|
---|
237 | #include "openxcas/openxcas_message.h"
|
---|
238 |
|
---|
239 | int openxcas_provid, openxcas_seq, openxcas_filter_idx, openxcas_stream_id, openxcas_cipher_idx, openxcas_busy;
|
---|
240 | unsigned char openxcas_cw[16];
|
---|
241 | unsigned short openxcas_sid, openxcas_caid, openxcas_ecm_pid, openxcas_video_pid, openxcas_audio_pid, openxcas_data_pid;
|
---|
242 |
|
---|
243 | void azbox_openxcas_ecm_callback(int stream_id, unsigned int sequence, int cipher_index, unsigned int caid, unsigned char *ecm_data, int l, unsigned short pid);
|
---|
244 | void azbox_openxcas_ex_callback(int stream_id, unsigned int seq, int idx, unsigned int pid, unsigned char *ecm_data, int l);
|
---|
245 | void azbox_send_dcw(struct s_client *client, ECM_REQUEST *er);
|
---|
246 | void * azbox_main(void * cli);
|
---|
247 | #endif
|
---|
248 |
|
---|
249 | #ifdef COOL
|
---|
250 | int coolapi_set_filter (int fd, int num, int pid, byte * flt, byte * mask);
|
---|
251 | int coolapi_remove_filter (int fd, int num);
|
---|
252 | int coolapi_open_device (int demux_index, int demux_id);
|
---|
253 | int coolapi_close_device(int fd);
|
---|
254 | int coolapi_write_cw(int mask, unsigned short *STREAMpids, int count, ca_descr_t * ca_descr);
|
---|
255 | int coolapi_set_pid (int demux_id, int num, int index, int pid);
|
---|
256 | void coolapi_close_all();
|
---|
257 | void dvbapi_write_cw(int demux_id, uchar *cw, int index);
|
---|
258 | #endif
|
---|
259 |
|
---|
260 | #ifdef WITH_STAPI
|
---|
261 | static int stapi_open();
|
---|
262 | static int stapi_set_filter(int demux_id, ushort pid, uchar *filter, uchar *mask, int num, char *pmtfile);
|
---|
263 | static int stapi_remove_filter(int demux_id, int num, char *pmtfile);
|
---|
264 | static int stapi_set_pid(int demux_id, int num, int index, ushort pid, char *pmtfile);
|
---|
265 | static int stapi_write_cw(int demux_id, uchar *cw, ushort *, int, char *pmtfile);
|
---|
266 | static int stapi_do_set_filter(int demux_id, FILTERTYPE *filter, ushort *pids, int pidcount, uchar *filt, uchar *mask, int dev_id);
|
---|
267 | static int stapi_do_remove_filter(int demux_id, FILTERTYPE *filter, int dev_id);
|
---|
268 | static void *stapi_read_thread(void *);
|
---|
269 |
|
---|
270 | uint oscam_stapi_Capability(char *name);
|
---|
271 | char *oscam_stapi_LibVersion(void);
|
---|
272 | uint oscam_stapi_Open(char *name, uint *sessionhandle);
|
---|
273 | uint oscam_stapi_SignalAllocate(uint sessionhandle, uint *signalhandle);
|
---|
274 | uint oscam_stapi_FilterAllocate(uint sessionhandle, uint *filterhandle);
|
---|
275 | uint oscam_stapi_SlotInit(uint sessionhandle, uint signalhandle, uint *bufferhandle, uint *slothandle, ushort pid);
|
---|
276 | uint oscam_stapi_FilterSet(uint filterhandle, uchar *filt, uchar *mask);
|
---|
277 | uint oscam_stapi_FilterAssociate(uint filterhandle, uint slothandle);
|
---|
278 | uint oscam_stapi_SlotDeallocate(uint slothandle);
|
---|
279 | uint oscam_stapi_BufferDeallocate(uint bufferhandle);
|
---|
280 | uint oscam_stapi_FilterDeallocate(uint filterhandle);
|
---|
281 | uint oscam_stapi_Close(uint sessionhandle);
|
---|
282 | uint oscam_stapi_CheckVersion();
|
---|
283 | uint oscam_stapi_DescramblerAssociate(uint deschandle, uint slot);
|
---|
284 | uint oscam_stapi_DescramblerDisassociate(uint deschandle, uint slot);
|
---|
285 | uint oscam_stapi_DescramblerAllocate(uint sessionhandle, uint *deschandle);
|
---|
286 | uint oscam_stapi_DescramblerDeallocate(uint deschandle);
|
---|
287 | uint oscam_stapi_DescramblerSet(uint deschandle, int parity, uchar *cw);
|
---|
288 | uint oscam_stapi_SignalWaitBuffer(uint signalhandle, uint *qbuffer, int timeout);
|
---|
289 | uint oscam_stapi_BufferReadSection(uint bufferhandle, uint *filterlist, int maxfilter, uint *filtercount, int *crc, uchar *buf, int bufsize, uint *size);
|
---|
290 | uint oscam_stapi_SignalAbort(uint signalhandle);
|
---|
291 | uint oscam_stapi_PidQuery(char *name, ushort pid);
|
---|
292 | uint oscam_stapi_BufferFlush(uint bufferhandle);
|
---|
293 | uint oscam_stapi_SlotClearPid(uint slot);
|
---|
294 | #endif
|
---|
295 |
|
---|
296 | void dvbapi_stop_descrambling(int);
|
---|
297 | void dvbapi_process_input(int demux_id, int filter_num, uchar *buffer, int len);
|
---|
298 | int dvbapi_open_device(int, int, int);
|
---|
299 | int dvbapi_stop_filternum(int demux_index, int num);
|
---|
300 | int dvbapi_stop_filter(int demux_index, int type);
|
---|
301 | struct s_dvbapi_priority *dvbapi_check_prio_match(int demux_id, int pidindex, char type);
|
---|
302 |
|
---|
303 | #ifdef WITH_STAPI
|
---|
304 | #define cs_log(x...) cs_log("stapi: "x)
|
---|
305 | #ifdef WITH_DEBUG
|
---|
306 | #define cs_debug_mask(x,y...) cs_debug_mask(x,"stapi: "y)
|
---|
307 | #endif
|
---|
308 | #else
|
---|
309 | #define cs_log(x...) cs_log("dvbapi: "x)
|
---|
310 | #ifdef WITH_DEBUG
|
---|
311 | #define cs_debug_mask(x,y...) cs_debug_mask(x,"dvbapi: "y)
|
---|
312 | #endif
|
---|
313 | #endif
|
---|
314 |
|
---|
315 | #endif // MODULEDVBAPI_H_
|
---|
316 | #endif // WITH_DVBAPI
|
---|