rotor turning with measure input power is now working
[enigma2.git] / lib / dvb / scan.h
1 #ifndef __lib_dvb_scan_h
2 #define __lib_dvb_scan_h
3
4 #include <lib/dvb_si/nit.h>
5 #include <lib/dvb_si/sdt.h>
6 #include <lib/dvb_si/bat.h>
7 #include <lib/dvb/idemux.h>
8 #include <lib/dvb/esection.h>
9 #include <lib/dvb/db.h>
10
11 class eDVBScan: public Object, public iObject
12 {
13 DECLARE_REF(eDVBScan);
14 private:
15                 /* chid helper functions: */
16                 
17                 /* heuristically determine if onid/tsid is valid */
18         int isValidONIDTSID(eOriginalNetworkID onid, eTransportStreamID tsid);
19                 /* build dvb namespace */
20         eDVBNamespace buildNamespace(eOriginalNetworkID onid, eTransportStreamID tsid, unsigned long hash);
21         
22                 /* scan resources */    
23         ePtr<iDVBChannel> m_channel;
24         ePtr<iDVBDemux> m_demux;
25         
26                 /* infrastructure */
27         void stateChange(iDVBChannel *);
28         ePtr<eConnection> m_stateChanged_connection;
29
30                 /* state handling */    
31         RESULT nextChannel();
32         
33         RESULT startFilter();   
34         enum { readySDT=1, readyNIT=2, readyBAT=4, readyAll=7,
35                validSDT=8, validNIT=16, validBAT=32};
36
37                 /* scan state variables */
38         int m_channel_state;
39         int m_ready;
40         
41         std::map<eDVBChannelID, ePtr<iDVBFrontendParameters> > m_new_channels;
42         std::map<eServiceReferenceDVB, ePtr<eDVBService> > m_new_services;
43         
44         std::list<ePtr<iDVBFrontendParameters> > m_ch_toScan, m_ch_scanned, m_ch_unavailable;
45         ePtr<iDVBFrontendParameters> m_ch_current;
46         
47         ePtr<eTable<ServiceDescriptionTable> > m_SDT;
48         ePtr<eTable<NetworkInformationTable> > m_NIT;
49         ePtr<eTable<BouquetAssociationTable> > m_BAT;
50         
51         void SDTready(int err);
52         void NITready(int err);
53         void BATready(int err);
54         
55         void addChannel(const eDVBChannelID &chid, iDVBFrontendParameters *feparm);
56         int  sameChannel(iDVBFrontendParameters *ch1, iDVBFrontendParameters *ch2) const;
57         
58         void channelDone();
59         
60         Signal1<void,int> m_event;
61         RESULT processSDT(eDVBNamespace dvbnamespace, const ServiceDescriptionTable &sdt);
62 public:
63         eDVBScan(iDVBChannel *channel);
64         ~eDVBScan();
65         
66         void start(const std::list<ePtr<iDVBFrontendParameters> > &known_transponders);
67
68         enum { evtUpdate, evtFinish, evtFail };
69   RESULT connectEvent(const Slot1<void,int> &event, ePtr<eConnection> &connection);
70         void insertInto(iDVBChannelList *db);
71         
72         void getStats(int &transponders_done, int &transponders_total, int &services);
73 };
74
75 #endif