#include <lib/service/servicedvbrecord.h>
#include <lib/dvb/metaparser.h>
+#include <lib/dvb/tstools.h>
class eStaticServiceDVBPVRInformation: public iStaticServiceInformation
{
public:
eStaticServiceDVBPVRInformation(const eServiceReference &ref);
RESULT getName(const eServiceReference &ref, std::string &name);
+ int getLength(const eServiceReference &ref);
};
DEFINE_REF(eStaticServiceDVBPVRInformation);
name = m_parser.m_name.size() ? m_parser.m_name : ref.path;
}
+int eStaticServiceDVBPVRInformation::getLength(const eServiceReference &ref)
+{
+ ASSERT(ref == m_ref);
+
+ eDVBTSTools tstools;
+
+ if (tstools.openFile(ref.path.c_str()))
+ return 0;
+
+ pts_t len;
+ if (tstools.calcLen(len))
+ return 0;
+
+ return len / 90000;
+}
+
+
+
+class eDVBPVRServiceOfflineOperations: public iServiceOfflineOperations
+{
+ DECLARE_REF(eDVBPVRServiceOfflineOperations);
+ eServiceReferenceDVB m_ref;
+public:
+ eDVBPVRServiceOfflineOperations(const eServiceReference &ref);
+
+ RESULT deleteFromDisk(int simulate);
+ RESULT getListOfFilenames(std::list<std::string> &);
+};
+
+DEFINE_REF(eDVBPVRServiceOfflineOperations);
+
+eDVBPVRServiceOfflineOperations::eDVBPVRServiceOfflineOperations(const eServiceReference &ref): m_ref((const eServiceReferenceDVB&)ref)
+{
+}
+
+RESULT eDVBPVRServiceOfflineOperations::deleteFromDisk(int simulate)
+{
+ if (simulate)
+ return 0;
+ else
+ {
+ std::list<std::string> res;
+ if (getListOfFilenames(res))
+ return -1;
+
+ /* TODO: deferred removing.. */
+ for (std::list<std::string>::iterator i(res.begin()); i != res.end(); ++i)
+ {
+ eDebug("Removing %s...", i->c_str());
+ ::unlink(i->c_str());
+ }
+
+ return 0;
+ }
+}
+
+RESULT eDVBPVRServiceOfflineOperations::getListOfFilenames(std::list<std::string> &res)
+{
+ res.clear();
+ res.push_back(m_ref.path);
+ return 0;
+}
+
+
+
DEFINE_REF(eServiceFactoryDVB)
eServiceFactoryDVB::eServiceFactoryDVB()
}
}
+RESULT eServiceFactoryDVB::offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr)
+{
+ ptr = 0;
+ return -1;
+}
+
RESULT eServiceFactoryDVB::lookupService(ePtr<eDVBService> &service, const eServiceReference &ref)
{
// TODO: handle the listing itself
eDVBServicePlay::eDVBServicePlay(const eServiceReference &ref, eDVBService *service):
m_reference(ref), m_dvb_service(service)
{
+ m_is_pvr = !ref.path.empty();
+
CONNECT(m_service_handler.serviceEvent, eDVBServicePlay::serviceEvent);
CONNECT(m_event_handler.m_eit_changed, eDVBServicePlay::gotNewEvent);
eDebug("DVB start (play)");
{
m_decoder->setVideoPID(vpid);
m_decoder->setAudioPID(apid, 0);
- m_decoder->setSyncPCR(pcrpid);
+ if (!m_is_pvr)
+ m_decoder->setSyncPCR(pcrpid);
+ else
+ m_decoder->setSyncPCR(-1);
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);
+
+ /* don't worry about non-existing services, nor pvr services */
+ if (m_dvb_service && !m_is_pvr)
+ {
+ m_dvb_service->setCachePID(eDVBService::cVPID, vpid);
+ m_dvb_service->setCachePID(eDVBService::cAPID, apid);
+ m_dvb_service->setCachePID(eDVBService::cPCRPID, pcrpid);
+ }
}
break;
RESULT eDVBServicePlay::start()
{
+ int r;
eDebug("starting DVB service");
+ r = m_service_handler.tune((eServiceReferenceDVB&)m_reference);
m_event(this, evStart);
- return m_service_handler.tune((eServiceReferenceDVB&)m_reference);
}
RESULT eDVBServicePlay::stop()
return -1;
}
+RESULT eDVBServicePlay::seek(ePtr<iSeekableService> &ptr)
+{
+ if (m_is_pvr)
+ {
+ ptr = this;
+ return 0;
+ }
+
+ ptr = 0;
+ return -1;
+}
+
+RESULT eDVBServicePlay::getLength(pts_t &len)
+{
+ ePtr<iDVBPVRChannel> pvr_channel;
+
+ if (m_service_handler.getPVRChannel(pvr_channel))
+ {
+ eDebug("getPVRChannel failed!");
+ return -1;
+ }
+
+ return pvr_channel->getLength(len);
+}
+
+RESULT eDVBServicePlay::seekTo(pts_t to)
+{
+ return -1;
+}
+
+RESULT eDVBServicePlay::getPlayPosition(pts_t &pos)
+{
+ ePtr<iDVBPVRChannel> pvr_channel;
+
+ if (m_service_handler.getPVRChannel(pvr_channel))
+ return -1;
+
+ return pvr_channel->getCurrentPosition(pos);
+}
+
RESULT eDVBServicePlay::info(ePtr<iServiceInformation> &ptr)
{
ptr = this;