X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/defa1a765f48ec880b36b14a247b89649553c2ec..d0899514fa9495013cb73c8ead8c5a5baaf49111:/lib/service/servicedvb.cpp diff --git a/lib/service/servicedvb.cpp b/lib/service/servicedvb.cpp index 5618477c..64e62cac 100644 --- a/lib/service/servicedvb.cpp +++ b/lib/service/servicedvb.cpp @@ -11,6 +11,7 @@ #include #include +#include class eStaticServiceDVBPVRInformation: public iStaticServiceInformation { @@ -20,6 +21,7 @@ class eStaticServiceDVBPVRInformation: public iStaticServiceInformation public: eStaticServiceDVBPVRInformation(const eServiceReference &ref); RESULT getName(const eServiceReference &ref, std::string &name); + int getLength(const eServiceReference &ref); }; DEFINE_REF(eStaticServiceDVBPVRInformation); @@ -36,6 +38,71 @@ RESULT eStaticServiceDVBPVRInformation::getName(const eServiceReference &ref, st name = m_parser.m_name.size() ? m_parser.m_name : ref.path; } +int eStaticServiceDVBPVRInformation::getLength(const eServiceReference &ref) +{ + ASSERT(ref == m_ref); + + eDVBTSTools tstools; + + if (tstools.openFile(ref.path.c_str())) + return 0; + + pts_t len; + if (tstools.calcLen(len)) + return 0; + + return len / 90000; +} + + + +class eDVBPVRServiceOfflineOperations: public iServiceOfflineOperations +{ + DECLARE_REF(eDVBPVRServiceOfflineOperations); + eServiceReferenceDVB m_ref; +public: + eDVBPVRServiceOfflineOperations(const eServiceReference &ref); + + RESULT deleteFromDisk(int simulate); + RESULT getListOfFilenames(std::list &); +}; + +DEFINE_REF(eDVBPVRServiceOfflineOperations); + +eDVBPVRServiceOfflineOperations::eDVBPVRServiceOfflineOperations(const eServiceReference &ref): m_ref((const eServiceReferenceDVB&)ref) +{ +} + +RESULT eDVBPVRServiceOfflineOperations::deleteFromDisk(int simulate) +{ + if (simulate) + return 0; + else + { + std::list res; + if (getListOfFilenames(res)) + return -1; + + /* TODO: deferred removing.. */ + for (std::list::iterator i(res.begin()); i != res.end(); ++i) + { + eDebug("Removing %s...", i->c_str()); + ::unlink(i->c_str()); + } + + return 0; + } +} + +RESULT eDVBPVRServiceOfflineOperations::getListOfFilenames(std::list &res) +{ + res.clear(); + res.push_back(m_ref.path); + return 0; +} + + + DEFINE_REF(eServiceFactoryDVB) eServiceFactoryDVB::eServiceFactoryDVB() @@ -151,6 +218,12 @@ RESULT eServiceFactoryDVB::info(const eServiceReference &ref, ePtr &ptr) +{ + ptr = 0; + return -1; +} + RESULT eServiceFactoryDVB::lookupService(ePtr &service, const eServiceReference &ref) { // TODO: handle the listing itself @@ -185,6 +258,8 @@ RESULT eServiceFactoryDVB::lookupService(ePtr &service, const eServ eDVBServicePlay::eDVBServicePlay(const eServiceReference &ref, eDVBService *service): m_reference(ref), m_dvb_service(service) { + m_is_pvr = !ref.path.empty(); + CONNECT(m_service_handler.serviceEvent, eDVBServicePlay::serviceEvent); CONNECT(m_event_handler.m_eit_changed, eDVBServicePlay::gotNewEvent); eDebug("DVB start (play)"); @@ -285,14 +360,22 @@ void eDVBServicePlay::serviceEvent(int event) { m_decoder->setVideoPID(vpid); m_decoder->setAudioPID(apid, 0); - m_decoder->setSyncPCR(pcrpid); + if (!m_is_pvr) + m_decoder->setSyncPCR(pcrpid); + else + m_decoder->setSyncPCR(-1); m_decoder->start(); // how we can do this better? // update cache pid when the user changed the audio track or video track // TODO handling of difference audio types.. default audio types.. - m_dvb_service->setCachePID(eDVBService::cVPID, vpid); - m_dvb_service->setCachePID(eDVBService::cAPID, apid); - m_dvb_service->setCachePID(eDVBService::cPCRPID, pcrpid); + + /* don't worry about non-existing services, nor pvr services */ + if (m_dvb_service && !m_is_pvr) + { + m_dvb_service->setCachePID(eDVBService::cVPID, vpid); + m_dvb_service->setCachePID(eDVBService::cAPID, apid); + m_dvb_service->setCachePID(eDVBService::cPCRPID, pcrpid); + } } break; @@ -302,9 +385,10 @@ void eDVBServicePlay::serviceEvent(int event) RESULT eDVBServicePlay::start() { + int r; eDebug("starting DVB service"); + r = m_service_handler.tune((eServiceReferenceDVB&)m_reference); m_event(this, evStart); - return m_service_handler.tune((eServiceReferenceDVB&)m_reference); } RESULT eDVBServicePlay::stop() @@ -326,6 +410,46 @@ RESULT eDVBServicePlay::pause(ePtr &ptr) return -1; } +RESULT eDVBServicePlay::seek(ePtr &ptr) +{ + if (m_is_pvr) + { + ptr = this; + return 0; + } + + ptr = 0; + return -1; +} + +RESULT eDVBServicePlay::getLength(pts_t &len) +{ + ePtr pvr_channel; + + if (m_service_handler.getPVRChannel(pvr_channel)) + { + eDebug("getPVRChannel failed!"); + return -1; + } + + return pvr_channel->getLength(len); +} + +RESULT eDVBServicePlay::seekTo(pts_t to) +{ + return -1; +} + +RESULT eDVBServicePlay::getPlayPosition(pts_t &pos) +{ + ePtr pvr_channel; + + if (m_service_handler.getPVRChannel(pvr_channel)) + return -1; + + return pvr_channel->getCurrentPosition(pos); +} + RESULT eDVBServicePlay::info(ePtr &ptr) { ptr = this;