1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
|
#ifndef _DVB_DEV_HH_
#define _DVB_DEV_HH_
extern "C" {
#include <stdint.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/poll.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <strstream.h>
#include <iostream.h>
#include <iomanip.h>
#include <sys/time.h>
#include <time.h>
#include <ost/dmx.h>
#include <ost/frontend.h>
#include <ost/sec.h>
#include <ost/video.h>
#include <channel.h>
}
#include <osd.hh>
#include <devices.hh>
#ifndef MAXNAM
#define MAXNAM 80
#endif
#define FRONT_DVBS 1
#define FRONT_DVBC 2
#define FRONT_DVBT 3
#define DEC(N) dec << setw(N) << setfill(int('0'))
#define HEX(N) hex << setw(N) << setfill(int('0'))
#define MAXSECSIZE 4096
#define NK 10
enum {LNB=0,DIS,ROTOR,TRANS,CHAN,BOU,SAT,PICS,SWI,NTW};
static const int nums[]={LNB,DIS,ROTOR,TRANS,CHAN,BOU,SAT,PICS,SWI,NTW};
static const int maxs[]={ 32, 32, 32, 512,16384,512,100, 50, 10, 100};
enum{DVB_ORIG=0, DVB_NOKIA, DVB_XML};
#define VIDEO_DEV "/dev/ost/video"
#define AUDIO_DEV "/dev/ost/audio"
#define FRONT_DEV "/dev/ost/frontend"
#define SEC_DEV "/dev/ost/sec"
#define DEMUX_DEV "/dev/ost/demux"
class DVB {
public:
int fd_video;
int fd_audio;
int fd_frontend;
int fd_sec;
int fd_demuxa;
int fd_demuxv;
int fd_demuxtt;
int fdvb;
int max_tpid;
int max_satid;
int max_chanid;
struct secCommand scmd;
struct secCmdSequence scmds;
struct dmxPesFilterParams pesFilterParamsV;
struct dmxPesFilterParams pesFilterParamsA;
struct dmxPesFilterParams pesFilterParamsTT;
FrontendParameters front_param;
int front_type;
int dvr_enabled;
OSD osd;
struct Lnb *lnbs;
struct DiSEqC *diseqcs;
struct Rotor *rotors;
struct Transponder *tps;
struct Channel *chans;
struct Bouquet *bouqs;
struct Sat *sats;
struct Picture *pics;
struct Switch *swis;
struct Network *ntws;
int num[NK];
DVB(){
max_tpid = 0;
max_satid = 0;
max_chanid = 0;
fd_video = -1;
fd_audio = -1;
fd_frontend = -1;
fd_sec = -1;
fd_demuxa = -1;
fd_demuxv = -1;
fd_demuxtt = -1;
fdvb = -1;
// init("","",0);
}
DVB(int i){
max_tpid = 0;
max_satid = 0;
max_chanid = 0;
fd_video = -1;
fd_audio = -1;
fd_frontend = -1;
fd_sec = -1;
fd_demuxa = -1;
fd_demuxv = -1;
fd_demuxtt = -1;
fdvb = -1;
init("","",i);
}
DVB(char *a, char *b) {
max_tpid = 0;
max_satid = 0;
max_chanid = 0;
fd_video = -1;
fd_audio = -1;
fd_frontend = -1;
fd_sec = -1;
fd_demuxa = -1;
fd_demuxv = -1;
fd_demuxtt = -1;
fdvb = -1;
init(a,b,0);
}
~DVB();
void use_osd(int fd = -1){
char dvn[32];
ostrstream str1(dvn,32);
if (fd >= 0) str1 << "/dev/ost/osd" << fd << ends;
else str1 << "/dev/ost/osd" << ends;
fdvb = open(dvn, O_RDWR);
if (fdvb >= 0){
cerr << dvn << " for OSD" << endl;
osd.init(fdvb);
} else perror("osd");
osd.Open(80, 500, 640, 540, 2, 0, 2);
osd.SetColor(0, 0, 0, 0, 255);
osd.SetColor(1, 240, 240, 240, 255);
osd.Show();
}
void close_osd(){
osd.Close(fdvb);
close(fdvb);
}
int DVR_enabled(){
return dvr_enabled;
}
void enable_DVR(){
dvr_enabled = 1;
}
void disable_DVR(){
dvr_enabled = 0;
}
void init(char *a="/dev/video0", char *b="/dev/vbi0",int minor = 0);
inline void init(char *a, char *b){
init(a,b,0);
}
int set_tp(uint *freq, int ttk, int pol, uint srate);
void set_apid(ushort apid);
void set_vpid(ushort vpid);
void set_ttpid(ushort ttpid);
int set_lnb(int dis);
void set_diseqc_nb(int nr);
void set_front(void);
void get_front(void);
/*
int GetNIT(dvb_nit_t *nit);
int GetPMT(dvb_pmt_t *pmt, unsigned short pid);
int GetPAT(dvb_pat_t *pat);
int GetSDT(dvb_sdt_t *sdt);
*/
int GetSection(uint8_t *buf,
uint16_t PID, uint8_t TID, uint16_t TIDExt,
uint16_t FilterTIDExt,
uint8_t secnum, uint8_t &msecnum);
int GetSection(uint8_t *buf,
uint16_t PID, uint8_t *filter, uint8_t *mask,
uint8_t secnum, uint8_t &msecnum);
int GetSection(unsigned char *buf, ushort PID, unsigned char sec,
unsigned char secnum, unsigned char &msecnum);
int SetFilter(uint16_t pid, unsigned char *filter,
unsigned char *mask,
uint32_t timeout, uint32_t flags);
uint16_t SetFilter(uint16_t pid, uint16_t section, uint16_t mode);
int CloseFilter(int h);
void bar2(int x, int y, int w, int h, int val, int col1, int col2);
int SetTP(unsigned int, unsigned int);
int scan(void);
int scan_all_tps(void);
int scan_lnb(struct Lnb &);
int scan_cable(Sat &sat);
int scan_sat(struct Sat &);
int scan_tp(struct Transponder &);
int AddLNB(int id, int t, uint l1, uint l2, uint sl,
int dnr, int dis, int sw);
int AddSat(Sat &sat);
int AddSat(int satid, unsigned int lnbid, char *name, uint fmin, uint fmax);
int AddTP(Transponder &tp);
// int AddChannels(Transponder &tp, dvb_pat_t &pat, dvb_sdt_t &sdt);
int AddChannel(Channel &chan);
int check_pids(Channel *chan);
void check_all_pids();
void parse_sdt(uint8_t *buf, int count, Channel *chan);
void scan_sdt(Channel *chan);
int channel_num(void) {
return num[CHAN];
};
int channel_change(int n) {
return 0;
};
int SetChannel(uint16_t, uint16_t, uint16_t, uint16_t);
bool Tune(int &newProgNr, int &oldProgNr, uint16_t ONID,
uint16_t TSID, int SID);
int SetChannel(int chnr, char *apref=NULL, uint16_t *apidp=NULL,
uint16_t *vpidp=NULL);
int GetChannel(int chnr, struct channel *);
int NumChannel(void) {
return num[CHAN];
}
int tune_it(FrontendParameters *qpsk);
void find_satid(Channel &chan);
int check_input_format(istream &ins);
void read_original(istream &ins);
int get_all_progs(uint16_t *progbuf, uint16_t *pnrbuf, int length);
uint16_t find_pnr(uint16_t vpid, uint16_t apid);
int get_pids(uint16_t prog_pid, uint16_t *vpid, uint16_t *apids);
friend ostream &operator<<(ostream &stream, DVB &x);
friend istream &operator>>(istream &stream, DVB &x);
};
#define NOKIA_MAX_SAT 4
class nokiaconv{
public:
DVB *dvb;
struct lnb_sat_l{
int n;
int diseqc[NOKIA_MAX_SAT];
char sat_names[NOKIA_MAX_SAT][MAXNAM+1];
int satid[NOKIA_MAX_SAT];
} lnb_sat;
nokiaconv(DVB *d){
dvb = d;
}
friend istream &operator>>(istream &stream, nokiaconv &x);
};
#define XML_MAX_SAT 4
class xmlconv{
public:
DVB *dvb;
struct lnb_sat_l{
int n;
int diseqc[XML_MAX_SAT];
char sat_names[XML_MAX_SAT][MAXNAM+1];
int satid[XML_MAX_SAT];
} lnb_sat;
xmlconv(DVB *d){
dvb = d;
}
int read_stream(istream &ins, int nchan);
int read_desc(istream &ins, int nchan);
int read_serv(istream &ins, int ctp, int csat);
int read_trans(istream &ins, int satid);
int read_sat(istream &ins, int satid = -1);
int skip_tag(istream &ins, char *tag);
int read_iso639(istream &ins, int nchan, int apids);
friend istream &operator>>(istream &stream, xmlconv &x);
};
void hdump(unsigned char *buf, int n);
int get_dvbrc(char *path,DVB &dv, int dev, int len);
#endif
|