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
RevLine 
[8265]1#ifndef MODULE_DVBAPI_H_
2#define MODULE_DVBAPI_H_
3
[2771]4#ifdef HAVE_DVBAPI
5#include <sys/un.h>
6
7#define TYPE_ECM 1
8#define TYPE_EMM 2
9
10//api
[8951]11#define DVBAPI_3 0
12#define DVBAPI_1 1
13#define STAPI 2
14#define COOLAPI 3
[2771]15
[8951]16#define TMPDIR "/tmp/"
17#define STANDBY_FILE "/tmp/.pauseoscam"
18#define ECMINFO_FILE "/tmp/ecm.info"
[2771]19
[6409]20#define MAX_DEMUX 16
[2771]21#define MAX_CAID 50
[5124]22#define ECM_PIDS 30
[6201]23#define MAX_FILTER 24
[2771]24
[4493]25#define BOX_COUNT 6
[2771]26
[8951]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
[9756]38#define BOXTYPE_PC_NODMX 12
39#define BOXTYPES 12
[9031]40#define DMXMD5HASHSIZE 16 // use MD5()
[10620]41#define REMOVED_STREAMPID_INDEX 1
[9320]42#define REMOVED_STREAMPID_LASTINDEX 2
[10620]43#define REMOVED_DECODING_STREAMPID_INDEX 3
[9320]44#define NO_STREAMPID_LISTED 0
45#define FOUND_STREAMPID_INDEX 0
46#define ADDED_STREAMPID_INDEX 1
[10620]47#define FIRST_STREAMPID_INDEX 2
48#define CA_IS_CLEAR -1
[9574]49#define DUMMY_FD 0xFFFF
[8368]50
[9869]51//constants used int socket communication:
[10652]52#define DVBAPI_PROTOCOL_VERSION 2
[9869]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
[9923]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
[9869]62#define DVBAPI_FILTER_DATA 0xFFFF0000
63#define DVBAPI_CLIENT_INFO 0xFFFF0001
64#define DVBAPI_SERVER_INFO 0xFFFF0002
[10652]65#define DVBAPI_ECM_INFO 0xFFFF0003
[9869]66
[10652]67#define DVBAPI_MAX_PACKET_SIZE 262 //maximum possible packet size
68
[2771]69struct box_devices
70{
[8960]71 char *path;
72 char *ca_device;
73 char *demux_device;
74 char *cam_socket_path;
75 int8_t api;
[2771]76};
77
[3874]78struct s_ecmpids
[2771]79{
[8960]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;
[3874]95};
[2771]96
97typedef struct filter_s
98{
[8960]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
[4771]107#ifdef WITH_STAPI
[8960]108 int32_t NumSlots;
109 uint32_t SlotHandle[10];
110 uint32_t BufferHandle[10];
[4771]111#endif
[2771]112} FILTERTYPE;
113
[3874]114struct s_emmpids
115{
[8960]116 uint16_t CAID;
117 uint32_t PROVID;
118 uint16_t PID;
119 uint8_t type;
[3874]120};
121
[4771]122#define PTINUM 10
123#define SLOTNUM 20
124
[2771]125typedef struct demux_s
126{
[8960]127 int8_t demux_index;
128 FILTERTYPE demux_fd[MAX_FILTER];
[10609]129 uint32_t ca_mask;
[8960]130 int8_t adapter_index;
131 int32_t socket_fd;
132 int8_t ECMpidcount;
[9087]133 struct timeb emmstart; // last time emm cat was started
[8960]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;
[9184]146 uint16_t pmtpid;
[8960]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;
[10620]155 uint8_t running;
[8960]156 uint8_t old_ecmfiltercount; // previous ecm filtercount
[9829]157 uint8_t old_emmfiltercount; // previous emm filtercount
158 pthread_mutex_t answerlock; // requestmode 1 avoid race
[4771]159#ifdef WITH_STAPI
[8960]160 uint32_t DescramblerHandle[PTINUM];
161 int32_t desc_pidcount;
162 uint32_t slot_assc[PTINUM][SLOTNUM];
[4771]163#endif
[10273]164 int8_t decodingtries; // -1 = first run
165 struct timeb decstart,decend;
[2771]166} DEMUXTYPE;
167
[9072]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
[10620]173 uint32_t caindex; // holds index that is used to decode on ca device
[9072]174}STREAMPIDTYPE;
175
[3522]176struct s_dvbapi_priority
177{
[8960]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;
[9770]189 int8_t pidx;
[3909]190#ifdef WITH_STAPI
[8960]191 char devname[30];
192 char pmtfile[30];
193 int8_t disablefilter;
[3909]194#endif
[8960]195 struct s_dvbapi_priority *next;
[3522]196};
[2771]197
[3522]198
[2771]199#define DMX_FILTER_SIZE 16
200
201
202//dvbapi 1
203typedef struct dmxFilter
204{
[8960]205 uint8_t filter[DMX_FILTER_SIZE];
206 uint8_t mask[DMX_FILTER_SIZE];
[2771]207} dmxFilter_t;
208
209struct dmxSctFilterParams
210{
[8960]211 uint16_t pid;
212 dmxFilter_t filter;
213 uint32_t timeout;
214 uint32_t flags;
[8951]215#define DMX_CHECK_CRC 1
216#define DMX_ONESHOT 2
[2771]217#define DMX_IMMEDIATE_START 4
[8951]218#define DMX_BUCKET 0x1000 /* added in 2005.05.18 */
[2771]219#define DMX_KERNEL_CLIENT 0x8000
220};
221
[8951]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 *)
[2771]225//------------------------------------------------------------------
226
227
228//dbox2+ufs
229typedef struct dmx_filter
230{
[8960]231 uint8_t filter[DMX_FILTER_SIZE];
232 uint8_t mask[DMX_FILTER_SIZE];
233 uint8_t mode[DMX_FILTER_SIZE];
[2771]234} dmx_filter_t;
235
236
237struct dmx_sct_filter_params
238{
[8960]239 uint16_t pid;
240 dmx_filter_t filter;
241 uint32_t timeout;
242 uint32_t flags;
[8951]243#define DMX_CHECK_CRC 1
244#define DMX_ONESHOT 2
[2771]245#define DMX_IMMEDIATE_START 4
246#define DMX_KERNEL_CLIENT 0x8000
247};
248
[8951]249typedef struct ca_descr
250{
[8960]251 uint32_t index;
252 uint32_t parity; /* 0 == even, 1 == odd */
253 unsigned char cw[8];
[2771]254} ca_descr_t;
255
[8951]256typedef struct ca_pid
257{
[8960]258 uint32_t pid;
259 int32_t index; /* -1 == disable*/
[2771]260} ca_pid_t;
261
[8951]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)
[2771]265
[8951]266#define CA_SET_DESCR _IOW('o', 134, ca_descr_t)
267#define CA_SET_PID _IOW('o', 135, ca_pid_t)
[2771]268// --------------------------------------------------------------------
269
270void dvbapi_stop_descrambling(int);
[10620]271void dvbapi_stop_all_descrambling(void);
[4994]272void dvbapi_process_input(int32_t demux_id, int32_t filter_num, uchar *buffer, int32_t len);
[5233]273int32_t dvbapi_open_device(int32_t, int32_t, int);
[4994]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);
[6224]277void dvbapi_send_dcw(struct s_client *client, ECM_REQUEST *er);
[7614]278void dvbapi_write_cw(int32_t demux_id, uchar *cw, int32_t idx);
[6954]279int32_t dvbapi_parse_capmt(unsigned char *buffer, uint32_t length, int32_t connfd, char *pmtfile);
[8680]280void request_cw(struct s_client *client, ECM_REQUEST *er, int32_t demux_id, uint8_t delayed_ecm_check);
[8703]281void dvbapi_try_next_caid(int32_t demux_id, int8_t checked);
[8265]282void dvbapi_read_priority(void);
[10620]283int32_t dvbapi_set_section_filter(int32_t demux_index, ECM_REQUEST *er, int32_t n);
[9574]284int32_t dvbapi_activate_section_filter(int32_t demux_index, int32_t num, int32_t fd, int32_t pid, uchar *filter, uchar *mask);
[8680]285int32_t dvbapi_check_ecm_delayed_delivery(int32_t demux_index, ECM_REQUEST *er);
[8690]286int32_t dvbapi_get_filternum(int32_t demux_index, ECM_REQUEST *er, int32_t type);
[8680]287int32_t dvbapi_ca_setpid(int32_t demux_index, int32_t pid);
[9072]288void dvbapi_set_pid(int32_t demux_id, int32_t num, int32_t idx, bool enable);
[9320]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);
[9072]291void disable_unused_streampids(int16_t demux_id);
[10610]292int8_t is_ca_used(uint8_t cadevice, int32_t pid);
[9877]293const char *dvbapi_get_client_name(void);
[10598]294void rotate_emmfilter(int32_t demux_id);
[9925]295uint16_t dvbapi_get_client_proto_version(void);
[9893]296void delayer(ECM_REQUEST *er);
[9989]297void check_add_emmpid(int32_t demux_index, uchar *filter, int32_t l, int32_t emmtype);
[10183]298void *dvbapi_start_handler(struct s_client *cl, uchar *mbuf, int32_t module_idx, void * (*_main_func)(void *));
[2771]299
[10167]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; }
[8265]308#else
[10167]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
[10212]316bool is_dvbapi_usr(char *usr);
[10230]317static inline bool module_dvbapi_enabled(void) { return cfg.dvbapi_enabled; }
[10167]318#else
[10622]319static inline void dvbapi_stop_all_descrambling(void) { }
[8265]320static inline void dvbapi_read_priority(void) { }
[10212]321static inline bool is_dvbapi_usr(char *UNUSED(usr)) { return 0; }
[10230]322static inline bool module_dvbapi_enabled(void) { return 0; }
[2771]323#endif // WITH_DVBAPI
[8265]324
325#endif // MODULE_DVBAPI_H_
Note: See TracBrowser for help on using the repository browser.