X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/1cdf6cb021fcaa6548b90ba7b6765cf1e8b8b37b..defa1a765f48ec880b36b14a247b89649553c2ec:/lib/service/servicedvb.cpp diff --git a/lib/service/servicedvb.cpp b/lib/service/servicedvb.cpp index 48d00d65..5618477c 100644 --- a/lib/service/servicedvb.cpp +++ b/lib/service/servicedvb.cpp @@ -9,6 +9,33 @@ #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); +}; + +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; +} + DEFINE_REF(eServiceFactoryDVB) eServiceFactoryDVB::eServiceFactoryDVB() @@ -76,17 +103,27 @@ RESULT eDVBServiceList::getContent(std::list &list) return 0; } +RESULT eDVBServiceList::getNext(eServiceReference &) +{ + /* implement me */ + return -1; +} + RESULT eServiceFactoryDVB::play(const eServiceReference &ref, ePtr &ptr) { + ePtr service; + int r = lookupService(service, ref); + if (r) + service = 0; // check resources... - ptr = new eDVBServicePlay(ref); + ptr = new eDVBServicePlay(ref, service); return 0; } -RESULT eServiceFactoryDVB::record(const eServiceReference &, ePtr &ptr) +RESULT eServiceFactoryDVB::record(const eServiceReference &ref, ePtr &ptr) { - ptr = 0; - return -1; + ptr = new eDVBServiceRecord((eServiceReferenceDVB&)ref); + return 0; } RESULT eServiceFactoryDVB::list(const eServiceReference &ref, ePtr &ptr) @@ -97,7 +134,25 @@ RESULT eServiceFactoryDVB::list(const eServiceReference &ref, ePtr &ptr) { - ptr = 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) +{ // TODO: handle the listing itself // if (ref.... == -1) .. return "... bouquets ..."; // could be also done in another serviceFactory (with seperate ID) to seperate actual services and lists @@ -117,22 +172,18 @@ RESULT eServiceFactoryDVB::info(const eServiceReference &ref, ePtr service; - /* we are sure to have a ..DVB reference as the info() call was forwarded here according to it's ID. */ if ((err = db->getService((eServiceReferenceDVB&)ref, service)) != 0) { eDebug("getService failed!"); return err; } - - /* eDVBService has the iStaticServiceInformation interface, so we pass it here. */ - ptr = service; + return 0; } -eDVBServicePlay::eDVBServicePlay(const eServiceReference &ref): - m_reference(ref) +eDVBServicePlay::eDVBServicePlay(const eServiceReference &ref, eDVBService *service): + m_reference(ref), m_dvb_service(service) { CONNECT(m_service_handler.serviceEvent, eDVBServicePlay::serviceEvent); CONNECT(m_event_handler.m_eit_changed, eDVBServicePlay::gotNewEvent); @@ -236,6 +287,12 @@ void eDVBServicePlay::serviceEvent(int event) m_decoder->setAudioPID(apid, 0); m_decoder->setSyncPCR(pcrpid); 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; @@ -246,6 +303,7 @@ void eDVBServicePlay::serviceEvent(int event) RESULT eDVBServicePlay::start() { eDebug("starting DVB service"); + m_event(this, evStart); return m_service_handler.tune((eServiceReferenceDVB&)m_reference); } @@ -274,9 +332,12 @@ RESULT eDVBServicePlay::info(ePtr &ptr) return 0; } -RESULT eDVBServicePlay::getName(const eServiceReference &ref, std::string &name) +RESULT eDVBServicePlay::getName(std::string &name) { - name = "DVB service"; + if (m_dvb_service) + m_dvb_service->getName(m_reference, name); + else + name = "DVB service"; return 0; }