1 #include <lib/base/eerror.h>
2 #include <lib/base/object.h>
4 #include <lib/service/servicedvb.h>
5 #include <lib/service/service.h>
6 #include <lib/base/init_num.h>
7 #include <lib/base/init.h>
9 DEFINE_REF(eServiceFactoryDVB)
11 eServiceFactoryDVB::eServiceFactoryDVB()
13 ePtr<eServiceCenter> sc;
15 eServiceCenter::getInstance(sc);
17 sc->addServiceFactory(eServiceFactoryDVB::id, this);
20 eServiceFactoryDVB::~eServiceFactoryDVB()
22 ePtr<eServiceCenter> sc;
24 eServiceCenter::getInstance(sc);
26 sc->removeServiceFactory(eServiceFactoryDVB::id);
29 RESULT eServiceFactoryDVB::play(const eServiceReference &ref, ePtr<iPlayableService> &ptr)
32 ptr = new eDVBServicePlay(ref);
36 RESULT eServiceFactoryDVB::record(const eServiceReference &, ePtr<iRecordableService> &ptr)
42 RESULT eServiceFactoryDVB::list(const eServiceReference &, ePtr<iListableService> &ptr)
48 eDVBServicePlay::eDVBServicePlay(const eServiceReference &ref):
51 CONNECT(m_serviceHandler.serviceEvent, eDVBServicePlay::serviceEvent);
52 eDebug("DVB start (play)");
55 eDVBServicePlay::~eDVBServicePlay()
57 eDebug("DVB stop (play)");
60 void eDVBServicePlay::serviceEvent(int event)
62 eDebug("service event %d", event);
65 case eDVBServicePMTHandler::eventNewProgramInfo:
67 int vpid = -1, apid = -1, pcrpid = -1;
68 eDVBServicePMTHandler::program program;
69 if (m_serviceHandler.getProgramInfo(program))
70 eDebug("getting program info failed.");
73 eDebugNoNewLine("have %d video stream(s)", program.videoStreams.size());
74 if (!program.videoStreams.empty())
76 eDebugNoNewLine(" (");
77 for (std::vector<eDVBServicePMTHandler::videoStream>::const_iterator
78 i(program.videoStreams.begin());
79 i != program.videoStreams.end(); ++i)
83 if (i != program.videoStreams.begin())
84 eDebugNoNewLine(", ");
85 eDebugNoNewLine("%04x", i->pid);
89 eDebugNoNewLine(", and %d audio stream(s)", program.audioStreams.size());
90 if (!program.audioStreams.empty())
92 eDebugNoNewLine(" (");
93 for (std::vector<eDVBServicePMTHandler::audioStream>::const_iterator
94 i(program.audioStreams.begin());
95 i != program.audioStreams.end(); ++i)
99 if (i != program.audioStreams.begin())
100 eDebugNoNewLine(", ");
101 eDebugNoNewLine("%04x", i->pid);
103 eDebugNoNewLine(")");
105 eDebug(", and the pcr pid is %04x", program.pcrPid);
106 if (program.pcrPid != 0x1fff)
107 pcrpid = program.pcrPid;
112 ePtr<iDVBDemux> demux;
113 m_serviceHandler.getDemux(demux);
115 demux->getMPEGDecoder(m_decoder);
120 m_decoder->setVideoPID(vpid);
121 m_decoder->setAudioPID(apid, 0);
122 m_decoder->setSyncPCR(pcrpid);
131 RESULT eDVBServicePlay::start()
133 eDebug("starting DVB service");
134 return m_serviceHandler.tune((eServiceReferenceDVB&)m_reference);
137 RESULT eDVBServicePlay::stop()
139 eDebug("stopping..");
143 RESULT eDVBServicePlay::connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection)
148 RESULT eDVBServicePlay::getIPausableService(ePtr<iPauseableService> &ptr)
150 // not yet possible, maybe later...
155 RESULT eDVBServicePlay::getIServiceInformation(ePtr<iServiceInformation> &ptr)
161 RESULT eDVBServicePlay::getName(eString &name)
163 name = "DVB service";
167 DEFINE_REF(eDVBServicePlay)
169 eAutoInitPtr<eServiceFactoryDVB> init_eServiceFactoryDVB(eAutoInitNumbers::service+1, "eServiceFactoryDVB");