From aee1fdd37eadd70de2af1b299af87e238b4ac388 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Mon, 27 Feb 2006 03:06:21 +0000 Subject: [PATCH] allow disabling cutlists --- lib/service/iservice.h | 1 + lib/service/servicedvb.cpp | 70 ++++++++++++++++++++++++++++++++++++-- lib/service/servicedvb.h | 6 ++-- 3 files changed, 72 insertions(+), 5 deletions(-) diff --git a/lib/service/iservice.h b/lib/service/iservice.h index 436d3554..86f2a294 100644 --- a/lib/service/iservice.h +++ b/lib/service/iservice.h @@ -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 }; }; diff --git a/lib/service/servicedvb.cpp b/lib/service/servicedvb.cpp index f9bb877f..4f392a6a 100644 --- a/lib/service/servicedvb.cpp +++ b/lib/service/servicedvb.cpp @@ -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::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 init_eServiceFactoryDVB(eAutoInitNumbers::service+1, "eServiceFactoryDVB"); diff --git a/lib/service/servicedvb.h b/lib/service/servicedvb.h index 5dbd47b7..b243ee07 100644 --- a/lib/service/servicedvb.h +++ b/lib/service/servicedvb.h @@ -77,7 +77,6 @@ public: RESULT subServices(ePtr &ptr); RESULT timeshift(ePtr &ptr); RESULT cueSheet(ePtr &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 m_cue_entries; - int m_cuesheet_changed; + int m_cuesheet_changed, m_cutlist_enabled; void loadCuesheet(); void saveCuesheet(); + + void cutlistToCuesheet(); }; #endif -- 2.30.2