fix spaces
[enigma2.git] / lib / dvb / scan.h
1 #ifndef __lib_dvb_scan_h
2 #define __lib_dvb_scan_h
3
4 #include <dvbsi++/network_information_section.h>
5 #include <dvbsi++/service_description_section.h>
6 #include <dvbsi++/bouquet_association_section.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         eUsePtr<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         eDVBChannelID m_chid_current;
47         
48         ePtr<eTable<ServiceDescriptionSection> > m_SDT;
49         ePtr<eTable<NetworkInformationSection> > m_NIT;
50         ePtr<eTable<BouquetAssociationSection> > m_BAT;
51         
52         void SDTready(int err);
53         void NITready(int err);
54         void BATready(int err);
55         
56         void addKnownGoodChannel(const eDVBChannelID &chid, iDVBFrontendParameters *feparm);
57         void addChannelToScan(const eDVBChannelID &chid, iDVBFrontendParameters *feparm);
58         int  sameChannel(iDVBFrontendParameters *ch1, iDVBFrontendParameters *ch2) const;
59         
60         void channelDone();
61         
62         Signal1<void,int> m_event;
63         RESULT processSDT(eDVBNamespace dvbnamespace, const ServiceDescriptionSection &sdt);
64 public:
65         eDVBScan(iDVBChannel *channel);
66         ~eDVBScan();
67         
68         void start(const std::list<ePtr<iDVBFrontendParameters> > &known_transponders);
69
70         enum { evtUpdate, evtFinish, evtFail };
71   RESULT connectEvent(const Slot1<void,int> &event, ePtr<eConnection> &connection);
72         void insertInto(iDVBChannelList *db);
73         
74         void getStats(int &transponders_done, int &transponders_total, int &services);
75 };
76
77 #endif