Merge branch 'acid-burn/bug_608_add_nim_sockets_to_crashlogs' into experimental
authoracid-burn <acid-burn@opendreambox.org>
Tue, 23 Nov 2010 13:10:23 +0000 (14:10 +0100)
committeracid-burn <acid-burn@opendreambox.org>
Tue, 23 Nov 2010 13:10:23 +0000 (14:10 +0100)
24 files changed:
lib/base/filepush.cpp
lib/base/filepush.h
lib/base/idatasource.h [new file with mode: 0644]
lib/base/rawfile.cpp
lib/base/rawfile.h
lib/dvb/dvb.cpp
lib/dvb/dvb.h
lib/dvb/idvb.h
lib/dvb/pmt.cpp
lib/dvb/pmt.h
lib/dvb/tstools.cpp
lib/dvb/tstools.h
lib/dvb_ci/dvbci.cpp
lib/python/Components/config.py
lib/python/Plugins/Extensions/DVDBurn/DVDProject.py
lib/python/Plugins/Extensions/DVDBurn/DreamboxDVD.ddvdp.xml
lib/python/Plugins/Extensions/DVDBurn/Text_menu_boat.ddvdm.xml
lib/python/Plugins/Extensions/DVDBurn/Thumbs_menu_clouds.ddvdm.xml
lib/python/Plugins/SystemPlugins/NFIFlash/downloader.py
lib/service/iservice.h
lib/service/service.cpp
lib/service/service.h
lib/service/servicedvb.cpp
lib/service/servicedvb.h

index 91f24ba..af5a8bb 100644 (file)
@@ -29,7 +29,7 @@ void eFilePushThread::thread()
 {
        setIoPrio(prio_class, prio);
 
-       off_t dest_pos = 0, source_pos = 0;
+       off_t dest_pos = 0;
        size_t bytes_read = 0;
        
        off_t current_span_offset = 0;
@@ -46,9 +46,7 @@ void eFilePushThread::thread()
        sigaction(SIGUSR1, &act, 0);
        
        hasStarted();
-       
-       source_pos = m_raw_source.lseek(0, SEEK_CUR);
-       
+
                /* m_stop must be evaluated after each syscall. */
        while (!m_stop)
        {
@@ -137,14 +135,12 @@ void eFilePushThread::thread()
                        
                if (m_sg && !current_span_remaining)
                {
-                       m_sg->getNextSourceSpan(source_pos, bytes_read, current_span_offset, current_span_remaining);
+                       m_sg->getNextSourceSpan(m_current_position, bytes_read, current_span_offset, current_span_remaining);
                        ASSERT(!(current_span_remaining % m_blocksize));
-
-                       if (source_pos != current_span_offset)
-                               source_pos = m_raw_source.lseek(current_span_offset, SEEK_SET);
+                       m_current_position = current_span_offset;
                        bytes_read = 0;
                }
-               
+
                size_t maxread = sizeof(m_buffer);
                
                        /* if we have a source span, don't read past the end */
@@ -157,9 +153,9 @@ void eFilePushThread::thread()
                m_buf_start = 0;
                m_filter_end = 0;
                m_buf_end = 0;
-               
+
                if (maxread)
-                       m_buf_end = m_raw_source.read(m_buffer, maxread);
+                       m_buf_end = m_source->read(m_current_position, m_buffer, maxread);
 
                if (m_buf_end < 0)
                {
@@ -177,10 +173,7 @@ void eFilePushThread::thread()
                        /* a read might be mis-aligned in case of a short read. */
                int d = m_buf_end % m_blocksize;
                if (d)
-               {
-                       m_raw_source.lseek(-d, SEEK_CUR);
                        m_buf_end -= d;
-               }
 
                if (m_buf_end == 0)
                {
@@ -216,18 +209,10 @@ void eFilePushThread::thread()
                                sleep(1);
                                continue;
                        }
-#if 0
-                       eDebug("FILEPUSH: end-of-file! (currently unhandled)");
-                       if (!m_raw_source.lseek(0, SEEK_SET))
-                       {
-                               eDebug("(looping)");
-                               continue;
-                       }
-#endif
                        break;
                } else
                {
-                       source_pos += m_buf_end;
+                       m_current_position += m_buf_end;
                        bytes_read += m_buf_end;
                        if (m_sg)
                                current_span_remaining -= m_buf_end;
@@ -239,20 +224,30 @@ void eFilePushThread::thread()
        eDebug("FILEPUSH THREAD STOP");
 }
 
-void eFilePushThread::start(int fd_source, int fd_dest)
+void eFilePushThread::start(int fd, int fd_dest)
 {
-       m_raw_source.setfd(fd_source);
-       m_fd_dest = fd_dest;
-       resume();
+       eRawFile *f = new eRawFile();
+       ePtr<iDataSource> source = f;
+       f->setfd(fd);
+       start(source, fd_dest);
 }
 
-int eFilePushThread::start(const char *filename, int fd_dest)
+int eFilePushThread::start(const char *file, int fd_dest)
 {
-       if (m_raw_source.open(filename) < 0)
+       eRawFile *f = new eRawFile();
+       ePtr<iDataSource> source = f;
+       if (f->open(file) < 0)
                return -1;
+       start(source, fd_dest);
+       return 0;
+}
+
+void eFilePushThread::start(ePtr<iDataSource> &source, int fd_dest)
+{
+       m_source = source;
        m_fd_dest = fd_dest;
+       m_current_position = 0;
        resume();
-       return 0;
 }
 
 void eFilePushThread::stop()
@@ -273,11 +268,6 @@ void eFilePushThread::pause()
        stop();
 }
 
-void eFilePushThread::seek(int whence, off_t where)
-{
-       m_raw_source.lseek(where, whence);
-}
-
 void eFilePushThread::resume()
 {
        m_stop = 0;
index 71ee997..eb8e792 100644 (file)
@@ -24,9 +24,10 @@ public:
        void stop();
        void start(int sourcefd, int destfd);
        int start(const char *filename, int destfd);
-       
+
+       void start(ePtr<iDataSource> &source, int destfd);
+
        void pause();
-       void seek(int whence, off_t where);
        void resume();
        
                /* flushes the internal readbuffer */ 
@@ -57,11 +58,12 @@ private:
        int m_send_pvr_commit;
        int m_stream_mode;
        int m_blocksize;
+       off_t m_current_position;
+
+       ePtr<iDataSource> m_source;
 
-       eRawFile m_raw_source;
-       
        eFixedMessagePump<int> m_messagepump;
-       
+
        void recvEvent(const int &evt);
 };
 
diff --git a/lib/base/idatasource.h b/lib/base/idatasource.h
new file mode 100644 (file)
index 0000000..0daa526
--- /dev/null
@@ -0,0 +1,19 @@
+#ifndef __lib_base_idatasource_h
+#define __lib_base_idatasource_h
+
+#include <lib/base/object.h>
+
+class iDataSource: public iObject
+{
+public:
+        /* NOTE: should only be used to get current position or filelength */
+       virtual off_t lseek(off_t offset, int whence)=0;
+       
+       /* NOTE: you must be able to handle short reads! */
+       virtual ssize_t read(off_t offset, void *buf, size_t count)=0; /* NOTE: this is what you in normal case have to use!! */
+
+       virtual off_t length()=0;
+       virtual int valid()=0;
+};
+
+#endif
index c7e11fe..3a09e07 100644 (file)
@@ -4,7 +4,10 @@
 #include <lib/base/rawfile.h>
 #include <lib/base/eerror.h>
 
+DEFINE_REF(eRawFile);
+
 eRawFile::eRawFile()
+       :m_lock(false)
 {
        m_fd = -1;
        m_file = 0;
@@ -53,6 +56,13 @@ void eRawFile::setfd(int fd)
 
 off_t eRawFile::lseek(off_t offset, int whence)
 {
+       eSingleLocker l(m_lock);
+       m_current_offset = lseek_internal(offset, whence);
+       return m_current_offset;
+}
+
+off_t eRawFile::lseek_internal(off_t offset, int whence)
+{
 //     eDebug("lseek: %lld, %d", offset, whence);
                /* if there is only one file, use the native lseek - the file could be growing! */
        if (m_nrfiles < 2)
@@ -61,7 +71,8 @@ off_t eRawFile::lseek(off_t offset, int whence)
                        return ::lseek(m_fd, offset, whence);
                else
                {
-                       ::fseeko(m_file, offset, whence);
+                       if (::fseeko(m_file, offset, whence) < 0)
+                               perror("fseeko");
                        return ::ftello(m_file);
                }
        }
@@ -100,11 +111,19 @@ int eRawFile::close()
        }
 }
 
-ssize_t eRawFile::read(void *buf, size_t count)
+ssize_t eRawFile::read(off_t offset, void *buf, size_t count)
 {
-//     eDebug("read: %p, %d", buf, count);
+       eSingleLocker l(m_lock);
+
+       if (offset != m_current_offset)
+       {
+               m_current_offset = lseek_internal(offset, SEEK_SET);
+               if (m_current_offset < 0)
+                       return m_current_offset;
+       }
+
        switchOffset(m_current_offset);
-       
+
        if (m_nrfiles >= 2)
        {
                if (m_current_offset + count > m_totallength)
index a1c73d6..1720d58 100644 (file)
@@ -2,24 +2,27 @@
 #define __lib_base_rawfile_h
 
 #include <string>
+#include <lib/base/idatasource.h>
 
-class eRawFile
+class eRawFile: public iDataSource
 {
+       DECLARE_REF(eRawFile);
+       eSingleLock m_lock;
 public:
        eRawFile();
        ~eRawFile();
-       
        int open(const char *filename, int cached = 0);
        void setfd(int fd);
-       off_t lseek(off_t offset, int whence);
        int close();
-       ssize_t read(void *buf, size_t count); /* NOTE: you must be able to handle short reads! */
+
+       // iDataSource
+       off_t lseek(off_t offset, int whence);
+       ssize_t read(off_t offset, void *buf, size_t count);
        off_t length();
        int valid();
 private:
        int m_fd;     /* for uncached */
        FILE *m_file; /* for cached */
-       
        int m_cached;
        std::string m_basename;
        off_t m_splitsize, m_totallength, m_current_offset, m_base_offset, m_last_offset;
@@ -27,6 +30,8 @@ private:
        void scan();
        int m_current_file;
        int switchOffset(off_t off);
+
+       off_t lseek_internal(off_t offset, int whence);
        FILE *openFileCached(int nr);
        int openFileUncached(int nr);
 };
index 5162945..c980ac5 100644 (file)
@@ -1752,6 +1752,20 @@ RESULT eDVBChannel::getCurrentFrontendParameters(ePtr<iDVBFrontendParameters> &p
 
 RESULT eDVBChannel::playFile(const char *file)
 {
+       eRawFile *f = new eRawFile();
+       ePtr<iDataSource> source = f;
+
+       if (f->open(file) < 0)
+       {
+               eDebug("can't open PVR file %s (%m)", file);
+               return -ENOENT;
+       }
+
+       return playSource(source, file);
+}
+
+RESULT eDVBChannel::playSource(ePtr<iDataSource> &source, const char *streaminfo_file)
+{
        ASSERT(!m_frontend);
        if (m_pvr_thread)
        {
@@ -1760,7 +1774,13 @@ RESULT eDVBChannel::playFile(const char *file)
                m_pvr_thread = 0;
        }
 
-       m_tstools.openFile(file);
+       if (!source->valid())
+       {
+               eDebug("PVR source is not valid!");
+               return -ENOENT;
+       }
+
+       m_tstools.setSource(source, streaminfo_file);
 
                /* DON'T EVEN THINK ABOUT FIXING THIS. FIX THE ATI SOURCES FIRST,
                   THEN DO A REAL FIX HERE! */
@@ -1787,15 +1807,7 @@ RESULT eDVBChannel::playFile(const char *file)
 
        m_event(this, evtPreStart);
 
-       if (m_pvr_thread->start(file, m_pvr_fd_dst))
-       {
-               delete m_pvr_thread;
-               m_pvr_thread = 0;
-               ::close(m_pvr_fd_dst);
-               m_pvr_fd_dst = -1;
-               eDebug("can't open PVR file %s (%m)", file);
-               return -ENOENT;
-       }
+       m_pvr_thread->start(source, m_pvr_fd_dst);
        CONNECT(m_pvr_thread->m_event, eDVBChannel::pvrEvent);
 
        m_state = state_ok;
@@ -1804,7 +1816,7 @@ RESULT eDVBChannel::playFile(const char *file)
        return 0;
 }
 
-void eDVBChannel::stopFile()
+void eDVBChannel::stopSource()
 {
        if (m_pvr_thread)
        {
@@ -1814,6 +1826,13 @@ void eDVBChannel::stopFile()
        }
        if (m_pvr_fd_dst >= 0)
                ::close(m_pvr_fd_dst);
+       ePtr<iDataSource> d;
+       m_tstools.setSource(d);
+}
+
+void eDVBChannel::stopFile()
+{
+       stopSource();
 }
 
 void eDVBChannel::setCueSheet(eCueSheet *cuesheet)
index fb92580..9277160 100644 (file)
@@ -259,7 +259,10 @@ public:
                /* iDVBPVRChannel */
        RESULT playFile(const char *file);
        void stopFile();
-       
+
+       RESULT playSource(ePtr<iDataSource>& source, const char *priv=NULL);
+       void stopSource();
+
        void setCueSheet(eCueSheet *cuesheet);
        
        RESULT getLength(pts_t &len);
@@ -301,7 +304,7 @@ private:
        std::list<std::pair<off_t, off_t> > m_source_span;
        void getNextSourceSpan(off_t current_offset, size_t bytes_read, off_t &start, size_t &size);
        void flushPVR(iDVBDemux *decoding_demux=0);
-       
+
        eSingleLock m_cuesheet_lock;
 
        friend class eUsePtr<eDVBChannel>;
index f1217a6..3996b6b 100644 (file)
@@ -15,6 +15,7 @@
 #include <lib/base/object.h>
 #include <lib/base/ebase.h>
 #include <lib/base/elock.h>
+#include <lib/base/idatasource.h>
 #include <lib/service/service.h>
 #include <libsig_comp.h>
 #include <connection.h>
@@ -605,6 +606,10 @@ public:
        virtual RESULT playFile(const char *file) = 0;
        virtual void stopFile() = 0;
        
+       /* new interface */
+       virtual RESULT playSource(ePtr<iDataSource> &source, const char *priv=NULL) = 0;
+       virtual void stopSource() = 0;
+       
        virtual void setCueSheet(eCueSheet *cuesheet) = 0;
        
        virtual RESULT getLength(pts_t &pts) = 0;
index ea4b96c..5fdd69d 100644 (file)
@@ -149,7 +149,7 @@ void eDVBServicePMTHandler::PATready(int)
                serviceEvent(eventNoPAT);
 }
 
-PyObject *eDVBServicePMTHandler::getCaIds()
+PyObject *eDVBServicePMTHandler::getCaIds(bool pair)
 {
        ePyObject ret;
 
@@ -161,16 +161,29 @@ PyObject *eDVBServicePMTHandler::getCaIds()
                if (cnt)
                {
                        ret=PyList_New(cnt);
-                       std::set<uint16_t>::iterator it(prog.caids.begin());
-                       while(cnt--)
-                               PyList_SET_ITEM(ret, cnt, PyInt_FromLong(*it++));
+                       std::set<program::capid_pair>::iterator it(prog.caids.begin());
+                       if (pair)
+                       {
+                               while(cnt--)
+                               {
+                                       ePyObject tuple = PyTuple_New(2);
+                                       PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(it->caid));
+                                       PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong((it++)->capid));
+                                       PyList_SET_ITEM(ret, cnt, tuple);
+                               }
+                       }
+                       else
+                       {
+                               while(cnt--)
+                                       PyList_SET_ITEM(ret, cnt, PyInt_FromLong((it++)->caid));
+                       }
                }
        }
 
        return ret ? (PyObject*)ret : (PyObject*)PyList_New(0);
 }
 
-int eDVBServicePMTHandler::getProgramInfo(struct program &program)
+int eDVBServicePMTHandler::getProgramInfo(program &program)
 {
        ePtr<eTable<ProgramMapSection> > ptr;
        int cached_apid_ac3 = -1;
@@ -460,7 +473,10 @@ int eDVBServicePMTHandler::getProgramInfo(struct program &program)
                                                        case CA_DESCRIPTOR:
                                                        {
                                                                CaDescriptor *descr = (CaDescriptor*)(*desc);
-                                                               program.caids.insert(descr->getCaSystemId());
+                                                               program::capid_pair pair;
+                                                               pair.caid = descr->getCaSystemId();
+                                                               pair.capid = descr->getCaPid();
+                                                               program.caids.insert(pair);
                                                                break;
                                                        }
                                                        default:
@@ -523,7 +539,10 @@ int eDVBServicePMTHandler::getProgramInfo(struct program &program)
                                        if ((*desc)->getTag() == CA_DESCRIPTOR)
                                        {
                                                CaDescriptor *descr = (CaDescriptor*)(*desc);
-                                               program.caids.insert(descr->getCaSystemId());
+                                               program::capid_pair pair;
+                                               pair.caid = descr->getCaSystemId();
+                                               pair.capid = descr->getCaPid();
+                                               program.caids.insert(pair);
                                        }
                                }
                        }
@@ -589,8 +608,12 @@ int eDVBServicePMTHandler::getProgramInfo(struct program &program)
                        program.textPid = cached_tpid;
                }
                CAID_LIST &caids = m_service->m_ca;
-               for (CAID_LIST::iterator it(caids.begin()); it != caids.end(); ++it)
-                       program.caids.insert(*it);
+               for (CAID_LIST::iterator it(caids.begin()); it != caids.end(); ++it) {
+                       program::capid_pair pair;
+                       pair.caid = *it;
+                       pair.capid = -1; // not known yet
+                       program.caids.insert(pair);
+               }
                if ( cnt )
                        ret = 0;
        }
@@ -675,6 +698,12 @@ void eDVBServicePMTHandler::SDTScanEvent(int event)
 
 int eDVBServicePMTHandler::tune(eServiceReferenceDVB &ref, int use_decode_demux, eCueSheet *cue, bool simulate, eDVBService *service)
 {
+       ePtr<iDataSource> s;
+       return tuneExt(ref, use_decode_demux, s, NULL, cue, simulate, service);
+}
+
+int eDVBServicePMTHandler::tuneExt(eServiceReferenceDVB &ref, int use_decode_demux, ePtr<iDataSource> &source, const char *streaminfo_file, eCueSheet *cue, bool simulate, eDVBService *service)
+{
        RESULT res=0;
        m_reference = ref;
        
@@ -704,7 +733,9 @@ int eDVBServicePMTHandler::tune(eServiceReferenceDVB &ref, int use_decode_demux,
                {
                        eWarning("no .meta file found, trying to find PMT pid");
                        eDVBTSTools tstools;
-                       if (tstools.openFile(ref.path.c_str()))
+                       if (source)
+                               tstools.setSource(source, streaminfo_file ? streaminfo_file : ref.path.c_str());
+                       else if (tstools.openFile(ref.path.c_str()))
                                eWarning("failed to open file");
                        else
                        {
@@ -757,7 +788,10 @@ int eDVBServicePMTHandler::tune(eServiceReferenceDVB &ref, int use_decode_demux,
                if (m_pvr_channel)
                {
                        m_pvr_channel->setCueSheet(cue);
-                       m_pvr_channel->playFile(ref.path.c_str());
+                       if (source)
+                               m_pvr_channel->playSource(source, streaminfo_file);
+                       else
+                               m_pvr_channel->playFile(ref.path.c_str());
                }
        }
 
index 483c06b..2d10f7a 100644 (file)
@@ -181,11 +181,17 @@ public:
 
        struct program
        {
+               struct capid_pair
+               {
+                       uint16_t caid;
+                       int capid;
+                       bool operator< (const struct capid_pair &t) { return t.caid < caid; }
+               };
                std::vector<videoStream> videoStreams;
                std::vector<audioStream> audioStreams;
                int defaultAudioStream;
                std::vector<subtitleStream> subtitleStreams;
-               std::set<uint16_t> caids;
+               std::set<capid_pair> caids;
                int pcrPid;
                int pmtPid;
                int textPid;
@@ -193,10 +199,10 @@ public:
                PyObject *createPythonObject();
        };
 
-       int getProgramInfo(struct program &program);
+       int getProgramInfo(program &program);
        int getDataDemux(ePtr<iDVBDemux> &demux);
        int getDecodeDemux(ePtr<iDVBDemux> &demux);
-       PyObject *getCaIds();
+       PyObject *getCaIds(bool pair=false); // caid / ecmpid pair
        
        int getPVRChannel(ePtr<iDVBPVRChannel> &pvr_channel);
        int getServiceReference(eServiceReferenceDVB &service) { service = m_reference; return 0; }
@@ -205,7 +211,12 @@ public:
        int getChannel(eUsePtr<iDVBChannel> &channel);
        void resetCachedProgram() { m_have_cached_program = false; }
 
+       /* deprecated interface */
        int tune(eServiceReferenceDVB &ref, int use_decode_demux, eCueSheet *sg=0, bool simulate=false, eDVBService *service = 0);
+
+       /* new interface */
+       int tuneExt(eServiceReferenceDVB &ref, int use_decode_demux, ePtr<iDataSource> &, const char *streaminfo_file, eCueSheet *sg=0, bool simulate=false, eDVBService *service = 0);
+
        void free();
 private:
        bool m_have_cached_program;
index d5ad249..bd36308 100644 (file)
@@ -7,7 +7,6 @@
 #include <stdio.h>
 
 eDVBTSTools::eDVBTSTools()
-       :m_file_lock(true)
 {
        m_pid = -1;
        m_maxrange = 256*1024;
@@ -23,19 +22,39 @@ eDVBTSTools::eDVBTSTools()
        m_futile = 0;
 }
 
+void eDVBTSTools::closeSource()
+{
+       m_source = NULL;
+}
+
 eDVBTSTools::~eDVBTSTools()
 {
-       closeFile();
+       closeSource();
 }
 
 int eDVBTSTools::openFile(const char *filename, int nostreaminfo)
 {
+       eRawFile *f = new eRawFile();
+       ePtr<iDataSource> src = f;
+
+       if (f->open(filename, 1) < 0)
+               return -1;
+
+       setSource(src, filename);
+
+       return 0;
+}
+
+void eDVBTSTools::setSource(ePtr<iDataSource> &source, const char *stream_info_filename)
+{
        closeFile();
-       
-       if (!nostreaminfo)
+
+       m_source = source;
+
+       if (stream_info_filename)
        {
-               eDebug("loading streaminfo for %s", filename);
-               m_streaminfo.load(filename);
+               eDebug("loading streaminfo for %s", stream_info_filename);
+               m_streaminfo.load(stream_info_filename);
        }
        
        if (!m_streaminfo.empty())
@@ -45,19 +64,14 @@ int eDVBTSTools::openFile(const char *filename, int nostreaminfo)
 //             eDebug("no recorded stream information available");
                m_use_streaminfo = 0;
        }
-       
-       m_samples_taken = 0;
 
-       eSingleLocker l(m_file_lock);
-       if (m_file.open(filename, 1) < 0)
-               return -1;
-       return 0;
+       m_samples_taken = 0;
 }
 
 void eDVBTSTools::closeFile()
 {
-       eSingleLocker l(m_file_lock);
-       m_file.close();
+       if (m_source)
+               closeSource();
 }
 
 void eDVBTSTools::setSyncPID(int pid)
@@ -77,31 +91,24 @@ int eDVBTSTools::getPTS(off_t &offset, pts_t &pts, int fixed)
                if (!m_streaminfo.getPTS(offset, pts))
                        return 0;
        
-       if (!m_file.valid())
+       if (!m_source || !m_source->valid())
                return -1;
 
        offset -= offset % 188;
 
-       eSingleLocker l(m_file_lock);
-       if (m_file.lseek(offset, SEEK_SET) < 0)
-       {
-               eDebug("lseek failed");
-               return -1;
-       }
-       
        int left = m_maxrange;
        
        while (left >= 188)
        {
                unsigned char packet[188];
-               if (m_file.read(packet, 188) != 188)
+               if (m_source->read(offset, packet, 188) != 188)
                {
                        eDebug("read error");
                        break;
                }
                left -= 188;
                offset += 188;
-               
+
                if (packet[0] != 0x47)
                {
                        eDebug("resync");
@@ -111,8 +118,8 @@ int eDVBTSTools::getPTS(off_t &offset, pts_t &pts, int fixed)
                                if (packet[i] == 0x47)
                                        break;
                                ++i;
+                               --offset;
                        }
-                       offset = m_file.lseek(i - 188, SEEK_CUR);
                        continue;
                }
                
@@ -404,7 +411,7 @@ int eDVBTSTools::getNextAccessPoint(pts_t &ts, const pts_t &start, int direction
 
 void eDVBTSTools::calcBegin()
 {
-       if (!m_file.valid())
+       if (!m_source || !m_source->valid())
                return;
 
        if (!(m_begin_valid || m_futile))
@@ -419,11 +426,10 @@ void eDVBTSTools::calcBegin()
 
 void eDVBTSTools::calcEnd()
 {
-       if (!m_file.valid())
+       if (!m_source || !m_source->valid())
                return;
 
-       eSingleLocker l(m_file_lock);
-       off_t end = m_file.lseek(0, SEEK_END);
+       off_t end = m_source->lseek(0, SEEK_END);
        
        if (llabs(end - m_last_filelength) > 1*1024*1024)
        {
@@ -573,31 +579,28 @@ int eDVBTSTools::takeSample(off_t off, pts_t &p)
 int eDVBTSTools::findPMT(int &pmt_pid, int &service_id)
 {
                /* FIXME: this will be factored out soon! */
-       if (!m_file.valid())
+       if (!m_source || !m_source->valid())
        {
                eDebug(" file not valid");
                return -1;
        }
 
-       eSingleLocker l(m_file_lock);
-       if (m_file.lseek(0, SEEK_SET) < 0)
-       {
-               eDebug("seek failed");
-               return -1;
-       }
+       off_t position=0;
 
        int left = 5*1024*1024;
        
        while (left >= 188)
        {
                unsigned char packet[188];
-               if (m_file.read(packet, 188) != 188)
+               int ret = m_source->read(position, packet, 188);
+               if (ret != 188)
                {
                        eDebug("read error");
                        break;
                }
                left -= 188;
-               
+               position += 188;
+
                if (packet[0] != 0x47)
                {
                        int i = 0;
@@ -605,12 +608,11 @@ int eDVBTSTools::findPMT(int &pmt_pid, int &service_id)
                        {
                                if (packet[i] == 0x47)
                                        break;
+                               --position;
                                ++i;
                        }
-                       m_file.lseek(i - 188, SEEK_CUR);
                        continue;
                }
-               
                int pid = ((packet[1] << 8) | packet[2]) & 0x1FFF;
                
                int pusi = !!(packet[1] & 0x40);
index ed8b924..1192cd2 100644 (file)
@@ -19,9 +19,12 @@ public:
        eDVBTSTools();
        ~eDVBTSTools();
 
+       void setSource(ePtr<iDataSource> &source, const char *streaminfo_filename=NULL);
+       void closeSource();
+
        int openFile(const char *filename, int nostreaminfo = 0);
        void closeFile();
-       
+
        void setSyncPID(int pid);
        void setSearchRange(int maxrange);
        
@@ -77,8 +80,7 @@ private:
        int m_pid;
        int m_maxrange;
 
-       eSingleLock m_file_lock;
-       eRawFile m_file;
+       ePtr<iDataSource> m_source;
 
        int m_begin_valid, m_end_valid;
        pts_t m_pts_begin, m_pts_end;
index 883fb5a..342f06a 100644 (file)
@@ -297,8 +297,8 @@ void eDVBCIInterfaces::recheckPMTHandlers()
                if (!pmthandler->getProgramInfo(p))
                {
                        int cnt=0;
-                       for (caidSet::reverse_iterator x(p.caids.rbegin()); x != p.caids.rend(); ++x, ++cnt)
-                               caids.push_front(*x);
+                       for (std::set<eDVBServicePMTHandler::program::capid_pair>::reverse_iterator x(p.caids.rbegin()); x != p.caids.rend(); ++x, ++cnt)
+                               caids.push_front(x->caid);
                        if (service && cnt)
                                service->m_ca = caids;
                }
index 44ad6d2..6e56085 100755 (executable)
@@ -1647,9 +1647,12 @@ class Config(ConfigSubsection):
 
                        if not base_file: # not the initial config file..
                                #update config.x.y.value when exist
-                               configEntry = eval(name)
-                               if configEntry is not None:
-                                       configEntry.value = val
+                               try:
+                                       configEntry = eval(name)
+                                       if configEntry is not None:
+                                               configEntry.value = val
+                               except (SyntaxError, KeyError):
+                                       pass
 
                # we inherit from ConfigSubsection, so ...
                #object.__setattr__(self, "saved_value", tree["config"])
index 7f755db..6dbcd49 100644 (file)
@@ -2,6 +2,7 @@ from Tools.Directories import fileExists
 from Components.config import config, ConfigSubsection, ConfigInteger, ConfigText, ConfigSelection, getConfigListEntry, ConfigSequence, ConfigSubList
 import DVDTitle
 import xml.dom.minidom
+from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_FONTS
 
 class ConfigColor(ConfigSequence):
        def __init__(self, default = [128,128,128]):
@@ -125,6 +126,14 @@ class DVDProject:
                        for key in self.filekeys:
                                val = self.settings.dict()[key].getValue()
                                if not fileExists(val):
+                                       if val[0] != "/":
+                                               if key.find("font") == 0:
+                                                       val = resolveFilename(SCOPE_FONTS)+val
+                                               else:
+                                                       val = resolveFilename(SCOPE_PLUGINS)+"Extensions/DVDBurn/"+val
+                                               if fileExists(val):
+                                                       self.settings.dict()[key].setValue(val)
+                                                       continue
                                        self.error += "\n%s '%s' not found" % (key, val)
                #except AttributeError:
                        #print "loadProject AttributeError", self.error
index 451e8a8..4645260 100644 (file)
@@ -3,11 +3,11 @@
        <settings
                name="Dreambox DVD record"
                authormode="menu_linked"
-               menutemplate="/usr/lib/enigma2/python/Plugins/Extensions/DVDBurn/Thumbs_menu_clouds.ddvdm.xml"
+               menutemplate="Thumbs_menu_clouds.ddvdm.xml"
                titlesetmode="multi"
-               vmgm="/usr/lib/enigma2/python/Plugins/Extensions/DVDBurn/vmgmdream.mpg"
+               vmgm="vmgmdream.mpg"
                output="dvd"
-               isopath="/media/hdd/movie/"
+               isopath="/hdd/movie/"
                dataformat="iso9660_4"
        />
        <titles> </titles>
index 0de7f4b..bf6356a 100644 (file)
@@ -3,17 +3,17 @@
        <settings
                titleformat="$i. $t"
                subtitleformat="$D.$M.$Y, $T $C, $d"
-               menubg="/usr/lib/enigma2/python/Plugins/Extensions/DVDBurn/dreamdvd_boat.jpg"
-               menuaudio="/usr/lib/enigma2/python/Plugins/Extensions/DVDBurn/silence.mp2"
+               menubg="dreamdvd_boat.jpg"
+               menuaudio="silence.mp2"
                dimensions="(720, 576)"
                rows="5"
                cols="1"
                color_button="[8, 0, 0]"
                color_highlight="[0, 192, 192]"
                color_headline="[0, 0, 128]"
-               fontface_headline="/usr/share/fonts/nmsbd.ttf"
-               fontface_title="/usr/share/fonts/nmsbd.ttf"
-               fontface_subtitle="/usr/share/fonts/nmsbd.ttf"
+               fontface_headline="nmsbd.ttf"
+               fontface_title="nmsbd.ttf"
+               fontface_subtitle="nmsbd.ttf"
                fontsize_headline="46"
                fontsize_title="24"
                fontsize_subtitle="14"
index c00c3fe..074f203 100644 (file)
@@ -3,17 +3,17 @@
        <settings
                titleformat="$t"
                subtitleformat="$d"
-               menubg="/usr/lib/enigma2/python/Plugins/Extensions/DVDBurn/dreamdvd_clouds.jpg"
-               menuaudio="/usr/lib/enigma2/python/Plugins/Extensions/DVDBurn/silence.mp2"
+               menubg="dreamdvd_clouds.jpg"
+               menuaudio="silence.mp2"
                dimensions="(720, 576)"
                rows="2"
                cols="2"
                color_button="[8, 0, 0]"
                color_highlight="[128, 0, 0]"
                color_headline="[128, 0, 0]"
-               fontface_headline="/usr/share/fonts/nmsbd.ttf"
-               fontface_title="/usr/share/fonts/nmsbd.ttf"
-               fontface_subtitle="/usr/share/fonts/nmsbd.ttf"
+               fontface_headline="nmsbd.ttf"
+               fontface_title="nmsbd.ttf"
+               fontface_subtitle="nmsbd.ttf"
                fontsize_headline="46"
                fontsize_title="18"
                fontsize_subtitle="12"
index 296d3bc..85ecc92 100644 (file)
@@ -16,7 +16,7 @@ from Components.MultiContent import MultiContentEntryText
 from Components.ScrollLabel import ScrollLabel
 from Components.Harddisk import harddiskmanager
 from Components.Task import Task, Job, job_manager, Condition
-from Tools.Directories import fileExists, isMount
+from Tools.Directories import fileExists, isMount, resolveFilename, SCOPE_HDD, SCOPE_MEDIA
 from Tools.HardwareInfo import HardwareInfo
 from Tools.Downloader import downloadWithProgress
 from enigma import eConsoleAppContainer, gFont, RT_HALIGN_LEFT, RT_HALIGN_CENTER, RT_VALIGN_CENTER, RT_WRAP, eTimer
@@ -391,7 +391,7 @@ class NFIDownload(Screen):
                
                self.box = HardwareInfo().get_device_name()
                self.feed_base = "http://www.dreamboxupdate.com/opendreambox" #/1.5/%s/images/" % self.box      
-               self.usbmountpoint = "/mnt/usb/"
+               self.usbmountpoint = resolveFilename(SCOPE_MEDIA)+"usb/"
 
                self.menulist = []
 
@@ -570,7 +570,7 @@ class NFIDownload(Screen):
 
        def ackedDestination(self):
                print "[ackedDestination]", self.branch, self.target_dir
-               self.container.setCWD("/mnt")
+               self.container.setCWD(resolveFilename(SCOPE_MEDIA)+"usb/")
                if self.target_dir[:8] == "/autofs/":
                        self.target_dir = "/dev/" + self.target_dir[8:-1]
 
@@ -792,13 +792,14 @@ If you already have a prepared bootable USB stick, please insert it now. Otherwi
                self.umountCallback()
 
 def main(session, **kwargs):
-       session.open(NFIDownload,"/home/root")
+       session.open(NFIDownload,resolveFilename(SCOPE_HDD))
 
 def filescan_open(list, session, **kwargs):
        dev = "/dev/" + (list[0].path).rsplit('/',1)[0][7:]
-       print "mounting device " + dev + " to /mnt/usb..."
-       system("mount "+dev+" /mnt/usb/ -o rw,sync")
-       session.open(NFIDownload,"/mnt/usb/")
+       print "mounting device " + dev + " to /media/usb..."
+       usbmountpoint = resolveFilename(SCOPE_MEDIA)+"usb/"
+       system("mount %s %s -o rw,sync" % (dev, usbmountpoint))
+       session.open(NFIDownload,usbmountpoint)
 
 def filescan(**kwargs):
        from Components.Scanner import Scanner, ScanPath
index 2ba7cb4..7f58249 100644 (file)
@@ -289,6 +289,7 @@ public:
                sFileSize,
 
                sCAIDs,
+               sCAIDPIDs,
                sVideoType,             /* MPEG2 MPEG4 */
 
                sTags,                          /* space seperated list of tags */
index eb2757a..8c674c5 100644 (file)
@@ -201,6 +201,25 @@ RESULT eServiceCenter::removeServiceFactory(int id)
        return 0;
 }
 
+RESULT eServiceCenter::addFactoryExtension(int id, const char *extension)
+{
+       std::map<int, std::list<std::string> >::iterator it = extensions.find(id);
+       if (it == extensions.end())
+               return -1;
+       it->second.push_back(extension);
+       return 0;
+}
+
+RESULT eServiceCenter::removeFactoryExtension(int id, const char *extension)
+{
+       std::map<int, std::list<std::string> >::iterator it = extensions.find(id);
+       if (it == extensions.end())
+               return -1;
+       it->second.remove(extension);
+       return 0;
+}
+
+
 int eServiceCenter::getServiceTypeForExtension(const char *str)
 {
        for (std::map<int, std::list<std::string> >::iterator sit(extensions.begin()); sit != extensions.end(); ++sit)
index 6f6ab98..ffc7d27 100644 (file)
@@ -40,6 +40,8 @@ public:
        static RESULT getPrivInstance(ePtr<eServiceCenter> &ptr) { ptr = instance; return 0; }
        RESULT addServiceFactory(int id, iServiceHandler *hnd, std::list<std::string> &extensions);
        RESULT removeServiceFactory(int id);
+       RESULT addFactoryExtension(int id, const char *extension);
+       RESULT removeFactoryExtension(int id, const char *extension);
 #endif
        static SWIG_VOID(RESULT) getInstance(ePtr<iServiceHandler> &SWIG_NAMED_OUTPUT(ptr)) { ptr = instance; return 0; }
 };
index e498dd4..2fd6671 100644 (file)
@@ -503,18 +503,19 @@ RESULT eDVBPVRServiceOfflineOperations::reindex()
        int err = f.open(m_ref.path.c_str(), 0);
        if (err < 0)
                return -1;
-       
+
+       off_t offset = 0;
        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));
+               int r = f.read(offset, buffer, sizeof(buffer));
                if (!r)
                        break;
                if (r < 0)
                        return r;
+               offset += r;
                parser.parseData(offset, buffer, r);
        }
        
@@ -1093,7 +1094,8 @@ void eDVBServicePlay::serviceEventTimeshift(int event)
 
                        if (m_skipmode < 0)
                                m_cue->seekTo(0, -1000);
-                       m_service_handler_timeshift.tune(r, 1, m_cue, 0, m_dvb_service); /* use the decoder demux for everything */
+                       ePtr<iDataSource> source = createDataSource(r);
+                       m_service_handler_timeshift.tuneExt(r, 1, source, r.path.c_str(), m_cue, 0, m_dvb_service); /* use the decoder demux for everything */
 
                        m_event((iPlayableService*)this, evUser+1);
                }
@@ -1122,7 +1124,8 @@ void eDVBServicePlay::serviceEventTimeshift(int event)
                                m_service_handler_timeshift.free();
                                resetTimeshift(1);
 
-                               m_service_handler_timeshift.tune(r, 1, m_cue, 0, m_dvb_service); /* use the decoder demux for everything */
+                               ePtr<iDataSource> source = createDataSource(r);
+                               m_service_handler_timeshift.tuneExt(r, 1, source, m_timeshift_file_next.c_str(), m_cue, 0, m_dvb_service); /* use the decoder demux for everything */
 
                                m_event((iPlayableService*)this, evUser+1);
                        }
@@ -1152,7 +1155,8 @@ RESULT eDVBServicePlay::start()
                m_event(this, evStart);
 
        m_first_program_info = 1;
-       m_service_handler.tune(service, m_is_pvr, m_cue, false, m_dvb_service);
+       ePtr<iDataSource> source = createDataSource(service);
+       m_service_handler.tuneExt(service, m_is_pvr, source, service.path.c_str(), m_cue, false, m_dvb_service);
 
        if (m_is_pvr)
        {
@@ -1585,7 +1589,7 @@ int eDVBServicePlay::getInfo(int w)
 {
        eDVBServicePMTHandler::program program;
 
-       if (w == sCAIDs)
+       if (w == sCAIDs || w == sCAIDPIDs)
                return resIsPyObject;
 
        eDVBServicePMTHandler &h = m_timeshift_active ? m_service_handler_timeshift : m_service_handler;
@@ -1726,6 +1730,8 @@ PyObject *eDVBServicePlay::getInfoObject(int w)
        {
        case sCAIDs:
                return m_service_handler.getCaIds();
+       case sCAIDPIDs:
+               return m_service_handler.getCaIds(true);
        case sTransponderData:
                return eStaticServiceDVBInformation().getInfoObject(m_reference, w);
        default:
@@ -2356,6 +2362,13 @@ void eDVBServicePlay::resetTimeshift(int start)
                m_timeshift_active = 0;
 }
 
+ePtr<iDataSource> eDVBServicePlay::createDataSource(eServiceReferenceDVB &ref)
+{
+       eRawFile *f = new eRawFile();
+       f->open(ref.path.c_str());
+       return ePtr<iDataSource>(f);
+}
+
 void eDVBServicePlay::switchToTimeshift()
 {
        if (m_timeshift_active)
@@ -2367,7 +2380,9 @@ void eDVBServicePlay::switchToTimeshift()
        r.path = m_timeshift_file;
 
        m_cue->seekTo(0, -1000);
-       m_service_handler_timeshift.tune(r, 1, m_cue, 0, m_dvb_service); /* use the decoder demux for everything */
+
+       ePtr<iDataSource> source = createDataSource(r);
+       m_service_handler_timeshift.tuneExt(r, 1, source, m_timeshift_file.c_str(), m_cue, 0, m_dvb_service); /* use the decoder demux for everything */
 
        eDebug("eDVBServicePlay::switchToTimeshift, in pause mode now.");
        pause();
index dafaf35..23675bf 100644 (file)
@@ -185,7 +185,7 @@ public:
        RESULT stream(ePtr<iStreamableService> &ptr);
        PyObject *getStreamingData();
 
-private:
+protected:
        friend class eServiceFactoryDVB;
        eServiceReference m_reference;
        
@@ -289,6 +289,8 @@ private:
 
        ePtr<eConnection> m_video_event_connection;
        void video_event(struct iTSMPEGDecoder::videoEvent);
+
+       virtual ePtr<iDataSource> createDataSource(eServiceReferenceDVB &ref);
 };
 
 class eStaticServiceDVBBouquetInformation: public iStaticServiceInformation