1 #ifndef __lib_dvb_scan_h
2 #define __lib_dvb_scan_h
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>
12 class eDVBScan: public Object, public iObject
14 DECLARE_REF(eDVBScan);
16 /* chid helper functions: */
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);
24 eUsePtr<iDVBChannel> m_channel;
25 ePtr<iDVBDemux> m_demux;
28 void stateChange(iDVBChannel *);
29 ePtr<eConnection> m_stateChanged_connection;
35 enum { readyPAT=1, readySDT=2, readyNIT=4, readyBAT=8,
36 validPAT=16, validSDT=32, validNIT=64, validBAT=128};
38 /* scan state variables */
40 int m_ready, m_ready_all;
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;
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;
50 ePtr<eTable<ServiceDescriptionSection> > m_SDT;
51 ePtr<eTable<NetworkInformationSection> > m_NIT;
52 ePtr<eTable<BouquetAssociationSection> > m_BAT;
53 ePtr<eTable<ProgramAssociationSection> > m_PAT;
55 void SDTready(int err);
56 void NITready(int err);
57 void BATready(int err);
58 void PATready(int err);
60 void addKnownGoodChannel(const eDVBChannelID &chid, iDVBFrontendParameters *feparm);
61 void addChannelToScan(const eDVBChannelID &chid, iDVBFrontendParameters *feparm);
63 int sameChannel(iDVBFrontendParameters *ch1, iDVBFrontendParameters *ch2, bool exact=false) const;
67 Signal1<void,int> m_event;
68 RESULT processSDT(eDVBNamespace dvbnamespace, const ServiceDescriptionSection &sdt);
73 eDVBScan(iDVBChannel *channel, bool usePAT=true, bool debug=true );
77 scanNetworkSearch = 1, scanSearchBAT = 2,
78 scanRemoveServices = 4, scanDontRemoveFeeds = 8,
79 clearToScanOnFirstNIT = 16 };
81 void start(const eSmartPtrList<iDVBFrontendParameters> &known_transponders, int flags);
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);
87 void getStats(int &transponders_done, int &transponders_total, int &services);
88 void getLastServiceName(std::string &name);