source: trunk/module-dvbapi.h@ 10622

Last change on this file since 10622 was 10622, checked in by Gorgone Impertinence, 7 years ago

better to use static inline instead of #ifdef

thnx jsompis

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