return 0;
}
+RESULT eDVBDemux::getSTC(pts_t &pts)
+{
+ char filename[128];
+#if HAVE_DVB_API_VERSION < 3
+ sprintf(filename, "/dev/dvb/card%d/demux%d", adapter, demux);
+#else
+ sprintf(filename, "/dev/dvb/adapter%d/demux%d", adapter, demux);
+#endif
+ int fd = ::open(filename, O_RDWR);
+
+ if (fd < 0)
+ return -ENODEV;
+
+ struct dmx_stc stc;
+ stc.num = 0;
+ stc.base = 1;
+
+ if (ioctl(fd, DMX_GET_STC, &stc) < 0)
+ {
+ ::close(fd);
+ return -1;
+ }
+
+ pts = stc.stc;
+ eDebug("got demux stc: %08llx", pts);
+
+ ::close(fd);
+
+ return 0;
+}
+
+
void eDVBSectionReader::data(int)
{
__u8 data[4096]; // max. section size
RESULT createSectionReader(eMainloop *context, ePtr<iDVBSectionReader> &reader);
RESULT createTSRecorder(ePtr<iDVBTSRecorder> &recorder);
RESULT getMPEGDecoder(ePtr<iTSMPEGDecoder> &reader);
+ RESULT getSTC(pts_t &pts);
};
class eDVBSectionReader: public iDVBSectionReader, public Object
RESULT eDVBChannel::getCurrentPosition(pts_t &pos)
{
-#if 0
off_t begin = 0;
/* getPTS for offset 0 is cached, so it doesn't harm. */
int r = m_tstools.getPTS(begin, pos);
if (r)
+ {
+ eDebug("tstools getpts(0) failed!");
return r;
+ }
+
+ pts_t now;
+
+ r = m_demux->get().getSTC(now);
+
+ if (r)
+ {
+ eDebug("demux getSTC failed");
+ return -1;
+ }
+
+ eDebug("STC: %08llx PTS: %08llx, diff %lld", now, pos, now - pos);
+
+ /* when we are less than 10 seconds before the start, return 0. */
+ /* (we're just waiting for the timespam to start) */
+ if ((now < pos) && ((pos - now) < 90000 * 10))
+ {
+ pos = 0;
+ return 0;
+ }
+
+ if (now < pos) /* wrap around */
+ pos = now + ((pts_t)1)<<33 - pos;
+ else
+ pos = now - pos;
- // DMX_GET_STC
-#endif
return 0;
}
/* so this is VERY UGLY. */
virtual RESULT playFile(const char *file) = 0;
- virtual RESULT getLength(pts_t &len) = 0;
+ virtual RESULT getLength(pts_t &pts) = 0;
virtual RESULT getCurrentPosition(pts_t &pos) = 0;
// seekTo ...
virtual RESULT createSectionReader(eMainloop *context, ePtr<iDVBSectionReader> &reader)=0;
virtual RESULT createTSRecorder(ePtr<iDVBTSRecorder> &recorder)=0;
virtual RESULT getMPEGDecoder(ePtr<iTSMPEGDecoder> &reader)=0;
+ virtual RESULT getSTC(pts_t &pts)=0;
};
class iTSMPEGDecoder: public iObject
return -1;
}
+int eDVBServicePMTHandler::getPVRChannel(ePtr<iDVBPVRChannel> &pvr_channel)
+{
+ pvr_channel = m_pvr_channel;
+ if (pvr_channel)
+ return 0;
+ else
+ return -1;
+}
+
int eDVBServicePMTHandler::tune(eServiceReferenceDVB &ref)
{
RESULT res;
int getProgramInfo(struct program &program);
int getDemux(ePtr<iDVBDemux> &demux);
+ int getPVRChannel(ePtr<iDVBPVRChannel> &pvr_channel);
int tune(eServiceReferenceDVB &ref);
};
#ifndef __lib_dvb_tstools_h
#define __lib_dvb_tstools_h
+#include <config.h>
#include <sys/types.h>
/*
#ifndef __lib_dvb_iservice_h
#define __lib_dvb_iservice_h
+#include <lib/python/swig.h>
#include <lib/base/object.h>
#include <string>
#include <connection.h>
TEMPLATE_TYPEDEF(ePtr<iPauseableService>, iPauseableServicePtr);
+class iSeekableService: public iObject
+{
+public:
+ virtual RESULT getLength(pts_t &SWIG_OUTPUT)=0;
+ virtual RESULT seekTo(pts_t to)=0;
+ virtual RESULT getPlayPosition(pts_t &SWIG_OUTPUT)=0;
+};
+
+TEMPLATE_TYPEDEF(ePtr<iSeekableService>, iSeekableServicePtr);
+
class iPlayableService: public iObject
{
friend class iServiceHandler;
virtual RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection)=0;
virtual RESULT start()=0;
virtual RESULT stop()=0;
+ virtual RESULT seek(ePtr<iSeekableService> &ptr)=0;
virtual RESULT pause(ePtr<iPauseableService> &ptr)=0;
virtual RESULT info(ePtr<iServiceInformation> &ptr)=0;
};
// 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;
RESULT getNext(eServiceReference &ptr);
};
-class eDVBServicePlay: public iPlayableService, public Object, public iServiceInformation
+class eDVBServicePlay: public iPlayableService, iSeekableService, public Object, public iServiceInformation
{
DECLARE_REF(eDVBServicePlay);
private:
RESULT connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection);
RESULT start();
RESULT stop();
+ RESULT seek(ePtr<iSeekableService> &ptr);
RESULT pause(ePtr<iPauseableService> &ptr);
RESULT info(ePtr<iServiceInformation> &ptr);
+ // iSeekableService
+ RESULT getLength(pts_t &len);
+ RESULT seekTo(pts_t to);
+ RESULT getPlayPosition(pts_t &pos);
+
// iServiceInformation
RESULT getName(std::string &name);
RESULT getEvent(ePtr<eServiceEvent> &evt, int nownext);
}
RESULT eServiceMP3::pause(ePtr<iPauseableService> &ptr) { ptr=this; return 0; }
+RESULT eServiceMP3::seek(ePtr<iSeekableService> &ptr) { ptr = 0; return -1; }
// iPausableService
RESULT eServiceMP3::pause() { printf("mp3 pauses!\n"); return 0; }
RESULT start();
RESULT stop();
RESULT pause(ePtr<iPauseableService> &ptr);
+ RESULT seek(ePtr<iSeekableService> &ptr);
// iPausableService
RESULT pause();