more pid cache stuff
[enigma2.git] / lib / service / servicedvb.cpp
index 5bd25f6..5618477 100644 (file)
 #include <lib/dvb/db.h>
 
 #include <lib/service/servicedvbrecord.h>
+#include <lib/dvb/metaparser.h>
+
+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)
 
@@ -109,13 +134,21 @@ RESULT eServiceFactoryDVB::list(const eServiceReference &ref, ePtr<iListableServ
 
 RESULT eServiceFactoryDVB::info(const eServiceReference &ref, ePtr<iStaticServiceInformation> &ptr)
 {
-       ePtr<eDVBService> 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<eDVBService> 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<eDVBService> &service, const eServiceReference &ref)
@@ -254,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;