X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/d5e22a275d2ecdf3205bfefa927be6e125ac27b8..4283696371a06f44605f9d005957bc8837c66e0d:/lib/service/servicedvb.cpp diff --git a/lib/service/servicedvb.cpp b/lib/service/servicedvb.cpp index 5bd25f67..955ceb0a 100644 --- a/lib/service/servicedvb.cpp +++ b/lib/service/servicedvb.cpp @@ -10,6 +10,49 @@ #include #include +#include +#include + +class eStaticServiceDVBPVRInformation: public iStaticServiceInformation +{ + DECLARE_REF(eStaticServiceDVBPVRInformation); + eServiceReference m_ref; + eDVBMetaParser m_parser; +public: + eStaticServiceDVBPVRInformation(const eServiceReference &ref); + RESULT getName(const eServiceReference &ref, std::string &name); + int getLength(const eServiceReference &ref); +}; + +DEFINE_REF(eStaticServiceDVBPVRInformation); + +eStaticServiceDVBPVRInformation::eStaticServiceDVBPVRInformation(const eServiceReference &ref) +{ + m_ref = ref; + m_parser.parseFile(ref.path); +} + +RESULT eStaticServiceDVBPVRInformation::getName(const eServiceReference &ref, std::string &name) +{ + ASSERT(ref == m_ref); + 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; +} DEFINE_REF(eServiceFactoryDVB) @@ -109,13 +152,21 @@ RESULT eServiceFactoryDVB::list(const eServiceReference &ref, ePtr &ptr) { - ePtr service; - int r = lookupService(service, ref); - if (r) - return r; - /* eDVBService has the iStaticServiceInformation interface, so we pass it here. */ - ptr = service; - return 0; + /* do we have a PVR service? */ + if (ref.path.size()) + { + ptr = new eStaticServiceDVBPVRInformation(ref); + return 0; + } else + { + ePtr service; + int r = lookupService(service, ref); + if (r) + return r; + /* eDVBService has the iStaticServiceInformation interface, so we pass it here. */ + ptr = service; + return 0; + } } RESULT eServiceFactoryDVB::lookupService(ePtr &service, const eServiceReference &ref) @@ -152,6 +203,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)"); @@ -252,8 +305,17 @@ 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); } break;