aboutsummaryrefslogtreecommitdiff
path: root/lib/service
diff options
context:
space:
mode:
Diffstat (limited to 'lib/service')
-rw-r--r--lib/service/iservice.h16
-rw-r--r--lib/service/service.cpp10
-rw-r--r--lib/service/servicedvb.cpp67
-rw-r--r--lib/service/servicedvb.h9
-rw-r--r--lib/service/servicedvbrecord.cpp60
-rw-r--r--lib/service/servicemp3.h3
6 files changed, 131 insertions, 34 deletions
diff --git a/lib/service/iservice.h b/lib/service/iservice.h
index 962e4a95..285063ec 100644
--- a/lib/service/iservice.h
+++ b/lib/service/iservice.h
@@ -180,6 +180,9 @@ public:
virtual SWIG_VOID(RESULT) getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &SWIG_OUTPUT, time_t start_time=0);
// returns true when not implemented
virtual bool isPlayable(const eServiceReference &ref, const eServiceReference &ignore);
+
+ virtual int getInfo(const eServiceReference &ref, int w);
+ virtual std::string getInfoString(const eServiceReference &ref,int w);
};
TEMPLATE_TYPEDEF(ePtr<iStaticServiceInformation>, iStaticServiceInformationPtr);
@@ -216,6 +219,9 @@ public:
sTSID,
sNamespace,
sProvider,
+
+ sDescription,
+ sTimeCreate, // unix time or string
};
enum { resNA = -1, resIsString = -2 };
@@ -293,6 +299,15 @@ public:
TEMPLATE_TYPEDEF(ePtr<iSubserviceList>, iSubserviceListPtr);
+class iTimeshiftService: public iObject
+{
+public:
+ virtual RESULT startTimeshift()=0;
+ virtual RESULT stopTimeshift()=0;
+};
+
+TEMPLATE_TYPEDEF(ePtr<iTimeshiftService>, iTimeshiftServicePtr);
+
class iPlayableService: public iObject
{
friend class iServiceHandler;
@@ -316,6 +331,7 @@ public:
virtual SWIG_VOID(RESULT) audioTracks(ePtr<iAudioTrackSelection> &SWIG_OUTPUT)=0;
virtual SWIG_VOID(RESULT) subServices(ePtr<iSubserviceList> &SWIG_OUTPUT)=0;
virtual SWIG_VOID(RESULT) frontendStatusInfo(ePtr<iFrontendStatusInformation> &SWIG_OUTPUT)=0;
+ virtual SWIG_VOID(RESULT) timeshift(ePtr<iTimeshiftService> &SWIG_OUTPUT)=0;
};
TEMPLATE_TYPEDEF(ePtr<iPlayableService>, iPlayableServicePtr);
diff --git a/lib/service/service.cpp b/lib/service/service.cpp
index cc8a9315..150a0cd3 100644
--- a/lib/service/service.cpp
+++ b/lib/service/service.cpp
@@ -155,6 +155,16 @@ RESULT iServiceInformation::getEvent(ePtr<eServiceEvent> &evt, int m_nownext)
return -1;
}
+int iStaticServiceInformation::getInfo(const eServiceReference &ref, int w)
+{
+ return -1;
+}
+
+std::string iStaticServiceInformation::getInfoString(const eServiceReference &ref, int w)
+{
+ return "";
+}
+
int iServiceInformation::getInfo(int w)
{
return -1;
diff --git a/lib/service/servicedvb.cpp b/lib/service/servicedvb.cpp
index a9d235ec..790bfca6 100644
--- a/lib/service/servicedvb.cpp
+++ b/lib/service/servicedvb.cpp
@@ -127,6 +127,9 @@ public:
eStaticServiceDVBPVRInformation(const eServiceReference &ref);
RESULT getName(const eServiceReference &ref, std::string &name);
int getLength(const eServiceReference &ref);
+
+ int getInfo(const eServiceReference &ref, int w);
+ std::string getInfoString(const eServiceReference &ref,int w);
};
DEFINE_REF(eStaticServiceDVBPVRInformation);
@@ -160,7 +163,32 @@ int eStaticServiceDVBPVRInformation::getLength(const eServiceReference &ref)
return len / 90000;
}
+int eStaticServiceDVBPVRInformation::getInfo(const eServiceReference &ref, int w)
+{
+ switch (w)
+ {
+ case iServiceInformation::sDescription:
+ return iServiceInformation::resIsString;
+ case iServiceInformation::sTimeCreate:
+ if (m_parser.m_time_create)
+ return m_parser.m_time_create;
+ else
+ return iServiceInformation::resNA;
+ default:
+ return iServiceInformation::resNA;
+ }
+}
+std::string eStaticServiceDVBPVRInformation::getInfoString(const eServiceReference &ref,int w)
+{
+ switch (w)
+ {
+ case iServiceInformation::sDescription:
+ return m_parser.m_description;
+ default:
+ return "";
+ }
+}
class eDVBPVRServiceOfflineOperations: public iServiceOfflineOperations
{
@@ -459,6 +487,7 @@ eDVBServicePlay::eDVBServicePlay(const eServiceReference &ref, eDVBService *serv
m_reference(ref), m_dvb_service(service), m_service_handler(0), m_is_paused(0)
{
m_is_pvr = !ref.path.empty();
+ m_timeshift_enabled = 0;
CONNECT(m_service_handler.serviceEvent, eDVBServicePlay::serviceEvent);
CONNECT(m_event_handler.m_eit_changed, eDVBServicePlay::gotNewEvent);
@@ -619,14 +648,14 @@ RESULT eDVBServicePlay::connectEvent(const Slot2<void,iPlayableService*,int> &ev
RESULT eDVBServicePlay::pause(ePtr<iPauseableService> &ptr)
{
- if (m_is_pvr)
+ if (!m_is_pvr)
{
- ptr = this;
- return 0;
+ ptr = 0;
+ return -1;
}
- ptr = 0;
- return -1;
+ ptr = this;
+ return 0;
}
RESULT eDVBServicePlay::setSlowMotion(int ratio)
@@ -753,6 +782,17 @@ RESULT eDVBServicePlay::subServices(ePtr<iSubserviceList> &ptr)
return 0;
}
+RESULT eDVBServicePlay::timeshift(ePtr<iTimeshiftService> &ptr)
+{
+ if (m_timeshift_enabled || !m_is_pvr)
+ {
+ ptr = this;
+ return 0;
+ }
+ ptr = 0;
+ return -1;
+}
+
RESULT eDVBServicePlay::getName(std::string &name)
{
if (m_dvb_service)
@@ -939,6 +979,23 @@ RESULT eDVBServicePlay::getSubservice(eServiceReference &sub, unsigned int n)
return -1;
}
+RESULT eDVBServicePlay::startTimeshift()
+{
+ if (m_timeshift_enabled)
+ return -1;
+ eDebug("TIMESHIFT - start!");
+ return 0;
+}
+
+RESULT eDVBServicePlay::stopTimeshift()
+{
+ if (!m_timeshift_enabled)
+ return -1;
+ m_timeshift_enabled = 0;
+ eDebug("timeshift disabled");
+ return 0;
+}
+
DEFINE_REF(eDVBServicePlay)
eAutoInitPtr<eServiceFactoryDVB> init_eServiceFactoryDVB(eAutoInitNumbers::service+1, "eServiceFactoryDVB");
diff --git a/lib/service/servicedvb.h b/lib/service/servicedvb.h
index 6b93469d..e99faffd 100644
--- a/lib/service/servicedvb.h
+++ b/lib/service/servicedvb.h
@@ -55,7 +55,7 @@ private:
class eDVBServicePlay: public iPlayableService, public iPauseableService,
public iSeekableService, public Object, public iServiceInformation,
public iAudioTrackSelection, public iFrontendStatusInformation,
- public iSubserviceList
+ public iSubserviceList, public iTimeshiftService
{
DECLARE_REF(eDVBServicePlay);
public:
@@ -71,6 +71,7 @@ public:
RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr);
RESULT frontendStatusInfo(ePtr<iFrontendStatusInformation> &ptr);
RESULT subServices(ePtr<iSubserviceList> &ptr);
+ RESULT timeshift(ePtr<iTimeshiftService> &ptr);
// iPauseableService
RESULT pause();
@@ -102,6 +103,10 @@ public:
int getNumberOfSubservices();
RESULT getSubservice(eServiceReference &subservice, unsigned int n);
+ // iTimeshiftService
+ RESULT startTimeshift();
+ RESULT stopTimeshift();
+
private:
friend class eServiceFactoryDVB;
eServiceReference m_reference;
@@ -120,7 +125,7 @@ private:
void serviceEvent(int event);
Signal2<void,iPlayableService*,int> m_event;
- int m_is_pvr, m_is_paused;
+ int m_is_pvr, m_is_paused, m_timeshift_enabled;
int m_current_audio_stream;
int selectAudioStream(int n);
diff --git a/lib/service/servicedvbrecord.cpp b/lib/service/servicedvbrecord.cpp
index 2f1dea0e..f05a35a3 100644
--- a/lib/service/servicedvbrecord.cpp
+++ b/lib/service/servicedvbrecord.cpp
@@ -20,6 +20,33 @@ void eDVBServiceRecord::serviceEvent(int event)
case eDVBServicePMTHandler::eventTuned:
{
eDebug("tuned..");
+ if (!m_record)
+ {
+ eDebug("Recording to %s...", m_filename.c_str());
+ ::remove(m_filename.c_str());
+ int fd = ::open(m_filename.c_str(), O_WRONLY|O_CREAT, 0644);
+ if (fd == -1)
+ {
+ eDebug("eDVBServiceRecord - can't open hardcoded recording file!");
+ return;
+// return -1;
+ }
+ ePtr<iDVBDemux> demux;
+ if (m_service_handler.getDemux(demux))
+ {
+ eDebug("eDVBServiceRecord - NO DEMUX available!");
+ return;
+// return -2;
+ }
+ demux->createTSRecorder(m_record);
+ if (!m_record)
+ {
+ eDebug("eDVBServiceRecord - no ts recorder available.");
+ return;
+// return -3;
+ }
+ m_record->setTargetFD(fd);
+ }
break;
}
case eDVBServicePMTHandler::eventNewProgramInfo:
@@ -38,7 +65,7 @@ RESULT eDVBServiceRecord::prepare(const char *filename)
{
m_filename = filename;
if (m_state == stateIdle)
- return m_service_handler.tune(m_ref);
+ doPrepare();
else
return -1;
}
@@ -74,33 +101,9 @@ int eDVBServiceRecord::doPrepare()
/* allocate a ts recorder if we don't already have one. */
if (m_state == stateIdle)
{
- eDebug("Recording to %s...", m_filename.c_str());
- ::remove(m_filename.c_str());
- int fd = ::open(m_filename.c_str(), O_WRONLY|O_CREAT, 0644);
- if (fd == -1)
- {
- eDebug("eDVBServiceRecord - can't open hardcoded recording file!");
- return -1;
- }
- ePtr<iDVBDemux> demux;
- if (m_service_handler.getDemux(demux))
- {
- eDebug("eDVBServiceRecord - NO DEMUX available!");
- return -2;
- }
- demux->createTSRecorder(m_record);
- if (!m_record)
- {
- eDebug("eDVBServiceRecord - no ts recorder available.");
- return -3;
- }
- m_record->setTargetFD(fd);
m_pids_active.clear();
m_state = statePrepared;
- } else if ((m_state == statePrepared) || (m_state == stateRecording))
- {
- /* when we're already recording, we already have a recorder allocated. */
- assert(m_record);
+ m_service_handler.tune(m_ref);
}
return 0;
}
@@ -111,6 +114,11 @@ int eDVBServiceRecord::doRecord()
if (err)
return err;
+ if (!m_record)
+ {
+ eDebug("demux not available (tune failed?). cannot record.");
+ return -1;
+ }
eDebug("starting recording..");
eDVBServicePMTHandler::program program;
diff --git a/lib/service/servicemp3.h b/lib/service/servicemp3.h
index ac174c41..c08278b8 100644
--- a/lib/service/servicemp3.h
+++ b/lib/service/servicemp3.h
@@ -64,7 +64,8 @@ public:
RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr) { ptr = 0; return -1; }
RESULT frontendStatusInfo(ePtr<iFrontendStatusInformation> &ptr) { ptr = 0; return -1; }
RESULT subServices(ePtr<iSubserviceList> &ptr) { ptr = 0; return -1; }
-
+ RESULT timeshift(ePtr<iTimeshiftService> &ptr) { ptr = 0; return -1; }
+
// iPausableService
RESULT pause();
RESULT unpause();