]> git.vomp.tv Git - vompserver.git/blob - libdvbmpeg/devices.hh
Initial import
[vompserver.git] / libdvbmpeg / devices.hh
1 #ifndef _channel_hh
2 #define _channel_hh
3
4 using namespace std;
5 #include <stdint.h>
6
7 #include <stdio.h>
8 #include <string.h>
9 #include <stdlib.h>
10
11 #include <iostream>
12 #include <fstream>
13 #include <sstream>
14
15 #include "DVB.hh"
16
17 #define MAXNAM 80
18 #define MAXKEY 15
19
20 const int maxname=80;
21 const int MAXAPIDS=32;
22 const uint32_t UNSET=0xffffffff;
23 const uint16_t NOID=0xffff;
24 const uint16_t NOPID=0xffff;
25
26 class Transponder {
27 public:
28         uint16_t id;
29         uint16_t onid;
30         uint16_t satid;
31         int type;
32         char name[maxname+1];
33         uint32_t freq;
34         int pol;
35         int qam;
36         uint32_t srate;
37         int fec;
38         int band;
39         int hp_rate;         
40         int lp_rate; 
41         int mod;    
42         int transmode;
43         int guard;
44         int hierarchy;
45
46         struct Sat *sat;
47         
48         Transponder() {
49                 name[0]='\0';
50                 id = NOID;
51                 onid = NOID;
52                 satid = NOID;
53                 type = 0;
54         }
55
56         friend ostream &operator<<(ostream &stream, Transponder &x);
57         friend istream &operator>>(istream &stream, Transponder &x);
58 };
59
60 class Sat {
61 public:
62         uint16_t id;
63         char name[maxname+1];
64         unsigned int lnbid;
65         struct Lnb *lnb;
66         unsigned int rotorid;
67         unsigned int fmin;
68         unsigned int fmax;
69
70         Sat() {
71                 id=NOID;
72                 name[0]='\0';
73                 lnb=NULL;
74                 rotorid=NOID;
75                 lnbid=NOID;
76                 fmin=fmax=0;
77         };
78         int set(int sid, char *sname, int slnbid, int srotorid) {
79           return 0;
80         }; 
81
82         friend ostream &operator<<(ostream &stream, Sat &x);
83         friend istream &operator>>(istream &stream, Sat &x);
84 };
85
86
87 class Lnb {
88 public:
89         Sat *sat;
90         uint16_t id;
91         struct DVB *dvbd;
92         char name[maxname+1];
93         int type;
94         unsigned int lof1;
95         unsigned int lof2;
96         unsigned int slof;
97         int diseqcnr;
98         uint16_t diseqcid;
99         uint16_t swiid;
100
101
102         void cpy (const Lnb &olnb){
103           this->id=olnb.id;
104           this->type=olnb.type;
105           this->lof1=olnb.lof1;
106           this->lof2=olnb.lof2;
107           this->slof=olnb.slof;
108           this->diseqcnr=olnb.diseqcnr;
109           this->diseqcid=olnb.diseqcid;
110           this->swiid=olnb.swiid;
111           strncpy(this->name,olnb.name,maxname);
112         }
113
114         void init(int t, uint l1, uint l2, uint sl,
115                   int dnr, int disid, int sw) {
116                 type=t;
117                 lof1=l1;
118                 lof2=l2;
119                 slof=sl;
120                 diseqcnr=dnr;
121                 diseqcid=disid;
122                 swiid=sw;
123                 dvbd=0;
124                 name[0]='\0';
125         }
126
127         Lnb () {
128                 lof1=lof2=slof=0;
129                 swiid=NOID;
130                 diseqcid=NOID;
131                 diseqcnr=-1;
132                 name[0]='\0';
133         }
134   
135         Lnb (const Lnb &olnb){
136           cpy(olnb);
137         }
138
139   
140
141         friend ostream &operator<<(ostream &stream, Lnb &x);
142         friend istream &operator>>(istream &stream, Lnb &x);
143 };
144
145 struct diseqcmsg {
146         int burst;
147         int len;
148         unsigned char msg[8];
149 };
150
151 class DiSEqC {
152 public:
153         uint16_t id;
154         char name[maxname+1];
155         diseqcmsg msgs[4];
156
157         friend ostream &operator<<(ostream &stream, DiSEqC &x);
158         friend istream &operator>>(istream &stream, DiSEqC &x);
159 };
160
161 class Rotor {
162 public:
163         uint16_t id;
164         char name[maxname+1];
165         diseqcmsg msgs[4];
166
167         friend ostream &operator<<(ostream &stream, Rotor &x);
168         friend istream &operator>>(istream &stream, Rotor &x);
169 };
170
171 class Switch {
172 public:
173         uint16_t id;
174         int switchid;
175         char name[maxname+1];
176         diseqcmsg msg;
177
178         friend ostream &operator<<(ostream &stream, Switch &x);
179         friend istream &operator>>(istream &stream, Switch &x);
180 };
181
182 class Network {
183 public:
184         uint16_t id;
185         char name[maxname+1];
186
187         friend ostream &operator<<(ostream &stream, Network &x);
188         friend istream &operator>>(istream &stream, Network &x);
189 };
190
191 class Bouquet {
192 public:
193         uint16_t id;
194         char name[maxname+1];
195
196         friend ostream &operator<<(ostream &stream, Bouquet &x);
197         friend istream &operator>>(istream &stream, Bouquet &x);
198 };
199
200
201 #define MAX_ECM 16
202 #define MAX_ECM_DESC 256
203 typedef struct ecm_struct {
204         int num;
205         uint16_t sysid[MAX_ECM];
206         uint16_t pid[MAX_ECM];
207         uint16_t length[MAX_ECM];
208         uint8_t data[MAX_ECM*MAX_ECM_DESC];
209 } ecm_t;
210
211
212
213 class Channel{
214 public:
215         Channel *next;
216         uint32_t id;
217         char name[maxname+1];
218         int32_t type;
219         int checked;
220   
221         uint16_t pnr;
222         uint16_t vpid;
223         uint16_t apids[MAXAPIDS];
224         char apids_name[MAXAPIDS*4];
225         int32_t  apidnum;
226         int  last_apidn;
227         uint16_t ac3pid;
228         uint16_t ttpid;
229         uint16_t pmtpid;
230         uint16_t pcrpid;
231         uint16_t casystem;
232         uint16_t capid;
233
234         ecm_t  ecm;
235         int (*ecm_callback)(Channel *chan);
236
237         int has_eit;
238         int pres_follow;
239
240         uint16_t satid;
241         uint16_t tpid;
242         uint16_t onid;
243         uint16_t bid;
244         int8_t eit_ver_n;
245         int8_t eit_ver_c;
246
247         void clearall(void) {
248                 id=UNSET;
249                 name[0]='\0';
250                 type=0;
251                 checked = 0;
252                 has_eit = -1;
253                 pres_follow = -1;
254                 eit_ver_c = -1;
255                 eit_ver_n = -1;
256                 
257                 pnr=NOPID;
258                 vpid=NOPID;
259                 memset(apids, 0, sizeof(uint16_t)*MAXAPIDS);
260                 memset(apids_name, 0, sizeof(char)*MAXAPIDS*4);
261                 apidnum=0;
262                 last_apidn=-1;
263                 ac3pid=NOPID;
264                 ttpid=NOPID;
265                 pmtpid=NOPID;
266                 pcrpid=NOPID;
267                 capid=NOPID;
268
269                 satid=NOID;
270                 tpid=NOID;
271                 onid=NOID;
272                 bid=NOID;
273                 ecm_callback = NULL;
274                 memset(&ecm,0, sizeof(ecm_t));
275         };
276
277         Channel() {
278                 clearall();
279         }
280   
281         Channel(int cid, char *nam, int ty, int prognr,
282                 int vid, int aid, int tid) {
283                 int l=strlen(nam);
284
285                 clearall();
286                 if (l>maxname){
287                   cerr << "" << endl; 
288                   l=maxname;
289                 }
290                 strncpy(name, nam, l);
291                 name[l]='\0';
292                 type=ty;
293                 pnr=prognr;
294                 vpid=vid;
295                 apids[0]=aid;
296         }
297
298 #ifdef DEBUG
299         ~Channel(){
300                 cerr <<"Channel " << name << "  destroyed" << endl;
301         }
302 #endif
303   
304         friend ostream &operator<<(ostream &stream, Channel &x);
305         friend istream &operator>>(istream &stream, Channel &x);
306 };
307
308 int findkey(char *name, char *keys[]);
309 void getname(char *name,istream &ins);
310 #endif /*channel.h*/