add getSize convenience function to obtain file or directory size (not tested with...
[enigma2.git] / lib / dvb / decoder.cpp
index bd52ea034051604202a748c756cca50748613a6b..90bf19e1d68aa72d93f17ec8077a03482b2f3b30 100644 (file)
 #define dmxPesFilterParams dmx_pes_filter_params
 #define DMX_PES_VIDEO0 DMX_PES_VIDEO
 #define DMX_PES_AUDIO0 DMX_PES_AUDIO
 #define dmxPesFilterParams dmx_pes_filter_params
 #define DMX_PES_VIDEO0 DMX_PES_VIDEO
 #define DMX_PES_AUDIO0 DMX_PES_AUDIO
+#define DMX_PES_PCR0 DMX_PES_PCR
+#define DMX_PES_TELETEXT0 DMX_PES_TELETEXT
 #define DMX_PES_VIDEO1 DMX_PES_VIDEO
 #define DMX_PES_AUDIO1 DMX_PES_AUDIO
 #define DMX_PES_VIDEO1 DMX_PES_VIDEO
 #define DMX_PES_AUDIO1 DMX_PES_AUDIO
+#define DMX_PES_PCR1 DMX_PES_PCR
+#define DMX_PES_TELETEXT1 DMX_PES_TELETEXT
 #include <ost/dmx.h>
 #include <ost/video.h>
 #include <ost/audio.h>
 #include <ost/dmx.h>
 #include <ost/video.h>
 #include <ost/audio.h>
@@ -196,6 +200,9 @@ int eDVBAudio::startPid(int pid, int type)
        case aAACHE:
                bypass = 9;
                break;
        case aAACHE:
                bypass = 9;
                break;
+       case aLPCM:
+               bypass = 6;
+               break;
        }
 
        eDebugNoNewLine("AUDIO_SET_BYPASS(%d) - ", bypass);
        }
 
        eDebugNoNewLine("AUDIO_SET_BYPASS(%d) - ", bypass);
@@ -686,7 +693,7 @@ int eDVBVideo::getFrameRate()
 
 DEFINE_REF(eDVBPCR);
 
 
 DEFINE_REF(eDVBPCR);
 
-eDVBPCR::eDVBPCR(eDVBDemux *demux): m_demux(demux)
+eDVBPCR::eDVBPCR(eDVBDemux *demux, int dev): m_demux(demux), m_dev(dev)
 {
        char filename[128];
 #if HAVE_DVB_API_VERSION < 3
 {
        char filename[128];
 #if HAVE_DVB_API_VERSION < 3
@@ -745,7 +752,7 @@ int eDVBPCR::startPid(int pid)
        pes.pid      = pid;
        pes.input    = DMX_IN_FRONTEND;
        pes.output   = DMX_OUT_DECODER;
        pes.pid      = pid;
        pes.input    = DMX_IN_FRONTEND;
        pes.output   = DMX_OUT_DECODER;
-       pes.pes_type = DMX_PES_PCR;
+       pes.pes_type = m_dev ? DMX_PES_PCR1 : DMX_PES_PCR0; /* FIXME */
        pes.flags    = 0;
        eDebugNoNewLine("DMX_SET_PES_FILTER(0x%02x) - pcr - ", pid);
        if (::ioctl(m_fd_demux, DMX_SET_PES_FILTER, &pes) < 0)
        pes.flags    = 0;
        eDebugNoNewLine("DMX_SET_PES_FILTER(0x%02x) - pcr - ", pid);
        if (::ioctl(m_fd_demux, DMX_SET_PES_FILTER, &pes) < 0)
@@ -782,7 +789,8 @@ eDVBPCR::~eDVBPCR()
 
 DEFINE_REF(eDVBTText);
 
 
 DEFINE_REF(eDVBTText);
 
-eDVBTText::eDVBTText(eDVBDemux *demux): m_demux(demux)
+eDVBTText::eDVBTText(eDVBDemux *demux, int dev)
+    :m_demux(demux), m_dev(dev)
 {
        char filename[128];
 #if HAVE_DVB_API_VERSION < 3
 {
        char filename[128];
 #if HAVE_DVB_API_VERSION < 3
@@ -804,7 +812,7 @@ int eDVBTText::startPid(int pid)
        pes.pid      = pid;
        pes.input    = DMX_IN_FRONTEND;
        pes.output   = DMX_OUT_DECODER;
        pes.pid      = pid;
        pes.input    = DMX_IN_FRONTEND;
        pes.output   = DMX_OUT_DECODER;
-       pes.pes_type = DMX_PES_TELETEXT;
+       pes.pes_type = m_dev ? DMX_PES_TELETEXT1 : DMX_PES_TELETEXT0; // FIXME
        pes.flags    = 0;
 
        eDebugNoNewLine("DMX_SET_PES_FILTER(0x%02x) - ttx - ", pid);
        pes.flags    = 0;
 
        eDebugNoNewLine("DMX_SET_PES_FILTER(0x%02x) - ttx - ", pid);
@@ -857,7 +865,7 @@ int eTSMPEGDecoder::setState()
        const char *decoder_states[] = {"stop", "pause", "play", "decoderfastforward", "trickmode", "slowmotion"};
        eDebug("decoder state: %s, vpid=%d, apid=%d", decoder_states[m_state], m_vpid, m_apid);
 
        const char *decoder_states[] = {"stop", "pause", "play", "decoderfastforward", "trickmode", "slowmotion"};
        eDebug("decoder state: %s, vpid=%d, apid=%d", decoder_states[m_state], m_vpid, m_apid);
 
-       bool changed = !!m_changed;
+       int changed = m_changed;
 #if HAVE_DVB_API_VERSION < 3
        bool checkAVSync = m_changed & (changeAudio|changeVideo|changePCR);
        if (m_changed & changeAudio && m_audio)
 #if HAVE_DVB_API_VERSION < 3
        bool checkAVSync = m_changed & (changeAudio|changeVideo|changePCR);
        if (m_changed & changeAudio && m_audio)
@@ -895,7 +903,7 @@ int eTSMPEGDecoder::setState()
        }
        if (m_changed & changePCR)
        {
        }
        if (m_changed & changePCR)
        {
-               m_pcr = new eDVBPCR(m_demux);
+               m_pcr = new eDVBPCR(m_demux, m_decoder);
                if (m_pcr->setPid(m_pcrpid))
                        res = -1;
        }
                if (m_pcr->setPid(m_pcrpid))
                        res = -1;
        }
@@ -960,7 +968,7 @@ int eTSMPEGDecoder::setState()
        {
                if ((m_pcrpid >= 0) && (m_pcrpid < 0x1FFF))
                {
        {
                if ((m_pcrpid >= 0) && (m_pcrpid < 0x1FFF))
                {
-                       m_pcr = new eDVBPCR(m_demux);
+                       m_pcr = new eDVBPCR(m_demux, m_decoder);
                        if (m_pcr->startPid(m_pcrpid))
                                res = -1;
                }
                        if (m_pcr->startPid(m_pcrpid))
                                res = -1;
                }
@@ -991,7 +999,7 @@ int eTSMPEGDecoder::setState()
        {
                if ((m_textpid >= 0) && (m_textpid < 0x1FFF) && !nott)
                {
        {
                if ((m_textpid >= 0) && (m_textpid < 0x1FFF) && !nott)
                {
-                       m_text = new eDVBTText(m_demux);
+                       m_text = new eDVBTText(m_demux, m_decoder);
                        if (m_text->startPid(m_textpid))
                                res = -1;
                }
                        if (m_text->startPid(m_textpid))
                                res = -1;
                }
@@ -999,7 +1007,7 @@ int eTSMPEGDecoder::setState()
        }
 #endif
 
        }
 #endif
 
-       if (m_changed & changeState)
+       if (changed & (changeState|changeVideo|changeAudio))
        {
                                        /* play, slowmotion, fast-forward */
                int state_table[6][4] = 
        {
                                        /* play, slowmotion, fast-forward */
                int state_table[6][4] = 
@@ -1012,7 +1020,7 @@ int eTSMPEGDecoder::setState()
                                /* [stateSlowMotion] =           */ {1, m_ff_sm_ratio, 0}
                        };
                int *s = state_table[m_state];
                                /* [stateSlowMotion] =           */ {1, m_ff_sm_ratio, 0}
                        };
                int *s = state_table[m_state];
-               if (m_video)
+               if (changed & (changeState|changeVideo) && m_video)
                {
                        m_video->setSlowMotion(s[1]);
                        m_video->setFastForward(s[2]);
                {
                        m_video->setSlowMotion(s[1]);
                        m_video->setFastForward(s[2]);
@@ -1021,7 +1029,7 @@ int eTSMPEGDecoder::setState()
                        else
                                m_video->freeze();
                }
                        else
                                m_video->freeze();
                }
-               if (m_audio)
+               if (changed & (changeState|changeAudio) && m_audio)
                {
                        if (s[0])
                                m_audio->unfreeze();
                {
                        if (s[0])
                                m_audio->unfreeze();
@@ -1172,10 +1180,7 @@ RESULT eTSMPEGDecoder::play()
        {
                if (!m_changed)
                        return 0;
        {
                if (!m_changed)
                        return 0;
-       }
-//     else  
-/* commented out because the changeState is needed to unfreeze decoders in decoder::setState... needed by normal pmt changes
-tmbinc please recheck this! */
+       } else  
        {
                m_state = statePlay;
                m_changed |= changeState;
        {
                m_state = statePlay;
                m_changed |= changeState;