add reindex
[enigma2.git] / lib / service / servicedvb.cpp
index a75c6cac6d51031a02642da9c423e1d9759f24b1..497911c5dd03e7fe97842efd7f951dac414f9539 100644 (file)
@@ -466,6 +466,7 @@ public:
        
        RESULT deleteFromDisk(int simulate);
        RESULT getListOfFilenames(std::list<std::string> &);
+       RESULT reindex();
 };
 
 DEFINE_REF(eDVBPVRServiceOfflineOperations);
@@ -528,6 +529,42 @@ RESULT eDVBPVRServiceOfflineOperations::getListOfFilenames(std::list<std::string
        return 0;
 }
 
+RESULT eDVBPVRServiceOfflineOperations::reindex()
+{
+       const char *filename = m_ref.path.c_str();
+       eDebug("reindexing %s...", filename);
+
+       eMPEGStreamInformation info;
+       eMPEGStreamParserTS parser(info);
+       
+       info.startSave(filename);
+       
+       eRawFile f;
+       
+       int err = f.open(m_ref.path.c_str(), 0);
+       if (err < 0)
+               return -1;
+       
+       off_t length = f.length();
+       unsigned char buffer[188*256*4];
+       while (1)
+       {
+               off_t offset = f.lseek(0, SEEK_CUR);
+               eDebug("at %08llx / %08llx (%d %%)", offset, length, (int)(offset * 100 / length));
+               int r = f.read(buffer, sizeof(buffer));
+               if (!r)
+                       break;
+               if (r < 0)
+                       return r;
+               parser.parseData(offset, buffer, r);
+       }
+       
+       info.stopSave();
+       f.close();
+       
+       return 0;
+}
+
 DEFINE_REF(eServiceFactoryDVB)
 
 eServiceFactoryDVB::eServiceFactoryDVB()
@@ -2350,9 +2387,11 @@ void eDVBServicePlay::updateDecoder()
                                        Py_DECREF(subs);
                                }
                        }
+                       m_decoder->play(); /* pids will be set later */
                }
                if (m_cue)
                        m_cue->setDecodingDemux(m_decode_demux, m_decoder);
+               m_decoder->play(); /* pids will be set later. */
        }
 
        m_timeshift_changed = 0;
@@ -2426,13 +2465,7 @@ void eDVBServicePlay::updateDecoder()
                                m_decoder->setRadioPic(radio_pic);
                }
 
-/*             if (!m_is_primary)
-                       m_decoder->setTrickmode();
-               else */ if (m_is_paused)
-                       m_decoder->pause();
-               else
-                       m_decoder->play();
-
+               m_decoder->set();
                m_decoder->setAudioChannel(achannel);
 
                /* don't worry about non-existing services, nor pvr services */