allow disabling cutlists
authorFelix Domke <tmbinc@elitedvb.net>
Mon, 27 Feb 2006 03:06:21 +0000 (03:06 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Mon, 27 Feb 2006 03:06:21 +0000 (03:06 +0000)
lib/service/iservice.h
lib/service/servicedvb.cpp
lib/service/servicedvb.h

index 436d355..86f2a29 100644 (file)
@@ -388,6 +388,7 @@ public:
                        /* returns a list of (pts, what)-tuples */
        virtual PyObject *getCutList() = 0;
        virtual void setCutList(PyObject *list) = 0;
+       virtual void setCutListEnable(int enable) = 0;
        enum { cutIn = 0, cutOut = 1, cutMark = 2 };
 };
 
index f9bb877..4f392a6 100644 (file)
@@ -551,9 +551,7 @@ eDVBServicePlay::eDVBServicePlay(const eServiceReference &ref, eDVBService *serv
        CONNECT(m_event_handler.m_eit_changed, eDVBServicePlay::gotNewEvent);
 
        m_cuesheet_changed = 0;
-       
-       if (m_is_pvr)
-               loadCuesheet();
+       m_cutlist_enabled = 1;
 }
 
 eDVBServicePlay::~eDVBServicePlay()
@@ -648,9 +646,12 @@ RESULT eDVBServicePlay::start()
                   two (one for decoding, one for data source), as we must be prepared
                   to start recording from the data demux. */
        m_cue = new eCueSheet();
+
        m_first_program_info = 1;
        eServiceReferenceDVB &service = (eServiceReferenceDVB&)m_reference;
        r = m_service_handler.tune(service, m_is_pvr, m_cue);
+       
+               /* inject EIT if there is a stored one */
        if (m_is_pvr)
        {
                std::string filename = service.path;
@@ -674,6 +675,10 @@ RESULT eDVBServicePlay::start()
                        }
                }
        }
+       
+       if (m_is_pvr)
+               loadCuesheet();
+
        m_event(this, evStart);
        m_event((iPlayableService*)this, evSeekableStatusChanged);
        return 0;
@@ -1289,9 +1294,16 @@ void eDVBServicePlay::setCutList(PyObject *list)
        }
        m_cuesheet_changed = 1;
        
+       cutlistToCuesheet();
        m_event((iPlayableService*)this, evCuesheetChanged);
 }
 
+void eDVBServicePlay::setCutListEnable(int enable)
+{
+       m_cutlist_enabled = enable;
+       cutlistToCuesheet();
+}
+
 void eDVBServicePlay::updateTimeshiftPids()
 {
        if (!m_record)
@@ -1506,6 +1518,7 @@ void eDVBServicePlay::loadCuesheet()
                eDebug("cutfile not found!");
        
        m_cuesheet_changed = 0;
+       cutlistToCuesheet();
        m_event((iPlayableService*)this, evCuesheetChanged);
 }
 
@@ -1538,6 +1551,57 @@ void eDVBServicePlay::saveCuesheet()
        m_cuesheet_changed = 0;
 }
 
+void eDVBServicePlay::cutlistToCuesheet()
+{
+       if (!m_cue)
+       {
+               eDebug("no cue sheet");
+               return;
+       }       
+       m_cue->clear();
+       
+       if (!m_cutlist_enabled)
+       {
+               m_cue->commitSpans();
+               eDebug("cutlists where disabled");
+               return;
+       }
+
+       pts_t in = 0, out = 0, length = 0;
+       
+       getLength(length);
+               
+       std::multiset<cueEntry>::iterator i(m_cue_entries.begin());
+       
+       while (1)
+       {
+               if (i == m_cue_entries.end())
+                       out = length;
+               else {
+                       if (i->what == 0) /* in */
+                       {
+                               in = i++->where;
+                               continue;
+                       } else if (i->what == 1) /* out */
+                               out = i++->where;
+                       else /* mark */
+                       {
+                               i++;
+                               continue;
+                       }
+               }
+               
+               if (in != out)
+                       m_cue->addSourceSpan(in, out);
+               
+               in = length;
+               
+               if (i == m_cue_entries.end())
+                       break;
+       }
+       m_cue->commitSpans();
+}
+
 DEFINE_REF(eDVBServicePlay)
 
 eAutoInitPtr<eServiceFactoryDVB> init_eServiceFactoryDVB(eAutoInitNumbers::service+1, "eServiceFactoryDVB");
index 5dbd47b..b243ee0 100644 (file)
@@ -77,7 +77,6 @@ public:
        RESULT subServices(ePtr<iSubserviceList> &ptr);
        RESULT timeshift(ePtr<iTimeshiftService> &ptr);
        RESULT cueSheet(ePtr<iCueSheet> &ptr);
-       
 
                // iPauseableService
        RESULT pause();
@@ -120,6 +119,7 @@ public:
                // iCueSheet
        PyObject *getCutList();
        void setCutList(PyObject *);
+       void setCutListEnable(int enable);
        
 private:
        friend class eServiceFactoryDVB;
@@ -181,10 +181,12 @@ private:
        };
        
        std::multiset<cueEntry> m_cue_entries;
-       int m_cuesheet_changed;
+       int m_cuesheet_changed, m_cutlist_enabled;
        
        void loadCuesheet();
        void saveCuesheet();
+       
+       void cutlistToCuesheet();
 };
 
 #endif