move dvb-t 5V antenna switching to better place
[enigma2.git] / lib / dvb / epgcache.cpp
index b04bdd8959f746e9c2ab98bbe5b77e487ccdefcd..7c64fb0cac05c497b5bd6fb5950b65f20a84f87e 100644 (file)
@@ -671,9 +671,18 @@ void eEPGCache::gotMessage( const Message &msg )
                                        chid.original_network_id.get() == msg.service.onid &&
                                        data->m_PrivatePid == -1 )
                                {
+                                       data->m_PrevVersion = -1;
                                        data->m_PrivatePid = msg.pid;
                                        data->m_PrivateService = msg.service;
-                                       data->startPrivateReader(msg.pid, -1);
+                                       updateMap::iterator It = channelLastUpdated.find( channel->getChannelID() );
+                                       int update = ( It != channelLastUpdated.end() ? ( UPDATE_INTERVAL - ( (time(0)+eDVBLocalTimeHandler::getInstance()->difference()-It->second) * 1000 ) ) : ZAP_DELAY );
+                                       if (update < ZAP_DELAY)
+                                               update = ZAP_DELAY;
+                                       data->startPrivateTimer.start(update, 1);
+                                       if (update >= 60000)
+                                               eDebug("[EPGC] next private update in %i min", update/60000);
+                                       else if (update >= 1000)
+                                               eDebug("[EPGC] next private update in %i sec", update/1000);
                                        break;
                                }
                        }
@@ -899,11 +908,12 @@ void eEPGCache::save()
 
 eEPGCache::channel_data::channel_data(eEPGCache *ml)
        :cache(ml)
-       ,abortTimer(ml), zapTimer(ml)
+       ,abortTimer(ml), zapTimer(ml), startPrivateTimer(ml)
        ,state(0), isRunning(0), haveData(0), can_delete(1)
 {
        CONNECT(zapTimer.timeout, eEPGCache::channel_data::startEPG);
        CONNECT(abortTimer.timeout, eEPGCache::channel_data::abortNonAvail);
+       CONNECT(startPrivateTimer.timeout, eEPGCache::channel_data::startPrivateReader);
 }
 
 bool eEPGCache::channel_data::finishEPG()
@@ -2216,6 +2226,14 @@ void eEPGCache::privateSectionRead(const uniqueEPGKey &current_service, const __
                        onid |= data[ptr++];
                        int sid = data[ptr++] << 8;
                        sid |= data[ptr++];
+
+// WORKAROUND for wrong transmitted epg data
+                       if ( onid == 0x85 && tsid == 0x11 && sid == 0xd3 )  // premiere sends wrong tsid here
+                               tsid = 0x1;
+                       else if ( onid == 0x85 && tsid == 0x3 && sid == 0xf5 ) // premiere sends wrong sid here
+                               sid = 0xdc;
+////////////////////////////////////////////
+                               
                        uniqueEPGKey service( sid, onid, tsid );
                        descr_len -= 6;
                        while( descr_len > 0 )
@@ -2297,27 +2315,24 @@ void eEPGCache::privateSectionRead(const uniqueEPGKey &current_service, const __
        }
 }
 
-void eEPGCache::channel_data::startPrivateReader(int pid, int version)
+void eEPGCache::channel_data::startPrivateReader()
 {
        eDVBSectionFilterMask mask;
        memset(&mask, 0, sizeof(mask));
-       mask.pid = pid;
+       mask.pid = m_PrivatePid;
        mask.flags = eDVBSectionFilterMask::rfCRC;
        mask.data[0] = 0xA0;
        mask.mask[0] = 0xFF;
-       eDebug("start privatefilter for pid %04x and version %d", pid, version);
-       if (version != -1)
+       eDebug("start privatefilter for pid %04x and version %d", m_PrivatePid, m_PrevVersion);
+       if (m_PrevVersion != -1)
        {
-               mask.data[3] = version << 1;
+               mask.data[3] = m_PrevVersion << 1;
                mask.mask[3] = 0x3E;
                mask.mode[3] = 0x3E;
        }
        seenPrivateSections.clear();
        m_PrivateReader->connectRead(slot(*this, &eEPGCache::channel_data::readPrivateData), m_PrivateConn);
        m_PrivateReader->start(mask);
-#ifdef NEED_DEMUX_WORKAROUND
-       m_PrevVersion=version;
-#endif
 }
 
 void eEPGCache::channel_data::readPrivateData( const __u8 *data)
@@ -2350,9 +2365,8 @@ void eEPGCache::channel_data::readPrivateData( const __u8 *data)
                        eDebug("[EPGC] private finished");
                        if (!isRunning)
                                can_delete = 1;
-                       int version = data[5];
-                       version = ((version & 0x3E) >> 1);
-                       startPrivateReader(m_PrivatePid, version);
+                       m_PrevVersion = (data[5] & 0x3E) >> 1;
+                       startPrivateReader();
                }
        }
 }