1 #include <lib/dvb/service.h>
3 #include <lib/base/i18n.h>
4 #include <lib/dvb/dvb.h>
5 #include <lib/system/init.h>
6 #include <lib/system/init_num.h>
7 #include <lib/system/econfig.h>
9 int eServiceHandler::flags
=0;
11 eServiceHandler::eServiceHandler(int id
): id(id
)
15 eServiceHandler::~eServiceHandler()
19 eService
*eServiceHandler::createService(const eServiceReference
&node
)
25 int eServiceHandler::play(const eServiceReference
&service
, int workaround
)
31 int eServiceHandler::serviceCommand(const eServiceCommand
&cmd
)
37 PMT
*eServiceHandler::getPMT()
42 void eServiceHandler::setPID(const PMTEntry
*)
47 SDT
*eServiceHandler::getSDT()
52 EIT
*eServiceHandler::getEIT()
57 int eServiceHandler::getFlags()
62 int eServiceHandler::getState()
67 int eServiceHandler::getAspectRatio()
72 int eServiceHandler::getErrorInfo()
77 int eServiceHandler::stop( int workaround
)
82 int eServiceHandler::getPosition(int)
87 void eServiceHandler::setAudioStream( unsigned int )
91 void eServiceHandler::enterDirectory(const eServiceReference
&dir
, Signal1
<void,const eServiceReference
&> &callback
)
98 void eServiceHandler::leaveDirectory(const eServiceReference
&dir
)
104 eService
*eServiceHandler::addRef(const eServiceReference
&service
)
110 void eServiceHandler::removeRef(const eServiceReference
&service
)
115 eString
eServiceHandler::getInfo(int id
)
121 eServiceInterface
*eServiceInterface::instance
;
123 eServiceInterface
*eServiceInterface::getInstance()
128 void eServiceInterface::handleServiceEvent(const eServiceEvent
&evt
)
133 int eServiceInterface::switchServiceHandler(int id
, int workaround
)
135 if (currentServiceHandler
&& (currentServiceHandler
->getID() == id
))
137 currentServiceHandler
->stop(workaround
);
142 eServiceHandler
*handler
=getServiceHandler(id
);
146 conn
=CONNECT(handler
->serviceEvent
, eServiceInterface::handleServiceEvent
);
147 currentServiceHandler
=handler
;
151 eServiceInterface::eServiceInterface()
153 currentServiceHandler
= 0;
158 eServiceInterface::~eServiceInterface()
160 if (instance
== this)
165 int eServiceInterface::registerHandler(int id
, eServiceHandler
*handler
)
167 if (handlers
.count(id
))
169 handlers
.insert(std::pair
<int,eServiceHandler
*>(id
, handler
));
173 int eServiceInterface::unregisterHandler(int id
)
175 std::map
<int,eServiceHandler
*>::iterator i
=handlers
.find(id
);
176 if (i
== handlers
.end())
178 if (i
->second
== currentServiceHandler
)
184 eServiceHandler
*eServiceInterface::getServiceHandler(int id
)
186 std::map
<int,eServiceHandler
*>::iterator i
=handlers
.find(id
);
187 if (i
== handlers
.end())
192 extern bool checkPin( int pin
, const char * text
);
194 int eServiceInterface::play(const eServiceReference
&s
)
199 int eServiceInterface::play(const eServiceReference
&s
, int workaround
)
201 int pLockActive
= eConfig::getInstance()->pLockActive();
202 if ( !workaround
&& s
.isLocked() && pLockActive
&& !checkPin( eConfig::getInstance()->getParentalPin(), _("parental") ) )
204 eWarning("service is parentallocked... don't play");
207 if (switchServiceHandler(s
.type
, workaround
))
209 eWarning("couldn't play service type %d", s
.type
);
213 return currentServiceHandler
->play(s
, workaround
);
216 int eServiceInterface::stop(int workaround
)
218 if (!currentServiceHandler
)
220 int res
=currentServiceHandler
->stop(workaround
);
222 currentServiceHandler
=0;
223 service
=eServiceReference();
227 void eServiceInterface::enterDirectory(const eServiceReference
&dir
, Signal1
<void,const eServiceReference
&> &callback
)
229 int pLockActive
= eConfig::getInstance()->pLockActive();
230 if ( dir
.isLocked() && pLockActive
&& !checkPin( eConfig::getInstance()->getParentalPin(), _("parental") ) )
232 eWarning("directory is parentallocked... don't enter");
235 for (std::map
<int,eServiceHandler
*>::iterator
i(handlers
.begin()); i
!= handlers
.end(); ++i
)
236 i
->second
->enterDirectory(dir
, callback
);
239 void eServiceInterface::leaveDirectory(const eServiceReference
&dir
)
241 for (std::map
<int,eServiceHandler
*>::iterator
i(handlers
.begin()); i
!= handlers
.end(); ++i
)
242 i
->second
->leaveDirectory(dir
);
245 eService
*eServiceInterface::addRef(const eServiceReference
&service
)
247 eServiceHandler
*handler
=getServiceHandler(service
.type
);
249 return handler
->addRef(service
);
254 void eServiceInterface::removeRef(const eServiceReference
&service
)
256 eServiceHandler
*handler
=getServiceHandler(service
.type
);
258 return handler
->removeRef(service
);
261 eAutoInitP0
<eServiceInterface
> i_eServiceInteface(eAutoInitNumbers::service
, "eServiceInterface");