X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/6977ff954d9c08c2f3ca7727cf997ccd7be201ed..55d011a98b9217c3b2eeba0ee18790b1989e6661:/lib/dvb/demux.cpp diff --git a/lib/dvb/demux.cpp b/lib/dvb/demux.cpp index 329eafda..73e04432 100644 --- a/lib/dvb/demux.cpp +++ b/lib/dvb/demux.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -6,12 +5,23 @@ #include #include - #if HAVE_DVB_API_VERSION < 3 #include + #ifndef DMX_SET_NEGFILTER_MASK #define DMX_SET_NEGFILTER_MASK _IOW('o',48,uint8_t *) #endif + +#ifndef DMX_GET_STC + struct dmx_stc + { + unsigned int num; /* input : which STC? O..N */ + unsigned int base; /* output: divisor for stc to get 90 kHz clock */ + unsigned long long stc; /* output: src in 'base'*90 kHz units */ + }; + #define DMX_GET_STC _IOR('o', 50, struct dmx_stc) +#endif + #else #include #endif @@ -24,6 +34,7 @@ #include #include #include +#include eDVBDemux::eDVBDemux(int adapter, int demux): adapter(adapter), demux(demux) { @@ -34,8 +45,46 @@ eDVBDemux::~eDVBDemux() { } +int eDVBDemux::openDemux(void) +{ + char filename[128]; +#if HAVE_DVB_API_VERSION < 3 + snprintf(filename, 128, "/dev/dvb/card%d/demux%d", adapter, demux); +#else + snprintf(filename, 128, "/dev/dvb/adapter%d/demux%d", adapter, demux); +#endif + return ::open(filename, O_RDWR); +} + DEFINE_REF(eDVBDemux) +RESULT eDVBDemux::setSourceFrontend(int fenum) +{ +#if HAVE_DVB_API_VERSION >= 3 + int fd = openDemux(); + + int n = DMX_SOURCE_FRONT0 + fenum; + int res = ::ioctl(fd, DMX_SET_SOURCE, &n); + if (res) + eDebug("DMX_SET_SOURCE failed! - %m"); + ::close(fd); + return res; +#endif + return 0; +} + +RESULT eDVBDemux::setSourcePVR(int pvrnum) +{ +#if HAVE_DVB_API_VERSION >= 3 + int fd = openDemux(); + int n = DMX_SOURCE_DVR0 + pvrnum; + int res = ::ioctl(fd, DMX_SET_SOURCE, &n); + ::close(fd); + return res; +#endif + return 0; +} + RESULT eDVBDemux::createSectionReader(eMainloop *context, ePtr &reader) { RESULT res; @@ -59,21 +108,15 @@ RESULT eDVBDemux::getMPEGDecoder(ePtr &decoder) return 0; } -RESULT eDVBDemux::getSTC(pts_t &pts) +RESULT eDVBDemux::getSTC(pts_t &pts, int num) { - char filename[128]; -#if HAVE_DVB_API_VERSION < 3 - sprintf(filename, "/dev/dvb/card%d/demux%d", adapter, demux); -#else - sprintf(filename, "/dev/dvb/adapter%d/demux%d", adapter, demux); -#endif - int fd = ::open(filename, O_RDWR); + int fd = openDemux(); if (fd < 0) return -ENODEV; struct dmx_stc stc; - stc.num = 0; + stc.num = num; stc.base = 1; if (ioctl(fd, DMX_GET_STC, &stc) < 0) @@ -131,14 +174,7 @@ void eDVBSectionReader::data(int) eDVBSectionReader::eDVBSectionReader(eDVBDemux *demux, eMainloop *context, RESULT &res): demux(demux) { char filename[128]; -#if HAVE_DVB_API_VERSION < 3 - sprintf(filename, "/dev/dvb/card%d/demux%d", demux->adapter, demux->demux); -#else - sprintf(filename, "/dev/dvb/adapter%d/demux%d", demux->adapter, demux->demux); -#endif - fd = ::open(filename, O_RDWR); - - eDebug("eDVBSectionReader has fd %d", fd); + fd = demux->openDemux(); if (fd >= 0) { @@ -192,6 +228,8 @@ RESULT eDVBSectionReader::start(const eDVBSectionFilterMask &mask) memcpy(sct.filter.mask, mask.mask, DMX_FILTER_SIZE); #if HAVE_DVB_API_VERSION >= 3 memcpy(sct.filter.mode, mask.mode, DMX_FILTER_SIZE); + if (::ioctl(fd, DMX_SET_BUFFER_SIZE, 8192*8) < 0) + eDebug("DMX_SET_BUFFER_SIZE failed(%m)"); #endif res = ::ioctl(fd, DMX_SET_FILTER, &sct); @@ -230,14 +268,45 @@ RESULT eDVBSectionReader::connectRead(const Slot1 &r, ePtrm_dvr_busy = 1; } @@ -302,11 +371,11 @@ RESULT eDVBTSRecorder::removePID(int pid) return 0; } -RESULT eDVBTSRecorder::setFormat(int format) +RESULT eDVBTSRecorder::setTimingPID(int pid) { if (m_running) return -1; - m_format = format; + m_thread->setTimingPID(pid); return 0; } @@ -343,16 +412,10 @@ RESULT eDVBTSRecorder::connectEvent(const Slot1 &event, ePtradapter, m_demux->demux); -#else - snprintf(filename, 128, "/dev/dvb/adapter%d/demux%d", m_demux->adapter, m_demux->demux); -#endif - int fd = ::open(filename, O_RDWR); + int fd = m_demux->openDemux(); if (fd < 0) { - eDebug("FAILED to open demux (%s) in ts recoder (%m)", filename); + eDebug("FAILED to open demux in ts recoder (%m)"); return -1; } @@ -386,6 +449,7 @@ RESULT eDVBTSRecorder::startPID(int pid) void eDVBTSRecorder::stopPID(int pid) { - ::close(m_pids[pid]); + if (m_pids[pid] != -1) + ::close(m_pids[pid]); m_pids[pid] = -1; }