add reindex
authorFelix Domke <felix.domke@multimedia-labs.de>
Mon, 10 Aug 2009 20:52:36 +0000 (22:52 +0200)
committerFelix Domke <felix.domke@multimedia-labs.de>
Mon, 10 Aug 2009 20:52:36 +0000 (22:52 +0200)
lib/service/iservice.h
lib/service/servicedvb.cpp
lib/service/servicemp3.cpp

index 24c2e341c04e13f078176b834db463364d9bed65..c477f11db41b4e433d4a3a8fcb0b6fcac44e5352 100644 (file)
@@ -719,6 +719,9 @@ public:
 
                /* for transferring a service... */
        virtual SWIG_VOID(RESULT) getListOfFilenames(std::list<std::string> &SWIG_OUTPUT)=0;
+       
+               /* a blocking call to reindex a file */
+       virtual int reindex() = 0;
 
                // TODO: additional stuff, like a conversion interface?
 };
index 8017e3d6aa70b58927360c68ead0c3856b51a28c..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()
@@ -2354,6 +2391,7 @@ void eDVBServicePlay::updateDecoder()
                }
                if (m_cue)
                        m_cue->setDecodingDemux(m_decode_demux, m_decoder);
+               m_decoder->play(); /* pids will be set later. */
        }
 
        m_timeshift_changed = 0;
index 3e6de28223bf7a4065f373a3fdccb0296870758e..2844b4775e4b4fba9e55c95fd98d2e7fd42504b2 100644 (file)
@@ -101,6 +101,7 @@ public:
        
        RESULT deleteFromDisk(int simulate);
        RESULT getListOfFilenames(std::list<std::string> &);
+       RESULT reindex();
 };
 
 DEFINE_REF(eMP3ServiceOfflineOperations);
@@ -143,6 +144,11 @@ RESULT eMP3ServiceOfflineOperations::getListOfFilenames(std::list<std::string> &
        return 0;
 }
 
+RESULT eMP3ServiceOfflineOperations::reindex()
+{
+       return -1;
+}
+
 
 RESULT eServiceFactoryMP3::offlineOperations(const eServiceReference &ref, ePtr<iServiceOfflineOperations> &ptr)
 {