add SeekRelative stuff
[enigma2.git] / lib / service / servicedvb.cpp
index fdf93d7..76b0089 100644 (file)
@@ -173,11 +173,10 @@ RESULT eDVBPVRServiceOfflineOperations::getListOfFilenames(std::list<std::string
 {
        res.clear();
        res.push_back(m_ref.path);
+       res.push_back(m_ref.path + ".meta");
        return 0;
 }
 
-
-
 DEFINE_REF(eServiceFactoryDVB)
 
 eServiceFactoryDVB::eServiceFactoryDVB()
@@ -227,7 +226,7 @@ RESULT eDVBServiceList::startQuery()
        
        ePtr<eDVBChannelQuery> q;
        
-       if (m_parent.path.size())
+       if (!m_parent.path.empty())
        {
                eDVBChannelQuery::compile(q, m_parent.path);
                if (!q)
@@ -284,8 +283,15 @@ RESULT eServiceFactoryDVB::play(const eServiceReference &ref, ePtr<iPlayableServ
 
 RESULT eServiceFactoryDVB::record(const eServiceReference &ref, ePtr<iRecordableService> &ptr)
 {
-       ptr = new eDVBServiceRecord((eServiceReferenceDVB&)ref);
-       return 0;
+       if (ref.path.empty())
+       {
+               ptr = new eDVBServiceRecord((eServiceReferenceDVB&)ref);
+               return 0;
+       } else
+       {
+               ptr = 0;
+               return -1;
+       }
 }
 
 RESULT eServiceFactoryDVB::list(const eServiceReference &ref, ePtr<iListableService> &ptr)
@@ -309,7 +315,7 @@ RESULT eServiceFactoryDVB::info(const eServiceReference &ref, ePtr<iStaticServic
                ptr = new eStaticServiceDVBBouquetInformation;
                return 0;
        }
-       else if (ref.path.size())
+       else if (!ref.path.empty())
        {
                ptr = new eStaticServiceDVBPVRInformation(ref);
                return 0;
@@ -327,10 +333,17 @@ RESULT eServiceFactoryDVB::info(const eServiceReference &ref, ePtr<iStaticServic
        }
 }
 
-RESULT eServiceFactoryDVB::offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr)
+RESULT eServiceFactoryDVB::offlineOperations(const eServiceReference &ref, ePtr<iServiceOfflineOperations> &ptr)
 {
-       ptr = 0;
-       return -1;
+       if (ref.path.empty())
+       {
+               ptr = 0;
+               return -1;
+       } else
+       {
+               ptr = new eDVBPVRServiceOfflineOperations(ref);
+               return 0;
+       }
 }
 
 RESULT eServiceFactoryDVB::lookupService(ePtr<eDVBService> &service, const eServiceReference &ref)
@@ -365,7 +378,7 @@ RESULT eServiceFactoryDVB::lookupService(ePtr<eDVBService> &service, const eServ
 }
 
 eDVBServicePlay::eDVBServicePlay(const eServiceReference &ref, eDVBService *service): 
-       m_reference(ref), m_dvb_service(service), m_service_handler(0)
+       m_reference(ref), m_dvb_service(service), m_service_handler(0), m_is_paused(0)
 {
        m_is_pvr = !ref.path.empty();
        
@@ -518,7 +531,12 @@ RESULT eDVBServicePlay::connectEvent(const Slot2<void,iPlayableService*,int> &ev
 
 RESULT eDVBServicePlay::pause(ePtr<iPauseableService> &ptr)
 {
-               // not yet possible, maybe later...
+       if (m_is_pvr)
+       {
+               ptr = this;
+               return 0;
+       }
+
        ptr = 0;
        return -1;
 }
@@ -548,11 +566,43 @@ RESULT eDVBServicePlay::getLength(pts_t &len)
        return pvr_channel->getLength(len);
 }
 
+RESULT eDVBServicePlay::pause()
+{
+       if (!m_is_paused && m_decoder)
+       {
+               m_is_paused = 1;
+               return m_decoder->freeze(0);
+       } else
+               return -1;
+}
+
+RESULT eDVBServicePlay::unpause()
+{
+       if (m_is_paused && m_decoder)
+       {
+               m_is_paused = 0;
+               return m_decoder->unfreeze();
+       } else
+               return -1;
+}
+
 RESULT eDVBServicePlay::seekTo(pts_t to)
 {
        return -1;
 }
 
+RESULT eDVBServicePlay::seekRelative(int direction, pts_t to)
+{
+       eDebug("eDVBServicePlay::seekRelative: jump %d, %lld", direction, to);
+
+       ePtr<iDVBPVRChannel> pvr_channel;
+       
+       if (m_service_handler.getPVRChannel(pvr_channel))
+               return -1;
+       
+       return pvr_channel->seekToPosition(SEEK_CUR, to);
+}
+
 RESULT eDVBServicePlay::getPlayPosition(pts_t &pos)
 {
        ePtr<iDVBPVRChannel> pvr_channel;