X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/cd038ce28d53719a27e7009365dd74fec19357df..95039ba3e50f5df85e6e1e2d4108486fd28f2264:/lib/dvb/decoder.cpp diff --git a/lib/dvb/decoder.cpp b/lib/dvb/decoder.cpp index 6794a056..8e21dcad 100644 --- a/lib/dvb/decoder.cpp +++ b/lib/dvb/decoder.cpp @@ -1,4 +1,3 @@ -#include #include #include #if HAVE_DVB_API_VERSION < 3 @@ -301,11 +300,72 @@ eDVBPCR::~eDVBPCR() ::close(m_fd_demux); } +DEFINE_REF(eDVBTText); + +eDVBTText::eDVBTText(eDVBDemux *demux): m_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 + m_fd_demux = ::open(filename, O_RDWR); + if (m_fd_demux < 0) + eWarning("%s: %m", filename); +} + +int eDVBTText::startPid(int pid) +{ + if (m_fd_demux < 0) + return -1; + dmx_pes_filter_params pes; + + pes.pid = pid; + pes.input = DMX_IN_FRONTEND; + pes.output = DMX_OUT_DECODER; + pes.pes_type = DMX_PES_TELETEXT; + pes.flags = 0; + if (::ioctl(m_fd_demux, DMX_SET_PES_FILTER, &pes) < 0) + { + eWarning("video: DMX_SET_PES_FILTER: %m"); + return -errno; + } + if (::ioctl(m_fd_demux, DMX_START) < 0) + { + eWarning("video: DMX_START: %m"); + return -errno; + } + return 0; +} + +void eDVBTText::stop() +{ + if (::ioctl(m_fd_demux, DMX_STOP) < 0) + eWarning("video: DMX_STOP: %m"); +} + +eDVBTText::~eDVBTText() +{ + if (m_fd_demux >= 0) + ::close(m_fd_demux); +} + DEFINE_REF(eTSMPEGDecoder); int eTSMPEGDecoder::setState() { int res = 0; + + int noaudio = m_is_sm || m_is_ff || m_is_trickmode; + int nott = noaudio; /* actually same conditions */ + + if ((noaudio && m_audio) || (!m_audio && !noaudio)) + m_changed |= changeAudio; + + if ((nott && m_text) || (!m_text && !nott)) + m_changed |= changeText; + #if HAVE_DVB_API_VERSION < 3 if (m_changed & changeAudio && m_audio) m_audio->stopPid(); @@ -357,6 +417,22 @@ int eTSMPEGDecoder::setState() m_changed &= ~changeAudio; } #else + if (m_changed & changePCR) + { + if (m_pcr) + m_pcr->stop(); + m_pcr = 0; + if ((m_pcrpid >= 0) && (m_pcrpid < 0x1FFF)) + { + m_pcr = new eDVBPCR(m_demux); + if (m_pcr->startPid(m_pcrpid)) + { + eWarning("pcr: startpid failed!"); + res = -1; + } + } + m_changed &= ~changePCR; + } if (m_changed & changeVideo) { eDebug("VIDEO CHANGED (to %04x)", m_vpid); @@ -378,28 +454,12 @@ int eTSMPEGDecoder::setState() } m_changed &= ~changeVideo; } - if (m_changed & changePCR) - { - if (m_pcr) - m_pcr->stop(); - m_pcr = 0; - if ((m_pcrpid >= 0) && (m_pcrpid < 0x1FFF)) - { - m_pcr = new eDVBPCR(m_demux); - if (m_pcr->startPid(m_pcrpid)) - { - eWarning("pcr: startpid failed!"); - res = -1; - } - } - m_changed &= ~changePCR; - } if (m_changed & changeAudio) { if (m_audio) m_audio->stop(); m_audio = 0; - if ((m_apid >= 0) && (m_apid < 0x1FFF)) + if ((m_apid >= 0) && (m_apid < 0x1FFF) && !noaudio) { m_audio = new eDVBAudio(m_demux, 0); if (m_audio->startPid(m_apid, m_atype)) @@ -410,6 +470,22 @@ int eTSMPEGDecoder::setState() } m_changed &= ~changeAudio; } + if (m_changed & changeText) + { + if (m_text) + m_text->stop(); + m_text = 0; + if ((m_textpid >= 0) && (m_textpid < 0x1FFF) && !nott) + { + m_text = new eDVBTText(m_demux); + if (m_text->startPid(m_textpid)) + { + eWarning("text: startpid failed!"); + res = -1; + } + } + m_changed &= ~changeText; + } #endif return res; } @@ -417,7 +493,7 @@ int eTSMPEGDecoder::setState() eTSMPEGDecoder::eTSMPEGDecoder(eDVBDemux *demux, int decoder): m_demux(demux), m_changed(0) { demux->connectEvent(slot(*this, &eTSMPEGDecoder::demux_event), m_demux_event); - eDebug("eTSMPEGDecoder::eTSMPEGDecoder %p", this); + m_is_ff = m_is_sm = m_is_trickmode = 0; } eTSMPEGDecoder::~eTSMPEGDecoder() @@ -425,7 +501,6 @@ eTSMPEGDecoder::~eTSMPEGDecoder() m_vpid = m_apid = m_pcrpid = pidNone; m_changed = -1; setState(); - eDebug("~eTSMPEGDecoder %p", this); } RESULT eTSMPEGDecoder::setVideoPID(int vpid) @@ -459,6 +534,16 @@ RESULT eTSMPEGDecoder::setSyncPCR(int pcrpid) return 0; } +RESULT eTSMPEGDecoder::setTextPID(int textpid) +{ + if (m_textpid != textpid) + { + m_changed |= changeText; + m_textpid = textpid; + } + return 0; +} + RESULT eTSMPEGDecoder::setSyncMaster(int who) { return -1; @@ -503,6 +588,10 @@ RESULT eTSMPEGDecoder::setPictureSkipMode(int what) RESULT eTSMPEGDecoder::setFastForward(int frames_to_skip) { + m_is_ff = frames_to_skip != 0; + + setState(); + if (m_video) return m_video->setFastForward(frames_to_skip); else @@ -511,6 +600,10 @@ RESULT eTSMPEGDecoder::setFastForward(int frames_to_skip) RESULT eTSMPEGDecoder::setSlowMotion(int repeat) { + m_is_sm = repeat != 0; + + setState(); + if (m_video) return m_video->setSlowMotion(repeat); else @@ -542,3 +635,10 @@ void eTSMPEGDecoder::demux_event(int event) break; } } + +RESULT eTSMPEGDecoder::setTrickmode(int what) +{ + m_is_trickmode = what; + setState(); + return 0; +}