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 |
|
---|
18 |
|
---|
19 | #define T_UNIQUE 1
|
---|
20 | #define T_SHARED 2
|
---|
21 | #define T_GLOBAL 4
|
---|
22 |
|
---|
23 | #define TMPDIR "/tmp/"
|
---|
24 | #define STANDBY_FILE "/tmp/.pauseoscam"
|
---|
25 | #define ECMINFO_FILE "/tmp/ecm.info"
|
---|
26 |
|
---|
27 | #define MAX_DEMUX 5
|
---|
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 | #define BOX_COUNT 4
|
---|
37 |
|
---|
38 | struct box_devices
|
---|
39 | {
|
---|
40 | char *path;
|
---|
41 | char *ca_device;
|
---|
42 | char *demux_device;
|
---|
43 | char *cam_socket_path;
|
---|
44 | };
|
---|
45 |
|
---|
46 | struct s_ecmpids
|
---|
47 | {
|
---|
48 | unsigned short CAID;
|
---|
49 | unsigned long PROVID;
|
---|
50 | unsigned short ECM_PID;
|
---|
51 | unsigned short EMM_PID;
|
---|
52 | int irdeto_numchids;
|
---|
53 | int irdeto_curchid;
|
---|
54 | int irdeto_chid;
|
---|
55 | int checked;
|
---|
56 | int status;
|
---|
57 | unsigned char table;
|
---|
58 | int index;
|
---|
59 | unsigned char slen;
|
---|
60 | char stream[8];
|
---|
61 | };
|
---|
62 |
|
---|
63 | typedef struct filter_s
|
---|
64 | {
|
---|
65 | uint fd; //FilterHandle
|
---|
66 | int pidindex;
|
---|
67 | int pid;
|
---|
68 | ushort type;
|
---|
69 | int count;
|
---|
70 | } FILTERTYPE;
|
---|
71 |
|
---|
72 | struct s_emmpids
|
---|
73 | {
|
---|
74 | ushort CAID;
|
---|
75 | ulong PROVID;
|
---|
76 | ushort PID;
|
---|
77 | uint8 type;
|
---|
78 | };
|
---|
79 |
|
---|
80 | typedef struct demux_s
|
---|
81 | {
|
---|
82 | int demux_index;
|
---|
83 | FILTERTYPE demux_fd[MAX_FILTER];
|
---|
84 | int ca_mask;
|
---|
85 | int adapter_index;
|
---|
86 | int socket_fd;
|
---|
87 | int ECMpidcount;
|
---|
88 | struct s_ecmpids ECMpids[ECM_PIDS];
|
---|
89 | int EMMpidcount;
|
---|
90 | struct s_emmpids EMMpids[ECM_PIDS];
|
---|
91 | int STREAMpidcount;
|
---|
92 | unsigned short STREAMpids[ECM_PIDS];
|
---|
93 | int pidindex;
|
---|
94 | int curindex;
|
---|
95 | int tries;
|
---|
96 | int max_status;
|
---|
97 | unsigned short program_number;
|
---|
98 | unsigned char lastcw[2][8];
|
---|
99 | int emm_filter;
|
---|
100 | uchar hexserial[8];
|
---|
101 | struct s_reader *rdr;
|
---|
102 | char pmt_file[30];
|
---|
103 | int pmt_time;
|
---|
104 | } DEMUXTYPE;
|
---|
105 |
|
---|
106 | struct s_dvbapi_priority
|
---|
107 | {
|
---|
108 | char type; // p or i
|
---|
109 | ushort caid;
|
---|
110 | ulong provid;
|
---|
111 | ushort srvid;
|
---|
112 | ushort chid;
|
---|
113 | ushort ecmpid;
|
---|
114 | ushort mapcaid;
|
---|
115 | ulong mapprovid;
|
---|
116 | int delay;
|
---|
117 | int force;
|
---|
118 | struct s_dvbapi_priority *next;
|
---|
119 | };
|
---|
120 |
|
---|
121 |
|
---|
122 | #define DMX_FILTER_SIZE 16
|
---|
123 |
|
---|
124 |
|
---|
125 | //dvbapi 1
|
---|
126 | typedef struct dmxFilter
|
---|
127 | {
|
---|
128 | uint8_t filter[DMX_FILTER_SIZE];
|
---|
129 | uint8_t mask[DMX_FILTER_SIZE];
|
---|
130 | } dmxFilter_t;
|
---|
131 |
|
---|
132 | struct dmxSctFilterParams
|
---|
133 | {
|
---|
134 | uint16_t pid;
|
---|
135 | dmxFilter_t filter;
|
---|
136 | uint32_t timeout;
|
---|
137 | uint32_t flags;
|
---|
138 | #define DMX_CHECK_CRC 1
|
---|
139 | #define DMX_ONESHOT 2
|
---|
140 | #define DMX_IMMEDIATE_START 4
|
---|
141 | #define DMX_BUCKET 0x1000 /* added in 2005.05.18 */
|
---|
142 | #define DMX_KERNEL_CLIENT 0x8000
|
---|
143 | };
|
---|
144 |
|
---|
145 | #define DMX_START1 _IOW('o',41,int)
|
---|
146 | #define DMX_STOP1 _IOW('o',42,int)
|
---|
147 | #define DMX_SET_FILTER1 _IOW('o',43,struct dmxSctFilterParams *)
|
---|
148 | //------------------------------------------------------------------
|
---|
149 |
|
---|
150 |
|
---|
151 | //dbox2+ufs
|
---|
152 | typedef struct dmx_filter
|
---|
153 | {
|
---|
154 | uint8_t filter[DMX_FILTER_SIZE];
|
---|
155 | uint8_t mask[DMX_FILTER_SIZE];
|
---|
156 | uint8_t mode[DMX_FILTER_SIZE];
|
---|
157 | } dmx_filter_t;
|
---|
158 |
|
---|
159 |
|
---|
160 | struct dmx_sct_filter_params
|
---|
161 | {
|
---|
162 | uint16_t pid;
|
---|
163 | dmx_filter_t filter;
|
---|
164 | uint32_t timeout;
|
---|
165 | uint32_t flags;
|
---|
166 | #define DMX_CHECK_CRC 1
|
---|
167 | #define DMX_ONESHOT 2
|
---|
168 | #define DMX_IMMEDIATE_START 4
|
---|
169 | #define DMX_KERNEL_CLIENT 0x8000
|
---|
170 | };
|
---|
171 |
|
---|
172 | typedef struct ca_descr {
|
---|
173 | unsigned int index;
|
---|
174 | unsigned int parity; /* 0 == even, 1 == odd */
|
---|
175 | unsigned char cw[8];
|
---|
176 | } ca_descr_t;
|
---|
177 |
|
---|
178 | typedef struct ca_pid {
|
---|
179 | unsigned int pid;
|
---|
180 | int index; /* -1 == disable*/
|
---|
181 | } ca_pid_t;
|
---|
182 |
|
---|
183 | #define DMX_START _IO('o', 41)
|
---|
184 | #define DMX_STOP _IO('o', 42)
|
---|
185 | #define DMX_SET_FILTER _IOW('o', 43, struct dmx_sct_filter_params)
|
---|
186 |
|
---|
187 | #define CA_SET_DESCR _IOW('o', 134, ca_descr_t)
|
---|
188 | #define CA_SET_PID _IOW('o', 135, ca_pid_t)
|
---|
189 | // --------------------------------------------------------------------
|
---|
190 |
|
---|
191 | #ifdef WITH_STAPI
|
---|
192 | void *stapi_read_thread(void *);
|
---|
193 | void stapi_off(int);
|
---|
194 | int stapi_open();
|
---|
195 | int stapi_set_filter(int demux_id, ushort pid, uchar *filter, uchar *mask, int num, char *pmtfile);
|
---|
196 | int stapi_remove_filter(int demux_id, int num, char *pmtfile);
|
---|
197 | int stapi_set_pid(int demux_id, int num, int index, ushort pid, char *pmtfile);
|
---|
198 | int stapi_write_cw(int demux_id, uchar *cw, ushort *, int, char *pmtfile);
|
---|
199 | #endif
|
---|
200 |
|
---|
201 | void dvbapi_stop_descrambling(int);
|
---|
202 | void dvbapi_process_input(int demux_id, int filter_num, uchar *buffer, int len);
|
---|
203 | int dvbapi_open_device(int, int, int);
|
---|
204 | int dvbapi_stop_filternum(int demux_index, int num);
|
---|
205 | int dvbapi_stop_filter(int demux_index, int type);
|
---|
206 | struct s_dvbapi_priority *dvbapi_check_prio_match(int demux_id, int pidindex, char type);
|
---|
207 |
|
---|
208 | #ifdef WITH_STAPI
|
---|
209 | #define cs_log(x...) cs_log("stapi: "x)
|
---|
210 | #ifdef WITH_DEBUG
|
---|
211 | #define cs_debug(x...) cs_debug("stapi: "x)
|
---|
212 | #endif
|
---|
213 | #else
|
---|
214 | #define cs_log(x...) cs_log("dvbapi: "x)
|
---|
215 | #ifdef WITH_DEBUG
|
---|
216 | #define cs_debug(x...) cs_debug("dvbapi: "x)
|
---|
217 | #endif
|
---|
218 | #endif
|
---|
219 |
|
---|
220 | #endif // MODULEDVBAPI_H_
|
---|
221 | #endif // WITH_DVBAPI
|
---|