7 #include <linux/dvb/dmx.h>
10 #include <lib/base/eerror.h>
11 #include <lib/dvb/idvb.h>
12 #include <lib/dvb/demux.h>
13 #include <lib/dvb/esection.h>
14 #include <lib/dvb/decoder.h>
16 eDVBDemux::eDVBDemux(int adapter, int demux): adapter(adapter), demux(demux), ref(0)
20 eDVBDemux::~eDVBDemux()
26 RESULT eDVBDemux::createSectionReader(eMainloop *context, ePtr<iDVBSectionReader> &reader)
29 reader = new eDVBSectionReader(this, context, res);
35 RESULT eDVBDemux::getMPEGDecoder(ePtr<iTSMPEGDecoder> &decoder)
37 decoder = new eTSMPEGDecoder(this, 0);
41 void eDVBSectionReader::data(int)
43 __u8 data[4096]; // max. section size
45 r = ::read(fd, data, 4096);
48 eWarning("ERROR reading section - %m\n");
53 // this check should never happen unless the driver is crappy!
55 if ((c = crc32((unsigned)-1, data, r)))
56 eFatal("crc32 failed! is %x\n", c);
61 eDVBSectionReader::eDVBSectionReader(eDVBDemux *demux, eMainloop *context, RESULT &res): ref(0), demux(demux)
64 sprintf(filename, "/dev/dvb/adapter%d/demux%d", demux->adapter, demux->demux);
65 fd = ::open(filename, O_RDWR);
69 notifier=new eSocketNotifier(context, fd, eSocketNotifier::Read);
70 CONNECT(notifier->activated, eDVBSectionReader::data);
79 DEFINE_REF(eDVBSectionReader)
81 eDVBSectionReader::~eDVBSectionReader()
89 RESULT eDVBSectionReader::start(const eDVBSectionFilterMask &mask)
95 dmx_sct_filter_params sct;
99 sct.flags = DMX_IMMEDIATE_START;
100 if (mask.flags & eDVBSectionFilterMask::rfCRC)
102 sct.flags |= DMX_CHECK_CRC;
107 memcpy(sct.filter.filter, mask.data, DMX_FILTER_SIZE);
108 memcpy(sct.filter.mask, mask.mask, DMX_FILTER_SIZE);
109 memcpy(sct.filter.mode, mask.mode, DMX_FILTER_SIZE);
111 res = ::ioctl(fd, DMX_SET_FILTER, &sct);
117 RESULT eDVBSectionReader::stop()
122 ::ioctl(fd, DMX_STOP);
127 RESULT eDVBSectionReader::connectRead(const Slot1<void,const __u8*> &r, ePtr<eConnection> &conn)
129 conn = new eConnection(read.connect(r));