4 #include <lib/dvb/idemux.h>
7 #define TABLE_eDebug(x...) do { if (m_debug) eDebug(x); } while(0)
8 #define TABLE_eDebugNoNewLine(x...) do { if (m_debug) eDebugNoNewLine(x); } while(0)
10 class eGTable: public iObject, public Object
13 ePtr<iDVBSectionReader> m_reader;
14 eDVBTableSpec m_table;
20 void sectionRead(const __u8 *data);
22 ePtr<eConnection> m_sectionRead_conn;
25 virtual int createTable(unsigned int nr, const __u8 *data, unsigned int max)=0;
27 Signal1<void, int> tableReady;
28 eGTable(bool debug=true);
29 RESULT start(iDVBSectionReader *reader, const eDVBTableSpec &table);
30 RESULT start(iDVBDemux *reader, const eDVBTableSpec &table);
31 RESULT getSpec(eDVBTableSpec &spec) { spec = m_table; return 0; }
37 template <class Section>
38 class eTable: public eGTable
41 std::vector<Section*> sections;
44 int createTable(unsigned int nr, const __u8 *data, unsigned int max)
46 unsigned int ssize = sections.size();
47 if (max < ssize || nr >= max)
49 TABLE_eDebug("kaputt max(%d) < ssize(%d) || nr(%d) >= max(%d)",
53 if (avail.find(nr) != avail.end())
57 sections[nr] = new Section(data);
60 for (unsigned int i = 0; i < max; ++i)
61 if (avail.find(i) != avail.end())
62 TABLE_eDebugNoNewLine("+");
64 TABLE_eDebugNoNewLine("-");
66 TABLE_eDebug(" %d/%d TID %02x", avail.size(), max, data[0]);
68 if (avail.size() == max)
70 TABLE_eDebug("done!");
76 std::vector<Section*> &getSections() { return sections; }
77 eTable(bool debug=true): eGTable(debug)
82 for (std::set<int>::iterator i(avail.begin()); i != avail.end(); ++i)
87 class eAUGTable: public Object
90 void slotTableReady(int);
92 Signal1<void, int> tableReady;
93 virtual void getNext(int err)=0;
96 template <class Table>
97 class eAUTable: public eAUGTable
99 ePtr<Table> current, next; // current is READY AND ERRORFREE, next is not yet ready
101 ePtr<iDVBDemux> m_demux;
120 int begin(eMainloop *m, const eDVBTableSpec &spec, ePtr<iDVBDemux> demux)
127 CONNECT(next->tableReady, eAUTable::slotTableReady);
128 next->start(demux, spec);
136 /*emit*/ tableReady(0);
140 /*emit*/ tableReady(-1);
146 RESULT getCurrent(ePtr<Table> &ptr)
157 eDebug("eAUTable: aborted!");
170 void inject(Table *t)
176 void getNext(int error)
183 /*emit*/ tableReady(error);
192 assert(current->ready);
194 /*emit*/ tableReady(0);
198 if (current && (!current->getSpec(spec)))
201 CONNECT(next->tableReady, eAUTable::slotTableReady);
202 spec.flags &= ~(eDVBTableSpec::tfAnyVersion|eDVBTableSpec::tfThisVersion|eDVBTableSpec::tfHaveTimeout);
203 next->eGTable::start(m_demux, spec);