trunk 20080912
[gitenigma.git] / include / lib / dvb / dvb.h
blobd93c5bb9ad77ad7876cb4aa8a8d3625c0cab5191
1 #ifndef __dvb_h
2 #define __dvb_h
4 #include <stdio.h>
5 #include "si.h"
7 /** reihenfolge: transport_stream_id, original_network_id, service_id
8 bei services wird die transport_stream_id evtl. ignoriert */
10 class eDVB;
12 #include <list>
13 #include <map>
14 #include <utility>
15 #include <functional>
16 #include <set>
17 #include <stack>
18 #include <xmltree.h>
20 #include <lib/system/elock.h>
22 #ifndef MIN
23 #define MIN(a,b) ((a) < (b) ? (a) : (b))
24 #endif
26 #ifndef MAX
27 #define MAX(a,b) ((a) > (b) ? (a) : (b))
28 #endif
30 class eTransponderList;
31 class eServiceReference;
32 class eLNB;
33 class eSatellite;
35 // bitte KEINE operator int() definieren, sonst bringt das ganze nix!
36 struct eTransportStreamID
38 private:
39 int v;
40 public:
41 int get() const { return v; }
42 eTransportStreamID(int i): v(i) { }
43 eTransportStreamID(): v(-1) { }
44 bool operator == (const eTransportStreamID &c) const { return v == c.v; }
45 bool operator != (const eTransportStreamID &c) const { return v != c.v; }
46 bool operator < (const eTransportStreamID &c) const { return v < c.v; }
47 bool operator > (const eTransportStreamID &c) const { return v > c.v; }
50 struct eServiceID
52 private:
53 int v;
54 public:
55 int get() const { return v; }
56 eServiceID(int i): v(i) { }
57 eServiceID(): v(-1) { }
58 bool operator == (const eServiceID &c) const { return v == c.v; }
59 bool operator != (const eServiceID &c) const { return v != c.v; }
60 bool operator < (const eServiceID &c) const { return v < c.v; }
61 bool operator > (const eServiceID &c) const { return v > c.v; }
64 struct eOriginalNetworkID
66 private:
67 int v;
68 public:
69 int get() const { return v; }
70 eOriginalNetworkID(int i): v(i) { }
71 eOriginalNetworkID(): v(-1) { }
72 bool operator == (const eOriginalNetworkID &c) const { return v == c.v; }
73 bool operator != (const eOriginalNetworkID &c) const { return v != c.v; }
74 bool operator < (const eOriginalNetworkID &c) const { return v < c.v; }
75 bool operator > (const eOriginalNetworkID &c) const { return v > c.v; }
78 struct eDVBNamespace
80 private:
81 int v;
82 public:
83 int get() const { return v; }
84 eDVBNamespace(int i): v(i) { }
85 eDVBNamespace(): v(-1) { }
86 bool operator == (const eDVBNamespace &c) const { return v == c.v; }
87 bool operator != (const eDVBNamespace &c) const { return v != c.v; }
88 bool operator < (const eDVBNamespace &c) const { return v < c.v; }
89 bool operator > (const eDVBNamespace &c) const { return v > c.v; }
92 struct tsref
94 eDVBNamespace dvbnamespace;
95 eTransportStreamID tsid;
96 eOriginalNetworkID onid;
97 bool operator<(const tsref &c) const
99 if (dvbnamespace < c.dvbnamespace)
100 return 1;
101 else if (dvbnamespace == c.dvbnamespace)
103 if (onid < c.onid)
104 return 1;
105 else if (onid == c.onid)
106 if (tsid < c.tsid)
107 return 1;
109 return 0;
111 tsref(eDVBNamespace dvbnamespace, eTransportStreamID tsid, eOriginalNetworkID onid):
112 dvbnamespace(dvbnamespace), tsid(tsid), onid(onid)
117 class eTransponder
119 eTransponderList &tplist;
120 // friend struct eTransponder::satellite;
121 public:
122 struct cable
124 int valid;
125 int frequency, symbol_rate;
126 int modulation;
127 int inversion, fec_inner;
128 void set(const CableDeliverySystemDescriptor *descriptor);
129 int tune(eTransponder *);
130 int isValid() { return valid; }
131 bool operator == (const cable &c) const
133 if (valid != c.valid)
134 return 0;
135 if (frequency != c.frequency)
136 return 0;
137 if (symbol_rate != c.symbol_rate)
138 return 0;
139 if (modulation != c.modulation)
140 return 0;
141 if (inversion != c.inversion)
142 return 0;
143 if (fec_inner != c.fec_inner)
144 return 0;
145 return 1;
147 bool operator<(const cable &c) const
149 if ( frequency == c.frequency )
151 if ( symbol_rate == c.symbol_rate )
152 return fec_inner < c.fec_inner;
153 else
154 return symbol_rate < c.symbol_rate;
156 return frequency < c.frequency;
158 } cable;
159 struct satellite
161 int valid;
162 unsigned int frequency, symbol_rate;
163 int polarisation, fec, inversion, orbital_position;
164 void set(const SatelliteDeliverySystemDescriptor *descriptor);
165 int tune(eTransponder *);
166 int isValid() const { return valid; }
167 inline bool useable( eLNB * lnb );
168 eString toString();
169 bool operator == (const satellite &c) const
171 if (valid != c.valid)
172 return 0;
173 // eDebug("frequency %i - %i = %i", frequency, c.frequency, MAXDIFF(frequency,c.frequency) );
174 if ( abs( frequency-c.frequency ) > 3000 )
175 return 0;
176 // eDebug("symbol_rate -> %i != %i", symbol_rate, c.symbol_rate );
177 if ( abs(symbol_rate-c.symbol_rate) > 4000 )
178 return 0;
179 // eDebug("polarisation -> %i != %i", polarisation, c.polarisation );
180 if (polarisation != c.polarisation)
181 return 0;
182 // eDebug("fec -> %i != %i", fec, c.fec );
183 if (fec != c.fec)
184 return 0;
185 // eDebug("inversion -> %i != %i", inversion, c.inversion );
186 // dont compare inversion when one have AUTO
187 if (inversion != 2 && c.inversion != 2 && inversion != c.inversion)
188 return 0;
189 // eDebug("orbital_position -> %i != %i", orbital_position, c.orbital_position);
190 if (abs(orbital_position - c.orbital_position) > 5)
191 return 0;
192 // eDebug("Satellite Data is equal");
193 return 1;
195 bool operator<(const satellite &s) const
197 if ( frequency == s.frequency )
199 if ( symbol_rate == s.symbol_rate )
200 return abs(orbital_position - s.orbital_position) < 6 ? 0
201 : orbital_position < s.orbital_position;
202 else
203 return symbol_rate < s.symbol_rate;
205 return frequency < s.frequency;
207 } satellite;
208 struct terrestrial
210 int valid;
211 int centre_frequency, bandwidth, constellation, hierarchy_information, code_rate_hp, code_rate_lp, guard_interval, transmission_mode, inversion;
212 void set(const TerrestrialDeliverySystemDescriptor *descriptor);
213 int tune(eTransponder *);
214 int isValid() const { return valid; }
215 bool operator == (const terrestrial &t) const
217 if (valid != t.valid)
218 return 0;
219 if (centre_frequency != t.centre_frequency)
220 return 0;
221 if (bandwidth != t.bandwidth)
222 return 0;
223 if (constellation != t.constellation)
224 return 0;
225 if (hierarchy_information != t.hierarchy_information)
226 return 0;
227 if (code_rate_hp != t.code_rate_hp)
228 return 0;
229 if (code_rate_lp != t.code_rate_lp)
230 return 0;
231 if (guard_interval != t.guard_interval)
232 return 0;
233 if (transmission_mode != t.transmission_mode)
234 return 0;
235 if (inversion != 2 && t.inversion != 2 && inversion != t.inversion)
236 return 0;
237 return 1;
239 bool operator<(const terrestrial &t) const
241 return centre_frequency < t.centre_frequency;
243 } terrestrial;
244 eTransponder(eTransponderList &tplist, eDVBNamespace dvbnamespace, eTransportStreamID transport_stream_id, eOriginalNetworkID original_network_id);
245 eTransponder(eTransponderList &tplist);
246 void setSatellite(SatelliteDeliverySystemDescriptor *descr) { satellite.set(descr); }
247 void setCable(CableDeliverySystemDescriptor *descr) { cable.set(descr); }
248 void setTerrestrial(TerrestrialDeliverySystemDescriptor *descr) { terrestrial.set(descr); }
249 void setSatellite(int frequency, int symbol_rate, int polarisation, int fec, int orbital_position, int inversion);
250 void setCable(int frequency, int symbol_rate, int inversion, int modulation, int fec_inner );
251 void setTerrestrial(int centre_frequency, int bandwidth, int constellation, int hierarchy_information, int code_rate_hp, int code_rate_lp, int guard_interval, int transmission_mode, int inversion);
253 eTransponder &operator=(const eTransponder &ref)
255 cable=ref.cable;
256 satellite=ref.satellite;
257 terrestrial=ref.terrestrial;
258 state=ref.state;
259 transport_stream_id=ref.transport_stream_id;
260 original_network_id=ref.original_network_id;
261 dvb_namespace=ref.dvb_namespace;
262 return *this;
264 int tune();
265 int isValid();
267 eDVBNamespace dvb_namespace;
268 eTransportStreamID transport_stream_id;
269 eOriginalNetworkID original_network_id;
271 static eDVBNamespace buildNamespace(eOriginalNetworkID onid, eTransportStreamID tsid, int orbital_position, int freq, int pol);
273 enum
275 stateOK = 1, stateToScan = 2, stateOnlyFree = 4, stateError = 8
277 int state;
279 operator tsref()
281 return tsref(
282 dvb_namespace,
283 transport_stream_id,
284 original_network_id );
287 bool operator==(const eTransponder &c) const
289 // eDebug("onid = %i, c.onid = %i, tsid = %i, c.tsid = %i", original_network_id.get(), transport_stream_id.get(), c.original_network_id.get(), c.transport_stream_id.get() );
290 if ( original_network_id != -1 && c.original_network_id != -1 && transport_stream_id != -1 && c.transport_stream_id != -1)
292 // eDebug("TSID / ONID Vergleich");
293 return ( original_network_id == c.original_network_id &&
294 transport_stream_id == c.transport_stream_id );
296 else
298 if (satellite.valid && c.satellite.valid)
299 return satellite == c.satellite;
300 if (cable.valid && c.cable.valid)
301 return cable == c.cable;
302 if (terrestrial.valid && c.terrestrial.valid)
303 return terrestrial == c.terrestrial;
305 return 1;
308 bool operator<(const eTransponder &c) const
310 if ((original_network_id == -1) && (transport_stream_id == -1))
312 if ((c.original_network_id == -1) && (c.transport_stream_id == -1))
314 if (satellite.valid && c.satellite.valid)
315 return satellite < c.satellite;
316 if (cable.valid && c.cable.valid)
317 return cable < c.cable;
318 if (terrestrial.valid && c.terrestrial.valid)
319 return terrestrial < c.terrestrial;
320 return 1;
322 else
323 return 1;
325 if (original_network_id < c.original_network_id)
326 return 1;
327 else if (original_network_id == c.original_network_id)
328 if (transport_stream_id < c.transport_stream_id)
329 return 1;
330 return 0;
335 class eServiceDVB;
336 class eServiceID3;
338 class eService
340 public:
341 eService(const eString &service_name);
342 virtual ~eService();
344 eString service_name;
346 int dummy; // this was no more used spflags
347 // this dummy is for binary compatibility with already existing(compiled)
348 // enigma plugins..
350 eServiceDVB *dvb;
351 #ifndef DISABLE_FILE
352 eServiceID3 *id3;
353 #endif
356 class eServiceDVB: public eService
358 private:
360 cacheID-Values are only stored where needed (saves memory...)
361 cachevalues[0] contains length of cachevalues (including cachevalues[0])
363 short* cachevalues;
364 void makeCache(short maxCacheID);
366 public:
367 enum cacheID
369 cVPID=0, cAPID, cTPID, cPCRPID, cAC3PID,
370 cVideoType, /* not used in e1.. but in e2 */
371 cStereoMono,
372 cAc3Delay, /* not used in e1.. but in e2 */
373 cPcmDelay, /* not used in e1.. but in e2 */
374 cSubtitle,
375 cTTXSubtitle,
377 please do not simply add any other value to the service cache
378 this breaks binary compatibilty of enigma1 and enigma2 service format
379 (and settings editors)
381 cacheMax
383 eServiceDVB(eDVBNamespace dvb_namespace, eTransportStreamID transport_stream_id, eOriginalNetworkID original_network_id, const SDTEntry *sdtentry, int service_number=-1);
384 eServiceDVB(eDVBNamespace dvb_namespace, eTransportStreamID transport_stream_id, eOriginalNetworkID original_network_id, eServiceID service_id, int service_number=-1);
385 eServiceDVB(eServiceID service_id, const char *name);
386 eServiceDVB(const eServiceDVB &c);
387 virtual ~eServiceDVB() ;
389 void update(const SDTEntry *sdtentry);
391 eDVBNamespace dvb_namespace;
392 eTransportStreamID transport_stream_id;
393 eOriginalNetworkID original_network_id;
394 eServiceID service_id;
395 int service_type;
397 eString service_provider;
399 int service_number; // nur fuer dvb, gleichzeitig sortierkriterium...
401 enum
403 dxNoSDT=1, // don't get SDT
404 dxDontshow=2,
405 dxNoDVB=4,
406 dxHoldName=8,
407 dxNewFound=64 // found in prev scan
409 __u8 dxflags;
412 void set(cacheID c, short v);
414 short get(cacheID c);
416 void clearCache();
418 bool operator<(const eServiceDVB &c) const
420 if (original_network_id < c.original_network_id)
421 return 1;
422 else if (original_network_id == c.original_network_id)
423 if (service_id < c.service_id)
424 return 1;
425 return 0;
429 class eServiceReference
431 public:
432 struct Parental_Compare
434 bool operator()(const eServiceReference &s1, const eServiceReference &s2) const
436 if ( s1.path && s2.path )
437 return s1.path < s2.path;
438 return s1 < s2;
441 private:
442 static std::set<eServiceReference,Parental_Compare> locked;
443 static bool lockedListChanged;
444 public:
445 static void loadLockedList( const char* filename );
446 static void saveLockedList( const char* filename );
447 bool isLocked() const { return locked.find( *this ) != locked.end(); }
448 void lock() const { locked.insert( *this );lockedListChanged=true; }
449 void unlock() const { locked.erase( *this );lockedListChanged=true; }
450 enum
452 idInvalid=-1,
453 idStructure, // service_id == 0 is root
454 idDVB,
455 idFile,
456 idUser=0x1000
458 int type;
460 eString descr;
462 int flags; // flags will NOT be compared.
463 enum
465 isDirectory=1, // SHOULD enter (implies mustDescent)
466 mustDescent=2, // cannot be played directly - often used with "isDirectory" (implies canDescent)
468 for example:
469 normal services have none of them - they can be fed directly into the "play"-handler.
470 normal directories have both of them set - you cannot play a directory directly and the UI should descent into it.
471 playlists have "mustDescent", but not "isDirectory" - you don't want the user to browse inside the playlist (unless he really wants)
472 services with sub-services have none of them, instead the have the "canDecsent" flag (as all of the above)
474 canDescent=4, // supports enterDirectory/leaveDirectory
475 flagDirectory=isDirectory|mustDescent|canDescent,
476 shouldSort=8, // should be ASCII-sorted according to service_name. great for directories.
477 hasSortKey=16, // has a sort key in data[3]. not having a sort key implies 0.
478 sort1=32, // sort key is 1 instead of 0
479 isMarker=64,
480 isNotPlayable=128
483 inline int getSortKey() const { return (flags & hasSortKey) ? data[3] : ((flags & sort1) ? 1 : 0); }
485 int data[8];
486 eString path;
488 eServiceReference()
489 : type(idInvalid), flags(0)
491 memset(data, 0, sizeof(data));
493 eServiceReference(int type, int flags)
494 : type(type), flags(flags)
496 memset(data, 0, sizeof(data));
498 eServiceReference(int type, int flags, int data0)
499 : type(type), flags(flags)
501 memset(data, 0, sizeof(data));
502 data[0]=data0;
504 eServiceReference(int type, int flags, int data0, int data1)
505 : type(type), flags(flags)
507 memset(data, 0, sizeof(data));
508 data[0]=data0;
509 data[1]=data1;
511 eServiceReference(int type, int flags, int data0, int data1, int data2)
512 : type(type), flags(flags)
514 memset(data, 0, sizeof(data));
515 data[0]=data0;
516 data[1]=data1;
517 data[2]=data2;
519 eServiceReference(int type, int flags, int data0, int data1, int data2, int data3)
520 : type(type), flags(flags)
522 memset(data, 0, sizeof(data));
523 data[0]=data0;
524 data[1]=data1;
525 data[2]=data2;
526 data[3]=data3;
528 eServiceReference(int type, int flags, int data0, int data1, int data2, int data3, int data4)
529 : type(type), flags(flags)
531 memset(data, 0, sizeof(data));
532 data[0]=data0;
533 data[1]=data1;
534 data[2]=data2;
535 data[3]=data3;
536 data[4]=data4;
538 eServiceReference(int type, int flags, const eString &path)
539 : type(type), flags(flags), path(path)
541 memset(data, 0, sizeof(data));
543 eServiceReference(const eString &string);
544 eString toString() const;
545 bool operator==(const eServiceReference &c) const
547 if (type != c.type)
548 return 0;
549 if ( type == idDVB && !c.flags && !flags )
550 return (memcmp(data+1, c.data+1, sizeof(int)*7)==0) && (path == c.path);
551 return (memcmp(data, c.data, sizeof(int)*8)==0) && (path == c.path);
553 bool operator!=(const eServiceReference &c) const
555 return !(*this == c);
557 bool operator<(const eServiceReference &c) const
559 if (type < c.type)
560 return 1;
562 if (type > c.type)
563 return 0;
565 int r = type == idDVB && !c.flags && !flags ?
566 memcmp(data+1, c.data+1, sizeof(int)*7) :
567 memcmp(data, c.data, sizeof(int)*8);
569 if (r)
570 return r < 0;
571 return path < c.path;
573 operator bool() const
575 return type != idInvalid;
579 class eServicePath
581 friend struct ePlaylistEntry;
582 std::list<eServiceReference> path;
583 public:
584 bool operator != ( const eServicePath& p ) const
586 return p.path != path;
588 bool operator == ( const eServicePath &p ) const
590 return p.path == path;
592 eServicePath() { }
593 eServicePath( const eString& data );
594 eServicePath(const eServiceReference &ref);
595 void setString( const eString& data );
596 eString toString();
597 bool up();
598 void down(const eServiceReference &ref);
599 eServiceReference current() const;
600 eServiceReference top() const { return current(); }
601 eServiceReference bottom() const;
602 int size() const;
605 struct eServiceReferenceDVB: public eServiceReference
607 int getServiceType() const { return data[0]; }
608 void setServiceType(int service_type) { data[0]=service_type; }
610 eServiceID getServiceID() const { return eServiceID(data[1]); }
611 void setServiceID(eServiceID service_id) { data[1]=service_id.get(); }
613 eTransportStreamID getTransportStreamID() const { return eTransportStreamID(data[2]); }
614 void setTransportStreamID(eTransportStreamID transport_stream_id) { data[2]=transport_stream_id.get(); }
616 eOriginalNetworkID getOriginalNetworkID() const { return eOriginalNetworkID(data[3]); }
617 void setOriginalNetworkID(eOriginalNetworkID original_network_id) { data[3]=original_network_id.get(); }
619 eDVBNamespace getDVBNamespace() const { return eDVBNamespace(data[4]); }
620 void setDVBNamespace(eDVBNamespace dvbnamespace) { data[4]=dvbnamespace.get(); }
622 // I hope this doesn't break anything, but I don't think data[5] is used anywhere else...
623 int getFileLength() const { return data[5]; }
624 void setFileLength(int filelength) { data[5]=filelength; }
626 eServiceReferenceDVB(eDVBNamespace dvbnamespace, eTransportStreamID transport_stream_id, eOriginalNetworkID original_network_id, eServiceID service_id, int service_type)
627 :eServiceReference(eServiceReference::idDVB, 0)
629 setTransportStreamID(transport_stream_id);
630 setOriginalNetworkID(original_network_id);
631 setDVBNamespace(dvbnamespace);
632 setServiceID(service_id);
633 setServiceType(service_type);
636 eServiceReferenceDVB()
641 class eBouquet
643 public:
644 int bouquet_id;
645 eString bouquet_name;
646 std::list<eServiceReferenceDVB> list;
648 inline eBouquet(int bouquet_id, eString& bouquet_name)
649 : bouquet_id(bouquet_id), bouquet_name(bouquet_name)
652 template <class T>
653 void forEachServiceReference(T ob)
655 for (std::list<eServiceReferenceDVB>::iterator it = list.begin(); it != list.end(); ++it )
656 ob(*it);
658 void add(const eServiceReferenceDVB &);
659 int remove(const eServiceReferenceDVB &);
660 bool operator == (const eBouquet &c) const
662 return bouquet_id==c.bouquet_id;
664 bool operator < (const eBouquet &c) const
666 return (bouquet_name.compare(c.bouquet_name));
670 struct eSwitchParameter
672 enum SIG22 { HILO=0, ON=1, OFF=2 }; // 22 Khz
673 enum VMODE { HV=0, _14V=1, _18V=2, _0V=3 }; // 14/18 V
674 VMODE VoltageMode;
675 SIG22 HiLoSignal;
678 class eSatellite
680 eTransponderList &tplist;
681 int orbital_position;
682 eString description;
683 eSwitchParameter switchParams;
684 eLNB *lnb;
685 friend class eLNB;
686 public:
687 eSatellite(eTransponderList &tplist, int orbital_position, eLNB &lnb);
688 ~eSatellite();
690 const eString &getDescription() const
692 return description;
695 void setDescription(const eString &description)
697 this->description=description;
700 int getOrbitalPosition() const
702 return orbital_position;
705 eSwitchParameter &getSwitchParams()
707 return switchParams;
710 eLNB *getLNB() const
712 return lnb;
715 void setLNB( eLNB* _lnb )
717 lnb = _lnb;
720 void setOrbitalPosition(int orbital_position);
722 bool operator<(const eSatellite &sat) const
724 return orbital_position < sat.orbital_position;
727 bool operator==(const eSatellite &sat) const
729 return orbital_position == sat.orbital_position;
733 struct Orbital_Position_Compare
735 inline bool operator()(const int &i1, const int &i2) const
737 return abs(i1-i2) < 6 ? false: i1 < i2;
741 struct eDiSEqC
743 enum { AA=0, AB=1, BA=2, BB=3, SENDNO=4 /* and 0xF0 .. 0xFF*/ }; // DiSEqC Parameter
744 int DiSEqCParam;
746 enum tDiSEqCMode { NONE=0, V1_0=1, V1_1=2, V1_2=3, SMATV=4 }; // DiSEqC Mode
747 tDiSEqCMode DiSEqCMode;
749 enum tMiniDiSEqCParam { NO=0, A=1, B=2 };
750 tMiniDiSEqCParam MiniDiSEqCParam;
752 std::map< int, int, Orbital_Position_Compare > RotorTable; // used for Rotors does not support gotoXX Cmd
753 int DiSEqCRepeats; // for cascaded switches
754 int FastDiSEqC; // send no DiSEqC on H/V or Lo/Hi change
755 int SeqRepeat; // send the complete DiSEqC Sequence twice...
756 int SwapCmds; // swaps the committed & uncommitted cmd
757 int uncommitted_cmd; // state of the 4 uncommitted switches..
758 int useGotoXX; // Rotor Support gotoXX Position ?
759 int useRotorInPower; // can we use Rotor Input Power to detect Rotor state ?
760 enum { NORTH, SOUTH, EAST, WEST };
761 int gotoXXLoDirection; // EAST, WEST
762 int gotoXXLaDirection; // NORT, SOUTH
763 double gotoXXLongitude; // Longitude for gotoXX° Function
764 double gotoXXLatitude; // Latitude for gotoXX° Function
765 void setRotorDefaultOptions(); // set default rotor options
768 class eLNB
770 unsigned int lof_hi, lof_lo, lof_threshold;
771 int increased_voltage, relais_12V_out;
772 ePtrList<eSatellite> satellites;
773 eTransponderList &tplist;
774 eDiSEqC DiSEqC;
775 public:
776 eLNB(eTransponderList &tplist): tplist(tplist)
778 satellites.setAutoDelete(true);
780 void setLOFHi(unsigned int lof_hi) { this->lof_hi=lof_hi; }
781 void setLOFLo(unsigned int lof_lo) { this->lof_lo=lof_lo; }
782 void setLOFThreshold(unsigned int lof_threshold) { this->lof_threshold=lof_threshold; }
783 void setIncreasedVoltage( int inc ) { increased_voltage = inc; }
784 void set12VOut(int state) { relais_12V_out = state; }
785 unsigned int getLOFHi() const { return lof_hi; }
786 unsigned int getLOFLo() const { return lof_lo; }
787 unsigned int getLOFThreshold() const { return lof_threshold; }
788 int getIncreasedVoltage() const { return increased_voltage; }
789 int get12VOut() { return relais_12V_out; }
790 eDiSEqC& getDiSEqC() { return DiSEqC; }
791 eSatellite *addSatellite(int orbital_position);
792 void deleteSatellite(eSatellite *satellite);
793 void addSatellite( eSatellite *satellite);
794 void setDefaultOptions();
795 eSatellite* takeSatellite( eSatellite *satellite);
796 bool operator==(const eLNB& lnb) { return this == &lnb; }
797 ePtrList<eSatellite> &getSatelliteList() { return satellites; }
800 class tpPacket
802 public:
803 bool operator==(const tpPacket& p) const
805 // this do only compare the adresses.. to find a tpPacket
806 // in a std::list<tpPacket>.. but it is fast !!
807 return &possibleTransponders == &p.possibleTransponders;
809 bool operator<(const tpPacket& p) const
811 return orbital_position < p.orbital_position;
813 std::string name;
814 int scanflags;
815 int orbital_position;
816 std::list<eTransponder> possibleTransponders;
819 class existNetworks
821 bool networksLoaded;
822 public:
823 std::list<tpPacket>& getNetworks();
824 std::map<int,tpPacket>& getNetworkNameMap();
825 int reloadNetworks();
826 int saveNetworks();
827 void invalidateNetworks() { networksLoaded=false; }
828 protected:
829 int fetype;
830 existNetworks();
831 std::list<tpPacket> networks;
832 std::map<int, tpPacket> names;
833 int addNetwork(tpPacket &p, XMLTreeNode *node, int type);
836 class eTransponderList: public existNetworks, public Object
838 public:
839 enum { SDT_SCAN_FREE, SDT_SCAN, SDT_SCAN_FINISHED, PAT_SCAN };
840 private:
841 static eTransponderList* instance;
842 std::map<tsref,eTransponder> transponders;
843 std::map<eServiceReferenceDVB,eServiceDVB> services;
844 std::map<eServiceReferenceDVB,eServiceDVB> subservices;
845 std::map<int,eSatellite*> satellites;
846 std::list<eLNB> lnbs;
847 std::map<int,eServiceReferenceDVB> channel_number;
848 friend class eLNB;
849 friend class eSatellite;
851 eServiceReferenceDVB newService;
852 ePtrList<SDTEntry>::const_iterator curSDTEntry;
853 ePtrList<PATEntry>::const_iterator curPATEntry;
854 Signal0<void> *callback;
855 std::set<eServiceID> newServiceIds;
856 std::set<eServiceID> checkedServiceIds;
857 int sdtscanstate;
858 void gotPMT(int);
859 void addService();
860 PMT *pmt; // for only free check
861 void leaveService( const eServiceReferenceDVB& );
862 public:
864 void leaveTransponder( eTransponder* );
865 std::map<tsref,int> TimeOffsetMap;
866 void readTimeOffsetData( const char* filename );
867 void writeTimeOffsetData( const char* filename );
869 void clearAllServices() { services.clear(); }
870 void clearAllSubServices() { subservices.clear(); }
871 void clearAllTransponders() { transponders.clear(); }
872 void removeService( const eServiceReferenceDVB& );
873 void removeOrbitalPosition(int orbital_position);
874 void removeNewFlags(int orbital_position);
876 static eTransponderList* getInstance() { return instance; }
877 eTransponderList();
879 ~eTransponderList()
881 writeLNBData(); // write Data to registry
882 /* newServices->save();
883 eServiceInterface::getInstance()->removeRef(newServicesRef);*/
885 if (instance == this)
886 instance = 0;
889 void readLNBData();
890 void writeLNBData();
892 eTransponder &createTransponder(eDVBNamespace dvb_namespace,eTransportStreamID transport_stream_id, eOriginalNetworkID original_network_id);
893 eServiceDVB &createService(const eServiceReferenceDVB &service, int service_number=-1, bool *newService=0);
894 eServiceDVB &createSubService(const eServiceReferenceDVB &service, bool *newService=0);
895 void startHandleSDT(const SDT *sdt, eDVBNamespace dvb_namespace, eOriginalNetworkID onid=-1, eTransportStreamID tsid=-1, Signal0<void> *callback=0, int sdtscanstate=SDT_SCAN );
896 void handleSDT(const SDT *sdt, eDVBNamespace dvb_namespace, eOriginalNetworkID onid=-1, eTransportStreamID tsid=-1, Signal0<void> *callback=0 );
897 Signal1<void, eTransponder*> transponder_added;
898 Signal2<void, const eServiceReferenceDVB &, bool> service_found;
899 Signal1<void, const eServiceReferenceDVB &> service_removed;
901 eTransponder *searchTransponder(const eTransponder &);
902 eTransponder *searchTS(eDVBNamespace dvbnamespace, eTransportStreamID transport_stream_id, eOriginalNetworkID original_network_id);
903 eServiceDVB *searchService(const eServiceReference &service);
904 eServiceDVB *searchSubService(const eServiceReference &service);
905 eServiceReferenceDVB searchServiceByNumber(int channel_number);
906 int countServices( eDVBNamespace dvbnamespace, eTransportStreamID tsid, eOriginalNetworkID onid )
908 int cnt=0;
909 for ( std::map<eServiceReferenceDVB,eServiceDVB>::iterator it(services.begin());
910 it != services.end(); ++it )
912 if ( it->first.getDVBNamespace() == dvbnamespace &&
913 it->first.getTransportStreamID() == tsid &&
914 it->first.getOriginalNetworkID() == onid )
915 ++cnt;
917 return cnt;
919 void removeTransponder( const tsref ts )
921 transponders.erase(ts);
924 template <class T>
925 void forEachService(T ob)
927 for (std::map<eServiceReferenceDVB,eServiceDVB>::iterator i(services.begin()); i!=services.end(); ++i)
928 ob(i->second);
930 template <class T>
931 void forEachSubService(T ob)
933 for (std::map<eServiceReferenceDVB,eServiceDVB>::iterator i(subservices.begin()); i!=subservices.end(); ++i)
934 ob(i->second);
936 template <class T>
937 void forEachServiceReference(T ob)
939 for (std::map<eServiceReferenceDVB,eServiceDVB>::iterator i(services.begin()); i!=services.end(); ++i)
940 ob(i->first);
942 template <class T> void forEachTransponder(T ob)
944 for (std::map<tsref,eTransponder>::iterator i(transponders.begin()); i!=transponders.end(); ++i)
945 ob(i->second);
947 template <class T> void forEachChannel(T ob)
949 for (std::map<int,eServiceDVB*>::iterator i(channel_number.begin()); i!=channel_number.end(); ++i)
950 ob(*i->second);
953 eTransponder *getFirstTransponder(int state);
954 eSatellite *findSatellite(int orbital_position);
955 std::map< int, eSatellite*>::iterator begin() { return satellites.begin(); }
956 std::map< int, eSatellite*>::iterator end() { return satellites.end(); }
957 std::list<eLNB>& getLNBs() { return lnbs; }
960 inline bool eTransponder::satellite::useable( eLNB * lnb )
962 // normal tuner can tune frequencys from 950 Mhz to 2150 Mhz
963 // do +- 100Mhz
964 if ( frequency > lnb->getLOFThreshold() )
966 int diff = abs(frequency - lnb->getLOFHi());
967 if ( diff > 2250000 || diff < 850000 )
968 return false;
970 else
972 int diff = abs(frequency - lnb->getLOFLo());
973 if ( diff > 2250000 || diff < 850000 )
974 return false;
976 return true;
980 #endif