don't keep unused references
[enigma2.git] / lib / dvb / dvbtime.h
1 #ifndef __LIB_DVB_DVBTIME_H_
2 #define __LIB_DVB_DVBTIME_H_
3
4 #ifndef SWIG
5
6 #include <lib/base/eerror.h>
7 #include <lib/dvb/esection.h>
8 #include <dvbsi++/time_date_section.h>
9
10 class eDVBChannel;
11
12 inline int fromBCD(int bcd)
13 {
14         if ((bcd&0xF0)>=0xA0)
15                 return -1;
16         if ((bcd&0xF)>=0xA)
17                 return -1;
18         return ((bcd&0xF0)>>4)*10+(bcd&0xF);
19 }
20
21 time_t parseDVBtime(__u8 t1, __u8 t2, __u8 t3, __u8 t4, __u8 t5);
22
23 class TDT: public eGTable
24 {
25         eDVBChannel *chan;
26         ePtr<iDVBDemux> demux;
27         eTimer m_interval_timer;
28         int createTable(int nr, const __u8 *data, unsigned int max);
29         void ready(int);
30         int update_count;
31 public:
32         TDT(eDVBChannel *chan, int update_count=0);
33         void start();
34         void startTimer(int interval);
35         int getUpdateCount() { return update_count; }
36 };
37
38 #endif  // SWIG
39
40 class eDVBLocalTimeHandler: public Object
41 {
42         struct channel_data
43         {
44                 TDT *tdt;
45                 ePtr<eDVBChannel> channel;
46                 ePtr<eConnection> m_stateChangedConn;
47                 int m_prevChannelState;
48         };
49         friend class TDT;
50         DECLARE_REF(eDVBLocalTimeHandler)
51         std::map<iDVBChannel*, channel_data> m_knownChannels;
52         std::map<eDVBChannelID,int> m_timeOffsetMap;
53         ePtr<eConnection> m_chanAddedConn;
54         bool m_time_ready;
55         int m_time_difference;
56         int m_last_tp_time_difference;
57         void DVBChannelAdded(eDVBChannel*);
58         void DVBChannelStateChanged(iDVBChannel*);
59         void readTimeOffsetData(const char*);
60         void writeTimeOffsetData(const char*);
61         void updateTime(time_t tp_time, eDVBChannel*, int updateCount);
62         static eDVBLocalTimeHandler *instance;
63 #ifdef SWIG
64         eDVBLocalTimeHandler();
65         ~eDVBLocalTimeHandler();
66 #endif
67 public:
68 #ifndef SWIG
69         PSignal0<void> m_timeUpdated;
70         eDVBLocalTimeHandler();
71         ~eDVBLocalTimeHandler();
72 #endif
73         time_t nowTime() const { return m_time_ready ? ::time(0)+m_time_difference : -1; }
74         bool ready() const { return m_time_ready; }
75         int difference() const { return m_time_difference; }
76         static eDVBLocalTimeHandler *getInstance() { return instance; }
77 };
78
79 #endif // __LIB_DVB_DVBTIME_H_