X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/4332f5c83e491aa5c16064ec244b7171ed6687c6..033a2333874297c1c388ecf4532de2bc2b11fb30:/lib/dvb/decoder.cpp diff --git a/lib/dvb/decoder.cpp b/lib/dvb/decoder.cpp index 28d877df..26172e0c 100644 --- a/lib/dvb/decoder.cpp +++ b/lib/dvb/decoder.cpp @@ -49,12 +49,12 @@ eDVBAudio::eDVBAudio(eDVBDemux *demux, int dev): m_demux(demux) eWarning("%s: %m", filename); } -int eDVBAudio::startPid(int pid) +int eDVBAudio::startPid(int pid, int type) { - eDebug("setting audio pid to %x", pid); if ((m_fd < 0) || (m_fd_demux < 0)) return -1; dmx_pes_filter_params pes; + pes.pid = pid; pes.input = DMX_IN_FRONTEND; pes.output = DMX_OUT_DECODER; @@ -70,6 +70,27 @@ int eDVBAudio::startPid(int pid) eWarning("audio: DMX_START: %m"); return -errno; } + + int bypass = 0; + + switch (type) + { + case aMPEG: + bypass = 1; + break; + case aAC3: + bypass = 0; + break; + /* + case aDTS: + bypass = 2; + break; + */ + } + + if (::ioctl(m_fd, AUDIO_SET_BYPASS_MODE, bypass) < 0) + eWarning("audio: AUDIO_SET_BYPASS_MODE: %m"); + if (::ioctl(m_fd, AUDIO_PLAY) < 0) eWarning("audio: AUDIO_PLAY: %m"); return 0; @@ -92,6 +113,24 @@ void eDVBAudio::stopPid() eWarning("audio: DMX_STOP: %m"); } #endif + +void eDVBAudio::flush() +{ + if (::ioctl(m_fd, AUDIO_CLEAR_BUFFER) < 0) + eDebug("audio: AUDIO_CLEAR_BUFFER: %m"); +} + +void eDVBAudio::freeze() +{ + if (::ioctl(m_fd, AUDIO_PAUSE) < 0) + eDebug("video: AUDIO_PAUSE: %m"); +} + +void eDVBAudio::unfreeze() +{ + if (::ioctl(m_fd, AUDIO_CONTINUE) < 0) + eDebug("video: AUDIO_CONTINUE: %m"); +} eDVBAudio::~eDVBAudio() { @@ -126,11 +165,10 @@ eDVBVideo::eDVBVideo(eDVBDemux *demux, int dev): m_demux(demux) int eDVBVideo::startPid(int pid) { - eDebug("setting video pid to %x", pid); if ((m_fd < 0) || (m_fd_demux < 0)) return -1; dmx_pes_filter_params pes; - + pes.pid = pid; pes.input = DMX_IN_FRONTEND; pes.output = DMX_OUT_DECODER; @@ -148,14 +186,12 @@ int eDVBVideo::startPid(int pid) } if (::ioctl(m_fd, VIDEO_PLAY) < 0) eWarning("video: VIDEO_PLAY: %m"); - else - eDebug("video ok"); return 0; } void eDVBVideo::stop() { - if (::ioctl(m_fd, VIDEO_STOP) < 0) + if (::ioctl(m_fd, VIDEO_STOP, 1) < 0) eWarning("video: VIDEO_STOP: %m"); #if HAVE_DVB_API_VERSION > 2 if (::ioctl(m_fd_demux, DMX_STOP) < 0) @@ -171,6 +207,24 @@ void eDVBVideo::stopPid() } #endif +void eDVBVideo::flush() +{ + if (::ioctl(m_fd, VIDEO_CLEAR_BUFFER) < 0) + eDebug("video: VIDEO_CLEAR_BUFFER: %m"); +} + +void eDVBVideo::freeze() +{ + if (::ioctl(m_fd, VIDEO_FREEZE) < 0) + eDebug("video: VIDEO_FREEZE: %m"); +} + +void eDVBVideo::unfreeze() +{ + if (::ioctl(m_fd, VIDEO_CONTINUE) < 0) + eDebug("video: VIDEO_CONTINUE: %m"); +} + eDVBVideo::~eDVBVideo() { if (m_fd >= 0) @@ -196,7 +250,6 @@ eDVBPCR::eDVBPCR(eDVBDemux *demux): m_demux(demux) int eDVBPCR::startPid(int pid) { - eDebug("setting pcr pid to %x", pid); if (m_fd_demux < 0) return -1; dmx_pes_filter_params pes; @@ -236,7 +289,6 @@ DEFINE_REF(eTSMPEGDecoder); int eTSMPEGDecoder::setState() { int res = 0; - eDebug("changed %x", m_changed); #if HAVE_DVB_API_VERSION < 3 if (m_changed & changeAudio && m_audio) m_audio->stopPid(); @@ -262,7 +314,7 @@ int eTSMPEGDecoder::setState() m_pcr = new eDVBPCR(m_demux); if (m_pcr->startPid(m_pcrpid)) { - eWarning("video: startpid failed!"); + eWarning("pcr: startpid failed!"); res = -1; } m_changed &= ~changePCR; @@ -280,7 +332,7 @@ int eTSMPEGDecoder::setState() if (m_changed & changeAudio) { m_audio = new eDVBAudio(m_demux, 0); - if (m_audio->startPid(m_apid)) + if (m_audio->startPid(m_apid, m_atype)) { eWarning("audio: startpid failed!"); res = -1; @@ -298,7 +350,7 @@ int eTSMPEGDecoder::setState() m_pcr = new eDVBPCR(m_demux); if (m_pcr->startPid(m_pcrpid)) { - eWarning("video: startpid failed!"); + eWarning("pcr: startpid failed!"); res = -1; } } @@ -328,7 +380,7 @@ int eTSMPEGDecoder::setState() if ((m_apid >= 0) && (m_apid < 0x1FFF)) { m_audio = new eDVBAudio(m_demux, 0); - if (m_audio->startPid(m_apid)) + if (m_audio->startPid(m_apid, m_atype)) { eWarning("audio: startpid failed!"); res = -1; @@ -342,6 +394,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); } eTSMPEGDecoder::~eTSMPEGDecoder() @@ -394,12 +447,24 @@ RESULT eTSMPEGDecoder::start() RESULT eTSMPEGDecoder::freeze(int cont) { - return -1; + if (m_video) + m_video->freeze(); + + if (m_audio) + m_audio->freeze(); + + return 0; } RESULT eTSMPEGDecoder::unfreeze() { - return -1; + if (m_video) + m_video->unfreeze(); + + if (m_audio) + m_audio->unfreeze(); + + return 0; } RESULT eTSMPEGDecoder::setSinglePictureMode(int when) @@ -421,3 +486,24 @@ RESULT eTSMPEGDecoder::setZoom(int what) { return -1; } + +RESULT eTSMPEGDecoder::flush() +{ + if (m_audio) + m_audio->flush(); + if (m_video) + m_video->flush(); + return 0; +} + +void eTSMPEGDecoder::demux_event(int event) +{ + switch (event) + { + case eDVBDemux::evtFlush: + flush(); + break; + default: + break; + } +}