1 #include <lib/dvb/dvb.h>
2 #include <lib/dvb/db.h>
3 #include <lib/components/scan.h>
4 #include <lib/base/eerror.h>
5 #include <lib/dvb/scan.h>
7 DEFINE_REF(eComponentScan);
9 void eComponentScan::scanEvent(int evt)
11 // eDebug("scan event %d!", evt);
15 case eDVBScan::evtFinish:
18 ePtr<iDVBChannelList> db;
19 ePtr<eDVBResourceManager> res;
22 if ((err = eDVBResourceManager::getInstance(res)) != 0)
24 eDebug("no resource manager");
26 } else if ((err = res->getChannelList(db)) != 0)
29 eDebug("no channel list");
32 m_scan->insertInto(db);
38 case eDVBScan::evtNewService:
41 case eDVBScan::evtFail:
42 eDebug("scan failed.");
46 case eDVBScan::evtUpdate:
52 eComponentScan::eComponentScan(): m_done(-1), m_failed(0)
56 eComponentScan::~eComponentScan()
60 void eComponentScan::clear()
65 void eComponentScan::addInitial(const eDVBFrontendParametersSatellite &p)
67 ePtr<eDVBFrontendParameters> parm = new eDVBFrontendParameters();
69 m_initial.push_back(parm);
72 void eComponentScan::addInitial(const eDVBFrontendParametersCable &p)
74 ePtr<eDVBFrontendParameters> parm = new eDVBFrontendParameters();
76 m_initial.push_back(parm);
79 void eComponentScan::addInitial(const eDVBFrontendParametersTerrestrial &p)
81 ePtr<eDVBFrontendParameters> parm = new eDVBFrontendParameters();
83 m_initial.push_back(parm);
87 int eComponentScan::start(int feid, int flags)
89 if (m_initial.empty())
96 ePtr<eDVBResourceManager> mgr;
98 eDVBResourceManager::getInstance(mgr);
100 eUsePtr<iDVBChannel> channel;
102 if (mgr->allocateRawChannel(channel, feid))
104 eDebug("scan: allocating raw channel (on frontend %d) failed!", feid);
108 std::list<ePtr<iDVBFrontendParameters> > list;
109 m_scan = new eDVBScan(channel);
110 m_scan->connectEvent(slot(*this, &eComponentScan::scanEvent), m_scan_event_connection);
112 if (!(flags & scanRemoveServices))
114 ePtr<iDVBChannelList> db;
115 ePtr<eDVBResourceManager> res;
117 if ((err = eDVBResourceManager::getInstance(res)) != 0)
118 eDebug("no resource manager");
119 else if ((err = res->getChannelList(db)) != 0)
120 eDebug("no channel list");
123 if (m_initial.size() > 1)
125 ePtr<iDVBFrontendParameters> tp = m_initial.first();
127 if (tp && !tp->getSystem(type))
131 case iDVBFrontend::feSatellite:
133 eDVBFrontendParametersSatellite parm;
135 db->removeFlags(eDVBService::dxNewFound, -1, -1, -1, parm.orbital_position);
138 case iDVBFrontend::feCable:
139 db->removeFlags(eDVBService::dxNewFound, 0xFFFF0000, -1, -1, -1);
141 case iDVBFrontend::feTerrestrial:
142 db->removeFlags(eDVBService::dxNewFound, 0xEEEE0000, -1, -1, -1);
149 m_scan->start(m_initial, flags);
154 int eComponentScan::getProgress()
158 int done, total, services;
159 m_scan->getStats(done, total, services);
162 return done * 100 / total;
165 int eComponentScan::getNumServices()
169 int done, total, services;
170 m_scan->getStats(done, total, services);
174 int eComponentScan::isDone()
179 int eComponentScan::getError()
184 void eComponentScan::getLastServiceName(std::string &string)
188 m_scan->getLastServiceName(string);
191 RESULT eComponentScan::getFrontend(ePtr<iDVBFrontend> &fe)
194 return m_scan->getFrontend(fe);
199 RESULT eComponentScan::getCurrentTransponder(ePtr<iDVBFrontendParameters> &tp)
202 return m_scan->getCurrentTransponder(tp);