source: trunk/module-dvbapi.h@ 10652

Last change on this file since 10652 was 10652, checked in by manio, 7 years ago

dvbapi: add support for ECMINFO in network mode (bump proto to v2)

  • Property svn:eol-style set to LF
File size: 9.3 KB
Line 
1#ifndef MODULE_DVBAPI_H_
2#define MODULE_DVBAPI_H_
3
4#ifdef HAVE_DVBAPI
5#include <sys/un.h>
6
7#define TYPE_ECM 1
8#define TYPE_EMM 2
9
10//api
11#define DVBAPI_3 0
12#define DVBAPI_1 1
13#define STAPI 2
14#define COOLAPI 3
15
16#define TMPDIR "/tmp/"
17#define STANDBY_FILE "/tmp/.pauseoscam"
18#define ECMINFO_FILE "/tmp/ecm.info"
19
20#define MAX_DEMUX 16
21#define MAX_CAID 50
22#define ECM_PIDS 30
23#define MAX_FILTER 24
24
25#define BOX_COUNT 6
26
27#define BOXTYPE_DREAMBOX 1
28#define BOXTYPE_DUCKBOX 2
29#define BOXTYPE_UFS910 3
30#define BOXTYPE_DBOX2 4
31#define BOXTYPE_IPBOX 5
32#define BOXTYPE_IPBOX_PMT 6
33#define BOXTYPE_DM7000 7
34#define BOXTYPE_QBOXHD 8
35#define BOXTYPE_COOLSTREAM 9
36#define BOXTYPE_NEUMO 10
37#define BOXTYPE_PC 11
38#define BOXTYPE_PC_NODMX 12
39#define BOXTYPES 12
40#define DMXMD5HASHSIZE 16 // use MD5()
41#define REMOVED_STREAMPID_INDEX 1
42#define REMOVED_STREAMPID_LASTINDEX 2
43#define REMOVED_DECODING_STREAMPID_INDEX 3
44#define NO_STREAMPID_LISTED 0
45#define FOUND_STREAMPID_INDEX 0
46#define ADDED_STREAMPID_INDEX 1
47#define FIRST_STREAMPID_INDEX 2
48#define CA_IS_CLEAR -1
49#define DUMMY_FD 0xFFFF
50
51//constants used int socket communication:
52#define DVBAPI_PROTOCOL_VERSION 2
53
54#define DVBAPI_CA_SET_PID 0x40086f87
55#define DVBAPI_CA_SET_DESCR 0x40106f86
56#define DVBAPI_DMX_SET_FILTER 0x403c6f2b
57#define DVBAPI_DMX_STOP 0x00006f2a
58
59#define DVBAPI_AOT_CA 0x9F803000
60#define DVBAPI_AOT_CA_PMT 0x9F803200 //least significant byte is length (ignored)
61#define DVBAPI_AOT_CA_STOP 0x9F803F04
62#define DVBAPI_FILTER_DATA 0xFFFF0000
63#define DVBAPI_CLIENT_INFO 0xFFFF0001
64#define DVBAPI_SERVER_INFO 0xFFFF0002
65#define DVBAPI_ECM_INFO 0xFFFF0003
66
67#define DVBAPI_MAX_PACKET_SIZE 262 //maximum possible packet size
68
69struct box_devices
70{
71 char *path;
72 char *ca_device;
73 char *demux_device;
74 char *cam_socket_path;
75 int8_t api;
76};
77
78struct s_ecmpids
79{
80 uint16_t CAID;
81 uint32_t PROVID;
82 uint16_t ECM_PID;
83 uint32_t CHID;
84 uint16_t EMM_PID;
85 uint32_t VPID; // videopid
86 uint8_t irdeto_maxindex; // max irdeto indexes always fresh fetched from current ecm
87 uint8_t irdeto_curindex; // current irdeto index we want to handle
88 uint8_t irdeto_cycle; // temp var that holds the irdeto index we started with to detect if we cycled trough all indexes
89 int8_t checked;
90 int8_t status;
91 uint8_t tries;
92 unsigned char table;
93 int8_t index;
94 uint32_t streams;
95};
96
97typedef struct filter_s
98{
99 uint32_t fd; //FilterHandle
100 int32_t pidindex;
101 int32_t pid;
102 uint16_t caid;
103 uint32_t provid;
104 uint16_t type;
105 int32_t count;
106 uchar ecmd5[CS_ECMSTORESIZE]; // last requested ecm md5
107#ifdef WITH_STAPI
108 int32_t NumSlots;
109 uint32_t SlotHandle[10];
110 uint32_t BufferHandle[10];
111#endif
112} FILTERTYPE;
113
114struct s_emmpids
115{
116 uint16_t CAID;
117 uint32_t PROVID;
118 uint16_t PID;
119 uint8_t type;
120};
121
122#define PTINUM 10
123#define SLOTNUM 20
124
125typedef struct demux_s
126{
127 int8_t demux_index;
128 FILTERTYPE demux_fd[MAX_FILTER];
129 uint32_t ca_mask;
130 int8_t adapter_index;
131 int32_t socket_fd;
132 int8_t ECMpidcount;
133 struct timeb emmstart; // last time emm cat was started
134 struct s_ecmpids ECMpids[ECM_PIDS];
135 int8_t EMMpidcount;
136 struct s_emmpids EMMpids[ECM_PIDS];
137 uint16_t max_emm_filter;
138 int8_t STREAMpidcount;
139 uint16_t STREAMpids[ECM_PIDS];
140 int16_t pidindex;
141 int16_t curindex;
142 int8_t max_status;
143 uint16_t program_number;
144 uint16_t onid;
145 uint16_t tsid;
146 uint16_t pmtpid;
147 uint32_t enigma_namespace;
148 unsigned char lastcw[2][8];
149 int8_t emm_filter;
150 uchar hexserial[8];
151 struct s_reader *rdr;
152 char pmt_file[30];
153 time_t pmt_time;
154 uint8_t stopdescramble;
155 uint8_t running;
156 uint8_t old_ecmfiltercount; // previous ecm filtercount
157 uint8_t old_emmfiltercount; // previous emm filtercount
158 pthread_mutex_t answerlock; // requestmode 1 avoid race
159#ifdef WITH_STAPI
160 uint32_t DescramblerHandle[PTINUM];
161 int32_t desc_pidcount;
162 uint32_t slot_assc[PTINUM][SLOTNUM];
163#endif
164 int8_t decodingtries; // -1 = first run
165 struct timeb decstart,decend;
166} DEMUXTYPE;
167
168typedef struct s_streampid
169{
170 uint8_t cadevice; // holds ca device
171 uint16_t streampid; // holds pids
172 uint32_t activeindexers; // bitmask indexers if streampid enabled for index bit is set
173 uint32_t caindex; // holds index that is used to decode on ca device
174}STREAMPIDTYPE;
175
176struct s_dvbapi_priority
177{
178 char type; // p or i
179 uint16_t caid;
180 uint32_t provid;
181 uint16_t srvid;
182 uint32_t chid;
183 uint16_t ecmpid;
184 uint16_t mapcaid;
185 uint32_t mapprovid;
186 uint16_t mapecmpid;
187 int16_t delay;
188 int8_t force;
189 int8_t pidx;
190#ifdef WITH_STAPI
191 char devname[30];
192 char pmtfile[30];
193 int8_t disablefilter;
194#endif
195 struct s_dvbapi_priority *next;
196};
197
198
199#define DMX_FILTER_SIZE 16
200
201
202//dvbapi 1
203typedef struct dmxFilter
204{
205 uint8_t filter[DMX_FILTER_SIZE];
206 uint8_t mask[DMX_FILTER_SIZE];
207} dmxFilter_t;
208
209struct dmxSctFilterParams
210{
211 uint16_t pid;
212 dmxFilter_t filter;
213 uint32_t timeout;
214 uint32_t flags;
215#define DMX_CHECK_CRC 1
216#define DMX_ONESHOT 2
217#define DMX_IMMEDIATE_START 4
218#define DMX_BUCKET 0x1000 /* added in 2005.05.18 */
219#define DMX_KERNEL_CLIENT 0x8000
220};
221
222#define DMX_START1 _IOW('o',41,int)
223#define DMX_STOP1 _IOW('o',42,int)
224#define DMX_SET_FILTER1 _IOW('o',43,struct dmxSctFilterParams *)
225//------------------------------------------------------------------
226
227
228//dbox2+ufs
229typedef struct dmx_filter
230{
231 uint8_t filter[DMX_FILTER_SIZE];
232 uint8_t mask[DMX_FILTER_SIZE];
233 uint8_t mode[DMX_FILTER_SIZE];
234} dmx_filter_t;
235
236
237struct dmx_sct_filter_params
238{
239 uint16_t pid;
240 dmx_filter_t filter;
241 uint32_t timeout;
242 uint32_t flags;
243#define DMX_CHECK_CRC 1
244#define DMX_ONESHOT 2
245#define DMX_IMMEDIATE_START 4
246#define DMX_KERNEL_CLIENT 0x8000
247};
248
249typedef struct ca_descr
250{
251 uint32_t index;
252 uint32_t parity; /* 0 == even, 1 == odd */
253 unsigned char cw[8];
254} ca_descr_t;
255
256typedef struct ca_pid
257{
258 uint32_t pid;
259 int32_t index; /* -1 == disable*/
260} ca_pid_t;
261
262#define DMX_START _IO('o', 41)
263#define DMX_STOP _IO('o', 42)
264#define DMX_SET_FILTER _IOW('o', 43, struct dmx_sct_filter_params)
265
266#define CA_SET_DESCR _IOW('o', 134, ca_descr_t)
267#define CA_SET_PID _IOW('o', 135, ca_pid_t)
268// --------------------------------------------------------------------
269
270void dvbapi_stop_descrambling(int);
271void dvbapi_stop_all_descrambling(void);
272void dvbapi_process_input(int32_t demux_id, int32_t filter_num, uchar *buffer, int32_t len);
273int32_t dvbapi_open_device(int32_t, int32_t, int);
274int32_t dvbapi_stop_filternum(int32_t demux_index, int32_t num);
275int32_t dvbapi_stop_filter(int32_t demux_index, int32_t type);
276struct s_dvbapi_priority *dvbapi_check_prio_match(int32_t demux_id, int32_t pidindex, char type);
277void dvbapi_send_dcw(struct s_client *client, ECM_REQUEST *er);
278void dvbapi_write_cw(int32_t demux_id, uchar *cw, int32_t idx);
279int32_t dvbapi_parse_capmt(unsigned char *buffer, uint32_t length, int32_t connfd, char *pmtfile);
280void request_cw(struct s_client *client, ECM_REQUEST *er, int32_t demux_id, uint8_t delayed_ecm_check);
281void dvbapi_try_next_caid(int32_t demux_id, int8_t checked);
282void dvbapi_read_priority(void);
283int32_t dvbapi_set_section_filter(int32_t demux_index, ECM_REQUEST *er, int32_t n);
284int32_t dvbapi_activate_section_filter(int32_t demux_index, int32_t num, int32_t fd, int32_t pid, uchar *filter, uchar *mask);
285int32_t dvbapi_check_ecm_delayed_delivery(int32_t demux_index, ECM_REQUEST *er);
286int32_t dvbapi_get_filternum(int32_t demux_index, ECM_REQUEST *er, int32_t type);
287int32_t dvbapi_ca_setpid(int32_t demux_index, int32_t pid);
288void dvbapi_set_pid(int32_t demux_id, int32_t num, int32_t idx, bool enable);
289int8_t update_streampid_list(uint8_t cadevice, uint16_t pid, int32_t idx);
290int8_t remove_streampid_from_list(uint8_t cadevice, uint16_t pid, int32_t idx);
291void disable_unused_streampids(int16_t demux_id);
292int8_t is_ca_used(uint8_t cadevice, int32_t pid);
293const char *dvbapi_get_client_name(void);
294void rotate_emmfilter(int32_t demux_id);
295uint16_t dvbapi_get_client_proto_version(void);
296void delayer(ECM_REQUEST *er);
297void check_add_emmpid(int32_t demux_index, uchar *filter, int32_t l, int32_t emmtype);
298void *dvbapi_start_handler(struct s_client *cl, uchar *mbuf, int32_t module_idx, void * (*_main_func)(void *));
299
300#if defined(WITH_AZBOX) || defined(WITH_MCA)
301#define USE_OPENXCAS 1
302extern int32_t openxcas_provid;
303extern uint16_t openxcas_sid, openxcas_caid, openxcas_ecm_pid;
304static inline void openxcas_set_caid(uint16_t _caid) { openxcas_caid = _caid; }
305static inline void openxcas_set_ecm_pid(uint16_t _pid) { openxcas_ecm_pid = _pid; }
306static inline void openxcas_set_sid(uint16_t _sid) { openxcas_sid = _sid; }
307static inline void openxcas_set_provid(uint32_t _provid) { openxcas_provid = _provid; }
308#else
309#define USE_OPENXCAS 0
310static inline void openxcas_set_caid(uint16_t UNUSED(_caid)) { }
311static inline void openxcas_set_ecm_pid(uint16_t UNUSED(_pid)) { }
312static inline void openxcas_set_sid(uint16_t UNUSED(_sid)) { }
313static inline void openxcas_set_provid(uint32_t UNUSED(_provid)) { }
314#endif
315
316bool is_dvbapi_usr(char *usr);
317static inline bool module_dvbapi_enabled(void) { return cfg.dvbapi_enabled; }
318#else
319static inline void dvbapi_stop_all_descrambling(void) { }
320static inline void dvbapi_read_priority(void) { }
321static inline bool is_dvbapi_usr(char *UNUSED(usr)) { return 0; }
322static inline bool module_dvbapi_enabled(void) { return 0; }
323#endif // WITH_DVBAPI
324
325#endif // MODULE_DVBAPI_H_
Note: See TracBrowser for help on using the repository browser.