add needed functions
[enigma2.git] / lib / dvb / eit.cpp
1 #include <lib/dvb/eit.h>
2 #include <lib/dvb/specs.h>
3 #include <lib/base/eerror.h>
4 #include <lib/service/event.h>
5
6 void eDVBServiceEITHandler::EITready(int error)
7 {
8         if (!error)
9         {
10                 ePtr<eTable<EventInformationSection> > ptr;
11                 if (!m_EIT.getCurrent(ptr))
12                 {
13                         int a = 0;
14                         for (std::vector<EventInformationSection*>::const_iterator i = ptr->getSections().begin();
15                                 i != ptr->getSections().end(); ++i)
16                         {
17                                 const EventInformationSection *eit = *i;
18                                 for (EventConstIterator ev = eit->getEvents()->begin(); ev != eit->getEvents()->end(); ++ev)
19                                 {
20                                         ePtr<eServiceEvent> evt = new eServiceEvent();
21                                         evt->parseFrom(*ev,(eit->getTransportStreamId()<<16)|eit->getOriginalNetworkId());
22                                         if (!a)
23                                                 m_event_now = evt;
24                                         else
25                                                 m_event_next = evt;
26                                         ++a;
27                                 }
28                         }
29                 }
30         }
31
32         m_eit_changed();
33 }
34
35 eDVBServiceEITHandler::eDVBServiceEITHandler()
36 {
37         CONNECT(m_EIT.tableReady, eDVBServiceEITHandler::EITready);
38 }
39
40 void eDVBServiceEITHandler::start(iDVBDemux *demux, int sid)
41 {
42         m_EIT.begin(eApp, eDVBEITSpec(sid), demux);
43 }
44
45 void eDVBServiceEITHandler::startOther(iDVBDemux *demux, int sid)
46 {
47         m_EIT.begin(eApp, eDVBEITSpecOther(sid), demux);
48 }
49
50 RESULT eDVBServiceEITHandler::getEvent(ePtr<eServiceEvent> &event, int nownext)
51 {
52         event = nownext ? m_event_next : m_event_now;
53         if (!event)
54                 return -1;
55         return 0;
56 }