4fdb6984beefe5a51ba7fad3e8bb49d56679775d
[vuplus_dvbapp] / 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                 m_mgr = new eDVBResourceManager();
31                 
32                 m_dvbdb = new eDVBDB();
33                 m_mgr->setChannelList(m_dvbdb);
34                 
35                 eDVBChannelID chid(1,2,3);
36                 
37                 eDVBFrontendParametersSatellite fesat;
38                 
39                 fesat.frequency = 12070000;
40                 fesat.symbol_rate = 27500000;
41                 fesat.polarisation = eDVBFrontendParametersSatellite::Polarisation::Horizontal;
42                 fesat.fec = eDVBFrontendParametersSatellite::FEC::f3_4;
43                 fesat.inversion = eDVBFrontendParametersSatellite::Inversion::Off;
44                 fesat.orbital_position = 192;
45
46                 eDVBFrontendParameters *fe = new eDVBFrontendParameters();
47                 
48                 fe->setDVBS(fesat);
49                 
50                 m_dvbdb->addChannelToList(chid, fe);
51                 
52                 if (m_mgr->allocateChannel(chid, m_channel))
53                         eDebug("shit it failed!");
54                 
55                 if (m_channel)
56                 {
57                         m_channel->connectStateChange(slot(*this, &eMain::channelStateChanged), m_state_change_connection);
58                         channelStateChanged(m_channel);
59                 }
60         }
61         
62         void channelStateChanged(iDVBChannel *channel)
63         {
64                 int state;
65                 channel->getState(state);
66                 eDebug("channel state is now %d", state);
67                 
68                 if ((m_last_channel_state != iDVBChannel::state_ok)
69                          && (state == iDVBChannel::state_ok) && (!m_demux))
70                 {
71                         eDebug("we'll start tuning!");
72                         if (m_channel)
73                                 if (m_channel->getDemux(m_demux))
74                                         eDebug("shit it failed.. again.");
75                 
76                         if (m_demux)
77                         {
78                                 CONNECT(m_table.tableReady, eMain::tableReady);
79                                 m_table.begin(this, eDVBPMTSpec(0x20, 0x33f6), m_demux);
80                         }
81                 }
82                 
83                 m_last_channel_state = state;
84         }
85         
86         void tableReady(int)
87         {
88                 ePtr<eTable<ProgramMapTable> > ptr;
89                 if (!m_table.getCurrent(ptr))
90                 {
91                         ProgramMapTableConstIterator i;
92                         for (i = ptr->getSections().begin(); i != ptr->getSections().end(); ++i)
93                         {
94                                 const ProgramMapTable &pmt = **i;
95                                 eDebug("pcr pid: %x", pmt.getPcrPid());
96                         }
97                         eDebug("program map ...");
98                         quit(0);
99                 }
100                 eDebug("table ready.");
101         }
102         
103         ~eMain()
104         {
105                 eDebug("... nicht mehr.");
106         }
107 };
108
109 #ifdef OBJECT_DEBUG
110 int object_total_remaining;
111
112 void object_dump()
113 {
114         printf("%d items left\n", object_total_remaining);
115 }
116 #endif
117
118 int main()
119 {       
120 #ifdef OBJECT_DEBUG
121         atexit(object_dump);
122 #endif
123         eMain app;
124         return app.exec();
125 }