show more information in service scan (needs additional changes in skin)
[enigma2.git] / lib / dvb / scan.h
1 #ifndef __lib_dvb_scan_h
2 #define __lib_dvb_scan_h
3
4 #include <dvbsi++/service_description_section.h>
5 #include <dvbsi++/network_information_section.h>
6 #include <dvbsi++/bouquet_association_section.h>
7 #include <dvbsi++/program_association_section.h>
8 #include <lib/dvb/idemux.h>
9 #include <lib/dvb/esection.h>
10 #include <lib/dvb/db.h>
11
12 class eDVBScan: public Object, public iObject
13 {
14 DECLARE_REF(eDVBScan);
15 private:
16                 /* chid helper functions: */
17                 
18                 /* heuristically determine if onid/tsid is valid */
19         int isValidONIDTSID(int orbital_position, eOriginalNetworkID onid, eTransportStreamID tsid);
20                 /* build dvb namespace */
21         eDVBNamespace buildNamespace(eOriginalNetworkID onid, eTransportStreamID tsid, unsigned long hash);
22         
23                 /* scan resources */    
24         eUsePtr<iDVBChannel> m_channel;
25         ePtr<iDVBDemux> m_demux;
26         
27                 /* infrastructure */
28         void stateChange(iDVBChannel *);
29         ePtr<eConnection> m_stateChanged_connection;
30
31                 /* state handling */    
32         RESULT nextChannel();
33         
34         RESULT startFilter();   
35         enum { readyPAT=1, readySDT=2, readyNIT=4, readyBAT=8,
36                validPAT=16, validSDT=32, validNIT=64, validBAT=128};
37
38                 /* scan state variables */
39         int m_channel_state;
40         int m_ready, m_ready_all;
41         
42         std::map<eDVBChannelID, ePtr<iDVBFrontendParameters> > m_new_channels;
43         std::map<eServiceReferenceDVB, ePtr<eDVBService> > m_new_services;
44         std::map<eServiceReferenceDVB, ePtr<eDVBService> >::iterator m_last_service;
45         
46         std::list<ePtr<iDVBFrontendParameters> > m_ch_toScan, m_ch_scanned, m_ch_unavailable;
47         ePtr<iDVBFrontendParameters> m_ch_current;
48         eDVBChannelID m_chid_current;
49         
50         ePtr<eTable<ServiceDescriptionSection> > m_SDT;
51         ePtr<eTable<NetworkInformationSection> > m_NIT;
52         ePtr<eTable<BouquetAssociationSection> > m_BAT;
53         ePtr<eTable<ProgramAssociationSection> > m_PAT;
54                 
55         void SDTready(int err);
56         void NITready(int err);
57         void BATready(int err);
58         void PATready(int err);
59                 
60         void addKnownGoodChannel(const eDVBChannelID &chid, iDVBFrontendParameters *feparm);
61         void addChannelToScan(const eDVBChannelID &chid, iDVBFrontendParameters *feparm);
62
63         int sameChannel(iDVBFrontendParameters *ch1, iDVBFrontendParameters *ch2, bool exact=false) const;
64
65         void channelDone();
66         
67         Signal1<void,int> m_event;
68         RESULT processSDT(eDVBNamespace dvbnamespace, const ServiceDescriptionSection &sdt);
69         
70         int m_flags;
71         bool m_usePAT;
72 public:
73         eDVBScan(iDVBChannel *channel, bool usePAT=true, bool debug=true );
74         ~eDVBScan();
75
76         enum {
77                 scanNetworkSearch = 1, scanSearchBAT = 2,
78                 scanRemoveServices = 4, scanDontRemoveFeeds = 8,
79                 clearToScanOnFirstNIT = 16 };
80
81         void start(const eSmartPtrList<iDVBFrontendParameters> &known_transponders, int flags);
82
83         enum { evtUpdate, evtNewService, evtFinish, evtFail };
84         RESULT connectEvent(const Slot1<void,int> &event, ePtr<eConnection> &connection);
85         void insertInto(iDVBChannelList *db, bool dontRemoveNewFlags=false);
86         
87         void getStats(int &transponders_done, int &transponders_total, int &services);
88         void getLastServiceName(std::string &name);
89         RESULT getFrontend(ePtr<iDVBFrontend> &);
90         RESULT getCurrentTransponder(ePtr<iDVBFrontendParameters> &);
91 };
92
93 #endif