added setup screens
[enigma2.git] / main / enigma-dvbtest.cpp
1 #include <stdio.h>
2 #include <libsig_comp.h>
3 #include <lib/base/ebase.h>
4 #include <lib/base/eerror.h>
5
6 #include <lib/dvb/dvb.h>
7 #include <lib/dvb/db.h>
8 #include <lib/dvb/isection.h>
9 #include <lib/dvb/esection.h>
10 #include <lib/dvb_si/pmt.h>
11 #include <lib/dvb/specs.h>
12 #include <unistd.h>
13
14 class eMain: public eApplication, public Object
15 {
16         ePtr<eDVBResourceManager> m_mgr;
17         ePtr<iDVBChannel> m_channel;
18         ePtr<iDVBDemux> m_demux;
19         eAUTable<eTable<ProgramMapTable> > m_table;
20         
21         ePtr<eDVBDB> m_dvbdb;
22         
23         ePtr<eConnection> m_state_change_connection;
24         int m_last_channel_state;
25 public:
26         eMain()
27         {
28                 eDebug("mich gibts nu!");
29                 
30                         /* Resourcemanager erstellen */
31                 m_mgr = new eDVBResourceManager();
32         
33                 /* Dummy DVB-Channellist anlegen.. */
34                         
35                         /* Datenbank erstellen */
36                 m_dvbdb = new eDVBDB();
37                         /* als Primary datenbank setzen */
38                 m_mgr->setChannelList(m_dvbdb);
39                 
40                         /* testtransponder adden */
41                 eDVBChannelID chid(1,2,3);
42                 
43                         /* frontenddaten... */
44                 eDVBFrontendParametersSatellite fesat;
45                 
46                 fesat.frequency = 12070000;
47                 fesat.symbol_rate = 27500000;
48                 fesat.polarisation = eDVBFrontendParametersSatellite::Polarisation::Horizontal;
49                 fesat.fec = eDVBFrontendParametersSatellite::FEC::f3_4;
50                 fesat.inversion = eDVBFrontendParametersSatellite::Inversion::Off;
51                 fesat.orbital_position = 192;
52
53                 eDVBFrontendParameters *fe = new eDVBFrontendParameters();
54                 
55                 fe->setDVBS(fesat);
56                         /* Zur Kanalliste hinzufuegen.. */
57                 m_dvbdb->addChannelToList(chid, fe);
58                 
59                         /* Channel allokieren... tunen startet hier, sofern noetig */
60                 if (m_mgr->allocateChannel(chid, m_channel))
61                         eDebug("shit it failed!");
62                 
63                 if (m_channel)
64                 {
65                                 /* Auf State-Change listenen */
66                         m_channel->connectStateChange(slot(*this, &eMain::channelStateChanged), m_state_change_connection);
67                                 /* Initial provozieren */
68                         channelStateChanged(m_channel);
69                 }
70         }
71         
72         void channelStateChanged(iDVBChannel *channel)
73         {
74                 int state;
75                         /* Channelstate holen */
76                 channel->getState(state);
77                 eDebug("channel state is now %d", state);
78                 
79                         /* Wenn Wechsel von nicht-ok auf ok (das erste mal) */
80                 if ((m_last_channel_state != iDVBChannel::state_ok)
81                          && (state == iDVBChannel::state_ok) && (!m_demux))
82                 {
83                         eDebug("we'll start tuning!");
84                                 /* Demux holen */
85                         if (m_channel)
86                                 if (m_channel->getDemux(m_demux))
87                                         eDebug("shit it failed.. again.");
88                 
89                         if (m_demux)
90                         {
91                                         /* auf table ready connecten */
92                                 CONNECT(m_table.tableReady, eMain::tableReady);
93                                         /* und section lesen beginnen */
94                                 m_table.begin(this, eDVBPMTSpec(0x20, 0x33f6), m_demux);
95                         }
96                 }
97                 
98                 m_last_channel_state = state;
99         }
100         
101         void tableReady(int)
102         {
103                         /* table "fertig" (wie auch immer) */
104                 ePtr<eTable<ProgramMapTable> > ptr;
105                                 /* erfolgreich? */
106                 if (!m_table.getCurrent(ptr))
107                 {
108                                 /* dumpen ... */
109                         ProgramMapTableConstIterator i;
110                         for (i = ptr->getSections().begin(); i != ptr->getSections().end(); ++i)
111                         {
112                                 const ProgramMapTable &pmt = **i;
113                                 eDebug("pcr pid: %x", pmt.getPcrPid());
114                         }
115                         eDebug("program map ...");
116                                 /* und raus */
117                         quit(0);
118                 }
119                 eDebug("table ready.");
120         }
121         
122         ~eMain()
123         {
124                 eDebug("... nicht mehr.");
125         }
126 };
127
128 #ifdef OBJECT_DEBUG
129 int object_total_remaining;
130
131 void object_dump()
132 {
133         printf("%d items left\n", object_total_remaining);
134 }
135 #endif
136
137 int main()
138 {       
139 #ifdef OBJECT_DEBUG
140         atexit(object_dump);
141 #endif
142         eMain app;
143         return app.exec();
144 }