aboutsummaryrefslogtreecommitdiff
path: root/main/enigma-dvbtest.cpp
blob: 1eaedb769e12636b923a948e158ec974ea553f36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#include <stdio.h>
#include <libsig_comp.h>
#include <lib/base/ebase.h>
#include <lib/base/eerror.h>

#include <lib/dvb/dvb.h>
#include <lib/dvb/db.h>
#include <lib/dvb/isection.h>
#include <lib/dvb/esection.h>
#include <dvbsi++/program_map_section.h>
#include <lib/dvb/specs.h>
#include <unistd.h>

class eMain: public eApplication, public Object
{
	ePtr<eDVBResourceManager> m_mgr;
	ePtr<iDVBChannel> m_channel;
	ePtr<iDVBDemux> m_demux;
	eAUTable<eTable<ProgramMapSection> > m_table;
	
	ePtr<eDVBDB> m_dvbdb;
	
	ePtr<eConnection> m_state_change_connection;
	int m_last_channel_state;
public:
	eMain()
	{
		eDebug("mich gibts nu!");
		
			/* Resourcemanager erstellen */
		m_mgr = new eDVBResourceManager();
	
		/* Dummy DVB-Channellist anlegen.. */
			
			/* Datenbank erstellen */
		m_dvbdb = new eDVBDB();
			/* als Primary datenbank setzen */
		m_mgr->setChannelList(m_dvbdb);
		
			/* testtransponder adden */
		eDVBChannelID chid(1,2,3);
		
			/* frontenddaten... */
		eDVBFrontendParametersSatellite fesat;
		
		fesat.frequency = 12070000;
		fesat.symbol_rate = 27500000;
		fesat.polarisation = eDVBFrontendParametersSatellite::Polarisation_Horizontal;
		fesat.fec = eDVBFrontendParametersSatellite::FEC_3_4;
		fesat.inversion = eDVBFrontendParametersSatellite::Inversion_Off;
		fesat.orbital_position = 192;

		eDVBFrontendParameters *fe = new eDVBFrontendParameters();
		
		fe->setDVBS(fesat);
			/* Zur Kanalliste hinzufuegen.. */
		m_dvbdb->addChannelToList(chid, fe);
		
			/* Channel allokieren... tunen startet hier, sofern noetig */
		if (m_mgr->allocateChannel(chid, m_channel))
			eDebug("shit it failed!");
		
		if (m_channel)
		{
				/* Auf State-Change listenen */
			m_channel->connectStateChange(slot(*this, &eMain::channelStateChanged), m_state_change_connection);
				/* Initial provozieren */
			channelStateChanged(m_channel);
		}
	}
	
	void channelStateChanged(iDVBChannel *channel)
	{
		int state;
			/* Channelstate holen */
		channel->getState(state);
		eDebug("channel state is now %d", state);
		
			/* Wenn Wechsel von nicht-ok auf ok (das erste mal) */
		if ((m_last_channel_state != iDVBChannel::state_ok)
			 && (state == iDVBChannel::state_ok) && (!m_demux))
		{
			eDebug("we'll start tuning!");
				/* Demux holen */
			if (m_channel)
				if (m_channel->getDemux(m_demux))
					eDebug("shit it failed.. again.");
		
			if (m_demux)
			{
					/* auf table ready connecten */
				CONNECT(m_table.tableReady, eMain::tableReady);
					/* und section lesen beginnen */
				m_table.begin(this, eDVBPMTSpec(0x20, 0x33f6), m_demux);
			}
		}
		
		m_last_channel_state = state;
	}
	
	void tableReady(int)
	{
			/* table "fertig" (wie auch immer) */
		ePtr<eTable<ProgramMapSection> > ptr;
				/* erfolgreich? */
		if (!m_table.getCurrent(ptr))
		{
				/* dumpen ... */
			ProgramMapSectionConstIterator i;
			for (i = ptr->getSections().begin(); i != ptr->getSections().end(); ++i)
			{
				const ProgramMapSection &pmt = **i;
				eDebug("pcr pid: %x", pmt.getPcrPid());
			}
			eDebug("program map ...");
				/* und raus */
			quit(0);
		}
		eDebug("table ready.");
	}
	
	~eMain()
	{
		eDebug("... nicht mehr.");
	}
};

#ifdef OBJECT_DEBUG
int object_total_remaining;

void object_dump()
{
	printf("%d items left\n", object_total_remaining);
}
#endif

int main()
{	
#ifdef OBJECT_DEBUG
	atexit(object_dump);
#endif
	eMain app;
	return app.exec();
}