Merge branch 'bug_623_fix_advanced_diseqc_1.0' into experimental
[enigma2.git] / main / enigma-scan.cpp
1 #include <stdio.h>
2 #include <libsig_comp.h>
3 #include <lib/base/ebase.h>
4 #include <lib/base/eerror.h>
5 #include <lib/base/init.h>
6 #include <lib/base/init_num.h>
7
8 #include <lib/dvb/dvb.h>
9 #include <lib/dvb/db.h>
10 #include <lib/dvb/isection.h>
11 #include <lib/dvb/esection.h>
12 #include <dvbsi++/program_map_section.h>
13 #include <lib/dvb/scan.h>
14 #include <unistd.h>
15
16 class eMain: public eApplication, public Object
17 {
18         eInit init;
19         
20         eDVBScan *m_scan;
21
22         ePtr<eDVBResourceManager> m_mgr;
23         ePtr<iDVBChannel> m_channel;
24         ePtr<eDVBDB> m_dvbdb;
25
26         void scanEvent(int evt)
27         {
28                 eDebug("scan event %d!", evt);
29                 if (evt == eDVBScan::evtFinish)
30                 {
31                         m_scan->insertInto(m_dvbdb);
32                         quit(0);
33                 }
34         }
35         ePtr<eConnection> m_scan_event_connection;
36 public:
37         eMain()
38         {
39                 m_dvbdb = new eDVBDB();
40                 m_mgr = new eDVBResourceManager();
41
42                 eDVBFrontendParametersSatellite fesat;
43                 
44                 fesat.frequency = 11817000; // 12070000;
45                 fesat.symbol_rate = 27500000;
46                 fesat.polarisation = eDVBFrontendParametersSatellite::Polarisation_Vertical;
47                 fesat.fec = eDVBFrontendParametersSatellite::FEC_3_4;
48                 fesat.inversion = eDVBFrontendParametersSatellite::Inversion_Off;
49                 fesat.orbital_position = 192;
50
51                 eDVBFrontendParameters *fe = new eDVBFrontendParameters();
52                 
53                 fe->setDVBS(fesat);
54
55                 if (m_mgr->allocateRawChannel(m_channel))
56                         eDebug("shit it failed!");
57
58 //              init.setRunlevel(eAutoInitNumbers::main);
59                 eDebug("starting scan...");
60                 
61                 std::list<ePtr<iDVBFrontendParameters> > list;
62                 
63                 list.push_back(fe);
64                 
65                 m_scan = new eDVBScan(m_channel);
66                 m_scan->start(list);
67                 
68                 m_scan->connectEvent(slot(*this, &eMain::scanEvent), m_scan_event_connection);
69         }
70         
71         ~eMain()
72         {
73                 delete m_scan;
74                 eDebug("... nicht mehr.");
75         }
76 };
77
78 #ifdef OBJECT_DEBUG
79 int object_total_remaining;
80
81 void object_dump()
82 {
83         printf("%d items left\n", object_total_remaining);
84 }
85 #endif
86
87 int main()
88 {       
89 #ifdef OBJECT_DEBUG
90         atexit(object_dump);
91 #endif
92         eMain app;
93         return app.exec();
94 }