add iCueSheet interface and null implementation
[enigma2.git] / lib / service / servicedvb.cpp
index d1cc4ef83bedc2f7a695b0ea303e8ffe80f7a351..76abbd3805120669c331898da1420e9ff533d08d 100644 (file)
 #include <lib/dvb/tstools.h>
 #include <lib/python/python.h>
 
+#include <sys/vfs.h>
+
+#define TSPATH "/media/hdd"
+
 class eStaticServiceDVBInformation: public iStaticServiceInformation
 {
        DECLARE_REF(eStaticServiceDVBInformation);
@@ -685,7 +689,7 @@ RESULT eDVBServicePlay::setFastForward(int ratio)
        {
                skipmode = 0;
                ffratio = 0;
-       } else if (ratio < 0)
+       } else // if (ratio < 0)
        {
                skipmode = ratio;
                ffratio = 1;
@@ -708,7 +712,7 @@ RESULT eDVBServicePlay::setFastForward(int ratio)
     
 RESULT eDVBServicePlay::seek(ePtr<iSeekableService> &ptr)
 {
-       if (m_is_pvr || m_timeshift_active)
+       if (m_is_pvr || m_timeshift_enabled)
        {
                ptr = this;
                return 0;
@@ -718,15 +722,13 @@ RESULT eDVBServicePlay::seek(ePtr<iSeekableService> &ptr)
        return -1;
 }
 
+       /* TODO: when timeshift is enabled but not active, this doesn't work. */
 RESULT eDVBServicePlay::getLength(pts_t &len)
 {
        ePtr<iDVBPVRChannel> pvr_channel;
        
-       if (m_service_handler.getPVRChannel(pvr_channel))
-       {
-               eDebug("getPVRChannel failed!");
+       if ((m_timeshift_enabled ? m_service_handler_timeshift : m_service_handler).getPVRChannel(pvr_channel))
                return -1;
-       }
        
        return pvr_channel->getLength(len);
 }
@@ -811,6 +813,11 @@ RESULT eDVBServicePlay::setTrickmode(int trick)
        return 0;
 }
 
+RESULT eDVBServicePlay::isCurrentlySeekable()
+{
+       return m_is_pvr || m_timeshift_active;
+}
+
 RESULT eDVBServicePlay::frontendStatusInfo(ePtr<iFrontendStatusInformation> &ptr)
 {
        ptr = this;
@@ -837,7 +844,34 @@ RESULT eDVBServicePlay::subServices(ePtr<iSubserviceList> &ptr)
 
 RESULT eDVBServicePlay::timeshift(ePtr<iTimeshiftService> &ptr)
 {
+       ptr = 0;
        if (m_timeshift_enabled || !m_is_pvr)
+       {
+               if (!m_timeshift_enabled)
+               {
+                               /* we need enough diskspace */
+                       struct statfs fs;
+                       if (statfs(TSPATH "/.", &fs) < 0)
+                       {
+                               eDebug("statfs failed!");
+                               return -2;
+                       }
+               
+                       if (((off_t)fs.f_bavail) * ((off_t)fs.f_bsize) < 1024*1024*1024LL)
+                       {
+                               eDebug("not enough diskspace for timeshift! (less than 1GB)");
+                               return -3;
+                       }
+               }
+               ptr = this;
+               return 0;
+       }
+       return -1;
+}
+
+RESULT eDVBServicePlay::cueSheet(ePtr<iCueSheet> &ptr)
+{
+       if (m_is_pvr)
        {
                ptr = this;
                return 0;
@@ -1085,7 +1119,7 @@ RESULT eDVBServicePlay::startTimeshift()
        if (!m_record)
                return -3;
 
-       char templ[]="/media/hdd/timeshift.XXXXXX";
+       char templ[]=TSPATH "/timeshift.XXXXXX";
        m_timeshift_fd = mkstemp(templ);
        m_timeshift_file = templ;
        
@@ -1120,6 +1154,7 @@ RESULT eDVBServicePlay::stopTimeshift()
        m_record = 0;
        
        close(m_timeshift_fd);
+       eDebug("remove timeshift file");
        remove(m_timeshift_file.c_str());
        
        return 0;
@@ -1144,6 +1179,23 @@ RESULT eDVBServicePlay::activateTimeshift()
        return -2;
 }
 
+PyObject *eDVBServicePlay::getCutList()
+{
+       PyObject *list = PyList_New(0);
+       
+       return list;
+}
+
+RESULT eDVBServicePlay::addCut(const pts_t &when, int what)
+{
+       return -1;
+}
+
+RESULT eDVBServicePlay::removeCut(const pts_t &when, int what)
+{
+       return -1;
+}
+
 void eDVBServicePlay::updateTimeshiftPids()
 {
        if (!m_record)