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 <dvbsi++/program_map_section.h>
10 #include <lib/dvb/idemux.h>
11 #include <lib/dvb/esection.h>
12 #include <lib/dvb/db.h>
16 service(unsigned short pmtPid)
17 :pmtPid(pmtPid), serviceType(0xFF), scrambled(false)
20 unsigned short pmtPid;
21 unsigned char serviceType;
25 class eDVBScan: public Object, public iObject
27 DECLARE_REF(eDVBScan);
28 /* chid helper functions: */
30 /* heuristically determine if onid/tsid is valid */
31 int isValidONIDTSID(int orbital_position, eOriginalNetworkID onid, eTransportStreamID tsid);
32 /* build dvb namespace */
33 eDVBNamespace buildNamespace(eOriginalNetworkID onid, eTransportStreamID tsid, unsigned long hash);
36 eUsePtr<iDVBChannel> m_channel;
37 ePtr<iDVBDemux> m_demux;
40 void stateChange(iDVBChannel *);
41 ePtr<eConnection> m_stateChanged_connection;
47 enum { readyPAT=1, readySDT=2, readyNIT=4, readyBAT=8,
48 validPAT=16, validSDT=32, validNIT=64, validBAT=128};
50 /* scan state variables */
52 int m_ready, m_ready_all;
54 std::map<eDVBChannelID, ePtr<iDVBFrontendParameters> > m_new_channels;
55 std::map<eDVBChannelID, ePyObjectWrapper> m_tuner_data; // data read from tuner for every new channel
57 std::map<eServiceReferenceDVB, ePtr<eDVBService> > m_new_services;
58 std::map<eServiceReferenceDVB, ePtr<eDVBService> >::iterator m_last_service;
60 std::map<unsigned short, service> m_pmts_to_read;
61 std::map<unsigned short, service>::iterator m_pmt_in_progress;
63 bool m_abort_current_pmt;
65 std::list<ePtr<iDVBFrontendParameters> > m_ch_toScan, m_ch_scanned, m_ch_unavailable;
66 ePtr<iDVBFrontendParameters> m_ch_current;
67 eDVBChannelID m_chid_current;
68 eTransportStreamID m_pat_tsid;
70 ePtr<eTable<ServiceDescriptionSection> > m_SDT;
71 ePtr<eTable<NetworkInformationSection> > m_NIT;
72 ePtr<eTable<BouquetAssociationSection> > m_BAT;
73 ePtr<eTable<ProgramAssociationSection> > m_PAT;
74 ePtr<eTable<ProgramMapSection> > m_PMT;
76 void SDTready(int err);
77 void NITready(int err);
78 void BATready(int err);
79 void PATready(int err);
80 void PMTready(int err);
82 void addKnownGoodChannel(const eDVBChannelID &chid, iDVBFrontendParameters *feparm);
83 void addChannelToScan(const eDVBChannelID &chid, iDVBFrontendParameters *feparm);
85 int sameChannel(iDVBFrontendParameters *ch1, iDVBFrontendParameters *ch2, bool exact=false) const;
89 Signal1<void,int> m_event;
90 RESULT processSDT(eDVBNamespace dvbnamespace, const ServiceDescriptionSection &sdt);
95 ePyObject m_additional_tsid_onid_check_func;
96 bool m_show_add_tsid_onid_check_failed_msg;
98 eDVBScan(iDVBChannel *channel, bool usePAT=true, bool debug=true );
102 scanNetworkSearch = 1, scanSearchBAT = 2,
103 scanRemoveServices = 4, scanDontRemoveFeeds = 8,
104 scanDontRemoveUnscanned = 16,
105 clearToScanOnFirstNIT = 32, scanOnlyFree = 64 };
107 void start(const eSmartPtrList<iDVBFrontendParameters> &known_transponders, int flags);
109 enum { evtUpdate, evtNewService, evtFinish, evtFail };
110 RESULT connectEvent(const Slot1<void,int> &event, ePtr<eConnection> &connection);
111 void insertInto(iDVBChannelList *db, bool dontRemoveNewFlags=false);
113 void getStats(int &transponders_done, int &transponders_total, int &services);
114 void getLastServiceName(std::string &name);
115 RESULT getFrontend(ePtr<iDVBFrontend> &);
116 RESULT getCurrentTransponder(ePtr<iDVBFrontendParameters> &);
117 eDVBChannelID getCurrentChannelID() { return m_chid_current; }