add dynamic m3u playlist
[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 void eDVBServiceEITHandler::inject(ePtr<eServiceEvent> &event, int nownext)
36 {
37         if (nownext)
38                 m_event_next = event;
39         else
40                 m_event_now = event;
41         m_eit_changed();
42 }
43
44 eDVBServiceEITHandler::eDVBServiceEITHandler()
45 {
46         CONNECT(m_EIT.tableReady, eDVBServiceEITHandler::EITready);
47 }
48
49 void eDVBServiceEITHandler::start(iDVBDemux *demux, int sid)
50 {
51         m_EIT.begin(eApp, eDVBEITSpec(sid), demux);
52 }
53
54 void eDVBServiceEITHandler::startOther(iDVBDemux *demux, int sid)
55 {
56         m_EIT.begin(eApp, eDVBEITSpecOther(sid), demux);
57 }
58
59 RESULT eDVBServiceEITHandler::getEvent(ePtr<eServiceEvent> &event, int nownext)
60 {
61         event = nownext ? m_event_next : m_event_now;
62         if (!event)
63                 return -1;
64         return 0;
65 }